-enum ipsec_sad_flags
-{
- IPSEC_API_SAD_FLAG_NONE = 0,
- /* Enable extended sequence numbers */
- IPSEC_API_SAD_FLAG_USE_ESN = 0x01,
- /* Enable Anti-replay */
- IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY = 0x02,
- /* IPsec tunnel mode if non-zero, else transport mode */
- IPSEC_API_SAD_FLAG_IS_TUNNEL = 0x04,
- /* IPsec tunnel mode is IPv6 if non-zero,
- * else IPv4 tunnel only valid if is_tunnel is non-zero */
- IPSEC_API_SAD_FLAG_IS_TUNNEL_V6 = 0x08,
- /* enable UDP encapsulation for NAT traversal */
- IPSEC_API_SAD_FLAG_UDP_ENCAP = 0x10,
-};
+/** \brief Add or Update Protection for a tunnel with IPSEC
+
+ Tunnel protection directly associates an SA with all packets
+ ingress and egress on the tunnel. This could also be achieved by
+ assigning an SPD to the tunnel, but that would incur an unnessccary
+ SPD entry lookup.
+
+ For tunnels the ESP acts on the post-encapsulated packet. So if this
+ packet:
+ +---------+------+
+ | Payload | O-IP |
+ +---------+------+
+ where O-IP is the overlay IP addrees that was routed into the tunnel,
+ the resulting encapsulated packet will be:
+ +---------+------+------+
+ | Payload | O-IP | T-IP |
+ +---------+------+------+
+ where T-IP is the tunnel's src.dst IP addresses.
+ If the SAs used for protection are in transport mode then the ESP is
+ inserted before T-IP, i.e.:
+ +---------+------+-----+------+
+ | Payload | O-IP | ESP | T-IP |
+ +---------+------+-----+------+
+ If the SAs used for protection are in tunnel mode then another
+ encapsulation occurs, i.e.:
+ +---------+------+------+-----+------+
+ | Payload | O-IP | T-IP | ESP | C-IP |
+ +---------+------+------+-----+------+
+ where C-IP are the crypto endpoint IP addresses defined as the tunnel
+ endpoints in the SA.
+ The mode for the inbound and outbound SA must be the same.