]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-lane.c
Add printing support for vsockmon devices.
[tcpdump] / print-lane.c
index c8d919e148ee82c3f05cb8999b2a284a0d7df4cd..a6f83b1a8572f57b2b436c0cc7c49de92f90ef62 100644 (file)
  *
  */
 
-#define NETDISSECT_REWORKED
+/* \summary: ATM LANE printer */
+
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
-#include <tcpdump-stdinc.h>
+#include "netdissect-stdinc.h"
 
-#include "interface.h"
+#include "netdissect.h"
 #include "extract.h"
-#include "ether.h"
 
 struct lecdatahdr_8023 {
-  u_int16_t le_header;
-  u_int8_t h_dest[ETHER_ADDR_LEN];
-  u_int8_t h_source[ETHER_ADDR_LEN];
-  u_int16_t h_type;
+  nd_uint16_t le_header;
+  nd_mac_addr h_dest;
+  nd_mac_addr h_source;
+  nd_uint16_t h_type;
 };
 
 struct lane_controlhdr {
-  u_int16_t lec_header;
-  u_int8_t lec_proto;
-  u_int8_t lec_vers;
-  u_int16_t lec_opcode;
+  nd_uint16_t lec_header;
+  nd_uint8_t  lec_proto;
+  nd_uint8_t  lec_vers;
+  nd_uint16_t lec_opcode;
 };
 
 static const struct tok lecop2str[] = {
@@ -68,7 +68,7 @@ static const struct tok lecop2str[] = {
 static void
 lane_hdr_print(netdissect_options *ndo, const u_char *bp)
 {
-       ND_PRINT((ndo, "lecid:%x ", EXTRACT_16BITS(bp)));
+       ND_PRINT("lecid:%x ", GET_BE_U_2(bp));
 }
 
 /*
@@ -82,21 +82,23 @@ lane_hdr_print(netdissect_options *ndo, const u_char *bp)
 void
 lane_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
 {
-       struct lane_controlhdr *lec;
+       const struct lane_controlhdr *lec;
 
+       ndo->ndo_protocol = "lane";
        if (caplen < sizeof(struct lane_controlhdr)) {
-               ND_PRINT((ndo, "[|lane]"));
+               nd_print_trunc(ndo);
                return;
        }
 
-       lec = (struct lane_controlhdr *)p;
-       if (EXTRACT_16BITS(&lec->lec_header) == 0xff00) {
+       lec = (const struct lane_controlhdr *)p;
+       if (GET_BE_U_2(lec->lec_header) == 0xff00) {
                /*
                 * LE Control.
                 */
-               ND_PRINT((ndo, "lec: proto %x vers %x %s",
-                   lec->lec_proto, lec->lec_vers,
-                   tok2str(lecop2str, "opcode-#%u", EXTRACT_16BITS(&lec->lec_opcode))));
+               ND_PRINT("lec: proto %x vers %x %s",
+                   GET_U_1(lec->lec_proto),
+                   GET_U_1(lec->lec_vers),
+                   tok2str(lecop2str, "opcode-#%u", GET_BE_U_2(lec->lec_opcode)));
                return;
        }
 
@@ -117,6 +119,7 @@ lane_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
 u_int
 lane_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
 {
+       ndo->ndo_protocol = "lane_if";
        lane_print(ndo, p, h->len, h->caplen);
 
        return (sizeof(struct lecdatahdr_8023));