struct S7commplusSessionData
{
uint8_t s7commplus_proto_id = 0;
- uint8_t s7commplus_pdu_type = 0;
+ uint8_t s7commplus_proto_version = 0;
uint16_t s7commplus_data_len = 0;
uint8_t s7commplus_opcode = 0;
uint16_t s7commplus_reserved_1 = 0;
void session_data_reset()
{
- s7commplus_proto_id = s7commplus_pdu_type = s7commplus_opcode = 0;
+ s7commplus_proto_id = s7commplus_proto_version = s7commplus_opcode = 0;
s7commplus_data_len = s7commplus_function = 0;
s7commplus_reserved_1 = s7commplus_reserved_2 = 0;
}
struct S7commplusHeader
{
uint8_t proto_id;
- uint8_t pdu_type;
+ uint8_t proto_version;
uint16_t data_len;
};
s7commplus_header = (const S7commplusHeader*)(p->data + offset);
/* Set the session data. Swap byte order for 16-bit fields. */
session->s7commplus_proto_id = s7commplus_header->proto_id;
- session->s7commplus_pdu_type = s7commplus_header->pdu_type;
+ session->s7commplus_proto_version = s7commplus_header->proto_version;
session->s7commplus_data_len = ntohs(s7commplus_header->data_len);
- offset += sizeof(S7commplusHeader);
+ if (s7commplus_header->proto_version <= HDR_VERSION_TWO)
+ {
+ /* V1 or V2 header packets */
+ offset += sizeof(S7commplusHeader);
+ }
+ else
+ {
+ /* 33 byte Integrity part for V3 header packets */
+ offset += sizeof(S7commplusHeader) + INTEGRITY_PART_LEN ;
+ }
s7commplus_data_header = (const S7commplusDataHeader*)(p->data + offset);
/* Set the session data. Swap byte order for 16-bit fields. */
#define TPKT_MIN_HDR_LEN 7 /* length field in TPKT header for S7comm */
#define TPKT_MAX_HDR_LEN /* Undecided */
#define S7COMMPLUS_MIN_HDR_LEN 4
+#define HDR_VERSION_TWO 0x02
+#define INTEGRITY_PART_LEN 33 /* length of Integrity part in V3 Header packets */
/* Need 8 bytes for MBAP Header + Function Code */
#define S7COMMPLUS_MIN_LEN 8 this value needs to be decided