- vlib_buffer_advance (i_b0, adv - icv_size);
-
- if (PREDICT_FALSE (is_ipv6))
- { /* is ipv6 */
- ih6_0 = (ip6_and_ah_header_t *) ih0;
- ip_hdr_size = sizeof (ip6_header_t);
- oh6_0 = vlib_buffer_get_current (i_b0);
-
- hop_limit = ih6_0->ip6.hop_limit;
- ip_version_traffic_class_and_flow_label =
- ih6_0->ip6.ip_version_traffic_class_and_flow_label;
- if (PREDICT_TRUE (sa0->is_tunnel))
- {
- next_hdr_type = IP_PROTOCOL_IPV6;
- }
- else
- {
- next_hdr_type = ih6_0->ip6.protocol;
- memmove (oh6_0, ih6_0, sizeof (ip6_header_t));
- }
-
- oh6_0->ip6.protocol = IP_PROTOCOL_IPSEC_AH;
- oh6_0->ip6.hop_limit = 0;
- oh6_0->ip6.ip_version_traffic_class_and_flow_label = 0x60;
- oh6_0->ah.reserved = 0;
- oh6_0->ah.nexthdr = next_hdr_type;
- oh6_0->ah.spi = clib_net_to_host_u32 (sa0->spi);
- oh6_0->ah.seq_no = clib_net_to_host_u32 (sa0->seq);
- oh6_0->ip6.payload_length =
- clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, i_b0) -
- sizeof (ip6_header_t));
- oh6_0->ah.hdrlen =
- (sizeof (ah_header_t) + icv_size + padding_len) / 4 - 2;
- }
- else
- {
- ip_hdr_size = sizeof (ip4_header_t);
- oh0 = vlib_buffer_get_current (i_b0);
- memset (oh0, 0, sizeof (ip4_and_ah_header_t));
-
- if (PREDICT_TRUE (sa0->is_tunnel))
- {
- next_hdr_type = IP_PROTOCOL_IP_IN_IP;
- }
- else
- {
- next_hdr_type = ih0->ip4.protocol;
- memmove (oh0, ih0, sizeof (ip4_header_t));
- }
-
- oh0->ip4.length =
- clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, i_b0));
- oh0->ip4.ip_version_and_header_length = 0x45;
- oh0->ip4.fragment_id = 0;
- oh0->ip4.flags_and_fragment_offset = 0;
- oh0->ip4.ttl = 0;
- oh0->ip4.tos = 0;
- oh0->ip4.protocol = IP_PROTOCOL_IPSEC_AH;
- oh0->ah.spi = clib_net_to_host_u32 (sa0->spi);
- oh0->ah.seq_no = clib_net_to_host_u32 (sa0->seq);
- oh0->ip4.checksum = 0;
- oh0->ah.nexthdr = next_hdr_type;
- oh0->ah.hdrlen =
- (sizeof (ah_header_t) + icv_size + padding_len) / 4 - 2;
- }