2 *------------------------------------------------------------------
3 * Copyright (c) 2020 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *------------------------------------------------------------------
19 #include <icmp_proto.h>
21 /* reply with the same data */
23 basic_packet_handler (memif_connection_t *c)
26 memif_buffer_t *dest, *src;
28 /* in case of zero-copy the tx_buf_num will be zero, so the loop body won't
30 for (i = 0; i < c->tx_buf_num; i++)
32 memcpy (c->tx_bufs[i].data, c->rx_bufs[i].data, c->rx_bufs[i].len);
38 /* ICMPv4 and ARP handler */
40 icmp_packet_handler (memif_connection_t *c)
43 memif_buffer_t *dest, *src;
45 /* if tx_buf_num > 0 we use non-zero-copy mode */
46 if (c->tx_buf_num > 0)
48 for (i = 0; i < c->tx_buf_num; i++)
50 resolve_packet (c->rx_bufs[i].data, c->rx_bufs[i].len,
51 c->tx_bufs[i].data, &c->tx_bufs[i].len, c->ip_addr,
57 for (i = 0; i < c->rx_buf_num; i++)
59 resolve_packet_zero_copy (c->rx_bufs[i].data, &c->rx_bufs[i].len,
60 c->ip_addr, c->hw_addr);