Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --overview and --no-print options to tcpdump #1033

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ DayOfTheWeek, Month DD, YYYY / The Tcpdump Group
Add --print-sampling to print every Nth packet instead of all.
Print the supported time stamp types (-J) to stdout instead of stderr.
Print the list of data link types (-L) to stdout instead of stderr.
Add --overview to print an overview of the contents of the capture
Add --no-print to suppress printing of individual packets (useful with --overview)
Source code:
Use %zu when printing a sizeof to squelch compiler warnings
Remove unused missing/snprintf.c.
Expand Down
7 changes: 7 additions & 0 deletions ethertype.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,11 @@
#define ETHERTYPE_ARISTA 0xd28b /* Arista Networks vendor specific EtherType */
#endif

/*
* Length of an Ethernet header; note that some compilers may pad
* "struct ether_header" to a multiple of 4 bytes, for example, so
* "sizeof (struct ether_header)" may not give the right answer.
*/
#define ETHER_HDRLEN 14

extern const struct tok ethertype_values[];
3 changes: 3 additions & 0 deletions netdissect.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ struct netdissect_options {
const u_char *ndo_packetp;
const u_char *ndo_snapend;

int ndo_dlt; /* datalink type */
int ndo_length_type; /* */

/* stack of saved packet boundary and buffer information */
struct netdissect_saved_packet_info *ndo_packet_info_stack;

Expand Down
11 changes: 4 additions & 7 deletions print-ether.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@ struct ether_header {
nd_uint16_t ether_length_type;
};

/*
* Length of an Ethernet header; note that some compilers may pad
* "struct ether_header" to a multiple of 4 bytes, for example, so
* "sizeof (struct ether_header)" may not give the right answer.
*/
#define ETHER_HDRLEN 14

const struct tok ethertype_values[] = {
{ ETHERTYPE_IP, "IPv4" },
{ ETHERTYPE_MPLS, "MPLS unicast" },
Expand Down Expand Up @@ -200,6 +193,7 @@ ether_common_print(netdissect_options *ndo, const u_char *p, u_int length,
*/
recurse:
length_type = GET_BE_U_2(p);
ndo->ndo_length_type = length_type;

length -= 2;
caplen -= 2;
Expand Down Expand Up @@ -237,6 +231,7 @@ ether_common_print(netdissect_options *ndo, const u_char *p, u_int length,
* Keep processing type/length fields.
*/
length_type = GET_BE_U_2(p);
ndo->ndo_length_type = length_type;

ND_ICHECK_U(caplen, <, 2);
length -= 2;
Expand Down Expand Up @@ -281,6 +276,8 @@ ether_common_print(netdissect_options *ndo, const u_char *p, u_int length,
}

length_type = GET_BE_U_2(p + 2);
ndo->ndo_length_type = length_type;

p += 4;
length -= 4;
caplen -= 4;
Expand Down
Loading