summaryrefslogtreecommitdiffstats
path: root/extras/libmemif/examples/common/packet_handler.c
diff options
context:
space:
mode:
Diffstat (limited to 'extras/libmemif/examples/common/packet_handler.c')
-rw-r--r--extras/libmemif/examples/common/packet_handler.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/extras/libmemif/examples/common/packet_handler.c b/extras/libmemif/examples/common/packet_handler.c
index 705cc728a36..9d3e4d703c1 100644
--- a/extras/libmemif/examples/common/packet_handler.c
+++ b/extras/libmemif/examples/common/packet_handler.c
@@ -47,19 +47,39 @@ icmp_packet_handler (memif_connection_t *c)
{
for (i = 0; i < c->tx_buf_num; i++)
{
- resolve_packet (c->rx_bufs[i].data, c->rx_bufs[i].len,
- c->tx_bufs[i].data, &c->tx_bufs[i].len, c->ip_addr,
- c->hw_addr);
+ uint32_t len;
+ void *packet = c->rx_bufs[i].data;
+
+ memcpy (c->tx_bufs[i].data, c->rx_bufs[i].data, c->rx_bufs[i].len);
+ c->tx_bufs[i].flags = c->rx_bufs[i].flags;
+ len = c->tx_bufs[i].len = c->rx_bufs[i].len;
+
+ while (c->rx_bufs[i].flags & MEMIF_BUFFER_FLAG_NEXT)
+ {
+ i++;
+ memcpy (c->tx_bufs[i].data, c->rx_bufs[i].data,
+ c->rx_bufs[i].len);
+ c->tx_bufs[i].flags = c->rx_bufs[i].flags;
+ len += c->tx_bufs[i].len = c->rx_bufs[i].len;
+ }
+
+ resolve_packet (packet, &len, c->ip_addr, c->hw_addr);
}
}
else
{
for (i = 0; i < c->rx_buf_num; i++)
{
- resolve_packet_zero_copy (c->rx_bufs[i].data, &c->rx_bufs[i].len,
- c->ip_addr, c->hw_addr);
+ uint32_t len = c->rx_bufs[i].len;
+ void *packet = c->rx_bufs[i].data;
+ while (c->rx_bufs[i].flags & MEMIF_BUFFER_FLAG_NEXT)
+ {
+ i++;
+ len += c->rx_bufs[i].len;
+ }
+ resolve_packet (packet, &len, c->ip_addr, c->hw_addr);
}
}
return 0;
-} \ No newline at end of file
+}