summaryrefslogtreecommitdiff
path: root/print-ether.c
Commit message (Collapse)AuthorAgeFilesLines
* Rework "Update more link-layer dissectors to void functions"Francois-Xavier Le Bail2020-08-061-44/+27
| | | | | | | | | | It's a follow-up to commit 81dbf4a0b05092760d0ff0cdd48c692e4769ba99. There is no need to update ether_print(), ether_common_print() and ether_switch_tag_print() to void functions: back to u_int functions. There is also no need to add a flag parameter to ether_print(), ether_common_print() and ether_switch_tag_print(): Remove it.
* Support for EAP Dump in RADIUS MessagesAravind Prasad S2020-07-221-1/+1
| | | | (pull request #864)
* Update more link-layer dissectors to void functionsFrancois-Xavier Le Bail2020-07-151-30/+54
| | | | | | | | | | | | | | | | | | | | | | brcm_tag_if_print() brcm_tag_prepend_if_print() dsa_if_print() edsa_if_print() ether_if_print() netanalyzer_if_print() netanalyzer_transparent_if_print() Update ether_print(), ether_common_print() and ether_switch_tag_print() to void functions. Add a flag parameter to ether_print(), ether_common_print() and ether_switch_tag_print() to increment the link-layer header length field of the netdissect_options when needed. The calls use TRUE when the return value of the funtions was used. The calls with FALSE avoid increments when the calls are nested. Moreover: Remove trailing "_if" from some protocol names.
* macsec, ether: clean up printing of encrypted and changed packets.Guy Harris2020-05-281-5/+2
| | | | | | | If the packet is encrypted or changed, so that we just print the payload as raw data, and we're not running with -e, print the MAC addresses (if any) and an indication that it's an 802.11AE packet, followed by the MACsec header.
* ether: for MACsec packets, print the MACsec ethertype if E or C set.Guy Harris2020-05-281-0/+4
| | | | | | If -e isn't specified, and a MACsec packet is encrypted or changed, so that we don't print the payload, at least report that it's a MACsec packet.
* ether: clean up MACsec processing.Guy Harris2020-05-281-4/+20
| | | | | | | | | | | | | Print the length early if we're printing the link-layer header. If the payload is encrypted or otherwise modified, print it out as raw data. If the payload is not encrypted or otherwise modified, and we didn't have a problem printing the header, fetch the type/length field following the MACsec header, skip past it, and continue, rather than looping back - there shouldn't be multiple MACsec headers, as far as I know. (If that's not the case, go back to looping.)
* macsec: more cleanups.Guy Harris2020-05-271-1/+6
| | | | | | Get rid of code that knows about Ethernet; this is 802.1AE, not 802.3AE. Get rid o some unused variables.
* Remove unused label.Guy Harris2020-05-271-1/+0
|
* Properly handle the return value of macsec_print().Guy Harris2020-05-271-4/+7
|
* Merge branch 'master' into macsecGuy Harris2020-05-271-147/+297
|\
| * Ethernet: Rename a printerFrancois-Xavier Le Bail2020-04-291-4/+4
| | | | | | | | | | | | | | | | Rename ether_print_common() to ether_common_print(), with _print suffix like in most similar cases. Moreover: Fix indent.
| * Ethernet: Rename a printerFrancois-Xavier Le Bail2020-03-081-1/+1
| | | | | | | | | | Rename ether_print_switch_tag() to ether_switch_tag_print(), with _print suffix like in most similar cases.
| * Dispatch the PTP ethertype to ptp_print()Jeff Chan2020-02-291-0/+5
| | | | | | | | | | | | This implements "IEEE 802.3/Ethernet" mode as described in annex F of the PTP standard. This uses the same format packets, but directly over Ethernet instead of encapsulated in UDP.
| * More bounds checking when fetching addresses and converting to strings.Guy Harris2020-01-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace more calls to ipaddr_string()/ip6addr_string() with calls to GET_IPADDR_STRING()/GET_IP6ADDR_STRING() macros performing bounds checking. Add similar bounds-checking inline functions and macros to wrap linkaddr_string(), etheraddr_string(), and isonsap_string() and convert calls to them to use the macros as well. Shuffle the inline functions in addrtoname.h around a bit, so that the inline functions, external declarations, and macros are all in the same order.
| * Use more HTTPS in URLsFrancois-Xavier Le Bail2019-08-191-1/+1
| | | | | | | | [skip ci]
| * Arista: Rename a printerFrancois-Xavier Le Bail2019-05-231-1/+1
| | | | | | | | | | | | | | | | Rename arista_print_ethertype() to arista_ethertype_print(), with _print suffix like in most similar cases. Moreover: Add a 'summary' comment with the protocol name.
| * Ethernet: Fix indentationFrancois-Xavier Le Bail2019-05-231-27/+27
| |
| * New ethertype protocol for Arista Networksniks30892019-05-231-0/+30
| |
| * Fix typo that increases, instead of decreases, caplenBill Fenner2019-04-301-1/+1
| | | | | | | | The refactoring in b258556b introduced this minor error.
| * Handle switch tags more cleanly.Guy Harris2019-04-231-110/+159
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Have the switch tag dissectors handle *only* the switch tag, not anything else in the Ethernet header. Have a routine ether_print_switch_tag() that takes a pointer to a routine to dissect the switch tag, and a switch tag length, as an argument, and have a common Ethernet dissection routine called by ether_print_switch_tag() and by ether_print(), passing a null pointer for the switch tag dissector and 0 for the switch tag length. Dissect the switch tag after the MAC addresses, if there's a non-null switch tag routine dissector pointer. Clean up the processing logic in the common Ethernet dissection code - have a loop to process VLAN tags, if any, and, when it's done, handle frames with a length field, frames with a regular type field, and Alteon jumbo frames.
| * Print the Ethertype the same way for Ethertypes in VLAN tags as for others.Guy Harris2019-04-231-2/+9
| |
| * Treat the length field in an Ethernet header as such.Guy Harris2019-04-221-15/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If we have an Ethernet packet where the last 2 octets of the header are a length rather than an Ethernet type, and it's less than the remaining length of the packet, shorten the length and captured length, update the snapshot end. Turn the buffer stack into a "packet information" stack, so that, if we *do* update the snapshot end, we push the old end onto the stack, and pop it off as soon as we're done dissecting the Ethernet packet, in case there's more data in the packet after the Ethernet packet. Use the stack when we use the IPv4 and IPv6 length fields as well.
| * Remove MEDSA ethertype printerVivien Didelot2019-04-161-5/+0
| | | | | | | | | | | | | | | | | | | | MEDSA (which unofficially stands for Marvell EDSA) relies on the unregistered 0xDADA ethertype value that was randomly choosen and currently used by the kernel. But with EDSA this value is programmable, hence can be changed anytime. Now that a reliable DLT parser is implemented for both DSA and EDSA tagged master interfaces, let's get rid for the MEDSA ethertype parser.
| * Ethernet: Rename a printerFrancois-Xavier Le Bail2019-04-031-2/+2
| | | | | | | | | | Rename ether_print_hdr_len() to ether_hdr_len_print(), with _print suffix like in most similar cases.
| * Clean up whitespaces/indentationFrancois-Xavier Le Bail2019-04-031-50/+50
| |
| * Use the new GET_ macros instead of the EXTRACT_ onesFrancois-Xavier Le Bail2019-03-261-6/+4
| | | | | | | | | | | | | | The exceptions are currently: Some EXTRACT_ in print-juniper.c, not used on packet buffer pointer. An EXTRACT_BE_U_3 in addrtoname.c, not always used on packet buffer pointer.
| * Ethernet: Allow specifying non-standard Ethernet header lengthFlorian Fainelli2019-01-251-16/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A fair number of proprietary Ethernet switch tagging protocols, such as Broadcom tags for instance, will place their tag between the MAC SA and the Type/Length field. Move the body of ether_print() into ether_print_hdr_len() and specify the Ethernet header length as an argument to that function. ether_print() calls ether_print_hdr_len() with a standard Ethernet header lenght of 14 bytes, while other callers could specify an arbitrary length. We still assume that the first Length/Type field to parse is located 2 bytes before the end of that Ethernet header length. This will be used in a subsequent commit to parse Broadcom tags.
| * Revert "Ethernet: Remove two useless tests"Francois-Xavier Le Bail2018-11-191-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | This reverts commit b7fff7058282c332ba1d8d236c9864ab21b16adf (partially) The sanity check in print.c/pretty_print_packet() function, packet length (length) >= capture length (caplen), apply when the ether_print() function is called by ether_if_print(), netanalyzer_if_print() or netanalyzer_transparent_if_print(). But the ether_print() function is called in some other cases, thus not sure length always >= caplen.
| * Add more nd_print_trunc() callsFrancois-Xavier Le Bail2018-09-131-2/+4
| |
| * Ethernet: Remove two useless testsFrancois-Xavier Le Bail2018-09-131-2/+2
| | | | | | | | | | | | Because packet length (len) >= capture length (caplen). (see the sanity checks in print.c, pretty_print_packet() function)
| * Ethernet: Remove two useless testsFrancois-Xavier Le Bail2018-09-121-9/+2
| | | | | | | | | | | | | | | | | | | | | | | | Because packet length (length) >= capture length (caplen), when caplen >= ETHER_HDRLEN, length >= caplen cannot be < ETHER_HDRLEN. Same for the other test (length < 4). (see the sanity checks in print.c, pretty_print_packet() function) Moreover: Clean up indentation.
| * Add more nd_print_trunc() callsFrancois-Xavier Le Bail2018-06-061-4/+4
| | | | | | | | Update the output of some tests accordingly.
| * Remove useless commentsFrancois-Xavier Le Bail2018-03-191-9/+0
| |
| * Add the ndo_protocol field in the netdissect_options structureFrancois-Xavier Le Bail2018-03-161-0/+4
| | | | | | | | | | Update this field in printer entry functions. It will be used for some printings.
| * Ethernet: Rename a variableFrancois-Xavier Le Bail2018-03-011-11/+11
| | | | | | | | | | From 'ep', often used as 'pointer to the end of current packet' to 'ehp' as Ethernet header pointer.
| * Remove function specifier 'inline' in printersFrancois-Xavier Le Bail2018-01-261-1/+1
| | | | | | | | | | | | | | | | It was mostly used with large functions. Moreover: Put some function definition names at the beginning of line. Fix a space.
| * Always include <config.h> rather than "config.h".Guy Harris2018-01-211-1/+1
| | | | | | | | | | | | | | | | This can prevent bizarre failures if, for example, you've done a configuration in the top-level source directory, leaving behind one config.h file, and then do an out-of-tree build in another directory, with different configuration options. This way, we always pick up the same config.h, in the build directory.
| * Use quoted include netdissect-stdinc.h instead of angle-bracketed oneFrancois-Xavier Le Bail2018-01-211-1/+1
| |
| * Update ND_PRINT() as a variadic macroFrancois-Xavier Le Bail2018-01-071-20/+20
| |
| * Directly refer to ether_shost and ether_dhost; get rid of ESRC() and EDST().Guy Harris2017-12-161-4/+4
| | | | | | | | They don't really add anything.
| * Remove all storage class specifier 'register'Francois-Xavier Le Bail2017-12-131-1/+1
| | | | | | | | | | | | Let the compiler do the optimizations (or not) based on build options. Avoid 'value has been optimized out' messages in gdb using '-O0'.
| * Use nd_ types in 802.x and FDDI headers.Guy Harris2017-12-121-7/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use EXTRACT_U_1() as required by those changes. Remove no-longer-necessary & operators from other EXTRACT_ calls. While we're at it, add MAC_ADDR_LEN to netdissect.h, and use it instead of ETHER_ADDR_LEN; eliminate ETHER_ADDR_LEN. Move the maximum Ethernet length field value to ethertype.h, under the name MAX_ETHERNET_LENGTH_VAL. Move the Ethernet header structure, and the #define for the Ethernet header length, to print-ether.c; in non-Ethernet dissectors that were using the Ethernet header structure, just declare two nd_mac_addr variables for the source and destination MAC addresses and use them instead of the Ethernet header (we don't need the type field there). These changes leave nothing in ether.h, so eliminate it.
| * Rename EXTRACT_ macrosFrancois-Xavier Le Bail2017-11-221-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now all the macros have a name meaning a count in bytes. With _S_: signed, _U_: unsigned e.g.: EXTRACT_BE_32BITS -> EXTRACT_BE_U_4 EXTRACT_LE_32BITS -> EXTRACT_LE_U_4 ... EXTRACT_BE_INT32 -> EXTRACT_BE_S_4 and have: EXTRACT_8BITS -> EXTRACT_U_1 EXTRACT_INT8 -> EXTRACT_S_1
| * Rename EXTRACT_nBITS() macros to EXTRACT_BE_nBITS()Francois-Xavier Le Bail2017-11-181-4/+4
| | | | | | | | | | It indicates clearly that these macros are used to extract big-endian integral values.
| * CVE-2017-12897/ISO CLNS: Use ND_TTEST() for the bounds checks in ↵Guy Harris2017-09-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | isoclns_print(). This fixes a buffer over-read discovered by Kamil Frankowicz. Don't pass the remaining caplen - that's too hard to get right, and we were getting it wrong in at least one case; just use ND_TTEST(). Add a test using the capture file supplied by the reporter(s).
* | Add support for MACsec (IEEE 802.1AE-2006)Sabrina Dubroca2017-05-181-0/+14
|/
* add NSH ethertypeSteven H. Wang2017-04-021-0/+5
| | | | https://tools.ietf.org/html/draft-ietf-sfc-nsh-12#section-12.1
* CVE-2016-7985,7986/fixup medsa_print()tcpdump-4.9.0-bpDenis Ovsienko2017-01-181-1/+1
| | | | | | | | | The code in medsa_print() assumed that the MEDSA packet always follows an Ethernet header that is inside the allocated memory buffer. But this is not always the case, see commit 6bc4429 for rationale. Eliminate the Ethernet header pointer and just pass on the struct lladdr_info arguments provided.
* CVE-2017-5342/pass correct caplen value to ether_print()Denis Ovsienko2017-01-181-0/+2
| | | | | | | | | | | | | | | In that function the "length" parameter means off-the-wire length, that is, the length declared inside the outer header. The "caplen" parameter means the amount of bytes actually available in the captured packet. gre_print_0() and the functions modelled after it passed the value of "length" instead of the value of "caplen", this could make ether_print() access beyond the memory allocated for the captured packet. Brian Carpenter had demonstrated this for the OTV case. Fix the involved functions that call ether_print() to pass the correct value and leave a comment to dismiss "caplen" later as its value can be reliably derived from the other ether_print() parameters.
* CVE-2016-7926/Do some additional bounds checking before calling isoclns_print().Guy Harris2017-01-181-1/+5
| | | | Fixes a heap overflow found with American Fuzzy Lop by Hanno Böck.