AppLayerParserState *pstate = NULL;
AppLayerParserProtoCtx *p = &alp_ctx.ctxs[f->protomap][alproto];
void *alstate = NULL;
+ uint64_t p_tx_cnt = 0;
/* we don't have the parser registered for this protocol */
if (p->StateAlloc == NULL)
alstate, AppLayerGetProtoName(f->alproto));
}
+ if (AppLayerParserProtocolIsTxAware(f->proto, alproto)) {
+ p_tx_cnt = AppLayerParserGetTxCnt(f->proto, alproto, f->alstate);
+ }
+
/* invoke the recursive parser, but only on data. We may get empty msgs on EOF */
if (input_len > 0 || (flags & STREAM_EOF)) {
/* invoke the parser */
}
}
+ if (AppLayerParserProtocolIsTxAware(f->proto, alproto)) {
+ if (likely(tv)) {
+ uint64_t cur_tx_cnt = AppLayerParserGetTxCnt(f->proto, alproto, f->alstate);
+ if (cur_tx_cnt > p_tx_cnt) {
+ AppLayerIncTxCounter(tv, f, cur_tx_cnt - p_tx_cnt);
+ }
+ }
+ }
/* next, see if we can get rid of transactions now */
AppLayerParserTransactionsCleanup(f);
typedef struct AppLayerCounters_ {
char *name;
+ char *tx_name;
uint16_t counter_id;
+ uint16_t counter_tx_id;
} AppLayerCounters;
AppLayerCounters applayer_counters[FLOW_PROTO_MAX][ALPROTO_MAX];
}
}
+void AppLayerIncTxCounter(ThreadVars *tv, Flow *f, uint64_t step)
+{
+ if (likely(tv)) {
+ StatsAddUI64(tv, applayer_counters[f->protomap][f->alproto].counter_tx_id, step);
+ }
+}
+
int AppLayerHandleTCPData(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx,
Packet *p, Flow *f,
TcpSession *ssn, TcpStream *stream,
for (alproto = 0; alproto < ALPROTO_MAX; alproto++) {
if (alprotos[alproto] == 1) {
char *str = "app_layer.flow.";
+ char *tx_str = "app_layer.tx.";
char *alproto_str = AppLayerGetProtoName(alproto);
int alproto_len = strlen(alproto_str) + 1;
uint8_t ipproto_map = FlowGetProtoMapping(ipprotos[ipproto]);
+ size_t size;
if (AppLayerParserProtoIsRegistered(ipprotos[ipproto], alproto) &&
AppLayerParserProtoIsRegistered(other_ipproto, alproto))
{
- applayer_counters[ipproto_map][alproto].name =
- SCMalloc(strlen(str) + alproto_len + strlen(ipproto_suffix));
+ size = strlen(str) + alproto_len + strlen(ipproto_suffix);
+ applayer_counters[ipproto_map][alproto].name = SCMalloc(size);
if (applayer_counters[ipproto_map][alproto].name == NULL) {
return;
}
- snprintf(applayer_counters[ipproto_map][alproto].name,
- strlen(str) + alproto_len + strlen(ipproto_suffix),
- "%s%s%s", str, alproto_str, ipproto_suffix);
+ snprintf(applayer_counters[ipproto_map][alproto].name, size,
+ "%s%s%s", str, alproto_str, ipproto_suffix);
+ if (AppLayerParserProtocolIsTxAware(ipprotos[ipproto], alproto)) {
+ size = strlen(tx_str) + alproto_len + strlen(ipproto_suffix);
+ applayer_counters[ipproto_map][alproto].tx_name = SCMalloc(size);
+ if (applayer_counters[ipproto_map][alproto].tx_name == NULL) {
+ return;
+ }
+ snprintf(applayer_counters[ipproto_map][alproto].tx_name, size,
+ "%s%s%s", tx_str, alproto_str, ipproto_suffix);
+ }
} else {
- applayer_counters[ipproto_map][alproto].name =
- SCMalloc(strlen(str) + alproto_len);
+ size = strlen(str) + alproto_len;
+ applayer_counters[ipproto_map][alproto].name = SCMalloc(size);
if (applayer_counters[ipproto_map][alproto].name == NULL) {
return;
}
- snprintf(applayer_counters[ipproto_map][alproto].name,
- strlen(str) + alproto_len,
- "%s%s", str, alproto_str);
+ snprintf(applayer_counters[ipproto_map][alproto].name, size,
+ "%s%s", str, alproto_str);
+ if (AppLayerParserProtocolIsTxAware(ipprotos[ipproto], alproto)) {
+ size = strlen(tx_str) + alproto_len;
+ applayer_counters[ipproto_map][alproto].tx_name = SCMalloc(size);
+ if (applayer_counters[ipproto_map][alproto].tx_name == NULL) {
+ return;
+ }
+ snprintf(applayer_counters[ipproto_map][alproto].tx_name, size,
+ "%s%s", tx_str, alproto_str);
+ }
}
}
}
uint8_t ipproto_map = FlowGetProtoMapping(ipprotos[ipproto]);
applayer_counters[ipproto_map][alproto].counter_id =
StatsRegisterCounter(applayer_counters[ipproto_map][alproto].name, tv);
+
+ if (AppLayerParserProtocolIsTxAware(ipprotos[ipproto], alproto)) {
+ applayer_counters[ipproto_map][alproto].counter_tx_id =
+ StatsRegisterCounter(applayer_counters[ipproto_map][alproto].tx_name, tv);
+ }
}
}
}
applayer_counters[FlowGetProtoMapping(ipprotos[ipproto])][alproto].name = NULL;
}
}
+ if (applayer_counters[FlowGetProtoMapping(ipproto)][alproto].tx_name) {
+ SCFree(applayer_counters[FlowGetProtoMapping(ipproto)][alproto].tx_name);
+ applayer_counters[FlowGetProtoMapping(ipproto)][alproto].tx_name = NULL;
+ }
}
}
}