X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/19a7707e79c1b3191ada3725f69cfd6c640cfb5c..ed2df84be4d4b16bd595bacc23c6df208ff84401:/print-ether.c diff --git a/print-ether.c b/print-ether.c index eed66ace..4dd253ac 100644 --- a/print-ether.c +++ b/print-ether.c @@ -57,6 +57,7 @@ const struct tok ethertype_values[] = { { ETHERTYPE_8021Q9100, "802.1Q-9100" }, { ETHERTYPE_8021QinQ, "802.1Q-QinQ" }, { ETHERTYPE_8021Q9200, "802.1Q-9200" }, + { ETHERTYPE_MACSEC, "802.1AE MACsec" }, { ETHERTYPE_VMAN, "VMAN" }, { ETHERTYPE_PUP, "PUP" }, { ETHERTYPE_ARP, "ARP"}, @@ -133,7 +134,7 @@ ether_type_print(netdissect_options *ndo, uint16_t type) * printing Ethernet header information (such as a LANE ID for ATM LANE). */ static u_int -ether_print_common(netdissect_options *ndo, const u_char *p, u_int length, +ether_common_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen, void (*print_switch_tag)(netdissect_options *ndo, const u_char *), u_int switch_tag_len, @@ -203,6 +204,22 @@ recurse: p += 2; hdrlen += 2; + if (length_type == ETHERTYPE_MACSEC) { + /* + * MACsec, aka IEEE 802.1AE-2006 + * Print the header, and try to print the payload if it's not encrypted + */ + int ret = macsec_print(ndo, &p, &length, &caplen, &hdrlen, &length_type); + + if (ret == 0) { + /* Payload is encrypted; just quit. */ + return (hdrlen + caplen); + } else if (ret > 0) { + /* Problem printing the header; just quit. */ + return (ret); + } + } + /* * Process VLAN tag types. */ @@ -380,7 +397,7 @@ ether_switch_tag_print(netdissect_options *ndo, const u_char *p, u_int length, void (*print_switch_tag)(netdissect_options *, const u_char *), u_int switch_tag_len) { - return (ether_print_common(ndo, p, length, caplen, print_switch_tag, + return (ether_common_print(ndo, p, length, caplen, print_switch_tag, switch_tag_len, NULL, NULL)); } @@ -399,8 +416,8 @@ ether_print(netdissect_options *ndo, const u_char *encap_header_arg) { ndo->ndo_protocol = "ether"; - return (ether_print_common(ndo, p, length, caplen, NULL, 0, - print_encap_header, encap_header_arg)); + return (ether_common_print(ndo, p, length, caplen, NULL, 0, + print_encap_header, encap_header_arg)); } /*