stats: always use tcp/udp prefix

Even when on detection-only mode.
So that we always have enip_tcp and enip_udp in stats
and never just `enip`.

Ticket: 6304
pull/10076/head
Philippe Antoine 2 years ago committed by Victor Julien
parent 467c3f2c64
commit 4bcdc79ed8

@ -1061,16 +1061,18 @@ void AppLayerSetupCounters(void)
for (uint8_t p = 0; p < IPPROTOS_MAX; p++) {
const uint8_t ipproto = ipprotos[p];
const uint8_t ipproto_map = FlowGetProtoMapping(ipproto);
const uint8_t other_ipproto = ipproto == IPPROTO_TCP ? IPPROTO_UDP : IPPROTO_TCP;
const char *ipproto_suffix = (ipproto == IPPROTO_TCP) ? "_tcp" : "_udp";
uint8_t ipprotos_all[256 / 8];
for (AppProto alproto = 0; alproto < ALPROTO_MAX; alproto++) {
if (alprotos[alproto] == 1) {
const char *tx_str = "app_layer.tx.";
const char *alproto_str = AppLayerGetProtoName(alproto);
if (AppLayerParserProtoIsRegistered(ipproto, alproto) &&
AppLayerParserProtoIsRegistered(other_ipproto, alproto)) {
memset(ipprotos_all, 0, sizeof(ipprotos_all));
AppLayerProtoDetectSupportedIpprotos(alproto, ipprotos_all);
if ((ipprotos_all[IPPROTO_TCP / 8] & (1 << (IPPROTO_TCP % 8))) &&
(ipprotos_all[IPPROTO_UDP / 8] & (1 << (IPPROTO_UDP % 8)))) {
snprintf(applayer_counter_names[ipproto_map][alproto].name,
sizeof(applayer_counter_names[ipproto_map][alproto].name),
"%s%s%s", str, alproto_str, ipproto_suffix);

Loading…
Cancel
Save