summaryrefslogtreecommitdiff
path: root/print-dhcp6.c
diff options
context:
space:
mode:
authorFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2018-06-16 17:23:21 +0200
committerFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2019-03-26 21:06:24 +0100
commitee68aa36460d7efeca48747f33b7f2adc0900bfb (patch)
tree72c1b65d29301835c0e064b433ea685fc856a68e /print-dhcp6.c
parent1af20c3adc4dfef93de41d4fcd02f0aeb6bbfd4e (diff)
downloadtcpdump-ee68aa36460d7efeca48747f33b7f2adc0900bfb.tar.gz
Use the new GET_ macros instead of the EXTRACT_ ones
The exceptions are currently: Some EXTRACT_ in print-juniper.c, not used on packet buffer pointer. An EXTRACT_BE_U_3 in addrtoname.c, not always used on packet buffer pointer.
Diffstat (limited to 'print-dhcp6.c')
-rw-r--r--print-dhcp6.c96
1 files changed, 50 insertions, 46 deletions
diff --git a/print-dhcp6.c b/print-dhcp6.c
index 5c8f1516..1dd6e4ea 100644
--- a/print-dhcp6.c
+++ b/print-dhcp6.c
@@ -301,10 +301,10 @@ dhcp6opt_print(netdissect_options *ndo,
goto trunc;
dh6o = (const struct dhcp6opt *)cp;
ND_TCHECK_SIZE(dh6o);
- optlen = EXTRACT_BE_U_2(dh6o->dh6opt_len);
+ optlen = GET_BE_U_2(dh6o->dh6opt_len);
if (ep < cp + sizeof(*dh6o) + optlen)
goto trunc;
- opttype = EXTRACT_BE_U_2(dh6o->dh6opt_type);
+ opttype = GET_BE_U_2(dh6o->dh6opt_type);
ND_PRINT(" (%s", tok2str(dh6opt_str, "opt_%u", opttype));
ND_TCHECK_LEN(cp + sizeof(*dh6o), optlen);
switch (opttype) {
@@ -316,14 +316,15 @@ dhcp6opt_print(netdissect_options *ndo,
break;
}
tp = (const u_char *)(dh6o + 1);
- switch (EXTRACT_BE_U_2(tp)) {
+ switch (GET_BE_U_2(tp)) {
case 1:
if (optlen >= 2 + 6) {
ND_PRINT(" hwaddr/time type %u time %u ",
- EXTRACT_BE_U_2(tp + 2),
- EXTRACT_BE_U_4(tp + 4));
+ GET_BE_U_2(tp + 2),
+ GET_BE_U_4(tp + 4));
for (i = 8; i < optlen; i++)
- ND_PRINT("%02x", EXTRACT_U_1(tp + i));
+ ND_PRINT("%02x",
+ GET_U_1(tp + i));
/*(*/
ND_PRINT(")");
} else {
@@ -335,7 +336,8 @@ dhcp6opt_print(netdissect_options *ndo,
if (optlen >= 2 + 8) {
ND_PRINT(" vid ");
for (i = 2; i < 2 + 8; i++)
- ND_PRINT("%02x", EXTRACT_U_1(tp + i));
+ ND_PRINT("%02x",
+ GET_U_1(tp + i));
/*(*/
ND_PRINT(")");
} else {
@@ -346,9 +348,10 @@ dhcp6opt_print(netdissect_options *ndo,
case 3:
if (optlen >= 2 + 2) {
ND_PRINT(" hwaddr type %u ",
- EXTRACT_BE_U_2(tp + 2));
+ GET_BE_U_2(tp + 2));
for (i = 4; i < optlen; i++)
- ND_PRINT("%02x", EXTRACT_U_1(tp + i));
+ ND_PRINT("%02x",
+ GET_U_1(tp + i));
/*(*/
ND_PRINT(")");
} else {
@@ -357,7 +360,7 @@ dhcp6opt_print(netdissect_options *ndo,
}
break;
default:
- ND_PRINT(" type %u)", EXTRACT_BE_U_2(tp));
+ ND_PRINT(" type %u)", GET_BE_U_2(tp));
break;
}
break;
@@ -370,8 +373,8 @@ dhcp6opt_print(netdissect_options *ndo,
tp = (const u_char *)(dh6o + 1);
ND_PRINT(" %s", ip6addr_string(ndo, tp));
ND_PRINT(" pltime:%u vltime:%u",
- EXTRACT_BE_U_4(tp + 16),
- EXTRACT_BE_U_4(tp + 20));
+ GET_BE_U_4(tp + 16),
+ GET_BE_U_4(tp + 20));
if (optlen > 24) {
/* there are sub-options */
dhcp6opt_print(ndo, tp + 24, tp + optlen);
@@ -387,7 +390,7 @@ dhcp6opt_print(netdissect_options *ndo,
tp = (const u_char *)(dh6o + 1);
for (i = 0; i < optlen; i += 2) {
ND_PRINT(" %s",
- tok2str(dh6opt_str, "opt_%u", EXTRACT_BE_U_2(tp + i)));
+ tok2str(dh6opt_str, "opt_%u", GET_BE_U_2(tp + i)));
}
ND_PRINT(")");
break;
@@ -397,7 +400,7 @@ dhcp6opt_print(netdissect_options *ndo,
break;
}
tp = (const u_char *)(dh6o + 1);
- ND_PRINT(" %u)", EXTRACT_U_1(tp));
+ ND_PRINT(" %u)", GET_U_1(tp));
break;
case DH6OPT_ELAPSED_TIME:
if (optlen != 2) {
@@ -405,7 +408,7 @@ dhcp6opt_print(netdissect_options *ndo,
break;
}
tp = (const u_char *)(dh6o + 1);
- ND_PRINT(" %u)", EXTRACT_BE_U_2(tp));
+ ND_PRINT(" %u)", GET_BE_U_2(tp));
break;
case DH6OPT_RELAY_MSG:
ND_PRINT(" (");
@@ -419,7 +422,7 @@ dhcp6opt_print(netdissect_options *ndo,
break;
}
tp = (const u_char *)(dh6o + 1);
- auth_proto = EXTRACT_U_1(tp);
+ auth_proto = GET_U_1(tp);
switch (auth_proto) {
case DH6OPT_AUTHPROTO_DELAYED:
ND_PRINT(" proto: delayed");
@@ -432,7 +435,7 @@ dhcp6opt_print(netdissect_options *ndo,
break;
}
tp++;
- auth_alg = EXTRACT_U_1(tp);
+ auth_alg = GET_U_1(tp);
switch (auth_alg) {
case DH6OPT_AUTHALG_HMACMD5:
/* XXX: may depend on the protocol */
@@ -443,7 +446,7 @@ dhcp6opt_print(netdissect_options *ndo,
break;
}
tp++;
- auth_rdm = EXTRACT_U_1(tp);
+ auth_rdm = GET_U_1(tp);
switch (auth_rdm) {
case DH6OPT_AUTHRDM_MONOCOUNTER:
ND_PRINT(", RDM: mono");
@@ -455,7 +458,7 @@ dhcp6opt_print(netdissect_options *ndo,
tp++;
ND_PRINT(", RD:");
for (i = 0; i < 4; i++, tp += 2)
- ND_PRINT(" %04x", EXTRACT_BE_U_2(tp));
+ ND_PRINT(" %04x", GET_BE_U_2(tp));
/* protocol dependent part */
authinfolen = optlen - 11;
@@ -472,19 +475,19 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT(", realm: ");
}
for (i = 0; i < authrealmlen; i++, tp++)
- ND_PRINT("%02x", EXTRACT_U_1(tp));
- ND_PRINT(", key ID: %08x", EXTRACT_BE_U_4(tp));
+ ND_PRINT("%02x", GET_U_1(tp));
+ ND_PRINT(", key ID: %08x", GET_BE_U_4(tp));
tp += 4;
ND_PRINT(", HMAC-MD5:");
for (i = 0; i < 4; i++, tp+= 4)
- ND_PRINT(" %08x", EXTRACT_BE_U_4(tp));
+ ND_PRINT(" %08x", GET_BE_U_4(tp));
break;
case DH6OPT_AUTHPROTO_RECONFIG:
if (authinfolen != 17) {
ND_PRINT(" ??");
break;
}
- switch (EXTRACT_U_1(tp)) {
+ switch (GET_U_1(tp)) {
case DH6OPT_AUTHRECONFIG_KEY:
ND_PRINT(" reconfig-key");
break;
@@ -498,7 +501,7 @@ dhcp6opt_print(netdissect_options *ndo,
tp++;
ND_PRINT(" value:");
for (i = 0; i < 4; i++, tp+= 4)
- ND_PRINT(" %08x", EXTRACT_BE_U_4(tp));
+ ND_PRINT(" %08x", GET_BE_U_4(tp));
break;
default:
ND_PRINT(" ??");
@@ -519,7 +522,7 @@ dhcp6opt_print(netdissect_options *ndo,
tp = (const u_char *)(dh6o + 1);
ND_PRINT(" ");
for (i = 0; i < optlen && i < 10; i++)
- ND_PRINT("%02x", EXTRACT_U_1(tp + i));
+ ND_PRINT("%02x", GET_U_1(tp + i));
ND_PRINT("...)");
break;
case DH6OPT_RECONF_MSG:
@@ -528,7 +531,7 @@ dhcp6opt_print(netdissect_options *ndo,
break;
}
tp = (const u_char *)(dh6o + 1);
- dh6_reconf_type = EXTRACT_U_1(tp);
+ dh6_reconf_type = GET_U_1(tp);
switch (dh6_reconf_type) {
case DH6_RENEW:
ND_PRINT(" for renew)");
@@ -577,7 +580,7 @@ dhcp6opt_print(netdissect_options *ndo,
break;
}
tp = (const u_char *)(dh6o + 1);
- ND_PRINT(" %s)", dhcp6stcode(EXTRACT_BE_U_2(tp)));
+ ND_PRINT(" %s)", dhcp6stcode(GET_BE_U_2(tp)));
break;
case DH6OPT_IA_NA:
case DH6OPT_IA_PD:
@@ -587,9 +590,9 @@ dhcp6opt_print(netdissect_options *ndo,
}
tp = (const u_char *)(dh6o + 1);
ND_PRINT(" IAID:%u T1:%u T2:%u",
- EXTRACT_BE_U_4(tp),
- EXTRACT_BE_U_4(tp + 4),
- EXTRACT_BE_U_4(tp + 8));
+ GET_BE_U_4(tp),
+ GET_BE_U_4(tp + 4),
+ GET_BE_U_4(tp + 8));
if (optlen > 12) {
/* there are sub-options */
dhcp6opt_print(ndo, tp + 12, tp + optlen);
@@ -602,7 +605,7 @@ dhcp6opt_print(netdissect_options *ndo,
break;
}
tp = (const u_char *)(dh6o + 1);
- ND_PRINT(" IAID:%u", EXTRACT_BE_U_4(tp));
+ ND_PRINT(" IAID:%u", GET_BE_U_4(tp));
if (optlen > 4) {
/* there are sub-options */
dhcp6opt_print(ndo, tp + 4, tp + optlen);
@@ -615,10 +618,11 @@ dhcp6opt_print(netdissect_options *ndo,
break;
}
tp = (const u_char *)(dh6o + 1);
- ND_PRINT(" %s/%u", ip6addr_string(ndo, tp + 9), EXTRACT_U_1(tp + 8));
+ ND_PRINT(" %s/%u", ip6addr_string(ndo, tp + 9),
+ GET_U_1(tp + 8));
ND_PRINT(" pltime:%u vltime:%u",
- EXTRACT_BE_U_4(tp),
- EXTRACT_BE_U_4(tp + 4));
+ GET_BE_U_4(tp),
+ GET_BE_U_4(tp + 4));
if (optlen > 25) {
/* there are sub-options */
dhcp6opt_print(ndo, tp + 25, tp + optlen);
@@ -632,7 +636,7 @@ dhcp6opt_print(netdissect_options *ndo,
break;
}
tp = (const u_char *)(dh6o + 1);
- ND_PRINT(" %u)", EXTRACT_BE_U_4(tp));
+ ND_PRINT(" %u)", GET_BE_U_4(tp));
break;
case DH6OPT_REMOTE_ID:
if (optlen < 4) {
@@ -640,12 +644,12 @@ dhcp6opt_print(netdissect_options *ndo,
break;
}
tp = (const u_char *)(dh6o + 1);
- ND_PRINT(" %u ", EXTRACT_BE_U_4(tp));
+ ND_PRINT(" %u ", GET_BE_U_4(tp));
/*
* Print hex dump first 10 characters.
*/
for (i = 4; i < optlen && i < 14; i++)
- ND_PRINT("%02x", EXTRACT_U_1(tp + i));
+ ND_PRINT("%02x", GET_U_1(tp + i));
ND_PRINT("...)");
break;
case DH6OPT_LQ_QUERY:
@@ -654,7 +658,7 @@ dhcp6opt_print(netdissect_options *ndo,
break;
}
tp = (const u_char *)(dh6o + 1);
- dh6_lq_query_type = EXTRACT_U_1(tp);
+ dh6_lq_query_type = GET_U_1(tp);
switch (dh6_lq_query_type) {
case 1:
ND_PRINT(" by-address");
@@ -692,7 +696,7 @@ dhcp6opt_print(netdissect_options *ndo,
* Print hex dump first 10 characters.
*/
for (i = 16; i < optlen && i < 26; i++)
- ND_PRINT("%02x", EXTRACT_U_1(tp + i));
+ ND_PRINT("%02x", GET_U_1(tp + i));
ND_PRINT("...)");
break;
case DH6OPT_NTP_SERVER:
@@ -702,9 +706,9 @@ dhcp6opt_print(netdissect_options *ndo,
}
tp = (const u_char *)(dh6o + 1);
while (tp < cp + sizeof(*dh6o) + optlen - 4) {
- subopt_code = EXTRACT_BE_U_2(tp);
+ subopt_code = GET_BE_U_2(tp);
tp += 2;
- subopt_len = EXTRACT_BE_U_2(tp);
+ subopt_len = GET_BE_U_2(tp);
tp += 2;
if (tp + subopt_len > cp + sizeof(*dh6o) + optlen)
goto trunc;
@@ -740,14 +744,14 @@ dhcp6opt_print(netdissect_options *ndo,
remain_len = optlen;
ND_PRINT(" ");
/* Encoding is described in section 3.1 of RFC 1035 */
- while (remain_len && EXTRACT_U_1(tp)) {
- label_len = EXTRACT_U_1(tp);
+ while (remain_len && GET_U_1(tp)) {
+ label_len = GET_U_1(tp);
tp++;
if (label_len < remain_len - 1) {
(void)nd_printn(ndo, tp, label_len, NULL);
tp += label_len;
remain_len -= (label_len + 1);
- if(EXTRACT_U_1(tp)) ND_PRINT(".");
+ if(GET_U_1(tp)) ND_PRINT(".");
} else {
ND_PRINT(" ?");
break;
@@ -805,7 +809,7 @@ dhcp6_print(netdissect_options *ndo,
dh6 = (const struct dhcp6 *)cp;
dh6relay = (const struct dhcp6_relay *)cp;
ND_TCHECK_4(dh6->dh6_msgtypexid.xid);
- msgtype = EXTRACT_U_1(dh6->dh6_msgtypexid.msgtype);
+ msgtype = GET_U_1(dh6->dh6_msgtypexid.msgtype);
name = tok2str(dh6_msgtype_str, "msgtype-%u", msgtype);
if (!ndo->ndo_vflag) {
@@ -818,7 +822,7 @@ dhcp6_print(netdissect_options *ndo,
ND_PRINT(" %s (", name); /*)*/
if (msgtype != DH6_RELAY_FORW && msgtype != DH6_RELAY_REPLY) {
ND_PRINT("xid=%x",
- EXTRACT_BE_U_4(dh6->dh6_msgtypexid.xid) & DH6_XIDMASK);
+ GET_BE_U_4(dh6->dh6_msgtypexid.xid) & DH6_XIDMASK);
extp = (const u_char *)(dh6 + 1);
dhcp6opt_print(ndo, extp, ep);
} else { /* relay messages */