Feb 2009 -- Due to time pressures, the ongoing development of 'rope' has been suspended temporarily.

Handling IP Addresses

The source and destination IP (v4) addresses of a packet can be accessed using the registers $ip_saddr and $ip_daddr. Both of these contain four bytes (octets) where each byte is one field of the IP address. This binary format can be converted into the traditional human-readable string syntax using the ipv4_ntoa action word, like this..

ipv4_ntoa( $ip_saddr ) println

An IPv4 address, spelled out like 192.168.0.10 in the source code (or passed to the script using the --rope-push-ip option [see PassingArguments]) is actually a 4-byte string where the four octets evaluate to the matching bytes in the string. This means that 1.2.3.4 is equivalent to "\1\2\3\4".

The human-readable string representation can be printed using code like..

192.168.0.10 ipv4_ntoa print

This means you can perform tests for IP addresses in certain subnets (etc) using boolean arithmetic. For example, to test for an address in the 192.168.0.0/16 subnet, you could use..

$ip_saddr 255.255.0.0 and 192.168.0.0 eq assert

As of the 20050418 release, this syntax can be used to build strings of arbitary lengths (see string).