]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-lmp.c
Default to first interface from pcap_findalldevs()
[tcpdump] / print-lmp.c
index d204887e1385699b4368dd3f59b98955b4b3b740..30edfc7437d222cb0f1298b767786ec5faba3486 100644 (file)
  * by Manu Pathak ([email protected]), May 2005
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
 
-#include "interface.h"
+#include "netdissect.h"
 #include "extract.h"
 #include "addrtoname.h"
 #include "gmpls.h"
  */
 
 struct lmp_common_header {
-    u_int8_t version_res[2];
-    u_int8_t flags;
-    u_int8_t msg_type;
-    u_int8_t length[2];
-    u_int8_t reserved[2];
+    uint8_t version_res[2];
+    uint8_t flags;
+    uint8_t msg_type;
+    uint8_t length[2];
+    uint8_t reserved[2];
 };
 
 #define LMP_VERSION            1
@@ -212,9 +211,9 @@ static const struct tok lmp_msg_type_values[] = {
  */
 
 struct lmp_object_header {
-    u_int8_t ctype;
-    u_int8_t class_num;
-    u_int8_t length[2];
+    uint8_t ctype;
+    uint8_t class_num;
+    uint8_t length[2];
 };
 
 #define        LMP_OBJ_CC_ID                 1
@@ -354,8 +353,8 @@ static const struct tok lmp_ctype_values[] = {
 
 void
 lmp_print(netdissect_options *ndo,
-          register const u_char *pptr, register u_int len) {
-
+          register const u_char *pptr, register u_int len)
+{
     const struct lmp_common_header *lmp_com_header;
     const struct lmp_object_header *lmp_obj_header;
     const u_char *tptr,*obj_tptr;
@@ -366,7 +365,7 @@ lmp_print(netdissect_options *ndo,
 
     union { /* int to float conversion buffer */
         float f;
-        u_int32_t i;
+        uint32_t i;
     } bw;
 
     tptr=pptr;
@@ -406,8 +405,7 @@ lmp_print(netdissect_options *ndo,
 
     while(tlen>0) {
         /* did we capture enough for fully decoding the object header ? */
-        if (!ND_TTEST2(*tptr, sizeof(struct lmp_object_header)))
-            goto trunc;
+        ND_TCHECK2(*tptr, sizeof(struct lmp_object_header));
 
         lmp_obj_header = (const struct lmp_object_header *)tptr;
         lmp_obj_len=EXTRACT_16BITS(lmp_obj_header->length);
@@ -432,8 +430,7 @@ lmp_print(netdissect_options *ndo,
         obj_tlen=lmp_obj_len-sizeof(struct lmp_object_header);
 
         /* did we capture enough for fully decoding the object ? */
-        if (!ND_TTEST2(*tptr, lmp_obj_len))
-            goto trunc;
+        ND_TCHECK2(*tptr, lmp_obj_len);
         hexdump=FALSE;
 
         switch(lmp_obj_header->class_num) {
@@ -458,17 +455,15 @@ lmp_print(netdissect_options *ndo,
             case LMP_CTYPE_IPV4_LOC:
             case LMP_CTYPE_IPV4_RMT:
                 ND_PRINT((ndo, "\n\t    IPv4 Link ID: %s (0x%08x)",
-                       ipaddr_string(obj_tptr),
+                       ipaddr_string(ndo, obj_tptr),
                        EXTRACT_32BITS(obj_tptr)));
                 break;
-#ifdef INET6
             case LMP_CTYPE_IPV6_LOC:
             case LMP_CTYPE_IPV6_RMT:
                 ND_PRINT((ndo, "\n\t    IPv6 Link ID: %s (0x%08x)",
-                       ip6addr_string(obj_tptr),
+                       ip6addr_string(ndo, obj_tptr),
                        EXTRACT_32BITS(obj_tptr)));
                 break;
-#endif
             case LMP_CTYPE_UNMD_LOC:
             case LMP_CTYPE_UNMD_RMT:
                 ND_PRINT((ndo, "\n\t    Link ID: %u (0x%08x)",
@@ -502,7 +497,7 @@ lmp_print(netdissect_options *ndo,
             case LMP_CTYPE_LOC:
             case LMP_CTYPE_RMT:
                 ND_PRINT((ndo, "\n\t    Node ID: %s (0x%08x)",
-                       ipaddr_string(obj_tptr),
+                       ipaddr_string(ndo, obj_tptr),
                        EXTRACT_32BITS(obj_tptr)));
                 break;
 
@@ -547,15 +542,13 @@ lmp_print(netdissect_options *ndo,
            case LMP_CTYPE_IPV4:
                ND_PRINT((ndo, "\n\t    Local Link-ID: %s (0x%08x)"
                       "\n\t    Remote Link-ID: %s (0x%08x)",
-                       ipaddr_string(obj_tptr+4),
+                       ipaddr_string(ndo, obj_tptr+4),
                        EXTRACT_32BITS(obj_tptr+4),
-                       ipaddr_string(obj_tptr+8),
+                       ipaddr_string(ndo, obj_tptr+8),
                        EXTRACT_32BITS(obj_tptr+8)));
                break;
 
-#ifdef INET6
            case LMP_CTYPE_IPV6:
-#endif
            case LMP_CTYPE_UNMD:
             default:
                 hexdump=TRUE;
@@ -573,9 +566,9 @@ lmp_print(netdissect_options *ndo,
            case LMP_CTYPE_UNMD:
                 ND_PRINT((ndo, "\n\t    Local Interface ID: %s (0x%08x)"
                        "\n\t    Remote Interface ID: %s (0x%08x)",
-                       ipaddr_string(obj_tptr+4),
+                       ipaddr_string(ndo, obj_tptr+4),
                        EXTRACT_32BITS(obj_tptr+4),
-                       ipaddr_string(obj_tptr+8),
+                       ipaddr_string(ndo, obj_tptr+8),
                        EXTRACT_32BITS(obj_tptr+8)));
 
                total_subobj_len = lmp_obj_len - 16;
@@ -622,9 +615,7 @@ lmp_print(netdissect_options *ndo,
                }
 
                break;
-#ifdef INET6
            case LMP_CTYPE_IPV6:
-#endif
             default:
                 hexdump=TRUE;
             }
@@ -692,7 +683,7 @@ lmp_print(netdissect_options *ndo,
                /* Decode pairs: <Interface_ID (4 bytes), Channel_status (4 bytes)> */
                while (offset < (lmp_obj_len-(int)sizeof(struct lmp_object_header)) ) {
                        ND_PRINT((ndo, "\n\t    Interface ID: %s (0x%08x)",
-                       ipaddr_string(obj_tptr+offset),
+                       ipaddr_string(ndo, obj_tptr+offset),
                        EXTRACT_32BITS(obj_tptr+offset)));
 
                        ND_PRINT((ndo, "\n\t\t    Active: %s (%u)",             (EXTRACT_32BITS(obj_tptr+offset+4)>>31) ?
@@ -711,9 +702,7 @@ lmp_print(netdissect_options *ndo,
                        offset+=8;
                }
                 break;
-#ifdef INET6
            case LMP_CTYPE_IPV6:
-#endif
             default:
                 hexdump=TRUE;
             }
@@ -726,14 +715,12 @@ lmp_print(netdissect_options *ndo,
                offset = 0;
                while (offset < (lmp_obj_len-(int)sizeof(struct lmp_object_header)) ) {
                        ND_PRINT((ndo, "\n\t    Interface ID: %s (0x%08x)",
-                       ipaddr_string(obj_tptr+offset),
+                       ipaddr_string(ndo, obj_tptr+offset),
                        EXTRACT_32BITS(obj_tptr+offset)));
                        offset+=4;
                }
                 break;
-#ifdef INET6
            case LMP_CTYPE_IPV6:
-#endif
            default:
                 hexdump=TRUE;
             }
@@ -821,7 +808,7 @@ lmp_print(netdissect_options *ndo,
                       EXTRACT_16BITS(obj_tptr+10)));
 
                ND_PRINT((ndo, "\n\t    Local Interface ID: %s (0x%08x)",
-                      ipaddr_string(obj_tptr+12),
+                      ipaddr_string(ndo, obj_tptr+12),
                       EXTRACT_32BITS(obj_tptr+12)));
 
                break;