networklayer.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. pthread_t listenerThreadHandle;
  32. UA_list_List connections;
  33. fd_set readerHandles;
  34. int maxReaderHandle;
  35. } NL_data;
  36. struct T_NL_connection;
  37. typedef void* (*NL_reader)(struct T_NL_connection *c);
  38. typedef struct T_NL_connection {
  39. TL_connection connection;
  40. NL_reader reader;
  41. pthread_t readerThreadHandle;
  42. NL_data* networkLayer;
  43. } NL_connection;
  44. NL_data* NL_init(NL_Description* tlDesc, UA_Int32 port);
  45. UA_Int32 NL_msgLoop(NL_data* nl, struct timeval* tv,UA_Int32 (*timeoutCallBack)(void*),void *arg);
  46. #endif /* NETWORKLAYER_H_ */