suricata
app-layer-dnp3.c File Reference
#include "suricata-common.h"
#include "suricata.h"
#include "util-unittest.h"
#include "util-spm-bs.h"
#include "util-enum.h"
#include "app-layer.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 "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_LINK_HDR_LEN   5
 
#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 DNP3_BANNER   "DNP3"
 

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 []
 

Detailed Description

DNP3 protocol implementation

Definition in file app-layer-dnp3.c.

Macro Definition Documentation

◆ DNP3_BANNER

#define DNP3_BANNER   "DNP3"

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

◆ DNP3_BLOCK_SIZE

#define DNP3_BLOCK_SIZE   16

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

◆ DNP3_CRC_LEN

#define DNP3_CRC_LEN   2

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

◆ DNP3_DEFAULT_PORT

#define DNP3_DEFAULT_PORT   "20000"

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

◆ DNP3_DEFAULT_REQ_FLOOD_COUNT

#define DNP3_DEFAULT_REQ_FLOOD_COUNT   500

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

◆ DNP3_LINK_HDR_LEN

#define DNP3_LINK_HDR_LEN   5

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

◆ DNP3_MAX_TRAN_SEQNO

#define DNP3_MAX_TRAN_SEQNO   64

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

◆ DNP3_MIN_LEN

#define DNP3_MIN_LEN   5

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

◆ DNP3_OBJ_PREFIX

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

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

◆ DNP3_OBJ_RANGE

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

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

◆ DNP3_START_BYTE0

#define DNP3_START_BYTE0   0x05

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

◆ DNP3_START_BYTE1

#define DNP3_START_BYTE1   0x64

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

◆ NEXT_TH_SEQNO

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

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

Function Documentation

◆ DNP3ParserRegisterTests()

void DNP3ParserRegisterTests ( void  )

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

◆ RegisterDNP3Parsers()

void RegisterDNP3Parsers ( void  )

Register the DNP3 application protocol parser.

Definition at line 1532 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:

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 88 of file app-layer-dnp3.c.

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