The functions are: nd_print, nd_printztn, nd_printn and nd_printzp.
Trying to make it clearer that they currently have to be used only on part
of the packet buffer.
Update some comments.
extern void unsigned_relts_print(netdissect_options *, uint32_t);
extern void fn_print_char(netdissect_options *, u_char);
-extern int fn_print(netdissect_options *, const u_char *, const u_char *);
-extern u_int fn_printztn(netdissect_options *ndo, const u_char *, u_int, 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 *);
+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 *);
+extern int nd_printzp(netdissect_options *, const u_char *, u_int, const u_char *);
/*
* Flags for txtproto_print().
#define PRINT_SSID(p) \
if (p.ssid_present) { \
ND_PRINT(" ("); \
- fn_print(ndo, p.ssid.ssid, NULL); \
+ nd_print(ndo, p.ssid.ssid, NULL); \
ND_PRINT(")"); \
}
ND_TCHECK_LEN(cp, cslen);
if (cslen) {
ND_PRINT("\n\tConfig String (length %u): ", cslen);
- if (fn_printn(ndo, cp, cslen, ndo->ndo_snapend))
+ if (nd_printn(ndo, cp, cslen, ndo->ndo_snapend))
goto trunc;
}
return;
pptr++;
ND_PRINT(", Password: ");
/* the length is equal to the password length plus three */
- if (fn_printn(ndo, pptr, auth_len - 3,
+ if (nd_printn(ndo, pptr, auth_len - 3,
ndo->ndo_snapend))
goto trunc;
break;
else {
ND_TCHECK_LEN(tptr + 1, shutdown_comm_length);
ND_PRINT(", Shutdown Communication (length: %u): \"", shutdown_comm_length);
- (void)fn_printn(ndo, tptr+1, shutdown_comm_length, NULL);
+ (void)nd_printn(ndo, tptr+1, shutdown_comm_length, NULL);
ND_PRINT("\"");
remainder_offset += shutdown_comm_length + 1;
}
ND_TCHECK_1(bp->bp_sname); /* check first char only */
if (EXTRACT_U_1(bp->bp_sname)) {
ND_PRINT("\n\t sname \"");
- if (fn_printztn(ndo, bp->bp_sname, (u_int)sizeof(bp->bp_sname),
- ndo->ndo_snapend)) {
+ if (nd_printztn(ndo, bp->bp_sname, (u_int)sizeof(bp->bp_sname),
+ ndo->ndo_snapend)) {
ND_PRINT("\"");
ND_PRINT("%s", tstr + 1);
return;
ND_TCHECK_1(bp->bp_file); /* check first char only */
if (EXTRACT_U_1(bp->bp_file)) {
ND_PRINT("\n\t file \"");
- if (fn_printztn(ndo, bp->bp_file, (u_int)sizeof(bp->bp_file),
- ndo->ndo_snapend)) {
+ if (nd_printztn(ndo, bp->bp_file, (u_int)sizeof(bp->bp_file),
+ ndo->ndo_snapend)) {
ND_PRINT("\"");
ND_PRINT("%s", tstr + 1);
return;
case 'a':
/* ASCII strings */
ND_PRINT("\"");
- if (fn_printn(ndo, bp, len, ndo->ndo_snapend)) {
+ if (nd_printn(ndo, bp, len, ndo->ndo_snapend)) {
ND_PRINT("\"");
goto trunc;
}
ND_PRINT("%u/%u ", EXTRACT_U_1(bp), EXTRACT_U_1(bp + 1));
bp += 2;
ND_PRINT("\"");
- if (fn_printn(ndo, bp, len - 3, ndo->ndo_snapend)) {
+ if (nd_printn(ndo, bp, len - 3, ndo->ndo_snapend)) {
ND_PRINT("\"");
goto trunc;
}
len--;
if (type == 0) {
ND_PRINT("\"");
- if (fn_printn(ndo, bp, len, ndo->ndo_snapend)) {
+ if (nd_printn(ndo, bp, len, ndo->ndo_snapend)) {
ND_PRINT("\"");
goto trunc;
}
case AGENT_SUBOPTION_CIRCUIT_ID: /* fall through */
case AGENT_SUBOPTION_REMOTE_ID:
case AGENT_SUBOPTION_SUBSCRIBER_ID:
- if (fn_printn(ndo, bp, suboptlen, ndo->ndo_snapend))
+ if (nd_printn(ndo, bp, suboptlen, ndo->ndo_snapend))
goto trunc;
break;
break;
}
ND_PRINT("\"");
- if (fn_printn(ndo, bp, suboptlen, ndo->ndo_snapend)) {
+ if (nd_printn(ndo, bp, suboptlen, ndo->ndo_snapend)) {
ND_PRINT("\"");
goto trunc;
}
if (!ndo->ndo_vflag)
ND_PRINT(", Device-ID ");
ND_PRINT("'");
- (void)fn_printn(ndo, tptr, len, NULL);
+ (void)nd_printn(ndo, tptr, len, NULL);
ND_PRINT("'");
break;
case 0x02: /* Address */
break;
case 0x03: /* Port-ID */
ND_PRINT("'");
- (void)fn_printn(ndo, tptr, len, NULL);
+ (void)nd_printn(ndo, tptr, len, NULL);
ND_PRINT("'");
break;
case 0x04: /* Capabilities */
break;
case 0x06: /* Platform */
ND_PRINT("'");
- (void)fn_printn(ndo, tptr, len, NULL);
+ (void)nd_printn(ndo, tptr, len, NULL);
ND_PRINT("'");
break;
case 0x07: /* Prefixes */
break;
case 0x09: /* VTP Mgmt Domain - CDPv2 */
ND_PRINT("'");
- (void)fn_printn(ndo, tptr, len, NULL);
+ (void)nd_printn(ndo, tptr, len, NULL);
ND_PRINT("'");
break;
case 0x0a: /* Native VLAN ID - CDPv2 */
break;
case 0x14: /* System Name - not documented */
ND_PRINT("'");
- (void)fn_printn(ndo, tptr, len, NULL);
+ (void)nd_printn(ndo, tptr, len, NULL);
ND_PRINT("'");
break;
case 0x16: /* System Object ID - not documented */
ND_PRINT("0x%02x", EXTRACT_U_1(tptr));
if (len > 1) {
ND_PRINT("/");
- (void)fn_printn(ndo, tptr + 1, len - 1, NULL);
+ (void)nd_printn(ndo, tptr + 1, len - 1, NULL);
}
break;
default:
label_len = EXTRACT_U_1(tp);
tp++;
if (label_len < remain_len - 1) {
- (void)fn_printn(ndo, tp, label_len, NULL);
+ (void)nd_printn(ndo, tp, label_len, NULL);
tp += label_len;
remain_len -= (label_len + 1);
if(EXTRACT_U_1(tp)) ND_PRINT(".");
}
tp = (const u_char *)(dh6o + 1);
ND_PRINT("=");
- (void)fn_printn(ndo, tp, (u_int)optlen, NULL);
+ (void)nd_printn(ndo, tp, (u_int)optlen, NULL);
ND_PRINT(")");
break;
return(NULL);
}
} else {
- if (fn_printn(ndo, cp, l, ndo->ndo_snapend))
+ if (nd_printn(ndo, cp, l, ndo->ndo_snapend))
return(NULL);
}
return (NULL);
i = EXTRACT_U_1(cp);
cp++;
- if (fn_printn(ndo, cp, i, ndo->ndo_snapend))
+ if (nd_printn(ndo, cp, i, ndo->ndo_snapend))
return (NULL);
return (cp + i);
}
case T_UNSPECA: /* One long string */
if (!ND_TTEST_LEN(cp, len))
return(NULL);
- if (fn_printn(ndo, cp, len, ndo->ndo_snapend))
+ if (nd_printn(ndo, cp, len, ndo->ndo_snapend))
return(NULL);
break;
switch (type) {
case DTP_DOMAIN_TLV:
ND_PRINT(", ");
- fn_printzp(ndo, tptr+4, len-4, pptr+length);
+ nd_printzp(ndo, tptr+4, len-4, pptr+length);
break;
case DTP_STATUS_TLV:
unsigned_relts_print(ndo, EXTRACT_U_1(hp->hsrp_holdtime));
ND_PRINT(" priority=%u", EXTRACT_U_1(hp->hsrp_priority));
ND_PRINT(" auth=\"");
- if (fn_printn(ndo, hp->hsrp_authdata, sizeof(hp->hsrp_authdata),
- ndo->ndo_snapend)) {
+ if (nd_printn(ndo, hp->hsrp_authdata, sizeof(hp->hsrp_authdata),
+ ndo->ndo_snapend)) {
ND_PRINT("\"");
goto trunc;
}
ND_PRINT("'");
goto trunc;
}
- if (fn_printzp(ndo, ipx, 48, ndo->ndo_snapend)) {
+ if (nd_printzp(ndo, ipx, 48, ndo->ndo_snapend)) {
ND_PRINT("'");
goto trunc;
}
ND_TCHECK_SIZE(mcid);
ND_PRINT("ID: %u, Name: ", EXTRACT_U_1(mcid->format_id));
- if (fn_printzp(ndo, mcid->name, 32, ndo->ndo_snapend))
+ if (nd_printzp(ndo, mcid->name, 32, ndo->ndo_snapend))
goto trunc;
ND_PRINT("\n\t Lvl: %u", EXTRACT_BE_U_2(mcid->revision_lvl));
switch (EXTRACT_U_1(tptr)) {
case ISIS_SUBTLV_AUTH_SIMPLE:
- if (fn_printzp(ndo, tptr + 1, tlv_len - 1, ndo->ndo_snapend))
+ if (nd_printzp(ndo, tptr + 1, tlv_len - 1, ndo->ndo_snapend))
goto trunc;
break;
case ISIS_SUBTLV_AUTH_MD5:
case ISIS_TLV_HOSTNAME:
ND_PRINT("\n\t Hostname: ");
- if (fn_printzp(ndo, tptr, tmp, ndo->ndo_snapend))
+ if (nd_printzp(ndo, tptr, tmp, ndo->ndo_snapend))
goto trunc;
break;
switch (subtype) {
case LLDP_IANA_SUBTYPE_MUDURL:
ND_PRINT("\n\t MUD-URL=");
- (void)fn_printn(ndo, tptr+4, tlv_len-4, NULL);
+ (void)nd_printn(ndo, tptr+4, tlv_len-4, NULL);
break;
default:
hexdump=TRUE;
/* Update 32-bit pointer (NFS filenames padded to 32-bit boundaries) */
dp += ((len + 3) & ~3) / sizeof(*dp);
ND_PRINT("\"");
- if (fn_printn(ndo, cp, len, ndo->ndo_snapend)) {
+ if (nd_printn(ndo, cp, len, ndo->ndo_snapend)) {
ND_PRINT("\"");
goto trunc;
}
break;
case PRIM_REF:
- if (fn_printn(ndo, (const u_char *)&(bp->refid), 4, ndo->ndo_snapend))
+ if (nd_printn(ndo, (const u_char *)&(bp->refid), 4, ndo->ndo_snapend))
goto trunc;
break;
else
ND_PRINT(", address %s, name \"",
ipaddr_string(ndo, msg_data));
- (void)fn_printn(ndo, msg_data + addr_size, name_entry_len, NULL);
+ (void)nd_printn(ndo, msg_data + addr_size, name_entry_len, NULL);
ND_PRINT("\"");
msg_data += addr_size + name_entry_len + name_entry_padding;
cp += 4;
/* data */
ND_PRINT(", data '");
- if (fn_printn(ndo, cp, len - 8, ep)) {
+ if (nd_printn(ndo, cp, len - 8, ep)) {
ND_PRINT("'");
goto trunc;
}
/* already checked that len >= 4 */
/* data */
ND_PRINT(", data '");
- if (fn_printn(ndo, cp, len - 4, ep)) {
+ if (nd_printn(ndo, cp, len - 4, ep)) {
ND_PRINT("'");
goto trunc;
}
/* name */
ND_TCHECK_LEN(cp, OFP_MAX_PORT_NAME_LEN);
ND_PRINT(", name '");
- fn_print(ndo, cp, cp + OFP_MAX_PORT_NAME_LEN);
+ nd_print(ndo, cp, cp + OFP_MAX_PORT_NAME_LEN);
ND_PRINT("'");
cp += OFP_MAX_PORT_NAME_LEN;
/* mfr_desc */
ND_TCHECK_LEN(cp, DESC_STR_LEN);
ND_PRINT("\n\t mfr_desc '");
- fn_print(ndo, cp, cp + DESC_STR_LEN);
+ nd_print(ndo, cp, cp + DESC_STR_LEN);
ND_PRINT("'");
cp += DESC_STR_LEN;
/* hw_desc */
ND_TCHECK_LEN(cp, DESC_STR_LEN);
ND_PRINT("\n\t hw_desc '");
- fn_print(ndo, cp, cp + DESC_STR_LEN);
+ nd_print(ndo, cp, cp + DESC_STR_LEN);
ND_PRINT("'");
cp += DESC_STR_LEN;
/* sw_desc */
ND_TCHECK_LEN(cp, DESC_STR_LEN);
ND_PRINT("\n\t sw_desc '");
- fn_print(ndo, cp, cp + DESC_STR_LEN);
+ nd_print(ndo, cp, cp + DESC_STR_LEN);
ND_PRINT("'");
cp += DESC_STR_LEN;
/* serial_num */
ND_TCHECK_LEN(cp, SERIAL_NUM_LEN);
ND_PRINT("\n\t serial_num '");
- fn_print(ndo, cp, cp + SERIAL_NUM_LEN);
+ nd_print(ndo, cp, cp + SERIAL_NUM_LEN);
ND_PRINT("'");
cp += SERIAL_NUM_LEN;
/* dp_desc */
ND_TCHECK_LEN(cp, DESC_STR_LEN);
ND_PRINT("\n\t dp_desc '");
- fn_print(ndo, cp, cp + DESC_STR_LEN);
+ nd_print(ndo, cp, cp + DESC_STR_LEN);
ND_PRINT("'");
return cp + DESC_STR_LEN;
/* name */
ND_TCHECK_LEN(cp, OFP_MAX_TABLE_NAME_LEN);
ND_PRINT(", name '");
- fn_print(ndo, cp, cp + OFP_MAX_TABLE_NAME_LEN);
+ nd_print(ndo, cp, cp + OFP_MAX_TABLE_NAME_LEN);
ND_PRINT("'");
cp += OFP_MAX_TABLE_NAME_LEN;
/* wildcards */
/* RFC 1661 says this is intended to be human readable */
if (len > 8) {
ND_PRINT("\n\t Message\n\t ");
- if (fn_printn(ndo, tptr + 4, len - 4, ndo->ndo_snapend))
+ if (nd_printn(ndo, tptr + 4, len - 4, ndo->ndo_snapend))
goto trunc;
}
break;
*/
#define RESP_PRINT_SEGMENT(_ndo, _bp, _len) \
ND_PRINT(" \""); \
- if (fn_printn(_ndo, _bp, _len, _ndo->ndo_snapend)) \
+ if (nd_printn(_ndo, _bp, _len, _ndo->ndo_snapend)) \
goto trunc; \
fn_print_char(_ndo, '"');
remaining -= sizeof(*eh);
if (auth_type == 2) {
ND_PRINT("\n\t Simple Text Authentication data: ");
- if (fn_printzp(ndo, p, RIP_AUTHLEN, p + remaining))
+ if (nd_printzp(ndo, p, RIP_AUTHLEN, p + remaining))
return (0);
} else if (auth_type == 3) {
const struct rip_auth_crypto_v2 *ch;
if (text_length) {
if (pdu_len < tlen + text_length)
goto invalid;
- /* fn_printn() makes the bounds check */
+ /* nd_printn() makes the bounds check */
ND_PRINT("%sError text: ", indent_string(indent+2));
- if (fn_printn(ndo, tptr + tlen, text_length, ndo->ndo_snapend))
+ if (nd_printn(ndo, tptr + tlen, text_length, ndo->ndo_snapend))
goto trunc;
}
}
goto trunc; \
bp += sizeof(uint32_t); \
ND_PRINT(" \""); \
- if (fn_printn(ndo, bp, _i, ndo->ndo_snapend)) \
+ if (nd_printn(ndo, bp, _i, ndo->ndo_snapend)) \
goto trunc; \
ND_PRINT("\""); \
bp += ((_i + sizeof(uint32_t) - 1) / sizeof(uint32_t)) * sizeof(uint32_t); \
} \
s[(MAX)] = '\0'; \
ND_PRINT(" \""); \
- fn_print(ndo, s, NULL); \
+ nd_print(ndo, s, NULL); \
ND_PRINT("\""); \
}
goto finish;
s += n;
ND_PRINT(" +{");
- fn_print(ndo, (u_char *)user, NULL);
+ nd_print(ndo, (u_char *)user, NULL);
ND_PRINT(" ");
ACLOUT(acl);
ND_PRINT("}");
goto finish;
s += n;
ND_PRINT(" -{");
- fn_print(ndo, (u_char *)user, NULL);
+ nd_print(ndo, (u_char *)user, NULL);
ND_PRINT(" ");
ACLOUT(acl);
ND_PRINT("}");
p = elem->data.str;
if (printable) {
ND_PRINT("\"");
- if (fn_printn(ndo, p, asnlen, ndo->ndo_snapend)) {
+ if (nd_printn(ndo, p, asnlen, ndo->ndo_snapend)) {
ND_PRINT("\"");
goto trunc;
}
ND_PRINT("\n\tv3len %u, ", EXTRACT_BE_U_2(ptr + MST_BPDU_VER3_LEN_OFFSET));
ND_TCHECK_4(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 12);
ND_PRINT("MCID Name ");
- if (fn_printzp(ndo, ptr + MST_BPDU_CONFIG_NAME_OFFSET, 32, ndo->ndo_snapend))
+ if (nd_printzp(ndo, ptr + MST_BPDU_CONFIG_NAME_OFFSET, 32, ndo->ndo_snapend))
goto trunc;
ND_PRINT(", rev %u,"
"\n\t\tdigest %08x%08x%08x%08x, ",
ND_PRINT("\n\tv4len %u, ", EXTRACT_BE_U_2(ptr + offset));
ND_PRINT("AUXMCID Name ");
- if (fn_printzp(ndo, ptr + offset + SPB_BPDU_CONFIG_NAME_OFFSET, 32,
+ if (nd_printzp(ndo, ptr + offset + SPB_BPDU_CONFIG_NAME_OFFSET, 32,
ndo->ndo_snapend))
goto trunc;
ND_PRINT(", Rev %u,\n\t\tdigest %08x%08x%08x%08x",
ND_PRINT(" ");
/* Print filename */
ND_PRINT("\"");
- ui = fn_printztn(ndo, bp, length, ndo->ndo_snapend);
+ ui = nd_printztn(ndo, bp, length, ndo->ndo_snapend);
ND_PRINT("\"");
if (ui == 0)
goto trunc;
if (length == 0)
goto trunc; /* no mode */
ND_PRINT(" ");
- ui = fn_printztn(ndo, bp, length, ndo->ndo_snapend);
+ ui = nd_printztn(ndo, bp, length, ndo->ndo_snapend);
if (ui == 0)
goto trunc;
bp += ui;
ND_TCHECK_1(bp);
if (EXTRACT_U_1(bp) != '\0')
ND_PRINT(" ");
- ui = fn_printztn(ndo, bp, length, ndo->ndo_snapend);
+ ui = nd_printztn(ndo, bp, length, ndo->ndo_snapend);
if (ui == 0)
goto trunc;
bp += ui;
ND_TCHECK_1(bp);
if (EXTRACT_U_1(bp) != '\0')
ND_PRINT(" ");
- ui = fn_printztn(ndo, bp, length, ndo->ndo_snapend);
+ ui = nd_printztn(ndo, bp, length, ndo->ndo_snapend);
if (ui == 0)
goto trunc;
bp += ui;
if (length == 0)
goto trunc; /* no error message */
ND_PRINT(" \"");
- ui = fn_printztn(ndo, bp, length, ndo->ndo_snapend);
+ ui = nd_printztn(ndo, bp, length, ndo->ndo_snapend);
ND_PRINT("\"");
if (ui == 0)
goto trunc;
break;
}
ND_PRINT(" name ");
- if (fn_print(ndo, (const u_char *)tsp->tsp_name, (const u_char *)tsp->tsp_name + sizeof(tsp->tsp_name)))
+ if (nd_print(ndo, (const u_char *)tsp->tsp_name, (const u_char *)tsp->tsp_name + sizeof(tsp->tsp_name)))
goto trunc;
return;
case UDLD_PORT_ID_TLV:
case UDLD_DEVICE_NAME_TLV:
ND_PRINT(", ");
- fn_printzp(ndo, tptr, len, NULL);
+ nd_printzp(ndo, tptr, len, NULL);
break;
case UDLD_ECHO_TLV:
ND_PRINT(", ");
- (void)fn_printn(ndo, tptr, len, NULL);
+ (void)nd_printn(ndo, tptr, len, NULL);
break;
case UDLD_MESSAGE_INTERVAL_TLV:
if (version == 2 && auth_type == VRRP_AUTH_SIMPLE) { /* simple text password */
ND_TCHECK_1(bp + 7);
ND_PRINT(" auth \"");
- if (fn_printn(ndo, bp, 8, ndo->ndo_snapend)) {
+ if (nd_printn(ndo, bp, 8, ndo->ndo_snapend)) {
ND_PRINT("\"");
goto trunc;
}
ND_PRINT(" [invalid MgmtD Len %u]", mgmtd_len);
return;
}
- fn_printzp(ndo, tptr + 4, mgmtd_len, NULL);
+ nd_printzp(ndo, tptr + 4, mgmtd_len, NULL);
ND_PRINT(", %s: %u",
tok2str(vtp_header_values, "Unknown", type),
EXTRACT_U_1(tptr + 2));
if (len < 4*((name_len + 3)/4))
goto trunc;
ND_TCHECK_LEN(tptr, name_len);
- fn_printzp(ndo, tptr, name_len, NULL);
+ nd_printzp(ndo, tptr, name_len, NULL);
/*
* Vlan names are aligned to 32-bit boundaries.
cp = (const char *)(io + nid);
if (ND_TTEST_LEN(cp, len)) {
ND_PRINT("\"");
- fn_print(ndo, (const u_char *)cp, (const u_char *)cp + len);
+ nd_print(ndo, (const u_char *)cp, (const u_char *)cp + len);
ND_PRINT("\"");
}
}
/*
- * Print out a null-terminated filename (or other ASCII string).
+ * 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
-fn_print(netdissect_options *ndo,
+nd_print(netdissect_options *ndo,
const u_char *s, const u_char *ep)
{
int ret;
/*
* Print out a null-terminated filename (or other ASCII string) from
- * a fixed-length buffer.
+ * a fixed-length buffer, part of the packet buffer.
* If ep is NULL, assume no truncation check is needed.
* Return the number of bytes of string processed, including the
* terminating null, if not truncated. Return 0 if truncated.
*/
u_int
-fn_printztn(netdissect_options *ndo,
+nd_printztn(netdissect_options *ndo,
const u_char *s, u_int n, const u_char *ep)
{
u_int bytes;
}
/*
- * Print out a counted filename (or other ASCII string).
+ * Print out a counted 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, whichever is first.
*/
int
-fn_printn(netdissect_options *ndo,
+nd_printn(netdissect_options *ndo,
const u_char *s, u_int n, const u_char *ep)
{
u_char c;
}
/*
- * Print out a null-padded filename (or other ASCII string).
+ * 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.
*/
int
-fn_printzp(netdissect_options *ndo,
+nd_printzp(netdissect_options *ndo,
const u_char *s, u_int n,
const u_char *ep)
{