5#include <click/cxxprotect.h>
8# include <net/checksum.h>
11# include <sys/types.h>
13# include <netinet/in.h>
14# include <netinet/ip.h>
15#define true linux_true
27#if CLICK_BYTE_ORDER == CLICK_BIG_ENDIAN
30#elif CLICK_BYTE_ORDER == CLICK_LITTLE_ENDIAN
34# error "unknown byte order"
37#define IP_DSCPMASK 0xFC
38#define IP_ECNMASK 0x03
39#define IP_ECN_NOT_ECT 0x00
40#define IP_ECN_ECT1 0x01
41#define IP_ECN_ECT2 0x02
50#define IP_OFFMASK 0X1FFF
55 struct in_addr ip_src;
56 struct in_addr ip_dst;
60#define IP_PROTO_ICMP 1
61#define IP_PROTO_IGMP 2
63#define IP_PROTO_IPIP 4
69#define IP_PROTO_BBN 10
70#define IP_PROTO_NVPII 11
71#define IP_PROTO_PUP 12
72#define IP_PROTO_ARGUS 13
73#define IP_PROTO_EMCON 14
74#define IP_PROTO_XNET 15
75#define IP_PROTO_CHAOS 16
76#define IP_PROTO_UDP 17
77#define IP_PROTO_MUX 18
78#define IP_PROTO_DCN 19
79#define IP_PROTO_HMP 20
80#define IP_PROTO_PRM 21
81#define IP_PROTO_XNS 22
82#define IP_PROTO_TRUNK1 23
83#define IP_PROTO_TRUNK2 24
84#define IP_PROTO_LEAF1 25
85#define IP_PROTO_LEAF2 26
86#define IP_PROTO_RDP 27
87#define IP_PROTO_IRTP 28
88#define IP_PROTO_ISOTP4 29
89#define IP_PROTO_NETBLT 30
90#define IP_PROTO_MFENSP 31
91#define IP_PROTO_MERIT 32
92#define IP_PROTO_DCCP 33
93#define IP_PROTO_RSVP 46
94#define IP_PROTO_GRE 47
95#define IP_PROTO_ICMP6 58
96#define IP_PROTO_CFTP 62
97#define IP_PROTO_SATNET 64
98#define IP_PROTO_MITSUBNET 65
99#define IP_PROTO_RVD 66
100#define IP_PROTO_IPPC 67
101#define IP_PROTO_SATMON 69
102#define IP_PROTO_IPCV 71
103#define IP_PROTO_BRSATMON 76
104#define IP_PROTO_WBMON 78
105#define IP_PROTO_WBEXPAK 79
106#define IP_PROTO_SCTP 132
107#define IP_PROTO_UDPLITE 136
109#define IP_PROTO_NONE 257
110#define IP_PROTO_TRANSP 258
111#define IP_PROTO_TCP_OR_UDP 256
112#define IP_PROTO_PAYLOAD 259
118#define IPOPT_SECURITY 130
119#define IPOPT_LSRR 131
120#define IPOPT_SATID 136
121#define IPOPT_SSRR 137
124#define IP_ISFRAG(iph) (((iph)->ip_off & htons(IP_MF | IP_OFFMASK)) != 0)
125#define IP_FIRSTFRAG(iph) (((iph)->ip_off & htons(IP_OFFMASK)) == 0)
130#if !CLICK_LINUXMODULE
136uint16_t click_in_cksum(
const unsigned char *x,
int len);
137uint16_t click_in_cksum_pseudohdr_raw(uint32_t csum, uint32_t src, uint32_t dst,
int proto,
int packet_len);
139# define click_in_cksum(addr, len) \
140 ip_compute_csum((unsigned char *)(addr), (len))
141# define click_in_cksum_pseudohdr_raw(csum, src, dst, proto, transport_len) \
142 csum_tcpudp_magic((src), (dst), (transport_len), (proto), ~(csum) & 0xFFFF)
144uint16_t click_in_cksum_pseudohdr_hard(uint32_t csum,
const struct click_ip *iph,
int packet_len);
145void click_update_zero_in_cksum_hard(uint16_t *csum,
const unsigned char *addr,
int len);
155static inline uint16_t
156click_in_cksum_pseudohdr(uint32_t data_csum,
const struct click_ip *iph,
160 return click_in_cksum_pseudohdr_raw(data_csum, iph->ip_src.s_addr, iph->ip_dst.s_addr, iph->ip_p, transport_len);
162 return click_in_cksum_pseudohdr_hard(data_csum, iph, transport_len);
181click_update_in_cksum(uint16_t *csum, uint16_t old_hw, uint16_t new_hw)
185 uint32_t sum = (~*csum & 0xFFFF) + (~old_hw & 0xFFFF) + new_hw;
186 sum = (sum & 0xFFFF) + (sum >> 16);
187 *csum = ~(sum + (sum >> 16));
200click_update_zero_in_cksum(uint16_t *csum,
const unsigned char *x,
int len)
203 click_update_zero_in_cksum_hard(csum, x, len);
207#include <click/cxxunprotect.h>