Skip to content
Eddie Kohler edited this page Oct 17, 2017 · 2 revisions

StoreIPAddress Element Documentation

NAME

StoreIPAddress — Click element; stores IP address in packet

SYNOPSIS

StoreIPAddress(OFFSET)
StoreIPAddress(ADDR, OFFSET)

Ports: 1 input, 1-2 outputs
Processing: agnostic, but output 1 is push

DESCRIPTION

The one-argument form writes the destination IP address annotation into the packet at offset OFFSET, usually an integer. But if the annotation is zero, it doesn't change the packet.

The two-argument form writes IP address ADDR into the packet at offset OFFSET. ADDR can be zero.

The OFFSET argument may be the special string 'src' or 'dst'. In this case, incoming packets must be IP packets. StoreIPAddress writes the address into either the source or destination field of the IP packet header, as specified, and incrementally updates the IP checksum (and, if appropriate, the TCP/UDP checksum) to account for the change.

If OFFSET is out of range, the packet is dropped or emitted on optional output 1.

NOTES

Unless you use a special OFFSET of 'src' or 'dst', this element doesn't recalculate any checksums. If you store the address into an existing IP packet, the packet's checksum will need to be set -- for example, with SetIPChecksum. And don't forget that you might need to recalculate TCP and UDP checksums as well. Here's a useful compound element:

  elementclass FixIPChecksums {
      // fix the IP checksum, and any embedded checksums that
      // include data from the IP header (TCP and UDP in particular)
      input -> SetIPChecksum
          -> ipc :: IPClassifier(tcp, udp, -)
          -> SetTCPChecksum
          -> output;
      ipc[1] -> SetUDPChecksum -> output;
      ipc[2] -> output
  }

SEE ALSO

SetIPChecksum, SetTCPChecksum, SetUDPChecksum, IPAddrPairRewriter, IPAddrRewriter

Generated by click-elem2man from ../elements/ip/storeipaddress.hh:7 on 2017/10/17.

Clone this wiki locally