netfilter
firewalling, NAT, and packet mangling for linux
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
exthdr.c File Reference
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <netinet/in.h>
#include <netinet/ip6.h>
#include <utils.h>
#include <headers.h>
#include <expression.h>
Include dependency graph for exthdr.c:

Macros

#define HDR_TEMPLATE(__name, __dtype, __type, __member)
 
#define HBH_FIELD(__name, __member, __dtype)   HDR_TEMPLATE(__name, __dtype, struct ip6_hbh, __member)
 
#define RT0_FIELD(__name, __member, __dtype)   HDR_TEMPLATE(__name, __dtype, struct ip6_rthdr0, __member)
 
#define RT_FIELD(__name, __member, __dtype)   HDR_TEMPLATE(__name, __dtype, struct ip6_rthdr, __member)
 
#define FRAG_FIELD(__name, __member, __dtype)   HDR_TEMPLATE(__name, __dtype, struct ip6_frag, __member)
 
#define DST_FIELD(__name, __member, __dtype)   HDR_TEMPLATE(__name, __dtype, struct ip6_dest, __member)
 
#define MH_FIELD(__name, __member, __dtype)   HDR_TEMPLATE(__name, __dtype, struct ip6_mh, __member)
 

Functions

struct exprexthdr_expr_alloc (const struct location *loc, const struct exthdr_desc *desc, uint8_t type)
 
void exthdr_init_raw (struct expr *expr, uint8_t type, unsigned int offset, unsigned int len)
 

Variables

const struct exthdr_desc exthdr_hbh
 
const struct exthdr_desc exthdr_rt2
 
const struct exthdr_desc exthdr_rt0
 
const struct exthdr_desc exthdr_rt
 
const struct exthdr_desc exthdr_frag
 
const struct exthdr_desc exthdr_dst
 
const struct exthdr_desc exthdr_mh
 

Macro Definition Documentation

#define DST_FIELD (   __name,
  __member,
  __dtype 
)    HDR_TEMPLATE(__name, __dtype, struct ip6_dest, __member)
#define FRAG_FIELD (   __name,
  __member,
  __dtype 
)    HDR_TEMPLATE(__name, __dtype, struct ip6_frag, __member)
#define HBH_FIELD (   __name,
  __member,
  __dtype 
)    HDR_TEMPLATE(__name, __dtype, struct ip6_hbh, __member)
#define HDR_TEMPLATE (   __name,
  __dtype,
  __type,
  __member 
)
Value:
PROTO_HDR_TEMPLATE(__name, __dtype, \
offsetof(__type, __member) * 8, \
field_sizeof(__type, __member) * 8)
#define PROTO_HDR_TEMPLATE(__token, __dtype,__byteorder, __offset, __len)
Definition: proto.h:46
#define field_sizeof(t, f)
Return a pointer to a constant variable of a size smaller than the variable.
Definition: utils.h:69
#define offsetof(TYPE, MEMBER)
Definition: linux_list.h:7
Definition: datatype.h:98
#define MH_FIELD (   __name,
  __member,
  __dtype 
)    HDR_TEMPLATE(__name, __dtype, struct ip6_mh, __member)
#define RT0_FIELD (   __name,
  __member,
  __dtype 
)    HDR_TEMPLATE(__name, __dtype, struct ip6_rthdr0, __member)
#define RT_FIELD (   __name,
  __member,
  __dtype 
)    HDR_TEMPLATE(__name, __dtype, struct ip6_rthdr, __member)

Function Documentation

struct expr* exthdr_expr_alloc ( const struct location loc,
const struct exthdr_desc desc,
uint8_t  type 
)

Variable Documentation

const struct exthdr_desc exthdr_dst
Initial value:
= {
.name = "dst",
.type = IPPROTO_DSTOPTS,
.templates = {
[DSTHDR_NEXTHDR] = DST_FIELD("nexthdr", ip6d_nxt, &inet_protocol_type),
[DSTHDR_HDRLENGTH] = DST_FIELD("hdrlength", ip6d_len, &integer_type),
},
}
const struct datatype integer_type
Definition: datatype.c:294
Definition: exthdr.h:66
const struct datatype inet_protocol_type
Definition: datatype.c:536
#define DST_FIELD(__name, __member, __dtype)
Definition: exthdr.c:199
Definition: exthdr.h:65
const struct exthdr_desc exthdr_frag
Initial value:
= {
.name = "frag",
.type = IPPROTO_FRAGMENT,
.templates = {
[FRAGHDR_NEXTHDR] = FRAG_FIELD("nexthdr", ip6f_nxt, &inet_protocol_type),
[FRAGHDR_RESERVED] = FRAG_FIELD("reserved", ip6f_reserved, &integer_type),
16, 13),
29, 2),
31, 1),
[FRAGHDR_ID] = FRAG_FIELD("id", ip6f_ident, &integer_type),
},
}
const struct datatype integer_type
Definition: datatype.c:294
Definition: exthdr.h:56
Definition: exthdr.h:58
Definition: exthdr.h:57
const struct datatype inet_protocol_type
Definition: datatype.c:536
#define PROTO_HDR_TEMPLATE(__token, __dtype,__byteorder, __offset, __len)
Definition: proto.h:46
#define FRAG_FIELD(__name, __member, __dtype)
Definition: exthdr.c:173
Definition: exthdr.h:55
Definition: exthdr.h:59
Definition: exthdr.h:60
Definition: datatype.h:98
const struct exthdr_desc exthdr_hbh
Initial value:
= {
.name = "hbh",
.type = IPPROTO_HOPOPTS,
.templates = {
[HBHHDR_NEXTHDR] = HBH_FIELD("nexthdr", ip6h_nxt, &inet_protocol_type),
[HBHHDR_HDRLENGTH] = HBH_FIELD("hdrlength", ip6h_len, &integer_type),
},
}
const struct datatype integer_type
Definition: datatype.c:294
const struct datatype inet_protocol_type
Definition: datatype.c:536
Definition: exthdr.h:30
#define HBH_FIELD(__name, __member, __dtype)
Definition: exthdr.c:113
Definition: exthdr.h:29
const struct exthdr_desc exthdr_mh
Initial value:
= {
.name = "mh",
.type = IPPROTO_MH,
.templates = {
[MHHDR_NEXTHDR] = MH_FIELD("nexthdr", ip6mh_proto, &inet_protocol_type),
[MHHDR_HDRLENGTH] = MH_FIELD("hdrlength", ip6mh_hdrlen, &integer_type),
[MHHDR_TYPE] = MH_FIELD("type", ip6mh_type, &mh_type_type),
[MHHDR_RESERVED] = MH_FIELD("reserved", ip6mh_reserved, &integer_type),
[MHHDR_CHECKSUM] = MH_FIELD("checksum", ip6mh_cksum, &integer_type),
},
}
const struct datatype integer_type
Definition: datatype.c:294
Definition: exthdr.h:73
Definition: exthdr.h:75
Definition: exthdr.h:74
Definition: exthdr.h:71
const struct datatype inet_protocol_type
Definition: datatype.c:536
#define MH_FIELD(__name, __member, __dtype)
Definition: exthdr.c:215
#define IPPROTO_MH
Definition: exthdr.c:31
Definition: exthdr.h:72
const struct exthdr_desc exthdr_rt
Initial value:
= {
.name = "rt",
.type = IPPROTO_ROUTING,
.templates = {
[RTHDR_NEXTHDR] = RT_FIELD("nexthdr", ip6r_nxt, &inet_protocol_type),
[RTHDR_HDRLENGTH] = RT_FIELD("hdrlength", ip6r_len, &integer_type),
[RTHDR_TYPE] = RT_FIELD("type", ip6r_type, &integer_type),
[RTHDR_SEG_LEFT] = RT_FIELD("seg-left", ip6r_segleft, &integer_type),
},
}
#define RT_FIELD(__name, __member, __dtype)
Definition: exthdr.c:148
const struct datatype integer_type
Definition: datatype.c:294
Definition: exthdr.h:38
Definition: exthdr.h:35
const struct datatype inet_protocol_type
Definition: datatype.c:536
Definition: exthdr.h:36
Definition: exthdr.h:37
const struct exthdr_desc exthdr_rt0
Initial value:
= {
.templates = {
[RT0HDR_RESERVED] = RT0_FIELD("reserved", ip6r0_reserved, &integer_type),
[RT0HDR_ADDR_1] = RT0_FIELD("addr[1]", ip6r0_addr[0], &ip6addr_type),
[RT0HDR_ADDR_1 + 1] = RT0_FIELD("addr[2]", ip6r0_addr[0], &ip6addr_type),
},
}
const struct datatype integer_type
Definition: datatype.c:294
const struct datatype ip6addr_type
Definition: datatype.c:481
#define RT0_FIELD(__name, __member, __dtype)
Definition: exthdr.c:136
Definition: exthdr.h:43
Definition: exthdr.h:44
const struct exthdr_desc exthdr_rt2
Initial value:
= {
.templates = {
[RT2HDR_ADDR] = {},
},
}
Definition: exthdr.h:49
Definition: exthdr.h:50