- register u_char *p;
- register u_short family;
- char buf[RIP_AUTHLEN];
-
- /* RFC 1723 */
- family = EXTRACT_16BITS(&ni->rip_family);
- if (family == 0xFFFF) {
- if (EXTRACT_16BITS(&ni->rip_tag) == 2) {
- memcpy(buf, &ni->rip_dest, sizeof(buf));
- buf[sizeof(buf)-1] = '\0';
- for (p = buf; *p; p++) {
- if (!isprint(*p))
- break;
- }
- if (!*p) {
- printf(" [password %s]", buf);
- } else {
- printf(" [password: ");
- rip_printblk((u_char *)&ni->rip_dest,
- (u_char *)&ni->rip_metric +
- sizeof(ni->rip_metric));
- printf("]");
- }
+ const struct rip_entry_header *eh = (const struct rip_entry_header *)p;
+ u_short family;
+ const struct rip_netinfo_v2 *ni;
+
+ ND_ICHECKMSG_ZU("remaining data length", remaining, <, sizeof(*eh));
+ ND_TCHECK_SIZE(eh);
+ family = GET_BE_U_2(eh->rip_family);
+ if (family == 0xFFFF) { /* variable-sized authentication structures */
+ uint16_t auth_type = GET_BE_U_2(eh->rip_tag);
+
+ p += sizeof(*eh);
+ remaining -= sizeof(*eh);
+ if (auth_type == 2) {
+ ND_PRINT("\n\t Simple Text Authentication data: ");
+ nd_printjnp(ndo, p, RIP_AUTHLEN);
+ } else if (auth_type == 3) {
+ const struct rip_auth_crypto_v2 *ch;
+
+ ch = (const struct rip_auth_crypto_v2 *)p;
+ ND_ICHECKMSG_ZU("remaining data length", remaining,
+ <, sizeof(*ch));
+ ND_PRINT("\n\t Auth header:");
+ ND_PRINT(" Packet Len %u,",
+ GET_BE_U_2(ch->rip_packet_len));
+ ND_PRINT(" Key-ID %u,", GET_U_1(ch->rip_key_id));
+ ND_PRINT(" Auth Data Len %u,",
+ GET_U_1(ch->rip_auth_data_len));
+ ND_PRINT(" SeqNo %u,", GET_BE_U_4(ch->rip_seq_num));
+ ND_PRINT(" MBZ %u,", GET_BE_U_4(ch->rip_mbz1));
+ ND_PRINT(" MBZ %u", GET_BE_U_4(ch->rip_mbz2));
+ } else if (auth_type == 1) {
+ ND_PRINT("\n\t Auth trailer:");
+ print_unknown_data(ndo, p, "\n\t ", remaining);
+ return (sizeof(*eh) + remaining); /* AT spans till the packet end */