summaryrefslogtreecommitdiff
path: root/print-rip.c
Commit message (Collapse)AuthorAgeFilesLines
* More bounds checking when fetching addresses and converting to strings.Guy Harris2020-01-191-4/+4
| | | | | | | | | | | | | | 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.
* 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-20/+22
| | | | | | | 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.
* RIP: Update two error messagesFrancois-Xavier Le Bail2019-03-201-2/+2
| | | | Update the output of a test accordingly.
* RIP: Fix two loops for undefined behavior at runtimeFrancois-Xavier Le Bail2019-03-091-3/+9
| | | | | | | | | | | | | | | 1) RIPv2 The error was: print-rip.c:386:9: runtime error: unsigned integer overflow: 16 - 20 cannot be represented in type 'unsigned int' Without this change the unsigned integer variable 'len' is assigned a very high value, because of underflow, and the loop continue incorrectly. Add a test case. 2) RIPv1 Same bugfix, based on a code inspection, so comes without a test case.
* RIP: Fix inaccurate variable namesFrancois-Xavier Le Bail2019-03-081-17/+17
|
* Clean up whitespaces/indentationFrancois-Xavier Le Bail2019-03-081-18/+18
|
* RIP: Add some bounds checksFrancois-Xavier Le Bail2018-06-201-0/+11
|
* Print truncations with nd_print_trunc() instead of tstr[] stringsFrancois-Xavier Le Bail2018-05-041-5/+4
| | | | | | | | Remove the tstr[] strings. Update the output of some tests accordingly. Moreover: Add or update some ndo_protocol fields.
* Rename the fn_printX() functions to nd_printX()Francois-Xavier Le Bail2018-04-301-1/+1
| | | | | | | The functions are: nd_print, nd_printztn, nd_printn and nd_printzp. Trying to make it clearer that they currently have to be used only on part of the packet buffer. Update some comments.
* 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.
* Remove unneeded '&' when getting a pointer to a nd_ipv4 typeFrancois-Xavier Le Bail2018-01-311-6/+6
|
* 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
|
* Change the way we dissect non-routing-entry entries.Guy Harris2018-01-151-92/+219
| | | | | | | | This should fix Coverity CID 1427593. It also uses fn_printzp() to print plain text passwords, rather than rolling its own code, and doesn't try to print anything from versions other than 1 and 2 other than the version number.
* Update ND_PRINT() as a variadic macroFrancois-Xavier Le Bail2018-01-071-31/+31
|
* Use nd_ types, add EXTRACT_ calls.Guy Harris2017-12-301-32/+37
|
* Remove all storage class specifier 'register'Francois-Xavier Le Bail2017-12-131-8/+8
| | | | | | Let the compiler do the optimizations (or not) based on build options. Avoid 'value has been optimized out' messages in gdb using '-O0'.
* Use more the EXTRACT_U_1() macro (54/n)Francois-Xavier Le Bail2017-12-101-2/+2
|
* Use more the EXTRACT_U_1() macro (38/n)Francois-Xavier Le Bail2017-12-011-1/+1
| | | | In some ND_ISPRINT() macro calls.
* Use more the EXTRACT_U_1() macro (31/n)Francois-Xavier Le Bail2017-11-271-1/+2
| | | | | | In ND_PRINT() macro call(s) (step 9). *(p)
* Rename EXTRACT_ macrosFrancois-Xavier Le Bail2017-11-221-17/+17
| | | | | | | | | | | | | | | | 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-17/+17
| | | | | It indicates clearly that these macros are used to extract big-endian integral values.
* Move the printer summaries from INSTALL.txt to each printerFrancois-Xavier Le Bail2016-08-141-0/+2
| | | | | | | | with the tag '\summary:' for greping. Remark: Currently some printers have no summary line. Moreover: Summarize all printers with a single line in INSTALL.txt
* Rename 'tcpdump-stdinc.h' to 'netdissect-stdinc.h'Francois-Xavier Le Bail2015-09-101-1/+1
| | | | Get the full log via: git log --follow netdissect-stdinc.h
* Remove obsolete commentsFrancois-Xavier Le Bail2015-09-071-1/+1
|
* Printers must include 'netdissect.h', not 'interface.h'Francois-Xavier Le Bail2015-09-051-1/+1
|
* Fix a bunch of de-constifications.Guy Harris2015-04-261-14/+14
|
* dismiss NETDISSECT_REWORKED macroDenis Ovsienko2015-03-221-1/+0
| | | | | | | The purpose of this macro was to enable the file-by-file switch to NDO, after which only tcpdump.c had a use of it and the definitions guarded by it. Update tcpdump.c not to require them any more and dismiss the unused definitions.
* u_intN_t is dead, long live uintN_t.Guy Harris2014-04-231-21/+21
| | | | | | | | | And, as we require at least autoconf 2.61, and as autoconf 2.61 and later have AC_TYPE_UINTn_T and AC_TYPE_INTn_T macros, we use them to define the uintN_t and intN_t macros if the system doesn't define them for us. This lets us get rid of bitypes.h as well.
* Netdissectify the to-name resolution routines.Guy Harris2014-04-041-4/+4
| | | | | | | | Have them take a netdissect_options * argument, and get the "no name resolution" flag from it. Move the declaration of dnaddr_string to addrtoname.h, along with the other XXX-to-string routines.
* improve previous NDO conversionsDenis Ovsienko2014-04-031-1/+1
|
* NDOize 7 bigger decodersDenis Ovsienko2014-03-191-51/+54
| | | | | This change converts IGMP, IPv6 mobility options, LDP, Lightweight Access Point, PGM, PPTP and RIP decoders.
* Do our own isascii(), isprint(), isgraph(), and toascii().Guy Harris2014-02-021-1/+1
| | | | | | | | | We do *not* want the behavior of isprint() and isgraph() to be locale-dependent - we want both of them to return "true" only for ASCII characters. We have to do our own isascii() and toascii() on non-UN*X systems anyway, so let's just do all of them ourselves.
* remove tcpdump's own CVS keywordsDenis Ovsienko2014-01-031-5/+0
| | | | | | Remove lots of $Header's and a few $Id's that all belong to the former CVS repository of tcpdump itself. These keywords have been frozen since the migration to git in late 2008.
* ndo-ize print-ascii: hex_print_with_offset()Michael Richardson2014-01-011-8/+8
|
* whitespace changesMichael Richardson2014-01-011-1/+1
|
* make consistent use of the "tstr" idiomDenis Ovsienko2013-12-261-3/+5
| | | | | | | | For each decoder that has more than one instance of truncation signaling and prints the same string in each instance make sure that the string is declared as "static const char tstr[]" right after the initial includes block. Where necessary, replace fputs(s, stdout) with equivalent printf("%s", s).
* Use byte offset instead of rip_dest (a 32-bit field) to extractXin Li2013-05-311-1/+1
| | | | | 16-bit field in order to avoid type punning. This fixes compile on IA64 platforms.
* decode RIPv2 authentication up to RFC4822Denis Ovsienko2012-06-121-21/+30
| | | | | | | | | | | | | | | | | | | | | | | This change addresses a few issues in rip_entry_print_v2() and rip_print(): 1. In the case of Simple Password (RFC2453) authentication the last (16th) character of a password was never printed. Other password characters were printed regardless of existing isprint() test. 2. In the case of Cryptographic (RFC4822) authentication there were no details available for fixed-size auth header and variable-size auth trailer. 3. Depending on particular hash function used, a normal authentication trailer "RTE" may be 20 or more bytes long. Iteration over packet RTEs should stop once a trailer is decoded. Exact number of RTEs in a message cannot be told from message size any more. Test cases are added for Request and Response messages with Simple Password, Keyed-MD5, HMAC-SHA-1, HMAC-SHA-256, HMAC-SHA-384 and HMAC-SHA-512 authentication modes. Earlier test case is updated to match new "number of routes" output format.
* fix RIP Request/full table decoding issuesDenis Ovsienko2012-06-121-5/+11
| | | | | | | | | | RIP Request and Response messages have the same structure. Update a switch block in rip_print() to proceed with decoding of both. A Request message may contain an AFI 0 RTE standing for a full table request, normally sent on a router start. Update rip_entry_print_v1() and rip_entry_print_v2() to treat IPv4 and AFI 0 as two valid, distinguishable cases.
* move the BSD AF defs into af.h and make the null and rip printer make use of ithannes2006-03-231-8/+8
|
* move AF specific stuff to dedicated fileshannes2006-02-211-4/+7
|
* Have the configure script arrange that the Makefile define _U_guy2003-11-161-4/+4
| | | | | | | | | | appropriately, and that GNUmakefile and the MSVC++ project file define it apppriately, as we do with libpcap, rather than defining it in "interface.h". Undo the rcsid-shuffling and addition of extra #includes, as we no longer need to arrange that "interface.h" be included before using _U_ in an RCS ID or copyright.
* From Neil Spring:guy2003-11-151-4/+4
| | | | | | | | | | | use "_U_" in the definitions of "rcsid[]", to eliminate complaints about those variables being unused; move the definitions after the include of "interface.h", or add an include of "interface.h", so that "_U_" is defined. Include "config.h" before including "tcpdump-stdinc.h" in "missing/datalinks.c".
* removed print_unknown_data() lookalikeshannes2002-12-221-86/+99
| | | | changed to multiline output
* The "__attribute__((packed))" tag on structures causes some files not toguy2002-12-111-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | compile with Sun C, as "interface.h" isn't being included before the structures are being declared. Furthermore, in the files that Sun C *can* compile, it doesn't cause Sun C to generate code that's safe with unaligned accesses, as "__attribute__" is defined as a do-nothing macro with compilers that don't support it. Therefore, we get rid of that tag on the structures to which it was added, and instead use "EXTRACT_16BIT()" and "EXTRACT_32BIT()" to fetch 16-bit and 32-bit big-endian quantities from packets. We also fix some other references to multi-byte quantities to get rid of code that tries to do unaligned loads on platforms that don't support them. We also throw in a hack that makes those macros use "__attribute__((packed))" on structures containing only one 16-bit or 32-bit integer to get the compiler to generate unaligned-safe code rather than doing it by hand. (GCC on SPARC produces the same code that doing it by hand does; I don't know if GCC on any other big-endian strict-alignment processor generates better code for that case. On little-endian processors, as "ntohs()" and "ntohl()" might be functions, that might actually produce worse code.) Fix some places to use "%u" rather than "%d" to print unsigned quantities.
* put __attribute__((packed)) to packet headers. s/u_short/u_int16_t/ and soitojun2002-11-091-8/+8
| | | | forth while i'm here
* Get rid of the "-Wno-unused" flag, and fix up most of theguy2002-09-051-5/+5
| | | | | | | | | | | | | | | unused-parameter problems reported by GCC. Add an _U_ tag to label parameters as unused if the function is called through a pointer (so that you can't change its signature by removing parameters) or if there are unused parameters only because the function isn't complete. Add some additional bounds checks the necessity for which was revealed while cleaning up unused-parameter problems. Make some routines static. "lcp_print()", defined in "print-lcp.c", isn't called anywhere - "print-ppp.c" has the code to dissect LCP. Get rid of "print-lcp.c".
* Add a few more GCC warnings on GCC >= 2 for ".devel" builds.guy2002-09-051-6/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From Neil T. Spring: fixes for many of those warnings: addrtoname.c, configure.in: Linux needs netinet/ether.h for ether_ntohost print-*.c: change char *foo = "bar" to const char *foo = "bar" to appease -Wwrite-strings; should affect no run-time behavior. print-*.c: make some variables unsigned. print-bgp.c: plen ('prefix len') is unsigned, no reason to validate by comparing to zero. print-cnfp.c, print-rx.c: use intoa, provided by addrtoname, instead of inet_ntoa. print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to be false, so check for (u_int)-1, which represents failure, explicitly. print-isakmp.c: complete initialization of attrmap objects. print-lwres.c: "if(x); print foo;" seemed much more likely to be intended to be "if(x) { print foo; }". print-smb.c: complete initialization of some structures. In addition, add some fixes for the signed vs. unsigned comparison warnings: extract.h: cast the result of the byte-extraction-and-combining, as, at least for the 16-bit version, C's integral promotions will turn "u_int16_t" into "int" if there are other "int"s nearby. print-*.c: make some more variables unsigned, or add casts to an unsigned type of signed values known not to be negative, or add casts to "int" of unsigned values known to fit in an "int", and make other changes needed to handle the aforementioned variables now being unsigned. print-isakmp.c: clean up the handling of error/status indicators in notify messages. print-ppp.c: get rid of a check that an unsigned quantity is >= 0. print-radius.c: clean up some of the bounds checking. print-smb.c: extract the word count into a "u_int" to avoid the aforementioned problems with C's integral promotions. print-snmp.c: change a check that an unsigned variable is >= 0 to a check that it's != 0. Also, fix some formats to use "%u" rather than "%d" for unsigned quantities.