sock.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*!
  2. * Copyright (C) Fraunhofer-Institut for Photonic Microsystems (IPMS)
  3. * Maria-Reiche-Str. 2
  4. * 01109 Dresden
  5. *
  6. * Unauthorized copying of this file, via any medium is strictly prohibited
  7. * Proprietary and confidential
  8. *
  9. * \file sock.h
  10. * \author zimmerli
  11. * \date 2020-01-21
  12. * \brief Ethernet Socket
  13. *
  14. */
  15. #ifndef SOCK_H_
  16. #define SOCK_H_
  17. #include <kernel/base/kernel.h>
  18. #include <kernel/net/netb.h>
  19. #include <kernel/net/netdev.h>
  20. /**
  21. * \brief UDP protocol settings
  22. */
  23. struct udp_proto_s {
  24. uint32_t src_ip_hbo; //!< source ip address, host byte order
  25. uint32_t dst_ip_hbo; //!< destination ip address, host byte order
  26. uint16_t src_port_hbo; //!< source port, host byte order
  27. uint16_t dst_port_hbo; //!< destination port, host byte order
  28. };
  29. /**
  30. * \brief Ethernet socket, rx only
  31. */
  32. struct sock_ethrx_s {
  33. uint16_t ethtype_hbo; //!< Ether type, host byte order
  34. QueueHandle_t queue_rx; //!< rx queue
  35. struct netdev_s *netdev; //!< associated network device, NULL for any
  36. };
  37. /**
  38. * \brief Ethernet socket, tx only
  39. */
  40. struct sock_ethtx_s {
  41. uint16_t ethtype_hbo; //!< Ether type, host byte order
  42. uint16_t vlantag_hbo; //!< VLAN tag, host byte order
  43. struct netdev_s *netdev; //!< associated network device
  44. uint8_t tstamp_id; //!< tx-timestamping channel id, 0 for no timestamping
  45. uint8_t traffic_prio; //!< traffic priority code
  46. };
  47. // layer functions
  48. void socket_rx(struct netdev_s *netdev, struct netb_s *netb);
  49. // socket functions
  50. struct sock_ethrx_s *socket_ethrx(uint16_t ethtype_hbo);
  51. void socket_ethrx_bind(struct sock_ethrx_s *sock, struct netdev_s *device);
  52. struct sock_ethtx_s *socket_ethtx(uint16_t ethtype_hbo);
  53. void socket_ethtx_bind(struct sock_ethtx_s *sock, struct netdev_s *device);
  54. int32_t socket_ethtx_send(struct sock_ethtx_s *sock, void *ptr, uint32_t length, uint8_t *dstmac);
  55. int32_t socket_ethtx_send_udp(struct sock_ethtx_s *sock, struct udp_proto_s *udp, void *ptr, uint32_t length);
  56. #endif /* SOCK_H_ */