/*
* Copyright (c) 2017-2019 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 __HICN_FACE_UDP_H__
#define __HICN_FACE_UDP_H__
#include <vlib/vlib.h>
#include <vnet/vnet.h>
#include <vnet/ip/ip6_packet.h>
#include <vnet/udp/udp_packet.h>
#include "../face.h"
/**
* @file
* @brief UDP face
*
* This file containes the definition of UDP faces.
* UDP faces encap and decap an hicn packet into a UDP tunnel.
* Src and dst address in interest and data packets are not considered and
* should be set to 0 (not checked in the forwarder).
*/
/* Pre-instantiated ip header to fast fill an newly encapsulated packet */
extern ip4_header_t ip4_header_skl;
extern ip6_header_t ip6_header_skl;
#define INVALID_UDP_DPO_INDEX ~0
/**
* @brief UDP face representation. The following is stored in the data field of
* an hicn_face_t object (see hicn_face.h). A UDP face is identifies by the
* quadruplet (src addr, dst addr, src port, dst port).
*/
typedef struct hicn_face_udp_t_
{
/**
* The headers to paint, in packet painting order
*/
union
{
struct
{
ip4_header_t ip;
udp_header_t udp;
} __attribute__ ((packed)) ip4;
struct
{
ip6_header_t ip;
udp_header_t udp;
} __attribute__ ((packed)) ip6;
} __attribute__ ((packed)) hdrs;
} hicn_face_udp_t;
/* Hast table mapping the udp key with the face id (dpoi_index pointing to and
element in the face pool defined in hicn_face.h)*/
extern mhash_t hicn_face_udp_hashtb;
/**
* @brief Hash table key.
*/
typedef struct hicn_face_udp_key_s
{
ip46_address_t local_addr;
ip46_address_t remote_addr;
u16 local_port;
u16 remote_port;
} hicn_face_udp_key_t;
/* DPO type for the udp face */
extern dpo_type_t hicn_face_udp_type;
/* VFT table for the udp face. Mainly used to format the face in the right way */
extern hicn_face_vft_t udp_vft;
/**
* @brief Create the key object for the mhash. Fill in the key object with the
* expected values.
*
* @param local_addr Local address of the UDP tunnel
* @param remote_addr Remote address of the UDP tunnel
* @param local_port Local port of the UDP tunnel
* @param remote_port Remote port of the UDP tunnel
* @param key Pointer to an allocated hic