- (void)printf(" SA-Response");
- TCHECK(*sp);
- (void)printf(" %d entries", *sp);
- if (*sp * 12 + 8 < len) {
- (void)printf(" [w/data]");
- if (vflag > 1) {
- (void)printf(" ");
- ip_print(sp + *sp * 12 + 8 - 3,
- len - (*sp * 12 + 8));
+ ND_PRINT(" SA-Response");
+
+ /* Entry Count */
+ if (len < 4)
+ goto trunc;
+ entry_count = GET_U_1(sp + 3);
+ ND_PRINT(" %u entries", entry_count);
+
+ /* RP Address */
+ if (len < 8)
+ goto trunc;
+ /* XXX -print this based on ndo_vflag? */
+ ND_TCHECK_LEN(sp + 4, 4);
+
+ /* Entries */
+ ND_TCHECK_LEN(sp + 8, entry_count*12);
+
+ if (len > (8 + entry_count*12)) {
+ /* Encapsulated IP packet */
+ ND_PRINT(" [w/data]");
+ if (ndo->ndo_vflag > 1) {
+ ND_PRINT(" ");
+ ip_print(ndo, sp + (8 + entry_count*12),
+ len - (8 + entry_count*12));