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_ESEC   0x85
 
#define IPV4_OPT_CIPSO   0x86
 
#define IPV4_OPT_SID   0x88
 
#define IPV4_OPT_SSRR   0x89
 
#define IPV4_OPT_RTRALT   0x94
 
#define IPV4_OPT_SID_LEN   4
 
#define IPV4_OPT_RTRALT_LEN   4
 
#define IPV4_OPT_SEC_MIN   3
 
#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)   ((uint8_t)(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)
 
#define IPV4_OPT_FLAG_EOL   BIT_U16(1)
 
#define IPV4_OPT_FLAG_NOP   BIT_U16(2)
 
#define IPV4_OPT_FLAG_RR   BIT_U16(3)
 
#define IPV4_OPT_FLAG_TS   BIT_U16(4)
 
#define IPV4_OPT_FLAG_QS   BIT_U16(5)
 
#define IPV4_OPT_FLAG_LSRR   BIT_U16(6)
 
#define IPV4_OPT_FLAG_SSRR   BIT_U16(7)
 
#define IPV4_OPT_FLAG_SID   BIT_U16(8)
 
#define IPV4_OPT_FLAG_SEC   BIT_U16(9)
 
#define IPV4_OPT_FLAG_CIPSO   BIT_U16(10)
 
#define IPV4_OPT_FLAG_RTRALT   BIT_U16(11)
 
#define IPV4_OPT_FLAG_ESEC   BIT_U16(12)
 

Typedefs

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

Functions

void DecodeIPV4RegisterTests (void)
 

Detailed Description

Macro Definition Documentation

◆ _IPV4_GET_IPOFFSET

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

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

◆ CLEAR_IPV4_PACKET

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

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

◆ IPV4_GET_DF

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

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

◆ IPV4_GET_HLEN

#define IPV4_GET_HLEN (   p)    ((uint8_t)(IPV4_GET_RAW_HLEN((p)->ip4h) << 2))

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

◆ IPV4_GET_IPID

#define IPV4_GET_IPID (   p)    (SCNtohs(IPV4_GET_RAW_IPID((p)->ip4h)))

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

◆ IPV4_GET_IPLEN

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

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

◆ IPV4_GET_IPOFFSET

#define IPV4_GET_IPOFFSET (   p)    (_IPV4_GET_IPOFFSET(p) & 0x1fff)

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

◆ IPV4_GET_IPPROTO

#define IPV4_GET_IPPROTO (   p)    IPV4_GET_RAW_IPPROTO((p)->ip4h)

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

◆ IPV4_GET_IPTOS

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

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

◆ IPV4_GET_IPTTL

#define IPV4_GET_IPTTL (   p)    IPV4_GET_RAW_IPTTL(p->ip4h)

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

◆ IPV4_GET_MF

#define IPV4_GET_MF (   p)    (uint8_t)((_IPV4_GET_IPOFFSET((p)) & 0x2000) >> 13)

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

◆ IPV4_GET_RAW_HLEN

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

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

◆ IPV4_GET_RAW_IPDST

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

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

◆ IPV4_GET_RAW_IPDST_U32

#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 110 of file decode-ipv4.h.

◆ IPV4_GET_RAW_IPID

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

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

◆ IPV4_GET_RAW_IPLEN

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

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

◆ IPV4_GET_RAW_IPOFFSET

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

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

◆ IPV4_GET_RAW_IPPROTO

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

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

◆ IPV4_GET_RAW_IPSRC

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

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

◆ IPV4_GET_RAW_IPSRC_U32

#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 108 of file decode-ipv4.h.

◆ IPV4_GET_RAW_IPTOS

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

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

◆ IPV4_GET_RAW_IPTTL

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

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

◆ IPV4_GET_RAW_VER

#define IPV4_GET_RAW_VER (   ip4h)    (((ip4h)->ip_verhl & 0xf0) >> 4)

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

◆ IPV4_GET_RF

#define IPV4_GET_RF (   p)    (uint8_t)((_IPV4_GET_IPOFFSET((p)) & 0x8000) >> 15)

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

◆ IPV4_GET_VER

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

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

◆ IPV4_HEADER_LEN

#define IPV4_HEADER_LEN   20

Header length

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

◆ IPV4_MAXPACKET_LEN

#define IPV4_MAXPACKET_LEN   65535

Maximum packet size

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

◆ IPV4_OPT_CIPSO

#define IPV4_OPT_CIPSO   0x86

Option: Commercial IP Security

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

◆ IPV4_OPT_CIPSO_MIN

#define IPV4_OPT_CIPSO_MIN   10

CIPSO Option Min Length

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

◆ IPV4_OPT_EOL

#define IPV4_OPT_EOL   0x00

IP Option Types Option: End of List

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

◆ IPV4_OPT_ESEC

#define IPV4_OPT_ESEC   0x85

Option: Extended Security

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

◆ IPV4_OPT_FLAG_CIPSO

#define IPV4_OPT_FLAG_CIPSO   BIT_U16(10)

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

◆ IPV4_OPT_FLAG_EOL

#define IPV4_OPT_FLAG_EOL   BIT_U16(1)

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

◆ IPV4_OPT_FLAG_ESEC

#define IPV4_OPT_FLAG_ESEC   BIT_U16(12)

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

◆ IPV4_OPT_FLAG_LSRR

#define IPV4_OPT_FLAG_LSRR   BIT_U16(6)

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

◆ IPV4_OPT_FLAG_NOP

#define IPV4_OPT_FLAG_NOP   BIT_U16(2)

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

◆ IPV4_OPT_FLAG_QS

#define IPV4_OPT_FLAG_QS   BIT_U16(5)

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

◆ IPV4_OPT_FLAG_RR

#define IPV4_OPT_FLAG_RR   BIT_U16(3)

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

◆ IPV4_OPT_FLAG_RTRALT

#define IPV4_OPT_FLAG_RTRALT   BIT_U16(11)

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

◆ IPV4_OPT_FLAG_SEC

#define IPV4_OPT_FLAG_SEC   BIT_U16(9)

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

◆ IPV4_OPT_FLAG_SID

#define IPV4_OPT_FLAG_SID   BIT_U16(8)

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

◆ IPV4_OPT_FLAG_SSRR

#define IPV4_OPT_FLAG_SSRR   BIT_U16(7)

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

◆ IPV4_OPT_FLAG_TS

#define IPV4_OPT_FLAG_TS   BIT_U16(4)

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

◆ IPV4_OPT_LSRR

#define IPV4_OPT_LSRR   0x83

Option: Loose Source Route

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

◆ IPV4_OPT_NOP

#define IPV4_OPT_NOP   0x01

Option: No op

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

◆ IPV4_OPT_QS

#define IPV4_OPT_QS   0x19

Option: Quick Start

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

◆ IPV4_OPT_QS_MIN

#define IPV4_OPT_QS_MIN   8

QS Option Min Length

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

◆ IPV4_OPT_ROUTE_MIN

#define IPV4_OPT_ROUTE_MIN   3

RR, SRR, LTRR Option Min Length

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

◆ IPV4_OPT_RR

#define IPV4_OPT_RR   0x07

Option: Record Route

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

◆ IPV4_OPT_RTRALT

#define IPV4_OPT_RTRALT   0x94

Option: Router Alert

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

◆ IPV4_OPT_RTRALT_LEN

#define IPV4_OPT_RTRALT_LEN   4

RTRALT Option Fixed Length

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

◆ IPV4_OPT_SEC

#define IPV4_OPT_SEC   0x82

Option: Security

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

◆ IPV4_OPT_SEC_MIN

#define IPV4_OPT_SEC_MIN   3

IP Option Lengths (variable) SEC, ESEC Option Min Length

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

◆ IPV4_OPT_SID

#define IPV4_OPT_SID   0x88

Option: Stream Identifier

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

◆ IPV4_OPT_SID_LEN

#define IPV4_OPT_SID_LEN   4

IP Option Lengths (fixed) SID Option Fixed Length

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

◆ IPV4_OPT_SSRR

#define IPV4_OPT_SSRR   0x89

Option: Strict Source Route

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

◆ IPV4_OPT_TS

#define IPV4_OPT_TS   0x44

Option: Timestamp

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

◆ IPV4_OPT_TS_MIN

#define IPV4_OPT_TS_MIN   5

TS Option Min Length

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

◆ IPV4_OPTMAX

#define IPV4_OPTMAX   40

Max options length

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

◆ IPV4_OPTS

#define IPV4_OPTS   ip4vars.ip_opts

IP Option fields

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

◆ IPV4_OPTS_CNT

#define IPV4_OPTS_CNT   ip4vars.ip_opt_cnt

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

◆ IPV4_SET_RAW_HLEN

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

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

◆ IPV4_SET_RAW_IPLEN

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

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

◆ IPV4_SET_RAW_IPPROTO

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

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

◆ IPV4_SET_RAW_IPTOS

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

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

◆ IPV4_SET_RAW_VER

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

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

◆ s_ip_addrs

#define s_ip_addrs   ip4_hdrun1.ip_addrs

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

◆ s_ip_dst

#define s_ip_dst   ip4_hdrun1.ip4_un1.ip_dst

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

◆ s_ip_src

#define s_ip_src   ip4_hdrun1.ip4_un1.ip_src

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

Typedef Documentation

◆ IPV4Hdr

typedef struct IPV4Hdr_ IPV4Hdr

◆ IPV4Opt

typedef struct IPV4Opt_ IPV4Opt

◆ IPV4Vars

typedef struct IPV4Vars_ IPV4Vars

Function Documentation

◆ DecodeIPV4RegisterTests()

void DecodeIPV4RegisterTests ( void  )

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

References UtRegisterTest().

Here is the call graph for this function: