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

Data Structures

struct  proto_hdr_template
 struct proto_hdr_template - protocol header field description More...
 
struct  proto_desc
 
struct  hook_proto_desc
 struct hook_proto_desc - description of protocol constraints imposed by hook family More...
 
struct  dev_proto_desc
 struct dev_proto_desc - description of device LL protocol More...
 
struct  proto_ctx
 struct proto_ctx - protocol context More...
 

Macros

#define PROTO_BASE_MAX   (__PROTO_BASE_MAX - 1)
 
#define PROTO_HDR_TEMPLATE(__token, __dtype,__byteorder, __offset, __len)
 
#define PROTO_META_TEMPLATE(__token, __dtype, __key, __len)
 
#define PROTO_UPPER_MAX   16
 
#define PROTO_HDRS_MAX   20
 

Enumerations

enum  proto_bases {
  PROTO_BASE_INVALID,
  PROTO_BASE_LL_HDR,
  PROTO_BASE_NETWORK_HDR,
  PROTO_BASE_TRANSPORT_HDR,
  __PROTO_BASE_MAX
}
 enum proto_bases - protocol bases More...
 

Variables

const char * proto_base_names []
 
const char * proto_base_tokens []
 

: protocol name

struct proto_desc - protocol header description

: header base : key of template containing upper layer protocol description : link to upper layer protocol descriptions indexed by protocol value : header templates

#define PROTO_LINK(__num, __desc)   { .num = (__num), .desc = (__desc), }
 
#define HOOK_PROTO_DESC(__base, __desc)   { .base = (__base), .desc = (__desc), }
 
#define DEV_PROTO_DESC(__type, __desc)   { .type = (__type), .desc = (__desc), }
 
enum  eth_hdr_fields {
  ETHHDR_INVALID,
  ETHHDR_DADDR,
  ETHHDR_SADDR,
  ETHHDR_TYPE
}
 
enum  vlan_hdr_fields {
  VLANHDR_INVALID,
  VLANHDR_VID,
  VLANHDR_CFI,
  VLANHDR_PCP,
  VLANHDR_TYPE
}
 
enum  arp_hdr_fields {
  ARPHDR_INVALID,
  ARPHDR_HRD,
  ARPHDR_PRO,
  ARPHDR_HLN,
  ARPHDR_PLN,
  ARPHDR_OP
}
 
enum  ip_hdr_fields {
  IPHDR_INVALID,
  IPHDR_VERSION,
  IPHDR_HDRLENGTH,
  IPHDR_TOS,
  IPHDR_LENGTH,
  IPHDR_ID,
  IPHDR_FRAG_OFF,
  IPHDR_TTL,
  IPHDR_PROTOCOL,
  IPHDR_CHECKSUM,
  IPHDR_SADDR,
  IPHDR_DADDR
}
 
enum  icmp_hdr_fields {
  ICMPHDR_INVALID,
  ICMPHDR_TYPE,
  ICMPHDR_CODE,
  ICMPHDR_CHECKSUM,
  ICMPHDR_ID,
  ICMPHDR_SEQ,
  ICMPHDR_GATEWAY,
  ICMPHDR_MTU
}
 
enum  icmp6_hdr_fields {
  ICMP6HDR_INVALID,
  ICMP6HDR_TYPE,
  ICMP6HDR_CODE,
  ICMP6HDR_CHECKSUM,
  ICMP6HDR_PPTR,
  ICMP6HDR_MTU,
  ICMP6HDR_ID,
  ICMP6HDR_SEQ,
  ICMP6HDR_MAXDELAY
}
 
enum  ip6_hdr_fields {
  IP6HDR_INVALID,
  IP6HDR_VERSION,
  IP6HDR_PRIORITY,
  IP6HDR_FLOWLABEL,
  IP6HDR_LENGTH,
  IP6HDR_NEXTHDR,
  IP6HDR_HOPLIMIT,
  IP6HDR_SADDR,
  IP6HDR_DADDR,
  IP6HDR_PROTOCOL
}
 
enum  ah_hdr_fields {
  AHHDR_INVALID,
  AHHDR_NEXTHDR,
  AHHDR_HDRLENGTH,
  AHHDR_RESERVED,
  AHHDR_SPI,
  AHHDR_SEQUENCE
}
 
enum  esp_hdr_fields {
  ESPHDR_INVALID,
  ESPHDR_SPI,
  ESPHDR_SEQUENCE
}
 
enum  comp_hdr_fields {
  COMPHDR_INVALID,
  COMPHDR_NEXTHDR,
  COMPHDR_FLAGS,
  COMPHDR_CPI
}
 
enum  udp_hdr_fields {
  UDPHDR_INVALID,
  UDPHDR_SPORT,
  UDPHDR_DPORT,
  UDPHDR_LENGTH,
  UDPHDR_CSUMCOV = UDPHDR_LENGTH,
  UDPHDR_CHECKSUM
}
 
enum  tcp_hdr_fields {
  TCPHDR_INVALID,
  TCPHDR_UNSPEC = TCPHDR_INVALID,
  TCPHDR_SPORT,
  TCPHDR_DPORT,
  TCPHDR_SEQ,
  TCPHDR_ACKSEQ,
  TCPHDR_DOFF,
  TCPHDR_RESERVED,
  TCPHDR_FLAGS,
  TCPHDR_WINDOW,
  TCPHDR_CHECKSUM,
  TCPHDR_URGPTR
}
 
enum  dccp_hdr_fields {
  DCCPHDR_INVALID,
  DCCPHDR_SPORT,
  DCCPHDR_DPORT,
  DCCPHDR_TYPE
}
 
enum  sctp_hdr_fields {
  SCTPHDR_INVALID,
  SCTPHDR_SPORT,
  SCTPHDR_DPORT,
  SCTPHDR_VTAG,
  SCTPHDR_CHECKSUM
}
 
const struct hook_proto_desc hook_proto_desc []
 
const struct proto_desc proto_icmp
 
const struct proto_desc proto_ah
 
const struct proto_desc proto_esp
 
const struct proto_desc proto_comp
 
const struct proto_desc proto_udp
 
const struct proto_desc proto_udplite
 
const struct proto_desc proto_tcp
 
const struct proto_desc proto_dccp
 
const struct proto_desc proto_sctp
 
const struct proto_desc proto_icmp6
 
const struct proto_desc proto_ip
 
const struct proto_desc proto_ip6
 
const struct proto_desc proto_inet
 
const struct proto_desc proto_inet_service
 
const struct proto_desc proto_arp
 
const struct proto_desc proto_vlan
 
const struct proto_desc proto_eth
 
const struct proto_desc proto_unknown
 
const struct proto_hdr_template proto_unknown_template
 
int proto_dev_type (const struct proto_desc *desc, uint16_t *res)
 proto_dev_type - return arphrd type linking a device and a protocol together More...
 
const struct proto_descproto_dev_desc (uint16_t type)
 proto_dev_desc - return protocol description for an arphrd type More...
 
void proto_ctx_init (struct proto_ctx *ctx, unsigned int family)
 proto_ctx_init - initialize protocol context for a given hook family More...
 
void proto_ctx_update (struct proto_ctx *ctx, enum proto_bases base, const struct location *loc, const struct proto_desc *desc)
 proto_ctx_update: update protocol context for given protocol base More...
 
const struct proto_descproto_find_upper (const struct proto_desc *base, unsigned int num)
 proto_find_upper - find higher layer protocol description by protocol value linking it to the lower layer protocol More...
 
int proto_find_num (const struct proto_desc *base, const struct proto_desc *desc)
 proto_find_num - return protocol number linking two protocols together More...
 

Macro Definition Documentation

#define DEV_PROTO_DESC (   __type,
  __desc 
)    { .type = (__type), .desc = (__desc), }
#define HOOK_PROTO_DESC (   __base,
  __desc 
)    { .base = (__base), .desc = (__desc), }
#define PROTO_BASE_MAX   (__PROTO_BASE_MAX - 1)
#define PROTO_HDR_TEMPLATE (   __token,
  __dtype,
  __byteorder,
  __offset,
  __len 
)
Value:
{ \
.token = (__token), \
.dtype = (__dtype), \
.byteorder = (__byteorder), \
.offset = (__offset), \
.len = (__len), \
}
#define PROTO_HDRS_MAX   20
#define PROTO_LINK (   __num,
  __desc 
)    { .num = (__num), .desc = (__desc), }
#define PROTO_META_TEMPLATE (   __token,
  __dtype,
  __key,
  __len 
)
Value:
{ \
.token = (__token), \
.dtype = (__dtype), \
.meta_key = (__key), \
.len = (__len), \
}
int len
Definition: utils.c:56
#define PROTO_UPPER_MAX   16

Enumeration Type Documentation

Enumerator
AHHDR_INVALID 
AHHDR_NEXTHDR 
AHHDR_HDRLENGTH 
AHHDR_RESERVED 
AHHDR_SPI 
AHHDR_SEQUENCE 
Enumerator
ARPHDR_INVALID 
ARPHDR_HRD 
ARPHDR_PRO 
ARPHDR_HLN 
ARPHDR_PLN 
ARPHDR_OP 
Enumerator
COMPHDR_INVALID 
COMPHDR_NEXTHDR 
COMPHDR_FLAGS 
COMPHDR_CPI 
Enumerator
DCCPHDR_INVALID 
DCCPHDR_SPORT 
DCCPHDR_DPORT 
DCCPHDR_TYPE 
Enumerator
ESPHDR_INVALID 
ESPHDR_SPI 
ESPHDR_SEQUENCE 
Enumerator
ETHHDR_INVALID 
ETHHDR_DADDR 
ETHHDR_SADDR 
ETHHDR_TYPE 
Enumerator
ICMP6HDR_INVALID 
ICMP6HDR_TYPE 
ICMP6HDR_CODE 
ICMP6HDR_CHECKSUM 
ICMP6HDR_PPTR 
ICMP6HDR_MTU 
ICMP6HDR_ID 
ICMP6HDR_SEQ 
ICMP6HDR_MAXDELAY 
Enumerator
ICMPHDR_INVALID 
ICMPHDR_TYPE 
ICMPHDR_CODE 
ICMPHDR_CHECKSUM 
ICMPHDR_ID 
ICMPHDR_SEQ 
ICMPHDR_GATEWAY 
ICMPHDR_MTU 
Enumerator
IP6HDR_INVALID 
IP6HDR_VERSION 
IP6HDR_PRIORITY 
IP6HDR_FLOWLABEL 
IP6HDR_LENGTH 
IP6HDR_NEXTHDR 
IP6HDR_HOPLIMIT 
IP6HDR_SADDR 
IP6HDR_DADDR 
IP6HDR_PROTOCOL 
Enumerator
IPHDR_INVALID 
IPHDR_VERSION 
IPHDR_HDRLENGTH 
IPHDR_TOS 
IPHDR_LENGTH 
IPHDR_ID 
IPHDR_FRAG_OFF 
IPHDR_TTL 
IPHDR_PROTOCOL 
IPHDR_CHECKSUM 
IPHDR_SADDR 
IPHDR_DADDR 

enum proto_bases - protocol bases

: uninitialised, does not happen : link layer header : network layer header : transport layer header

Enumerator
PROTO_BASE_INVALID 
PROTO_BASE_LL_HDR 
PROTO_BASE_NETWORK_HDR 
PROTO_BASE_TRANSPORT_HDR 
__PROTO_BASE_MAX 
Enumerator
SCTPHDR_INVALID 
SCTPHDR_SPORT 
SCTPHDR_DPORT 
SCTPHDR_VTAG 
SCTPHDR_CHECKSUM 
Enumerator
TCPHDR_INVALID 
TCPHDR_UNSPEC 
TCPHDR_SPORT 
TCPHDR_DPORT 
TCPHDR_SEQ 
TCPHDR_ACKSEQ 
TCPHDR_DOFF 
TCPHDR_RESERVED 
TCPHDR_FLAGS 
TCPHDR_WINDOW 
TCPHDR_CHECKSUM 
TCPHDR_URGPTR 
Enumerator
UDPHDR_INVALID 
UDPHDR_SPORT 
UDPHDR_DPORT 
UDPHDR_LENGTH 
UDPHDR_CSUMCOV 
UDPHDR_CHECKSUM 
Enumerator
VLANHDR_INVALID 
VLANHDR_VID 
VLANHDR_CFI 
VLANHDR_PCP 
VLANHDR_TYPE 

Function Documentation

void proto_ctx_init ( struct proto_ctx ctx,
unsigned int  family 
)

proto_ctx_init - initialize protocol context for a given hook family

: protocol context : hook family

References hook_proto_desc::base, hook_proto_desc::desc, proto_ctx::desc, proto_ctx::family, and proto_ctx::protocol.

void proto_ctx_update ( struct proto_ctx ctx,
enum proto_bases  base,
const struct location loc,
const struct proto_desc desc 
)

proto_ctx_update: update protocol context for given protocol base

: protocol context : protocol base : location of the relational expression definiting the context : protocol description for the given layer

References hook_proto_desc::base, hook_proto_desc::desc, proto_ctx::desc, proto_ctx::location, and proto_ctx::protocol.

const struct proto_desc* proto_dev_desc ( uint16_t  type)

proto_dev_desc - return protocol description for an arphrd type

: the arphrd type

References array_size, dev_proto_desc::desc, and NULL.

int proto_dev_type ( const struct proto_desc desc,
uint16_t *  res 
)

proto_dev_type - return arphrd type linking a device and a protocol together

: the protocol description : pointer to result

References array_size, and dev_proto_desc::type.

Referenced by payload_gen_dependency().

Here is the caller graph for this function:

int proto_find_num ( const struct proto_desc base,
const struct proto_desc desc 
)

proto_find_num - return protocol number linking two protocols together

: lower layer protocol description : upper layer protocol description

References array_size, proto_desc::desc, proto_desc::num, and proto_desc::protocols.

Referenced by payload_gen_dependency().

Here is the caller graph for this function:

const struct proto_desc* proto_find_upper ( const struct proto_desc base,
unsigned int  num 
)

proto_find_upper - find higher layer protocol description by protocol value linking it to the lower layer protocol

: lower layer protocol description : protocol value

References array_size, proto_desc::desc, NULL, proto_desc::num, and proto_desc::protocols.

Variable Documentation

const struct proto_desc proto_ah
const struct proto_desc proto_arp
const char* proto_base_names[]

Referenced by payload_gen_dependency().

const char* proto_base_tokens[]
const struct proto_desc proto_comp
const struct proto_desc proto_dccp
const struct proto_desc proto_esp
const struct proto_desc proto_eth

Referenced by payload_gen_dependency().

const struct proto_desc proto_icmp
const struct proto_desc proto_icmp6
const struct proto_desc proto_inet

Referenced by payload_gen_dependency().

const struct proto_desc proto_inet_service

Referenced by payload_gen_dependency().

const struct proto_desc proto_ip

Referenced by ct_expr_update_type().

const struct proto_desc proto_ip6

Referenced by ct_expr_update_type().

const struct proto_desc proto_sctp
const struct proto_desc proto_tcp
const struct proto_desc proto_udp
const struct proto_desc proto_udplite
const struct proto_desc proto_unknown

Referenced by payload_expr_alloc().

const struct proto_hdr_template proto_unknown_template

Referenced by payload_expr_alloc().

const struct proto_desc proto_vlan