ua_architecture.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  2. * See http://creativecommons.org/publicdomain/zero/1.0/ for more information.
  3. *
  4. * Copyright 2016-2017 (c) Julius Pfrommer, Fraunhofer IOSB
  5. * Copyright 2017 (c) Stefan Profanter, fortiss GmbH
  6. */
  7. #ifndef PLUGINS_ARCH_VXWORKS_UA_ARCHITECTURE_H_
  8. #define PLUGINS_ARCH_VXWORKS_UA_ARCHITECTURE_H_
  9. #include <../deps/queue.h> //in some compilers there's already a _SYS_QUEUE_H_ who is included first and doesn't have all functions
  10. #include <errno.h>
  11. #include <arpa/inet.h>
  12. #include <netinet/in.h>
  13. #include <netdb.h>
  14. #include <sys/ioctl.h>
  15. #include <hostLib.h>
  16. #include <selectLib.h>
  17. #define UA_sleep_ms(X) \
  18. { \
  19. struct timespec timeToSleep; \
  20. timeToSleep.tv_sec = X / 1000; \
  21. timeToSleep.tv_nsec = 1000000 * (X % 1000); \
  22. nanosleep(&timeToSleep, NULL); \
  23. }
  24. #define OPTVAL_TYPE int
  25. #include <fcntl.h>
  26. #include <unistd.h> // read, write, close
  27. #include <netinet/tcp.h>
  28. #define UA_fd_set(fd, fds) FD_SET((unsigned int)fd, fds)
  29. #define UA_fd_isset(fd, fds) FD_ISSET((unsigned int)fd, fds)
  30. #define UA_IPV6 1
  31. #define UA_SOCKET int
  32. #define UA_INVALID_SOCKET -1
  33. #define UA_ERRNO errno
  34. #define UA_INTERRUPTED EINTR
  35. #define UA_AGAIN EAGAIN
  36. #define UA_EAGAIN EAGAIN
  37. #define UA_WOULDBLOCK EWOULDBLOCK
  38. #define UA_ERR_CONNECTION_PROGRESS EINPROGRESS
  39. #include "ua_types.h"
  40. #define ua_getnameinfo getnameinfo
  41. #define ua_send send
  42. #define ua_recv recv
  43. #define ua_close close
  44. #define ua_select select
  45. #define ua_shutdown shutdown
  46. #define ua_socket socket
  47. #define ua_bind bind
  48. #define ua_listen listen
  49. #define ua_accept accept
  50. #define ua_connect connect
  51. #define ua_translate_error gai_strerror
  52. #define ua_getaddrinfo getaddrinfo
  53. #define ua_getsockopt getsockopt
  54. #define ua_setsockopt setsockopt
  55. #define ua_freeaddrinfo freeaddrinfo
  56. static UA_INLINE uint32_t socket_set_blocking(UA_SOCKET sockfd){
  57. int on = FALSE;
  58. if(ioctl(sockfd, FIONBIO, &on) < 0)
  59. return UA_STATUSCODE_BADINTERNALERROR;
  60. return UA_STATUSCODE_GOOD;
  61. }
  62. static UA_INLINE uint32_t socket_set_nonblocking(UA_SOCKET sockfd){
  63. int on = TRUE;
  64. if(ioctl(sockfd, FIONBIO, &on) < 0)
  65. return UA_STATUSCODE_BADINTERNALERROR;
  66. return UA_STATUSCODE_GOOD;
  67. }
  68. #include <stdio.h>
  69. #define ua_snprintf snprintf
  70. static UA_INLINE void ua_initialize_architecture_network(void){
  71. return;
  72. }
  73. static UA_INLINE void ua_deinitialize_architecture_network(void){
  74. return;
  75. }
  76. #endif /* PLUGINS_ARCH_VXWORKS_UA_ARCHITECTURE_H_ */