pio 0.3.0 → 0.4.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/CONTRIBUTING.md +46 -12
- data/README.md +131 -116
- data/Rakefile +7 -92
- data/examples/arp_new.rb +16 -0
- data/examples/arp_read.rb +4 -0
- data/examples/dhcp_new.rb +30 -0
- data/examples/dhcp_read.rb +4 -0
- data/examples/icmp_new.rb +21 -0
- data/examples/icmp_read.rb +4 -0
- data/examples/lldp_new.rb +4 -0
- data/examples/lldp_read.rb +4 -0
- data/lib/pio.rb +6 -12
- data/lib/pio/arp.rb +7 -19
- data/lib/pio/arp/frame.rb +8 -12
- data/lib/pio/arp/message.rb +12 -25
- data/lib/pio/arp/reply.rb +30 -30
- data/lib/pio/arp/request.rb +30 -29
- data/lib/pio/dhcp.rb +58 -0
- data/lib/pio/dhcp/ack.rb +12 -0
- data/lib/pio/dhcp/boot_reply.rb +16 -0
- data/lib/pio/dhcp/boot_reply_options.rb +75 -0
- data/lib/pio/dhcp/boot_request.rb +16 -0
- data/lib/pio/dhcp/boot_request_options.rb +69 -0
- data/lib/pio/dhcp/common_options.rb +71 -0
- data/lib/pio/dhcp/csum_util.rb +83 -0
- data/lib/pio/dhcp/dhcp_field.rb +48 -0
- data/lib/pio/dhcp/dhcp_tlv_options.rb +84 -0
- data/lib/pio/dhcp/discover.rb +12 -0
- data/lib/pio/dhcp/field_util.rb +102 -0
- data/lib/pio/dhcp/frame.rb +95 -0
- data/lib/pio/dhcp/message.rb +79 -0
- data/lib/pio/dhcp/offer.rb +12 -0
- data/lib/pio/dhcp/optional_tlv.rb +74 -0
- data/lib/pio/dhcp/request.rb +12 -0
- data/lib/pio/dhcp/type/dhcp_client_id.rb +21 -0
- data/lib/pio/dhcp/type/dhcp_param_list.rb +22 -0
- data/lib/pio/dhcp/type/dhcp_string.rb +21 -0
- data/lib/pio/icmp.rb +7 -18
- data/lib/pio/icmp/frame.rb +38 -40
- data/lib/pio/icmp/message.rb +10 -61
- data/lib/pio/icmp/options.rb +25 -0
- data/lib/pio/icmp/reply.rb +34 -7
- data/lib/pio/icmp/request.rb +43 -7
- data/lib/pio/ipv4_address.rb +5 -8
- data/lib/pio/lldp.rb +22 -62
- data/lib/pio/lldp/chassis_id_tlv.rb +7 -13
- data/lib/pio/lldp/end_of_lldpdu_value.rb +3 -9
- data/lib/pio/lldp/frame.rb +6 -12
- data/lib/pio/lldp/management_address_value.rb +4 -10
- data/lib/pio/lldp/optional_tlv.rb +5 -10
- data/lib/pio/lldp/options.rb +37 -0
- data/lib/pio/lldp/organizationally_specific_value.rb +2 -8
- data/lib/pio/lldp/port_description_value.rb +2 -8
- data/lib/pio/lldp/port_id_tlv.rb +6 -12
- data/lib/pio/lldp/system_capabilities_value.rb +2 -8
- data/lib/pio/lldp/system_description_value.rb +2 -8
- data/lib/pio/lldp/system_name_value.rb +2 -8
- data/lib/pio/lldp/ttl_tlv.rb +5 -11
- data/lib/pio/mac.rb +4 -9
- data/lib/pio/message_type_selector.rb +22 -0
- data/lib/pio/options.rb +65 -0
- data/lib/pio/parse_error.rb +6 -0
- data/lib/pio/type/ethernet_header.rb +3 -2
- data/lib/pio/type/ip_address.rb +4 -9
- data/lib/pio/type/ipv4_header.rb +12 -17
- data/lib/pio/type/mac_address.rb +5 -10
- data/lib/pio/type/udp_header.rb +18 -0
- data/lib/pio/version.rb +3 -8
- data/pio.gemspec +12 -10
- data/spec/pio/arp/reply/options_spec.rb +145 -0
- data/spec/pio/arp/reply_spec.rb +77 -113
- data/spec/pio/arp/request/options_spec.rb +115 -0
- data/spec/pio/arp/request_spec.rb +74 -96
- data/spec/pio/arp_spec.rb +71 -105
- data/spec/pio/dhcp/ack_spec.rb +189 -0
- data/spec/pio/dhcp/discover_spec.rb +165 -0
- data/spec/pio/dhcp/offer_spec.rb +189 -0
- data/spec/pio/dhcp/request_spec.rb +173 -0
- data/spec/pio/dhcp_spec.rb +609 -0
- data/spec/pio/icmp/reply_spec.rb +102 -95
- data/spec/pio/icmp/request_spec.rb +86 -78
- data/spec/pio/icmp_spec.rb +153 -146
- data/spec/pio/ipv4_address_spec.rb +2 -7
- data/spec/pio/lldp/options_spec.rb +188 -0
- data/spec/pio/lldp_spec.rb +181 -208
- data/spec/pio/mac_spec.rb +3 -8
- data/spec/spec_helper.rb +4 -10
- metadata +69 -17
- data/.gitignore +0 -20
- data/.rspec +0 -3
- data/.rubocop.yml +0 -1
- data/.travis.yml +0 -13
- data/Gemfile +0 -37
- data/Guardfile +0 -24
- data/lib/pio/message_util.rb +0 -19
- data/lib/pio/type/config.reek +0 -4
- data/lib/pio/util.rb +0 -21
- data/pio.org +0 -668
- data/pio.org_archive +0 -943
- data/rubocop-todo.yml +0 -9
@@ -0,0 +1,173 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'pio'
|
4
|
+
|
5
|
+
describe Pio::Dhcp::Request do
|
6
|
+
Pio::DHCP::Request == Pio::Dhcp::Request
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Pio::Dhcp::Request, '.new' do
|
10
|
+
context 'with optional options' do
|
11
|
+
subject do
|
12
|
+
Pio::Dhcp::Request.new(
|
13
|
+
source_mac: source_mac,
|
14
|
+
transaction_id: 0xdeadbeef,
|
15
|
+
server_identifier: server_identifier,
|
16
|
+
requested_ip_address: requested_ip_address
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
valid_dhcp_request_dump =
|
21
|
+
[
|
22
|
+
# Destination MAC Address
|
23
|
+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
24
|
+
# Source MAC Address
|
25
|
+
0x24, 0xdb, 0xac, 0x41, 0xe5, 0x5b,
|
26
|
+
# Ethernet Type
|
27
|
+
0x08, 0x00,
|
28
|
+
# IP version and IP Header Length
|
29
|
+
0x45,
|
30
|
+
# DSCP
|
31
|
+
0x00,
|
32
|
+
# IP Total Length
|
33
|
+
0x01, 0x48,
|
34
|
+
# IP Identifier
|
35
|
+
0x00, 0x00,
|
36
|
+
# IP Flags and IP Fragmentation
|
37
|
+
0x00, 0x00,
|
38
|
+
# IP TTL
|
39
|
+
0x80,
|
40
|
+
# IP Protocol
|
41
|
+
0x11,
|
42
|
+
# IP Header Checksum
|
43
|
+
0x39, 0xa6,
|
44
|
+
# IP Source Address
|
45
|
+
0x00, 0x00, 0x00, 0x00,
|
46
|
+
# IP Destination Address
|
47
|
+
0xff, 0xff, 0xff, 0xff,
|
48
|
+
# UDP Source Port
|
49
|
+
0x00, 0x44,
|
50
|
+
# UDP Destination Port
|
51
|
+
0x00, 0x43,
|
52
|
+
# UDP Total Length
|
53
|
+
0x01, 0x34,
|
54
|
+
# UDP Header Checksum
|
55
|
+
0xce, 0xb3,
|
56
|
+
# Bootp Msg Type
|
57
|
+
0x01,
|
58
|
+
# Hw Type
|
59
|
+
0x01,
|
60
|
+
# Hw Address Length
|
61
|
+
0x06,
|
62
|
+
# Hops
|
63
|
+
0x00,
|
64
|
+
# Transaction ID
|
65
|
+
0xde, 0xad, 0xbe, 0xef,
|
66
|
+
# Seconds
|
67
|
+
0x00, 0x00,
|
68
|
+
# Bootp Flags
|
69
|
+
0x00, 0x00,
|
70
|
+
# Client IP Address
|
71
|
+
0x00, 0x00, 0x00, 0x00,
|
72
|
+
# Your IP Address
|
73
|
+
0x00, 0x00, 0x00, 0x00,
|
74
|
+
# Next Server IP Address
|
75
|
+
0x00, 0x00, 0x00, 0x00,
|
76
|
+
# Relay Agent IP Address
|
77
|
+
0x00, 0x00, 0x00, 0x00,
|
78
|
+
# Client MAC Address
|
79
|
+
0x24, 0xdb, 0xac, 0x41, 0xe5, 0x5b,
|
80
|
+
# Client Hw Address Padding
|
81
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
82
|
+
# Server Host Name
|
83
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
84
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
85
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
86
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
87
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
88
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
89
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
90
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
91
|
+
# Boot File Name
|
92
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
93
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
94
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
95
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
96
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
97
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
98
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
99
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
100
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
101
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
102
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
103
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
104
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
105
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
106
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
107
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
108
|
+
# Magic Cookie
|
109
|
+
0x63, 0x82, 0x53, 0x63,
|
110
|
+
# DHCP Msg Type
|
111
|
+
0x35, 0x01, 0x03,
|
112
|
+
# Client Identifier
|
113
|
+
0x3d, 0x07, 0x01, 0x24, 0xdb, 0xac, 0x41, 0xe5, 0x5b,
|
114
|
+
# Requested IP Address
|
115
|
+
0x32, 0x04, 0xc0, 0xa8, 0x00, 0x0a,
|
116
|
+
# Parameter Lists
|
117
|
+
0x37, 0x04, 0x01, 0x03, 0x06, 0x2a,
|
118
|
+
# DHCP Server Identifier
|
119
|
+
0x36, 0x04, 0xc0, 0xa8, 0x00, 0x01,
|
120
|
+
# End Option
|
121
|
+
0xff,
|
122
|
+
# Padding Field
|
123
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
124
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
125
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
126
|
+
0x00, 0x00, 0x00, 0x00, 0x00
|
127
|
+
]
|
128
|
+
|
129
|
+
context 'with String Address' do
|
130
|
+
let(:source_mac) { '24:db:ac:41:e5:5b' }
|
131
|
+
let(:server_identifier) { '192.168.0.1' }
|
132
|
+
let(:requested_ip_address) { '192.168.0.10' }
|
133
|
+
|
134
|
+
context '#to_binary' do
|
135
|
+
it 'returns a DHCP Request binary string' do
|
136
|
+
expect(subject.to_binary.unpack('C*')).to eq valid_dhcp_request_dump
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'returns a valid ether frame with size = 342' do
|
140
|
+
expect(subject.to_binary.size).to eq 342
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
context 'with IPv4Address Object Address And Mac Object Address' do
|
146
|
+
let(:source_mac) { Pio::Mac.new('24:db:ac:41:e5:5b') }
|
147
|
+
let(:server_identifier) { Pio::IPv4Address.new('192.168.0.1') }
|
148
|
+
let(:requested_ip_address) { Pio::IPv4Address.new('192.168.0.10') }
|
149
|
+
|
150
|
+
context '#to_binary' do
|
151
|
+
it 'returns a DHCP Request binary string' do
|
152
|
+
expect(subject.to_binary.unpack('C*')).to eq valid_dhcp_request_dump
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'returns a valid ether frame with size = 342' do
|
156
|
+
expect(subject.to_binary.size).to eq 342
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
context 'without optional options' do
|
163
|
+
subject do
|
164
|
+
Pio::Dhcp::Request.new(source_mac: '24:db:ac:41:e5:5b')
|
165
|
+
end
|
166
|
+
|
167
|
+
describe '#to_binary' do
|
168
|
+
it 'returns a valid ether frame with size = 342' do
|
169
|
+
expect(subject.to_binary.size).to eq 342
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
@@ -0,0 +1,609 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'pio'
|
4
|
+
|
5
|
+
describe Pio::DHCP do
|
6
|
+
Pio::DHCP == Pio::Dhcp
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Pio::Dhcp, '.read' do
|
10
|
+
subject { Pio::Dhcp.read(data.pack('C*')) }
|
11
|
+
|
12
|
+
context 'with DHCP Discover frame' do
|
13
|
+
let(:data) do
|
14
|
+
[
|
15
|
+
# Destination MAC Address
|
16
|
+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
17
|
+
# Source MAC Address
|
18
|
+
0x24, 0xdb, 0xac, 0x41, 0xe5, 0x5b,
|
19
|
+
# Ethernet Type
|
20
|
+
0x08, 0x00,
|
21
|
+
# IP version and IP Header Length
|
22
|
+
0x45,
|
23
|
+
# DSCP
|
24
|
+
0x00,
|
25
|
+
# IP Total Length
|
26
|
+
0x01, 0x48,
|
27
|
+
# IP Identifier
|
28
|
+
0x00, 0x00,
|
29
|
+
# IP Flags and IP Fragmentation
|
30
|
+
0x00, 0x00,
|
31
|
+
# IP TTL
|
32
|
+
0x80,
|
33
|
+
# IP Protocol
|
34
|
+
0x11,
|
35
|
+
# IP Header Checksum
|
36
|
+
0x39, 0xa6,
|
37
|
+
# IP Source Address
|
38
|
+
0x00, 0x00, 0x00, 0x00,
|
39
|
+
# IP Destination Address
|
40
|
+
0xff, 0xff, 0xff, 0xff,
|
41
|
+
# UDP Source Port
|
42
|
+
0x00, 0x44,
|
43
|
+
# UDP Destination Port
|
44
|
+
0x00, 0x43,
|
45
|
+
# UDP Total Length
|
46
|
+
0x01, 0x34,
|
47
|
+
# UDP Header Checksum
|
48
|
+
0x88, 0x14,
|
49
|
+
# Bootp Msg Type
|
50
|
+
0x01,
|
51
|
+
# Hw Type
|
52
|
+
0x01,
|
53
|
+
# Hw Address Length
|
54
|
+
0x06,
|
55
|
+
# Hops
|
56
|
+
0x00,
|
57
|
+
# Transaction ID
|
58
|
+
0xde, 0xad, 0xbe, 0xef,
|
59
|
+
# Seconds
|
60
|
+
0x00, 0x00,
|
61
|
+
# Bootp Flags
|
62
|
+
0x00, 0x00,
|
63
|
+
# Client IP Address
|
64
|
+
0x00, 0x00, 0x00, 0x00,
|
65
|
+
# Your IP Address
|
66
|
+
0x00, 0x00, 0x00, 0x00,
|
67
|
+
# Next Server IP Address
|
68
|
+
0x00, 0x00, 0x00, 0x00,
|
69
|
+
# Relay Agent IP Address
|
70
|
+
0x00, 0x00, 0x00, 0x00,
|
71
|
+
# Client MAC Address
|
72
|
+
0x24, 0xdb, 0xac, 0x41, 0xe5, 0x5b,
|
73
|
+
# Client Hw Address Padding
|
74
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
75
|
+
# Server Host Name
|
76
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
77
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
78
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
79
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
80
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
81
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
82
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
83
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
84
|
+
# Boot File Name
|
85
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
86
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
87
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
88
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
89
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
90
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
91
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
92
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
93
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
94
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
95
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
96
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
97
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
98
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
99
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
100
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
101
|
+
# Magic Cookie
|
102
|
+
0x63, 0x82, 0x53, 0x63,
|
103
|
+
# DHCP Msg Type
|
104
|
+
0x35, 0x01, 0x01,
|
105
|
+
# Client Identifier
|
106
|
+
0x3d, 0x07, 0x01, 0x24, 0xdb, 0xac, 0x41, 0xe5, 0x5b,
|
107
|
+
# Requested IP Address
|
108
|
+
0x32, 0x04, 0x00, 0x00, 0x00, 0x00,
|
109
|
+
# Parameter Lists
|
110
|
+
0x37, 0x04, 0x01, 0x03, 0x06, 0x2a,
|
111
|
+
# End Option
|
112
|
+
0xff,
|
113
|
+
# Padding Field
|
114
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
115
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
116
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
117
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
118
|
+
]
|
119
|
+
end
|
120
|
+
|
121
|
+
its(:class) { should be Pio::Dhcp::Discover }
|
122
|
+
its('destination_mac.to_s') { should eq 'ff:ff:ff:ff:ff:ff' }
|
123
|
+
its('source_mac.to_s') { should eq '24:db:ac:41:e5:5b' }
|
124
|
+
its(:ether_type) { should eq 2048 }
|
125
|
+
its(:ip_version) { should eq 4 }
|
126
|
+
its(:ip_header_length) { should eq 5 }
|
127
|
+
its(:ip_type_of_service) { should eq 0 }
|
128
|
+
its(:ip_total_length) { should eq 328 }
|
129
|
+
its(:ip_identifier) { should eq 0x0000 }
|
130
|
+
its(:ip_flag) { should eq 0 }
|
131
|
+
its(:ip_fragment) { should eq 0 }
|
132
|
+
its(:ip_ttl) { should eq 128 }
|
133
|
+
its(:ip_protocol) { should eq 17 }
|
134
|
+
its(:ip_header_checksum) { should eq 0x39a6 }
|
135
|
+
its('ip_source_address.to_s') { should eq '0.0.0.0' }
|
136
|
+
its('ip_destination_address.to_s') { should eq '255.255.255.255' }
|
137
|
+
its(:udp_src_port) { should eq 68 }
|
138
|
+
its(:udp_dst_port) { should eq 67 }
|
139
|
+
its(:udp_length) { should eq 308 }
|
140
|
+
its(:udp_checksum) { should eq 0x8814 }
|
141
|
+
its(:message_type) { should eq 1 }
|
142
|
+
its(:hw_addr_type) { should eq 1 }
|
143
|
+
its(:hw_addr_len) { should eq 6 }
|
144
|
+
its(:hops) { should eq 0 }
|
145
|
+
its(:transaction_id) { should eq 0xdeadbeef }
|
146
|
+
its(:seconds) { should eq 0 }
|
147
|
+
its(:bootp_flags) { should eq 0 }
|
148
|
+
its('client_ip_address.to_s') { should eq '0.0.0.0' }
|
149
|
+
its('your_ip_address.to_s') { should eq '0.0.0.0' }
|
150
|
+
its('next_server_ip_address.to_s') { should eq '0.0.0.0' }
|
151
|
+
its('relay_agent_ip_address.to_s') { should eq '0.0.0.0' }
|
152
|
+
its('client_mac_address.to_s') { should eq '24:db:ac:41:e5:5b' }
|
153
|
+
its('client_identifier.to_s') { should eq '24:db:ac:41:e5:5b' }
|
154
|
+
its('requested_ip_address.to_s') { should eq '0.0.0.0' }
|
155
|
+
its(:parameters_list) { should eq [0x01, 0x03, 0x06, 0x2a] }
|
156
|
+
end
|
157
|
+
|
158
|
+
context 'with DHCP offer frame' do
|
159
|
+
let(:data) do
|
160
|
+
[
|
161
|
+
# Destination MAC Address
|
162
|
+
0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
|
163
|
+
# Source MAC Address
|
164
|
+
0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
|
165
|
+
# Ethernet Type
|
166
|
+
0x08, 0x00,
|
167
|
+
# IP version and IP Header Length
|
168
|
+
0x45,
|
169
|
+
# DSCP
|
170
|
+
0x00,
|
171
|
+
# IP Total Length
|
172
|
+
0x01, 0x48,
|
173
|
+
# IP Identifier
|
174
|
+
0x00, 0x00,
|
175
|
+
# IP Flags and IP Fragmentation
|
176
|
+
0x00, 0x00,
|
177
|
+
# IP TTL
|
178
|
+
0x80,
|
179
|
+
# IP Protocol
|
180
|
+
0x11,
|
181
|
+
# IP Header Checksum
|
182
|
+
0xb8, 0x49,
|
183
|
+
# IP Source Address
|
184
|
+
0xc0, 0xa8, 0x00, 0x0a,
|
185
|
+
# IP Destination Address
|
186
|
+
0xc0, 0xa8, 0x00, 0x01,
|
187
|
+
# UDP Source Port
|
188
|
+
0x00, 0x43,
|
189
|
+
# UDP Destination Port
|
190
|
+
0x00, 0x44,
|
191
|
+
# UDP Total Length
|
192
|
+
0x01, 0x34,
|
193
|
+
# UDP Header Checksum
|
194
|
+
0x1e, 0x64,
|
195
|
+
# Bootp Msg Type
|
196
|
+
0x02,
|
197
|
+
# Hw Type
|
198
|
+
0x01,
|
199
|
+
# Hw Address Length
|
200
|
+
0x06,
|
201
|
+
# Hops
|
202
|
+
0x00,
|
203
|
+
# Transaction ID
|
204
|
+
0xde, 0xad, 0xbe, 0xef,
|
205
|
+
# Seconds
|
206
|
+
0x00, 0x00,
|
207
|
+
# Bootp Flags
|
208
|
+
0x00, 0x00,
|
209
|
+
# Client IP Address
|
210
|
+
0x00, 0x00, 0x00, 0x00,
|
211
|
+
# Your IP Address
|
212
|
+
0xc0, 0xa8, 0x00, 0x01,
|
213
|
+
# Next Server IP Address
|
214
|
+
0x00, 0x00, 0x00, 0x00,
|
215
|
+
# Relay Agent IP Address
|
216
|
+
0x00, 0x00, 0x00, 0x00,
|
217
|
+
# Client MAC Address
|
218
|
+
0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
|
219
|
+
# Client Hw Address Padding
|
220
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
221
|
+
# Server Host Name
|
222
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
223
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
224
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
225
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
226
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
227
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
228
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
229
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
230
|
+
# Boot File Name
|
231
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
232
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
233
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
234
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
235
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
236
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
237
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
238
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
239
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
240
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
241
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
242
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
243
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
244
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
245
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
246
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
247
|
+
# Magic Cookie
|
248
|
+
0x63, 0x82, 0x53, 0x63,
|
249
|
+
# DHCP Msg Type
|
250
|
+
0x35, 0x01, 0x02,
|
251
|
+
# Renewal Time Value
|
252
|
+
0x3a, 0x04, 0xde, 0xad, 0xbe, 0xef,
|
253
|
+
# Rebinding Time Value
|
254
|
+
0x3b, 0x04, 0xde, 0xad, 0xbe, 0xef,
|
255
|
+
# IP Address Lease Time Value
|
256
|
+
0x33, 0x04, 0xde, 0xad, 0xbe, 0xef,
|
257
|
+
# DHCP Server Identifier
|
258
|
+
0x36, 0x04, 0xc0, 0xa8, 0x00, 0x0a,
|
259
|
+
# Subnet Mask
|
260
|
+
0x01, 0x04, 0xff, 0xff, 0xff, 0x00,
|
261
|
+
# End Option
|
262
|
+
0xff,
|
263
|
+
# Padding Field
|
264
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
265
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
266
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
267
|
+
0x00, 0x00
|
268
|
+
]
|
269
|
+
end
|
270
|
+
|
271
|
+
its(:class) { should be Pio::Dhcp::Offer }
|
272
|
+
its('destination_mac.to_s') { should eq '11:22:33:44:55:66' }
|
273
|
+
its('source_mac.to_s') { should eq 'aa:bb:cc:dd:ee:ff' }
|
274
|
+
its(:ether_type) { should eq 2048 }
|
275
|
+
its(:ip_version) { should eq 4 }
|
276
|
+
its(:ip_header_length) { should eq 5 }
|
277
|
+
its(:ip_type_of_service) { should eq 0 }
|
278
|
+
its(:ip_total_length) { should eq 328 }
|
279
|
+
its(:ip_identifier) { should eq 0x0000 }
|
280
|
+
its(:ip_flag) { should eq 0 }
|
281
|
+
its(:ip_fragment) { should eq 0 }
|
282
|
+
its(:ip_ttl) { should eq 128 }
|
283
|
+
its(:ip_protocol) { should eq 17 }
|
284
|
+
its(:ip_header_checksum) { should eq 0xb849 }
|
285
|
+
its('ip_source_address.to_s') { should eq '192.168.0.10' }
|
286
|
+
its('ip_destination_address.to_s') { should eq '192.168.0.1' }
|
287
|
+
its(:udp_src_port) { should eq 67 }
|
288
|
+
its(:udp_dst_port) { should eq 68 }
|
289
|
+
its(:udp_length) { should eq 308 }
|
290
|
+
its(:udp_checksum) { should eq 7780 }
|
291
|
+
its(:message_type) { should eq 2 }
|
292
|
+
its(:hw_addr_type) { should eq 1 }
|
293
|
+
its(:hw_addr_len) { should eq 6 }
|
294
|
+
its(:hops) { should eq 0 }
|
295
|
+
its(:transaction_id) { should eq 0xdeadbeef }
|
296
|
+
its(:seconds) { should eq 0 }
|
297
|
+
its(:bootp_flags) { should eq 0x0000 }
|
298
|
+
its('client_ip_address.to_s') { should eq '0.0.0.0' }
|
299
|
+
its('your_ip_address.to_s') { should eq '192.168.0.1' }
|
300
|
+
its('next_server_ip_address.to_s') { should eq '0.0.0.0' }
|
301
|
+
its('relay_agent_ip_address.to_s') { should eq '0.0.0.0' }
|
302
|
+
its('client_mac_address.to_s') { should eq 'aa:bb:cc:dd:ee:ff' }
|
303
|
+
its('server_identifier.to_s') { should eq '192.168.0.10' }
|
304
|
+
its('subnet_mask.to_s') { should eq '255.255.255.0' }
|
305
|
+
its(:renewal_time_value) { should eq 0xdeadbeef }
|
306
|
+
its(:rebinding_time_value) { should eq 0xdeadbeef }
|
307
|
+
its(:ip_address_lease_time) { should eq 0xdeadbeef }
|
308
|
+
end
|
309
|
+
|
310
|
+
context 'with DHCP Request frame' do
|
311
|
+
let(:data) do
|
312
|
+
[
|
313
|
+
# Destination MAC Address
|
314
|
+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
315
|
+
# Source MAC Address
|
316
|
+
0x24, 0xdb, 0xac, 0x41, 0xe5, 0x5b,
|
317
|
+
# Ethernet Type
|
318
|
+
0x08, 0x00,
|
319
|
+
# IP version and IP Header Length
|
320
|
+
0x45,
|
321
|
+
# DSCP
|
322
|
+
0x00,
|
323
|
+
# IP Total Length
|
324
|
+
0x01, 0x48,
|
325
|
+
# IP Identifier
|
326
|
+
0x00, 0x00,
|
327
|
+
# IP Flags and IP Fragmentation
|
328
|
+
0x00, 0x00,
|
329
|
+
# IP TTL
|
330
|
+
0x80,
|
331
|
+
# IP Protocol
|
332
|
+
0x11,
|
333
|
+
# IP Header Checksum
|
334
|
+
0x39, 0xa6,
|
335
|
+
# IP Source Address
|
336
|
+
0x00, 0x00, 0x00, 0x00,
|
337
|
+
# IP Destination Address
|
338
|
+
0xff, 0xff, 0xff, 0xff,
|
339
|
+
# UDP Source Port
|
340
|
+
0x00, 0x44,
|
341
|
+
# UDP Destination Port
|
342
|
+
0x00, 0x43,
|
343
|
+
# UDP Total Length
|
344
|
+
0x01, 0x34,
|
345
|
+
# UDP Header Checksum
|
346
|
+
0xce, 0xb3,
|
347
|
+
# Bootp Msg Type
|
348
|
+
0x01,
|
349
|
+
# Hw Type
|
350
|
+
0x01,
|
351
|
+
# Hw Address Length
|
352
|
+
0x06,
|
353
|
+
# Hops
|
354
|
+
0x00,
|
355
|
+
# Transaction ID
|
356
|
+
0xde, 0xad, 0xbe, 0xef,
|
357
|
+
# Seconds
|
358
|
+
0x00, 0x00,
|
359
|
+
# Bootp Flags
|
360
|
+
0x00, 0x00,
|
361
|
+
# Client IP Address
|
362
|
+
0x00, 0x00, 0x00, 0x00,
|
363
|
+
# Your IP Address
|
364
|
+
0x00, 0x00, 0x00, 0x00,
|
365
|
+
# Next Server IP Address
|
366
|
+
0x00, 0x00, 0x00, 0x00,
|
367
|
+
# Relay Agent IP Address
|
368
|
+
0x00, 0x00, 0x00, 0x00,
|
369
|
+
# Client MAC Address
|
370
|
+
0x24, 0xdb, 0xac, 0x41, 0xe5, 0x5b,
|
371
|
+
# Client Hw Address Padding
|
372
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
373
|
+
# Server Host Name
|
374
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
375
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
376
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
377
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
378
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
379
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
380
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
381
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
382
|
+
# Boot File Name
|
383
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
384
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
385
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
386
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
387
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
388
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
389
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
390
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
391
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
392
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
393
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
394
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
395
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
396
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
397
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
398
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
399
|
+
# Magic Cookie
|
400
|
+
0x63, 0x82, 0x53, 0x63,
|
401
|
+
# DHCP Msg Type
|
402
|
+
0x35, 0x01, 0x03,
|
403
|
+
# Client Identifier
|
404
|
+
0x3d, 0x07, 0x01, 0x24, 0xdb, 0xac, 0x41, 0xe5, 0x5b,
|
405
|
+
# Requested IP Address
|
406
|
+
0x32, 0x04, 0xc0, 0xa8, 0x00, 0x0a,
|
407
|
+
# Parameter Lists
|
408
|
+
0x37, 0x04, 0x01, 0x03, 0x06, 0x2a,
|
409
|
+
# DHCP Server Identifier
|
410
|
+
0x36, 0x04, 0xc0, 0xa8, 0x00, 0x01,
|
411
|
+
# End Option
|
412
|
+
0xff,
|
413
|
+
# Padding Field
|
414
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
415
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
416
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
417
|
+
0x00, 0x00, 0x00, 0x00, 0x00
|
418
|
+
]
|
419
|
+
end
|
420
|
+
|
421
|
+
its(:class) { should be Pio::Dhcp::Request }
|
422
|
+
its('destination_mac.to_s') { should eq 'ff:ff:ff:ff:ff:ff' }
|
423
|
+
its('source_mac.to_s') { should eq '24:db:ac:41:e5:5b' }
|
424
|
+
its(:ether_type) { should eq 2048 }
|
425
|
+
its(:ip_version) { should eq 4 }
|
426
|
+
its(:ip_header_length) { should eq 5 }
|
427
|
+
its(:ip_type_of_service) { should eq 0 }
|
428
|
+
its(:ip_total_length) { should eq 328 }
|
429
|
+
its(:ip_identifier) { should eq 0x0000 }
|
430
|
+
its(:ip_flag) { should eq 0 }
|
431
|
+
its(:ip_fragment) { should eq 0 }
|
432
|
+
its(:ip_ttl) { should eq 128 }
|
433
|
+
its(:ip_protocol) { should eq 17 }
|
434
|
+
its(:ip_header_checksum) { should eq 0x39a6 }
|
435
|
+
its('ip_source_address.to_s') { should eq '0.0.0.0' }
|
436
|
+
its('ip_destination_address.to_s') { should eq '255.255.255.255' }
|
437
|
+
its(:udp_src_port) { should eq 68 }
|
438
|
+
its(:udp_dst_port) { should eq 67 }
|
439
|
+
its(:udp_length) { should eq 308 }
|
440
|
+
its(:udp_checksum) { should eq 0xceb3 }
|
441
|
+
its(:message_type) { should eq 3 }
|
442
|
+
its(:hw_addr_type) { should eq 1 }
|
443
|
+
its(:hw_addr_len) { should eq 6 }
|
444
|
+
its(:hops) { should eq 0 }
|
445
|
+
its(:transaction_id) { should eq 0xdeadbeef }
|
446
|
+
its(:seconds) { should eq 0 }
|
447
|
+
its(:bootp_flags) { should eq 0 }
|
448
|
+
its('client_ip_address.to_s') { should eq '0.0.0.0' }
|
449
|
+
its('your_ip_address.to_s') { should eq '0.0.0.0' }
|
450
|
+
its('next_server_ip_address.to_s') { should eq '0.0.0.0' }
|
451
|
+
its('relay_agent_ip_address.to_s') { should eq '0.0.0.0' }
|
452
|
+
its('client_mac_address.to_s') { should eq '24:db:ac:41:e5:5b' }
|
453
|
+
its('client_identifier.to_s') { should eq '24:db:ac:41:e5:5b' }
|
454
|
+
its('requested_ip_address.to_s') { should eq '192.168.0.10' }
|
455
|
+
its(:parameters_list) { should eq [0x01, 0x03, 0x06, 0x2a] }
|
456
|
+
end
|
457
|
+
|
458
|
+
context 'with DHCP ACK frame' do
|
459
|
+
let(:data) do
|
460
|
+
[
|
461
|
+
# Destination MAC Address
|
462
|
+
0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
|
463
|
+
# Source MAC Address
|
464
|
+
0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
|
465
|
+
# Ethernet Type
|
466
|
+
0x08, 0x00,
|
467
|
+
# IP version and IP Header Length
|
468
|
+
0x45,
|
469
|
+
# DSCP
|
470
|
+
0x00,
|
471
|
+
# IP Total Length
|
472
|
+
0x01, 0x48,
|
473
|
+
# IP Identifier
|
474
|
+
0x00, 0x00,
|
475
|
+
# IP Flags and IP Fragmentation
|
476
|
+
0x00, 0x00,
|
477
|
+
# IP TTL
|
478
|
+
0x80,
|
479
|
+
# IP Protocol
|
480
|
+
0x11,
|
481
|
+
# IP Header Checksum
|
482
|
+
0xb8, 0x49,
|
483
|
+
# IP Source Address
|
484
|
+
0xc0, 0xa8, 0x00, 0x0a,
|
485
|
+
# IP Destination Address
|
486
|
+
0xc0, 0xa8, 0x00, 0x01,
|
487
|
+
# UDP Source Port
|
488
|
+
0x00, 0x43,
|
489
|
+
# UDP Destination Port
|
490
|
+
0x00, 0x44,
|
491
|
+
# UDP Total Length
|
492
|
+
0x01, 0x34,
|
493
|
+
# UDP Header Checksum
|
494
|
+
0x1b, 0x64,
|
495
|
+
# Bootp Msg Type
|
496
|
+
0x02,
|
497
|
+
# Hw Type
|
498
|
+
0x01,
|
499
|
+
# Hw Address Length
|
500
|
+
0x06,
|
501
|
+
# Hops
|
502
|
+
0x00,
|
503
|
+
# Transaction ID
|
504
|
+
0xde, 0xad, 0xbe, 0xef,
|
505
|
+
# Seconds
|
506
|
+
0x00, 0x00,
|
507
|
+
# Bootp Flags
|
508
|
+
0x00, 0x00,
|
509
|
+
# Client IP Address
|
510
|
+
0x00, 0x00, 0x00, 0x00,
|
511
|
+
# Your IP Address
|
512
|
+
0xc0, 0xa8, 0x00, 0x01,
|
513
|
+
# Next Server IP Address
|
514
|
+
0x00, 0x00, 0x00, 0x00,
|
515
|
+
# Relay Agent IP Address
|
516
|
+
0x00, 0x00, 0x00, 0x00,
|
517
|
+
# Client MAC Address
|
518
|
+
0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
|
519
|
+
# Client Hw Address Padding
|
520
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
521
|
+
# Server Host Name
|
522
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
523
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
524
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
525
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
526
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
527
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
528
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
529
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
530
|
+
# Boot File Name
|
531
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
532
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
533
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
534
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
535
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
536
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
537
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
538
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
539
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
540
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
541
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
542
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
543
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
544
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
545
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
546
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
547
|
+
# Magic Cookie
|
548
|
+
0x63, 0x82, 0x53, 0x63,
|
549
|
+
# DHCP Msg Type
|
550
|
+
0x35, 0x01, 0x05,
|
551
|
+
# Renewal Time Value
|
552
|
+
0x3a, 0x04, 0xde, 0xad, 0xbe, 0xef,
|
553
|
+
# Rebinding Time Value
|
554
|
+
0x3b, 0x04, 0xde, 0xad, 0xbe, 0xef,
|
555
|
+
# IP Address Lease Time Value
|
556
|
+
0x33, 0x04, 0xde, 0xad, 0xbe, 0xef,
|
557
|
+
# DHCP Server Identifier
|
558
|
+
0x36, 0x04, 0xc0, 0xa8, 0x00, 0x0a,
|
559
|
+
# Subnet Mask
|
560
|
+
0x01, 0x04, 0xff, 0xff, 0xff, 0x00,
|
561
|
+
# End Option
|
562
|
+
0xff,
|
563
|
+
# Padding Field
|
564
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
565
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
566
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
567
|
+
0x00, 0x00
|
568
|
+
]
|
569
|
+
end
|
570
|
+
|
571
|
+
its(:class) { should be Pio::Dhcp::Ack }
|
572
|
+
its('destination_mac.to_s') { should eq '11:22:33:44:55:66' }
|
573
|
+
its('source_mac.to_s') { should eq 'aa:bb:cc:dd:ee:ff' }
|
574
|
+
its(:ether_type) { should eq 2048 }
|
575
|
+
its(:ip_version) { should eq 4 }
|
576
|
+
its(:ip_header_length) { should eq 5 }
|
577
|
+
its(:ip_type_of_service) { should eq 0 }
|
578
|
+
its(:ip_total_length) { should eq 328 }
|
579
|
+
its(:ip_identifier) { should eq 0x0000 }
|
580
|
+
its(:ip_flag) { should eq 0 }
|
581
|
+
its(:ip_fragment) { should eq 0 }
|
582
|
+
its(:ip_ttl) { should eq 128 }
|
583
|
+
its(:ip_protocol) { should eq 17 }
|
584
|
+
its(:ip_header_checksum) { should eq 0xb849 }
|
585
|
+
its('ip_source_address.to_s') { should eq '192.168.0.10' }
|
586
|
+
its('ip_destination_address.to_s') { should eq '192.168.0.1' }
|
587
|
+
its(:udp_src_port) { should eq 67 }
|
588
|
+
its(:udp_dst_port) { should eq 68 }
|
589
|
+
its(:udp_length) { should eq 308 }
|
590
|
+
its(:udp_checksum) { should eq 0x1b64 }
|
591
|
+
its(:message_type) { should eq 5 }
|
592
|
+
its(:hw_addr_type) { should eq 1 }
|
593
|
+
its(:hw_addr_len) { should eq 6 }
|
594
|
+
its(:hops) { should eq 0 }
|
595
|
+
its(:transaction_id) { should eq 0xdeadbeef }
|
596
|
+
its(:seconds) { should eq 0 }
|
597
|
+
its(:bootp_flags) { should eq 0x0000 }
|
598
|
+
its('client_ip_address.to_s') { should eq '0.0.0.0' }
|
599
|
+
its('your_ip_address.to_s') { should eq '192.168.0.1' }
|
600
|
+
its('next_server_ip_address.to_s') { should eq '0.0.0.0' }
|
601
|
+
its('relay_agent_ip_address.to_s') { should eq '0.0.0.0' }
|
602
|
+
its('client_mac_address.to_s') { should eq 'aa:bb:cc:dd:ee:ff' }
|
603
|
+
its('server_identifier.to_s') { should eq '192.168.0.10' }
|
604
|
+
its('subnet_mask.to_s') { should eq '255.255.255.0' }
|
605
|
+
its(:renewal_time_value) { should eq 0xdeadbeef }
|
606
|
+
its(:rebinding_time_value) { should eq 0xdeadbeef }
|
607
|
+
its(:ip_address_lease_time) { should eq 0xdeadbeef }
|
608
|
+
end
|
609
|
+
end
|