#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
-#include "ether.h"
#include "ethertype.h"
#include "ipproto.h"
#include "oui.h"
return cp;
/* data */
ND_PRINT((ndo, "\n\t data (%u octets)", len));
- ND_TCHECK2(*cp, len);
+ ND_TCHECK_LEN(cp, len);
if (ndo->ndo_vflag >= 2)
hex_and_ascii_print(ndo, "\n\t ", cp, len);
return cp + len;
cp += 4;
break;
default:
- ND_TCHECK2(*cp, len - 4);
+ ND_TCHECK_LEN(cp, len - 4);
cp += len - 4;
}
return cp;
invalid: /* skip the undersized data */
ND_PRINT((ndo, "%s", istr));
- ND_TCHECK2(*cp0, len);
+ ND_TCHECK_LEN(cp0, len);
return cp0 + len;
trunc:
ND_PRINT((ndo, "%s", tstr));
cp += 3;
break;
default:
- ND_TCHECK2(*cp, len - 4);
+ ND_TCHECK_LEN(cp, len - 4);
cp += len - 4;
}
invalid:
ND_PRINT((ndo, "%s", istr));
- ND_TCHECK2(*cp0, len);
+ ND_TCHECK_LEN(cp0, len);
return cp0 + len;
trunc:
ND_PRINT((ndo, "%s", tstr));
invalid: /* skip the undersized data */
ND_PRINT((ndo, "%s", istr));
- ND_TCHECK2(*cp, len);
+ ND_TCHECK_LEN(cp, len);
return cp + len;
trunc:
ND_PRINT((ndo, "%s", tstr));
invalid: /* skip the undersized data */
ND_PRINT((ndo, "%s", istr));
- ND_TCHECK2(*cp, len);
+ ND_TCHECK_LEN(cp, len);
return cp + len;
trunc:
ND_PRINT((ndo, "%s", tstr));
invalid: /* skip the undersized data */
ND_PRINT((ndo, "%s", istr));
- ND_TCHECK2(*cp, len);
+ ND_TCHECK_LEN(cp, len);
return cp + len;
trunc:
ND_PRINT((ndo, "%s", tstr));
ND_PRINT((ndo, "\n\t data (%u octets)", len));
if (ndo->ndo_vflag < 3)
return cp + len;
- ND_TCHECK2(*cp, len);
+ ND_TCHECK_LEN(cp, len);
ndo->ndo_vflag -= 3;
ND_PRINT((ndo, ", frame decoding below\n"));
ether_print(ndo, cp, len, ndo->ndo_snapend - cp, NULL, NULL);
ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_BE_U_2(cp))));
cp += 2;
/* hw_addr */
- ND_TCHECK2(*cp, ETHER_ADDR_LEN);
+ ND_TCHECK_LEN(cp, MAC_ADDR_LEN);
ND_PRINT((ndo, ", hw_addr %s", etheraddr_string(ndo, cp)));
- cp += ETHER_ADDR_LEN;
+ cp += MAC_ADDR_LEN;
/* name */
- ND_TCHECK2(*cp, OFP_MAX_PORT_NAME_LEN);
+ ND_TCHECK_LEN(cp, OFP_MAX_PORT_NAME_LEN);
ND_PRINT((ndo, ", name '"));
fn_print(ndo, cp, cp + OFP_MAX_PORT_NAME_LEN);
ND_PRINT((ndo, "'"));
cp += OFP_MAX_PORT_NAME_LEN;
if (ndo->ndo_vflag < 2) {
- ND_TCHECK2(*cp, 24);
+ ND_TCHECK_LEN(cp, 24);
cp += 24;
goto next_port;
}
invalid: /* skip the undersized trailing data */
ND_PRINT((ndo, "%s", istr));
- ND_TCHECK2(*cp0, len0);
+ ND_TCHECK_LEN(cp0, len0);
return cp0 + len0;
trunc:
ND_PRINT((ndo, "%s", tstr));
skip = 1;
}
if (skip) {
- ND_TCHECK2(*cp, plen - 4);
+ ND_TCHECK_LEN(cp, plen - 4);
cp += plen - 4;
goto next_property;
}
invalid: /* skip the rest of queue properties */
ND_PRINT((ndo, "%s", istr));
- ND_TCHECK2(*cp0, len0);
+ ND_TCHECK_LEN(cp0, len0);
return cp0 + len0;
trunc:
ND_PRINT((ndo, "%s", tstr));
cp += 2;
/* properties */
if (ndo->ndo_vflag < 2) {
- ND_TCHECK2(*cp, desclen - OF_PACKET_QUEUE_LEN);
+ ND_TCHECK_LEN(cp, desclen - OF_PACKET_QUEUE_LEN);
cp += desclen - OF_PACKET_QUEUE_LEN;
goto next_queue;
}
invalid: /* skip the rest of queues */
ND_PRINT((ndo, "%s", istr));
- ND_TCHECK2(*cp0, len0);
+ ND_TCHECK_LEN(cp0, len0);
return cp0 + len0;
trunc:
ND_PRINT((ndo, "%s", tstr));
ND_PRINT((ndo, "%smatch in_port %s", pfx, tok2str(ofpp_str, "%u", EXTRACT_BE_U_2(cp))));
cp += 2;
/* dl_src */
- ND_TCHECK2(*cp, ETHER_ADDR_LEN);
+ ND_TCHECK_LEN(cp, MAC_ADDR_LEN);
if (! (wildcards & OFPFW_DL_SRC))
ND_PRINT((ndo, "%smatch dl_src %s", pfx, etheraddr_string(ndo, cp)));
- cp += ETHER_ADDR_LEN;
+ cp += MAC_ADDR_LEN;
/* dl_dst */
- ND_TCHECK2(*cp, ETHER_ADDR_LEN);
+ ND_TCHECK_LEN(cp, MAC_ADDR_LEN);
if (! (wildcards & OFPFW_DL_DST))
ND_PRINT((ndo, "%smatch dl_dst %s", pfx, etheraddr_string(ndo, cp)));
- cp += ETHER_ADDR_LEN;
+ cp += MAC_ADDR_LEN;
/* dl_vlan */
ND_TCHECK_2(cp);
if (! (wildcards & OFPFW_DL_VLAN))
cp += 1;
/* nw_proto */
ND_TCHECK_1(cp);
- nw_proto = *cp;
+ nw_proto = EXTRACT_U_1(cp);
cp += 1;
if (! (wildcards & OFPFW_NW_PROTO)) {
field_name = ! (wildcards & OFPFW_DL_TYPE) && dl_type == ETHERTYPE_ARP
skip = 1;
}
if (skip) {
- ND_TCHECK2(*cp, alen - 4);
+ ND_TCHECK_LEN(cp, alen - 4);
cp += alen - 4;
goto next_action;
}
case OFPAT_SET_DL_SRC:
case OFPAT_SET_DL_DST:
/* dl_addr */
- ND_TCHECK2(*cp, ETHER_ADDR_LEN);
+ ND_TCHECK_LEN(cp, MAC_ADDR_LEN);
ND_PRINT((ndo, ", dl_addr %s", etheraddr_string(ndo, cp)));
- cp += ETHER_ADDR_LEN;
+ cp += MAC_ADDR_LEN;
/* pad */
ND_TCHECK_6(cp);
cp += 6;
invalid: /* skip the rest of actions */
ND_PRINT((ndo, "%s", istr));
- ND_TCHECK2(*cp0, len0);
+ ND_TCHECK_LEN(cp0, len0);
return cp0 + len0;
trunc:
ND_PRINT((ndo, "%s", tstr));
ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_BE_U_2(cp))));
cp += 2;
/* hw_addr */
- ND_TCHECK2(*cp, ETHER_ADDR_LEN);
+ ND_TCHECK_LEN(cp, MAC_ADDR_LEN);
ND_PRINT((ndo, ", hw_addr %s", etheraddr_string(ndo, cp)));
- cp += ETHER_ADDR_LEN;
+ cp += MAC_ADDR_LEN;
/* config */
ND_TCHECK_4(cp);
ND_PRINT((ndo, "\n\t config 0x%08x", EXTRACT_BE_U_4(cp)));
invalid: /* skip the message body */
ND_PRINT((ndo, "%s", istr));
- ND_TCHECK2(*cp0, len0);
+ ND_TCHECK_LEN(cp0, len0);
return cp0 + len0;
trunc:
ND_PRINT((ndo, "%s", tstr));
if (len != OF_DESC_STATS_LEN)
goto invalid;
/* mfr_desc */
- ND_TCHECK2(*cp, DESC_STR_LEN);
+ ND_TCHECK_LEN(cp, DESC_STR_LEN);
ND_PRINT((ndo, "\n\t mfr_desc '"));
fn_print(ndo, cp, cp + DESC_STR_LEN);
ND_PRINT((ndo, "'"));
cp += DESC_STR_LEN;
/* hw_desc */
- ND_TCHECK2(*cp, DESC_STR_LEN);
+ ND_TCHECK_LEN(cp, DESC_STR_LEN);
ND_PRINT((ndo, "\n\t hw_desc '"));
fn_print(ndo, cp, cp + DESC_STR_LEN);
ND_PRINT((ndo, "'"));
cp += DESC_STR_LEN;
/* sw_desc */
- ND_TCHECK2(*cp, DESC_STR_LEN);
+ ND_TCHECK_LEN(cp, DESC_STR_LEN);
ND_PRINT((ndo, "\n\t sw_desc '"));
fn_print(ndo, cp, cp + DESC_STR_LEN);
ND_PRINT((ndo, "'"));
cp += DESC_STR_LEN;
/* serial_num */
- ND_TCHECK2(*cp, SERIAL_NUM_LEN);
+ ND_TCHECK_LEN(cp, SERIAL_NUM_LEN);
ND_PRINT((ndo, "\n\t serial_num '"));
fn_print(ndo, cp, cp + SERIAL_NUM_LEN);
ND_PRINT((ndo, "'"));
cp += SERIAL_NUM_LEN;
/* dp_desc */
- ND_TCHECK2(*cp, DESC_STR_LEN);
+ ND_TCHECK_LEN(cp, DESC_STR_LEN);
ND_PRINT((ndo, "\n\t dp_desc '"));
fn_print(ndo, cp, cp + DESC_STR_LEN);
ND_PRINT((ndo, "'"));
invalid: /* skip the message body */
ND_PRINT((ndo, "%s", istr));
- ND_TCHECK2(*cp, len);
+ ND_TCHECK_LEN(cp, len);
return cp + len;
trunc:
ND_PRINT((ndo, "%s", tstr));
invalid: /* skip the rest of flow statistics entries */
ND_PRINT((ndo, "%s", istr));
- ND_TCHECK2(*cp0, len0);
+ ND_TCHECK_LEN(cp0, len0);
return cp0 + len0;
trunc:
ND_PRINT((ndo, "%s", tstr));
invalid: /* skip the message body */
ND_PRINT((ndo, "%s", istr));
- ND_TCHECK2(*cp, len);
+ ND_TCHECK_LEN(cp, len);
return cp + len;
trunc:
ND_PRINT((ndo, "%s", tstr));
ND_TCHECK_3(cp);
cp += 3;
/* name */
- ND_TCHECK2(*cp, OFP_MAX_TABLE_NAME_LEN);
+ ND_TCHECK_LEN(cp, OFP_MAX_TABLE_NAME_LEN);
ND_PRINT((ndo, ", name '"));
fn_print(ndo, cp, cp + OFP_MAX_TABLE_NAME_LEN);
ND_PRINT((ndo, "'"));
invalid: /* skip the undersized trailing data */
ND_PRINT((ndo, "%s", istr));
- ND_TCHECK2(*cp0, len0);
+ ND_TCHECK_LEN(cp0, len0);
return cp0 + len0;
trunc:
ND_PRINT((ndo, "%s", tstr));
ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_BE_U_2(cp))));
cp += 2;
if (ndo->ndo_vflag < 2) {
- ND_TCHECK2(*cp, OF_PORT_STATS_LEN - 2);
+ ND_TCHECK_LEN(cp, OF_PORT_STATS_LEN - 2);
cp += OF_PORT_STATS_LEN - 2;
goto next_port;
}
invalid: /* skip the undersized trailing data */
ND_PRINT((ndo, "%s", istr));
- ND_TCHECK2(*cp0, len0);
+ ND_TCHECK_LEN(cp0, len0);
return cp0 + len0;
trunc:
ND_PRINT((ndo, "%s", tstr));
invalid: /* skip the undersized trailing data */
ND_PRINT((ndo, "%s", istr));
- ND_TCHECK2(*cp0, len0);
+ ND_TCHECK_LEN(cp0, len0);
return cp0 + len0;
trunc:
ND_PRINT((ndo, "%s", tstr));
if (decoder != NULL)
return decoder(ndo, cp, ep, len - OF_STATS_REPLY_LEN);
}
- ND_TCHECK2(*cp0, len);
+ ND_TCHECK_LEN(cp0, len);
return cp0 + len;
trunc:
invalid: /* skip the rest of the message body */
ND_PRINT((ndo, "%s", istr));
- ND_TCHECK2(*cp0, len0);
+ ND_TCHECK_LEN(cp0, len0);
return cp0 + len0;
trunc:
ND_PRINT((ndo, "%s", tstr));
invalid: /* skip the message body */
ND_PRINT((ndo, "%s", istr));
next_message:
- ND_TCHECK2(*cp0, len0 - OF_HEADER_LEN);
+ ND_TCHECK_LEN(cp0, len0 - OF_HEADER_LEN);
return cp0 + len0 - OF_HEADER_LEN;
trunc:
ND_PRINT((ndo, "%s", tstr));