Use more the EXTRACT_8BITS() macro to fetch a one-byte value (22/n)

In ND_PRINT() macro calls, *p++.

Partial list.
This commit is contained in:
Francois-Xavier Le Bail 2017-11-22 15:27:53 +01:00
parent 6d78d5e47c
commit 01cd3621f1
7 changed files with 28 additions and 14 deletions

View File

@ -342,8 +342,10 @@ cdp_print_addr(netdissect_options *ndo,
if (p + pl > endp)
goto trunc;
ND_PRINT((ndo, "pt=0x%02x, pl=%d, pb=", EXTRACT_8BITS((p - 2)), pl));
while (pl-- > 0)
ND_PRINT((ndo, " %02x", *p++));
while (pl-- > 0) {
ND_PRINT((ndo, " %02x", EXTRACT_8BITS(p)));
p++;
}
ND_TCHECK2(*p, 2);
if (p + 2 > endp)
goto trunc;
@ -352,8 +354,10 @@ cdp_print_addr(netdissect_options *ndo,
ND_TCHECK2(*p, al);
if (p + al > endp)
goto trunc;
while (al-- > 0)
ND_PRINT((ndo, " %02x", *p++));
while (al-- > 0) {
ND_PRINT((ndo, " %02x", EXTRACT_8BITS(p)));
p++;
}
}
num--;
if (num)

View File

@ -617,7 +617,8 @@ print_lladdr(netdissect_options *ndo, const uint8_t *p, size_t l)
while (l > 0 && q < ep) {
if (q > p)
ND_PRINT((ndo,":"));
ND_PRINT((ndo,"%02x", *q++));
ND_PRINT((ndo,"%02x", EXTRACT_8BITS(q)));
q++;
l--;
}
}

View File

@ -203,10 +203,12 @@ krb4_print(netdissect_options *ndo,
case AUTH_MSG_APPL_REQUEST:
cp += 2;
ND_TCHECK(*cp);
ND_PRINT((ndo, "v%d ", *cp++));
ND_PRINT((ndo, "v%d ", EXTRACT_8BITS(cp)));
cp++;
PRINT;
ND_TCHECK(*cp);
ND_PRINT((ndo, " (%d)", *cp++));
ND_PRINT((ndo, " (%d)", EXTRACT_8BITS(cp)));
cp++;
ND_TCHECK(*cp);
ND_PRINT((ndo, " (%d)", *cp));
break;

View File

@ -268,7 +268,8 @@ print_string(netdissect_options *ndo, const u_char *dat, u_int length)
{
u_int i;
for (i=0; i<length; i++) {
ND_PRINT((ndo, "%c", *dat++));
ND_PRINT((ndo, "%c", EXTRACT_8BITS(dat)));
dat++;
}
}
@ -277,7 +278,8 @@ print_octets(netdissect_options *ndo, const u_char *dat, u_int length)
{
u_int i;
for (i=0; i<length; i++) {
ND_PRINT((ndo, "%02x", *dat++));
ND_PRINT((ndo, "%02x", EXTRACT_8BITS(dat)));
dat++;
}
}

View File

@ -367,8 +367,10 @@ remove_addr_print(netdissect_options *ndo,
opt_len -= 3;
ND_PRINT((ndo, " id"));
while (opt_len--)
ND_PRINT((ndo, " %u", *addr_id++));
while (opt_len--) {
ND_PRINT((ndo, " %u", EXTRACT_8BITS(addr_id)));
addr_id++;
}
return 1;
}

View File

@ -883,7 +883,8 @@ handle_chap(netdissect_options *ndo,
ND_PRINT((ndo, ", Value "));
for (i = 0; i < val_size; i++) {
ND_TCHECK(*p);
ND_PRINT((ndo, "%02x", *p++));
ND_PRINT((ndo, "%02x", EXTRACT_8BITS(p)));
p++;
}
name_size = len - (p - p0);
ND_PRINT((ndo, ", Name "));

View File

@ -685,8 +685,10 @@ smb_fdata1(netdissect_options *ndo,
{
int l = atoi(fmt + 1);
ND_TCHECK2(*buf, l);
while (l--)
ND_PRINT((ndo, "%02x", *buf++));
while (l--) {
ND_PRINT((ndo, "%02x", EXTRACT_8BITS(buf)));
buf++;
}
fmt++;
while (isdigit((unsigned char)*fmt))
fmt++;