diff options
author | Filip Tehlar <ftehlar@cisco.com> | 2016-06-27 13:09:20 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2016-06-29 18:54:02 +0000 |
commit | 006eb2689b901b4700f4360cc0417c6c0d93cc46 (patch) | |
tree | 62f2005841fa85d7050ff0444ddf07ac7e45e619 /vpp/vpp-api | |
parent | 71fb06fba05ff74390f4ff013ff14ea1086ab631 (diff) |
Add support for ethernet address in LISP API
Change-Id: I9f1522f55bdd11602784a421fd850b839a1070e6
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Diffstat (limited to 'vpp/vpp-api')
-rw-r--r-- | vpp/vpp-api/api.c | 112 | ||||
-rw-r--r-- | vpp/vpp-api/vpe.api | 28 |
2 files changed, 91 insertions, 49 deletions
diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c index 2ea92df0..fbe33fe1 100644 --- a/vpp/vpp-api/api.c +++ b/vpp/vpp-api/api.c @@ -4781,26 +4781,41 @@ vl_api_lisp_add_del_local_eid_t_handler( ip_prefix_t *prefp = NULL; ip_address_t *ip_eid = NULL; gid_address_t eid; + u8 * mac = gid_address_mac (&eid); uword * p = NULL; u32 locator_set_index = ~0, map_index = ~0; vnet_lisp_add_del_mapping_args_t _a, *a = &_a; u8 *name = NULL; memset (a, 0, sizeof (a[0])); + memset (&eid, 0, sizeof (eid)); prefp = &gid_address_ippref(&eid); ip_eid = &ip_prefix_addr(prefp); - gid_address_type (&eid) = GID_ADDR_IP_PREFIX; - if (mp->is_ipv6) { - clib_memcpy(&ip_addr_v6(ip_eid), mp->ip_address, - sizeof(ip_addr_v6(ip_eid))); - ip_addr_version(ip_eid) = IP6; - } else { - clib_memcpy(&ip_addr_v4(ip_eid), mp->ip_address, + switch (mp->eid_type) + { + case 0: /* ipv4*/ + gid_address_type (&eid) = GID_ADDR_IP_PREFIX; + clib_memcpy(&ip_addr_v4(ip_eid), mp->eid, sizeof(ip_addr_v4(ip_eid))); ip_addr_version(ip_eid) = IP4; - } - ip_prefix_len(prefp) = mp->prefix_len; + ip_prefix_len(prefp) = mp->prefix_len; + break; + case 1: /* ipv6 */ + gid_address_type (&eid) = GID_ADDR_IP_PREFIX; + clib_memcpy(&ip_addr_v6(ip_eid), mp->eid, + sizeof(ip_addr_v6(ip_eid))); + ip_addr_version(ip_eid) = IP6; + ip_prefix_len(prefp) = mp->prefix_len; + break; + case 2: /* l2 mac */ + gid_address_type (&eid) = GID_ADDR_MAC; + clib_memcpy(mac, mp->eid, 6); + break; + default: + rv = VNET_API_ERROR_INVALID_EID_TYPE; + goto out; + } name = format(0, "%s", mp->locator_set_name); p = hash_get_mem(lcm->locator_set_index_by_name, name); @@ -4813,7 +4828,7 @@ vl_api_lisp_add_del_local_eid_t_handler( /* XXX treat batch configuration */ a->is_add = mp->is_add; gid_address_vni (&eid) = clib_net_to_host_u32 (mp->vni); - a->deid = eid; + gid_address_copy (&a->deid, &eid); a->locator_set_index = locator_set_index; a->local = 1; rv = vnet_lisp_add_del_local_mapping(a, &map_index); @@ -5041,30 +5056,49 @@ vl_api_lisp_add_del_remote_mapping_t_handler ( ip_prefix_t * seid_pref = &gid_address_ippref(seid); ip_prefix_t * deid_pref = &gid_address_ippref(deid); - gid_address_type(seid) = GID_ADDR_IP_PREFIX; - gid_address_type(deid) = GID_ADDR_IP_PREFIX; + memset (seid, 0, sizeof (seid[0])); + memset (deid, 0, sizeof (deid[0])); ip_address_t * seid_addr = &ip_prefix_addr(seid_pref); ip_address_t * deid_addr = &ip_prefix_addr(deid_pref); ip_prefix_len(seid_pref) = mp->seid_len; ip_prefix_len(deid_pref) = mp->deid_len; + u8 * seid_mac = gid_address_mac (seid); + u8 * deid_mac = gid_address_mac (deid); gid_address_vni (seid) = ntohl (mp->vni); gid_address_vni (deid) = ntohl (mp->vni); - if (mp->eid_is_ip4) { + switch (mp->eid_type) + { + case 0: /* ipv4 */ + gid_address_type(seid) = GID_ADDR_IP_PREFIX; + gid_address_type(deid) = GID_ADDR_IP_PREFIX; ip_prefix_version(seid_pref) = IP4; ip_prefix_version(deid_pref) = IP4; clib_memcpy (&ip_addr_v4(seid_addr), mp->seid, sizeof (ip_addr_v4(seid_addr))); clib_memcpy (&ip_addr_v4(deid_addr), mp->deid, sizeof (ip_addr_v4(deid_addr))); - } else { + break; + case 1: /* ipv6 */ + gid_address_type(seid) = GID_ADDR_IP_PREFIX; + gid_address_type(deid) = GID_ADDR_IP_PREFIX; ip_prefix_version(seid_pref) = IP6; ip_prefix_version(deid_pref) = IP6; clib_memcpy (&ip_addr_v6(seid_addr), mp->seid, sizeof (ip_addr_v6(seid_addr))); clib_memcpy (&ip_addr_v6(deid_addr), mp->deid, sizeof (ip_addr_v6(deid_addr))); - } + break; + case 2: /* l2 mac */ + gid_address_type(seid) = GID_ADDR_MAC; + gid_address_type(deid) = GID_ADDR_MAC; + clib_memcpy (seid_mac, mp->seid, 6); + clib_memcpy (deid_mac, mp->deid, 6); + break; + default: + rv = VNET_API_ERROR_INVALID_EID_TYPE; + goto send_reply; + } for (i = 0; i < mp->rloc_num; i++) { rloc_t * r = &((rloc_t *) mp->rlocs)[i]; @@ -5081,6 +5115,7 @@ vl_api_lisp_add_del_remote_mapping_t_handler ( rv = vnet_lisp_add_del_remote_mapping (deid, seid, rlocs, mp->action, mp->is_add, mp->del_all); vec_free (rlocs); +send_reply: REPLY_MACRO(VL_API_LISP_GPE_ADD_DEL_IFACE_REPLY); } @@ -5152,21 +5187,15 @@ send_lisp_local_eid_table_details (mapping_t *mapit, lisp_cp_main_t * lcm = vnet_lisp_cp_get_main(); locator_set_t *ls = NULL; gid_address_t *gid = NULL; + u8 * mac = 0; ip_prefix_t *ip_prefix = NULL; u8 * str = NULL; - u8 type = ~0; ls = pool_elt_at_index (lcm->locator_set_pool, mapit->locator_set_index); - gid = &mapit->eid; - type = gid_address_type(gid); - - if (type != GID_ADDR_IP_PREFIX) { - return; - } - ip_prefix = &gid_address_ippref(gid); + mac = gid_address_mac(gid); rmp = vl_msg_api_alloc (sizeof (*rmp)); memset (rmp, 0, sizeof (*rmp)); @@ -5182,23 +5211,30 @@ send_lisp_local_eid_table_details (mapping_t *mapit, vec_free(str); } - switch (ip_prefix_version(ip_prefix)) { - case IP4: - rmp->eid_is_ipv6 = 0; - clib_memcpy(rmp->eid_ip_address, &ip_prefix_v4(ip_prefix), + switch (gid_address_type (gid)) + { + case GID_ADDR_IP_PREFIX: + rmp->eid_prefix_len = ip_prefix_len(ip_prefix); + if (ip_prefix_version(ip_prefix) == IP4) + { + rmp->eid_type = 0; /* ipv4 type */ + clib_memcpy(rmp->eid, &ip_prefix_v4(ip_prefix), sizeof(ip_prefix_v4(ip_prefix))); - break; - - case IP6: - rmp->eid_is_ipv6 = 1; - clib_memcpy(rmp->eid_ip_address, &ip_prefix_v6(ip_prefix), + } + else + { + rmp->eid_type = 1; /* ipv6 type */ + clib_memcpy(rmp->eid, &ip_prefix_v6(ip_prefix), sizeof(ip_prefix_v6(ip_prefix))); - break; - - default: - ASSERT(0); - } - rmp->eid_prefix_len = ip_prefix_len(ip_prefix); + } + break; + case GID_ADDR_MAC: + rmp->eid_type = 2; /* l2 mac type */ + clib_memcpy(rmp->eid, mac, 6); + break; + default: + ASSERT(0); + } rmp->context = context; rmp->vni = clib_host_to_net_u32 (gid_address_vni (gid)); vl_msg_api_send_shmem (q, (u8 *)&rmp); diff --git a/vpp/vpp-api/vpe.api b/vpp/vpp-api/vpe.api index 0184a3e1..033ba240 100644 --- a/vpp/vpp-api/vpe.api +++ b/vpp/vpp-api/vpe.api @@ -2201,18 +2201,21 @@ define lisp_add_del_locator_reply { @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param is_add - add address if non-zero, else delete - @param is_ipv6 - if non-zero the address is ipv6, else ipv4 - @param ip_address - array of address bytes + @param eid_type: + 0 : ipv4 + 1 : ipv6 + 2 : mac + @param eid - EID can be ip4, ip6 or mac @param prefix_len - prefix len @param locator_set_name - name of locator_set to add/del eid-table - @param vni - vitual network instance + @param vni - virtual network instance */ define lisp_add_del_local_eid { u32 client_index; u32 context; u8 is_add; - u8 is_ipv6; - u8 ip_address[16]; + u8 eid_type; + u8 eid[16]; u8 prefix_len; u8 locator_set_name[64]; u32 vni; @@ -2374,7 +2377,10 @@ define lisp_pitr_set_locator_set_reply { @param del_all - if set, delete all remote mappings @param vni - virtual network instance @param action - negative map-reply action - @param eid_is_ip4 - ipv4/6 of source and destination EIDs + @param eid_type - + 0 : ipv4 + 1 : ipv6 + 2 : mac @param deid - destination EID @param seid - source EID @param rloc_num - number of remote locators @@ -2387,7 +2393,7 @@ define lisp_add_del_remote_mapping { u8 del_all; u32 vni; u8 action; - u8 eid_is_ip4; + u8 eid_type; u8 deid[16]; u8 seid[16]; u8 deid_len; @@ -2482,16 +2488,16 @@ define lisp_locator_set_dump { /** \brief LISP local eid table status @param locator_set_name - name of the locator_set - @param eid_is_ipv6 - if non-zero the address is ipv6, else ipv4 - @param eid_ip_address - array of address bytes + @param eid_type - ip4, ip6 or l2 mac address + @param eid - array of address bytes @param eid_prefix_len - prefix len */ manual_java define lisp_local_eid_table_details { u32 context; u8 locator_set_name[64]; - u8 eid_is_ipv6; + u8 eid_type; u32 vni; - u8 eid_ip_address[16]; + u8 eid[16]; u8 eid_prefix_len; }; |