2 *------------------------------------------------------------------
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:
9 * http://www.apache.org/licenses/LICENSE-2.0
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 *------------------------------------------------------------------
19 #include <vnet/lisp-cp/lisp_types_api.h>
20 #include <vnet/ip/ip_types_api.h>
21 #include <vnet/ethernet/ethernet_types_api.h>
24 unformat_lisp_eid_api (gid_address_t * dst, u32 vni, const vl_api_eid_t * eid)
28 case EID_TYPE_API_PREFIX: /* ip prefix */
29 gid_address_type (dst) = GID_ADDR_IP_PREFIX;
30 ip_address_decode2 (&eid->address.prefix.address, &dst->ippref.addr);
31 gid_address_ippref_len (dst) = eid->address.prefix.len;
32 ip_prefix_normalize (&gid_address_ippref (dst));
34 case EID_TYPE_API_MAC: /* l2 mac */
35 gid_address_type (dst) = GID_ADDR_MAC;
36 mac_address_decode (eid->address.mac, (mac_address_t *) gid_address_mac (dst));
40 return VNET_API_ERROR_INVALID_VALUE;
43 gid_address_vni (dst) = clib_net_to_host_u32 (vni);
49 lisp_fid_put_api (vl_api_eid_t * eid, const fid_address_t * fid)
51 switch (fid_addr_type (fid))
53 case FID_ADDR_IP_PREF:
54 ip_prefix_encode2 (&fid_addr_ippref (fid), &eid->address.prefix);
55 eid->type = EID_TYPE_API_PREFIX;
59 mac_address_encode ((mac_address_t *) fid_addr_mac (fid), eid->address.mac);
60 eid->type = EID_TYPE_API_MAC;
64 clib_warning ("Unknown FID type %d!", fid_addr_type (fid));
70 lisp_gid_put_api (vl_api_eid_t * eid, const gid_address_t * gid)
72 switch (gid_address_type (gid))
74 case GID_ADDR_IP_PREFIX:
75 ip_prefix_encode2 (&gid_address_ippref (gid), &eid->address.prefix);
76 eid->type = EID_TYPE_API_PREFIX;
80 mac_address_encode ((mac_address_t *) gid_address_mac (gid), eid->address.mac);
81 eid->type = EID_TYPE_API_MAC;
85 clib_warning ("Unknown GID type %d!", gid_address_type (gid));