packetgen 3.1.3 → 3.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -1
  3. data/bin/pgconsole +1 -0
  4. data/lib/packetgen.rb +33 -4
  5. data/lib/packetgen/capture.rb +51 -28
  6. data/lib/packetgen/config.rb +17 -11
  7. data/lib/packetgen/deprecation.rb +33 -7
  8. data/lib/packetgen/header.rb +2 -9
  9. data/lib/packetgen/header/arp.rb +2 -2
  10. data/lib/packetgen/header/asn1_base.rb +2 -2
  11. data/lib/packetgen/header/base.rb +70 -74
  12. data/lib/packetgen/header/bootp.rb +3 -3
  13. data/lib/packetgen/header/dhcp.rb +2 -2
  14. data/lib/packetgen/header/dhcp/option.rb +2 -2
  15. data/lib/packetgen/header/dhcp/options.rb +2 -2
  16. data/lib/packetgen/header/dhcpv6.rb +12 -12
  17. data/lib/packetgen/header/dhcpv6/duid.rb +11 -5
  18. data/lib/packetgen/header/dhcpv6/option.rb +8 -16
  19. data/lib/packetgen/header/dhcpv6/options.rb +2 -2
  20. data/lib/packetgen/header/dhcpv6/relay.rb +2 -2
  21. data/lib/packetgen/header/dns.rb +9 -9
  22. data/lib/packetgen/header/dns/name.rb +20 -9
  23. data/lib/packetgen/header/dns/opt.rb +2 -2
  24. data/lib/packetgen/header/dns/option.rb +2 -2
  25. data/lib/packetgen/header/dns/qdsection.rb +3 -3
  26. data/lib/packetgen/header/dns/question.rb +37 -35
  27. data/lib/packetgen/header/dns/rr.rb +3 -3
  28. data/lib/packetgen/header/dns/rrsection.rb +2 -2
  29. data/lib/packetgen/header/dot11.rb +30 -51
  30. data/lib/packetgen/header/dot11/control.rb +5 -5
  31. data/lib/packetgen/header/dot11/data.rb +11 -7
  32. data/lib/packetgen/header/dot11/element.rb +16 -16
  33. data/lib/packetgen/header/dot11/management.rb +2 -2
  34. data/lib/packetgen/header/dot11/sub_mngt.rb +2 -12
  35. data/lib/packetgen/header/dot1q.rb +2 -2
  36. data/lib/packetgen/header/dot1x.rb +7 -20
  37. data/lib/packetgen/header/eap.rb +30 -33
  38. data/lib/packetgen/header/eap/fast.rb +2 -2
  39. data/lib/packetgen/header/eap/md5.rb +2 -2
  40. data/lib/packetgen/header/eap/tls.rb +2 -2
  41. data/lib/packetgen/header/eap/ttls.rb +2 -2
  42. data/lib/packetgen/header/eth.rb +13 -11
  43. data/lib/packetgen/header/gre.rb +2 -2
  44. data/lib/packetgen/header/http.rb +2 -0
  45. data/lib/packetgen/header/http/headers.rb +6 -4
  46. data/lib/packetgen/header/http/request.rb +36 -21
  47. data/lib/packetgen/header/http/response.rb +7 -7
  48. data/lib/packetgen/header/http/verbs.rb +3 -3
  49. data/lib/packetgen/header/icmp.rb +2 -2
  50. data/lib/packetgen/header/icmpv6.rb +2 -2
  51. data/lib/packetgen/header/igmp.rb +4 -4
  52. data/lib/packetgen/header/igmpv3.rb +3 -3
  53. data/lib/packetgen/header/igmpv3/group_record.rb +8 -6
  54. data/lib/packetgen/header/igmpv3/mq.rb +2 -2
  55. data/lib/packetgen/header/igmpv3/mr.rb +2 -2
  56. data/lib/packetgen/header/ip.rb +30 -31
  57. data/lib/packetgen/header/ip/addr.rb +10 -3
  58. data/lib/packetgen/header/ip/option.rb +8 -10
  59. data/lib/packetgen/header/ip/options.rb +3 -5
  60. data/lib/packetgen/header/ipv6.rb +2 -2
  61. data/lib/packetgen/header/ipv6/addr.rb +9 -2
  62. data/lib/packetgen/header/ipv6/extension.rb +2 -2
  63. data/lib/packetgen/header/ipv6/hop_by_hop.rb +3 -3
  64. data/lib/packetgen/header/llc.rb +2 -2
  65. data/lib/packetgen/header/mdns.rb +2 -2
  66. data/lib/packetgen/header/mld.rb +2 -2
  67. data/lib/packetgen/header/mldv2.rb +2 -2
  68. data/lib/packetgen/header/mldv2/mcast_address_record.rb +4 -2
  69. data/lib/packetgen/header/mldv2/mlq.rb +2 -2
  70. data/lib/packetgen/header/mldv2/mlr.rb +2 -2
  71. data/lib/packetgen/header/ospfv2.rb +9 -9
  72. data/lib/packetgen/header/ospfv2/db_description.rb +2 -2
  73. data/lib/packetgen/header/ospfv2/hello.rb +2 -2
  74. data/lib/packetgen/header/ospfv2/ls_ack.rb +2 -2
  75. data/lib/packetgen/header/ospfv2/ls_request.rb +4 -2
  76. data/lib/packetgen/header/ospfv2/ls_update.rb +2 -2
  77. data/lib/packetgen/header/ospfv2/lsa.rb +9 -5
  78. data/lib/packetgen/header/ospfv2/lsa_header.rb +8 -7
  79. data/lib/packetgen/header/ospfv3.rb +2 -2
  80. data/lib/packetgen/header/ospfv3/db_description.rb +2 -2
  81. data/lib/packetgen/header/ospfv3/hello.rb +2 -2
  82. data/lib/packetgen/header/ospfv3/ipv6_prefix.rb +4 -2
  83. data/lib/packetgen/header/ospfv3/ls_ack.rb +2 -2
  84. data/lib/packetgen/header/ospfv3/ls_request.rb +4 -2
  85. data/lib/packetgen/header/ospfv3/ls_update.rb +2 -2
  86. data/lib/packetgen/header/ospfv3/lsa.rb +5 -5
  87. data/lib/packetgen/header/ospfv3/lsa_header.rb +9 -8
  88. data/lib/packetgen/header/snmp.rb +33 -29
  89. data/lib/packetgen/header/tcp.rb +4 -23
  90. data/lib/packetgen/header/tcp/option.rb +11 -11
  91. data/lib/packetgen/header/tcp/options.rb +2 -2
  92. data/lib/packetgen/header/tftp.rb +6 -6
  93. data/lib/packetgen/header/udp.rb +3 -3
  94. data/lib/packetgen/headerable.rb +5 -4
  95. data/lib/packetgen/inject.rb +23 -0
  96. data/lib/packetgen/inspect.rb +23 -20
  97. data/lib/packetgen/packet.rb +82 -53
  98. data/lib/packetgen/pcap.rb +29 -0
  99. data/lib/packetgen/pcapng.rb +13 -13
  100. data/lib/packetgen/pcapng/block.rb +26 -13
  101. data/lib/packetgen/pcapng/epb.rb +25 -22
  102. data/lib/packetgen/pcapng/file.rb +260 -138
  103. data/lib/packetgen/pcapng/idb.rb +36 -38
  104. data/lib/packetgen/pcapng/shb.rb +51 -53
  105. data/lib/packetgen/pcapng/spb.rb +19 -19
  106. data/lib/packetgen/pcapng/unknown_block.rb +5 -13
  107. data/lib/packetgen/pcaprub_wrapper.rb +81 -0
  108. data/lib/packetgen/proto.rb +2 -2
  109. data/lib/packetgen/types.rb +3 -0
  110. data/lib/packetgen/types/abstract_tlv.rb +27 -7
  111. data/lib/packetgen/types/array.rb +22 -15
  112. data/lib/packetgen/types/cstring.rb +57 -20
  113. data/lib/packetgen/types/enum.rb +7 -2
  114. data/lib/packetgen/types/fieldable.rb +65 -0
  115. data/lib/packetgen/types/fields.rb +182 -117
  116. data/lib/packetgen/types/int.rb +18 -6
  117. data/lib/packetgen/types/int_string.rb +10 -2
  118. data/lib/packetgen/types/length_from.rb +20 -12
  119. data/lib/packetgen/types/oui.rb +4 -2
  120. data/lib/packetgen/types/string.rb +59 -8
  121. data/lib/packetgen/types/tlv.rb +4 -2
  122. data/lib/packetgen/utils.rb +4 -4
  123. data/lib/packetgen/utils/arp_spoofer.rb +2 -2
  124. data/lib/packetgen/version.rb +3 -3
  125. metadata +39 -61
  126. data/.gitignore +0 -13
  127. data/.rubocop.yml +0 -30
  128. data/.travis.yml +0 -19
  129. data/Gemfile +0 -4
  130. data/Rakefile +0 -21
  131. data/packetgen.gemspec +0 -36
@@ -1,10 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of PacketGen
2
4
  # See https://github.com/sdaubert/packetgen for more informations
3
5
  # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
4
6
  # This program is published under MIT license.
5
7
 
6
- # frozen_string_literal: true
7
-
8
8
  module PacketGen
9
9
  module Header
10
10
  class OSPFv2
@@ -1,10 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of PacketGen
2
4
  # See https://github.com/sdaubert/packetgen for more informations
3
5
  # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
4
6
  # This program is published under MIT license.
5
7
 
6
- # frozen_string_literal: true
7
-
8
8
  module PacketGen
9
9
  module Header
10
10
  class OSPFv2
@@ -1,10 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of PacketGen
2
4
  # See https://github.com/sdaubert/packetgen for more informations
3
5
  # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
4
6
  # This program is published under MIT license.
5
7
 
6
- # frozen_string_literal: true
7
-
8
8
  module PacketGen
9
9
  module Header
10
10
  class OSPFv2
@@ -1,10 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of PacketGen
2
4
  # See https://github.com/sdaubert/packetgen for more informations
3
5
  # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
4
6
  # This program is published under MIT license.
5
7
 
6
- # frozen_string_literal: true
7
-
8
8
  module PacketGen
9
9
  module Header
10
10
  class OSPFv2
@@ -14,6 +14,8 @@ module PacketGen
14
14
  # * and {#advertising_router}.
15
15
  # @author Sylvain Daubert
16
16
  class LSR < Types::Fields
17
+ include Types::Fieldable
18
+
17
19
  # @!attribute type
18
20
  # The type of the LSA to request.
19
21
  # @return [Integer]
@@ -1,10 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of PacketGen
2
4
  # See https://github.com/sdaubert/packetgen for more informations
3
5
  # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
4
6
  # This program is published under MIT license.
5
7
 
6
- # frozen_string_literal: true
7
-
8
8
  module PacketGen
9
9
  module Header
10
10
  class OSPFv2
@@ -1,10 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of PacketGen
2
4
  # See https://github.com/sdaubert/packetgen for more informations
3
5
  # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
4
6
  # This program is published under MIT license.
5
7
 
6
- # frozen_string_literal: true
7
-
8
8
  module PacketGen
9
9
  module Header
10
10
  class OSPFv2
@@ -23,6 +23,8 @@ module PacketGen
23
23
  # LSA router payload}.
24
24
  # @author Sylvain Daubert
25
25
  class TosMetric < Types::Fields
26
+ include Types::Fieldable
27
+
26
28
  # @!attribute tos
27
29
  # 8-bit IP Type of Service that this metric refers to.
28
30
  # @return [Integer]
@@ -52,6 +54,8 @@ module PacketGen
52
54
  # This class handles links in a {LSARouter LSA router payload}.
53
55
  # @author Sylvain Daubert
54
56
  class Link < Types::Fields
57
+ include Types::Fieldable
58
+
55
59
  # @!attribute id
56
60
  # @return [IP::Addr]
57
61
  define_field :id, IP::Addr
@@ -136,6 +140,8 @@ module PacketGen
136
140
  # This class handles external links in {LSAASExternal LSA AS-External payloads}.
137
141
  # @author Sylvain Daubert
138
142
  class External < Types::Fields
143
+ include Types::Fieldable
144
+
139
145
  # @!attribute u8
140
146
  # @return [Integer]
141
147
  define_field :u8, Types::Int8
@@ -204,9 +210,7 @@ module PacketGen
204
210
  private
205
211
 
206
212
  def record_from_hash(hsh)
207
- unless hsh.key? :type
208
- raise ArgumentError, 'hash should have :type key'
209
- end
213
+ raise ArgumentError, 'hash should have :type key' unless hsh.key? :type
210
214
 
211
215
  klass = if @only_headers
212
216
  LSAHeader
@@ -1,10 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of PacketGen
2
4
  # See https://github.com/sdaubert/packetgen for more informations
3
5
  # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
4
6
  # This program is published under MIT license.
5
7
 
6
- # frozen_string_literal: true
7
-
8
8
  module PacketGen
9
9
  module Header
10
10
  class OSPFv2
@@ -29,13 +29,15 @@ module PacketGen
29
29
  # is also a base class for different LSA class, as {LSARouter}.
30
30
  # @author Sylvain Daubert
31
31
  class LSAHeader < Types::Fields
32
+ include Types::Fieldable
33
+
32
34
  # LSA Types
33
35
  TYPES = {
34
- 'Router' => 1,
35
- 'Network' => 2,
36
- 'Summary-IP' => 3,
36
+ 'Router' => 1,
37
+ 'Network' => 2,
38
+ 'Summary-IP' => 3,
37
39
  'Summary-ABSR' => 4,
38
- 'AS-External' => 5
40
+ 'AS-External' => 5
39
41
  }.freeze
40
42
 
41
43
  # @!attribute age
@@ -75,7 +77,6 @@ module PacketGen
75
77
  # Compute and set Fletcher-16 checksum on LSA
76
78
  # @return [Integer]
77
79
  def calc_checksum
78
- self.checksum = 0
79
80
  bytes = to_s[2..-1].unpack('C*')
80
81
 
81
82
  c0 = c1 = 0
@@ -1,10 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of PacketGen
2
4
  # See https://github.com/sdaubert/packetgen for more informations
3
5
  # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
4
6
  # This program is published under MIT license.
5
7
 
6
- # frozen_string_literal: true
7
-
8
8
  module PacketGen
9
9
  module Header
10
10
  # This class supports OSPFv3 (RFC 5340).
@@ -1,10 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of PacketGen
2
4
  # See https://github.com/sdaubert/packetgen for more informations
3
5
  # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
4
6
  # This program is published under MIT license.
5
7
 
6
- # frozen_string_literal: true
7
-
8
8
  module PacketGen
9
9
  module Header
10
10
  class OSPFv3
@@ -1,10 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of PacketGen
2
4
  # See https://github.com/sdaubert/packetgen for more informations
3
5
  # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
4
6
  # This program is published under MIT license.
5
7
 
6
- # frozen_string_literal: true
7
-
8
8
  module PacketGen
9
9
  module Header
10
10
  class OSPFv3
@@ -1,10 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of PacketGen
2
4
  # See https://github.com/sdaubert/packetgen for more informations
3
5
  # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
4
6
  # This program is published under MIT license.
5
7
 
6
- # frozen_string_literal: true
7
-
8
8
  module PacketGen
9
9
  module Header
10
10
  class OSPFv3
@@ -17,6 +17,8 @@ module PacketGen
17
17
  # array consumes ((PrefixLength + 31) / 32) 32-bit words.
18
18
  # @author Sylvain Daubert
19
19
  class IPv6Prefix < Types::Fields
20
+ include Types::Fieldable
21
+
20
22
  # @!attribute length
21
23
  # Prefix length, in bits
22
24
  # @return [Integer]
@@ -1,10 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of PacketGen
2
4
  # See https://github.com/sdaubert/packetgen for more informations
3
5
  # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
4
6
  # This program is published under MIT license.
5
7
 
6
- # frozen_string_literal: true
7
-
8
8
  module PacketGen
9
9
  module Header
10
10
  class OSPFv3
@@ -1,10 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of PacketGen
2
4
  # See https://github.com/sdaubert/packetgen for more informations
3
5
  # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
4
6
  # This program is published under MIT license.
5
7
 
6
- # frozen_string_literal: true
7
-
8
8
  module PacketGen
9
9
  module Header
10
10
  class OSPFv3
@@ -27,6 +27,8 @@ module PacketGen
27
27
  # * and a 32-bit {#advertising_router} field.
28
28
  # @author Sylvain Daubert
29
29
  class LSR < Types::Fields
30
+ include Types::Fieldable
31
+
30
32
  # @!attribute reserved
31
33
  # reserved field.
32
34
  # @return [Integer]
@@ -1,10 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of PacketGen
2
4
  # See https://github.com/sdaubert/packetgen for more informations
3
5
  # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
4
6
  # This program is published under MIT license.
5
7
 
6
- # frozen_string_literal: true
7
-
8
8
  module PacketGen
9
9
  module Header
10
10
  class OSPFv3
@@ -1,16 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of PacketGen
2
4
  # See https://github.com/sdaubert/packetgen for more informations
3
5
  # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
4
6
  # This program is published under MIT license.
5
7
 
6
- # frozen_string_literal: true
7
-
8
8
  module PacketGen
9
9
  module Header
10
10
  class OSPFv3
11
11
  # This class handles links in a {LSARouter OSPFv3 LSA router payload}.
12
12
  # @author Sylvain Daubert
13
13
  class Link < Types::Fields
14
+ include Types::Fieldable
15
+
14
16
  # @!attribute type
15
17
  # @return [Integer]
16
18
  define_field :type, Types::Int8
@@ -197,9 +199,7 @@ module PacketGen
197
199
  private
198
200
 
199
201
  def record_from_hash(hsh)
200
- unless hsh.key? :type
201
- raise ArgumentError, 'hash should have :type key'
202
- end
202
+ raise ArgumentError, 'hash should have :type key' unless hsh.key? :type
203
203
 
204
204
  klass = if @only_headers
205
205
  LSAHeader
@@ -1,10 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of PacketGen
2
4
  # See https://github.com/sdaubert/packetgen for more informations
3
5
  # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
4
6
  # This program is published under MIT license.
5
7
 
6
- # frozen_string_literal: true
7
-
8
8
  module PacketGen
9
9
  module Header
10
10
  class OSPFv3
@@ -29,15 +29,17 @@ module PacketGen
29
29
  # But this class is also a base class for different LSA class, as {LSARouter}.
30
30
  # @author Sylvain Daubert
31
31
  class LSAHeader < Types::Fields
32
+ include Types::Fieldable
33
+
32
34
  # LSA known types
33
35
  TYPES = {
34
- 'Router' => 0x2001,
35
- 'Network' => 0x2002,
36
+ 'Router' => 0x2001,
37
+ 'Network' => 0x2002,
36
38
  'Inter-Area-Prefix' => 0x2003,
37
39
  'Inter-Area-Router' => 0x2004,
38
- 'AS-External' => 0x4005,
39
- 'NSSA' => 0x2007,
40
- 'Link' => 0x0008,
40
+ 'AS-External' => 0x4005,
41
+ 'NSSA' => 0x2007,
42
+ 'Link' => 0x0008,
41
43
  'Intra-Area-Prefix' => 0x2009
42
44
  }.freeze
43
45
 
@@ -76,7 +78,6 @@ module PacketGen
76
78
  # Compute and set Fletcher-16 checksum on LSA
77
79
  # @return [Integer]
78
80
  def calc_checksum
79
- self.checksum = 0
80
81
  bytes = to_s[2..-1].unpack('C*')
81
82
 
82
83
  c0 = c1 = 0
@@ -1,11 +1,11 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
3
+
2
4
  # This file is part of PacketGen
3
5
  # See https://github.com/sdaubert/packetgen for more informations
4
6
  # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
5
7
  # This program is published under MIT license.
6
8
 
7
- # frozen_string_literal: true
8
-
9
9
  module PacketGen
10
10
  module Header
11
11
  # Dissect error
@@ -22,6 +22,8 @@ module PacketGen
22
22
  # Configuration sinks listen to this port
23
23
  UDP_PORT2 = 162
24
24
 
25
+ # rubocop:disable Naming/ConstantName
26
+
25
27
  PDU_GET = 0
26
28
  PDU_NEXT = 1
27
29
  PDU_RESPONSE = 2
@@ -31,27 +33,28 @@ module PacketGen
31
33
  PDU_INFORM = 6
32
34
  PDU_TRAPv2 = 7
33
35
  PDU_REPORT = 8
36
+ # rubocop:enable Naming/ConstantName
34
37
 
35
38
  ERRORS = {
36
- 'no_error' => 0,
37
- 'too_big' => 1,
38
- 'no_such_name' => 2,
39
- 'bad_value' => 3,
40
- 'read_only' => 4,
41
- 'generic_error' => 5,
42
- 'no_access' => 6,
43
- 'wrong_type' => 7,
44
- 'wrong_length' => 8,
45
- 'wrong_encoding' => 9,
46
- 'wrong_value' => 10,
47
- 'no_creation' => 11,
48
- 'inconsistent_value' => 12,
39
+ 'no_error' => 0,
40
+ 'too_big' => 1,
41
+ 'no_such_name' => 2,
42
+ 'bad_value' => 3,
43
+ 'read_only' => 4,
44
+ 'generic_error' => 5,
45
+ 'no_access' => 6,
46
+ 'wrong_type' => 7,
47
+ 'wrong_length' => 8,
48
+ 'wrong_encoding' => 9,
49
+ 'wrong_value' => 10,
50
+ 'no_creation' => 11,
51
+ 'inconsistent_value' => 12,
49
52
  'ressource_unavailable' => 13,
50
- 'commit_failed' => 14,
51
- 'undo_failed' => 15,
52
- 'authorization_error' => 16,
53
- 'not_writable' => 17,
54
- 'inconsistent_name' => 18
53
+ 'commit_failed' => 14,
54
+ 'undo_failed' => 15,
55
+ 'authorization_error' => 16,
56
+ 'not_writable' => 17,
57
+ 'inconsistent_name' => 18
55
58
  }.freeze
56
59
 
57
60
  # Class to handle SNMP VarBind
@@ -162,13 +165,13 @@ module PacketGen
162
165
  implicit: SNMP::PDU_TRAPv1, constructed: true,
163
166
  content: [objectid(:enterprise),
164
167
  octet_string(:agent_addr),
165
- integer(:generic_trap, enum: { 'cold_start' => 0,
166
- 'warm_start' => 1,
167
- 'link_down' => 2,
168
- 'link_up' => 3,
169
- 'auth_failure' => 4,
168
+ integer(:generic_trap, enum: { 'cold_start' => 0,
169
+ 'warm_start' => 1,
170
+ 'link_down' => 2,
171
+ 'link_up' => 3,
172
+ 'auth_failure' => 4,
170
173
  'egp_neighbor_loss' => 5,
171
- 'specific' => 6 }),
174
+ 'specific' => 6 }),
172
175
  integer(:specific_trap),
173
176
  integer(:timestamp),
174
177
  model(:varbindlist, VariableBindings)]
@@ -243,7 +246,8 @@ module PacketGen
243
246
  end
244
247
 
245
248
  sequence :message,
246
- content: [integer(:version, value: 'v2c',
249
+ content: [integer(:version,
250
+ value: 'v2c',
247
251
  enum: { 'v1' => 0, 'v2c' => 1, 'v2' => 2, 'v3' => 3 }),
248
252
  octet_string(:community, value: 'public'),
249
253
  model(:data, PDUs)]
@@ -291,8 +295,8 @@ module PacketGen
291
295
  str << data.chosen_value.inspect(1)
292
296
  begin
293
297
  str << Inspect.inspect_body(self[:message].to_der, 'ASN.1 DER')
294
- rescue StandardError => ex
295
- raise unless ex.message =~ /TAG.*not handled/
298
+ rescue StandardError => e
299
+ raise unless e.message.match?(/TAG.*not handled/)
296
300
  end
297
301
  str
298
302
  end