Method: EtherShell::ShellDsl#out

Defined in:
lib/ether_shell/shell_dsl.rb

#out(packet_data) ⇒ Object

Outputs a packet.

Args:

packet_data:: an Array of integers (bytes), a hex string starting with 0x,
              or a string of raw bytes

Raises:

RuntimeError:: if the shell was not connected to a socket by a call to
               connect or socket


76
77
78
79
80
81
82
83
84
85
# File 'lib/ether_shell/shell_dsl.rb', line 76

def out(packet_data)
  raise "Not connected. did you forget to call connect?" unless @_socket
  bytes = EtherShell::ShellDsl.parse_packet_data packet_data
  
  
  print "Sending #{bytes.unpack('H*').first}... " if @_verbose
  @_socket.send bytes
  print "OK\n" if @_verbose
  EtherShell::ShellDsl.nothing
end