eth-raw-os.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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_RAW_OS_H
  9. #define __ETH_RAW_OS_H
  10. #define IFNAMSIZ 16
  11. /**
  12. * struct eth_sandbox_raw_priv - raw socket session
  13. *
  14. * sd: socket descriptor - the open socket during a session
  15. * host_ifname: interface name on the host to use for sending our packets
  16. * host_ifindex: interface index number on the host
  17. * device: struct sockaddr_ll - the host interface packets move to/from
  18. * local: 1 or 0 to select the local interface ('lo') or not
  19. * local_bindsd: socket descriptor to prevent the kernel from sending
  20. * a message to the server claiming the port is
  21. * unreachable
  22. * local_bind_udp_port: The UDP port number that we bound to
  23. */
  24. struct eth_sandbox_raw_priv {
  25. int sd;
  26. char host_ifname[IFNAMSIZ];
  27. unsigned int host_ifindex;
  28. void *device;
  29. int local;
  30. int local_bind_sd;
  31. unsigned short local_bind_udp_port;
  32. };
  33. /*
  34. * Check if the interface named "ifname" is a localhost interface or not.
  35. * ifname - the interface name on the host to check
  36. *
  37. * returns - 0 if real interface, 1 if local, negative if error
  38. */
  39. int sandbox_eth_raw_os_is_local(const char *ifname);
  40. int sandbox_eth_raw_os_start(struct eth_sandbox_raw_priv *priv,
  41. unsigned char *ethmac);
  42. int sandbox_eth_raw_os_send(void *packet, int length,
  43. struct eth_sandbox_raw_priv *priv);
  44. int sandbox_eth_raw_os_recv(void *packet, int *length,
  45. const struct eth_sandbox_raw_priv *priv);
  46. void sandbox_eth_raw_os_stop(struct eth_sandbox_raw_priv *priv);
  47. #endif /* __ETH_RAW_OS_H */