- if (family == 0xFFFF) { /* 16 bytes authentication ? */
- if (EXTRACT_16BITS(&ni->rip_tag) == 2) { /* simple text authentication ? */
- memcpy(buf, &ni->rip_dest, sizeof(buf));
- buf[sizeof(buf)-1] = '\0';
- for (p = buf; *p; p++) {
- if (!isprint(*p))
- break;
- }
- printf("\n\t Simple Text Authentication data: %s", buf);
- } else {
- printf("\n\t Unknown (%u) Authentication data:",
- EXTRACT_16BITS(&ni->rip_tag));
- print_unknown_data((u_int8_t *)&ni->rip_dest,"\n\t ",RIP_AUTHLEN);
+ if (family == 0xFFFF) { /* variable-sized authentication structures */
+ uint16_t auth_type = EXTRACT_16BITS(&ni->rip_tag);
+ if (auth_type == 2) {
+ register const u_char *p = (const u_char *)&ni->rip_dest;
+ u_int i = 0;
+ ND_PRINT((ndo, "\n\t Simple Text Authentication data: "));
+ for (; i < RIP_AUTHLEN; p++, i++)
+ ND_PRINT((ndo, "%c", ND_ISPRINT(*p) ? *p : '.'));
+ } else if (auth_type == 3) {
+ ND_PRINT((ndo, "\n\t Auth header:"));
+ ND_PRINT((ndo, " Packet Len %u,", EXTRACT_16BITS((const uint8_t *)ni + 4)));
+ ND_PRINT((ndo, " Key-ID %u,", *((const uint8_t *)ni + 6)));
+ ND_PRINT((ndo, " Auth Data Len %u,", *((const uint8_t *)ni + 7)));
+ ND_PRINT((ndo, " SeqNo %u,", EXTRACT_32BITS(&ni->rip_dest_mask)));
+ ND_PRINT((ndo, " MBZ %u,", EXTRACT_32BITS(&ni->rip_router)));
+ ND_PRINT((ndo, " MBZ %u", EXTRACT_32BITS(&ni->rip_metric)));
+ } else if (auth_type == 1) {
+ ND_PRINT((ndo, "\n\t Auth trailer:"));
+ print_unknown_data(ndo, (const uint8_t *)&ni->rip_dest, "\n\t ", remaining);
+ return remaining; /* AT spans till the packet end */
+ } else {
+ ND_PRINT((ndo, "\n\t Unknown (%u) Authentication data:",
+ EXTRACT_16BITS(&ni->rip_tag)));
+ print_unknown_data(ndo, (const uint8_t *)&ni->rip_dest, "\n\t ", remaining);