-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
110 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
Feature: Arp Request | ||
Scenario: create an ARP request | ||
When I create a packet with: | ||
""" | ||
Pio::Arp::Request.new( | ||
source_mac: '00:26:82:eb:ea:d1', | ||
sender_protocol_address: '192.168.83.3', | ||
target_protocol_address: '192.168.83.254' | ||
) | ||
""" | ||
Then the packet has the following fields and values: | ||
| field | value | | ||
| class | Pio::Arp::Request | | ||
| destination_mac | ff:ff:ff:ff:ff:ff | | ||
| source_mac | 00:26:82:eb:ea:d1 | | ||
| ether_type | 2054 | | ||
| hardware_type | 1 | | ||
| protocol_type | 2048 | | ||
| hardware_length | 6 | | ||
| protocol_length | 4 | | ||
| operation | 1 | | ||
| sender_hardware_address | 00:26:82:eb:ea:d1 | | ||
| sender_protocol_address | 192.168.83.3 | | ||
| target_hardware_address | 00:00:00:00:00:00 | | ||
| target_protocol_address | 192.168.83.254 | | ||
|
||
Scenario: convert to hex string | ||
When I eval the following Ruby code: | ||
"""ruby | ||
Pio::Arp::Request.new( | ||
source_mac: '00:26:82:eb:ea:d1', | ||
sender_protocol_address: '192.168.83.3', | ||
target_protocol_address: '192.168.83.254' | ||
).to_hex | ||
""" | ||
Then the result of eval should be: | ||
""" | ||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, # destination_mac | ||
0x00, 0x26, 0x82, 0xeb, 0xea, 0xd1, # source_mac | ||
0x08, 0x06, # ether_type | ||
0x00, 0x01, # hardware_type | ||
0x08, 0x00, # protocol_type | ||
0x06, # hardware_length | ||
0x04, # protocol_length | ||
0x00, 0x01, # operation | ||
0x00, 0x26, 0x82, 0xeb, 0xea, 0xd1, # sender_hardware_address | ||
0xc0, 0xa8, 0x53, 0x03, # sender_protocol_address | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, # target_hardware_address | ||
0xc0, 0xa8, 0x53, 0xfe, # target_protocol_address | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
When(/^I eval the following Ruby code:$/) do |ruby_code| | ||
@result = Pio.module_eval(ruby_code) | ||
end | ||
|
||
Then(/^the result of eval should be:$/) do |expected| | ||
expect(@result.to_s).to eq expected | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,10 @@ def &(other) | |
def ==(other) | ||
get == other | ||
end | ||
|
||
def to_hex | ||
octets.map(&:to_hex).join(', ') | ||
end | ||
end | ||
end | ||
end |