]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ahcp.c
Do the dump file Capsicum stuff in a common routine.
[tcpdump] / print-ahcp.c
index 1d498735acb069d9a08f25eb26df58d326293551..a9ae38a972334cfafd0302a46cbb67a047d8fb9a 100644 (file)
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include "netdissect.h"
+#include "interface.h"
 #include "extract.h"
 #include "addrtoname.h"
 
@@ -99,7 +100,8 @@ static const struct tok ahcp1_opt_str[] = {
 };
 
 static int
-ahcp_time_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) {
+ahcp_time_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
        time_t t;
        struct tm *tm;
        char buf[BUFSIZE];
@@ -126,7 +128,8 @@ trunc:
 }
 
 static int
-ahcp_seconds_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) {
+ahcp_seconds_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
        if (cp + 4 != ep)
                goto corrupt;
        ND_TCHECK2(*cp, 4);
@@ -143,20 +146,19 @@ trunc:
 }
 
 static int
-ahcp_ipv6_addresses_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) {
+ahcp_ipv6_addresses_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
        const char *sep = ": ";
 
        while (cp < ep) {
                if (cp + 16 > ep)
                        goto corrupt;
                ND_TCHECK2(*cp, 16);
-               ND_PRINT((ndo, "%s%s", sep,
 #ifdef INET6
-                      ip6addr_string(cp)
+               ND_PRINT((ndo, "%s%s", sep, ip6addr_string(ndo, cp)));
 #else
-                      "(compiled w/o IPv6)"
+               ND_PRINT((ndo, "%s(compiled w/o IPv6)", sep));
 #endif /* INET6 */
-                      ));
                cp += 16;
                sep = ", ";
        }
@@ -172,14 +174,15 @@ trunc:
 }
 
 static int
-ahcp_ipv4_addresses_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) {
+ahcp_ipv4_addresses_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
        const char *sep = ": ";
 
        while (cp < ep) {
                if (cp + 4 > ep)
                        goto corrupt;
                ND_TCHECK2(*cp, 4);
-               ND_PRINT((ndo, "%s%s", sep, ipaddr_string(cp)));
+               ND_PRINT((ndo, "%s%s", sep, ipaddr_string(ndo, cp)));
                cp += 4;
                sep = ", ";
        }
@@ -195,20 +198,19 @@ trunc:
 }
 
 static int
-ahcp_ipv6_prefixes_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) {
+ahcp_ipv6_prefixes_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
        const char *sep = ": ";
 
        while (cp < ep) {
                if (cp + 17 > ep)
                        goto corrupt;
                ND_TCHECK2(*cp, 17);
-               ND_PRINT((ndo, "%s%s/%u", sep,
 #ifdef INET6
-                      ip6addr_string(cp),
+               ND_PRINT((ndo, "%s%s/%u", sep, ip6addr_string(ndo, cp), *(cp + 16)));
 #else
-                      "(compiled w/o IPv6)",
+               ND_PRINT((ndo, "%s(compiled w/o IPv6)/%u", sep, *(cp + 16)));
 #endif /* INET6 */
-                      *(cp + 16)));
                cp += 17;
                sep = ", ";
        }
@@ -224,14 +226,15 @@ trunc:
 }
 
 static int
-ahcp_ipv4_prefixes_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) {
+ahcp_ipv4_prefixes_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
        const char *sep = ": ";
 
        while (cp < ep) {
                if (cp + 5 > ep)
                        goto corrupt;
                ND_TCHECK2(*cp, 5);
-               ND_PRINT((ndo, "%s%s/%u", sep, ipaddr_string(cp), *(cp + 4)));
+               ND_PRINT((ndo, "%s%s/%u", sep, ipaddr_string(ndo, cp), *(cp + 4)));
                cp += 5;
                sep = ", ";
        }
@@ -266,7 +269,8 @@ static int
 };
 
 static void
-ahcp1_options_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) {
+ahcp1_options_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
        uint8_t option_no, option_len;
 
        while (cp < ep) {
@@ -306,7 +310,8 @@ trunc:
 }
 
 static void
-ahcp1_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) {
+ahcp1_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
        uint8_t type, mbz;
        uint16_t body_len;
 
@@ -350,7 +355,8 @@ trunc:
 }
 
 void
-ahcp_print(netdissect_options *ndo, const u_char *cp, const u_int len) {
+ahcp_print(netdissect_options *ndo, const u_char *cp, const u_int len)
+{
        const u_char *ep = cp + len;
        uint8_t version;
 
@@ -389,11 +395,11 @@ ahcp_print(netdissect_options *ndo, const u_char *cp, const u_int len) {
                                cp += 4;
                                /* Source Id */
                                ND_TCHECK2(*cp, 8);
-                               ND_PRINT((ndo, ", Source Id %s", linkaddr_string(cp, 0, 8)));
+                               ND_PRINT((ndo, ", Source Id %s", linkaddr_string(ndo, cp, 0, 8)));
                                cp += 8;
                                /* Destination Id */
                                ND_TCHECK2(*cp, 8);
-                               ND_PRINT((ndo, ", Destination Id %s", linkaddr_string(cp, 0, 8)));
+                               ND_PRINT((ndo, ", Destination Id %s", linkaddr_string(ndo, cp, 0, 8)));
                                cp += 8;
                        }
                        /* Body */
@@ -413,4 +419,3 @@ corrupt:
 trunc:
        ND_PRINT((ndo, "%s", tstr));
 }
-