2006-12-03 06:07:13 +00:00
|
|
|
/* Header for use in defining a given protocol. */
|
|
|
|
#ifndef _NF_NAT_PROTOCOL_H
|
|
|
|
#define _NF_NAT_PROTOCOL_H
|
|
|
|
#include <net/netfilter/nf_nat.h>
|
|
|
|
#include <linux/netfilter/nfnetlink_conntrack.h>
|
|
|
|
|
|
|
|
struct nf_nat_range;
|
|
|
|
|
|
|
|
struct nf_nat_protocol
|
|
|
|
{
|
|
|
|
/* Protocol number. */
|
|
|
|
unsigned int protonum;
|
|
|
|
|
|
|
|
struct module *me;
|
|
|
|
|
|
|
|
/* Translate a packet to the target according to manip type.
|
|
|
|
Return true if succeeded. */
|
2007-10-15 07:53:15 +00:00
|
|
|
int (*manip_pkt)(struct sk_buff *skb,
|
2006-12-03 06:07:13 +00:00
|
|
|
unsigned int iphdroff,
|
|
|
|
const struct nf_conntrack_tuple *tuple,
|
|
|
|
enum nf_nat_manip_type maniptype);
|
|
|
|
|
|
|
|
/* Is the manipable part of the tuple between min and max incl? */
|
|
|
|
int (*in_range)(const struct nf_conntrack_tuple *tuple,
|
|
|
|
enum nf_nat_manip_type maniptype,
|
|
|
|
const union nf_conntrack_man_proto *min,
|
|
|
|
const union nf_conntrack_man_proto *max);
|
|
|
|
|
|
|
|
/* Alter the per-proto part of the tuple (depending on
|
|
|
|
maniptype), to give a unique tuple in the given range if
|
|
|
|
possible; return false if not. Per-protocol part of tuple
|
|
|
|
is initialized to the incoming packet. */
|
|
|
|
int (*unique_tuple)(struct nf_conntrack_tuple *tuple,
|
|
|
|
const struct nf_nat_range *range,
|
|
|
|
enum nf_nat_manip_type maniptype,
|
|
|
|
const struct nf_conn *ct);
|
|
|
|
|
2007-09-28 21:37:41 +00:00
|
|
|
int (*range_to_nlattr)(struct sk_buff *skb,
|
2006-12-03 06:07:13 +00:00
|
|
|
const struct nf_nat_range *range);
|
|
|
|
|
2007-09-28 21:37:41 +00:00
|
|
|
int (*nlattr_to_range)(struct nlattr *tb[],
|
2006-12-03 06:07:13 +00:00
|
|
|
struct nf_nat_range *range);
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Protocol registration. */
|
2007-12-18 06:37:36 +00:00
|
|
|
extern int nf_nat_protocol_register(const struct nf_nat_protocol *proto);
|
|
|
|
extern void nf_nat_protocol_unregister(const struct nf_nat_protocol *proto);
|
2006-12-03 06:07:13 +00:00
|
|
|
|
2007-12-18 06:37:36 +00:00
|
|
|
extern const struct nf_nat_protocol *nf_nat_proto_find_get(u_int8_t protocol);
|
|
|
|
extern void nf_nat_proto_put(const struct nf_nat_protocol *proto);
|
2006-12-03 06:07:13 +00:00
|
|
|
|
|
|
|
/* Built-in protocols. */
|
2007-12-18 06:37:36 +00:00
|
|
|
extern const struct nf_nat_protocol nf_nat_protocol_tcp;
|
|
|
|
extern const struct nf_nat_protocol nf_nat_protocol_udp;
|
|
|
|
extern const struct nf_nat_protocol nf_nat_protocol_icmp;
|
|
|
|
extern const struct nf_nat_protocol nf_nat_unknown_protocol;
|
2006-12-03 06:07:13 +00:00
|
|
|
|
|
|
|
extern int init_protocols(void) __init;
|
|
|
|
extern void cleanup_protocols(void);
|
2007-12-18 06:37:36 +00:00
|
|
|
extern const struct nf_nat_protocol *find_nat_proto(u_int16_t protonum);
|
2006-12-03 06:07:13 +00:00
|
|
|
|
2008-03-20 14:15:47 +00:00
|
|
|
extern int nf_nat_proto_in_range(const struct nf_conntrack_tuple *tuple,
|
|
|
|
enum nf_nat_manip_type maniptype,
|
|
|
|
const union nf_conntrack_man_proto *min,
|
|
|
|
const union nf_conntrack_man_proto *max);
|
|
|
|
|
|
|
|
extern int nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple,
|
|
|
|
const struct nf_nat_range *range,
|
|
|
|
enum nf_nat_manip_type maniptype,
|
|
|
|
const struct nf_conn *ct,
|
|
|
|
u_int16_t *rover);
|
|
|
|
|
2008-04-14 09:15:47 +00:00
|
|
|
extern int nf_nat_proto_range_to_nlattr(struct sk_buff *skb,
|
|
|
|
const struct nf_nat_range *range);
|
|
|
|
extern int nf_nat_proto_nlattr_to_range(struct nlattr *tb[],
|
|
|
|
struct nf_nat_range *range);
|
2006-12-03 06:07:13 +00:00
|
|
|
|
|
|
|
#endif /*_NF_NAT_PROTO_H*/
|