DataHandler (Compact 2013)

3/28/2014

This function is called by the network address translation (NAT) driver for each packet received during a session controlled by a NAT editor.

Syntax

NTSTATUS DataHandler( 
  PVOID InterfaceHandle, 
  PVOID SessionHandle, 
  PVOID DataHandle, 
  PVOID EditorContext, 
  PVOID EditorSessionContext, 
  PIPRCVBUF RecvBuffer, 
  ULONG DataOffset 
)

Parameters

  • InterfaceHandle
    [in] Handle to an interface.
  • SessionHandle
    [in] Handle to the session. Use this handle when calling the QueryInfoSession function.
  • DataHandle
    [in] Handle to the per-packet data context. Use this handle when calling the EditSession function.
  • EditorContext
    [in] Pointer to a context that the NAT editor supplied when the editor called the RegisterEditor function.
  • EditorSessionContext
    [in] Pointer to the context of the session mapping that the editor supplied when the editor called the CreateHandler function.
  • RecvBuffer
    [in] Pointer to an IPRcvBuf structure that specifies the received packet data.
  • DataOffset
    [in] Unsigned long integer that specifies the offset of the protocol data contained in RecvBuffer.

Return Value

STATUS_SUCCESS indicates success. A non-zero value indicates failure.

Remarks

This function is optional. Not all protocol editors need to implement this function.

The following code example shows an example of a DataHandler function.

Important

For readability, the following code example does not contain security checking or error handling. Do not use the following code in a production environment.

NTSTATUS EditorForwardDataHandler(
    IN PVOID InterfaceHandle,
    IN PVOID SessionHandle,
    IN PVOID DataHandle,
    IN PVOID EditorContext,
    IN PVOID EditorSessionContext,
    IN PIPRCVBUF RecvBuffer,
    IN ULONG DataOffset
    )
{
#define BUFFER_LEN  64
PIPRCVBUF pRcvBuf = RecvBuffer;
TCHAR szTextBuffer[BUFFER_LEN];
while (pRcvBuf) 
    {
    _sntprintf(szTextBuffer, BUFFER_LEN, 
              TEXT("    ipr_buf: 0x%X, size: %u\r\n"), 
              pRcvBuf, pRcvBuf->ipr_size);
    szTextBuffer[BUFFER_LEN-1] = TEXT('\0'); // Guarantee null-termination
    OutputDebugString(szTextBuffer);
    pRcvBuf = pRcvBuf->ipr_next;
    }
return STATUS_SUCCESS;
}

Requirements

Header

natedit.h

Library

coredll.dll

See Also

Reference

Network Address Translation Functions
CreateHandler
EditSession
IPRcvBuf
QueryInfoSession
RegisterEditor