NF_EventHandler
The client application must implement this interface and pass the object pointer to nf_srv_init function. nfsrvapi code calls the methods of NF_EventHandler from a separate thread to indicate the driver 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 (nfsrv_CC *threadStart)();
void (nfsrv_CC *threadEnd)();
//
// TCP events
//
void (nfsrv_CC *tcpConnectRequest)(ENDPOINT_ID id, PNF_TCP_CONN_INFO pConnInfo);
void (nfsrv_CC *tcpConnected)(ENDPOINT_ID id, PNF_TCP_CONN_INFO pConnInfo);
void (nfsrv_CC *tcpClosed)(ENDPOINT_ID id, PNF_TCP_CONN_INFO pConnInfo);
void (nfsrv_CC *tcpReceive)(ENDPOINT_ID id, const char * buf, int len);
void (nfsrv_CC *tcpSend)(ENDPOINT_ID id, const char * buf, int len);
void (nfsrv_CC *tcpCanReceive)(ENDPOINT_ID id);
void (nfsrv_CC *tcpCanSend)(ENDPOINT_ID id);
//
// UDP events
//
void (nfsrv_CC *udpCreated)(ENDPOINT_ID id, PNF_UDP_CONN_INFO pConnInfo);
void (nfsrv_CC *udpConnectRequest)(ENDPOINT_ID id, PNF_UDP_CONN_REQUEST pConnReq);
void (nfsrv_CC *udpClosed)(ENDPOINT_ID id, PNF_UDP_CONN_INFO pConnInfo);
void (nfsrv_CC *udpReceive)(ENDPOINT_ID id, const unsigned char * remoteAddress, const char * buf, int len, PNF_UDP_OPTIONS options);
void (nfsrv_CC *udpSend)(ENDPOINT_ID id, const unsigned char * remoteAddress, const char * buf, int len, PNF_UDP_OPTIONS options);
void (nfsrv_CC *udpCanReceive)(ENDPOINT_ID id);
void (nfsrv_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 a TCP connection from local proxy. 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 a 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 destination endpoint.
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 source endpoint.
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_srv_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_srv_tcpPostSend for pushing sends via specified connection.
Parameters:
id - Connection identifier.
void udpCreated(ENDPOINT_ID id, PNF_UDP_CONN_INFO pConnInfo)
-
Called after receiving the first UDP packet from source endpoint.
Parameters:
id - Socket identifier.
pConnInfo - Socket parameters, see NF_UDP_CONN_INFO.
void udpConnectRequest(ENDPOINT_ID id, PNF_UDP_CONN_REQUEST pConnReq)
-
This event is not called by server side driver.
-
void udpClosed(ENDPOINT_ID id, PNF_UDP_CONN_INFO pConnInfo)
- Called after closing UDP 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 destination host.
Parameters:
id - Socket identifier.
remoteAddress - Source address.
buf - Pointer to data buffer.
len - Buffer length.
options - UDP options, always NULL with server side driver.
-
void udpSend(ENDPOINT_ID id, const unsigned char * remoteAddress, const char * buf, int len, PNF_UDP_OPTIONS options)
- Indicates the buffer sent from source host.
Parameters:
id - Socket identifier.
remoteAddress - Destination address.
buf - Pointer to data buffer.
len - Buffer length.
options - UDP options, always NULL with server side driver.
-
void udpCanReceive(ENDPOINT_ID id)
- Notifies that the internal buffer for inbound packets is empty, and it is possible to call
nf_srv_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_srv_udpPostSend for indicating sends via specified socket.
Parameters:
id - Socket identifier.
Requirements
Header |
nfsrvapi.h
|
Library |
nfsrvapi.lib |