suricata
decode-ipv4.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  IPV4Opt_
 
struct  IPV4Hdr_
 
struct  IPV4Vars_
 

Macros

#define IPV4_HEADER_LEN   20
 
#define IPV4_OPTMAX   40
 
#define IPV4_MAXPACKET_LEN   65535
 
#define IPV4_OPT_EOL   0x00
 
#define IPV4_OPT_NOP   0x01
 
#define IPV4_OPT_RR   0x07
 
#define IPV4_OPT_QS   0x19
 
#define IPV4_OPT_TS   0x44
 
#define IPV4_OPT_SEC   0x82
 
#define IPV4_OPT_LSRR   0x83
 
#define IPV4_OPT_CIPSO   0x86
 
#define IPV4_OPT_SID   0x88
 
#define IPV4_OPT_SSRR   0x89
 
#define IPV4_OPT_RTRALT   0x94
 
#define IPV4_OPT_SEC_LEN   11
 
#define IPV4_OPT_SID_LEN   4
 
#define IPV4_OPT_RTRALT_LEN   4
 
#define IPV4_OPT_ROUTE_MIN   3
 
#define IPV4_OPT_QS_MIN   8
 
#define IPV4_OPT_TS_MIN   5
 
#define IPV4_OPT_CIPSO_MIN   10
 
#define IPV4_OPTS   ip4vars.ip_opts
 
#define IPV4_OPTS_CNT   ip4vars.ip_opt_cnt
 
#define s_ip_src   ip4_hdrun1.ip4_un1.ip_src
 
#define s_ip_dst   ip4_hdrun1.ip4_un1.ip_dst
 
#define s_ip_addrs   ip4_hdrun1.ip_addrs
 
#define IPV4_GET_RAW_VER(ip4h)   (((ip4h)->ip_verhl & 0xf0) >> 4)
 
#define IPV4_GET_RAW_HLEN(ip4h)   ((ip4h)->ip_verhl & 0x0f)
 
#define IPV4_GET_RAW_IPTOS(ip4h)   ((ip4h)->ip_tos)
 
#define IPV4_GET_RAW_IPLEN(ip4h)   ((ip4h)->ip_len)
 
#define IPV4_GET_RAW_IPID(ip4h)   ((ip4h)->ip_id)
 
#define IPV4_GET_RAW_IPOFFSET(ip4h)   ((ip4h)->ip_off)
 
#define IPV4_GET_RAW_IPTTL(ip4h)   ((ip4h)->ip_ttl)
 
#define IPV4_GET_RAW_IPPROTO(ip4h)   ((ip4h)->ip_proto)
 
#define IPV4_GET_RAW_IPSRC(ip4h)   ((ip4h)->s_ip_src)
 
#define IPV4_GET_RAW_IPDST(ip4h)   ((ip4h)->s_ip_dst)
 
#define IPV4_GET_RAW_IPSRC_U32(ip4h)   (uint32_t)((ip4h)->s_ip_src.s_addr)
 
#define IPV4_GET_RAW_IPDST_U32(ip4h)   (uint32_t)((ip4h)->s_ip_dst.s_addr)
 
#define IPV4_SET_RAW_VER(ip4h, value)   ((ip4h)->ip_verhl = (((ip4h)->ip_verhl & 0x0f) | (value << 4)))
 
#define IPV4_SET_RAW_HLEN(ip4h, value)   ((ip4h)->ip_verhl = (((ip4h)->ip_verhl & 0xf0) | (value & 0x0f)))
 
#define IPV4_SET_RAW_IPTOS(ip4h, value)   ((ip4h)->ip_tos = value)
 
#define IPV4_SET_RAW_IPLEN(ip4h, value)   ((ip4h)->ip_len = value)
 
#define IPV4_SET_RAW_IPPROTO(ip4h, value)   ((ip4h)->ip_proto = value)
 
#define IPV4_GET_VER(p)   IPV4_GET_RAW_VER((p)->ip4h)
 
#define IPV4_GET_HLEN(p)   (IPV4_GET_RAW_HLEN((p)->ip4h) << 2)
 
#define IPV4_GET_IPTOS(p)   IPV4_GET_RAW_IPTOS((p)->ip4h)
 
#define IPV4_GET_IPLEN(p)   (SCNtohs(IPV4_GET_RAW_IPLEN((p)->ip4h)))
 
#define IPV4_GET_IPID(p)   (SCNtohs(IPV4_GET_RAW_IPID((p)->ip4h)))
 
#define _IPV4_GET_IPOFFSET(p)   (SCNtohs(IPV4_GET_RAW_IPOFFSET((p)->ip4h)))
 
#define IPV4_GET_IPOFFSET(p)   (_IPV4_GET_IPOFFSET(p) & 0x1fff)
 
#define IPV4_GET_RF(p)   (uint8_t)((_IPV4_GET_IPOFFSET((p)) & 0x8000) >> 15)
 
#define IPV4_GET_DF(p)   (uint8_t)((_IPV4_GET_IPOFFSET((p)) & 0x4000) >> 14)
 
#define IPV4_GET_MF(p)   (uint8_t)((_IPV4_GET_IPOFFSET((p)) & 0x2000) >> 13)
 
#define IPV4_GET_IPTTL(p)   IPV4_GET_RAW_IPTTL(p->ip4h)
 
#define IPV4_GET_IPPROTO(p)   IPV4_GET_RAW_IPPROTO((p)->ip4h)
 
#define CLEAR_IPV4_PACKET(p)
 

Typedefs

typedef struct IPV4Opt_ IPV4Opt
 
typedef struct IPV4Hdr_ IPV4Hdr
 
typedef struct IPV4Vars_ IPV4Vars
 

Enumerations

enum  IPV4OptionFlags {
  IPV4_OPT_FLAG_EOL = 0, IPV4_OPT_FLAG_NOP, IPV4_OPT_FLAG_RR, IPV4_OPT_FLAG_TS,
  IPV4_OPT_FLAG_QS, IPV4_OPT_FLAG_LSRR, IPV4_OPT_FLAG_SSRR, IPV4_OPT_FLAG_SID,
  IPV4_OPT_FLAG_SEC, IPV4_OPT_FLAG_CIPSO, IPV4_OPT_FLAG_RTRALT
}
 

Functions

void DecodeIPV4RegisterTests (void)
 

Detailed Description

Macro Definition Documentation

#define _IPV4_GET_IPOFFSET (   p)    (SCNtohs(IPV4_GET_RAW_IPOFFSET((p)->ip4h)))

Definition at line 132 of file decode-ipv4.h.

#define CLEAR_IPV4_PACKET (   p)
Value:
do { \
(p)->ip4h = NULL; \
(p)->level3_comp_csum = -1; \
memset(&p->ip4vars, 0x00, sizeof(p->ip4vars)); \
} while (0)

Definition at line 151 of file decode-ipv4.h.

#define IPV4_GET_DF (   p)    (uint8_t)((_IPV4_GET_IPOFFSET((p)) & 0x4000) >> 14)

Definition at line 141 of file decode-ipv4.h.

Referenced by DecodeIPV4(), and DetectFragBitsRegister().

#define IPV4_GET_HLEN (   p)    (IPV4_GET_RAW_HLEN((p)->ip4h) << 2)
#define IPV4_GET_IPID (   p)    (SCNtohs(IPV4_GET_RAW_IPID((p)->ip4h)))

Definition at line 129 of file decode-ipv4.h.

Referenced by DecodeIPV4(), DetectIdFree(), and DetectIdRegister().

#define IPV4_GET_IPLEN (   p)    (SCNtohs(IPV4_GET_RAW_IPLEN((p)->ip4h)))

Definition at line 127 of file decode-ipv4.h.

Referenced by DecodeIPV4(), and DefragRbFragCompare().

#define IPV4_GET_IPOFFSET (   p)    (_IPV4_GET_IPOFFSET(p) & 0x1fff)
#define IPV4_GET_IPPROTO (   p)    IPV4_GET_RAW_IPPROTO((p)->ip4h)

Definition at line 148 of file decode-ipv4.h.

Referenced by AFPSetBPFFilter(), DecodeIPV4(), and DefragTrackerFreeFrags().

#define IPV4_GET_IPTOS (   p)    IPV4_GET_RAW_IPTOS((p)->ip4h)

Definition at line 125 of file decode-ipv4.h.

Referenced by DetectTosRegister().

#define IPV4_GET_IPTTL (   p)    IPV4_GET_RAW_IPTTL(p->ip4h)
#define IPV4_GET_MF (   p)    (uint8_t)((_IPV4_GET_IPOFFSET((p)) & 0x2000) >> 13)

Definition at line 144 of file decode-ipv4.h.

Referenced by DecodeIPV4(), Defrag(), DefragRbFragCompare(), and DetectFragBitsRegister().

#define IPV4_GET_RAW_HLEN (   ip4h)    ((ip4h)->ip_verhl & 0x0f)

Definition at line 95 of file decode-ipv4.h.

Referenced by DetectCsumRegister(), and ReCalculateChecksum().

#define IPV4_GET_RAW_IPDST (   ip4h)    ((ip4h)->s_ip_dst)

Definition at line 103 of file decode-ipv4.h.

#define IPV4_GET_RAW_IPDST_U32 (   ip4h)    (uint32_t)((ip4h)->s_ip_dst.s_addr)

return the raw (directly from the header) dst ip as uint32_t

Definition at line 108 of file decode-ipv4.h.

Referenced by FlowKeyGetHash().

#define IPV4_GET_RAW_IPID (   ip4h)    ((ip4h)->ip_id)

Definition at line 98 of file decode-ipv4.h.

#define IPV4_GET_RAW_IPLEN (   ip4h)    ((ip4h)->ip_len)

Definition at line 97 of file decode-ipv4.h.

Referenced by DetectCsumRegister().

#define IPV4_GET_RAW_IPOFFSET (   ip4h)    ((ip4h)->ip_off)

Definition at line 99 of file decode-ipv4.h.

#define IPV4_GET_RAW_IPPROTO (   ip4h)    ((ip4h)->ip_proto)

Definition at line 101 of file decode-ipv4.h.

#define IPV4_GET_RAW_IPSRC (   ip4h)    ((ip4h)->s_ip_src)

Definition at line 102 of file decode-ipv4.h.

#define IPV4_GET_RAW_IPSRC_U32 (   ip4h)    (uint32_t)((ip4h)->s_ip_src.s_addr)

return the raw (directly from the header) src ip as uint32_t

Definition at line 106 of file decode-ipv4.h.

Referenced by FlowKeyGetHash().

#define IPV4_GET_RAW_IPTOS (   ip4h)    ((ip4h)->ip_tos)

Definition at line 96 of file decode-ipv4.h.

#define IPV4_GET_RAW_IPTTL (   ip4h)    ((ip4h)->ip_ttl)

Definition at line 100 of file decode-ipv4.h.

#define IPV4_GET_RAW_VER (   ip4h)    (((ip4h)->ip_verhl & 0xf0) >> 4)
#define IPV4_GET_RF (   p)    (uint8_t)((_IPV4_GET_IPOFFSET((p)) & 0x8000) >> 15)

Definition at line 138 of file decode-ipv4.h.

Referenced by DecodeIPV4(), and DetectFragBitsRegister().

#define IPV4_GET_VER (   p)    IPV4_GET_RAW_VER((p)->ip4h)

Definition at line 121 of file decode-ipv4.h.

#define IPV4_HEADER_LEN   20

Header length

Definition at line 28 of file decode-ipv4.h.

Referenced by DecodePPP(), DecodePPPOESession(), DecodeRaw(), and DefragRbFragCompare().

#define IPV4_MAXPACKET_LEN   65535

Maximum packet size

Definition at line 30 of file decode-ipv4.h.

Referenced by DefragRbFragCompare(), and Unified2AlertThreadInit().

#define IPV4_OPT_CIPSO   0x86

Option: Commercial IP Security

Definition at line 40 of file decode-ipv4.h.

Referenced by DecodeIPV4().

#define IPV4_OPT_CIPSO_MIN   10

CIPSO Option Min Length

Definition at line 54 of file decode-ipv4.h.

#define IPV4_OPT_EOL   0x00

IP Option Types Option: End of List

Definition at line 33 of file decode-ipv4.h.

Referenced by DecodeIPV4().

#define IPV4_OPT_LSRR   0x83

Option: Loose Source Route

Definition at line 39 of file decode-ipv4.h.

Referenced by DecodeIPV4().

#define IPV4_OPT_NOP   0x01

Option: No op

Definition at line 34 of file decode-ipv4.h.

Referenced by DecodeIPV4().

#define IPV4_OPT_QS   0x19

Option: Quick Start

Definition at line 36 of file decode-ipv4.h.

Referenced by DecodeIPV4().

#define IPV4_OPT_QS_MIN   8

QS Option Min Length

Definition at line 52 of file decode-ipv4.h.

#define IPV4_OPT_ROUTE_MIN   3

IP Option Lengths (variable) RR, SRR, LTRR Option Min Length

Definition at line 51 of file decode-ipv4.h.

#define IPV4_OPT_RR   0x07

Option: Record Route

Definition at line 35 of file decode-ipv4.h.

Referenced by DecodeIPV4().

#define IPV4_OPT_RTRALT   0x94

Option: Router Alert

Definition at line 43 of file decode-ipv4.h.

Referenced by DecodeIPV4().

#define IPV4_OPT_RTRALT_LEN   4

RTRALT Option Fixed Length

Definition at line 48 of file decode-ipv4.h.

#define IPV4_OPT_SEC   0x82

Option: Security

Definition at line 38 of file decode-ipv4.h.

Referenced by DecodeIPV4().

#define IPV4_OPT_SEC_LEN   11

IP Option Lengths (fixed) SEC Option Fixed Length

Definition at line 46 of file decode-ipv4.h.

#define IPV4_OPT_SID   0x88

Option: Stream Identifier

Definition at line 41 of file decode-ipv4.h.

Referenced by DecodeIPV4().

#define IPV4_OPT_SID_LEN   4

SID Option Fixed Length

Definition at line 47 of file decode-ipv4.h.

#define IPV4_OPT_SSRR   0x89

Option: Strict Source Route

Definition at line 42 of file decode-ipv4.h.

Referenced by DecodeIPV4().

#define IPV4_OPT_TS   0x44

Option: Timestamp

Definition at line 37 of file decode-ipv4.h.

Referenced by DecodeIPV4().

#define IPV4_OPT_TS_MIN   5

TS Option Min Length

Definition at line 53 of file decode-ipv4.h.

#define IPV4_OPTMAX   40

Max options length

Definition at line 29 of file decode-ipv4.h.

#define IPV4_OPTS   ip4vars.ip_opts

IP Option fields

Definition at line 57 of file decode-ipv4.h.

#define IPV4_OPTS_CNT   ip4vars.ip_opt_cnt

Definition at line 58 of file decode-ipv4.h.

#define IPV4_SET_RAW_HLEN (   ip4h,
  value 
)    ((ip4h)->ip_verhl = (((ip4h)->ip_verhl & 0xf0) | (value & 0x0f)))

Definition at line 112 of file decode-ipv4.h.

#define IPV4_SET_RAW_IPLEN (   ip4h,
  value 
)    ((ip4h)->ip_len = value)

Definition at line 114 of file decode-ipv4.h.

#define IPV4_SET_RAW_IPPROTO (   ip4h,
  value 
)    ((ip4h)->ip_proto = value)

Definition at line 115 of file decode-ipv4.h.

#define IPV4_SET_RAW_IPTOS (   ip4h,
  value 
)    ((ip4h)->ip_tos = value)

Definition at line 113 of file decode-ipv4.h.

Referenced by DetectTosRegister().

#define IPV4_SET_RAW_VER (   ip4h,
  value 
)    ((ip4h)->ip_verhl = (((ip4h)->ip_verhl & 0x0f) | (value << 4)))

Definition at line 111 of file decode-ipv4.h.

#define s_ip_addrs   ip4_hdrun1.ip_addrs

Definition at line 92 of file decode-ipv4.h.

#define s_ip_dst   ip4_hdrun1.ip4_un1.ip_dst

Definition at line 91 of file decode-ipv4.h.

#define s_ip_src   ip4_hdrun1.ip4_un1.ip_src

Definition at line 90 of file decode-ipv4.h.

Typedef Documentation

typedef struct IPV4Hdr_ IPV4Hdr
typedef struct IPV4Opt_ IPV4Opt
typedef struct IPV4Vars_ IPV4Vars

Enumeration Type Documentation

Enumerator
IPV4_OPT_FLAG_EOL 
IPV4_OPT_FLAG_NOP 
IPV4_OPT_FLAG_RR 
IPV4_OPT_FLAG_TS 
IPV4_OPT_FLAG_QS 
IPV4_OPT_FLAG_LSRR 
IPV4_OPT_FLAG_SSRR 
IPV4_OPT_FLAG_SID 
IPV4_OPT_FLAG_SEC 
IPV4_OPT_FLAG_CIPSO 
IPV4_OPT_FLAG_RTRALT 

Definition at line 157 of file decode-ipv4.h.

Function Documentation

void DecodeIPV4RegisterTests ( void  )

Definition at line 1666 of file decode-ipv4.c.

References UtRegisterTest().

Here is the call graph for this function: