networkhandler.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*******************************************************************************
  2. * Copyright (c) 2009, Rockwell Automation, Inc.
  3. * All rights reserved.
  4. *
  5. ******************************************************************************/
  6. #ifndef OPENER_NETWORKHANDLER_H_
  7. #define OPENER_NETWORKHANDLER_H_
  8. #include "typedefs.h"
  9. #define OPENER_SOCKET_WOULD_BLOCK EWOULDBLOCK
  10. /** @brief Executes platform dependent network handler initialization code
  11. *
  12. * @return EipStatusOk if initialization was successful, otherwise EipStatusError
  13. */
  14. EipStatus NetworkHandlerInitializePlatform(void);
  15. /** @brief Platform dependent code to shutdown a stream socket
  16. *
  17. * @param socket_handle The socket to shut down
  18. */
  19. void ShutdownSocketPlatform(int socket_handle);
  20. /** @brief Platform dependent code to close a socket
  21. *
  22. * @param socket_handle The socket handle to be closed
  23. */
  24. void CloseSocketPlatform(int socket_handle);
  25. /** @brief Tries to set socket to non blocking behavior
  26. *
  27. * @param socket_handle The socket handle to be set
  28. *
  29. * @return platform specific result code
  30. */
  31. int SetSocketToNonBlocking(int socket_handle);
  32. /** @brief Returns current time in microseconds from monotonic time base, please note
  33. * that this does not represent a real absolute time, but measured from an arbitrary starting point
  34. *
  35. * This function returns the current time relative to an arbitrary starting point from a monotonic time source.
  36. * As monotonic clocks and clock functions in general are platform dependent, this has to be implemented for each platform
  37. * (see ports subfolders)
  38. *
  39. * @return Current time relative to monotonic clock starting point as MicroSeconds
  40. */
  41. MicroSeconds GetMicroSeconds(void);
  42. /** @brief Returns current time in milliseconds from monotonic time base, please note
  43. * that this does not represent a real absolute time, but measured from an arbitrary starting point
  44. *
  45. * This function returns the current time relative to an arbitrary starting point from a monotonic time source.
  46. * As monotonic clocks and clock functions in general are platform dependent, this has to be implemented for each platform
  47. * (see ports subfolders)
  48. *
  49. * @return Current time relative to monotonic clock starting point as MilliSeconds
  50. */
  51. MilliSeconds GetMilliSeconds(void);
  52. /** @brief Sets QoS on socket
  53. *
  54. * A wrapper function - needs a platform dependent implementation to set QoS on a socket
  55. *
  56. * @param socket The socket which QoS shall be set
  57. * @param qos_value The desired QoS value, as specified in ENIP Vol.2 QoS Object
  58. *
  59. * @return platform dependent result code
  60. *
  61. */
  62. int SetQosOnSocket(const int socket, CipUsint qos_value);
  63. #endif /* OPENER_NETWORKHANDLER_H_ */