summaryrefslogtreecommitdiff
path: root/print-nsh.c
Commit message (Collapse)AuthorAgeFilesLines
* NSH: Update an error messageFrancois-Xavier Le Bail2023-05-151-1/+1
| | | | | This change will avoid having the keyword "invalid" twice as: (invalid length for the MD type) (invalid)
* Put "}" at beginning of line with "else" to keep a consistent styleFrancois-Xavier Le Bail2023-04-211-2/+1
| | | | [skip ci]
* NSH: Modernize packet parsing style.Denis Ovsienko2020-12-201-64/+143
| | | | | | | | | | | | | | | | | Enable ND_LONGJMP_FROM_TCHECK. Remove a redundant ND_TCHECK_LEN() instance and make another one conditional. Report invalid packets as invalid with a reason, not truncated. Update the code from draft-ietf-sfc-nsh-01 to RFC 8300: remove the no longer existent C-bit, add the TTL field, adjust the MD Type field offset and size, apply correct mask to TLV length, redo TLV length in bytes instead of 4-byte words and mind the padding. Fetch and print one header at a time. Add and use two lookup tables for MD Type and Next Protocol. Add a version number check. Add a length check for MD Type 1. Update some error messages. Add a few encoding diagrams for clarity. Lose a few variables and reduce scope of the remaining variables. Update a few tests.
* Rework "Update more link-layer dissectors to void functions"Francois-Xavier Le Bail2020-08-061-1/+1
| | | | | | | | | | 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.
* Update more link-layer dissectors to void functionsFrancois-Xavier Le Bail2020-07-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | 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.
* Fix some narrowing warnings on LP64/LLP64 platforms.Guy Harris2019-04-181-1/+1
| | | | | | | | | | | | Add a ND_BYTES_AVAILABLE_AFTER() macro to find the number of bytes available in the captured data, starting at the byte pointed to by the argument. It returns a u_int rather than a ptrdiff_t, so it'll be 32 bits on LP64 and LLP64 platforms as well as on ILP32 platforms. Use that macro. Make size-of-buffer arguments size_t. Cast some size_t and ptrdiff_t values to u_int or int.
* Use the new GET_ macros instead of the EXTRACT_ onesFrancois-Xavier Le Bail2019-03-261-12/+12
| | | | | | | 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.
* Print truncations with nd_print_trunc() instead of tstr[] stringsFrancois-Xavier Le Bail2018-05-041-2/+1
| | | | | | | | Remove the tstr[] strings. Update the output of some tests accordingly. Moreover: Add or update some ndo_protocol fields.
* Add the ndo_protocol field in the netdissect_options structureFrancois-Xavier Le Bail2018-03-161-0/+1
| | | | | Update this field in printer entry functions. It will be used for some printings.
* 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
|
* Clean up signed vs. unsigned warnings.Guy Harris2018-01-141-1/+1
| | | | | | | | | | If length is a uint8_t, subtracting 2 (a value of type int) from it yields a value of type int, so compariing it against a u_int index causes a signed vs. unsigned warning. Make it a u_int instead (before we subtract 2 from it, we've already checked to make sure it's >= 2, so we know the result will never be negative).
* Clean up signed vs. unsigned.Guy Harris2018-01-111-6/+6
|
* Update ND_PRINT() as a variadic macroFrancois-Xavier Le Bail2018-01-071-17/+17
|
* Replace ND_TTEST2()/ND_TCHECK2() macros by macros using pointers (1/n)Francois-Xavier Le Bail2017-12-111-2/+2
| | | | | ND_TTEST2(var, l) -> ND_TTEST_LEN(p, l) ND_TCHECK2(var, l) -> ND_TCHECK_LEN(p, l)
* More EXTRACT_U_1() replacing direct dereferences.Guy Harris2017-12-081-8/+8
|
* 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-5342/pass correct caplen value to ether_print()Denis Ovsienko2017-01-181-1/+1
| | | | | | | | | | | | | | | 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.
* Add a summary comment in all other printersFrancois-Xavier Le Bail2016-08-151-4/+4
| | | | | | | Moreover: Remove some redundant comments Update some summary comments Update the specification URL for ATA over Ethernet (AoE) protocol
* Squelch a signed vs. unsigned comparison warning.Guy Harris2016-08-021-1/+1
| | | | | | Multiplying a uint8_t by an int results in an int, not an unsigned int; make NSH_HDR_WORD_SIZE an unsigned constant so the multiplication is uint8_t times unsigned int.
* Make sure the length of the header is valid.Guy Harris2016-03-251-1/+12
| | | | | It must be at least 2, as it includes the lengths of the Base and Service Path headers, and those are always present.
* Add printing function for Generic Protocol Extension for VXLANbugyo2016-03-221-0/+174
and Network Service Header. This code stands for following internet drafts: - VXLAN GPE: draft-ietf-nvo3-vxlan-gpe-01 - NSH: draft-ietf-sfc-nsh-01