packetgen-plugin-ipsec 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,260 +1,263 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
3
+
2
4
  # This file is part of IPsec packetgen plugin.
3
5
  # See https://github.com/sdaubert/packetgen-plugin-ipsec for more informations
4
6
  # Copyright (c) 2018 Sylvain Daubert <sylvain.daubert@laposte.net>
5
7
  # This program is published under MIT license.
6
8
 
7
- # frozen_string_literal: true
9
+ module PacketGen::Plugin
10
+ class IKE
11
+ # TrafficSelector substructure, as defined in RFC 7296, §3.13.1:
12
+ # 1 2 3
13
+ # 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
14
+ # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
15
+ # | TS Type |IP Protocol ID*| Selector Length |
16
+ # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
17
+ # | Start Port* | End Port* |
18
+ # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
19
+ # | |
20
+ # ~ Starting Address* ~
21
+ # | |
22
+ # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
23
+ # | |
24
+ # ~ Ending Address* ~
25
+ # | |
26
+ # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27
+ # @author Sylvain Daubert
28
+ class TrafficSelector < BinStruct::Struct
29
+ # IPv4 traffic selector type
30
+ TS_IPV4_ADDR_RANGE = 7
31
+ # IPv6 traffic selector type
32
+ TS_IPV6_ADDR_RANGE = 8
8
33
 
9
- module PacketGen
10
- module Plugin
11
- class IKE
12
- # TrafficSelector substructure, as defined in RFC 7296, §3.13.1:
13
- # 1 2 3
14
- # 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
15
- # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
16
- # | TS Type |IP Protocol ID*| Selector Length |
17
- # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
18
- # | Start Port* | End Port* |
19
- # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
20
- # | |
21
- # ~ Starting Address* ~
22
- # | |
23
- # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
24
- # | |
25
- # ~ Ending Address* ~
26
- # | |
27
- # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
28
- # @author Sylvain Daubert
29
- class TrafficSelector < PacketGen::Types::Fields
30
- # IPv4 traffic selector type
31
- TS_IPV4_ADDR_RANGE = 7
32
- # IPv6 traffic selector type
33
- TS_IPV6_ADDR_RANGE = 8
34
+ # @!attribute [r] type
35
+ # 8-bit TS type
36
+ # @return [Integer]
37
+ define_attr :type, BinStruct::Int8, default: 7
38
+ # @!attribute [r] protocol
39
+ # 8-bit protocol ID
40
+ # @return [Integer]
41
+ define_attr :protocol, BinStruct::Int8, default: 0
42
+ # @!attribute length
43
+ # 16-bit Selector Length
44
+ # @return [Integer]
45
+ define_attr :length, BinStruct::Int16
46
+ # @!attribute start_port
47
+ # 16-bit Start port
48
+ # @return [Integer]
49
+ define_attr :start_port, BinStruct::Int16, default: 0
50
+ # @!attribute end_port
51
+ # 16-bit End port
52
+ # @return [Integer]
53
+ define_attr :end_port, BinStruct::Int16, default: 65_535
54
+ # @!attribute start_addr
55
+ # starting address
56
+ # @return [IP::Addr, IPv6::Addr]
57
+ define_attr :start_addr, PacketGen::Header::IP::Addr
58
+ # @!attribute end_addr
59
+ # starting address
60
+ # @return [IP::Addr, IPv6::Addr]
61
+ define_attr :end_addr, PacketGen::Header::IP::Addr
34
62
 
35
- # @!attribute [r] type
36
- # 8-bit TS type
37
- # @return [Integer]
38
- define_field :type, PacketGen::Types::Int8, default: 7
39
- # @!attribute [r] protocol
40
- # 8-bit protocol ID
41
- # @return [Integer]
42
- define_field :protocol, PacketGen::Types::Int8, default: 0
43
- # @!attribute length
44
- # 16-bit Selector Length
45
- # @return [Integer]
46
- define_field :length, PacketGen::Types::Int16
47
- # @!attribute start_port
48
- # 16-bit Start port
49
- # @return [Integer]
50
- define_field :start_port, PacketGen::Types::Int16, default: 0
51
- # @!attribute end_port
52
- # 16-bit End port
53
- # @return [Integer]
54
- define_field :end_port, PacketGen::Types::Int16, default: 65_535
55
- # @!attribute start_addr
56
- # starting address
57
- # @return [IP::Addr, IPv6::Addr]
58
- define_field :start_addr, PacketGen::Header::IP::Addr
59
- # @!attribute end_addr
60
- # starting address
61
- # @return [IP::Addr, IPv6::Addr]
62
- define_field :end_addr, PacketGen::Header::IP::Addr
63
+ # @param [Hash] options
64
+ # @options[Integer] :type
65
+ # @options[Integer] :protocol
66
+ # @options[Integer] :length
67
+ # @option [String] :start_addr
68
+ # @option [String] :end_addr
69
+ # @option [Range] :ports port range
70
+ def initialize(options={}) # rubocop:disable Metrics/AbcSize
71
+ super
72
+ select_addr options
73
+ self[:start_addr].from_human(options[:start_addr]) if options[:start_addr]
74
+ self[:end_addr].from_human(options[:end_addr]) if options[:end_addr]
75
+ self.type = options[:type] if options[:type]
76
+ self.protocol = options[:protocol] if options[:protocol]
77
+ self[:length].value = sz unless options[:length]
78
+ return unless options[:ports]
63
79
 
64
- # @param [Hash] options
65
- # @option [Range] :ports port range
66
- # @option [Integer] :start_port start port
67
- # @option [Integer] :end_port end port
68
- def initialize(options={})
69
- super
70
- select_addr options
71
- self[:start_addr].from_human(options[:start_addr]) if options[:start_addr]
72
- self[:end_addr].from_human(options[:end_addr]) if options[:end_addr]
73
- self.type = options[:type] if options[:type]
74
- self.protocol = options[:protocol] if options[:protocol]
75
- self[:length].value = sz unless options[:length]
80
+ self.start_port = options[:ports].begin
81
+ self.end_port = options[:ports].end
82
+ end
76
83
 
77
- return unless options[:ports]
78
- self.start_port = options[:ports].begin
79
- self.end_port = options[:ports].end
80
- end
84
+ # Populate object from a string
85
+ # @param [String] str
86
+ # @return [self]
87
+ def read(str)
88
+ super
89
+ select_addr_from_type type
90
+ super
91
+ end
81
92
 
82
- # Populate object from a string
83
- # @param [String] str
84
- # @return [self]
85
- def read(str)
86
- super
87
- select_addr_from_type type
88
- super
89
- end
93
+ undef type=, protocol=
90
94
 
91
- undef type=, protocol=
95
+ # Set type
96
+ # @param [Integer,String] value
97
+ # @return [Integer]
98
+ def type=(value)
99
+ type = case value
100
+ when Integer
101
+ value
102
+ else
103
+ c = self.class.constants.grep(/TS_#{value.upcase}/).first
104
+ c ? self.class.const_get(c) : nil
105
+ end
106
+ raise ArgumentError, "unknown type #{value.inspect}" unless type
92
107
 
93
- # Set type
94
- # @param [Integer,String] value
95
- # @return [Integer]
96
- def type=(value)
97
- type = case value
98
- when Integer
99
- value
100
- else
101
- c = self.class.constants.grep(/TS_#{value.upcase}/).first
102
- c ? self.class.const_get(c) : nil
103
- end
104
- raise ArgumentError, "unknown type #{value.inspect}" unless type
105
- select_addr_from_type type
106
- self[:type].value = type
107
- end
108
+ select_addr_from_type type
109
+ self[:type].value = type
110
+ end
108
111
 
109
- # Set protocol
110
- # @param [Integer,String] value
111
- # @return [Integer]
112
- def protocol=(value)
113
- protocol = case value
114
- when Integer
115
- value
116
- else
117
- Proto.getprotobyname(value)
118
- end
119
- raise ArgumentError, "unknown protocol #{value.inspect}" unless protocol
120
- self[:protocol].value = protocol
121
- end
112
+ # Set protocol
113
+ # @param [Integer,String] value
114
+ # @return [Integer]
115
+ def protocol=(value)
116
+ protocol = case value
117
+ when Integer
118
+ value
119
+ else
120
+ PacketGen::Proto.getprotobyname(value)
121
+ end
122
+ raise ArgumentError, "unknown protocol #{value.inspect}" unless protocol
122
123
 
123
- # Get a human readable string
124
- # @return [String]
125
- def to_human
126
- h = start_addr << '-' << end_addr
127
- unless human_protocol.empty?
128
- h << "/#{human_protocol}"
129
- h << "[#{start_port}-#{end_port}]" if (start_port..end_port) != (0..65_535)
130
- end
131
- h
132
- end
124
+ self[:protocol].value = protocol
125
+ end
133
126
 
134
- # Get human readable protocol name. If protocol ID is 0, an empty string
135
- # is returned.
136
- # @return [String]
137
- def human_protocol
138
- if protocol.zero?
139
- ''
140
- else
141
- Proto.getprotobynumber(protocol) || protocol.to_s
142
- end
127
+ # Get a human readable string
128
+ # @return [String]
129
+ def to_human
130
+ h = start_addr << '-' << end_addr
131
+ unless human_protocol.empty?
132
+ h << "/#{human_protocol}"
133
+ h << "[#{start_port}-#{end_port}]" if (start_port..end_port) != (0..65_535)
143
134
  end
135
+ h
136
+ end
144
137
 
145
- # Get human readable TS type
146
- # @return [String]
147
- def human_type
148
- case type
149
- when TS_IPV4_ADDR_RANGE
150
- 'IPv4'
151
- when TS_IPV6_ADDR_RANGE
152
- 'IPv6'
153
- else
154
- "type #{type}"
155
- end
138
+ # Get human readable protocol name. If protocol ID is 0, an empty string
139
+ # is returned.
140
+ # @return [String]
141
+ def human_protocol
142
+ if protocol.zero?
143
+ ''
144
+ else
145
+ PacketGen::Proto.getprotobynumber(protocol) || protocol.to_s
156
146
  end
147
+ end
157
148
 
158
- private
159
-
160
- def select_addr_from_type(type)
161
- case type
162
- when TS_IPV4_ADDR_RANGE, 'IPV4', 'IPv4', 'ipv4', nil
163
- self[:start_addr] = PacketGen::Header::IP::Addr.new unless self[:start_addr].is_a?(PacketGen::Header::IP::Addr)
164
- self[:end_addr] = PacketGen::Header::IP::Addr.new unless self[:end_addr].is_a?(PacketGen::Header::IP::Addr)
165
- when TS_IPV6_ADDR_RANGE, 'IPV6', 'IPv6', 'ipv6'
166
- self[:start_addr] = PacketGen::Header::IPv6::Addr.new unless self[:start_addr].is_a?(PacketGen::Header::IPv6::Addr)
167
- self[:end_addr] = PacketGen::Header::IPv6::Addr.new unless self[:end_addr].is_a?(PacketGen::Header::IPv6::Addr)
168
- else
169
- raise ArgumentError, "unknown type #{type}"
170
- end
149
+ # Get human readable TS type
150
+ # @return [String]
151
+ def human_type
152
+ case type
153
+ when TS_IPV4_ADDR_RANGE
154
+ 'IPv4'
155
+ when TS_IPV6_ADDR_RANGE
156
+ 'IPv6'
157
+ else
158
+ "type #{type}"
171
159
  end
160
+ end
161
+
162
+ private
172
163
 
173
- def select_addr(options)
174
- if options[:type]
175
- select_addr_from_type options[:type]
176
- elsif options[:start_addr]
177
- ipv4 = IPAddr.new(options[:start_addr]).ipv4?
178
- self.type = ipv4 ? TS_IPV4_ADDR_RANGE : TS_IPV6_ADDR_RANGE
179
- elsif options[:end_addr]
180
- ipv4 = IPAddr.new(options[:end_addr]).ipv4?
181
- self.type = ipv4 ? TS_IPV4_ADDR_RANGE : TS_IPV6_ADDR_RANGE
182
- end
164
+ def select_addr_from_type(type)
165
+ case type
166
+ when TS_IPV4_ADDR_RANGE, 'IPV4', 'IPv4', 'ipv4', nil
167
+ self[:start_addr] = PacketGen::Header::IP::Addr.new unless self[:start_addr].is_a?(PacketGen::Header::IP::Addr)
168
+ self[:end_addr] = PacketGen::Header::IP::Addr.new unless self[:end_addr].is_a?(PacketGen::Header::IP::Addr)
169
+ when TS_IPV6_ADDR_RANGE, 'IPV6', 'IPv6', 'ipv6'
170
+ self[:start_addr] = PacketGen::Header::IPv6::Addr.new unless self[:start_addr].is_a?(PacketGen::Header::IPv6::Addr)
171
+ self[:end_addr] = PacketGen::Header::IPv6::Addr.new unless self[:end_addr].is_a?(PacketGen::Header::IPv6::Addr)
172
+ else
173
+ raise ArgumentError, "unknown type #{type}"
183
174
  end
184
175
  end
185
176
 
186
- # Set of {TrafficSelector}, used by {TSi} and {TSr}.
187
- # @author Sylvain Daubert
188
- class TrafficSelectors < PacketGen::Types::Array
189
- set_of TrafficSelector
177
+ def select_addr(options)
178
+ if options[:type]
179
+ select_addr_from_type options[:type]
180
+ elsif options[:start_addr]
181
+ ipv4 = IPAddr.new(options[:start_addr]).ipv4?
182
+ self.type = ipv4 ? TS_IPV4_ADDR_RANGE : TS_IPV6_ADDR_RANGE
183
+ elsif options[:end_addr]
184
+ ipv4 = IPAddr.new(options[:end_addr]).ipv4?
185
+ self.type = ipv4 ? TS_IPV4_ADDR_RANGE : TS_IPV6_ADDR_RANGE
186
+ end
190
187
  end
188
+ end
191
189
 
192
- # This class handles Traffic Selector - Initiator payloads, denoted TSi.
193
- #
194
- # A TSi payload consists of the IKE generic payload Plugin (see {Payload})
195
- # and some specific fields:
196
- # 1 2 3
197
- # 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
198
- # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
199
- # | Next Payload |C| RESERVED | Payload Length |
200
- # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
201
- # | Number of TSs | RESERVED |
202
- # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
203
- # | |
204
- # ~ <Traffic Selectors> ~
205
- # | |
206
- # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
207
- # These specific fields are:
208
- # * {#num_ts},
209
- # * {#rsv1},
210
- # * {#rsv2},
211
- # * and {#traffic_selectors}.
212
- #
213
- # == Create a TSi payload
214
- # # Create a IKE packet with a TSi payload
215
- # pkt = PacketGen.gen('IP').add('UDP').add('IKE').add('IKE::TSi')
216
- # # add a traffic selector to this payload
217
- # pkt.ike_tsi.traffic_selectors << { protocol: 'tcp', ports: 1..1024, start_addr: '20.0.0.1', end_addr: '21.255.255.254' }
218
- # # add another traffic selector (IPv6, all protocols)
219
- # pkt.ike_tsi.traffic_selectors << { start_addr: '2001::1', end_addr: '200a:ffff:ffff:ffff:ffff:ffff:ffff:ffff' }
220
- # @author Sylvain Daubert
221
- class TSi < Payload
222
- # Payload type number
223
- PAYLOAD_TYPE = 44
190
+ # Set of {TrafficSelector}, used by {TSi} and {TSr}.
191
+ # @author Sylvain Daubert
192
+ class TrafficSelectors < BinStruct::Array
193
+ set_of TrafficSelector
194
+ end
224
195
 
225
- remove_field :content
196
+ # This class handles Traffic Selector - Initiator payloads, denoted TSi.
197
+ #
198
+ # A TSi payload consists of the IKE generic payload Plugin (see {Payload})
199
+ # and some specific fields:
200
+ # 1 2 3
201
+ # 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
202
+ # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
203
+ # | Next Payload |C| RESERVED | Payload Length |
204
+ # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
205
+ # | Number of TSs | RESERVED |
206
+ # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
207
+ # | |
208
+ # ~ <Traffic Selectors> ~
209
+ # | |
210
+ # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
211
+ # These specific fields are:
212
+ # * {#num_ts},
213
+ # * {#rsv1},
214
+ # * {#rsv2},
215
+ # * and {#traffic_selectors}.
216
+ #
217
+ # == Create a TSi payload
218
+ # # Create a IKE packet with a TSi payload
219
+ # pkt = PacketGen.gen('IP').add('UDP').add('IKE').add('IKE::TSi')
220
+ # # add a traffic selector to this payload
221
+ # pkt.ike_tsi.traffic_selectors << { protocol: 'tcp', ports: 1..1024, start_addr: '20.0.0.1', end_addr: '21.255.255.254' }
222
+ # # add another traffic selector (IPv6, all protocols)
223
+ # pkt.ike_tsi.traffic_selectors << { start_addr: '2001::1', end_addr: '200a:ffff:ffff:ffff:ffff:ffff:ffff:ffff' }
224
+ # @author Sylvain Daubert
225
+ class TSi < Payload
226
+ # Payload type number
227
+ PAYLOAD_TYPE = 44
226
228
 
227
- # @!attribute num_ts
228
- # 8-bit Number of TSs
229
- # @return [Integer]
230
- define_field_before :body, :num_ts, PacketGen::Types::Int8
231
- # @!attribute rsv
232
- # 24-bit RESERVED field
233
- # @return [Integer]
234
- define_field_before :body, :rsv, PacketGen::Types::Int24
229
+ remove_attr :content
235
230
 
236
- # @!attribute traffic_selectors
237
- # Set of {TrafficSelector}
238
- # @return {TrafficSelectors}
239
- define_field_before :body, :traffic_selectors, TrafficSelectors,
240
- builder: ->(h, t) { t.new(counter: h[:num_ts]) }
241
- alias selectors traffic_selectors
231
+ # @!attribute num_ts
232
+ # 8-bit Number of TSs
233
+ # @return [Integer]
234
+ define_attr_before :body, :num_ts, BinStruct::Int8
235
+ # @!attribute rsv
236
+ # 24-bit RESERVED field
237
+ # @return [Integer]
238
+ define_attr_before :body, :rsv, BinStruct::Int24
242
239
 
243
- # Compute length and set {#length} field
244
- # @return [Integer] new length
245
- def calc_length
246
- selectors.each(&:calc_length)
247
- super
248
- end
249
- end
240
+ # @!attribute traffic_selectors
241
+ # Set of {TrafficSelector}
242
+ # @return {TrafficSelectors}
243
+ define_attr_before :body, :traffic_selectors, TrafficSelectors,
244
+ builder: ->(h, t) { t.new(counter: h[:num_ts]) }
245
+ alias selectors traffic_selectors
250
246
 
251
- class TSr < TSi
252
- # Payload type number
253
- PAYLOAD_TYPE = 45
247
+ # Compute length and set {#length} field
248
+ # @return [Integer] new length
249
+ def calc_length
250
+ selectors.each(&:calc_length)
251
+ super
254
252
  end
255
253
  end
256
254
 
257
- Header.add_class IKE::TSi
258
- Header.add_class IKE::TSr
255
+ class TSr < TSi
256
+ # Payload type number
257
+ PAYLOAD_TYPE = 45
258
+ end
259
259
  end
260
+
261
+ PacketGen::Header.add_class IKE::TSi
262
+ PacketGen::Header.add_class IKE::TSr
260
263
  end
@@ -1,39 +1,37 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
3
+
2
4
  # This file is part of IPsec packetgen plugin.
3
5
  # See https://github.com/sdaubert/packetgen-plugin-ipsec for more informations
4
6
  # Copyright (c) 2018 Sylvain Daubert <sylvain.daubert@laposte.net>
5
7
  # This program is published under MIT license.
6
8
 
7
- # frozen_string_literal: true
8
-
9
- module PacketGen
10
- module Plugin
11
- class IKE
12
- # This class handles Vendor ID payloads, as defined in RFC 7296 §3.12.
13
- #
14
- # A Vendor ID payload contains a generic payload Plugin (see {Payload})
15
- # and data field (type {PacketGen::Types::String}):
16
- # 1 2 3
17
- # 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
18
- # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
19
- # | Next Payload |C| RESERVED | Payload Length |
20
- # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
21
- # | |
22
- # ~ VendorID Data ~
23
- # | |
24
- # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25
- #
26
- # == Create a Vendor ID payload
27
- # # Create a IKE packet with a Vendor ID payload
28
- # pkt = PacketGen.gen('IP').add('UDP').add('IKE')
29
- # pkt.add('IKE::VendorID', data: "abcdefgh")
30
- # @author Sylvain Daubert
31
- class VendorID < Payload
32
- # Payload type number
33
- PAYLOAD_TYPE = 43
34
- end
9
+ module PacketGen::Plugin
10
+ class IKE
11
+ # This class handles Vendor ID payloads, as defined in RFC 7296 §3.12.
12
+ #
13
+ # A Vendor ID payload contains a generic payload Plugin (see {Payload})
14
+ # and data field (type {BinStruct::String}):
15
+ # 1 2 3
16
+ # 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
17
+ # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
18
+ # | Next Payload |C| RESERVED | Payload Length |
19
+ # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
20
+ # | |
21
+ # ~ VendorID Data ~
22
+ # | |
23
+ # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
24
+ #
25
+ # == Create a Vendor ID payload
26
+ # # Create a IKE packet with a Vendor ID payload
27
+ # pkt = PacketGen.gen('IP').add('UDP').add('IKE')
28
+ # pkt.add('IKE::VendorID', data: "abcdefgh")
29
+ # @author Sylvain Daubert
30
+ class VendorID < Payload
31
+ # Payload type number
32
+ PAYLOAD_TYPE = 43
35
33
  end
36
-
37
- Header.add_class IKE::VendorID
38
34
  end
35
+
36
+ PacketGen::Header.add_class IKE::VendorID
39
37
  end