1 /* Header for use in defining a given protocol. */
2 #ifndef _IP_NAT_PROTOCOL_H
3 #define _IP_NAT_PROTOCOL_H
4 #include <linux/init.h>
5 #include <linux/list.h>
10 struct ip_nat_protocol
15 /* Protocol number. */
16 unsigned int protonum
;
18 /* Translate a packet to the target according to manip type.
19 Return true if succeeded. */
20 int (*manip_pkt
)(struct sk_buff
**pskb
,
21 unsigned int iphdroff
,
22 const struct ip_conntrack_tuple
*tuple
,
23 enum ip_nat_manip_type maniptype
);
25 /* Is the manipable part of the tuple between min and max incl? */
26 int (*in_range
)(const struct ip_conntrack_tuple
*tuple
,
27 enum ip_nat_manip_type maniptype
,
28 const union ip_conntrack_manip_proto
*min
,
29 const union ip_conntrack_manip_proto
*max
);
31 /* Alter the per-proto part of the tuple (depending on
32 maniptype), to give a unique tuple in the given range if
33 possible; return false if not. Per-protocol part of tuple
34 is initialized to the incoming packet. */
35 int (*unique_tuple
)(struct ip_conntrack_tuple
*tuple
,
36 const struct ip_nat_range
*range
,
37 enum ip_nat_manip_type maniptype
,
38 const struct ip_conntrack
*conntrack
);
40 unsigned int (*print
)(char *buffer
,
41 const struct ip_conntrack_tuple
*match
,
42 const struct ip_conntrack_tuple
*mask
);
44 unsigned int (*print_range
)(char *buffer
,
45 const struct ip_nat_range
*range
);
48 #define MAX_IP_NAT_PROTO 256
49 extern struct ip_nat_protocol
*ip_nat_protos
[MAX_IP_NAT_PROTO
];
51 /* Protocol registration. */
52 extern int ip_nat_protocol_register(struct ip_nat_protocol
*proto
);
53 extern void ip_nat_protocol_unregister(struct ip_nat_protocol
*proto
);
55 static inline struct ip_nat_protocol
*ip_nat_find_proto(u_int8_t protocol
)
57 return ip_nat_protos
[protocol
];
60 /* Built-in protocols. */
61 extern struct ip_nat_protocol ip_nat_protocol_tcp
;
62 extern struct ip_nat_protocol ip_nat_protocol_udp
;
63 extern struct ip_nat_protocol ip_nat_protocol_icmp
;
64 extern struct ip_nat_protocol ip_nat_unknown_protocol
;
66 extern int init_protocols(void) __init
;
67 extern void cleanup_protocols(void);
68 extern struct ip_nat_protocol
*find_nat_proto(u_int16_t protonum
);
70 #endif /*_IP_NAT_PROTO_H*/