}
}
-/*
- * Print out a null-terminated filename (or other ASCII string), part of
- * the packet buffer.
- * If ep is NULL, assume no truncation check is needed.
- * Return true if truncated.
- * Stop at ep (if given) or before the null char, whichever is first.
- */
-int
-nd_print(netdissect_options *ndo,
- const u_char *s, const u_char *ep)
-{
- int ret;
- u_char c;
-
- ret = 1; /* assume truncated */
- while (ep == NULL || s < ep) {
- c = GET_U_1(s);
- s++;
- if (c == '\0') {
- ret = 0;
- break;
- }
- fn_print_char(ndo, c);
- }
- return(ret);
-}
-
/*
* Print out a null-terminated filename (or other ASCII string) from
* a fixed-length field in the packet buffer, or from what remains of
}
/*
- * Print out a null-padded filename (or other ASCII string), part of
- * the packet buffer.
- * If ep is NULL, assume no truncation check is needed.
- * Return true if truncated.
- * Stop at ep (if given) or after n bytes or before the null char,
+ * Print a counted filename (or other ASCII string), part of
+ * the packet buffer, filtering out non-printable characters.
+ * Stop if truncated (via GET_U_1/longjmp) or after n bytes,
* whichever is first.
+ * The suffix comes from: j:longJmp, n:after N bytes.
*/
-int
-nd_printzp(netdissect_options *ndo,
- const u_char *s, u_int n,
- const u_char *ep)
+void
+nd_printjn(netdissect_options *ndo, const u_char *s, u_int n)
+{
+ while (n > 0) {
+ fn_print_char(ndo, GET_U_1(s));
+ n--;
+ s++;
+ }
+}
+
+/*
+ * Print a null-padded filename (or other ASCII string), part of
+ * the packet buffer, filtering out non-printable characters.
+ * Stop if truncated (via GET_U_1/longjmp) or after n bytes or before
+ * the null char, whichever occurs first.
+ * The suffix comes from: j:longJmp, n:after N bytes, p:null-Padded.
+ */
+void
+nd_printjnp(netdissect_options *ndo, const u_char *s, u_int n)
{
- int ret;
u_char c;
- ret = 1; /* assume truncated */
- while (n > 0 && (ep == NULL || s < ep)) {
- n--;
+ while (n > 0) {
c = GET_U_1(s);
- s++;
- if (c == '\0') {
- ret = 0;
+ if (c == '\0')
break;
- }
fn_print_char(ndo, c);
+ n--;
+ s++;
}
- return (n == 0) ? 0 : ret;
}
/*
int
print_unknown_data(netdissect_options *ndo, const u_char *cp,
- const char *ident, u_int len)
+ const char *indent, u_int len)
{
- u_int len_to_print;
-
- len_to_print = len;
if (!ND_TTEST_LEN(cp, 0)) {
- ND_PRINT("%sDissector error: print_unknown_data called with pointer past end of packet",
- ident);
+ ND_PRINT("%sDissector error: %s() called with pointer past end of packet",
+ indent, __func__);
return(0);
}
- if (ND_BYTES_AVAILABLE_AFTER(cp) < len_to_print)
- len_to_print = ND_BYTES_AVAILABLE_AFTER(cp);
- hex_print(ndo, ident, cp, len_to_print);
+ hex_print(ndo, indent, cp, ND_MIN(len, ND_BYTES_AVAILABLE_AFTER(cp)));
return(1); /* everything is ok */
}