Skip to content

Commit

Permalink
Add Arp::Reply#inspect
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuhito committed Jul 11, 2016
1 parent 6ab3bf7 commit fe48f4a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'bundler/gem_tasks'

RELISH_PROJECT = 'trema/pio'.freeze
FLAY_THRESHOLD = 1524
FLAY_THRESHOLD = 1594

task default: :travis
task test: [:spec, :cucumber]
Expand Down
15 changes: 15 additions & 0 deletions features/arp_reply.feature
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,18 @@ Feature: Arp::Reply
0xc0, 0xa8, 0x53, 0x03, # target_protocol_address
].pack('C42')
"""

Scenario: ARP reply inspection
When I eval the following Ruby code:
"""ruby
Pio::Arp::Reply.new(
destination_mac: '00:26:82:eb:ea:d1',
source_mac: '00:16:9d:1d:9c:c4',
sender_protocol_address: '192.168.83.254',
target_protocol_address: '192.168.83.3'
).inspect
"""
Then the result of eval should be:
"""ruby
#<Arp::Reply destination_mac: "00:26:82:eb:ea:d1", source_mac: "00:16:9d:1d:9c:c4", ether_type: 0x0806, hardware_type: 1, protocol_length: 4, operation: 2, sender_hardware_address: "00:16:9d:1d:9c:c4", sender_protocol_address: "192.168.83.254", target_hardware_address: "00:26:82:eb:ea:d1", target_protocol_address: "192.168.83.3">
"""
6 changes: 6 additions & 0 deletions lib/pio/arp/reply.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ class Reply < Message
OPERATION = 2
public_class_method :new

# rubocop:disable LineLength
def inspect
%(#<Arp::Reply destination_mac: "#{destination_mac}", source_mac: "#{source_mac}", ether_type: #{format '0x%04x', ether_type}, hardware_type: #{hardware_type}, protocol_length: #{protocol_length}, operation: #{operation}, sender_hardware_address: "#{sender_hardware_address}", sender_protocol_address: "#{sender_protocol_address}", target_hardware_address: "#{target_hardware_address}", target_protocol_address: "#{target_protocol_address}">)
end
# rubocop:enable LineLength

# User options for creating an Arp Reply.
class Options < Pio::Options
mandatory_option :source_mac
Expand Down

0 comments on commit fe48f4a

Please sign in to comment.