The Fn ipsec_get_policylen function will returns the of the buffer which is needed when passing the specification structure to the setsockopt(2) system call.
The Fn ipsec_dump_policy function converts an IPsec policy structure into a human readable form. The Fa buf argument points to an IPsec policy structure, struct sadb_x_policy Fa delim is a delimiter string, which is usually a blank character. If you set Fa delim to NULL a single white space is assumed. The Fn ipsec_dump_policy function returns a pointer to dynamically allocated string. It is the caller's responsibility to free the returned pointer using the free(3) library call.
A Fa policy is given in the following way:
The mode is either transport or tunnel the meanings of both modes are described in ipsec(4).
The src and dst specify the IP address, either v4 or v6, of the source and destination systems. The src always stands for the ``sending node'' and dst always stands for the ``receiving node'' When direction is in dst is this local node and src is the remote node or peer. If mode is transport both src and dst can be omitted.
The level must be set to one of the following: default , use , require or unique default means that the kernel should consult the default security policies as defined by a set of sysctl(8), variables. The relevant sysctl(8) variables are described in ipsec(4).
When use is selected a relevant security association (SA) can be used when available but is not necessary. If the SA is available then packets will be handled by IPsec, i.e. encrypted and/or authenticated but if an SA is not available then packets will be transmitted in the clear. The use option is not recommended because it allows for accidental mis-configurations where encrypted or authenticated link becomes unencrypted or unauthenticated, the require keyword is recommended instead of use where possible. Using the require keyword means that a relevant SA is required, and that the kernel must perform IPsec processing on all matching packets.
The unique keyword has the same effect as require but adds the restriction that the SA for outbound traffic is used only for this policy. You may need the identifier in order to relate the policy and the SA when you define the SA by manual keying using setkey(8). Put the decimal number as the identifier after the unique keyword in this way: unique : number where number must be between 1 and 32767.
If the request string is kept unambiguous, level and the slash prior to level can be omitted but you are encouraged to specify them explicitly to avoid unintended behaviors. If level is omitted, it will be interpreted as default
Note that there is a difference between the specification allowed here and in setkey(8). When specifying security policies with setkey(8), neither entrust nor bypass are used. Refer to setkey(8) for details.
All outbound packets are required to be processed by IPsec and transported using ESP.in discard
All inbound packets are required to be authenticated using the AH protocol.out ipsec esp/transport//require
Tunnel packets outbound through the endpoints at 10.1.1.2 and 10.1.1.1.in ipsec ah/transport//require
out ipsec esp/tunnel/10.1.1.2-10.1.1.1/require
The Fn ipsec_get_policylen function returns a positive value, indicating the buffer size, on success, and a negative value on error.
The Fn ipsec_dump_policy function returns a pointer to a dynamically allocated region containing a human readable security policy on success, and NULL on error.
IPv6 and IPsec support based on the KAME Project (http://www.kame.net/) stack was initially integrated into Fx 4.0