ipsec_set_policy

NAME

LIBRARY

SYNOPSIS

n netinet6/ipsec.h

DESCRIPTION

generates an IPsec policy specification structure, namely and/or from a human-readable policy specification. The policy specification must be given as a C string and its length will return a buffer with the corresponding IPsec policy specification structure. The buffer is dynamically allocated, and must be free(3) by the caller.
You can get the length of the generated buffer with (i.e. for calling setsockopt(2)
converts an IPsec policy structure into human-readable form. Therefore, can be regarded as the inverse function to points to an IPsec policy structure, is a delimiter string, which is usually a blank character. If you set to a single whitespace is assumed. returns a pointer to a dynamically allocated string. It is the caller's responsibility to free(3) it.
is formatted as either of the following:
  • discard must be or specifies in which direction the policy needs to be applied. The non-standard direction is substituted with on platforms which do not support forward policies.
is used to control the placement of the policy within the SPD. The policy position is determined by a signed integer where higher priorities indicate the policy is placed closer to the beginning of the list and lower priorities indicate the policy is placed closer to the end of the list. Policies with equal priorities are added at the end of the group of such policies.
Priority can only be specified when libipsec has been compiled against kernel headers that support policy priorities (Linux >= 2.6.6). It takes one of the following formats:
  • Xo is an integer in the range -2147483647..214783648.
  • Xo is either or
is an unsigned integer. It can be up to 1073741824 for positive offsets, and up to 1073741823 for negative offsets.
The interpretation of policy priority in these functions and the kernel DOES differ. The relationship between the two can be described as p(kernel) = 0x80000000 - p(func)
With policy, packets will be dropped if they match the policy.
  • entrust means to consult the SPD defined by setkey(8)
  • bypass means to bypass the IPsec processing.
  • This is for privileged sockets.
  • Xo q Ar priority specification means that the matching packets are subject to IPsec processing. can be followed by one or more strings, which are formatted as below:
    • Xo is either or
  • is either or
    and specifies the IPsec endpoint. always means the and always means the Therefore, when is is this node and is the other node
    If is Both and can be omitted.
    must be set to one of the following: or means that the kernel should consult the system default policy defined by sysctl(8) such as See ipsec(4) regarding the system default. means that a relevant SA can be used when available, since the kernel may perform IPsec operation against packets when possible. In this case, packets can be transmitted in clear
    or encrypted
    means that a relevant SA is required, since the kernel must perform IPsec operation against packets. is the same as 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. You can put the decimal number as the identifier after like must be between 1 and 32767 . If the string is kept unambiguous, and slash prior to can be omitted. However, it is encouraged to specify them explicitly to avoid unintended behavior. If is omitted, it will be interpreted as
    Note that there are slight differences to the specification of setkey(8) In the specification of setkey(8) both and are not used. Refer to setkey(8) for details.
    Here are several examples
    in discard
    out ipsec esp/transport//require
    in ipsec ah/transport//require
    out ipsec esp/tunnel/10.1.1.2-10.1.1.1/use
    in ipsec ipcomp/transport//use
            esp/transport//use
    

    RETURN VALUES

    returns a pointer to the allocated buffer with the policy specification if successful; otherwise a pointer is returned. returns a positive value
    on success, and a negative value on errors. returns a pointer to a dynamically allocated region on success, and on errors.

    SEE ALSO

    HISTORY

    The functions first appeared in the WIDE/KAME IPv6 protocol stack kit.