suricata
app-layer-dnp3.c File Reference
#include "suricata-common.h"
#include "stream.h"
#include "util-byte.h"
#include "util-unittest.h"
#include "util-hashlist.h"
#include "util-print.h"
#include "app-layer-protos.h"
#include "app-layer-parser.h"
#include "app-layer-detect-proto.h"
#include "app-layer-dnp3.h"
#include "app-layer-dnp3-objects.h"
#include "app-layer-dcerpc-common.h"
#include "flow-util.h"
#include "stream-tcp.h"
Include dependency graph for app-layer-dnp3.c:

Go to the source code of this file.

Macros

#define DNP3_DEFAULT_REQ_FLOOD_COUNT   500
 
#define DNP3_DEFAULT_PORT   "20000"
 
#define DNP3_START_BYTE0   0x05
 
#define DNP3_START_BYTE1   0x64
 
#define DNP3_MIN_LEN   5
 
#define DNP3_CRC_LEN   2
 
#define DNP3_BLOCK_SIZE   16
 
#define DNP3_MAX_TRAN_SEQNO   64
 
#define DNP3_MAX_APP_SEQNO   16
 
#define DNP3_LINK_HDR_LEN   5
 
#define DNP3_RESERVED_ADDR_MIN   0xfff0
 
#define DNP3_RESERVED_ADDR_MAX   0xfffb
 
#define DNP3_SRC_ADDR_MAX   0xfff0
 
#define DNP3_OBJ_TIME_SIZE   6 /* AKA UINT48. */
 
#define DNP3_OBJ_G12_V1_SIZE   11
 
#define DNP3_OBJ_G12_V2_SIZE   11
 
#define DNP3_OBJ_G12_V3_SIZE   1
 
#define DNP3_OBJ_PREFIX(x)   ((x >> 4) & 0x7)
 
#define DNP3_OBJ_RANGE(x)   (x & 0xf)
 
#define NEXT_TH_SEQNO(current)   ((current + 1) % DNP3_MAX_TRAN_SEQNO)
 
#define NEXT_APP_SEQNO(current)   ((current + 1) % DNP3_MAX_APP_SEQNO)
 

Enumerations

enum  { DNP3_LINK_FC_CONFIRMED_USER_DATA = 3, DNP3_LINK_FC_UNCONFIRMED_USER_DATA }
 

Functions

int DNP3PrefixIsSize (uint8_t prefix_code)
 Check if the prefix code is a size prefix. More...
 
void RegisterDNP3Parsers (void)
 Register the DNP3 application protocol parser. More...
 
void DNP3ParserRegisterTests (void)
 

Variables

SCEnumCharMap dnp3_decoder_event_table []
 

Macro Definition Documentation

◆ DNP3_BLOCK_SIZE

#define DNP3_BLOCK_SIZE   16

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

◆ DNP3_CRC_LEN

#define DNP3_CRC_LEN   2

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

◆ DNP3_DEFAULT_PORT

#define DNP3_DEFAULT_PORT   "20000"

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

◆ DNP3_DEFAULT_REQ_FLOOD_COUNT

#define DNP3_DEFAULT_REQ_FLOOD_COUNT   500

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

◆ DNP3_LINK_HDR_LEN

#define DNP3_LINK_HDR_LEN   5

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

◆ DNP3_MAX_APP_SEQNO

#define DNP3_MAX_APP_SEQNO   16

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

◆ DNP3_MAX_TRAN_SEQNO

#define DNP3_MAX_TRAN_SEQNO   64

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

◆ DNP3_MIN_LEN

#define DNP3_MIN_LEN   5

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

◆ DNP3_OBJ_G12_V1_SIZE

#define DNP3_OBJ_G12_V1_SIZE   11

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

◆ DNP3_OBJ_G12_V2_SIZE

#define DNP3_OBJ_G12_V2_SIZE   11

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

◆ DNP3_OBJ_G12_V3_SIZE

#define DNP3_OBJ_G12_V3_SIZE   1

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

◆ DNP3_OBJ_PREFIX

#define DNP3_OBJ_PREFIX (   x)    ((x >> 4) & 0x7)

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

◆ DNP3_OBJ_RANGE

#define DNP3_OBJ_RANGE (   x)    (x & 0xf)

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

◆ DNP3_OBJ_TIME_SIZE

#define DNP3_OBJ_TIME_SIZE   6 /* AKA UINT48. */

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

◆ DNP3_RESERVED_ADDR_MAX

#define DNP3_RESERVED_ADDR_MAX   0xfffb

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

◆ DNP3_RESERVED_ADDR_MIN

#define DNP3_RESERVED_ADDR_MIN   0xfff0

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

◆ DNP3_SRC_ADDR_MAX

#define DNP3_SRC_ADDR_MAX   0xfff0

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

◆ DNP3_START_BYTE0

#define DNP3_START_BYTE0   0x05

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

◆ DNP3_START_BYTE1

#define DNP3_START_BYTE1   0x64

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

◆ NEXT_APP_SEQNO

#define NEXT_APP_SEQNO (   current)    ((current + 1) % DNP3_MAX_APP_SEQNO)

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

◆ NEXT_TH_SEQNO

#define NEXT_TH_SEQNO (   current)    ((current + 1) % DNP3_MAX_TRAN_SEQNO)

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

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
DNP3_LINK_FC_CONFIRMED_USER_DATA 
DNP3_LINK_FC_UNCONFIRMED_USER_DATA 

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

Function Documentation

◆ DNP3ParserRegisterTests()

void DNP3ParserRegisterTests ( void  )

Definition at line 2675 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 1577 of file app-layer-dnp3.c.

◆ RegisterDNP3Parsers()

void RegisterDNP3Parsers ( void  )

Register the DNP3 application protocol parser.

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

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

Referenced by AppLayerParserRegisterProtocolParsers().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ dnp3_decoder_event_table

SCEnumCharMap dnp3_decoder_event_table[]
Initial value:
= {
{"BAD_TRANSPORT_CRC", DNP3_DECODER_EVENT_BAD_TRANSPORT_CRC},
{"UNKNOWN_OBJECT", DNP3_DECODER_EVENT_UNKNOWN_OBJECT},
{NULL, -1},
}

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

DNP3_DECODER_EVENT_MALFORMED
@ DNP3_DECODER_EVENT_MALFORMED
Definition: app-layer-dnp3.h:109
DNP3_DECODER_EVENT_FLOODED
@ DNP3_DECODER_EVENT_FLOODED
Definition: app-layer-dnp3.h:105
DNP3_DECODER_EVENT_UNKNOWN_OBJECT
@ DNP3_DECODER_EVENT_UNKNOWN_OBJECT
Definition: app-layer-dnp3.h:110
DNP3_DECODER_EVENT_BAD_LINK_CRC
@ DNP3_DECODER_EVENT_BAD_LINK_CRC
Definition: app-layer-dnp3.h:107
DNP3_DECODER_EVENT_BAD_TRANSPORT_CRC
@ DNP3_DECODER_EVENT_BAD_TRANSPORT_CRC
Definition: app-layer-dnp3.h:108
DNP3_DECODER_EVENT_LEN_TOO_SMALL
@ DNP3_DECODER_EVENT_LEN_TOO_SMALL
Definition: app-layer-dnp3.h:106