summaryrefslogtreecommitdiff
path: root/print-ripng.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-12-30 18:24:16 -0800
committerGuy Harris <guy@alum.mit.edu>2017-12-30 18:24:16 -0800
commitc0829e7c05444b1c6c2e4387fc98a7b456209d63 (patch)
tree46b872abdf4ea5fe0b94950e26df46ecaae381b5 /print-ripng.c
parente022dd779979dafd8e9f997d9ce5fbb8d063e252 (diff)
downloadtcpdump-c0829e7c05444b1c6c2e4387fc98a7b456209d63.tar.gz
Use nd_ types, add EXTRACT_ calls.
Diffstat (limited to 'print-ripng.c')
-rw-r--r--print-ripng.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/print-ripng.c b/print-ripng.c
index daf7bd37..bd6fe9b4 100644
--- a/print-ripng.c
+++ b/print-ripng.c
@@ -66,18 +66,18 @@
struct netinfo6 {
struct in6_addr rip6_dest;
- uint16_t rip6_tag;
- uint8_t rip6_plen;
- uint8_t rip6_metric;
+ nd_uint16_t rip6_tag;
+ nd_uint8_t rip6_plen;
+ nd_uint8_t rip6_metric;
};
struct rip6 {
- uint8_t rip6_cmd;
- uint8_t rip6_vers;
- uint8_t rip6_res1[2];
+ nd_uint8_t rip6_cmd;
+ nd_uint8_t rip6_vers;
+ nd_byte rip6_res1[2];
union {
struct netinfo6 ru6_nets[1];
- char ru6_tracefile[1];
+ nd_byte ru6_tracefile[1];
} rip6un;
#define rip6_nets rip6un.ru6_nets
#define rip6_tracefile rip6un.ru6_tracefile
@@ -94,14 +94,17 @@ static int IN6_IS_ADDR_UNSPECIFIED(const struct in6_addr *addr)
#endif
static int
-rip6_entry_print(netdissect_options *ndo, const struct netinfo6 *ni, int metric)
+rip6_entry_print(netdissect_options *ndo, const struct netinfo6 *ni, u_int metric)
{
int l;
- l = ND_PRINT((ndo, "%s/%d", ip6addr_string(ndo, &ni->rip6_dest), ni->rip6_plen));
- if (ni->rip6_tag)
- l += ND_PRINT((ndo, " [%d]", EXTRACT_BE_U_2(&ni->rip6_tag)));
+ uint16_t tag;
+
+ l = ND_PRINT((ndo, "%s/%u", ip6addr_string(ndo, &ni->rip6_dest), EXTRACT_U_1(ni->rip6_plen)));
+ tag = EXTRACT_BE_U_2(ni->rip6_tag);
+ if (tag)
+ l += ND_PRINT((ndo, " [%u]", tag));
if (metric)
- l += ND_PRINT((ndo, " (%d)", ni->rip6_metric));
+ l += ND_PRINT((ndo, " (%u)", metric));
return l;
}
@@ -109,12 +112,14 @@ void
ripng_print(netdissect_options *ndo, const u_char *dat, unsigned int length)
{
const struct rip6 *rp = (const struct rip6 *)dat;
+ uint8_t cmd;
const struct netinfo6 *ni;
unsigned int length_left;
u_int j;
ND_TCHECK(rp->rip6_cmd);
- switch (rp->rip6_cmd) {
+ cmd = EXTRACT_U_1(rp->rip6_cmd);
+ switch (cmd) {
case RIP6_REQUEST:
length_left = length;
@@ -124,7 +129,7 @@ ripng_print(netdissect_options *ndo, const u_char *dat, unsigned int length)
j = length_left / sizeof(*ni);
if (j == 1) {
ND_TCHECK(rp->rip6_nets);
- if (rp->rip6_nets->rip6_metric == HOPCNT_INFINITY6
+ if (EXTRACT_U_1(rp->rip6_nets->rip6_metric) == HOPCNT_INFINITY6
&& IN6_IS_ADDR_UNSPECIFIED(&rp->rip6_nets->rip6_dest)) {
ND_PRINT((ndo, " ripng-req dump"));
break;
@@ -153,9 +158,9 @@ ripng_print(netdissect_options *ndo, const u_char *dat, unsigned int length)
length_left -= (sizeof(struct rip6) - sizeof(struct netinfo6));
j = length_left / sizeof(*ni);
if (j * sizeof(*ni) != length_left)
- ND_PRINT((ndo, " ripng-resp %d[%u]:", j, length));
+ ND_PRINT((ndo, " ripng-resp %u[%u]:", j, length));
else
- ND_PRINT((ndo, " ripng-resp %d:", j));
+ ND_PRINT((ndo, " ripng-resp %u:", j));
for (ni = rp->rip6_nets; length_left >= sizeof(*ni);
length_left -= sizeof(*ni), ++ni) {
ND_TCHECK(*ni);
@@ -163,18 +168,18 @@ ripng_print(netdissect_options *ndo, const u_char *dat, unsigned int length)
ND_PRINT((ndo, "\n\t"));
else
ND_PRINT((ndo, " "));
- rip6_entry_print(ndo, ni, ni->rip6_metric);
+ rip6_entry_print(ndo, ni, EXTRACT_U_1(ni->rip6_metric));
}
if (length_left != 0)
goto trunc;
break;
default:
- ND_PRINT((ndo, " ripng-%d ?? %u", rp->rip6_cmd, length));
+ ND_PRINT((ndo, " ripng-%u ?? %u", cmd, length));
break;
}
ND_TCHECK(rp->rip6_vers);
- if (rp->rip6_vers != RIP6_VERSION)
- ND_PRINT((ndo, " [vers %d]", rp->rip6_vers));
+ if (EXTRACT_U_1(rp->rip6_vers) != RIP6_VERSION)
+ ND_PRINT((ndo, " [vers %u]", EXTRACT_U_1(rp->rip6_vers)));
return;
trunc: