+ u32 sw_if_index0, sw_if_index1;
+ ip4_header_t *ip40, *ip41;
+ ip6_header_t *ip60, *ip61;
+ esp_header_t *esp0, *esp1;
+ u32 len0, len1;
+ u16 buf_adv0, buf_adv1;
+ u32 tid0, tid1;
+ ipsec_tunnel_if_t *t0, *t1;
+ ipsec4_tunnel_key_t key40, key41;
+ ipsec6_tunnel_key_t key60, key61;
+
+ if (n_left_from >= 4)
+ {
+ CLIB_PREFETCH (b[2], CLIB_CACHE_LINE_BYTES, STORE);
+ CLIB_PREFETCH (b[2]->data, CLIB_CACHE_LINE_BYTES, LOAD);
+ CLIB_PREFETCH (b[3], CLIB_CACHE_LINE_BYTES, STORE);
+ CLIB_PREFETCH (b[3]->data, CLIB_CACHE_LINE_BYTES, LOAD);
+ }
+
+ ip40 =
+ (ip4_header_t *) (b[0]->data + vnet_buffer (b[0])->l3_hdr_offset);
+ ip41 =
+ (ip4_header_t *) (b[1]->data + vnet_buffer (b[1])->l3_hdr_offset);
+
+ if (is_ip6)
+ {
+ ip60 = (ip6_header_t *) ip40;
+ ip61 = (ip6_header_t *) ip41;
+ esp0 = (esp_header_t *) ((u8 *) ip60 + sizeof (ip6_header_t));
+ esp1 = (esp_header_t *) ((u8 *) ip61 + sizeof (ip6_header_t));
+ buf_adv0 = sizeof (ip6_header_t);
+ buf_adv1 = sizeof (ip6_header_t);
+ }
+ else
+ {
+ /* NAT UDP port 4500 case, don't advance any more */
+ if (ip40->protocol == IP_PROTOCOL_UDP)
+ {
+ esp0 =
+ (esp_header_t *) ((u8 *) ip40 + ip4_header_bytes (ip40) +
+ sizeof (udp_header_t));
+ buf_adv0 = 0;
+ }
+ else
+ {
+ esp0 = (esp_header_t *) ((u8 *) ip40 + ip4_header_bytes (ip40));
+ buf_adv0 = ip4_header_bytes (ip40);
+ }
+ /* NAT UDP port 4500 case, don't advance any more */
+ if (ip41->protocol == IP_PROTOCOL_UDP)
+ {
+ esp1 =
+ (esp_header_t *) ((u8 *) ip41 + ip4_header_bytes (ip41) +
+ sizeof (udp_header_t));
+ buf_adv1 = 0;
+ }
+ else
+ {
+ esp1 = (esp_header_t *) ((u8 *) ip41 + ip4_header_bytes (ip41));
+ buf_adv1 = ip4_header_bytes (ip41);
+ }
+ }
+
+ vlib_buffer_advance (b[0], buf_adv0);
+ vlib_buffer_advance (b[1], buf_adv1);