]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-cfm.c
CI: Add warning exemptions for Sun C (suncc-5.14) on Solaris 10
[tcpdump] / print-cfm.c
index 63d58e39b6c1d7bf2eabab0386c14782f2c12518..84fd5d9406b5168288849628af354c2666e0dbfa 100644 (file)
 
 /* \summary: IEEE 802.1ag Connectivity Fault Management (CFM) protocols printer */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #include "netdissect-stdinc.h"
 
-#include <stdio.h>
-
 #include "netdissect.h"
 #include "extract.h"
 #include "addrtoname.h"
@@ -116,8 +112,8 @@ struct cfm_lbm_t {
 struct cfm_ltm_t {
     nd_uint32_t transaction_id;
     nd_uint8_t  ttl;
-    nd_mac_addr original_mac;
-    nd_mac_addr target_mac;
+    nd_mac48 original_mac;
+    nd_mac48 target_mac;
 };
 
 static const struct tok cfm_ltm_flag_values[] = {
@@ -223,7 +219,7 @@ cfm_network_addr_print(netdissect_options *ndo,
     u_int hexdump =  FALSE;
 
     /*
-     * Although AFIs are typically 2 octects wide,
+     * Although AFIs are typically 2 octets wide,
      * 802.1ab specifies that this field width
      * is only one octet.
      */
@@ -241,22 +237,22 @@ cfm_network_addr_print(netdissect_options *ndo,
      * Resolve the passed in Address.
      */
     switch(network_addr_type) {
-    case AFNUM_INET:
+    case AFNUM_IP:
         if (length != 1 + 4) {
             ND_PRINT("(invalid IPv4 address length %u)", length - 1);
             hexdump = TRUE;
             break;
         }
-        ND_PRINT(", %s", ipaddr_string(ndo, tptr + 1));
+        ND_PRINT(", %s", GET_IPADDR_STRING(tptr + 1));
         break;
 
-    case AFNUM_INET6:
+    case AFNUM_IP6:
         if (length != 1 + 16) {
             ND_PRINT("(invalid IPv6 address length %u)", length - 1);
             hexdump = TRUE;
             break;
         }
-        ND_PRINT(", %s", ip6addr_string(ndo, tptr + 1));
+        ND_PRINT(", %s", GET_IP6ADDR_STRING(tptr + 1));
         break;
 
     default:
@@ -403,13 +399,12 @@ cfm_print(netdissect_options *ndo,
             switch (md_nameformat) {
             case CFM_CCM_MD_FORMAT_DNS:
             case CFM_CCM_MD_FORMAT_CHAR:
-                (void)nd_printzp(ndo, md_name, md_namelength, NULL);
+                nd_printjnp(ndo, md_name, md_namelength);
                 break;
 
             case CFM_CCM_MD_FORMAT_MAC:
-                if (md_namelength == 6) {
-                    ND_PRINT("\n\t  MAC %s", etheraddr_string(ndo,
-                               md_name));
+                if (md_namelength == MAC48_LEN) {
+                    ND_PRINT("\n\t  MAC %s", GET_MAC48_STRING(md_name));
                 } else {
                     ND_PRINT("\n\t  MAC (length invalid)");
                 }
@@ -455,7 +450,7 @@ cfm_print(netdissect_options *ndo,
         ND_PRINT("\n\t  MA Name: ");
         switch (ma_nameformat) {
         case CFM_CCM_MA_FORMAT_CHAR:
-            (void)nd_printzp(ndo, ma_name, ma_namelength, NULL);
+            nd_printjnp(ndo, ma_name, ma_namelength);
             break;
 
             /* FIXME add printers for those MA formats - hexdump for now */
@@ -487,8 +482,8 @@ cfm_print(netdissect_options *ndo,
                GET_U_1(msg_ptr.cfm_ltm->ttl));
 
         ND_PRINT("\n\t  Original-MAC %s, Target-MAC %s",
-               etheraddr_string(ndo, msg_ptr.cfm_ltm->original_mac),
-               etheraddr_string(ndo, msg_ptr.cfm_ltm->target_mac));
+               GET_MAC48_STRING(msg_ptr.cfm_ltm->original_mac),
+               GET_MAC48_STRING(msg_ptr.cfm_ltm->target_mac));
         break;
 
     case CFM_OPCODE_LTR:
@@ -531,11 +526,10 @@ cfm_print(netdissect_options *ndo,
     tptr += first_tlv_offset;
     tlen -= first_tlv_offset;
 
-    while (tlen > 0) {
+    while (tlen != 0) {
         cfm_tlv_header = (const struct cfm_tlv_header_t *)tptr;
 
         /* Enough to read the tlv type ? */
-        ND_TCHECK_1(cfm_tlv_header->type);
         cfm_tlv_type = GET_U_1(cfm_tlv_header->type);
 
         ND_PRINT("\n\t%s TLV (0x%02x)",
@@ -644,12 +638,12 @@ cfm_print(netdissect_options *ndo,
                 /* IEEE 802.1Q-2014 Section 21.5.3.3: Chassis ID */
                 switch (chassis_id_type) {
                 case CFM_CHASSIS_ID_MAC_ADDRESS:
-                    if (chassis_id_length != MAC_ADDR_LEN) {
+                    if (chassis_id_length != MAC48_LEN) {
                         ND_PRINT(" (invalid MAC address length)");
                         hexdump = TRUE;
                         break;
                     }
-                    ND_PRINT("\n\t  MAC %s", etheraddr_string(ndo, tptr + 1));
+                    ND_PRINT("\n\t  MAC %s", GET_MAC48_STRING(tptr + 1));
                     break;
 
                 case CFM_CHASSIS_ID_NETWORK_ADDRESS:
@@ -661,7 +655,7 @@ cfm_print(netdissect_options *ndo,
                 case CFM_CHASSIS_ID_LOCAL:
                 case CFM_CHASSIS_ID_CHASSIS_COMPONENT:
                 case CFM_CHASSIS_ID_PORT_COMPONENT:
-                    (void)nd_printzp(ndo, tptr + 1, chassis_id_length, NULL);
+                    nd_printjnp(ndo, tptr + 1, chassis_id_length);
                     break;
 
                 default: