1 #ifndef _IP_SET_GETPORT_H
2 #define _IP_SET_GETPORT_H
6 #define INVALID_PORT (MAX_RANGE + 1)
8 /* We must handle non-linear skbs */
9 static inline ip_set_ip_t
10 get_port(const struct sk_buff
*skb
, const u_int32_t
*flags
)
12 struct iphdr
*iph
= ip_hdr(skb
);
13 u_int16_t offset
= ntohs(iph
->frag_off
) & IP_OFFSET
;
14 switch (iph
->protocol
) {
18 /* See comments at tcp_match in ip_tables.c */
22 if (skb_copy_bits(skb
, ip_hdr(skb
)->ihl
*4, &tcph
, sizeof(tcph
)) < 0)
23 /* No choice either */
26 return ntohs(flags
[0] & IPSET_SRC
?
27 tcph
.source
: tcph
.dest
);
35 if (skb_copy_bits(skb
, ip_hdr(skb
)->ihl
*4, &udph
, sizeof(udph
)) < 0)
36 /* No choice either */
39 return ntohs(flags
[0] & IPSET_SRC
?
40 udph
.source
: udph
.dest
);
46 #endif /* __KERNEL__ */
48 #endif /*_IP_SET_GETPORT_H*/