NF_EventHandler =================== The client application must implement this interface and pass the object pointer to nf_init function. nfapi code calls the methods of NF_EventHandler from separate thread(s) to indicate the extension notifications. The interface is defined as an abstract class with pure virtual functions for C++. If the symbol _C_API is defined, the interface is a structure with function pointers. *C++ (_C_API is not defined)* .. code-block:: class NF_EventHandler { public: virtual void threadStart() = 0; virtual void threadEnd() = 0; // // TCP events // virtual void tcpConnectRequest(ENDPOINT_ID id, PNF_TCP_CONN_INFO pConnInfo) = 0; virtual void tcpConnected(ENDPOINT_ID id, PNF_TCP_CONN_INFO pConnInfo) = 0; virtual void tcpClosed(ENDPOINT_ID id, PNF_TCP_CONN_INFO pConnInfo) = 0; virtual void tcpReceive(ENDPOINT_ID id, const char * buf, int len) = 0; virtual void tcpSend(ENDPOINT_ID id, const char * buf, int len) = 0; virtual void tcpCanReceive(ENDPOINT_ID id) = 0; virtual void tcpCanSend(ENDPOINT_ID id) = 0; // // UDP events // virtual void udpCreated(ENDPOINT_ID id, PNF_UDP_CONN_INFO pConnInfo) = 0; virtual void udpConnectRequest(ENDPOINT_ID id, PNF_UDP_CONN_REQUEST pConnReq) = 0; virtual void udpClosed(ENDPOINT_ID id, PNF_UDP_CONN_INFO pConnInfo) = 0; virtual void udpReceive(ENDPOINT_ID id, const unsigned char * remoteAddress, const char * buf, int len, PNF_UDP_OPTIONS options) = 0; virtual void udpSend(ENDPOINT_ID id, const unsigned char * remoteAddress, const char * buf, int len, PNF_UDP_OPTIONS options) = 0; virtual void udpCanReceive(ENDPOINT_ID id) = 0; virtual void udpCanSend(ENDPOINT_ID id) = 0; }; *C (_C_API is defined)* .. code-block:: typedef struct _NF_EventHandler { void (NFAPI_CC *threadStart)(); void (NFAPI_CC *threadEnd)(); // // TCP events // void (NFAPI_CC *tcpConnectRequest)(ENDPOINT_ID id, PNF_TCP_CONN_INFO pConnInfo); void (NFAPI_CC *tcpConnected)(ENDPOINT_ID id, PNF_TCP_CONN_INFO pConnInfo); void (NFAPI_CC *tcpClosed)(ENDPOINT_ID id, PNF_TCP_CONN_INFO pConnInfo); void (NFAPI_CC *tcpReceive)(ENDPOINT_ID id, const char * buf, int len); void (NFAPI_CC *tcpSend)(ENDPOINT_ID id, const char * buf, int len); void (NFAPI_CC *tcpCanReceive)(ENDPOINT_ID id); void (NFAPI_CC *tcpCanSend)(ENDPOINT_ID id); // // UDP events // void (NFAPI_CC *udpCreated)(ENDPOINT_ID id, PNF_UDP_CONN_INFO pConnInfo); void (NFAPI_CC *udpConnectRequest)(ENDPOINT_ID id, PNF_UDP_CONN_REQUEST pConnReq); void (NFAPI_CC *udpClosed)(ENDPOINT_ID id, PNF_UDP_CONN_INFO pConnInfo); void (NFAPI_CC *udpReceive)(ENDPOINT_ID id, const unsigned char * remoteAddress, const char * buf, int len, PNF_UDP_OPTIONS options); void (NFAPI_CC *udpSend)(ENDPOINT_ID id, const unsigned char * remoteAddress, const char * buf, int len, PNF_UDP_OPTIONS options); void (NFAPI_CC *udpCanReceive)(ENDPOINT_ID id); void (NFAPI_CC *udpCanSend)(ENDPOINT_ID id); } NF_EventHandler, *PNF_EventHandler; .. cpp:function:: void threadStart() Called immediately after starting the filtering thread. Use this event for thread-specific initialization, e.g. calling CoInitialize() etc. .. cpp:function:: void threadEnd() Called before stopping the thread. .. cpp:function:: void tcpConnectRequest(ENDPOINT_ID id, PNF_TCP_CONN_INFO pConnInfo) :param id: Connection identifier. :param pConnInfo: Connection parameters, see :doc:`ref_NF_TCP_CONN_INFO`. Called before establishing an outgoing TCP connection, when NF_INDICATE_CONNECT_REQUESTS flag is enabled in an appropriate rule. It is possible to modify the fields filteringFlag and remoteAddress in pConnInfo structure. The changes are applied to the connection. .. cpp:function:: void tcpConnected(ENDPOINT_ID id, PNF_TCP_CONN_INFO pConnInfo) :param id: Connection identifier. :param pConnInfo: Connection parameters, see :doc:`ref_NF_TCP_CONN_INFO`. Called after establishing incoming or outgoing TCP connection. .. cpp:function:: void tcpClosed(ENDPOINT_ID id, PNF_TCP_CONN_INFO pConnInfo) :param id: Connection identifier. :param pConnInfo: Connection parameters, see :doc:`ref_NF_TCP_CONN_INFO`. Called after closing a TCP connection. .. cpp:function:: void tcpReceive(ENDPOINT_ID id, const char * buf, int len) :param id: Connection identifier. :param buf: Pointer to data buffer. :param len: Buffer length Indicates the buffer received from server. .. cpp:function:: void tcpSend(ENDPOINT_ID id, const char * buf, int len) :param id: Connection identifier. :param buf: Pointer to data buffer. :param len: Buffer length Indicates the buffer sent from a local socket. .. cpp:function:: void tcpCanReceive(ENDPOINT_ID id) :param id: Connection identifier. Notifies that the internal buffer for inbound packets is empty and it is possible to call nf_tcpPostReceive for pushing receives via specified connection. .. cpp:function:: void tcpCanSend(ENDPOINT_ID id) :param id: Connection identifier. Notifies that the internal buffer for outbound packets is empty and it is possible to call nf_tcpPostSend for pushing sends via specified connection. .. cpp:function:: void udpCreated(ENDPOINT_ID id, PNF_UDP_CONN_INFO pConnInfo) :param id: Socket identifier. :param pConnInfo: Socket parameters, see :doc:`ref_NF_UDP_CONN_INFO`. Called after creating UDP socket. .. cpp:function:: void udpConnectRequest(ENDPOINT_ID id, PNF_UDP_CONN_REQUEST pConnReq) Not used. .. cpp:function:: void udpClosed(ENDPOINT_ID id, PNF_UDP_CONN_INFO pConnInfo) :param id: Socket identifier. :param pConnInfo: Socket parameters, see :doc:`ref_NF_UDP_CONN_INFO`. Called after closing a socket. .. cpp:function:: void udpReceive(ENDPOINT_ID id, const unsigned char * remoteAddress, const char * buf, int len, PNF_UDP_OPTIONS options) :param id: Socket identifier. :param remoteAddress: Source address. :param buf: Pointer to data buffer. :param len: Buffer length. :param options: Pointer to :doc:`ref_NF_UDP_OPTIONS`. Indicates the buffer received from server. .. cpp:function:: void udpSend(ENDPOINT_ID id, const unsigned char * remoteAddress, const char * buf, int len, PNF_UDP_OPTIONS options) :param id: Socket identifier. :param remoteAddress: Source address. :param buf: Pointer to data buffer. :param len: Buffer length. :param options: Pointer to :doc:`ref_NF_UDP_OPTIONS`. Indicates the buffer sent from a local socket. .. cpp:function:: void udpCanReceive(ENDPOINT_ID id) :param id: Socket identifier. Notifies that the internal buffer for inbound packets is empty, and it is possible to call nf_udpPostReceive for indicating receives via specified socket. .. cpp:function:: void udpCanSend(ENDPOINT_ID id) :param id: Socket identifier. Notifies that the internal buffer for outbound packets is empty, and it is possible to call nf_udpPostSend for indicating sends via specified socket.