eth.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2015 National Instruments
  4. *
  5. * (C) Copyright 2015
  6. * Joe Hershberger <joe.hershberger@ni.com>
  7. */
  8. #ifndef __ETH_H
  9. #define __ETH_H
  10. void sandbox_eth_disable_response(int index, bool disable);
  11. void sandbox_eth_skip_timeout(void);
  12. /*
  13. * sandbox_eth_arp_req_to_reply()
  14. *
  15. * Check for an arp request to be sent. If so, inject a reply
  16. *
  17. * @dev: device that received the packet
  18. * @packet: pointer to the received pacaket buffer
  19. * @len: length of received packet
  20. * @return 0 if injected, -EAGAIN if not
  21. */
  22. int sandbox_eth_arp_req_to_reply(struct udevice *dev, void *packet,
  23. unsigned int len);
  24. /*
  25. * sandbox_eth_ping_req_to_reply()
  26. *
  27. * Check for a ping request to be sent. If so, inject a reply
  28. *
  29. * @dev: device that received the packet
  30. * @packet: pointer to the received pacaket buffer
  31. * @len: length of received packet
  32. * @return 0 if injected, -EAGAIN if not
  33. */
  34. int sandbox_eth_ping_req_to_reply(struct udevice *dev, void *packet,
  35. unsigned int len);
  36. /**
  37. * A packet handler
  38. *
  39. * dev - device pointer
  40. * pkt - pointer to the "sent" packet
  41. * len - packet length
  42. */
  43. typedef int sandbox_eth_tx_hand_f(struct udevice *dev, void *pkt,
  44. unsigned int len);
  45. /**
  46. * struct eth_sandbox_priv - memory for sandbox mock driver
  47. *
  48. * fake_host_hwaddr - MAC address of mocked machine
  49. * fake_host_ipaddr - IP address of mocked machine
  50. * disabled - Will not respond
  51. * recv_packet_buffer - buffer of the packet returned as received
  52. * recv_packet_length - length of the packet returned as received
  53. * tx_handler - function to generate responses to sent packets
  54. */
  55. struct eth_sandbox_priv {
  56. uchar fake_host_hwaddr[ARP_HLEN];
  57. struct in_addr fake_host_ipaddr;
  58. bool disabled;
  59. uchar *recv_packet_buffer;
  60. int recv_packet_length;
  61. sandbox_eth_tx_hand_f *tx_handler;
  62. };
  63. /*
  64. * Set packet handler
  65. *
  66. * handler - The func ptr to call on send. If NULL, set to default handler
  67. */
  68. void sandbox_eth_set_tx_handler(int index, sandbox_eth_tx_hand_f *handler);
  69. #endif /* __ETH_H */