networklayer.h 1.5 KB

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