struct ofpbuf *
ofputil_encode_packet_in(const struct ofputil_packet_in *pin)
{
- int total_len = pin->packet->size;
struct ofp_packet_in opi;
struct ofpbuf *rw_packet;
rw_packet = ofpbuf_clone_data_with_headroom(
- pin->packet->data, MIN(pin->send_len, pin->packet->size),
+ pin->packet, MIN(pin->send_len, pin->packet_len),
offsetof(struct ofp_packet_in, data));
/* Add OFPT_PACKET_IN. */
memset(&opi, 0, sizeof opi);
opi.header.version = OFP_VERSION;
opi.header.type = OFPT_PACKET_IN;
- opi.total_len = htons(total_len);
+ opi.total_len = htons(pin->packet_len);
opi.in_port = htons(pin->in_port);
opi.reason = pin->reason;
opi.buffer_id = htonl(pin->buffer_id);
/* Abstract packet-in message. */
struct ofputil_packet_in {
- struct ofpbuf *packet;
+ const void *packet;
+ size_t packet_len;
+
uint16_t in_port;
uint8_t reason; /* One of OFPR_*. */
} else if (!ofconn->pktbuf) {
pin.buffer_id = UINT32_MAX;
} else {
- pin.buffer_id = pktbuf_save(ofconn->pktbuf, pin.packet->data,
- pin.packet->size, flow->in_port);
+ pin.buffer_id = pktbuf_save(ofconn->pktbuf, pin.packet, pin.packet_len,
+ flow->in_port);
}
/* Figure out how much of the packet to send. */
if (pin.reason == OFPR_NO_MATCH) {
- pin.send_len = pin.packet->size;
+ pin.send_len = pin.packet_len;
} else {
/* Caller should have initialized 'send_len' to 'max_len' specified in
* struct ofp_action_output. */
{
struct ofputil_packet_in pin;
- pin.packet = packet;
+ pin.packet = packet->data;
+ pin.packet_len = packet->size;
pin.in_port = flow->in_port;
pin.reason = OFPR_NO_MATCH;
pin.buffer_id = 0; /* not yet known */
memcpy(&cookie, &userdata, sizeof(cookie));
- pin.packet = packet;
+ pin.packet = packet->data;
+ pin.packet_len = packet->size;
pin.in_port = flow->in_port;
pin.reason = OFPR_ACTION;
pin.buffer_id = 0; /* not yet known */