tfSadbRecordGet

Jump to: navigation, search

Table of Contents >> IPsec/IKE Programmer's Reference >> IPsec/IKE Function Reference


#include <trsocket.h>


int tfSadbRecordGet (
ttUser32Bit options,
ttSaIdentityPtr saidPtr,
ttSadbRecordPtrPtr sadbPtrPtr
);


Function Description

This function is called to find an SA using the triple <destination address, protocol, SPI>. It is usually called by the INBOUND path where we know the triple value. This function is designed for kernel usage, however, user may call it directly for debugging purpose.


Parameters

  • options
    Zero if the SAD is not locked by the calling procedure, or TM_IPSEC_DATABASE_LOCKED if SAD is already locked by the calling procedure. For manual usage, this is always zero.
  • saidPtr
    Contains the triple value
  • sadbPtrPtr
    For output use. Carries the address of the located SA pointer.


Returns

  • TM_ENOERROR
    SA is successfully located. saPtrPtr contains the SA pointer’s address
  • TM_EWRONGSPI
    SPI value is invalid
  • -1
    SA is not found


Example

This example locates SA which has the triple value of <destination = "1.1.1.1", ESP, SPI=1000>.

 
{
    ttSaIdentity            said;
    ttSadbRecordPtr         saPtr;
    int                     errorCode;
 
    said.siDstSockaddr.ss_family = PF_INET;
    said.siDstSockaddr.ss_len = sizeof(struct sockaddr_in);
    said.siDstSockaddr.addr.ipv4.sin_addr.s_addr = inet_addr("1.1.1.1");
    said.siSpi = 1000;
    said.siProto = TM_IP_ESP;
    errorCOde = tfSadbRecordGet(0, &said, &saPtr);
...
}
 


Table of Contents >> IPsec/IKE Programmer's Reference >> IPsec/IKE Function Reference