X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/b12b2d669e76845b858c212eb89d9c6187c58c24..refs/pull/1034/head:/print-ipoib.c diff --git a/print-ipoib.c b/print-ipoib.c index d38be329..3d431235 100644 --- a/print-ipoib.c +++ b/print-ipoib.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, + * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, * 1997, 2000, 2011, 2012 * The Regents of the University of California. All rights reserved. * @@ -23,14 +23,13 @@ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. */ +/* \summary: IP-over-InfiniBand (IPoIB) printer */ + #ifdef HAVE_CONFIG_H -#include "config.h" +#include #endif -#include - -#include -#include +#include "netdissect-stdinc.h" #include "netdissect.h" #include "extract.h" @@ -45,19 +44,18 @@ static inline void ipoib_hdr_print(netdissect_options *ndo, const u_char *bp, u_int length) { uint16_t ether_type; - char abuf[40]; - ether_type = GET_BE_U_2(&bp[40]); + ether_type = GET_BE_U_2(bp + 40); if (!ndo->ndo_qflag) { - (void)printf(", ethertype %s (0x%04x)", + ND_PRINT(", ethertype %s (0x%04x)", tok2str(ethertype_values,"Unknown", ether_type), ether_type); } else { - (void)printf(", ethertype %s", + ND_PRINT(", ethertype %s", tok2str(ethertype_values,"Unknown", ether_type)); } - (void)printf(", length %u: ", length); + ND_PRINT(", length %u: ", length); } /* @@ -73,23 +71,31 @@ ipoib_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen const u_char *orig_hdr = p; u_int orig_length; u_short ether_type; - u_short extracted_ether_type; - if (caplen < IPOIB_HDRLEN || length < IPOIB_HDRLEN) { - printf("[|ipoib]"); + if (caplen < IPOIB_HDRLEN) { + nd_print_trunc(ndo); + ndo->ndo_ll_hdr_len += caplen; + return; + } + + if (length < IPOIB_HDRLEN) { + nd_print_trunc(ndo); + ndo->ndo_ll_hdr_len += length; return; } if (ndo->ndo_eflag) { + nd_print_protocol_caps(ndo); if (print_encap_header != NULL) (*print_encap_header)(encap_header_arg); ipoib_hdr_print(ndo, p, length); } orig_length = length; + ndo->ndo_ll_hdr_len += IPOIB_HDRLEN; length -= IPOIB_HDRLEN; caplen -= IPOIB_HDRLEN; - ether_type = GET_BE_U_2(&p[40]); + ether_type = GET_BE_U_2(p + 40); p += IPOIB_HDRLEN; if (ethertype_print(ndo, ether_type, p, length, caplen, NULL, NULL) == 0) { @@ -111,17 +117,9 @@ ipoib_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen * 'h->len' is the length of the packet off the wire, and 'h->caplen' * is the number of bytes actually captured. */ -u_int +void ipoib_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p) { + ndo->ndo_protocol = "ipoib"; ipoib_print(ndo, p, h->len, h->caplen, NULL, NULL); - - return (IPOIB_HDRLEN); } - -/* - * Local Variables: - * c-style: whitesmith - * c-basic-offset: 8 - * End: - */