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.
- checksums.yaml +4 -4
- data/.github/workflows/specs.yml +32 -0
- data/.rubocop.yml +28 -3
- data/Gemfile +18 -0
- data/README.md +12 -6
- data/Rakefile +10 -4
- data/lib/packetgen/plugin/crypto.rb +38 -4
- data/lib/packetgen/plugin/esp.rb +410 -378
- data/lib/packetgen/plugin/ike/auth.rb +153 -140
- data/lib/packetgen/plugin/ike/cert.rb +61 -62
- data/lib/packetgen/plugin/ike/certreq.rb +51 -52
- data/lib/packetgen/plugin/ike/id.rb +80 -81
- data/lib/packetgen/plugin/ike/ke.rb +64 -65
- data/lib/packetgen/plugin/ike/nonce.rb +29 -31
- data/lib/packetgen/plugin/ike/notify.rb +134 -139
- data/lib/packetgen/plugin/ike/payload.rb +75 -76
- data/lib/packetgen/plugin/ike/sa.rb +515 -452
- data/lib/packetgen/plugin/ike/sk.rb +221 -221
- data/lib/packetgen/plugin/ike/ts.rb +226 -223
- data/lib/packetgen/plugin/ike/vendor_id.rb +28 -30
- data/lib/packetgen/plugin/ike.rb +213 -217
- data/lib/packetgen/plugin/ipsec_version.rb +8 -1
- data/lib/packetgen-plugin-ipsec.rb +2 -0
- data/packetgen-plugin-ipsec.gemspec +6 -11
- metadata +11 -88
- data/.travis.yml +0 -14
@@ -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
|
-
|
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
|
-
|
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
|
+
# @!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
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
-
|
65
|
-
|
66
|
-
|
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
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
94
|
-
|
95
|
-
|
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
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
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
|
-
|
124
|
-
|
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
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
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
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
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
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
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
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
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
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
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
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
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
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
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
|
-
|
252
|
-
|
253
|
-
|
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
|
-
|
258
|
-
|
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
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
#
|
30
|
-
|
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
|