1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2015 National Instruments
6 * Joe Hershberger <joe.hershberger@ni.com>
14 void sandbox_eth_disable_response(int index, bool disable);
16 void sandbox_eth_skip_timeout(void);
19 * sandbox_eth_arp_req_to_reply()
21 * Check for an arp request to be sent. If so, inject a reply
23 * @dev: device that received the packet
24 * @packet: pointer to the received pacaket buffer
25 * @len: length of received packet
26 * @return 0 if injected, -EAGAIN if not
28 int sandbox_eth_arp_req_to_reply(struct udevice *dev, void *packet,
32 * sandbox_eth_ping_req_to_reply()
34 * Check for a ping request to be sent. If so, inject a reply
36 * @dev: device that received the packet
37 * @packet: pointer to the received pacaket buffer
38 * @len: length of received packet
39 * @return 0 if injected, -EAGAIN if not
41 int sandbox_eth_ping_req_to_reply(struct udevice *dev, void *packet,
45 * sandbox_eth_recv_arp_req()
47 * Inject an ARP request for this target
49 * @dev: device that received the packet
50 * @return 0 if injected, -EOVERFLOW if not
52 int sandbox_eth_recv_arp_req(struct udevice *dev);
55 * sandbox_eth_recv_ping_req()
57 * Inject a ping request for this target
59 * @dev: device that received the packet
60 * @return 0 if injected, -EOVERFLOW if not
62 int sandbox_eth_recv_ping_req(struct udevice *dev);
67 * dev - device pointer
68 * pkt - pointer to the "sent" packet
71 typedef int sandbox_eth_tx_hand_f(struct udevice *dev, void *pkt,
75 * struct eth_sandbox_priv - memory for sandbox mock driver
77 * fake_host_hwaddr - MAC address of mocked machine
78 * fake_host_ipaddr - IP address of mocked machine
79 * disabled - Will not respond
80 * recv_packet_buffer - buffers of the packet returned as received
81 * recv_packet_length - lengths of the packet returned as received
82 * recv_packets - number of packets returned
83 * tx_handler - function to generate responses to sent packets
84 * priv - a pointer to some structure a test may want to keep track of
86 struct eth_sandbox_priv {
87 uchar fake_host_hwaddr[ARP_HLEN];
88 struct in_addr fake_host_ipaddr;
90 uchar * recv_packet_buffer[PKTBUFSRX];
91 int recv_packet_length[PKTBUFSRX];
93 sandbox_eth_tx_hand_f *tx_handler;
100 * handler - The func ptr to call on send. If NULL, set to default handler
102 void sandbox_eth_set_tx_handler(int index, sandbox_eth_tx_hand_f *handler);
107 * priv - priv void ptr to store in the device
109 void sandbox_eth_set_priv(int index, void *priv);