FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
lisp_types_api.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  *
4  * Copyright (c) 2020 Cisco and/or its affiliates.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *------------------------------------------------------------------
17  */
18 
20 #include <vnet/ip/ip_types_api.h>
22 
23 int
24 unformat_lisp_eid_api (gid_address_t * dst, u32 vni, const vl_api_eid_t * eid)
25 {
26  switch (eid->type)
27  {
28  case EID_TYPE_API_PREFIX: /* ip prefix */
30  ip_address_decode2 (&eid->address.prefix.address, &dst->ippref.addr);
31  gid_address_ippref_len (dst) = eid->address.prefix.len;
33  break;
34  case EID_TYPE_API_MAC: /* l2 mac */
37  break;
38  default:
39  /* unknown type */
40  return VNET_API_ERROR_INVALID_VALUE;
41  }
42 
43  gid_address_vni (dst) = clib_net_to_host_u32 (vni);
44 
45  return 0;
46 }
47 
48 void
49 lisp_fid_put_api (vl_api_eid_t * eid, const fid_address_t * fid)
50 {
51  switch (fid_addr_type (fid))
52  {
53  case FID_ADDR_IP_PREF:
54  ip_prefix_encode2 (&fid_addr_ippref (fid), &eid->address.prefix);
55  eid->type = EID_TYPE_API_PREFIX;
56  break;
57 
58  case FID_ADDR_MAC:
59  mac_address_encode ((mac_address_t *) fid_addr_mac (fid), eid->address.mac);
60  eid->type = EID_TYPE_API_MAC;
61  break;
62 
63  default:
64  clib_warning ("Unknown FID type %d!", fid_addr_type (fid));
65  break;
66  }
67 }
68 
69 void
70 lisp_gid_put_api (vl_api_eid_t * eid, const gid_address_t * gid)
71 {
72  switch (gid_address_type (gid))
73  {
74  case GID_ADDR_IP_PREFIX:
75  ip_prefix_encode2 (&gid_address_ippref (gid), &eid->address.prefix);
76  eid->type = EID_TYPE_API_PREFIX;
77  break;
78 
79  case GID_ADDR_MAC:
80  mac_address_encode ((mac_address_t *) gid_address_mac (gid), eid->address.mac);
81  eid->type = EID_TYPE_API_MAC;
82  break;
83 
84  default:
85  clib_warning ("Unknown GID type %d!", gid_address_type (gid));
86  break;
87  }
88 }
gid_address_ippref_len
#define gid_address_ippref_len(_a)
Definition: lisp_types.h:205
lisp_fid_put_api
void lisp_fid_put_api(vl_api_eid_t *eid, const fid_address_t *fid)
Definition: lisp_types_api.c:49
fid_address_t
Definition: lisp_types.h:69
ip_prefix_encode2
void ip_prefix_encode2(const ip_prefix_t *in, vl_api_prefix_t *out)
Definition: ip_types_api.c:311
vni
u32 vni
Definition: flow_types.api:160
gid_address_ippref
#define gid_address_ippref(_a)
Definition: lisp_types.h:204
ip_prefix_normalize
void ip_prefix_normalize(ip_prefix_t *a)
Definition: ip_types.c:357
GID_ADDR_IP_PREFIX
@ GID_ADDR_IP_PREFIX
Definition: lisp_types.h:39
EID_TYPE_API_PREFIX
@ EID_TYPE_API_PREFIX
Definition: lisp_types.api:39
eid
typedef eid
Definition: lisp_types.api:59
unformat_lisp_eid_api
int unformat_lisp_eid_api(gid_address_t *dst, u32 vni, const vl_api_eid_t *eid)
Definition: lisp_types_api.c:24
fid_addr_type
#define fid_addr_type(_a)
Definition: lisp_types.h:87
FID_ADDR_IP_PREF
@ FID_ADDR_IP_PREF
Definition: lisp_types.h:63
gid_address_vni
#define gid_address_vni(_a)
Definition: lisp_types.h:213
FID_ADDR_MAC
@ FID_ADDR_MAC
Definition: lisp_types.h:64
lisp_gid_put_api
void lisp_gid_put_api(vl_api_eid_t *eid, const gid_address_t *gid)
Definition: lisp_types_api.c:70
ip_address_decode2
void ip_address_decode2(const vl_api_address_t *in, ip_address_t *out)
Definition: ip_types_api.c:192
mac_address_encode
void mac_address_encode(const mac_address_t *in, u8 *out)
Definition: ethernet_types_api.c:40
u32
unsigned int u32
Definition: types.h:88
dst
vl_api_ip4_address_t dst
Definition: pnat.api:41
ethernet_types_api.h
fid_addr_ippref
#define fid_addr_ippref(_a)
Definition: lisp_types.h:82
mac_address_decode
void mac_address_decode(const u8 *in, mac_address_t *out)
Conversion functions to/from (decode/encode) API types to VPP internal types.
Definition: ethernet_types_api.c:34
mac_address_t_
Definition: mac_address.h:21
gid_address_type
#define gid_address_type(_a)
Definition: lisp_types.h:203
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
gid_address_t
struct _gid_address_t gid_address_t
GID_ADDR_MAC
@ GID_ADDR_MAC
Definition: lisp_types.h:41
fid_addr_mac
#define fid_addr_mac(_a)
Definition: lisp_types.h:85
lisp_types_api.h
ip_types_api.h
EID_TYPE_API_MAC
@ EID_TYPE_API_MAC
Definition: lisp_types.api:40
gid_address_mac
#define gid_address_mac(_a)
Definition: lisp_types.h:209