- /* Save the dst mac address */
- clib_memcpy (dst_mac_address, eth0->dst_address, sizeof (dst_mac_address));
-
- vec_insert (buffers, 1, 0);
- buffers[0] = pi0;
-
- for (i = 0; i < vec_len (buffers); i++)
- {
- b0 = vlib_get_buffer (vm, buffers[i]);
- arp0 = vlib_buffer_get_current (b0);
-
- hi = vnet_get_sup_hw_interface (vnm, input_sw_if_index);
- si = vnet_get_sw_interface (vnm, input_sw_if_index);
-
- /* For decoration, most likely */
- vnet_buffer (b0)->sw_if_index[VLIB_TX] = hi->sw_if_index;
-
- /* Fix ARP pkt src address */
- clib_memcpy (arp0->ip4_over_ethernet[0].ethernet, hi->hw_address, 6);
-
- /* Build L2 encaps for this swif */
- header_size = sizeof (ethernet_header_t);
- if (si->sub.eth.flags.one_tag)
- header_size += 4;
- else if (si->sub.eth.flags.two_tags)
- header_size += 8;
-
- vlib_buffer_advance (b0, -header_size);
- eth0 = vlib_buffer_get_current (b0);
-
- if (si->sub.eth.flags.one_tag)
- {
- ethernet_vlan_header_t *outer = (void *) (eth0 + 1);
-
- eth0->type = si->sub.eth.flags.dot1ad ?
- clib_host_to_net_u16 (ETHERNET_TYPE_DOT1AD) :
- clib_host_to_net_u16 (ETHERNET_TYPE_VLAN);
- outer->priority_cfi_and_id =
- clib_host_to_net_u16 (si->sub.eth.outer_vlan_id);
- outer->type = clib_host_to_net_u16 (ETHERNET_TYPE_ARP);
-
- }
- else if (si->sub.eth.flags.two_tags)
- {
- ethernet_vlan_header_t *outer = (void *) (eth0 + 1);
- ethernet_vlan_header_t *inner = (void *) (outer + 1);
-
- eth0->type = si->sub.eth.flags.dot1ad ?
- clib_host_to_net_u16 (ETHERNET_TYPE_DOT1AD) :
- clib_host_to_net_u16 (ETHERNET_TYPE_VLAN);
- outer->priority_cfi_and_id =
- clib_host_to_net_u16 (si->sub.eth.outer_vlan_id);
- outer->type = clib_host_to_net_u16 (ETHERNET_TYPE_VLAN);
- inner->priority_cfi_and_id =
- clib_host_to_net_u16 (si->sub.eth.inner_vlan_id);
- inner->type = clib_host_to_net_u16 (ETHERNET_TYPE_ARP);
-
- }
- else
- {
- eth0->type = clib_host_to_net_u16 (ETHERNET_TYPE_ARP);
- }
-
- /* Restore the original dst address, set src address */
- clib_memcpy (eth0->dst_address, dst_mac_address,
- sizeof (eth0->dst_address));
- clib_memcpy (eth0->src_address, hi->hw_address,
- sizeof (eth0->src_address));
-
- /* Transmit replicas */
- if (i > 0)
- {
- vlib_frame_t *f =
- vlib_get_frame_to_node (vm, hi->output_node_index);
- u32 *to_next = vlib_frame_vector_args (f);
- to_next[0] = buffers[i];
- f->n_vectors = 1;
- vlib_put_frame_to_node (vm, hi->output_node_index, f);
- }
- }
-
- /* The regular path outputs the original pkt.. */
- vnet_buffer (p0)->sw_if_index[VLIB_TX] = input_sw_if_index;
-
- vec_free (buffers);
-