|
| 1 | +/* Header for use in defining a given protocol. */ |
| 2 | +#ifndef _NF_NAT_PROTOCOL_H |
| 3 | +#define _NF_NAT_PROTOCOL_H |
| 4 | +#include <net/netfilter/nf_nat.h> |
| 5 | +#include <linux/netfilter/nfnetlink_conntrack.h> |
| 6 | + |
| 7 | +struct nf_nat_range; |
| 8 | + |
| 9 | +struct nf_nat_protocol |
| 10 | +{ |
| 11 | + /* Protocol name */ |
| 12 | + const char *name; |
| 13 | + |
| 14 | + /* Protocol number. */ |
| 15 | + unsigned int protonum; |
| 16 | + |
| 17 | + struct module *me; |
| 18 | + |
| 19 | + /* Translate a packet to the target according to manip type. |
| 20 | + Return true if succeeded. */ |
| 21 | + int (*manip_pkt)(struct sk_buff **pskb, |
| 22 | + unsigned int iphdroff, |
| 23 | + const struct nf_conntrack_tuple *tuple, |
| 24 | + enum nf_nat_manip_type maniptype); |
| 25 | + |
| 26 | + /* Is the manipable part of the tuple between min and max incl? */ |
| 27 | + int (*in_range)(const struct nf_conntrack_tuple *tuple, |
| 28 | + enum nf_nat_manip_type maniptype, |
| 29 | + const union nf_conntrack_man_proto *min, |
| 30 | + const union nf_conntrack_man_proto *max); |
| 31 | + |
| 32 | + /* Alter the per-proto part of the tuple (depending on |
| 33 | + maniptype), to give a unique tuple in the given range if |
| 34 | + possible; return false if not. Per-protocol part of tuple |
| 35 | + is initialized to the incoming packet. */ |
| 36 | + int (*unique_tuple)(struct nf_conntrack_tuple *tuple, |
| 37 | + const struct nf_nat_range *range, |
| 38 | + enum nf_nat_manip_type maniptype, |
| 39 | + const struct nf_conn *ct); |
| 40 | + |
| 41 | + int (*range_to_nfattr)(struct sk_buff *skb, |
| 42 | + const struct nf_nat_range *range); |
| 43 | + |
| 44 | + int (*nfattr_to_range)(struct nfattr *tb[], |
| 45 | + struct nf_nat_range *range); |
| 46 | +}; |
| 47 | + |
| 48 | +/* Protocol registration. */ |
| 49 | +extern int nf_nat_protocol_register(struct nf_nat_protocol *proto); |
| 50 | +extern void nf_nat_protocol_unregister(struct nf_nat_protocol *proto); |
| 51 | + |
| 52 | +extern struct nf_nat_protocol *nf_nat_proto_find_get(u_int8_t protocol); |
| 53 | +extern void nf_nat_proto_put(struct nf_nat_protocol *proto); |
| 54 | + |
| 55 | +/* Built-in protocols. */ |
| 56 | +extern struct nf_nat_protocol nf_nat_protocol_tcp; |
| 57 | +extern struct nf_nat_protocol nf_nat_protocol_udp; |
| 58 | +extern struct nf_nat_protocol nf_nat_protocol_icmp; |
| 59 | +extern struct nf_nat_protocol nf_nat_unknown_protocol; |
| 60 | + |
| 61 | +extern int init_protocols(void) __init; |
| 62 | +extern void cleanup_protocols(void); |
| 63 | +extern struct nf_nat_protocol *find_nat_proto(u_int16_t protonum); |
| 64 | + |
| 65 | +extern int nf_nat_port_range_to_nfattr(struct sk_buff *skb, |
| 66 | + const struct nf_nat_range *range); |
| 67 | +extern int nf_nat_port_nfattr_to_range(struct nfattr *tb[], |
| 68 | + struct nf_nat_range *range); |
| 69 | + |
| 70 | +#endif /*_NF_NAT_PROTO_H*/ |
0 commit comments