# Copyright (c) 2015 Cisco and/or its affiliates. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. lib_LTLIBRARIES += libvnet.la libvnet_la_SOURCES = libvnet_la_DEPENDENCIES = \ libvppinfra.la \ libvlib.la \ libsvmdb.la \ libsvm.la \ libvlibapi.la \ libvlibmemory.la \ libvlibmemoryclient.la libvnet_la_LIBADD = $(libvnet_la_DEPENDENCIES) -lm -lpthread -ldl -lrt if WITH_LIBSSL libvnet_la_LIBADD += -lcrypto endif ######################################## # Generic stuff ######################################## libvnet_la_SOURCES += \ vnet/config.c \ vnet/devices/devices.c \ vnet/handoff.c \ vnet/interface.c \ vnet/interface_api.c \ vnet/interface_cli.c \ vnet/interface_format.c \ vnet/interface_output.c \ vnet/misc.c \ vnet/replication.c \ vnet/rewrite.c nobase_include_HEADERS += \ vnet/api_errno.h \ vnet/buffer.h \ vnet/config.h \ vnet/devices/devices.h \ vnet/global_funcs.h \ vnet/handoff.h \ vnet/interface.h \ vnet/interface.api.h \ vnet/interface_funcs.h \ vnet/l3_types.h \ vnet/pipeline.h \ vnet/replication.h \ vnet/rewrite.h \ vnet/vnet.h \ vnet/vnet_all_api_h.h \ vnet/vnet_msg_enum.h \ vnet/util/radix.h API_FILES += vnet/interface.api ######################################## # Policer infra ######################################## libvnet_la_SOURCES += \ vnet/policer/node_funcs.c \ vnet/policer/policer.c \ vnet/policer/xlate.c \ vnet/policer/policer_api.c nobase_include_HEADERS += \ vnet/policer/police.h \ vnet/policer/policer.h \ vnet/policer/xlate.h \ vnet/policer/policer.api.h API_FILES += vnet/policer/policer.api ######################################## # Cop - junk filter ######################################## libvnet_la_SOURCES += \ vnet/cop/cop.c \ vnet/cop/node1.c \ vnet/cop/ip4_whitelist.c \ vnet/cop/ip6_whitelist.c \ vnet/cop/cop_api.c nobase_include_HEADERS += \ vnet/cop/cop.h \ vnet/cop/cop.api.h API_FILES += vnet/cop/cop.api ######################################## # Layer 2 protocols go here ######################################## ######################################## # Layer 2 protocol: Ethernet ######################################## libvnet_la_SOURCES += \ vnet/ethernet/arp.c \ vnet/ethernet/format.c \ vnet/ethernet/init.c \ vnet/ethernet/interface.c \ vnet/ethernet/node.c \ vnet/ethernet/pg.c nobase_include_HEADERS += \ vnet/ethernet/arp_packet.h \ vnet/ethernet/error.def \ vnet/ethernet/ethernet.h \ vnet/ethernet/packet.h \ vnet/ethernet/types.def ######################################## # Layer 2 protocol: Ethernet bridging ######################################## libvnet_la_SOURCES += \ vnet/l2/feat_bitmap.c \ vnet/l2/l2_api.c \ vnet/l2/l2_bd.c \ vnet/l2/l2_bvi.c \ vnet/l2/l2_input_classify.c \ vnet/l2/l2_output_classify.c \ vnet/l2/l2_efp_filter.c \ vnet/l2/l2_fib.c \ vnet/l2/l2_flood.c \ vnet/l2/l2_fwd.c \ vnet/l2/l2_input_acl.c \ vnet/l2/l2_input.c \ vnet/l2/l2_input_vtr.c \ vnet/l2/l2_learn.c \ vnet/l2/l2_output_acl.c \ vnet/l2/l2_output.c \ vnet/l2/l2_patch.c \ vnet/l2/l2_rw.c \ vnet/l2/l2_vtr.c \ vnet/l2/l2_xcrw.c nobase_include_HEADERS += \ vnet/l2/feat_bitmap.h \ vnet/l2/l2_input.h \ vnet/l2/l2_output.h \ vnet/l2/l2_vtr.h \ vnet/l2/l2_input_vtr.h \ vnet/l2/l2_efp_filter.h \ vnet/l2/l2_fwd.h \ vnet/l2/l2_bd.h \ vnet/l2/l2_bvi.h \ vnet/l2/l2_flood.h \ vnet/l2/l2_fib.h \ vnet/l2/l2_rw.h \ vnet/l2/l2_xcrw.h \ vnet/l2/l2_classify.h \ vnet/l2/l2.api.h API_FILES += vnet/l2/l2.api ######################################## # Layer 2 protocol: SRP ######################################## libvnet_la_SOURCES += \ vnet/srp/format.c \ vnet/srp/interface.c \ vnet/srp/node.c \ vnet/srp/pg.c nobase_include_HEADERS += \ vnet/srp/packet.h \ vnet/srp/srp.h ######################################## # Layer 2 protocol: PPP ######################################## libvnet_la_SOURCES += \ vnet/ppp/node.c \ vnet/ppp/pg.c \ vnet/ppp/ppp.c nobase_include_HEADERS += \ vnet/ppp/error.def \ vnet/ppp/ppp.h \ vnet/ppp/packet.h ######################################## # Layer 2 protocol: HDLC ######################################## libvnet_la_SOURCES += \ vnet/hdlc/node.c \ vnet/hdlc/pg.c \ vnet/hdlc/hdlc.c nobase_include_HEADERS += \ vnet/hdlc/error.def \ vnet/hdlc/hdlc.h \ vnet/hdlc/packet.h ######################################## # Layer 2 protocol: LLC ######################################## libvnet_la_SOURCES += \ vnet/llc/llc.c \ vnet/llc/node.c \ vnet/llc/pg.c nobase_include_HEADERS += \ vnet/llc/llc.h ######################################## # Layer 2 protocol: SNAP ######################################## libvnet_la_SOURCES += \ vnet/snap/snap.c \ vnet/snap/node.c \ vnet/snap/pg.c nobase_include_HEADERS += \ vnet/snap/snap.h ######################################## # Layer 2 / vxlan ######################################## libvnet_la_SOURCES += \ vnet/vxlan/vxlan.c \ vnet/vxlan/encap.c \ vnet/vxlan/decap.c \ vnet/vxlan/vxlan_api.c nobase_include_HEADERS += \ vnet/vxlan/vxlan.h \ vnet/vxlan/vxlan_packet.h \ vnet/vxlan/vxlan_error.def \ vnet/vxlan/vxlan.api.h API_FILES += vnet/vxlan/vxlan.api ######################################## # Layer 2 / CDP ######################################## libvnet_la_SOURCES += \ vnet/cdp/cdp_input.c \ vnet/cdp/cdp_node.c \ vnet/cdp/cdp_periodic.c nobase_include_HEADERS += \ vnet/cdp/cdp_protocol.h ######################################## # Layer 2 / LLDP ######################################## libvnet_la_SOURCES += \ vnet/lldp/lldp_input.c \ vnet/lldp/lldp_node.c \ vnet/lldp/lldp_output.c \ vnet/lldp/lldp_cli.c nobase_include_HEADERS += \ vnet/lldp/lldp_protocol.h ######################################## # Layer 2/3 "classify" ######################################## libvnet_la_SOURCES += \ vnet/classify/vnet_classify.c \ vnet/classify/ip_classify.c \ vnet/classify/input_acl.c \ vnet/classify/policer_classify.c \ vnet/classify/flow_classify.c \ vnet/classify/flow_classify_node.c \ vnet/classify/vnet_classify.h \ vnet/classify/classify_api.c nobase_include_HEADERS += \ vnet/classify/vnet_classify.h \ vnet/classify/input_acl.h \ vnet/classify/policer_classify.h \ vnet/classify/flow_classify.h \ vnet/classify/classify.api.h API_FILES += vnet/classify/classify.api ######################################## # Layer 3 protocols go here ######################################## ######################################## # Layer 3 protocol: IP v4/v6 ######################################## libvnet_la_SOURCES += \ vnet/ip/format.c \ vnet/ip/icmp4.c \ vnet/ip/icmp6.c \ vnet/ip/ip46_cli.c \ vnet/ip/ip4_format.c \ vnet/ip/ip4_forward.c \ vnet/ip/ip4_input.c \ vnet/ip/ip4_mtrie.c \ vnet/ip/ip4_pg.c \ vnet/ip/ip4_source_and_port_range_check.c \ vnet/ip/ip4_source_check.c \ vnet/ip/ip6_format.c \ vnet/ip/ip6_forward.c \ vnet/ip/ip6_hop_by_hop.c \ vnet/ip/ip6_input.c \ vnet/ip/ip6_neighbor.c \ vnet/ip/ip6_pg.c \ vnet/ip/ip_api.c \ vnet/ip/ip_checksum.c \ vnet/ip/ip_frag.c \ vnet/ip/ip.h \ vnet/ip/ip_init.c \ vnet/ip/ip_input_acl.c \ vnet/ip/lookup.c \ vnet/ip/ping.c \ vnet/ip/punt.c nobase_include_HEADERS += \ vnet/ip/format.h \ vnet/ip/icmp46_packet.h \ vnet/ip/icmp4.h \ vnet/ip/icmp6.h \ vnet/ip/igmp_packet.h \ vnet/ip/ip.api.h \ vnet/ip/ip4_error.h \ vnet/ip/ip4.h \ vnet/ip/ip4_mtrie.h \ vnet/ip/ip4_packet.h \ vnet/ip/ip6_error.h \ vnet/ip/ip6.h \ vnet/ip/ip6_hop_by_hop.h \ vnet/ip/ip6_hop_by_hop_packet.h \ vnet/ip/ip6_packet.h \ vnet/ip/ip6_neighbor.h \ vnet/ip/ip.h \ vnet/ip/ip_packet.h \ vnet/ip/ip_source_and_port_range_check.h \ vnet/ip/lookup.h \ vnet/ip/ports.def \ vnet/ip/protocols.def \ vnet/ip/punt_error.def \ vnet/ip/punt.h API_FILES += vnet/ip/ip.api ######################################## # Bidirectional Forwarding Detection ######################################## nobase_include_HEADERS += \ vnet/bfd/bfd_protocol.h \ vnet/bfd/bfd_main.h \ vnet/bfd/bfd_api.h \ vnet/bfd/bfd_udp.h \ vnet/bfd/bfd.api.h libvnet_la_SOURCES += \ vnet/bfd/bfd_api.h \ vnet/bfd/bfd_udp.c \ vnet/bfd/bfd_main.c \ vnet/bfd/bfd_protocol.c \ vnet/bfd/bfd_cli.c \ vnet/bfd/bfd_api.c API_FILES += vnet/bfd/bfd.api ######################################## # Layer 3 protocol: IPSec ######################################## if WITH_LIBSSL libvnet_la_SOURCES += \ vnet/ipsec/ipsec.c \ vnet/ipsec/ipsec_cli.c \ vnet/ipsec/ipsec_format.c \ vnet/ipsec/ipsec_input.c \ vnet/ipsec/ipsec_if.c \ vnet/ipsec/ipsec_if_in.c \ vnet/ipsec/ipsec_if_out.c \ vnet/ipsec/esp_encrypt.c \ vnet/ipsec/esp_decrypt.c \ vnet/ipsec/ikev2.c \ vnet/ipsec/ikev2_crypto.c \ vnet/ipsec/ikev2_cli.c \ vnet/ipsec/ikev2_payload.c \ vnet/ipsec/ikev2_format.c \ vnet/ipsec/ipsec_api.c API_FILES += vnet/ipsec/ipsec.api endif libvnet_la_SOURCES += \ vnet/ipsec/ipsec_output.c nobase_include_HEADERS += \ vnet/ipsec/ipsec.h \ vnet/ipsec/esp.h \ vnet/ipsec/ikev2.h \ vnet/ipsec/ikev2_priv.h \ vnet/ipsec/ipsec.api.h ######################################## # Layer 3 protocol: osi ######################################## libvnet_la_SOURCES += \ vnet/osi/node.c \ vnet/osi/osi.c \ vnet/osi/pg.c nobase_include_HEADERS += \ vnet/osi/osi.h ######################################## # Layer 3 protocol: MAP ######################################## libvnet_la_SOURCES += \ vnet/map/map.c \ vnet/map/map_dpo.c \ vnet/map/ip4_map.c \ vnet/map/ip6_map.c \ vnet/map/ip4_map_t.c \ vnet/map/ip6_map_t.c \ vnet/map/map_api.c nobase_include_HEADERS += \ vnet/map/map.h \ vnet/map/map_dpo.h \ vnet/map/map.api.h API_FILES += vnet/map/map.api if ENABLE_TESTS TESTS += test_map test_map_SOURCES = \ vnet/map/test.c test_map_CPPFLAGS = $(AM_CPPFLAGS) -DCLIB_DEBUG test_map_LDADD = libvnet.la libvppinfra.la libvlib.la \ -lpthread -lvlibmemory -lvlibapi \ -ldl -lsvm -lrt test_map_LDFLAGS = -static endif ######################################## # Layer 4 protocol: tcp ######################################## libvnet_la_SOURCES += \ vnet/tcp/tcp_format.c \ vnet/tcp/tcp_pg.c \ vnet/tcp/tcp_syn_filter4.c \ vnet/tcp/tcp_output.c \ vnet/tcp/tcp_input.c \ vnet/tcp/tcp_newreno.c \ vnet/tcp/builtin_server.c \ vnet/tcp/tcp.c nobase_include_HEADERS += \ vnet/tcp/tcp_packet.h \ vnet/tcp/tcp_timer.h \ vnet/tcp/tcp.h ######################################## # Layer 4 protocol: udp ######################################## libvnet_la_SOURCES += \ vnet/udp/udp.c \ vnet/udp/udp_input.c \ vnet/udp/builtin_server.c \ vnet/udp/udp_format.c \ vnet/udp/udp_local.c \ vnet/udp/udp_pg.c nobase_include_HEADERS += \ vnet/udp/udp_error.def \ vnet/udp/udp.h \ vnet/udp/udp_packet.h ######################################## # Tunnel protocol: gre ######################################## libvnet_la_SOURCES += \ vnet/gre/gre.c \ vnet/gre/node.c \ vnet/gre/interface.c \ vnet/gre/pg.c \ vnet/gre/gre_api.c nobase_include_HEADERS += \ vnet/gre/gre.h \ vnet/gre/packet.h \ vnet/gre/error.def \ vnet/gre/gre.api.h API_FILES += vnet/gre/gre.api ######################################## # Tunnel protocol: l2tpv3 ######################################## libvnet_la_SOURCES += \ vnet/l2tp/l2tp.c \ vnet/l2tp/encap.c \ vnet/l2tp/decap.c \ vnet/l2tp/pg.c \ vnet/l2tp/l2tp_api.c nobase_include_HEADERS += \ vnet/l2tp/l2tp.h \ vnet/l2tp/packet.h \ vnet/l2tp/l2tp.api.h API_FILES += vnet/l2tp/l2tp.api ######################################## # Tunnel protocol: gre+mpls ######################################## libvnet_la_SOURCES += \ vnet/mpls/mpls.c \ vnet/mpls/mpls_lookup.
/*
 * Copyright (c) 2015 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef __included_vat_h__
#define __included_vat_h__

#define _GNU_SOURCE
#include <stdio.h>
#include <setjmp.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <vppinfra/clib.h>
#include <vppinfra/format.h>
#include <vppinfra/error.h>
#include <vppinfra/time.h>
#include <vppinfra/macros.h>
#include <vppinfra/socket.h>
#include <vnet/vnet.h>
#include <vlib/vlib.h>
#include <vlib/unix/unix.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>

#include "vat/json_format.h"

#include <vlib/vlib.h>

typedef struct
{
  u8 *interface_name;
  u32 sw_if_index;
  /*
   * Subinterface ID. A number 0-N to uniquely identify this
   * subinterface under the super interface
   */
  u32 sub_id;

  /* 0 = dot1q, 1=dot1ad */
  u8 sub_dot1ad;

  /* Number of tags 0-2 */
  u8 sub_number_of_tags;
  u16 sub_outer_vlan_id;
  u16 sub_inner_vlan_id;
  u8 sub_exact_match;
  u8 sub_default;
  u8 sub_outer_vlan_id_any;
  u8 sub_inner_vlan_id_any;

  /* vlan tag rewrite */
  u32 vtr_op;
  u32 vtr_push_dot1q;
  u32 vtr_tag1;
  u32 vtr_tag2;