tfStartIke
Table of Contents >> IPsec/IKE Programmer's Reference >> IPsec/IKE Function Reference
| #include <trsocket.h> |
| int tfStartIke | ( |
| unsigned int ipaddrType, | |
| unsigned int ipaddrLength, | |
| ttUserVoidPtr ipaddrPtr, | |
| ttUserInterface interfaceHandle | |
| ); | |
| Conditional parameter. See details in Parameters below. | |
Function Description
If IKE is required, either tfStartIke() or tfStartEnhancedIke() must be called after tfOpenInterface() (or tfNgOpenInterface() for IPv6). If the ID in IKE phase 1 exchange is the same as the IP address we run IKE, tfStartIke() is used. Otherwise, if ID is anything other than the IP address we run IKE, tfStartEnhancedIke() should be used. tfStartIke() gets the identification (the IP address) of IKE participant, allocates and initializes the IKE global variable tvIkePtr, opens an IKE socket with port 500, registers a callback function (internal) to the IKE socket for the receiving event, and starts refreshing the cookie secret pool regularly.
Parameters
- ipaddrType
- Identification IP address type of Treck IKE participant. It could be: TM_DOI_ID_IPV4_ADDR, a single four-octet IPv4 address, or TM_DOI_ID_IPV6_ADDR, a single sixteen-octets IPv6 address.
- ipaddrLength
- The length of identification.
- ipaddrPtr
- If ipaddrType is TM_DOI_ID_IPV4_ADDR, it points to the four-octet IPv4 address (in network-byte order). If ipaddrType is TM_DOI_ID_IPV6_ADDR, it points to the sixteen-octet IPv6 address (in network-byte order).
- interfaceHandle
- Restrict IKE packet traffic to the specified interface. Specify (ttUserInterface)0 to allow traffic on all interfaces. NOTE: This parameter is conditional and only present when macro TM_USE_STRONG_ESL is defined at compile time. For more information, please see Appendix C: Strong End System Model / Weak End System Model.
Returns
- TM_ENOERROR
- Success.
- TM_EIPSECNOTINITIALIZED
- TM_USE_IKE is not defined.
- TM_EALREADY
- IKE global variable tvIkePtr is not NULL before this call.
- TM_ENOBUFS
- No more buffers available.
- Other Errors
- Most likely a socket error. The user can call tfStrError(errorCode) to get a string representation of the error code.
Example
This example starts IKE using identification type TM_DOI_ID_IPV4_ADDR "1.1.1.1"
{ ... ttUserIpAddress clientIpAddr = inet_addr("1.1.1.1"); ttUserIpAddress mask = inet_addr("255.255.255.0"); /* start treck */ errorCode = tfStartTreck(); if (errorCode != TM_ENOERROR) { } ... /* Initialize IPsec global variables */ #ifdef TM_USE_IPSEC errorCode = tfUseIpsec(); if (errorCode != TM_ENOERROR) { } #endif /* TM_USE_IPSEC*/ /* Open the added Loop back interface */ errorCode = tfOpenInterface( ...); #ifdef TM_USE_IKE errorCode = tfStartIke(TM_DOI_ID_IPV4_ADDR, 4, (void*)&clientIpAddr); if (errorCode != TM_ENOERROR) { } #endif /* TM_USE_IKE*/ ... }
Table of Contents >> IPsec/IKE Programmer's Reference >> IPsec/IKE Function Reference