|
32 | 32 |
|
33 | 33 | #ifndef lint
|
34 | 34 | static const char rcsid[] _U_ =
|
35 |
| - "@(#) $Header: /tcpdump/master/tcpdump/print-aodv.c,v 1.10 2003-11-16 09:36:12 guy Exp $ (LBL)"; |
| 35 | + "@(#) $Header: /tcpdump/master/tcpdump/print-aodv.c,v 1.11 2004-03-24 00:30:19 guy Exp $ (LBL)"; |
36 | 36 | #endif
|
37 | 37 |
|
38 | 38 | #ifdef HAVE_CONFIG_H
|
@@ -143,20 +143,30 @@ aodv_rrep(const union aodv *ap, const u_char *dat, u_int length)
|
143 | 143 | }
|
144 | 144 |
|
145 | 145 | static void
|
146 |
| -aodv_rerr(const union aodv *ap, u_int length) |
| 146 | +aodv_rerr(const union aodv *ap, const u_char *dat, u_int length) |
147 | 147 | {
|
| 148 | + u_int i; |
148 | 149 | const struct rerr_unreach *dp = NULL;
|
149 |
| - int i, j, n, trunc; |
| 150 | + int n, trunc; |
150 | 151 |
|
151 |
| - i = length - offsetof(struct aodv_rerr, r); |
152 |
| - j = sizeof(ap->rerr.r.dest[0]); |
| 152 | + if (snapend < dat) { |
| 153 | + printf(" [|aodv]"); |
| 154 | + return; |
| 155 | + } |
| 156 | + i = min(length, (u_int)(snapend - dat)); |
| 157 | + if (i < offsetof(struct aodv_rerr, r)) { |
| 158 | + printf(" [|rerr]"); |
| 159 | + return; |
| 160 | + } |
| 161 | + i -= offsetof(struct aodv_rerr, r); |
153 | 162 | dp = &ap->rerr.r.dest[0];
|
154 |
| - n = ap->rerr.rerr_dc * j; |
| 163 | + n = ap->rerr.rerr_dc * sizeof(ap->rerr.r.dest[0]); |
155 | 164 | printf(" rerr %s [items %u] [%u]:",
|
156 | 165 | ap->rerr.rerr_flags & RERR_NODELETE ? "[D]" : "",
|
157 | 166 | ap->rerr.rerr_dc, length);
|
158 |
| - trunc = n - (i/j); |
159 |
| - for (; i -= j >= 0; ++dp) { |
| 167 | + trunc = n - (i/sizeof(ap->rerr.r.dest[0])); |
| 168 | + for (; i >= sizeof(ap->rerr.r.dest[0]); |
| 169 | + ++dp, i -= sizeof(ap->rerr.r.dest[0])) { |
160 | 170 | printf(" {%s}(%ld)", ipaddr_string(&dp->u_da),
|
161 | 171 | (unsigned long)EXTRACT_32BITS(&dp->u_ds));
|
162 | 172 | }
|
@@ -416,7 +426,7 @@ aodv_print(const u_char *dat, u_int length, int is_ip6)
|
416 | 426 | if (is_ip6)
|
417 | 427 | aodv_v6_rerr(ap, length);
|
418 | 428 | else
|
419 |
| - aodv_rerr(ap, length); |
| 429 | + aodv_rerr(ap, dat, length); |
420 | 430 | break;
|
421 | 431 |
|
422 | 432 | case AODV_RREP_ACK:
|
|
0 commit comments