]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Add the fn_print_str() function
authorFrancois-Xavier Le Bail <[email protected]>
Fri, 18 May 2018 20:18:46 +0000 (22:18 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Fri, 18 May 2018 21:05:01 +0000 (23:05 +0200)
This function print a null-terminated string, filtering out non-printable
characters.
DON'T USE IT with a pointer on the packet buffer because there is no
truncation check. For this use, see the nd_printX() functions.

netdissect.h
util-print.c

index 39d17969113a84643b975abec7f3bc1f2cb71b30..443a9310e5fe1326bae9f86099880240e4ea4947 100644 (file)
@@ -331,6 +331,7 @@ extern void signed_relts_print(netdissect_options *, int32_t);
 extern void unsigned_relts_print(netdissect_options *, uint32_t);
 
 extern void fn_print_char(netdissect_options *, u_char);
+extern void fn_print_str(netdissect_options *, const u_char *);
 extern int nd_print(netdissect_options *, const u_char *, const u_char *);
 extern u_int nd_printztn(netdissect_options *ndo, const u_char *, u_int, const u_char *);
 extern int nd_printn(netdissect_options *, const u_char *, u_int, const u_char *);
index 8cf0576b2d49186035218d89051a2e8f433ae18d..43380f918c26273d2698cca7c1913dfe973d8605 100644 (file)
@@ -86,6 +86,20 @@ fn_print_char(netdissect_options *ndo, u_char c)
        ND_PRINT("%c", c);
 }
 
+/*
+ * Print a null-terminated string, filtering out non-printable characters.
+ * DON'T USE IT with a pointer on the packet buffer because there is no
+ * truncation check. For this use, see the nd_printX() functions below.
+ */
+void
+fn_print_str(netdissect_options *ndo, const u_char *s)
+{
+       while (*s != '\0') {
+               fn_print_char(ndo, *s);
+               s++;
+       }
+}
+
 /*
  * Print out a null-terminated filename (or other ASCII string), part of
  * the packet buffer.