netfilter
firewalling, NAT, and packet mangling for linux
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
network.h File Reference
#include <stdint.h>
#include <sys/types.h>
Include dependency graph for network.h:
This graph shows which files directly or indirectly include this file:

Data Structures

struct  nethdr
 
struct  nethdr_ack
 
struct  netattr
 
struct  nta_attr_natseqadj
 

Macros

#define CONNTRACKD_PROTOCOL_VERSION   1
 
#define NETHDR_SIZ   nethdr_align(sizeof(struct nethdr))
 
#define NETHDR_DATA(x)   (struct netattr *)(((char *)x) + NETHDR_SIZ)
 
#define NETHDR_TAIL(x)   (struct netattr *)(((char *)x) + x->len)
 
#define NETHDR_ACK_SIZ   nethdr_align(sizeof(struct nethdr_ack))
 
#define BUILD_NETMSG_FROM_CT(ct, query)
 
#define BUILD_NETMSG_FROM_EXP(exp, query)
 
#define IS_DATA(x)
 
#define IS_ACK(x)   (x->type == NET_T_CTL && x->flags & NET_F_ACK)
 
#define IS_NACK(x)   (x->type == NET_T_CTL && x->flags & NET_F_NACK)
 
#define IS_RESYNC(x)   (x->type == NET_T_CTL && x->flags & NET_F_RESYNC)
 
#define IS_ALIVE(x)   (x->type == NET_T_CTL && x->flags & NET_F_ALIVE)
 
#define IS_HELLO(x)   (x->flags & NET_F_HELLO)
 
#define IS_HELLO_BACK(x)   (x->flags & NET_F_HELLO_BACK)
 
#define HDR_NETWORK2HOST(x)
 
#define HDR_HOST2NETWORK(x)
 
#define after(seq2, seq1)   before(seq1, seq2)
 
#define ATTR_NETWORK2HOST(x)
 
#define NTA_SIZE(len)   NTA_ALIGN(sizeof(struct netattr)) + len
 
#define NTA_DATA(x)   (void *)(((char *)x) + NTA_ALIGN(sizeof(struct netattr)))
 
#define NTA_NEXT(x, len)
 
#define NTA_ALIGNTO   4
 
#define NTA_ALIGN(len)   (((len) + NTA_ALIGNTO - 1) & ~(NTA_ALIGNTO - 1))
 
#define NTA_LENGTH(len)   (NTA_ALIGN(sizeof(struct netattr)) + (len))
 
#define NTA_LABELS_MAX_SIZE   (4096/sizeof(uint32_t))
 

Enumerations

enum  nethdr_type {
  NET_T_STATE_CT_NEW = 0,
  NET_T_STATE_CT_UPD,
  NET_T_STATE_CT_DEL,
  NET_T_STATE_EXP_NEW = 3,
  NET_T_STATE_EXP_UPD,
  NET_T_STATE_EXP_DEL,
  NET_T_STATE_MAX = NET_T_STATE_EXP_DEL,
  NET_T_CTL = 10
}
 
enum  {
  NET_F_UNUSED = (1 << 0),
  NET_F_RESYNC = (1 << 1),
  NET_F_NACK = (1 << 2),
  NET_F_ACK = (1 << 3),
  NET_F_ALIVE = (1 << 4),
  NET_F_HELLO = (1 << 5),
  NET_F_HELLO_BACK = (1 << 6)
}
 
enum  {
  MSG_DATA,
  MSG_CTL,
  MSG_DROP,
  MSG_BAD
}
 
enum  {
  SEQ_UNKNOWN,
  SEQ_UNSET,
  SEQ_IN_SYNC,
  SEQ_AFTER,
  SEQ_BEFORE
}
 
enum  nta_attr {
  NTA_IPV4 = 0,
  NTA_IPV6,
  NTA_L4PROTO,
  NTA_PORT,
  NTA_TCP_STATE = 4,
  NTA_STATUS,
  NTA_TIMEOUT,
  NTA_MARK,
  NTA_MASTER_IPV4 = 8,
  NTA_MASTER_IPV6,
  NTA_MASTER_L4PROTO,
  NTA_MASTER_PORT,
  NTA_SNAT_IPV4 = 12,
  NTA_DNAT_IPV4,
  NTA_SPAT_PORT,
  NTA_DPAT_PORT,
  NTA_NAT_SEQ_ADJ = 16,
  NTA_SCTP_STATE,
  NTA_SCTP_VTAG_ORIG,
  NTA_SCTP_VTAG_REPL,
  NTA_DCCP_STATE = 20,
  NTA_DCCP_ROLE,
  NTA_ICMP_TYPE,
  NTA_ICMP_CODE,
  NTA_ICMP_ID,
  NTA_TCP_WSCALE_ORIG,
  NTA_TCP_WSCALE_REPL,
  NTA_HELPER_NAME,
  NTA_LABELS,
  NTA_MAX
}
 
enum  nta_exp_attr {
  NTA_EXP_MASTER_IPV4 = 0,
  NTA_EXP_MASTER_IPV6,
  NTA_EXP_MASTER_L4PROTO,
  NTA_EXP_MASTER_PORT,
  NTA_EXP_EXPECT_IPV4 = 4,
  NTA_EXP_EXPECT_IPV6,
  NTA_EXP_EXPECT_L4PROTO,
  NTA_EXP_EXPECT_PORT,
  NTA_EXP_MASK_IPV4 = 8,
  NTA_EXP_MASK_IPV6,
  NTA_EXP_MASK_L4PROTO,
  NTA_EXP_MASK_PORT,
  NTA_EXP_TIMEOUT,
  NTA_EXP_FLAGS,
  NTA_EXP_CLASS,
  NTA_EXP_NAT_IPV4,
  NTA_EXP_NAT_PORT,
  NTA_EXP_NAT_L4PROTO,
  NTA_EXP_NAT_DIR,
  NTA_EXP_HELPER_NAME,
  NTA_EXP_FN,
  NTA_EXP_MAX
}
 

Functions

int nethdr_align (int len)
 
int nethdr_size (int len)
 
void nethdr_set (struct nethdr *net, int type)
 
void nethdr_set_ack (struct nethdr *net)
 
void nethdr_set_ctl (struct nethdr *net)
 
int object_status_to_network_type (struct cache_object *obj)
 
int nethdr_track_seq (uint32_t seq, uint32_t *exp_seq)
 
void nethdr_track_update_seq (uint32_t seq)
 
int nethdr_track_is_seq_set (void)
 
void ct2msg (const struct nf_conntrack *ct, struct nethdr *n)
 
int msg2ct (struct nf_conntrack *ct, struct nethdr *n, size_t remain)
 
void exp2msg (const struct nf_expect *exp, struct nethdr *n)
 
int msg2exp (struct nf_expect *exp, struct nethdr *n, size_t remain)
 

Macro Definition Documentation

#define after (   seq2,
  seq1 
)    before(seq1, seq2)
#define ATTR_NETWORK2HOST (   x)
Value:
({ \
x->nta_len = ntohs(x->nta_len); \
x->nta_attr = ntohs(x->nta_attr); \
})

Referenced by msg2ct(), and msg2exp().

#define BUILD_NETMSG_FROM_CT (   ct,
  query 
)
Value:
({ \
static char __net[4096]; \
struct nethdr *__hdr = (struct nethdr *) __net; \
memset(__hdr, 0, NETHDR_SIZ); \
nethdr_set(__hdr, query); \
ct2msg(ct, __hdr); \
__hdr; \
})
void ct2msg(const struct nf_conntrack *ct, struct nethdr *n)
Definition: build.c:216
#define NETHDR_SIZ
Definition: network.h:26
#define HDR_HOST2NETWORK(x)
Definition: network.h:146
struct nf_conntrack * ct
Definition: conntrack.c:72
void nethdr_set(struct nethdr *net, int type)
Definition: network.c:53
Definition: network.h:12
#define BUILD_NETMSG_FROM_EXP (   exp,
  query 
)
Value:
({ \
static char __net[4096]; \
struct nethdr *__hdr = (struct nethdr *) __net; \
memset(__hdr, 0, NETHDR_SIZ); \
nethdr_set(__hdr, query); \
exp2msg(exp, __hdr); \
__hdr; \
})
#define NETHDR_SIZ
Definition: network.h:26
#define HDR_HOST2NETWORK(x)
Definition: network.h:146
void nethdr_set(struct nethdr *net, int type)
Definition: network.c:53
void exp2msg(const struct nf_expect *exp, struct nethdr *n)
Definition: build.c:333
struct nf_expect * exp
Definition: conntrack.c:73
Definition: network.h:12
#define CONNTRACKD_PROTOCOL_VERSION   1
#define HDR_HOST2NETWORK (   x)
Value:
({ \
if (IS_ACK(x) || IS_NACK(x) || IS_RESYNC(x)) { \
struct nethdr_ack *__ack = (struct nethdr_ack *) x; \
__ack->from = htonl(__ack->from); \
__ack->to = htonl(__ack->to); \
} \
x->len = htons(x->len); \
x->seq = htonl(x->seq); \
})
#define IS_RESYNC(x)
Definition: network.h:130
#define IS_NACK(x)
Definition: network.h:129
#define IS_ACK(x)
Definition: network.h:128
Definition: network.h:53
uint32_t from
Definition: network.h:66
#define HDR_NETWORK2HOST (   x)
Value:
({ \
x->len = ntohs(x->len); \
x->seq = ntohl(x->seq); \
if (IS_ACK(x) || IS_NACK(x) || IS_RESYNC(x)) { \
struct nethdr_ack *__ack = (struct nethdr_ack *) x; \
__ack->from = ntohl(__ack->from); \
__ack->to = ntohl(__ack->to); \
} \
})
#define IS_RESYNC(x)
Definition: network.h:130
#define IS_NACK(x)
Definition: network.h:129
#define IS_ACK(x)
Definition: network.h:128
Definition: network.h:53
uint32_t from
Definition: network.h:66
#define IS_ACK (   x)    (x->type == NET_T_CTL && x->flags & NET_F_ACK)
#define IS_ALIVE (   x)    (x->type == NET_T_CTL && x->flags & NET_F_ALIVE)
#define IS_DATA (   x)
Value:
(x->type <= NET_T_STATE_MAX && \
(x->flags & ~(NET_F_HELLO | NET_F_HELLO_BACK)) == 0)
Definition: network.h:78
Definition: network.h:77
Definition: network.h:35
#define IS_HELLO (   x)    (x->flags & NET_F_HELLO)
#define IS_HELLO_BACK (   x)    (x->flags & NET_F_HELLO_BACK)
#define IS_NACK (   x)    (x->type == NET_T_CTL && x->flags & NET_F_NACK)
#define IS_RESYNC (   x)    (x->type == NET_T_CTL && x->flags & NET_F_RESYNC)
#define NETHDR_ACK_SIZ   nethdr_align(sizeof(struct nethdr_ack))

Referenced by nethdr_set_ack().

#define NETHDR_DATA (   x)    (struct netattr *)(((char *)x) + NETHDR_SIZ)

Referenced by msg2ct(), and msg2exp().

#define NETHDR_SIZ   nethdr_align(sizeof(struct nethdr))
#define NETHDR_TAIL (   x)    (struct netattr *)(((char *)x) + x->len)
#define NTA_ALIGN (   len)    (((len) + NTA_ALIGNTO - 1) & ~(NTA_ALIGNTO - 1))
#define NTA_ALIGNTO   4
#define NTA_DATA (   x)    (void *)(((char *)x) + NTA_ALIGN(sizeof(struct netattr)))

Referenced by msg2ct(), and msg2exp().

#define NTA_LABELS_MAX_SIZE   (4096/sizeof(uint32_t))
#define NTA_LENGTH (   len)    (NTA_ALIGN(sizeof(struct netattr)) + (len))

Referenced by msg2ct(), and msg2exp().

#define NTA_NEXT (   x,
  len 
)
Value:
( \
len -= NTA_ALIGN(x->nta_len), \
(struct netattr *)(((char *)x) + NTA_ALIGN(x->nta_len)) \
)
Definition: network.h:176
#define NTA_ALIGN(len)
Definition: network.h:199
int len
Definition: utils.c:56

Referenced by msg2ct(), and msg2exp().

#define NTA_SIZE (   len)    NTA_ALIGN(sizeof(struct netattr)) + len

Enumeration Type Documentation

anonymous enum
Enumerator
NET_F_UNUSED 
NET_F_RESYNC 
NET_F_NACK 
NET_F_ACK 
NET_F_ALIVE 
NET_F_HELLO 
NET_F_HELLO_BACK 
anonymous enum
Enumerator
MSG_DATA 
MSG_CTL 
MSG_DROP 
MSG_BAD 
anonymous enum
Enumerator
SEQ_UNKNOWN 
SEQ_UNSET 
SEQ_IN_SYNC 
SEQ_AFTER 
SEQ_BEFORE 
Enumerator
NET_T_STATE_CT_NEW 
NET_T_STATE_CT_UPD 
NET_T_STATE_CT_DEL 
NET_T_STATE_EXP_NEW 
NET_T_STATE_EXP_UPD 
NET_T_STATE_EXP_DEL 
NET_T_STATE_MAX 
NET_T_CTL 
enum nta_attr
Enumerator
NTA_IPV4 
NTA_IPV6 
NTA_L4PROTO 
NTA_PORT 
NTA_TCP_STATE 
NTA_STATUS 
NTA_TIMEOUT 
NTA_MARK 
NTA_MASTER_IPV4 
NTA_MASTER_IPV6 
NTA_MASTER_L4PROTO 
NTA_MASTER_PORT 
NTA_SNAT_IPV4 
NTA_DNAT_IPV4 
NTA_SPAT_PORT 
NTA_DPAT_PORT 
NTA_NAT_SEQ_ADJ 
NTA_SCTP_STATE 
NTA_SCTP_VTAG_ORIG 
NTA_SCTP_VTAG_REPL 
NTA_DCCP_STATE 
NTA_DCCP_ROLE 
NTA_ICMP_TYPE 
NTA_ICMP_CODE 
NTA_ICMP_ID 
NTA_TCP_WSCALE_ORIG 
NTA_TCP_WSCALE_REPL 
NTA_HELPER_NAME 
NTA_LABELS 
NTA_MAX 
Enumerator
NTA_EXP_MASTER_IPV4 
NTA_EXP_MASTER_IPV6 
NTA_EXP_MASTER_L4PROTO 
NTA_EXP_MASTER_PORT 
NTA_EXP_EXPECT_IPV4 
NTA_EXP_EXPECT_IPV6 
NTA_EXP_EXPECT_L4PROTO 
NTA_EXP_EXPECT_PORT 
NTA_EXP_MASK_IPV4 
NTA_EXP_MASK_IPV6 
NTA_EXP_MASK_L4PROTO 
NTA_EXP_MASK_PORT 
NTA_EXP_TIMEOUT 
NTA_EXP_FLAGS 
NTA_EXP_CLASS 
NTA_EXP_NAT_IPV4 
NTA_EXP_NAT_PORT 
NTA_EXP_NAT_L4PROTO 
NTA_EXP_NAT_DIR 
NTA_EXP_HELPER_NAME 
NTA_EXP_FN 
NTA_EXP_MAX 

Function Documentation

int nethdr_align ( int  len)

References NETHDR_ALIGNTO.

void nethdr_set ( struct nethdr net,
int  type 
)

References NETHDR_SIZ, nethdr::type, and type.

void nethdr_set_ack ( struct nethdr net)

References NETHDR_ACK_SIZ.

void nethdr_set_ctl ( struct nethdr net)

References NETHDR_SIZ.

int nethdr_size ( int  len)

References len, and NETHDR_SIZ.

int nethdr_track_is_seq_set ( void  )
int nethdr_track_seq ( uint32_t  seq,
uint32_t *  exp_seq 
)
void nethdr_track_update_seq ( uint32_t  seq)

References STATE_SYNC.

int object_status_to_network_type ( struct cache_object obj)