7#ifndef MIDDLEBOX_IPELEMENT_HH
8#define MIDDLEBOX_IPELEMENT_HH
10#include <click/config.h>
11#include <click/glue.hh>
62 const click_ip *iph = packet->
ip_header();
64 return ntohs(iph->ip_len);
69 return (((
const unsigned char *)packet->
ip_header()) - packet->
data());
74 click_ip *iph = packet->ip_header();
75 iph->ip_len = htons(length);
81 click_ip *iph = packet->ip_header();
84 unsigned hlen = iph->ip_hl << 2;
87 iph->ip_sum = click_in_cksum((
const unsigned char *)iph, hlen);
92 const click_ip *iph = packet->
ip_header();
94 return *(
const uint32_t*)&iph->ip_src;
99 const click_ip *iph = packet->
ip_header();
101 return *(
const uint32_t*)&iph->ip_dst;
This class provides several methods that can be used by elements that inherits from it in order to ma...
Definition ipelement.hh:22
void computeIPChecksum(WritablePacket *packet) const
Recompute the IP checksum of the packet and set it in the IP header.
Definition ipelement.hh:79
uint16_t packetTotalLength(Packet *packet) const
Return the length of the IP packet, obtained from the header.
Definition ipelement.hh:60
const uint32_t getSourceAddress(Packet *packet) const
Return the IP source address of the packet.
Definition ipelement.hh:90
void setPacketTotalLength(WritablePacket *packet, unsigned length) const
Set the length of the IP packet in the header.
Definition ipelement.hh:72
uint16_t getIPHeaderOffset(Packet *packet) const
Return the offset in the packet at which the IP header starts.
Definition ipelement.hh:67
const uint32_t getDestinationAddress(Packet *packet) const
Return the IP destination address of the packet.
Definition ipelement.hh:97
A network packet.
Definition packet.hh:68
const click_ip * ip_header() const
Return the packet's network header pointer as IPv4.
Definition packet.hh:1523
const unsigned char * data() const
Return the packet's data pointer.
Definition packet.hh:1207
A network packet believed not to be shared.
Definition packet.hh:1004