1 .\" $KAME: ipsec_set_policy.3,v 1.16 2003/01/06 21:59:03 sumikawa Exp $
3 .\" Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the project nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .Dt IPSEC_SET_POLICY 3
34 .Nm ipsec_dump_policy ,
35 .Nm ipsec_get_policylen ,
37 .Nd manipulate IPsec policy specification structure from human-readable policy string
49 .Fo ipsec_get_policylen
59 generates an IPsec policy specification structure, namely
60 .Li struct sadb_x_policy
62 .Li struct sadb_x_ipsecrequest
63 from a human-readable policy specification.
64 The policy specification must be given as a C string
69 will return a buffer with the corresponding IPsec policy specification structure.
70 The buffer is dynamically allocated, and must be
74 You can get the length of the generated buffer with
75 .Fn ipsec_get_policylen
80 converts an IPsec policy structure into human-readable form.
83 can be regarded as the inverse function to
84 .Fn ipsec_set_policy .
86 points to an IPsec policy structure,
87 .Li struct sadb_x_policy .
89 is a delimiter string, which is usually a blank character.
94 a single whitespace is assumed.
96 returns a pointer to a dynamically allocated string.
97 It is the caller's responsibility to
102 is formatted as either of the following:
103 .Bl -tag -width "discard"
104 .It Ar direction [priority specification] Li discard
112 specifies in which direction the policy needs to be applied.
113 The non-standard direction
117 on platforms which do not support forward policies.
119 .Ar priority specification
120 is used to control the placement of the policy within the SPD.
121 The policy position is determined by
122 a signed integer where higher priorities indicate the policy is placed
123 closer to the beginning of the list and lower priorities indicate the
124 policy is placed closer to the end of the list.
126 priorities are added at the end of the group of such policies.
129 be specified when libipsec has been compiled against kernel headers that
130 support policy priorities (Linux \*[Gt]= 2.6.6).
131 It takes one of the following formats:
132 .Bl -tag -width "discard"
134 .Ar {priority,prio} offset
137 is an integer in the range -2147483647..214783648.
139 .Ar {priority,prio} base {+,-} offset
143 .Li low (-1073741824) ,
146 .Li high (1073741824) .
149 is an unsigned integer.
150 It can be up to 1073741824 for
151 positive offsets, and up to 1073741823 for negative offsets.
154 The interpretation of policy priority in these functions and the
156 The relationship between the two can be described as
157 p(kernel) = 0x80000000 - p(func)
161 policy, packets will be dropped if they match the policy.
162 .It Ar direction [priority specification] Li entrust
164 means to consult the SPD defined by
166 .It Ar direction [priority specification] Li bypass
168 means to bypass the IPsec processing.
169 .Pq the packet will be transmitted in clear .
170 This is for privileged sockets.
173 .Bq Ar priority specification
178 means that the matching packets are subject to IPsec processing.
180 can be followed by one or more
182 strings, which are formatted as below:
183 .Bl -tag -width "discard"
210 specifies the IPsec endpoint.
239 must be set to one of the following:
240 .Li default , use , require ,
244 means that the kernel should consult the system default policy
248 .Li net.inet.ipsec.esp_trans_deflev .
251 regarding the system default.
253 means that a relevant SA can be used when available,
254 since the kernel may perform IPsec operation against packets when possible.
255 In this case, packets can be transmitted in clear
256 .Pq when SA is not available ,
258 .Pq when SA is available .
260 means that a relevant SA is required,
261 since the kernel must perform IPsec operation against packets.
265 but adds the restriction that the SA for outbound traffic is used
266 only for this policy.
267 You may need the identifier in order to relate the policy and the SA
268 when you define the SA by manual keying.
269 You can put the decimal number as the identifier after
272 .Li unique : number .
274 must be between 1 and 32767 .
277 string is kept unambiguous,
282 However, it is encouraged to specify them explicitly
283 to avoid unintended behavior.
286 is omitted, it will be interpreted as
290 Note that there are slight differences to the specification of
292 In the specification of
303 Here are several examples
304 .Pq long lines are wrapped for readability :
305 .Bd -literal -offset indent
307 out ipsec esp/transport//require
308 in ipsec ah/transport//require
309 out ipsec esp/tunnel/10.1.1.2-10.1.1.1/use
310 in ipsec ipcomp/transport//use
316 returns a pointer to the allocated buffer with the policy specification
317 if successful; otherwise a
320 .Fn ipsec_get_policylen
321 returns a positive value
322 .Pq meaning the buffer size
323 on success, and a negative value on errors.
324 .Fn ipsec_dump_policy
325 returns a pointer to a dynamically allocated region on success,
330 .Xr ipsec_strerror 3 ,
334 The functions first appeared in the WIDE/KAME IPv6 protocol stack kit.