}
}
-/*
- * 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,
- * whichever is first.
+ * 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.
*/
-int
-nd_printzp(netdissect_options *ndo,
- const u_char *s, u_int n,
- const u_char *ep)
+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;
}
/*
/*
* Convert a token value to a string; use "fmt" if not found.
*/
-const char *
+static const char *
tok2strbuf(const struct tok *lp, const char *fmt,
u_int v, char *buf, size_t bufsize)
{
int
mask2plen(uint32_t mask)
{
- uint32_t bitmasks[33] = {
+ const uint32_t bitmasks[33] = {
0x00000000,
0x80000000, 0xc0000000, 0xe0000000, 0xf0000000,
0xf8000000, 0xfc000000, 0xfe000000, 0xff000000,
(defined(__s390__) || defined(__s390x__) || defined(__zarch__)) || \
defined(__vax__)
/*
- * The procesor natively handles unaligned loads, so just use memcpy()
+ * The processor natively handles unaligned loads, so just use memcpy()
* and memcmp(), to enable those optimizations.
*
* XXX - are those all the x86 tests we need?