Squashed commit of the following:
commit
689610e78e3964183dd9743cc2b284cc78520e28
Author: Katura Harvey <katharve@cisco.com>
Date: Thu Jun 4 17:08:10 2020 -0400
service_inspectors: remove some redundant initializations and lookups, move some field initializations into the constructor
// total per frame - scan
uint32_t frame_length;
uint32_t data_len;
- uint32_t padding_len = 0;
+ uint32_t padding_len;
uint8_t frame_flags;
// accumulating - scan
uint32_t frame_bytes_seen = 0;
uint32_t bytes_sent_http = 0;
- uint32_t data_bytes_read = 0;
- uint32_t padding_read = 0;
+ uint32_t data_bytes_read;
+ uint32_t padding_read;
// leftover from previous scan call
uint32_t leftover_bytes = 0;
uint32_t leftover_padding = 0;
events = stream_events;
infractions = stream_infractions;
pseudo_headers_fragment_size = 0;
+ decode_error = false;
// A maximum of two table size updates are allowed, and must be at the start of the header block
table_size_update_allowed = true;
HpackIndexTable* get_decode_table() { return &decode_table; }
private:
- Http2StartLine* start_line = nullptr;
+ Http2StartLine* start_line;
uint32_t decoded_headers_size;
- uint32_t pseudo_headers_fragment_size = 0;
- bool decode_error = false;
+ uint32_t pseudo_headers_fragment_size;
+ bool decode_error;
Http2EventGen* events;
Http2Infractions* infractions;
{
headers_present[header_name_id[j]] = true;
NormalizedHeader* tmp_ptr = norm_heads;
- norm_heads = new NormalizedHeader(header_name_id[j]);
- norm_heads->next = tmp_ptr;
- norm_heads->count = 1;
+ norm_heads = new NormalizedHeader(tmp_ptr, 1, header_name_id[j]);
}
}
}
struct NormalizedHeader
{
- NormalizedHeader(HttpEnums::HeaderId id_) : id(id_) {}
+ NormalizedHeader(NormalizedHeader* next_, int32_t count_, HttpEnums::HeaderId id_) :
+ next(next_), count(count_), id(id_) {}
Field norm;
NormalizedHeader* next;
// evaluating on the first PDU. Setting this flag stops the caching.
p->packet_flags |= PKT_ALLOW_MULTIPLE_DETECT;
- if ( !ModbusDecode(p) )
+ if ( !ModbusDecode(p, mfd) )
mfd->reset();
}
}
}
-bool ModbusDecode(Packet* p)
+bool ModbusDecode(Packet* p, ModbusFlowData* mfd)
{
const modbus_header_t* header;
if (p->dsize < MODBUS_MIN_LEN)
return false;
- ModbusFlowData* mfd =
- (ModbusFlowData*)p->flow->get_flow_data(ModbusFlowData::inspector_id);
-
/* Lay the header struct over the payload */
header = (const modbus_header_t*)p->data;
struct Packet;
}
+class ModbusFlowData;
+
/* Need 8 bytes for MBAP Header + Function Code */
#define MODBUS_MIN_LEN 8
-bool ModbusDecode(snort::Packet*);
+bool ModbusDecode(snort::Packet*, ModbusFlowData* mfd);
#endif
// evaluating on the first PDU. Setting this flag stops the caching.
p->packet_flags |= PKT_ALLOW_MULTIPLE_DETECT;
- if ( !S7commplusDecode(p) )
+ if ( !S7commplusDecode(p, mfd))
mfd->reset();
}
return true;
}
-bool S7commplusDecode(Packet* p)
+bool S7commplusDecode(Packet* p, S7commplusFlowData* mfd)
{
const TpktHeader* tpkt_header;
const CotpHeader* cotp_header;
if (p->dsize < TPKT_MIN_HDR_LEN)
return false;
- S7commplusFlowData* mfd =
- (S7commplusFlowData*)p->flow->get_flow_data(S7commplusFlowData::inspector_id);
tpkt_header = (const TpktHeader*)p->data;
cotp_header = (const CotpHeader*)(p->data + sizeof(TpktHeader));
tpkt_length = ntohs(tpkt_header->length);
struct Packet;
}
+class S7commplusFlowData;
+
/* S7comm defines */
#define S7COMMPLUS_PDUTYPE_CONNECT 0x01
#define S7COMMPLUS_PDUTYPE_DATA 0x02
#define S7COMMPLUS_RESERVED_FUNCTION_STR \
"(spp_s7commplus): Reserved S7commplus function code in use."
-bool S7commplusDecode(snort::Packet*);
+bool S7commplusDecode(snort::Packet*, S7commplusFlowData* mfd);
#endif