Add packet utils to packet.h

This commit is contained in:
luwenpeng
2024-04-11 19:44:02 +08:00
parent 84541c40e2
commit 17f5d338de
32 changed files with 615 additions and 558 deletions

View File

@@ -171,8 +171,16 @@ int marsio_io_ingress(struct marsio_io *handle, uint16_t thr_idx, struct packet
continue;
}
pkt = &pkts[nr_parsed];
memset(pkt, 0, sizeof(struct packet));
packet_parse(pkt, data, len);
packet_set_io_ctx(pkt, mbuff);
packet_set_origin(pkt, PACKET_ORIGIN_MARSIO);
nr_parsed++;
if (marsio_buff_is_ctrlbuf(mbuff))
{
packet_set_ctrl(pkt);
ATOMIC_ADD(&handle->stat.ctrl_rx_pkts, 1);
ATOMIC_ADD(&handle->stat.ctrl_rx_bytes, len);
}
@@ -181,12 +189,6 @@ int marsio_io_ingress(struct marsio_io *handle, uint16_t thr_idx, struct packet
ATOMIC_ADD(&handle->stat.raw_rx_pkts, 1);
ATOMIC_ADD(&handle->stat.raw_rx_bytes, len);
}
pkt = &pkts[nr_parsed];
packet_parse(pkt, data, len);
packet_set_io_ctx(pkt, mbuff);
packet_set_action(pkt, PACKET_ACTION_FORWARD);
nr_parsed++;
}
return nr_parsed;