diff --git a/userland/examples/pfcount.c b/userland/examples/pfcount.c index 791f4f348..74cb2c549 100644 --- a/userland/examples/pfcount.c +++ b/userland/examples/pfcount.c @@ -576,7 +576,7 @@ void print_packet(const struct pfring_pkthdr *h, const u_char *p, u_int8_t dump_ pfring_print_parsed_pkt(bigbuf, sizeof(bigbuf), p, h); len = strlen(bigbuf); - if(len > 0) bigbuf[len-1] = '\0'; + if(len > 0) bigbuf[len] = '\0'; snprintf(&dump_str[strlen(dump_str)], sizeof(dump_str)-strlen(dump_str), "%s", bigbuf); } else { diff --git a/userland/examples/pfcount_multichannel.c b/userland/examples/pfcount_multichannel.c index d57021942..639456513 100644 --- a/userland/examples/pfcount_multichannel.c +++ b/userland/examples/pfcount_multichannel.c @@ -239,7 +239,7 @@ void print_packet(const struct pfring_pkthdr *h, const u_char *p, long threadId) else buflen += snprintf(&bigbuf[buflen], BUFSIZE - buflen, "[eth_type=0x%04X]", eth_type); buflen += snprintf(&bigbuf[buflen], BUFSIZE - buflen, "[caplen=%d][len=%d]" - "[eth_offset=%d][l3_offset=%d][l4_offset=%d][payload_offset=%d]\n", + "[eth_offset=%d][l3_offset=%d][l4_offset=%d][payload_offset=%d]", h->caplen, h->len, h->extended_hdr.parsed_pkt.offset.eth_offset, h->extended_hdr.parsed_pkt.offset.l3_offset, @@ -247,6 +247,7 @@ void print_packet(const struct pfring_pkthdr *h, const u_char *p, long threadId) h->extended_hdr.parsed_pkt.offset.payload_offset); } fputs(bigbuf, stdout); + fputs("\n", stdout); } /* ****************************************************** */ diff --git a/userland/examples/pfflow_offload.c b/userland/examples/pfflow_offload.c index a4e881c88..3f810b48a 100644 --- a/userland/examples/pfflow_offload.c +++ b/userland/examples/pfflow_offload.c @@ -100,24 +100,28 @@ void processPacket(const struct pfring_pkthdr *h, if (!quiet) { + buffer[0] = '\0'; + pfring_print_pkt(buffer, sizeof(buffer), p, h->len, h->len); + + printf("%s ", buffer); + if (h->extended_hdr.flags & PKT_FLAGS_FLOW_HIT) { - printf("Packet - flow hit\n"); + printf("[HIT]"); } else if (h->extended_hdr.flags & PKT_FLAGS_FLOW_MISS) { - printf("Packet - flow miss\n"); + printf("[MISS]"); } else if (h->extended_hdr.flags & PKT_FLAGS_FLOW_UNHANDLED) { - printf("Packet - flow unhandled\n"); + printf("[UNHANDLED]"); + } else { + printf("[-]"); } - buffer[0] = '\0'; - pfring_print_pkt(buffer, sizeof(buffer), p, h->len, h->len); + printf("\n"); } #if 0 /* TODO Discard all future packets for this flow */ - hw_filtering_rule r; + hw_filtering_rule r = { 0 }; r.rule_family_type = generic_flow_id_rule; - r.rule_family.flow_id_rule.action = flow_drop_rule; - r.rule_family.flow_id_rule.thread = 0; r.rule_family.flow_id_rule.flow_id = flow_id; pfring_add_hw_rule(pd, &r); #endif diff --git a/userland/lib/pfring_utils.c b/userland/lib/pfring_utils.c index ec239cf93..8c89d3a18 100644 --- a/userland/lib/pfring_utils.c +++ b/userland/lib/pfring_utils.c @@ -702,7 +702,7 @@ int pfring_print_parsed_pkt(char *buff, u_int buff_len, const u_char *p, const s } buff_used += snprintf(&buff[buff_used], buff_len - buff_used, - " [caplen=%d][len=%d][eth_offset=%d][l3_offset=%d][l4_offset=%d][payload_offset=%d]\n", + " [caplen=%d][len=%d][eth_offset=%d][l3_offset=%d][l4_offset=%d][payload_offset=%d]", h->caplen, h->len, h->extended_hdr.parsed_pkt.offset.eth_offset, h->extended_hdr.parsed_pkt.offset.l3_offset,