Jump to main content

##

# TCPIP_STACK_PacketHandlerRegister Function

## C

    TCPIP_STACK_PROCESS_HANDLE TCPIP_STACK_PacketHandlerRegister(
        TCPIP_NET_HANDLE hNet,
        TCPIP_STACK_PACKET_HANDLER pktHandler,
        const void* handlerParam
    );

## Description

This function registers a new packet processing handler. The caller can use the handler to be notified of incoming packets and given a chance to examine/process them.

## Preconditions

The TCP/IP stack should have been initialized by TCPIP_STACK_Initialize() and the TCPIP_STACK_Status() returned SYS_STATUS_READY. The network interface should be up and running.

## Parameters

Parameters | Description
--- | ---
hNet | Network handle.
pktHandle | The packet handler which will be called for an incoming packet.
handlerParam | Packet handler parameter.

## Returns

- A valid TCPIP_STACK_PROCESS_HANDLE - If the operation succeeded.
- NULL - If the operation failed.

## Remarks

Currently only one packet handler is supported per interface. The call will fail if a handler is already registered. Use TCPIP_STACK_PacketHandlerDeregister() first.

Exists only if TCPIP_STACK_EXTERN_PACKET_PROCESS is true.

## Example

    TCPIP_STACK_PROCESS_HANDLE pktHandle = TCPIP_STACK_PacketHandlerRegister( hNet, myPktHandler, myParam );