This change will print the protocol name even if the length is invalid
or if the packet is truncated at the beginning.
Use nd_print_protocol_caps().
Moreover:
Remove an useless variable.
void
gre_print(netdissect_options *ndo, const u_char *bp, u_int length)
{
void
gre_print(netdissect_options *ndo, const u_char *bp, u_int length)
{
- u_int len = length, vers;
ndo->ndo_protocol = "gre";
ndo->ndo_protocol = "gre";
+ nd_print_protocol_caps(ndo);
+ ND_LCHECK_U(length, 2);
vers = GET_BE_U_2(bp) & GRE_VERS_MASK;
vers = GET_BE_U_2(bp) & GRE_VERS_MASK;
- ND_PRINT("GREv%u",vers);
- gre_print_0(ndo, bp, len);
+ gre_print_0(ndo, bp, length);
- gre_print_1(ndo, bp, len);
+ gre_print_1(ndo, bp, length);
break;
default:
ND_PRINT(" ERROR: unknown-version");
break;
default:
ND_PRINT(" ERROR: unknown-version");