aboutsummaryrefslogtreecommitdiffstats
path: root/vpp/vpp-api/api.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2016-08-02 02:31:03 +0200
committerDave Barach <openvpp@barachs.net>2016-08-04 11:58:07 +0000
commitbb5c22f1b6f48cb53fa2d0e5abcac7248318f8e0 (patch)
tree6744b25f4af97e88094a3dbd1536ed056b198de8 /vpp/vpp-api/api.c
parentf3f25416900288d86511133b4d47e68ccf359772 (diff)
LISP multihoming API changes and cleanup
Change-Id: I106352a6da0fad2b91dc8593f8d6d664af3113a8 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'vpp/vpp-api/api.c')
-rw-r--r--vpp/vpp-api/api.c65
1 files changed, 46 insertions, 19 deletions
diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c
index 18999a5f..45c3aebd 100644
--- a/vpp/vpp-api/api.c
+++ b/vpp/vpp-api/api.c
@@ -4975,23 +4975,51 @@ typedef CLIB_PACKED(struct
u8 addr[16]; /**< IPv4/IPv6 address */
}) rloc_t;
+static locator_pair_t *
+unformat_lisp_loc_pairs (void * lcl_locs, void * rmt_locs, u32 rloc_num)
+{
+ u32 i;
+ locator_pair_t * pairs = 0, pair;
+ rloc_t * r;
+
+ for (i = 0; i < rloc_num; i++) {
+ /* local locator */
+ r = &((rloc_t *) lcl_locs)[i];
+ memset(&pair.lcl_loc, 0, sizeof(pair.lcl_loc));
+ ip_address_set(&pair.lcl_loc, &r->addr, r->is_ip4 ? IP4 : IP6);
+
+ /* remote locators */
+ r = &((rloc_t *) rmt_locs)[i];
+ memset(&pair.rmt_loc, 0, sizeof(pair.rmt_loc));
+ ip_address_set(&pair.rmt_loc, &r->addr, r->is_ip4 ? IP4 : IP6);
+
+ pair.priority = r->priority;
+ pair.weight = r->weight;
+
+ vec_add1 (pairs, pair);
+ }
+ return pairs;
+}
+
static locator_t *
-unformat_lisp_locs (void * data, u32 rloc_num)
+unformat_lisp_locs (void * rmt_locs, u32 rloc_num)
{
u32 i;
- locator_t rloc, * rlocs = 0;
+ locator_t * locs = 0, loc;
+ rloc_t * r;
for (i = 0; i < rloc_num; i++) {
- rloc_t * r = &((rloc_t *) data)[i];
- memset(&rloc, 0, sizeof(rloc));
- gid_address_ip_set (&rloc.address, &r->addr, r->is_ip4 ? IP4 : IP6);
- gid_address_ippref_len(&rloc.address) = r->is_ip4 ? 32: 128;
- gid_address_type(&rloc.address) = GID_ADDR_IP_PREFIX;
- rloc.priority = r->priority;
- rloc.weight = r->weight;
- vec_add1 (rlocs, rloc);
+ /* remote locators */
+ r = &((rloc_t *) rmt_locs)[i];
+ memset(&loc, 0, sizeof(loc));
+ gid_address_ip_set(&loc.address, &r->addr, r->is_ip4 ? IP4 : IP6);
+
+ loc.priority = r->priority;
+ loc.weight = r->weight;
+
+ vec_add1 (locs, loc);
}
- return rlocs;
+ return locs;
}
static void
@@ -4999,9 +5027,9 @@ vl_api_lisp_gpe_add_del_fwd_entry_t_handler(
vl_api_lisp_gpe_add_del_fwd_entry_t *mp)
{
vl_api_lisp_gpe_add_del_fwd_entry_reply_t *rmp;
- int rv = 0;
vnet_lisp_gpe_add_del_fwd_entry_args_t _a, * a = &_a;
- locator_t * lcl_locs = 0, * rmt_locs = 0;
+ locator_pair_t * pairs = 0;
+ int rv = 0;
memset (a, 0, sizeof(a[0]));
@@ -5010,20 +5038,19 @@ vl_api_lisp_gpe_add_del_fwd_entry_t_handler(
rv |= unformat_lisp_eid_api (&a->lcl_eid, mp->vni, mp->eid_type,
mp->lcl_eid, mp->lcl_len);
- lcl_locs = unformat_lisp_locs (mp->lcl_locs, mp->loc_num);
- rmt_locs = unformat_lisp_locs (mp->rmt_locs, mp->loc_num);
+ pairs = unformat_lisp_loc_pairs (mp->lcl_locs, mp->rmt_locs, mp->loc_num);
- if (rv || 0 == lcl_locs || 0 == lcl_locs)
+ if (rv || 0 == pairs)
goto send_reply;
a->is_add = mp->is_add;
- a->lcl_loc = gid_address_ip(&lcl_locs[0].address); /* TODO support more */
- a->rmt_loc = gid_address_ip(&rmt_locs[0].address);
+ a->locator_pairs = pairs;
a->dp_table = mp->dp_table;
a->vni = mp->vni;
+ a->action = mp->action;
rv = vnet_lisp_gpe_add_del_fwd_entry (a, 0);
-
+ vec_free(pairs);
send_reply:
REPLY_MACRO(VL_API_LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY);
}