Top Level Namespace

Defined Under Namespace

Classes: ACLIdASA, Appid56PanaL7Pen, Appid64PanaL7Pen, Appid72PanaL7Pen, Application_Id16, Application_Id24, Application_Id32, Application_Id40, Application_Id56, Application_Id64, Application_Id72, Forwarding_Status, Header, IP4Addr, IP6Addr, IpfixOptionFlowset, IpfixPDU, IpfixTemplateFlowset, MPLSLabelStackOctets, MacAddr, Netflow5PDU, Netflow9PDU, NetflowOptionFlowset, NetflowTemplateFlowset, OctetArray, VarSkip, VarString, Vash

Instance Method Summary collapse

Instance Method Details

#iana2bindata(type) ⇒ Object

Convert IANA types to those used by BinData or created by ourselves



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/logstash/codecs/netflow/iana2yaml.rb', line 8

def iana2bindata(type)
  case type
  when /^unsigned(\d+)$/
    return 'uint' + $1
  when /^signed(\d+)$/
    return 'int' + $1
  when 'float32'
    return 'float'
  when 'float64'
    return 'double'
  when 'ipv4Address'
    return 'ip4_addr'
  when 'ipv6Address'
    return 'ip6_addr'
  when 'macAddress'
    return 'mac_addr'
  when 'octetArray', 'string'
    return 'string'
  when 'dateTimeSeconds'
    return 'uint32'
  when 'dateTimeMilliseconds', 'dateTimeMicroseconds', 'dateTimeNanoseconds'
    return 'uint64'
  when 'boolean'
    return 'uint8'
  when 'basicList', 'subTemplateList', 'subTemplateMultiList'
    return 'skip'
  else
    raise "Unknown type #{type}"
  end
end

#iana2hash(url) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/logstash/codecs/netflow/iana2yaml.rb', line 39

def iana2hash(url)
  fields = { 0 => {} }

  # Read in IANA-registered Information Elements (PEN 0)
  CSV.new(open(url), :headers => :first_row, :converters => :numeric).each do |line|
    # If it's not a Fixnum it's something like 'x-y' used to mark reserved blocks
    next if line['ElementID'].class != Fixnum

    # Blacklisted ID's
    next if [0].include?(line['ElementID'])

    # Skip any elements with no name
    next unless line['Name'] and line['Data Type']

    fields[0][line['ElementID']] = [iana2bindata(line['Data Type']).to_sym]
    if fields[0][line['ElementID']][0] != :skip
      fields[0][line['ElementID']] << line['Name'].to_sym
    end
  end

  # Overrides
  fields[0][210][0] = :skip # 210 is PaddingOctets so skip them properly
  fields[0][210].delete_at(1)

  # Generate the reverse PEN (PEN 29305)
  reversed = fields[0].reject { |k|
    # Excluded according to RFC 5103
    [40,41,42,130,131,137,145,148,149,163,164,165,166,167,168,173,210,211,212,213,214,215,216,217,239].include?(k)
  }.map { |k,v|
    [k, v.size > 1 ? [v[0], ('reverse' + v[1].to_s.slice(0,1).capitalize + v[1].to_s.slice(1..-1)).to_sym] : [v[0]]]
  }
  fields[29305] = Hash[reversed]

  return fields
end