packetgen 3.3.2 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +37 -21
  3. data/lib/packetgen/capture.rb +2 -2
  4. data/lib/packetgen/config.rb +0 -1
  5. data/lib/packetgen/deprecation.rb +7 -7
  6. data/lib/packetgen/header/arp.rb +13 -13
  7. data/lib/packetgen/header/asn1_base.rb +1 -1
  8. data/lib/packetgen/header/base.rb +17 -18
  9. data/lib/packetgen/header/bootp.rb +32 -34
  10. data/lib/packetgen/header/dhcp/option.rb +19 -19
  11. data/lib/packetgen/header/dhcp/options.rb +1 -1
  12. data/lib/packetgen/header/dhcp.rb +3 -3
  13. data/lib/packetgen/header/dhcpv6/duid.rb +16 -16
  14. data/lib/packetgen/header/dhcpv6/option.rb +53 -53
  15. data/lib/packetgen/header/dhcpv6/options.rb +1 -1
  16. data/lib/packetgen/header/dhcpv6/relay.rb +5 -5
  17. data/lib/packetgen/header/dhcpv6.rb +6 -6
  18. data/lib/packetgen/header/dns/name.rb +14 -10
  19. data/lib/packetgen/header/dns/opt.rb +2 -2
  20. data/lib/packetgen/header/dns/option.rb +11 -11
  21. data/lib/packetgen/header/dns/qdsection.rb +1 -1
  22. data/lib/packetgen/header/dns/question.rb +6 -8
  23. data/lib/packetgen/header/dns/rr.rb +56 -43
  24. data/lib/packetgen/header/dns/rrsection.rb +4 -4
  25. data/lib/packetgen/header/dns.rb +27 -30
  26. data/lib/packetgen/header/dot11/control.rb +11 -11
  27. data/lib/packetgen/header/dot11/data.rb +20 -20
  28. data/lib/packetgen/header/dot11/element.rb +4 -4
  29. data/lib/packetgen/header/dot11/management.rb +8 -8
  30. data/lib/packetgen/header/dot11/sub_mngt.rb +39 -53
  31. data/lib/packetgen/header/dot11.rb +88 -93
  32. data/lib/packetgen/header/dot1q.rb +10 -12
  33. data/lib/packetgen/header/dot1x.rb +9 -9
  34. data/lib/packetgen/header/eap/fast.rb +4 -4
  35. data/lib/packetgen/header/eap/md5.rb +6 -6
  36. data/lib/packetgen/header/eap/tls.rb +13 -15
  37. data/lib/packetgen/header/eap/ttls.rb +13 -15
  38. data/lib/packetgen/header/eap.rb +22 -22
  39. data/lib/packetgen/header/eth.rb +18 -18
  40. data/lib/packetgen/header/gre.rb +8 -10
  41. data/lib/packetgen/header/http/headers.rb +2 -2
  42. data/lib/packetgen/header/http/request.rb +17 -16
  43. data/lib/packetgen/header/http/response.rb +18 -17
  44. data/lib/packetgen/header/http/verbs.rb +1 -3
  45. data/lib/packetgen/header/icmp.rb +8 -8
  46. data/lib/packetgen/header/icmpv6.rb +3 -3
  47. data/lib/packetgen/header/igmp.rb +8 -8
  48. data/lib/packetgen/header/igmpv3/group_record.rb +12 -12
  49. data/lib/packetgen/header/igmpv3/mq.rb +16 -18
  50. data/lib/packetgen/header/igmpv3/mr.rb +4 -4
  51. data/lib/packetgen/header/igmpv3.rb +7 -7
  52. data/lib/packetgen/header/ip/addr.rb +13 -13
  53. data/lib/packetgen/header/ip/option.rb +31 -33
  54. data/lib/packetgen/header/ip/options.rb +1 -1
  55. data/lib/packetgen/header/ip.rb +37 -72
  56. data/lib/packetgen/header/ipv6/addr.rb +14 -14
  57. data/lib/packetgen/header/ipv6/extension.rb +8 -8
  58. data/lib/packetgen/header/ipv6/hop_by_hop.rb +9 -9
  59. data/lib/packetgen/header/ipv6.rb +20 -22
  60. data/lib/packetgen/header/llc.rb +17 -17
  61. data/lib/packetgen/header/mdns.rb +1 -1
  62. data/lib/packetgen/header/mld.rb +6 -6
  63. data/lib/packetgen/header/mldv2/mcast_address_record.rb +11 -11
  64. data/lib/packetgen/header/mldv2/mlq.rb +21 -23
  65. data/lib/packetgen/header/mldv2/mlr.rb +8 -8
  66. data/lib/packetgen/header/ospfv2/db_description.rb +11 -12
  67. data/lib/packetgen/header/ospfv2/hello.rb +11 -11
  68. data/lib/packetgen/header/ospfv2/ls_ack.rb +1 -1
  69. data/lib/packetgen/header/ospfv2/ls_request.rb +9 -9
  70. data/lib/packetgen/header/ospfv2/ls_update.rb +3 -3
  71. data/lib/packetgen/header/ospfv2/lsa.rb +54 -58
  72. data/lib/packetgen/header/ospfv2/lsa_header.rb +9 -9
  73. data/lib/packetgen/header/ospfv2.rb +27 -29
  74. data/lib/packetgen/header/ospfv3/db_description.rb +13 -14
  75. data/lib/packetgen/header/ospfv3/hello.rb +12 -12
  76. data/lib/packetgen/header/ospfv3/ipv6_prefix.rb +17 -19
  77. data/lib/packetgen/header/ospfv3/ls_ack.rb +2 -2
  78. data/lib/packetgen/header/ospfv3/ls_request.rb +9 -9
  79. data/lib/packetgen/header/ospfv3/ls_update.rb +4 -4
  80. data/lib/packetgen/header/ospfv3/lsa.rb +48 -51
  81. data/lib/packetgen/header/ospfv3/lsa_header.rb +9 -9
  82. data/lib/packetgen/header/ospfv3.rb +25 -27
  83. data/lib/packetgen/header/sctp/chunk.rb +44 -41
  84. data/lib/packetgen/header/sctp/error.rb +52 -52
  85. data/lib/packetgen/header/sctp/parameter.rb +38 -38
  86. data/lib/packetgen/header/sctp.rb +5 -5
  87. data/lib/packetgen/header/snmp.rb +2 -2
  88. data/lib/packetgen/header/tcp/option.rb +45 -39
  89. data/lib/packetgen/header/tcp/options.rb +2 -2
  90. data/lib/packetgen/header/tcp.rb +55 -44
  91. data/lib/packetgen/header/tftp.rb +16 -16
  92. data/lib/packetgen/header/udp.rb +8 -8
  93. data/lib/packetgen/header.rb +9 -10
  94. data/lib/packetgen/headerable.rb +13 -3
  95. data/lib/packetgen/inspect.rb +2 -2
  96. data/lib/packetgen/packet.rb +54 -37
  97. data/lib/packetgen/pcap.rb +15 -4
  98. data/lib/packetgen/pcapng/block.rb +18 -17
  99. data/lib/packetgen/pcapng/epb.rb +13 -15
  100. data/lib/packetgen/pcapng/file.rb +3 -97
  101. data/lib/packetgen/pcapng/idb.rb +9 -11
  102. data/lib/packetgen/pcapng/shb.rb +13 -15
  103. data/lib/packetgen/pcapng/spb.rb +8 -10
  104. data/lib/packetgen/pcapng/unknown_block.rb +6 -17
  105. data/lib/packetgen/pcapng.rb +4 -4
  106. data/lib/packetgen/pcaprub_wrapper.rb +17 -1
  107. data/lib/packetgen/proto.rb +1 -1
  108. data/lib/packetgen/unknown_packet.rb +2 -2
  109. data/lib/packetgen/utils/arp_spoofer.rb +18 -19
  110. data/lib/packetgen/utils.rb +2 -2
  111. data/lib/packetgen/version.rb +1 -1
  112. data/lib/packetgen.rb +4 -3
  113. metadata +34 -29
  114. data/lib/packetgen/types/abstract_tlv.rb +0 -278
  115. data/lib/packetgen/types/array.rb +0 -287
  116. data/lib/packetgen/types/cstring.rb +0 -109
  117. data/lib/packetgen/types/enum.rb +0 -171
  118. data/lib/packetgen/types/fieldable.rb +0 -66
  119. data/lib/packetgen/types/fields.rb +0 -622
  120. data/lib/packetgen/types/int.rb +0 -473
  121. data/lib/packetgen/types/int_string.rb +0 -102
  122. data/lib/packetgen/types/length_from.rb +0 -54
  123. data/lib/packetgen/types/oui.rb +0 -52
  124. data/lib/packetgen/types/string.rb +0 -97
  125. data/lib/packetgen/types/tlv.rb +0 -161
  126. data/lib/packetgen/types.rb +0 -26
@@ -42,20 +42,20 @@ module PacketGen
42
42
  # @!attribute type
43
43
  # 8-bit SCTP chunk type
44
44
  # @return [Integer]
45
- define_field :type, Types::Int8Enum, enum: TYPES
45
+ define_attr :type, BinStruct::Int8Enum, enum: TYPES
46
46
  # @!attribute type
47
47
  # 8-bit SCTP chunk flags
48
48
  # @return [Integer]
49
- define_field :flags, Types::Int8
49
+ define_attr :flags, BinStruct::Int8
50
50
  # @!attribute length
51
51
  # 16-bit SCTP chunk length
52
52
  # @return [Integer]
53
- define_field :length, Types::Int16
53
+ define_attr :length, BinStruct::Int16
54
54
 
55
55
  # Get human-redable chunk
56
56
  # @return [::String]
57
57
  def to_human
58
- str = +"<chunk:#{human_type}"
58
+ str = "<chunk:#{human_type}"
59
59
  flags_str = flags_to_human
60
60
  str << ",flags:#{flags_str}" unless flags_str.empty?
61
61
  str << '>'
@@ -91,7 +91,7 @@ module PacketGen
91
91
  class SCTP
92
92
  # Embed chunks for a given {SCTP} packet.
93
93
  # @author Sylvain Daubert
94
- class ArrayOfChunk < Types::Array
94
+ class ArrayOfChunk < BinStruct::Array
95
95
  set_of BaseChunk
96
96
 
97
97
  private
@@ -121,7 +121,7 @@ module PacketGen
121
121
  # @!attribute body
122
122
  # SCTP chunk value
123
123
  # @return [String]
124
- define_field :body, Types::String, builder: ->(h, t) { t.new(length_from: -> { h.length - 4 }) }
124
+ define_attr :body, BinStruct::String, builder: ->(h, t) { t.new(length_from: -> { h.length - 4 }) }
125
125
  end
126
126
 
127
127
  # Data chunk
@@ -145,37 +145,38 @@ module PacketGen
145
145
  # @!attribute tsn
146
146
  # 32-bit TSN for this DATA chunk
147
147
  # @return [Integer]
148
- define_field :tsn, Types::Int32
148
+ define_attr :tsn, BinStruct::Int32
149
149
  # @!attribute stream_id
150
150
  # 16-bit stream identifier
151
151
  # @return [Integer]
152
- define_field :stream_id, Types::Int16
152
+ define_attr :stream_id, BinStruct::Int16
153
153
  # @!attribute stream_sn
154
154
  # 16-bit stream sequence number
155
155
  # @return [Integer]
156
- define_field :stream_sn, Types::Int16
156
+ define_attr :stream_sn, BinStruct::Int16
157
157
  # @!attribute ppid
158
158
  # 32-bit payload protocol identifier
159
159
  # @return [Integer]
160
- define_field :ppid, Types::Int32
160
+ define_attr :ppid, BinStruct::Int32
161
161
  # @!attribute body
162
162
  # SCTP chunk value
163
163
  # @return [String]
164
- define_field :body, Types::String, builder: ->(h, t) { t.new(length_from: -> { h.length - 4 }) }
164
+ define_attr :body, BinStruct::String, builder: ->(h, t) { t.new(length_from: -> { h.length - 4 }) }
165
165
 
166
+ remove_attr :flags
166
167
  # @!attribute flag_i
167
168
  # IMMEDIATE flag
168
- # @return [Boolean]
169
+ # @return [Integer]
169
170
  # @!attribute flag_u
170
171
  # UNORDERED flag
171
- # @return [Boolean]
172
+ # @return [Integer]
172
173
  # @!attribute flag_b
173
174
  # BEGINNING fragment flag
174
- # @return [Boolean]
175
+ # @return [Integer]
175
176
  # @!attribute flag_e
176
177
  # ENDING fragment flag
177
- # @return [Boolean]
178
- define_bit_fields_on :flags, :flag_res, 4, :flag_i, :flag_u, :flag_b, :flag_e
178
+ # @return [Integer]
179
+ define_bit_attr_after :type, :flags, flag_res: 4, flag_i: 1, flag_u: 1, flag_b: 1, flag_e: 1
179
180
 
180
181
  private
181
182
 
@@ -212,27 +213,27 @@ module PacketGen
212
213
  # @!attribute initiate_tag
213
214
  # 32-bit Initiate Tag
214
215
  # @return [Integer]
215
- define_field :initiate_tag, Types::Int32
216
+ define_attr :initiate_tag, BinStruct::Int32
216
217
  # @!attribute a_wrnd
217
218
  # 32-bit Advertised Receiver Window Credit (a_rwnd)
218
219
  # @return [Integer]
219
- define_field :a_rwnd, Types::Int32
220
+ define_attr :a_rwnd, BinStruct::Int32
220
221
  # @!attribute nos
221
222
  # 16-bit Number of Outbound Streams
222
223
  # @return [Integer]
223
- define_field :nos, Types::Int16
224
+ define_attr :nos, BinStruct::Int16
224
225
  # @!attribute nis
225
226
  # 16-bit Number of Inbound Streams
226
227
  # @return [Integer]
227
- define_field :nis, Types::Int16
228
+ define_attr :nis, BinStruct::Int16
228
229
  # @!attribute initial_tsn
229
230
  # 32-bit Initial TSN
230
231
  # @return [Integer]
231
- define_field :initial_tsn, Types::Int32
232
+ define_attr :initial_tsn, BinStruct::Int32
232
233
  # @!attribute parameters
233
234
  # List of parameters
234
235
  # @return [ArrayOfParameter]
235
- define_field :parameters, ArrayOfParameter
236
+ define_attr :parameters, ArrayOfParameter
236
237
 
237
238
  def initialize(options={})
238
239
  options[:type] = BaseChunk::TYPES['INIT'] unless options.key?(:type)
@@ -248,7 +249,7 @@ module PacketGen
248
249
 
249
250
  # @return [::String]
250
251
  def to_human
251
- str = +"<chunk:#{human_type}"
252
+ str = "<chunk:#{human_type}"
252
253
  flags_str = flags_to_human
253
254
  str << ",flags:#{flags_str}" unless flags_str.empty?
254
255
  str << ",param:#{parameters.map(&:to_human).join(',')}" unless parameters.empty?
@@ -315,28 +316,28 @@ module PacketGen
315
316
  # @!attribute ctsn_ack
316
317
  # 32-bit Cumulative TSN Ack
317
318
  # @return [Integer]
318
- define_field :ctsn_ack, Types::Int32
319
+ define_attr :ctsn_ack, BinStruct::Int32
319
320
  # @!attribute a_rwnd
320
321
  # 32-bit Advertised Receiver Window Credit
321
322
  # @return [Integer]
322
- define_field :a_rwnd, Types::Int32
323
+ define_attr :a_rwnd, BinStruct::Int32
323
324
  # @!attribute num_gap
324
325
  # 16-bit Number of Gap Ack Blocks
325
326
  # @return [Integer]
326
- define_field :num_gap, Types::Int32
327
+ define_attr :num_gap, BinStruct::Int32
327
328
  # @!attribute num_dup_tsn
328
329
  # 16-bit Number of Duplicate TSNs
329
330
  # @return [Integer]
330
- define_field :num_dup_tsn, Types::Int32
331
+ define_attr :num_dup_tsn, BinStruct::Int32
331
332
  # @!attribute gaps
332
333
  # Array of 32-bit Integers, encoding boudaries of a Gap Ack Block.
333
334
  # 16 most significant bits encode block start. 16 least significant bits encode block end.
334
- # @return [Types::ArrayOfInt32]
335
- define_field :gaps, Types::ArrayOfInt32
335
+ # @return [BinStruct::ArrayOfInt32]
336
+ define_attr :gaps, BinStruct::ArrayOfInt32
336
337
  # @!attribute dup_tsns
337
338
  # Array of 32-bit Duplicate TSNs.
338
- # @return [Types::ArrayOfInt32]
339
- define_field :dup_tsns, Types::ArrayOfInt32
339
+ # @return [BinStruct::ArrayOfInt32]
340
+ define_attr :dup_tsns, BinStruct::ArrayOfInt32
340
341
 
341
342
  def initialize(options={})
342
343
  options[:type] = BaseChunk::TYPES['SACK'] unless options.key?(:type)
@@ -358,8 +359,8 @@ module PacketGen
358
359
  class HeartbeatChunk < BaseChunk
359
360
  # @!attribute info
360
361
  # Array of Heartbeat information TLV.
361
- # @return [Types::ArrayOfInt32]
362
- define_field :info, HearbeatInfoParameter
362
+ # @return [BinStruct::ArrayOfInt32]
363
+ define_attr :info, HearbeatInfoParameter
363
364
 
364
365
  def initialize(options={})
365
366
  options[:type] = BaseChunk::TYPES['HEARTBEAT'] unless options.key?(:type)
@@ -399,7 +400,7 @@ module PacketGen
399
400
  class ErrorChunk < BaseChunk
400
401
  # @!attribute error_causes
401
402
  # @return [ArrayofError]
402
- define_field :error_causes, ArrayOfError
403
+ define_attr :error_causes, ArrayOfError
403
404
 
404
405
  def initialize(options={})
405
406
  options[:type] = BaseChunk::TYPES['ERROR'] unless options.key?(:type)
@@ -415,7 +416,7 @@ module PacketGen
415
416
 
416
417
  # @return [::String]
417
418
  def to_human
418
- str = +"<chunk:#{human_type}"
419
+ str = "<chunk:#{human_type}"
419
420
  flags_str = flags_to_human
420
421
  str << ",flags:#{flags_str}" unless flags_str.empty?
421
422
  str << ",causes:#{error_causes.map(&:to_human).join(',')}" unless error_causes.empty?
@@ -435,9 +436,10 @@ module PacketGen
435
436
  # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
436
437
  # @author Sylvain Daubert
437
438
  class AbortChunk < ErrorChunk
439
+ remove_attr :flags
438
440
  # @!attribute flag_t
439
- # @return [Boolean]
440
- define_bit_fields_on :flags, :flag_res, 7, :flag_t
441
+ # @return [Integer]
442
+ define_bit_attr_after :type, :flags, flag_res: 7, flag_t: 1
441
443
 
442
444
  def initialize(options={})
443
445
  options[:type] = BaseChunk::TYPES['ABORT'] unless options.key?(:type)
@@ -464,7 +466,7 @@ module PacketGen
464
466
  # @!attribute cstn_ack
465
467
  # 32-bit cumulative TSN ack
466
468
  # @return [Integer]
467
- define_field :ctsn_ack, Types::Int32
469
+ define_attr :ctsn_ack, BinStruct::Int32
468
470
 
469
471
  def initialize(options={})
470
472
  options[:type] = BaseChunk::TYPES['SHUTDOWN'] unless options.key?(:type)
@@ -501,7 +503,7 @@ module PacketGen
501
503
  class CookieEchoChunk < BaseChunk
502
504
  # @!attribute cookie
503
505
  # @return [String]
504
- define_field :cookie, Types::String
506
+ define_attr :cookie, BinStruct::String
505
507
 
506
508
  def initialize(options={})
507
509
  options[:type] = BaseChunk::TYPES['COOKIE_ECHO'] unless options.key?(:type)
@@ -532,9 +534,10 @@ module PacketGen
532
534
  # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
533
535
  # @author Sylvain Daubert
534
536
  class ShutdownCompleteChunk < BaseChunk
537
+ remove_attr :flags
535
538
  # @!attribute flag_t
536
- # @return [Boolean]
537
- define_bit_fields_on :flags, :flag_res, 7, :flag_t
539
+ # @return [Integer]
540
+ define_bit_attr_after :type, :flags, flag_res: 7, flag_t: 1
538
541
 
539
542
  def initialize(options={})
540
543
  options[:type] = BaseChunk::TYPES['SHUTDOWN_COMPLETE'] unless options.key?(:type)
@@ -26,9 +26,9 @@ module PacketGen
26
26
  end
27
27
  end
28
28
 
29
- Error = Types::AbstractTLV.create(type_class: Types::Int16Enum,
30
- length_class: Types::Int16,
31
- field_in_length: 'TLV')
29
+ Error = BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
30
+ length_class: BinStruct::Int16,
31
+ attr_in_length: 'TLV')
32
32
 
33
33
  # Base class/factory for {AbortChunk} and {ErrorChunk} error causes
34
34
  # @author Sylvain Daubert
@@ -65,7 +65,7 @@ module PacketGen
65
65
 
66
66
  # Handle array of {Error} and {ErrorMixin} classes.
67
67
  # @author Sylvain Daubert
68
- class ArrayOfError < Types::Array
68
+ class ArrayOfError < BinStruct::Array
69
69
  set_of Error
70
70
 
71
71
  private
@@ -83,10 +83,10 @@ module PacketGen
83
83
  end
84
84
  end
85
85
 
86
- InvalidStreamIdError = Types::AbstractTLV.create(type_class: Types::Int16Enum,
87
- length_class: Types::Int16,
88
- value_class: Types::Int32,
89
- field_in_length: 'TLV')
86
+ InvalidStreamIdError = BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
87
+ length_class: BinStruct::Int16,
88
+ value_class: BinStruct::Int32,
89
+ attr_in_length: 'TLV')
90
90
 
91
91
  # InvalidStreamIdentifier error
92
92
  # @author Sylvain Daubert
@@ -115,16 +115,16 @@ module PacketGen
115
115
  # @param [Integer] val
116
116
  def from_human(val)
117
117
  super
118
- self.value <<= 16 if self[:value] < Types::Int
118
+ self.value <<= 16 if self[:value] < BinStruct::Int
119
119
  end
120
120
  end
121
121
  InvalidStreamIdError.define_type_enum(Error::TYPES)
122
122
  InvalidStreamIdError.define_type_default('InvalidStreamId')
123
123
 
124
- MissingMandatoryParameterError = Types::AbstractTLV.create(type_class: Types::Int16Enum,
125
- length_class: Types::Int16,
126
- value_class: Types::ArrayOfInt16,
127
- field_in_length: 'TLV')
124
+ MissingMandatoryParameterError = BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
125
+ length_class: BinStruct::Int16,
126
+ value_class: BinStruct::ArrayOfInt16,
127
+ attr_in_length: 'TLV')
128
128
 
129
129
  # MissingMandatoryParameter error. Indicate that one or more
130
130
  # mandatory TLV parameters are missing in a received {InitChunk}
@@ -141,10 +141,10 @@ module PacketGen
141
141
  MissingMandatoryParameterError.define_type_enum(Error::TYPES)
142
142
  MissingMandatoryParameterError.define_type_default('MissingMandatoryParameter')
143
143
 
144
- StaleCookieError = Types::AbstractTLV.create(type_class: Types::Int16Enum,
145
- length_class: Types::Int16,
146
- value_class: Types::Int32,
147
- field_in_length: 'TLV')
144
+ StaleCookieError = BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
145
+ length_class: BinStruct::Int16,
146
+ value_class: BinStruct::Int32,
147
+ attr_in_length: 'TLV')
148
148
 
149
149
  # StaleCookie error. Indicates the receipt of a valid State Cookie that
150
150
  # has expired.
@@ -155,9 +155,9 @@ module PacketGen
155
155
  StaleCookieError.define_type_enum(Error::TYPES)
156
156
  StaleCookieError.define_type_default('StaleCookie')
157
157
 
158
- OutOfResourceError = Types::AbstractTLV.create(type_class: Types::Int16Enum,
159
- length_class: Types::Int16,
160
- field_in_length: 'TLV')
158
+ OutOfResourceError = BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
159
+ length_class: BinStruct::Int16,
160
+ attr_in_length: 'TLV')
161
161
 
162
162
  # Out of ressource error. Indicates that the sender is out of resource.
163
163
  # @author Sylvain Daubert
@@ -172,10 +172,10 @@ module PacketGen
172
172
  OutOfResourceError.define_type_enum(Error::TYPES)
173
173
  OutOfResourceError.define_type_default('OutOfResource')
174
174
 
175
- UnresolvableAddressError = Types::AbstractTLV.create(type_class: Types::Int16Enum,
176
- length_class: Types::Int16,
177
- value_class: Parameter,
178
- field_in_length: 'TLV')
175
+ UnresolvableAddressError = BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
176
+ length_class: BinStruct::Int16,
177
+ value_class: Parameter,
178
+ attr_in_length: 'TLV')
179
179
 
180
180
  # Out of ressource error. Indicates that the sender is out of resource.
181
181
  # @author Sylvain Daubert
@@ -203,10 +203,10 @@ module PacketGen
203
203
  UnresolvableAddressError.define_type_enum(Error::TYPES)
204
204
  UnresolvableAddressError.define_type_default('UnresolvableAddress')
205
205
 
206
- UnrecognizedChunkTypeError = Types::AbstractTLV.create(type_class: Types::Int16Enum,
207
- length_class: Types::Int16,
208
- value_class: BaseChunk,
209
- field_in_length: 'TLV')
206
+ UnrecognizedChunkTypeError = BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
207
+ length_class: BinStruct::Int16,
208
+ value_class: BaseChunk,
209
+ attr_in_length: 'TLV')
210
210
 
211
211
  # Unrecognized chunk type error. The receiver does not understand the chunk and the upper bits of the 'Chunk Type'
212
212
  # are set to 01 or 11.
@@ -222,9 +222,9 @@ module PacketGen
222
222
  UnrecognizedChunkTypeError.define_type_enum(Error::TYPES)
223
223
  UnrecognizedChunkTypeError.define_type_default('UnrecognizedChunkType')
224
224
 
225
- InvalidMandatoryParameterError = Types::AbstractTLV.create(type_class: Types::Int16Enum,
226
- length_class: Types::Int16,
227
- field_in_length: 'TLV')
225
+ InvalidMandatoryParameterError = BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
226
+ length_class: BinStruct::Int16,
227
+ attr_in_length: 'TLV')
228
228
 
229
229
  # Invalid mandatory parameter error. Returned to the originator of an INIT or INIT ACK chunk when one of the
230
230
  # mandatory parameters is set to an invalid value.
@@ -240,10 +240,10 @@ module PacketGen
240
240
  InvalidMandatoryParameterError.define_type_enum(Error::TYPES)
241
241
  InvalidMandatoryParameterError.define_type_default('InvalidMandatoryParameter')
242
242
 
243
- UnrecognizedParametersError = Types::AbstractTLV.create(type_class: Types::Int16Enum,
244
- length_class: Types::Int16,
245
- value_class: ArrayOfParameter,
246
- field_in_length: 'TLV')
243
+ UnrecognizedParametersError = BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
244
+ length_class: BinStruct::Int16,
245
+ value_class: ArrayOfParameter,
246
+ attr_in_length: 'TLV')
247
247
 
248
248
  # Unrecognized parameters error. Returned to the originator of the INIT ACK chunk if the receiver does not
249
249
  # recognize one or more Optional TLV parameters in the INIT ACK chunk.
@@ -259,10 +259,10 @@ module PacketGen
259
259
  UnrecognizedParametersError.define_type_enum(Error::TYPES)
260
260
  UnrecognizedParametersError.define_type_default('UnrecognizedParameters')
261
261
 
262
- NoUserDataError = Types::AbstractTLV.create(type_class: Types::Int16Enum,
263
- length_class: Types::Int16,
264
- value_class: Types::Int32,
265
- field_in_length: 'TLV')
262
+ NoUserDataError = BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
263
+ length_class: BinStruct::Int16,
264
+ value_class: BinStruct::Int32,
265
+ attr_in_length: 'TLV')
266
266
 
267
267
  # No user data error. Returned when a received {DataChunk} was received with no data.
268
268
  # @author Sylvain Daubert
@@ -272,9 +272,9 @@ module PacketGen
272
272
  NoUserDataError.define_type_enum(Error::TYPES)
273
273
  NoUserDataError.define_type_default('NoUserData')
274
274
 
275
- CookieReceivedWhileShuttingDownError = Types::AbstractTLV.create(type_class: Types::Int16Enum,
276
- length_class: Types::Int16,
277
- field_in_length: 'TLV')
275
+ CookieReceivedWhileShuttingDownError = BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
276
+ length_class: BinStruct::Int16,
277
+ attr_in_length: 'TLV')
278
278
 
279
279
  # Cookie received while shutting down error.
280
280
  # A COOKIE ECHO chunk was received while the endpoint was in the SHUTDOWN-ACK-SENT state.
@@ -290,10 +290,10 @@ module PacketGen
290
290
  CookieReceivedWhileShuttingDownError.define_type_enum(Error::TYPES)
291
291
  CookieReceivedWhileShuttingDownError.define_type_default('CookieReceivedWhileShuttingDown')
292
292
 
293
- RestartAssociationWithNewAddressError = Types::AbstractTLV.create(type_class: Types::Int16Enum,
294
- length_class: Types::Int16,
295
- value_class: ArrayOfParameter,
296
- field_in_length: 'TLV')
293
+ RestartAssociationWithNewAddressError = BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
294
+ length_class: BinStruct::Int16,
295
+ value_class: ArrayOfParameter,
296
+ attr_in_length: 'TLV')
297
297
 
298
298
  # Cookie received while shutting down error.
299
299
  # A COOKIE ECHO chunk was received while the endpoint was in the SHUTDOWN-ACK-SENT state.
@@ -309,9 +309,9 @@ module PacketGen
309
309
  RestartAssociationWithNewAddressError.define_type_enum(Error::TYPES)
310
310
  RestartAssociationWithNewAddressError.define_type_default('RestartAssociationWithNewAddress')
311
311
 
312
- UserInitiatedAbortError = Types::AbstractTLV.create(type_class: Types::Int16Enum,
313
- length_class: Types::Int16,
314
- field_in_length: 'TLV')
312
+ UserInitiatedAbortError = BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
313
+ length_class: BinStruct::Int16,
314
+ attr_in_length: 'TLV')
315
315
 
316
316
  # User-Initiated abort error.
317
317
  # @author Sylvain Daubert
@@ -326,9 +326,9 @@ module PacketGen
326
326
  UserInitiatedAbortError.define_type_enum(Error::TYPES)
327
327
  UserInitiatedAbortError.define_type_default('UserInitiatedAbort')
328
328
 
329
- ProtocolViolationError = Types::AbstractTLV.create(type_class: Types::Int16Enum,
330
- length_class: Types::Int16,
331
- field_in_length: 'TLV')
329
+ ProtocolViolationError = BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
330
+ length_class: BinStruct::Int16,
331
+ attr_in_length: 'TLV')
332
332
 
333
333
  # Protocol violation error.
334
334
  # @author Sylvain Daubert
@@ -26,9 +26,9 @@ module PacketGen
26
26
  end
27
27
  end
28
28
 
29
- Parameter = Types::AbstractTLV.create(type_class: Types::Int16Enum,
30
- length_class: Types::Int16,
31
- field_in_length: 'TLV')
29
+ Parameter = BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
30
+ length_class: BinStruct::Int16,
31
+ attr_in_length: 'TLV')
32
32
  # Base class/factory for {InitChunk} and {InitAckChunk} parameters
33
33
  # @author Sylvain Daubert
34
34
  class Parameter
@@ -62,10 +62,10 @@ module PacketGen
62
62
  end
63
63
  Parameter.define_type_enum(Parameter::TYPES)
64
64
 
65
- IPv4Parameter = Types::AbstractTLV.create(type_class: Types::Int16Enum,
66
- length_class: Types::Int16,
67
- value_class: IP::Addr,
68
- field_in_length: 'TLV')
65
+ IPv4Parameter = BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
66
+ length_class: BinStruct::Int16,
67
+ value_class: IP::Addr,
68
+ attr_in_length: 'TLV')
69
69
 
70
70
  # IPv4 address parameter
71
71
  # @author Sylvain Daubert
@@ -75,10 +75,10 @@ module PacketGen
75
75
  IPv4Parameter.define_type_enum(Parameter::TYPES)
76
76
  IPv4Parameter.define_type_default('IPv4')
77
77
 
78
- IPv6Parameter = Types::AbstractTLV.create(type_class: Types::Int16Enum,
79
- length_class: Types::Int16,
80
- value_class: IPv6::Addr,
81
- field_in_length: 'TLV')
78
+ IPv6Parameter = BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
79
+ length_class: BinStruct::Int16,
80
+ value_class: IPv6::Addr,
81
+ attr_in_length: 'TLV')
82
82
 
83
83
  # IPv6 address parameter
84
84
  # @author Sylvain Daubert
@@ -88,10 +88,10 @@ module PacketGen
88
88
  IPv6Parameter.define_type_enum(Parameter::TYPES)
89
89
  IPv6Parameter.define_type_default('IPv6')
90
90
 
91
- StateCookieParameter = Types::AbstractTLV.create(type_class: Types::Int16Enum,
92
- length_class: Types::Int16,
93
- value_class: Types::String,
94
- field_in_length: 'TLV')
91
+ StateCookieParameter = BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
92
+ length_class: BinStruct::Int16,
93
+ value_class: BinStruct::String,
94
+ attr_in_length: 'TLV')
95
95
 
96
96
  # State Cookie parameter
97
97
  # @author Sylvain Daubert
@@ -106,10 +106,10 @@ module PacketGen
106
106
  StateCookieParameter.define_type_enum(Parameter::TYPES)
107
107
  StateCookieParameter.define_type_default('StateCookie')
108
108
 
109
- UnrecognizedParameter = Types::AbstractTLV.create(type_class: Types::Int16Enum,
110
- length_class: Types::Int16,
111
- value_class: Parameter,
112
- field_in_length: 'TLV')
109
+ UnrecognizedParameter = BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
110
+ length_class: BinStruct::Int16,
111
+ value_class: Parameter,
112
+ attr_in_length: 'TLV')
113
113
 
114
114
  # Unrecognized parameter
115
115
  # @author Sylvain Daubert
@@ -124,10 +124,10 @@ module PacketGen
124
124
  UnrecognizedParameter.define_type_enum(Parameter::TYPES)
125
125
  UnrecognizedParameter.define_type_default('Unrecognized')
126
126
 
127
- HostnameParameter = Types::AbstractTLV.create(type_class: Types::Int16Enum,
128
- length_class: Types::Int16,
129
- value_class: Types::CString,
130
- field_in_length: 'TLV')
127
+ HostnameParameter = BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
128
+ length_class: BinStruct::Int16,
129
+ value_class: BinStruct::CString,
130
+ attr_in_length: 'TLV')
131
131
 
132
132
  # Hostname address parameter
133
133
  # @author Sylvain Daubert
@@ -137,10 +137,10 @@ module PacketGen
137
137
  HostnameParameter.define_type_enum(Parameter::TYPES)
138
138
  HostnameParameter.define_type_default('Hostname')
139
139
 
140
- SupportedAddrTypesParameter = Types::AbstractTLV.create(type_class: Types::Int16Enum,
141
- length_class: Types::Int16,
142
- value_class: Types::ArrayOfInt16,
143
- field_in_length: 'TLV')
140
+ SupportedAddrTypesParameter = BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
141
+ length_class: BinStruct::Int16,
142
+ value_class: BinStruct::ArrayOfInt16,
143
+ attr_in_length: 'TLV')
144
144
 
145
145
  # Supported address types parameter
146
146
  # @author Sylvain Daubert
@@ -158,10 +158,10 @@ module PacketGen
158
158
  SupportedAddrTypesParameter.define_type_enum(Parameter::TYPES)
159
159
  SupportedAddrTypesParameter.define_type_default('SupportedAddrTypes')
160
160
 
161
- CookiePreservativeParameter = Types::AbstractTLV.create(type_class: Types::Int16Enum,
162
- length_class: Types::Int16,
163
- value_class: Types::Int32,
164
- field_in_length: 'TLV')
161
+ CookiePreservativeParameter = BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
162
+ length_class: BinStruct::Int16,
163
+ value_class: BinStruct::Int32,
164
+ attr_in_length: 'TLV')
165
165
 
166
166
  # Cookie Preservative parameter
167
167
  # @author Sylvain Daubert
@@ -176,9 +176,9 @@ module PacketGen
176
176
  CookiePreservativeParameter.define_type_enum(Parameter::TYPES)
177
177
  CookiePreservativeParameter.define_type_default('CookiePreservative')
178
178
 
179
- ECNParameter = Types::AbstractTLV.create(type_class: Types::Int16Enum,
180
- length_class: Types::Int16,
181
- field_in_length: 'TLV')
179
+ ECNParameter = BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
180
+ length_class: BinStruct::Int16,
181
+ attr_in_length: 'TLV')
182
182
 
183
183
  # ECN parameter
184
184
  # @author Sylvain Daubert
@@ -193,9 +193,9 @@ module PacketGen
193
193
  ECNParameter.define_type_enum(Parameter::TYPES)
194
194
  ECNParameter.define_type_default('ECN')
195
195
 
196
- HearbeatInfoParameter = Types::AbstractTLV.create(type_class: Types::Int16Enum,
197
- length_class: Types::Int16,
198
- field_in_length: 'TLV')
196
+ HearbeatInfoParameter = BinStruct::AbstractTLV.create(type_class: BinStruct::Int16Enum,
197
+ length_class: BinStruct::Int16,
198
+ attr_in_length: 'TLV')
199
199
 
200
200
  # Heartbeat Information parameter
201
201
  # @author Sylvain Daubert
@@ -207,7 +207,7 @@ module PacketGen
207
207
 
208
208
  # Array of {Parameter}s and {ParameterMixin}.
209
209
  # @author Sylvain Daubert
210
- class ArrayOfParameter < Types::Array
210
+ class ArrayOfParameter < BinStruct::Array
211
211
  set_of Parameter
212
212
 
213
213
  private
@@ -46,23 +46,23 @@ module PacketGen
46
46
  # @!attribute sport
47
47
  # 16-bit TCP source port
48
48
  # @return [Integer]
49
- define_field :sport, Types::Int16
49
+ define_attr :sport, BinStruct::Int16
50
50
  # @!attribute dport
51
51
  # 16-bit TCP destination port
52
52
  # @return [Integer]
53
- define_field :dport, Types::Int16
53
+ define_attr :dport, BinStruct::Int16
54
54
  # @!attribute verification_tag
55
55
  # 32-bit verification tag
56
56
  # @return [Integer]
57
- define_field :verification_tag, Types::Int32
57
+ define_attr :verification_tag, BinStruct::Int32
58
58
  # @!attribute checksum
59
59
  # 32-bit TCP checksum
60
60
  # @return [Integer]
61
- define_field :checksum, Types::Int32le
61
+ define_attr :checksum, BinStruct::Int32le
62
62
  # @!attribute chunks
63
63
  # List of chunks this packet transports
64
64
  # @return [ArrayOfChunk]
65
- define_field :chunks, ArrayOfChunk
65
+ define_attr :chunks, ArrayOfChunk
66
66
 
67
67
  # Compute SCTP checksum
68
68
  def calc_checksum
@@ -286,7 +286,7 @@ module PacketGen
286
286
  end
287
287
 
288
288
  # accessor to data payload
289
- # @return [ASN1::Types::Choice]
289
+ # @return [ASN1::BinStruct::Choice]
290
290
  def data
291
291
  @elements[:data]
292
292
  end
@@ -319,7 +319,7 @@ module PacketGen
319
319
  # @since 2.7.0 Set UDP sport according to bindings, only if sport is 0.
320
320
  # Needed by new bind API.
321
321
  def added_to_packet(packet)
322
- return unless packet.is? 'UDP'
322
+ return unless packet.is?('UDP')
323
323
  return unless packet.udp.sport.zero?
324
324
 
325
325
  packet.udp.sport = packet.udp.dport