suricata
app-layer-dnp3.h File Reference
#include "rust.h"
#include "util-byte.h"
Include dependency graph for app-layer-dnp3.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  DNP3LinkHeader_
 DNP3 link header. More...
 
struct  DNP3ApplicationHeader_
 DNP3 application header. More...
 
struct  DNP3InternalInd_
 DNP3 internal indicators. More...
 
struct  DNP3Buffer_
 A struct used for buffering incoming data prior to reassembly. More...
 
struct  DNP3ObjHeader_
 DNP3 application object header. More...
 
struct  DNP3Point_
 DNP3 object point. More...
 
struct  DNP3Object_
 Struct to hold the list of decoded objects. More...
 
struct  DNP3Transaction_
 DNP3 transaction. More...
 
struct  DNP3State_
 Per flow DNP3 state. More...
 

Macros

#define DNP3_APP_FC_CONFIRM   0x00
 
#define DNP3_APP_FC_READ   0x01
 
#define DNP3_APP_FC_WRITE   0x02
 
#define DNP3_APP_FC_SELECT   0x03
 
#define DNP3_APP_FC_OPERATE   0x04
 
#define DNP3_APP_FC_DIR_OPERATE   0x05
 
#define DNP3_APP_FC_DIR_OPERATE_NR   0x06
 
#define DNP3_APP_FC_FREEZE   0x07
 
#define DNP3_APP_FC_FREEZE_NR   0x08
 
#define DNP3_APP_FC_FREEZE_CLEAR   0x09
 
#define DNP3_APP_FC_FREEZE_CLEAR_NR   0x0a
 
#define DNP3_APP_FC_FREEZE_AT_TIME   0x0b
 
#define DNP3_APP_FC_FREEZE_AT_TIME_NR   0x0c
 
#define DNP3_APP_FC_COLD_RESTART   0x0d
 
#define DNP3_APP_FC_WARM_RESTART   0x0e
 
#define DNP3_APP_FC_INITIALIZE_DATA   0x0f
 
#define DNP3_APP_FC_INITIALIZE_APPLICATION   0x10
 
#define DNP3_APP_FC_START_APPLICATION   0x11
 
#define DNP3_APP_FC_STOP_APPLICATION   0x12
 
#define DNP3_APP_FC_SAVE_CONFIGURATION   0x13
 
#define DNP3_APP_FC_ENABLE_UNSOLICITED   0x14
 
#define DNP3_APP_FC_DISABLE_UNSOLICITED   0x15
 
#define DNP3_APP_FC_ASSIGN_CLASS   0x16
 
#define DNP3_APP_FC_DELAY_MEASUREMENT   0x17
 
#define DNP3_APP_FC_RECORD_CURRENT_TIME   0x18
 
#define DNP3_APP_FC_OPEN_TIME   0x19
 
#define DNP3_APP_FC_CLOSE_FILE   0x1a
 
#define DNP3_APP_FC_DELETE_FILE   0x1b
 
#define DNP3_APP_FC_GET_FILE_INFO   0x1c
 
#define DNP3_APP_FC_AUTHENTICATE_FILE   0x1d
 
#define DNP3_APP_FC_ABORT_FILE   0x1e
 
#define DNP3_APP_FC_ACTIVATE_CONFIG   0x1f
 
#define DNP3_APP_FC_AUTH_REQ   0x20
 
#define DNP3_APP_FC_AUTH_REQ_NR   0x21
 
#define DNP3_APP_FC_RESPONSE   0x81
 
#define DNP3_APP_FC_UNSOLICITED_RESP   0x82
 
#define DNP3_APP_FC_AUTH_RESP   0x83
 
#define DNP3_LINK_DIR(control)   (control & 0x80)
 
#define DNP3_LINK_PRI(control)   (control & 0x40)
 
#define DNP3_LINK_FCB(control)   (control & 0x20)
 
#define DNP3_LINK_FCV(control)   (control & 0x10)
 
#define DNP3_LINK_FC(control)   (control & 0x0f)
 
#define DNP3_TH_FIN(x)   (x & 0x80)
 
#define DNP3_TH_FIR(x)   (x & 0x40)
 
#define DNP3_TH_SEQ(x)   (x & 0x3f)
 
#define DNP3_APP_FIR(x)   (x & 0x80)
 
#define DNP3_APP_FIN(x)   (x & 0x40)
 
#define DNP3_APP_CON(x)   (x & 0x20)
 
#define DNP3_APP_UNS(x)   (x & 0x10)
 
#define DNP3_APP_SEQ(x)   (x & 0x0f)
 
#define DNP3_SWAP16(x)   SCByteSwap16(x)
 
#define DNP3_SWAP32(x)   SCByteSwap32(x)
 
#define DNP3_SWAP64(x)   SCByteSwap64(x)
 

Typedefs

typedef uint8_t DNP3TransportHeader
 DNP3 transport header. More...
 
typedef struct DNP3Buffer_ DNP3Buffer
 A struct used for buffering incoming data prior to reassembly. More...
 
typedef struct DNP3Point_ DNP3Point
 DNP3 object point. More...
 
typedef struct DNP3Object_ DNP3Object
 Struct to hold the list of decoded objects. More...
 
typedef struct DNP3Transaction_ DNP3Transaction
 DNP3 transaction. More...
 
typedef struct DNP3State_ DNP3State
 Per flow DNP3 state. More...
 

Enumerations

enum  {
  DNP3_DECODER_EVENT_FLOODED = 1, DNP3_DECODER_EVENT_LEN_TOO_SMALL, DNP3_DECODER_EVENT_BAD_LINK_CRC, DNP3_DECODER_EVENT_BAD_TRANSPORT_CRC,
  DNP3_DECODER_EVENT_MALFORMED, DNP3_DECODER_EVENT_UNKNOWN_OBJECT
}
 

Functions

struct DNP3LinkHeader_ __attribute__ ((__packed__)) DNP3LinkHeader
 DNP3 link header. More...
 
struct DNP3ObjHeader_ __attribute__ ((packed)) DNP3ObjHeader
 DNP3 application object header. More...
 
typedef TAILQ_HEAD (DNP3PointList_, DNP3Point_) DNP3PointList
 
typedef TAILQ_HEAD (DNP3ObjectList_, DNP3Object_) DNP3ObjectList
 
 TAILQ_HEAD (TxListHead, DNP3Transaction_)
 
void RegisterDNP3Parsers (void)
 Register the DNP3 application protocol parser. More...
 
void DNP3ParserRegisterTests (void)
 
int DNP3PrefixIsSize (uint8_t)
 Check if the prefix code is a size prefix. More...
 

Variables

uint8_t start_byte0
 
uint8_t start_byte1
 
uint8_t len
 
uint8_t control
 
uint16_t dst
 
uint16_t src
 
uint16_t crc
 
uint8_t function_code
 
uint8_t iin1
 
uint8_t iin2
 
uint8_t group
 
uint8_t variation
 
uint8_t qualifier
 

Detailed Description

DNP3 application layer protocol header file

Definition in file app-layer-dnp3.h.

Macro Definition Documentation

◆ DNP3_APP_CON

#define DNP3_APP_CON (   x)    (x & 0x20)

Definition at line 89 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_ABORT_FILE

#define DNP3_APP_FC_ABORT_FILE   0x1e

Definition at line 64 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_ACTIVATE_CONFIG

#define DNP3_APP_FC_ACTIVATE_CONFIG   0x1f

Definition at line 65 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_ASSIGN_CLASS

#define DNP3_APP_FC_ASSIGN_CLASS   0x16

Definition at line 56 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_AUTH_REQ

#define DNP3_APP_FC_AUTH_REQ   0x20

Definition at line 66 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_AUTH_REQ_NR

#define DNP3_APP_FC_AUTH_REQ_NR   0x21

Definition at line 67 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_AUTH_RESP

#define DNP3_APP_FC_AUTH_RESP   0x83

Definition at line 72 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_AUTHENTICATE_FILE

#define DNP3_APP_FC_AUTHENTICATE_FILE   0x1d

Definition at line 63 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_CLOSE_FILE

#define DNP3_APP_FC_CLOSE_FILE   0x1a

Definition at line 60 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_COLD_RESTART

#define DNP3_APP_FC_COLD_RESTART   0x0d

Definition at line 47 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_CONFIRM

#define DNP3_APP_FC_CONFIRM   0x00

Definition at line 34 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_DELAY_MEASUREMENT

#define DNP3_APP_FC_DELAY_MEASUREMENT   0x17

Definition at line 57 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_DELETE_FILE

#define DNP3_APP_FC_DELETE_FILE   0x1b

Definition at line 61 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_DIR_OPERATE

#define DNP3_APP_FC_DIR_OPERATE   0x05

Definition at line 39 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_DIR_OPERATE_NR

#define DNP3_APP_FC_DIR_OPERATE_NR   0x06

Definition at line 40 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_DISABLE_UNSOLICITED

#define DNP3_APP_FC_DISABLE_UNSOLICITED   0x15

Definition at line 55 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_ENABLE_UNSOLICITED

#define DNP3_APP_FC_ENABLE_UNSOLICITED   0x14

Definition at line 54 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_FREEZE

#define DNP3_APP_FC_FREEZE   0x07

Definition at line 41 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_FREEZE_AT_TIME

#define DNP3_APP_FC_FREEZE_AT_TIME   0x0b

Definition at line 45 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_FREEZE_AT_TIME_NR

#define DNP3_APP_FC_FREEZE_AT_TIME_NR   0x0c

Definition at line 46 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_FREEZE_CLEAR

#define DNP3_APP_FC_FREEZE_CLEAR   0x09

Definition at line 43 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_FREEZE_CLEAR_NR

#define DNP3_APP_FC_FREEZE_CLEAR_NR   0x0a

Definition at line 44 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_FREEZE_NR

#define DNP3_APP_FC_FREEZE_NR   0x08

Definition at line 42 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_GET_FILE_INFO

#define DNP3_APP_FC_GET_FILE_INFO   0x1c

Definition at line 62 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_INITIALIZE_APPLICATION

#define DNP3_APP_FC_INITIALIZE_APPLICATION   0x10

Definition at line 50 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_INITIALIZE_DATA

#define DNP3_APP_FC_INITIALIZE_DATA   0x0f

Definition at line 49 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_OPEN_TIME

#define DNP3_APP_FC_OPEN_TIME   0x19

Definition at line 59 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_OPERATE

#define DNP3_APP_FC_OPERATE   0x04

Definition at line 38 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_READ

#define DNP3_APP_FC_READ   0x01

Definition at line 35 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_RECORD_CURRENT_TIME

#define DNP3_APP_FC_RECORD_CURRENT_TIME   0x18

Definition at line 58 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_RESPONSE

#define DNP3_APP_FC_RESPONSE   0x81

Definition at line 70 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_SAVE_CONFIGURATION

#define DNP3_APP_FC_SAVE_CONFIGURATION   0x13

Definition at line 53 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_SELECT

#define DNP3_APP_FC_SELECT   0x03

Definition at line 37 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_START_APPLICATION

#define DNP3_APP_FC_START_APPLICATION   0x11

Definition at line 51 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_STOP_APPLICATION

#define DNP3_APP_FC_STOP_APPLICATION   0x12

Definition at line 52 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_UNSOLICITED_RESP

#define DNP3_APP_FC_UNSOLICITED_RESP   0x82

Definition at line 71 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_WARM_RESTART

#define DNP3_APP_FC_WARM_RESTART   0x0e

Definition at line 48 of file app-layer-dnp3.h.

◆ DNP3_APP_FC_WRITE

#define DNP3_APP_FC_WRITE   0x02

Definition at line 36 of file app-layer-dnp3.h.

◆ DNP3_APP_FIN

#define DNP3_APP_FIN (   x)    (x & 0x40)

Definition at line 88 of file app-layer-dnp3.h.

◆ DNP3_APP_FIR

#define DNP3_APP_FIR (   x)    (x & 0x80)

Definition at line 87 of file app-layer-dnp3.h.

◆ DNP3_APP_SEQ

#define DNP3_APP_SEQ (   x)    (x & 0x0f)

Definition at line 91 of file app-layer-dnp3.h.

◆ DNP3_APP_UNS

#define DNP3_APP_UNS (   x)    (x & 0x10)

Definition at line 90 of file app-layer-dnp3.h.

◆ DNP3_LINK_DIR

#define DNP3_LINK_DIR (   control)    (control & 0x80)

Definition at line 75 of file app-layer-dnp3.h.

◆ DNP3_LINK_FC

#define DNP3_LINK_FC (   control)    (control & 0x0f)

Definition at line 79 of file app-layer-dnp3.h.

◆ DNP3_LINK_FCB

#define DNP3_LINK_FCB (   control)    (control & 0x20)

Definition at line 77 of file app-layer-dnp3.h.

◆ DNP3_LINK_FCV

#define DNP3_LINK_FCV (   control)    (control & 0x10)

Definition at line 78 of file app-layer-dnp3.h.

◆ DNP3_LINK_PRI

#define DNP3_LINK_PRI (   control)    (control & 0x40)

Definition at line 76 of file app-layer-dnp3.h.

◆ DNP3_SWAP16

#define DNP3_SWAP16 (   x)    SCByteSwap16(x)

Definition at line 96 of file app-layer-dnp3.h.

◆ DNP3_SWAP32

#define DNP3_SWAP32 (   x)    SCByteSwap32(x)

Definition at line 97 of file app-layer-dnp3.h.

◆ DNP3_SWAP64

#define DNP3_SWAP64 (   x)    SCByteSwap64(x)

Definition at line 98 of file app-layer-dnp3.h.

◆ DNP3_TH_FIN

#define DNP3_TH_FIN (   x)    (x & 0x80)

Definition at line 82 of file app-layer-dnp3.h.

◆ DNP3_TH_FIR

#define DNP3_TH_FIR (   x)    (x & 0x40)

Definition at line 83 of file app-layer-dnp3.h.

◆ DNP3_TH_SEQ

#define DNP3_TH_SEQ (   x)    (x & 0x3f)

Definition at line 84 of file app-layer-dnp3.h.

Typedef Documentation

◆ DNP3Buffer

typedef struct DNP3Buffer_ DNP3Buffer

A struct used for buffering incoming data prior to reassembly.

◆ DNP3Object

typedef struct DNP3Object_ DNP3Object

Struct to hold the list of decoded objects.

◆ DNP3Point

typedef struct DNP3Point_ DNP3Point

DNP3 object point.

Each DNP3 object can have 0 or more points representing the values of the object.

◆ DNP3State

typedef struct DNP3State_ DNP3State

Per flow DNP3 state.

◆ DNP3Transaction

DNP3 transaction.

◆ DNP3TransportHeader

typedef uint8_t DNP3TransportHeader

DNP3 transport header.

Definition at line 130 of file app-layer-dnp3.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
DNP3_DECODER_EVENT_FLOODED 
DNP3_DECODER_EVENT_LEN_TOO_SMALL 
DNP3_DECODER_EVENT_BAD_LINK_CRC 
DNP3_DECODER_EVENT_BAD_TRANSPORT_CRC 
DNP3_DECODER_EVENT_MALFORMED 
DNP3_DECODER_EVENT_UNKNOWN_OBJECT 

Definition at line 105 of file app-layer-dnp3.h.

Function Documentation

◆ __attribute__() [1/2]

struct DNP3LinkHeader_ __attribute__ ( (__packed__)  )

DNP3 link header.

DNP3 internal indicators.

DNP3 application header.

Part of the application header for responses only.

Definition at line 54 of file decode-vlan.c.

◆ __attribute__() [2/2]

struct DNP3ObjHeader_ __attribute__ ( (packed)  )

DNP3 application object header.

Definition at line 1 of file source-erf-file.c.

◆ DNP3ParserRegisterTests()

void DNP3ParserRegisterTests ( void  )

Definition at line 2629 of file app-layer-dnp3.c.

References UtRegisterTest().

Here is the call graph for this function:

◆ DNP3PrefixIsSize()

int DNP3PrefixIsSize ( uint8_t  prefix_code)

Check if the prefix code is a size prefix.

Return values
1if the prefix_code specifies a size prefix, 0 if not.

Definition at line 1498 of file app-layer-dnp3.c.

◆ RegisterDNP3Parsers()

void RegisterDNP3Parsers ( void  )

Register the DNP3 application protocol parser.

Definition at line 1548 of file app-layer-dnp3.c.

References ALPROTO_DNP3, AppLayerProtoDetectConfProtoDetectionEnabledDefault(), AppLayerProtoDetectPPRegister(), AppLayerProtoDetectRegisterProtocol(), DNP3_DEFAULT_PORT, RunmodeIsUnittests(), and SCEnter.

Here is the call graph for this function:

◆ TAILQ_HEAD() [1/3]

typedef TAILQ_HEAD ( DNP3ObjectList_  ,
DNP3Object_   
)

◆ TAILQ_HEAD() [2/3]

typedef TAILQ_HEAD ( DNP3PointList_  ,
DNP3Point_   
)

◆ TAILQ_HEAD() [3/3]

TAILQ_HEAD ( TxListHead  ,
DNP3Transaction_   
)

Variable Documentation

◆ control

uint8_t control

Control flags.

Definition at line 3 of file app-layer-dnp3.h.

◆ crc

uint16_t crc

Link header CRC.

Definition at line 6 of file app-layer-dnp3.h.

◆ dst

◆ function_code

uint8_t function_code

Application function code.

Definition at line 1 of file app-layer-dnp3.h.

◆ group

uint8_t group

Definition at line 0 of file app-layer-dnp3.h.

Referenced by DNP3DecodeObject(), DNP3FreeObjectPoint(), SCGetGroupID(), and SCGetUserID().

◆ iin1

uint8_t iin1

Definition at line 0 of file app-layer-dnp3.h.

◆ iin2

uint8_t iin2

Definition at line 1 of file app-layer-dnp3.h.

◆ len

◆ qualifier

uint8_t qualifier

Definition at line 2 of file app-layer-dnp3.h.

◆ src

◆ start_byte0

uint8_t start_byte0

First check byte.

Definition at line 0 of file app-layer-dnp3.h.

◆ start_byte1

uint8_t start_byte1

Second check byte.

Definition at line 1 of file app-layer-dnp3.h.

◆ variation

uint8_t variation

Definition at line 1 of file app-layer-dnp3.h.

Referenced by DNP3DecodeObject(), and DNP3FreeObjectPoint().