networklayer.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef NETWORKLAYER_H_
  2. #define NETWORKLAYER_H_
  3. #include "opcua.h"
  4. #include "ua_transport.h"
  5. #include "ua_transport_binary.h"
  6. #include "ua_list.h"
  7. #ifdef MULTITHREADING
  8. #include <pthread.h> // pthreadcreate, pthread_t
  9. #endif
  10. #include <sys/select.h> // FD_ZERO, FD_SET
  11. #define NL_MAXCONNECTIONS_DEFAULT 10
  12. enum NL_UA_ENCODING_enum {
  13. NL_UA_ENCODING_BINARY = 0,
  14. NL_UA_ENCODING_XML = 1,
  15. };
  16. enum NL_CONNECTIONTYPE_enum {
  17. NL_CONNECTIONTYPE_TCPV4 = 0,
  18. NL_CONNECTIONTYPE_TCPV6 = 1,
  19. };
  20. typedef struct T_NL_Description {
  21. UA_Int32 encoding;
  22. UA_Int32 connectionType;
  23. UA_Int32 maxConnections;
  24. TL_buffer localConf;
  25. } NL_Description;
  26. extern NL_Description NL_Description_TcpBinary;
  27. typedef struct T_NL_data {
  28. NL_Description* tld;
  29. UA_String endpointUrl;
  30. int listenerHandle;
  31. #ifdef MULTITHREADING
  32. pthread_t listenerThreadHandle;
  33. #endif
  34. UA_list_List connections;
  35. fd_set readerHandles;
  36. int maxReaderHandle;
  37. } NL_data;
  38. struct T_NL_connection;
  39. typedef void* (*NL_reader)(struct T_NL_connection *c);
  40. typedef struct T_NL_connection {
  41. TL_connection connection;
  42. NL_reader reader;
  43. #ifdef MULTITHREADING
  44. pthread_t readerThreadHandle;
  45. #endif
  46. NL_data* networkLayer;
  47. } NL_connection;
  48. NL_data* NL_init(NL_Description* tlDesc, UA_Int32 port);
  49. UA_Int32 NL_msgLoop(NL_data* nl, struct timeval* tv,UA_Int32 (*timeoutCallBack)(void*),void *arg);
  50. #endif /* NETWORKLAYER_H_ */