-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
netfilter: add protocol independent NAT core
Convert the IPv4 NAT implementation to a protocol independent core and address family specific modules. Signed-off-by: Patrick McHardy <kaber@trash.net>
- Loading branch information
Patrick McHardy
authored and
Pablo Neira Ayuso
committed
Aug 30, 2012
1 parent
051966c
commit c7232c9
Showing
49 changed files
with
1,495 additions
and
1,140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#ifndef _NF_NAT_L3PROTO_H | ||
#define _NF_NAT_L3PROTO_H | ||
|
||
struct nf_nat_l4proto; | ||
struct nf_nat_l3proto { | ||
u8 l3proto; | ||
|
||
bool (*in_range)(const struct nf_conntrack_tuple *t, | ||
const struct nf_nat_range *range); | ||
|
||
u32 (*secure_port)(const struct nf_conntrack_tuple *t, __be16); | ||
|
||
bool (*manip_pkt)(struct sk_buff *skb, | ||
unsigned int iphdroff, | ||
const struct nf_nat_l4proto *l4proto, | ||
const struct nf_conntrack_tuple *target, | ||
enum nf_nat_manip_type maniptype); | ||
|
||
void (*csum_update)(struct sk_buff *skb, unsigned int iphdroff, | ||
__sum16 *check, | ||
const struct nf_conntrack_tuple *t, | ||
enum nf_nat_manip_type maniptype); | ||
|
||
void (*csum_recalc)(struct sk_buff *skb, u8 proto, | ||
void *data, __sum16 *check, | ||
int datalen, int oldlen); | ||
|
||
void (*decode_session)(struct sk_buff *skb, | ||
const struct nf_conn *ct, | ||
enum ip_conntrack_dir dir, | ||
unsigned long statusbit, | ||
struct flowi *fl); | ||
|
||
int (*nlattr_to_range)(struct nlattr *tb[], | ||
struct nf_nat_range *range); | ||
}; | ||
|
||
extern int nf_nat_l3proto_register(const struct nf_nat_l3proto *); | ||
extern void nf_nat_l3proto_unregister(const struct nf_nat_l3proto *); | ||
extern const struct nf_nat_l3proto *__nf_nat_l3proto_find(u8 l3proto); | ||
|
||
extern int nf_nat_icmp_reply_translation(struct sk_buff *skb, | ||
struct nf_conn *ct, | ||
enum ip_conntrack_info ctinfo, | ||
unsigned int hooknum); | ||
|
||
#endif /* _NF_NAT_L3PROTO_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* Header for use in defining a given protocol. */ | ||
#ifndef _NF_NAT_L4PROTO_H | ||
#define _NF_NAT_L4PROTO_H | ||
#include <net/netfilter/nf_nat.h> | ||
#include <linux/netfilter/nfnetlink_conntrack.h> | ||
|
||
struct nf_nat_range; | ||
struct nf_nat_l3proto; | ||
|
||
struct nf_nat_l4proto { | ||
/* Protocol number. */ | ||
u8 l4proto; | ||
|
||
/* Translate a packet to the target according to manip type. | ||
* Return true if succeeded. | ||
*/ | ||
bool (*manip_pkt)(struct sk_buff *skb, | ||
const struct nf_nat_l3proto *l3proto, | ||
unsigned int iphdroff, unsigned int hdroff, | ||
const struct nf_conntrack_tuple *tuple, | ||
enum nf_nat_manip_type maniptype); | ||
|
||
/* Is the manipable part of the tuple between min and max incl? */ | ||
bool (*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. Per-protocol part of tuple is initialized to the | ||
* incoming packet. | ||
*/ | ||
void (*unique_tuple)(const struct nf_nat_l3proto *l3proto, | ||
struct nf_conntrack_tuple *tuple, | ||
const struct nf_nat_range *range, | ||
enum nf_nat_manip_type maniptype, | ||
const struct nf_conn *ct); | ||
|
||
int (*nlattr_to_range)(struct nlattr *tb[], | ||
struct nf_nat_range *range); | ||
}; | ||
|
||
/* Protocol registration. */ | ||
extern int nf_nat_l4proto_register(u8 l3proto, const struct nf_nat_l4proto *l4proto); | ||
extern void nf_nat_l4proto_unregister(u8 l3proto, const struct nf_nat_l4proto *l4proto); | ||
|
||
extern const struct nf_nat_l4proto *__nf_nat_l4proto_find(u8 l3proto, u8 l4proto); | ||
|
||
/* Built-in protocols. */ | ||
extern const struct nf_nat_l4proto nf_nat_l4proto_tcp; | ||
extern const struct nf_nat_l4proto nf_nat_l4proto_udp; | ||
extern const struct nf_nat_l4proto nf_nat_l4proto_icmp; | ||
extern const struct nf_nat_l4proto nf_nat_l4proto_unknown; | ||
|
||
extern bool nf_nat_l4proto_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 void nf_nat_l4proto_unique_tuple(const struct nf_nat_l3proto *l3proto, | ||
struct nf_conntrack_tuple *tuple, | ||
const struct nf_nat_range *range, | ||
enum nf_nat_manip_type maniptype, | ||
const struct nf_conn *ct, | ||
u16 *rover); | ||
|
||
extern int nf_nat_l4proto_nlattr_to_range(struct nlattr *tb[], | ||
struct nf_nat_range *range); | ||
|
||
#endif /*_NF_NAT_L4PROTO_H*/ |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.