NF_EventHandler

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

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;
void threadStart()

Called immediately after starting the filtering thread. Use this event for thread-specific initialization.

void threadEnd()

Called before stopping the thread.

void tcpConnectRequest(ENDPOINT_ID id, PNF_TCP_CONN_INFO pConnInfo)
Parameters:
  • id – Connection identifier.

  • pConnInfo – Connection parameters, see NF_TCP_CONN_INFO.

Called before establishing an outgoing TCP connection, when the NF_INDICATE_CONNECT_REQUESTS flag is enabled in the matching rule. It is possible to modify the filteringFlag and remoteAddress fields in the pConnInfo structure. The changes are applied to the connection.

void tcpConnected(ENDPOINT_ID id, PNF_TCP_CONN_INFO pConnInfo)
Parameters:
  • id – Connection identifier.

  • pConnInfo – Connection parameters, see NF_TCP_CONN_INFO.

Called after an incoming or outgoing TCP connection has been established.

void tcpClosed(ENDPOINT_ID id, PNF_TCP_CONN_INFO pConnInfo)
Parameters:
  • id – Connection identifier.

  • pConnInfo – Connection parameters, see NF_TCP_CONN_INFO.

Called after closing a TCP connection.

void tcpReceive(ENDPOINT_ID id, const char *buf, int len)
Parameters:
  • id – Connection identifier.

  • buf – Pointer to data buffer.

  • len – Buffer length

Indicates a buffer received from the server.

void tcpSend(ENDPOINT_ID id, const char *buf, int len)
Parameters:
  • id – Connection identifier.

  • buf – Pointer to data buffer.

  • len – Buffer length

Indicates a buffer sent from a local socket.

void tcpCanReceive(ENDPOINT_ID id)
Parameters:

id – Connection identifier.

Notifies that the internal buffer for inbound packets is empty and that nf_tcpPostReceive can be called to push received data via the specified connection.

void tcpCanSend(ENDPOINT_ID id)
Parameters:

id – Connection identifier.

Notifies that the internal buffer for outbound packets is empty and that nf_tcpPostSend can be called to push data to be sent via the specified connection.

void udpCreated(ENDPOINT_ID id, PNF_UDP_CONN_INFO pConnInfo)
Parameters:
  • id – Socket identifier.

  • pConnInfo – Socket parameters, see NF_UDP_CONN_INFO.

Called after a UDP socket is created.

void udpConnectRequest(ENDPOINT_ID id, PNF_UDP_CONN_REQUEST pConnReq)

Not used.

void udpClosed(ENDPOINT_ID id, PNF_UDP_CONN_INFO pConnInfo)
Parameters:
  • id – Socket identifier.

  • pConnInfo – Socket parameters, see NF_UDP_CONN_INFO.

Called after a socket is closed.

void udpReceive(ENDPOINT_ID id, const unsigned char *remoteAddress, const char *buf, int len, PNF_UDP_OPTIONS options)
Parameters:
  • id – Socket identifier.

  • remoteAddress – Source address.

  • buf – Pointer to data buffer.

  • len – Buffer length.

  • options – Pointer to NF_UDP_OPTIONS.

Indicates a buffer received from the server.

void udpSend(ENDPOINT_ID id, const unsigned char *remoteAddress, const char *buf, int len, PNF_UDP_OPTIONS options)
Parameters:
  • id – Socket identifier.

  • remoteAddress – Source address.

  • buf – Pointer to data buffer.

  • len – Buffer length.

  • options – Pointer to NF_UDP_OPTIONS.

Indicates a buffer sent from a local socket.

void udpCanReceive(ENDPOINT_ID id)
Parameters:

id – Socket identifier.

Notifies that the internal buffer for inbound packets is empty, and that nf_udpPostReceive can be called to indicate receives via the specified socket.

void udpCanSend(ENDPOINT_ID id)
Parameters:

id – Socket identifier.

Notifies that the internal buffer for outbound packets is empty, and that nf_udpPostSend can be called to indicate sends via the specified socket.