NF_EventHandler

The client application must implement this interface and pass the object pointer to nf_init function. API code calls the methods of NF_EventHandler from a separate thread to indicate the 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):

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):

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;

Members

void threadStart()
Called immediately after starting the filtering thread. Use this event for thread-specific initialization, e.g. calling CoInitialize() etc.

void threadEnd()
Called before stopping the thread.

void tcpConnectRequest(ENDPOINT_ID id, PNF_TCP_CONN_INFO pConnInfo)
Called before establishing an outgoing TCP connection. It is possible to modify the fields filteringFlag and remoteAddress in pConnInfo structure. The changes are applied to the connection.

Parameters:
id - Connection identifier.
pConnInfo - Connection parameters, see NF_TCP_CONN_INFO.

void tcpConnected(ENDPOINT_ID id, PNF_TCP_CONN_INFO pConnInfo)
Called after establishing incoming or outgoing TCP connection.

Parameters:
id - Connection identifier.
pConnInfo - Connection parameters, see NF_TCP_CONN_INFO.

void tcpClosed(ENDPOINT_ID id, PNF_TCP_CONN_INFO pConnInfo)
Called after closing a TCP connection.

Parameters:
id - Connection identifier.
pConnInfo - Connection parameters, see NF_TCP_CONN_INFO.

void tcpReceive(ENDPOINT_ID id, const char * buf, int len)
Indicates the buffer received from server.

Parameters:
id - Connection identifier.
buf - Pointer to data buffer.
len - Buffer length

void tcpSend(ENDPOINT_ID id, const char * buf, int len)
Indicates the buffer sent from a local socket.

Parameters:
id - Connection identifier.
buf - Pointer to data buffer.
len - Buffer length

void tcpCanReceive(ENDPOINT_ID id)
Notifies that the internal buffer for inbound packets is empty and it is possible to call nf_tcpPostReceive for pushing receives via specified connection.
Parameters:
id - Connection identifier.

void tcpCanSend(ENDPOINT_ID id)
Notifies that the internal buffer for outbound packets is empty and it is possible to call nf_tcpPostSend for pushing sends via specified connection.

Parameters:
id - Connection identifier.

void udpCreated(ENDPOINT_ID id, PNF_UDP_CONN_INFO pConnInfo)
Called after creating UDP socket.

Parameters:
id - Socket identifier.
pConnInfo - Socket parameters, see NF_UDP_CONN_INFO.

void udpConnectRequest(ENDPOINT_ID id, PNF_UDP_CONN_REQUEST pConnReq)
Called before establishing an outgoing UDP connection. It is possible to modify the fields filteringFlag and remoteAddress in pConnInfo structure. The changes are applied to the connection.

Parameters:
id - Connection identifier.
pConnReq - UDP connection parameters, see NF_UDP_CONN_REQUEST.

void udpClosed(ENDPOINT_ID id, PNF_UDP_CONN_INFO pConnInfo)
Called after closing a socket.

Parameters:
id - Socket identifier.
pConnInfo - Socket parameters, see NF_UDP_CONN_INFO.

void udpReceive(ENDPOINT_ID id, const unsigned char * remoteAddress, const char * buf, int len, PNF_UDP_OPTIONS options)
Indicates the buffer received from server.

Parameters:
id - Socket identifier.
remoteAddress - Source address.
buf - Pointer to data buffer.
len - Buffer length.
options - UDP options.

void udpSend(ENDPOINT_ID id, const unsigned char * remoteAddress, const char * buf, int len, PNF_UDP_OPTIONS options)
Indicates the buffer sent from a local socket.

Parameters:
id - Socket identifier.
remoteAddress - Destination address.
buf - Pointer to data buffer.
len - Buffer length.
options - UDP options.

void udpCanReceive(ENDPOINT_ID id)
Notifies that the internal buffer for inbound packets is empty, and it is possible to call nf_udpPostReceive for indicating receives via specified socket.

Parameters:
id - Socket identifier.

void udpCanSend(ENDPOINT_ID id)
Notifies that the internal buffer for outbound packets is empty, and it is possible to call nf_udpPostSend for indicating sends via specified socket.

Parameters:
id - Socket identifier.