]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-token.c
Avoid -E and -M options inconsistencies with no libcrypto
[tcpdump] / print-token.c
index 9d9e36ed7eed08e0151e8d0c6741d60efe8566bd..74355ffd9ab9955e01f62a2119378d4922f95c02 100644 (file)
@@ -26,9 +26,7 @@
 
 /* \summary: Token Ring printer */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #include "netdissect-stdinc.h"
 
 #define TOKEN_HDRLEN           14
 #define ROUTING_SEGMENT_MAX    16
 #define IS_SOURCE_ROUTED(trp)  ((trp)->token_shost[0] & 0x80)
-#define FRAME_TYPE(trp)                ((EXTRACT_U_1((trp)->token_fc) & 0xC0) >> 6)
+#define FRAME_TYPE(trp)                ((GET_U_1((trp)->token_fc) & 0xC0) >> 6)
 #define TOKEN_FC_LLC           1
 
-#define BROADCAST(trp)         ((EXTRACT_BE_U_2((trp)->token_rcf) & 0xE000) >> 13)
-#define RIF_LENGTH(trp)                ((EXTRACT_BE_U_2((trp)->token_rcf) & 0x1f00) >> 8)
-#define DIRECTION(trp)         ((EXTRACT_BE_U_2((trp)->token_rcf) & 0x0080) >> 7)
-#define LARGEST_FRAME(trp)     ((EXTRACT_BE_U_2((trp)->token_rcf) & 0x0070) >> 4)
-#define RING_NUMBER(trp, x)    ((EXTRACT_BE_U_2((trp)->token_rseg[x]) & 0xfff0) >> 4)
-#define BRIDGE_NUMBER(trp, x)  ((EXTRACT_BE_U_2((trp)->token_rseg[x]) & 0x000f))
+#define BROADCAST(trp)         ((GET_BE_U_2((trp)->token_rcf) & 0xE000) >> 13)
+#define RIF_LENGTH(trp)                ((GET_BE_U_2((trp)->token_rcf) & 0x1f00) >> 8)
+#define DIRECTION(trp)         ((GET_BE_U_2((trp)->token_rcf) & 0x0080) >> 7)
+#define LARGEST_FRAME(trp)     ((GET_BE_U_2((trp)->token_rcf) & 0x0070) >> 4)
+#define RING_NUMBER(trp, x)    ((GET_BE_U_2((trp)->token_rseg[x]) & 0xfff0) >> 4)
+#define BRIDGE_NUMBER(trp, x)  (GET_BE_U_2((trp)->token_rseg[x]) & 0x000f)
 #define SEGMENT_COUNT(trp)     ((int)((RIF_LENGTH(trp) - 2) / 2))
 
 struct token_header {
        nd_uint8_t   token_ac;
        nd_uint8_t   token_fc;
-       nd_mac_addr  token_dhost;
-       nd_mac_addr  token_shost;
+       nd_mac48  token_dhost;
+       nd_mac48  token_shost;
        nd_uint16_t  token_rcf;
        nd_uint16_t  token_rseg[ROUTING_SEGMENT_MAX];
 };
@@ -108,13 +106,13 @@ token_hdr_print(netdissect_options *ndo,
 {
        const char *srcname, *dstname;
 
-       srcname = etheraddr_string(ndo, fsrc);
-       dstname = etheraddr_string(ndo, fdst);
+       srcname = mac48_string(ndo, fsrc);
+       dstname = mac48_string(ndo, fdst);
 
        if (!ndo->ndo_qflag)
                ND_PRINT("%02x %02x ",
-                      EXTRACT_U_1(trp->token_ac),
-                      EXTRACT_U_1(trp->token_fc));
+                      GET_U_1(trp->token_ac),
+                      GET_U_1(trp->token_fc));
        ND_PRINT("%s > %s, length %u: ",
               srcname, dstname,
               length);
@@ -147,12 +145,12 @@ token_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen
 {
        const struct token_header *trp;
        int llc_hdrlen;
-       nd_mac_addr srcmac, dstmac;
+       nd_mac48 srcmac, dstmac;
        struct lladdr_info src, dst;
        u_int route_len = 0, hdr_len = TOKEN_HDRLEN;
        int seg;
 
-       ndo->ndo_protocol = "token";
+       ndo->ndo_protocol = "token-ring";
        trp = (const struct token_header *)p;
 
        if (caplen < TOKEN_HDRLEN) {
@@ -191,10 +189,11 @@ token_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen
                                ND_PRINT(" [%u:%u]", RING_NUMBER(trp, seg),
                                    BRIDGE_NUMBER(trp, seg));
                } else {
-                       ND_PRINT("rt = %x", EXTRACT_BE_U_2(trp->token_rcf));
+                       ND_PRINT("rt = %x", GET_BE_U_2(trp->token_rcf));
 
                        for (seg = 0; seg < SEGMENT_COUNT(trp); seg++)
-                               ND_PRINT(":%x", EXTRACT_BE_U_2(trp->token_rseg[seg]));
+                               ND_PRINT(":%x",
+                                        GET_BE_U_2(trp->token_rseg[seg]));
                }
                ND_PRINT(" (%s) ", largest_frame[LARGEST_FRAME(trp)]);
        } else {
@@ -203,9 +202,9 @@ token_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen
        }
 
        src.addr = srcmac;
-       src.addr_string = etheraddr_string;
+       src.addr_string = mac48_string;
        dst.addr = dstmac;
-       dst.addr_string = etheraddr_string;
+       dst.addr_string = mac48_string;
 
        /* Skip over token ring MAC header and routing information */
        length -= hdr_len;
@@ -241,9 +240,9 @@ token_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
 token_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
 {
-       ndo->ndo_protocol = "token_if";
-       return (token_print(ndo, p, h->len, h->caplen));
+       ndo->ndo_protocol = "token-ring";
+       ndo->ndo_ll_hdr_len += token_print(ndo, p, h->len, h->caplen);
 }