add packet type raw and pseudo

This commit is contained in:
luwenpeng
2024-11-13 14:43:38 +08:00
parent 8349a631e1
commit 492a7fb8ea
10 changed files with 65 additions and 52 deletions

View File

@@ -147,7 +147,14 @@ static void copy_metadata_to_packet(marsio_buff_t *mbuff, struct packet *pkt)
PACKET_IO_LOG_ERROR("failed to get link id");
}
packet_set_ctrl(pkt, marsio_buff_is_ctrlbuf(mbuff));
if (marsio_buff_is_ctrlbuf(mbuff))
{
packet_set_type(pkt, PACKET_TYPE_PSEUDO);
}
else
{
packet_set_type(pkt, PACKET_TYPE_RAW);
}
enum packet_direction direction = PACKET_DIRECTION_OUTGOING;
if (marsio_buff_get_metadata(mbuff, MR_BUFF_DIR, &direction, sizeof(direction)) == sizeof(direction))
@@ -201,7 +208,7 @@ static void copy_metadata_to_mbuff(struct packet *pkt, marsio_buff_t *mbuff)
PACKET_IO_LOG_ERROR("failed to set link id");
}
if (packet_is_ctrl(pkt))
if (packet_get_type(pkt) == PACKET_TYPE_PSEUDO)
{
marsio_buff_set_ctrlbuf(mbuff);
}

View File

@@ -488,6 +488,7 @@ int pcap_io_recv(void *handle, uint16_t thr_idx, struct packet *pkts[], int nr_p
packet_parse(pkt, pcap->data, pcap->len);
memset(&pkt->meta, 0, sizeof(pkt->meta));
packet_set_action(pkt, PACKET_ACTION_FORWARD);
packet_set_type(pkt, PACKET_TYPE_RAW);
packet_set_timeval(pkt, &pcap->ts);
packet_set_origin(pkt, &origin);