]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-cfm.c
Default to first interface from pcap_findalldevs()
[tcpdump] / print-cfm.c
index 6901b89805d6f1efdc94eb58a89bc57000585ca1..2d67e84c7000ebf8b8b3b1cb47e1e95ce5bf426c 100644 (file)
  * Original code by Hannes Gredler ([email protected])
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
 
 #include <stdio.h>
 
-#include "interface.h"
+#include "netdissect.h"
 #include "extract.h"
 #include "ether.h"
 #include "addrtoname.h"
 #include "af.h"
 
 struct cfm_common_header_t {
-    u_int8_t mdlevel_version;
-    u_int8_t opcode;
-    u_int8_t flags;
-    u_int8_t first_tlv_offset;
+    uint8_t mdlevel_version;
+    uint8_t opcode;
+    uint8_t flags;
+    uint8_t first_tlv_offset;
 };
 
 #define        CFM_VERSION 0
@@ -63,13 +62,13 @@ static const struct tok cfm_opcode_values[] = {
  * Message Formats.
  */
 struct cfm_ccm_t {
-    u_int8_t sequence[4];
-    u_int8_t ma_epi[2];
-    u_int8_t md_nameformat;
-    u_int8_t md_namelength;
-    u_int8_t md_name[46]; /* md name and short ma name */
-    u_int8_t reserved_itu[16];
-    u_int8_t reserved[6];
+    uint8_t sequence[4];
+    uint8_t ma_epi[2];
+    uint8_t md_nameformat;
+    uint8_t md_namelength;
+    uint8_t md_name[46]; /* md name and short ma name */
+    uint8_t reserved_itu[16];
+    uint8_t reserved[6];
 };
 
 /*
@@ -114,17 +113,17 @@ static const struct tok cfm_ma_nameformat_values[] = {
 };
 
 struct cfm_lbm_t {
-    u_int8_t transaction_id[4];
-    u_int8_t reserved[4];
+    uint8_t transaction_id[4];
+    uint8_t reserved[4];
 };
 
 struct cfm_ltm_t {
-    u_int8_t transaction_id[4];
-    u_int8_t egress_id[8];
-    u_int8_t ttl;
-    u_int8_t original_mac[ETHER_ADDR_LEN];
-    u_int8_t target_mac[ETHER_ADDR_LEN];
-    u_int8_t reserved[3];
+    uint8_t transaction_id[4];
+    uint8_t egress_id[8];
+    uint8_t ttl;
+    uint8_t original_mac[ETHER_ADDR_LEN];
+    uint8_t target_mac[ETHER_ADDR_LEN];
+    uint8_t reserved[3];
 };
 
 static const struct tok cfm_ltm_flag_values[] = {
@@ -133,12 +132,12 @@ static const struct tok cfm_ltm_flag_values[] = {
 };
 
 struct cfm_ltr_t {
-    u_int8_t transaction_id[4];
-    u_int8_t last_egress_id[8];
-    u_int8_t next_egress_id[8];
-    u_int8_t ttl;
-    u_int8_t replay_action;
-    u_int8_t reserved[6];
+    uint8_t transaction_id[4];
+    uint8_t last_egress_id[8];
+    uint8_t next_egress_id[8];
+    uint8_t ttl;
+    uint8_t replay_action;
+    uint8_t reserved[6];
 };
 
 static const struct tok cfm_ltr_flag_values[] = {
@@ -182,8 +181,8 @@ static const struct tok cfm_tlv_values[] = {
  */
 
 struct cfm_tlv_header_t {
-    u_int8_t type;
-    u_int8_t length[2];
+    uint8_t type;
+    uint8_t length[2];
 };
 
 /* FIXME define TLV formats */
@@ -227,8 +226,8 @@ static const struct tok cfm_tlv_senderid_chassisid_values[] = {
 
 static int
 cfm_mgmt_addr_print(netdissect_options *ndo,
-                    register const u_char *tptr) {
-
+                    register const u_char *tptr)
+{
     u_int mgmt_addr_type;
     u_int hexdump =  FALSE;
 
@@ -247,14 +246,12 @@ cfm_mgmt_addr_print(netdissect_options *ndo,
      */
     switch(mgmt_addr_type) {
     case AFNUM_INET:
-        ND_PRINT((ndo, ", %s", ipaddr_string(tptr + 1)));
+        ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr + 1)));
         break;
 
-#ifdef INET6
     case AFNUM_INET6:
-        ND_PRINT((ndo, ", %s", ip6addr_string(tptr + 1)));
+        ND_PRINT((ndo, ", %s", ip6addr_string(ndo, tptr + 1)));
         break;
-#endif
 
     default:
         hexdump = TRUE;
@@ -268,24 +265,25 @@ cfm_mgmt_addr_print(netdissect_options *ndo,
  * The egress-ID string is a 16-Bit string plus a MAC address.
  */
 static const char *
-cfm_egress_id_string(register const u_char *tptr) {
+cfm_egress_id_string(netdissect_options *ndo, register const u_char *tptr)
+{
     static char egress_id_buffer[80];
 
     snprintf(egress_id_buffer, sizeof(egress_id_buffer),
              "MAC 0x%4x-%s",
              EXTRACT_16BITS(tptr),
-             etheraddr_string(tptr+2));
+             etheraddr_string(ndo, tptr+2));
 
     return egress_id_buffer;
 }
 
 void
 cfm_print(netdissect_options *ndo,
-          register const u_char *pptr, register u_int length) {
-
+          register const u_char *pptr, register u_int length)
+{
     const struct cfm_common_header_t *cfm_common_header;
     const struct cfm_tlv_header_t *cfm_tlv_header;
-    const u_int8_t *tptr, *tlv_ptr, *ma_name, *ma_nameformat, *ma_namelength;
+    const uint8_t *tptr, *tlv_ptr, *ma_name, *ma_nameformat, *ma_namelength;
     u_int hexdump, tlen, cfm_tlv_len, cfm_tlv_type, ccm_interval;
 
 
@@ -371,7 +369,7 @@ cfm_print(netdissect_options *ndo,
                 break;
 
             case CFM_CCM_MD_FORMAT_MAC:
-                ND_PRINT((ndo, "\n\t  MAC %s", etheraddr_string(
+                ND_PRINT((ndo, "\n\t  MAC %s", etheraddr_string(ndo,
                            msg_ptr.cfm_ccm->md_name)));
                 break;
 
@@ -421,12 +419,12 @@ cfm_print(netdissect_options *ndo,
 
         ND_PRINT((ndo, "\n\t  Transaction-ID 0x%08x, Egress-ID %s, ttl %u",
                EXTRACT_32BITS(msg_ptr.cfm_ltm->transaction_id),
-               cfm_egress_id_string(msg_ptr.cfm_ltm->egress_id),
+               cfm_egress_id_string(ndo, msg_ptr.cfm_ltm->egress_id),
                msg_ptr.cfm_ltm->ttl));
 
         ND_PRINT((ndo, "\n\t  Original-MAC %s, Target-MAC %s",
-               etheraddr_string(msg_ptr.cfm_ltm->original_mac),
-               etheraddr_string(msg_ptr.cfm_ltm->target_mac)));
+               etheraddr_string(ndo, msg_ptr.cfm_ltm->original_mac),
+               etheraddr_string(ndo, msg_ptr.cfm_ltm->target_mac)));
         break;
 
     case CFM_OPCODE_LTR:
@@ -437,10 +435,10 @@ cfm_print(netdissect_options *ndo,
 
         ND_PRINT((ndo, "\n\t  Transaction-ID 0x%08x, Last-Egress-ID %s",
                EXTRACT_32BITS(msg_ptr.cfm_ltr->transaction_id),
-               cfm_egress_id_string(msg_ptr.cfm_ltr->last_egress_id)));
+               cfm_egress_id_string(ndo, msg_ptr.cfm_ltr->last_egress_id)));
 
         ND_PRINT((ndo, "\n\t  Next-Egress-ID %s, ttl %u",
-               cfm_egress_id_string(msg_ptr.cfm_ltr->next_egress_id),
+               cfm_egress_id_string(ndo, msg_ptr.cfm_ltr->next_egress_id),
                msg_ptr.cfm_ltr->ttl));
 
         ND_PRINT((ndo, "\n\t  Replay-Action %s (%u)",
@@ -565,7 +563,7 @@ cfm_print(netdissect_options *ndo,
 
                 switch (chassis_id_type) {
                 case CFM_CHASSIS_ID_MAC_ADDRESS:
-                    ND_PRINT((ndo, "\n\t  MAC %s", etheraddr_string(tptr + 1)));
+                    ND_PRINT((ndo, "\n\t  MAC %s", etheraddr_string(ndo, tptr + 1)));
                     break;
 
                 case CFM_CHASSIS_ID_NETWORK_ADDRESS: