Add a fn_print_char() to do filtering.
extern void ts_print(netdissect_options *, const struct timeval *);
extern void relts_print(netdissect_options *, int);
+extern void fn_print_char(netdissect_options *, u_char);
extern int fn_print(netdissect_options *, const u_char *, const u_char *);
extern int fn_printn(netdissect_options *, const u_char *, u_int, const u_char *);
extern int fn_printzp(netdissect_options *, const u_char *, u_int, const u_char *);
ND_PRINT((ndo, "\n\t "));
for (i=0;i<len;i++) {
j = *(tptr+i);
- ND_PRINT((ndo, "%c", j));
- if (j == 0x0a) /* lets rework the version string to get a nice indentation */
- ND_PRINT((ndo, "\t "));
+ if (j == '\n') /* lets rework the version string to
+ get a nice indentation */
+ ND_PRINT((ndo, "\n\t "));
+ else
+ fn_print_char(ndo, j);
}
break;
case 0x06: /* Platform */
#define TOKBUFSIZE 128
+/*
+ * Print out a character, filtering out the non-printable ones
+ */
+void
+fn_print_char(netdissect_options *ndo, u_char c)
+{
+ if (!ND_ISASCII(c)) {
+ c = ND_TOASCII(c);
+ ND_PRINT((ndo, "M-"));
+ }
+ if (!ND_ISPRINT(c)) {
+ c ^= 0x40; /* DEL to ?, others to alpha */
+ ND_PRINT((ndo, "^"));
+ }
+ ND_PRINT((ndo, "%c", c));
+}
+
/*
* Print out a null-terminated filename (or other ascii string).
* If ep is NULL, assume no truncation check is needed.