You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.4 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __KERNEL_MODULE_ONVIF_OBSERVER_HEADER__
  2. #define __KERNEL_MODULE_ONVIF_OBSERVER_HEADER__
  3. #include "../../components/base/basicEventHeap.h"
  4. #include "../../components/base/basicFunctionality.h"
  5. #include "../../components/base/basicMutex.h"
  6. #include "../../components/base/basicThread.h"
  7. #include "../../data/protocol/xmlParser.h"
  8. #include "kernelModule.h"
  9. #include <arpa/inet.h>
  10. #include <fcntl.h>
  11. #include <ifaddrs.h>
  12. #include <netinet/in.h>
  13. #include <sys/socket.h>
  14. #ifndef __linux__
  15. #pragma warning(disable : 4251)
  16. #endif
  17. #define HTTPMU_HOST_ADDRESS "239.255.255.250"
  18. #define HTTPMU_HOST_PORT 3702
  19. // #define DEBUG_ONVIF_PRINTOUT_MESSAGES
  20. #define DEFAULT_HTTP_PORT 80
  21. typedef std::vector<OBSERVER_RESULT *> vectorOBSERVER_RESULT;
  22. class kernelModuleOnvifObserver;
  23. typedef struct S_PROBE_CTX
  24. {
  25. int AddressID;
  26. char IpAddress[16];
  27. int Port;
  28. int socketFD;
  29. char buff[MAX_BUFF_SIZE + 1];
  30. CSTR send_buff;
  31. CSTR recv_buff;
  32. struct sockaddr_in r_address;
  33. bool bOptVal;
  34. int bOptLen;
  35. int iOptLen;
  36. int RetVal;
  37. int index;
  38. bool isFinished;
  39. kernelModuleOnvifObserver * observer;
  40. } PROBE_CTX;
  41. typedef struct S_OBSERVER_CTX
  42. {
  43. DWORD m_dwThreadID;
  44. #ifdef __linux__
  45. pthread_t m_hThreadHandle;
  46. #else
  47. HANDLE m_hThreadHandle;
  48. #endif
  49. PROBE_CTX * context;
  50. } OBSERVER_CTX;
  51. typedef std::vector<OBSERVER_CTX *> vectorOBSERVER_CTX;
  52. class kernelModuleOnvifObserver : public kernelModule, public basicThread
  53. {
  54. private:
  55. basicEventHeap * m_pEventHeap;
  56. // enumeratorInfo m_vLocalDevices;
  57. // localIpAddresses m_vIpAddresses;
  58. vectorOBSERVER_RESULT m_vResultPool;
  59. basicMutex m_mResultProtector;
  60. basicMutex m_mNIFMUTEX;
  61. vectorCSTR m_vNIFIPS;
  62. bool m_bProbeIsActive;
  63. bool m_bWSAOK;
  64. uint8_t m_bCurrentNIF;
  65. // PROBE_CTX * init_PROBE_CTX( CSTR ADR, int ID );
  66. // bool loadAssignedSources(void);
  67. // bool startProbe( CSTR IP, int ID );
  68. // static void * probeThreadProc(void *);
  69. OBSERVER_RESULT * parseXML(CSTR data);
  70. protected:
  71. virtual void m_fThreadProc(void);
  72. public:
  73. explicit kernelModuleOnvifObserver(uint32_t moduleID);
  74. ~kernelModuleOnvifObserver();
  75. virtual bool reloadSettings();
  76. virtual bool startService();
  77. virtual bool stopService(bool force = false);
  78. virtual bool dispatchEvent(EVENT_CONTAINER * Evt);
  79. virtual bool validate();
  80. };
  81. #endif