+static int
+api_lisp_add_del_locator_set(vat_main_t * vam)
+{
+ unformat_input_t * input = vam->input;
+ vl_api_lisp_add_del_locator_set_t *mp;
+ f64 timeout = ~0;
+ u8 is_add = 1;
+ u8 *locator_set_name = NULL;
+ u8 locator_set_name_set = 0;
+
+ /* Parse args required to build the message */
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
+ if (unformat(input, "del")) {
+ is_add = 0;
+ } else if (unformat(input, "locator-set %s", &locator_set_name)) {
+ locator_set_name_set = 1;
+ } else
+ break;
+ }
+
+ if (locator_set_name_set == 0) {
+ errmsg ("missing locator-set name");
+ return -99;
+ }
+
+ if (vec_len(locator_set_name) > 64) {
+ errmsg ("locator-set name too long\n");
+ vec_free(locator_set_name);
+ return -99;
+ }
+ vec_add1(locator_set_name, 0);
+
+ /* Construct the API message */
+ M(LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set);
+
+ mp->is_add = is_add;
+ clib_memcpy(mp->locator_set_name, locator_set_name,
+ vec_len(locator_set_name));
+ vec_free(locator_set_name);
+
+ /* send it... */
+ S;
+
+ /* Wait for a reply... */
+ W;
+
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_lisp_add_del_locator(vat_main_t * vam)
+{
+ unformat_input_t * input = vam->input;
+ vl_api_lisp_add_del_locator_t *mp;
+ f64 timeout = ~0;
+ u32 tmp_if_index = ~0;
+ u32 sw_if_index = ~0;
+ u8 sw_if_index_set = 0;
+ u8 sw_if_index_if_name_set = 0;
+ u8 priority = ~0;
+ u8 priority_set = 0;
+ u8 weight = ~0;
+ u8 weight_set = 0;
+ u8 is_add = 1;
+ u8 *locator_set_name = NULL;
+ u8 locator_set_name_set = 0;
+
+ /* Parse args required to build the message */
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
+ if (unformat(input, "del")) {
+ is_add = 0;
+ } else if (unformat(input, "locator-set %s", &locator_set_name)) {
+ locator_set_name_set = 1;
+ } else if (unformat(input, "iface %U", unformat_sw_if_index, vam,
+ &tmp_if_index)) {
+ sw_if_index_if_name_set = 1;
+ sw_if_index = tmp_if_index;
+ } else if (unformat(input,"sw_if_index %d", &tmp_if_index)) {
+ sw_if_index_set = 1;
+ sw_if_index = tmp_if_index;
+ } else if (unformat(input, "p %d", &priority)) {
+ priority_set = 1;
+ } else if (unformat(input, "w %d", &weight)) {
+ weight_set = 1;
+ } else
+ break;
+ }
+
+ if (locator_set_name_set == 0) {
+ errmsg ("missing locator-set name");
+ return -99;
+ }
+
+ if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0) {
+ errmsg ("missing sw_if_index");
+ vec_free(locator_set_name);
+ return -99;
+ }
+
+ if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0) {
+ errmsg ("cannot use both params interface name and sw_if_index");
+ vec_free(locator_set_name);
+ return -99;
+ }
+
+ if (priority_set == 0) {
+ errmsg ("missing locator-set priority\n");
+ vec_free(locator_set_name);
+ return -99;
+ }
+
+ if (weight_set == 0) {
+ errmsg ("missing locator-set weight\n");
+ vec_free(locator_set_name);
+ return -99;
+ }
+
+ if (vec_len(locator_set_name) > 64) {
+ errmsg ("locator-set name too long\n");
+ vec_free(locator_set_name);
+ return -99;
+ }
+ vec_add1(locator_set_name, 0);
+
+ /* Construct the API message */
+ M(LISP_ADD_DEL_LOCATOR, lisp_add_del_locator);
+
+ mp->is_add = is_add;
+ mp->sw_if_index = ntohl(sw_if_index);
+ mp->priority = priority;
+ mp->weight = weight;
+ clib_memcpy(mp->locator_set_name, locator_set_name,
+ vec_len(locator_set_name));
+ vec_free(locator_set_name);
+
+ /* send it... */
+ S;
+
+ /* Wait for a reply... */
+ W;
+
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_lisp_add_del_local_eid(vat_main_t * vam)
+{
+ unformat_input_t * input = vam->input;
+ vl_api_lisp_add_del_local_eid_t *mp;
+ f64 timeout = ~0;
+ u8 is_add = 1;
+ u8 eidv4_set = 0;
+ u8 eidv6_set = 0;
+ ip4_address_t eidv4;
+ ip6_address_t eidv6;
+ u8 tmp_eid_lenght = ~0;
+ u8 eid_lenght = ~0;
+ u8 *locator_set_name = NULL;
+ u8 locator_set_name_set = 0;
+
+ /* Parse args required to build the message */
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
+ if (unformat(input, "del")) {
+ is_add = 0;
+ } else if (unformat(input, "eid %U/%d", unformat_ip4_address,
+ &eidv4, &tmp_eid_lenght)) {
+ eid_lenght = tmp_eid_lenght;
+ eidv4_set = 1;
+ } else if (unformat(input, "eid %U/%d", unformat_ip6_address,
+ &eidv6, &tmp_eid_lenght)) {
+ eid_lenght = tmp_eid_lenght;
+ eidv6_set = 1;
+ } else if (unformat(input, "locator-set %s", &locator_set_name)) {
+ locator_set_name_set = 1;
+ } else
+ break;
+ }
+
+ if (locator_set_name_set == 0) {
+ errmsg ("missing locator-set name\n");
+ return -99;
+ }
+
+ if (vec_len(locator_set_name) > 64) {
+ errmsg ("locator-set name too long\n");
+ vec_free(locator_set_name);
+ return -99;
+ }
+ vec_add1(locator_set_name, 0);
+
+ if (eidv4_set && eidv6_set) {
+ errmsg ("both eid v4 and v6 addresses set\n");
+ vec_free(locator_set_name);
+ return -99;
+ }
+
+ if (!eidv4_set && !eidv6_set) {
+ errmsg ("eid addresses not set\n");
+ vec_free(locator_set_name);
+ return -99;
+ }
+
+ if (eidv4_set && eid_lenght > 32) {
+ errmsg ("eid prefix to big\n");
+ vec_free(locator_set_name);
+ return -99;
+ }
+
+ if (eidv6_set && eid_lenght > 128) {
+ errmsg ("eid prefix to big\n");
+ vec_free(locator_set_name);
+ return -99;
+ }
+
+ /* Construct the API message */
+ M(LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid);
+
+ mp->is_add = is_add;
+ if (eidv6_set) {
+ mp->is_ipv6 = 1;
+ clib_memcpy(mp->ip_address, &eidv6, sizeof(eidv6));
+ } else {
+ mp->is_ipv6 = 0;
+ clib_memcpy(mp->ip_address, &eidv4, sizeof(eidv4));
+ }
+ mp->prefix_len = eid_lenght;
+ clib_memcpy(mp->locator_set_name, locator_set_name,
+ vec_len(locator_set_name));
+ vec_free(locator_set_name);
+
+ /* send it... */
+ S;
+
+ /* Wait for a reply... */
+ W;
+
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_lisp_gpe_add_del_fwd_entry(vat_main_t * vam)
+{
+ unformat_input_t * input = vam->input;
+ vl_api_lisp_gpe_add_del_fwd_entry_t *mp;
+ f64 timeout = ~0;
+ u8 is_add = 1;
+ u8 eidv4_set = 0, slocv4_set = 0, dlocv4_set = 0;
+ u8 eidv6_set = 0, slocv6_set = 0, dlocv6_set = 0;
+ ip4_address_t eidv4, slocv4, dlocv4;
+ ip6_address_t eidv6, slocv6, dlocv6;
+ u8 tmp_eid_lenght = ~0;
+ u8 eid_lenght = ~0;
+
+ /* Parse args required to build the message */
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
+ if (unformat(input, "del")) {
+ is_add = 0;
+ } else if (unformat(input, "eid %U/%d", unformat_ip4_address,
+ &eidv4, &tmp_eid_lenght)) {
+ eid_lenght = tmp_eid_lenght;
+ eidv4_set = 1;
+ } else if (unformat(input, "eid %U/%d", unformat_ip6_address,
+ &eidv6, &tmp_eid_lenght)) {
+ eid_lenght = tmp_eid_lenght;
+ eidv6_set = 1;
+ } else if (unformat(input, "sloc %U", unformat_ip4_address, &slocv4)) {
+ slocv4_set = 1;
+ } else if (unformat(input, "sloc %U", unformat_ip6_address, &slocv6)) {
+ slocv6_set = 1;
+ } else if (unformat(input, "dloc %U", unformat_ip4_address, &dlocv4)) {
+ dlocv4_set = 1;
+ } else if (unformat(input, "dloc %U", unformat_ip6_address, &dlocv6)) {
+ dlocv6_set = 1;
+ } else
+ break;
+ }
+
+ if (eidv4_set && eidv6_set) {
+ errmsg ("both eid v4 and v6 addresses set\n");
+ return -99;
+ }
+
+ if (!eidv4_set && !eidv6_set) {
+ errmsg ("eid addresses not set\n");
+ return -99;
+ }
+
+ if (slocv4_set && slocv6_set) {
+ errmsg ("both source v4 and v6 addresses set\n");
+ return -99;
+ }
+
+ if (!slocv4_set && !slocv6_set) {
+ errmsg ("source addresses not set\n");
+ return -99;
+ }
+
+ if (dlocv4_set && dlocv6_set) {
+ errmsg ("both destination v4 and v6 addresses set\n");
+ return -99;
+ }
+
+ if (dlocv4_set && dlocv6_set) {
+ errmsg ("destination addresses not set\n");
+ return -99;
+ }
+
+ if (!(slocv4_set == dlocv4_set && slocv6_set == dlocv6_set)) {
+ errmsg ("mixing type of source and destination address\n");
+ return -99;
+ }
+
+ /* Construct the API message */
+ M(LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry);
+
+ mp->is_add = is_add;
+ if (eidv6_set) {
+ mp->eid_is_ipv6 = 1;
+ clib_memcpy(mp->eid_ip_address, &eidv6, sizeof(eidv6));
+ } else {
+ mp->eid_is_ipv6 = 0;
+ clib_memcpy(mp->eid_ip_address, &eidv4, sizeof(eidv4));
+ }
+ mp->eid_prefix_len = eid_lenght;
+ if (slocv6_set) {
+ mp->address_is_ipv6 = 1;
+ clib_memcpy(mp->source_ip_address, &slocv6, sizeof(slocv6));
+ clib_memcpy(mp->destination_ip_address, &dlocv6, sizeof(dlocv6));
+ } else {
+ mp->address_is_ipv6 = 0;
+ clib_memcpy(mp->source_ip_address, &slocv4, sizeof(slocv4));
+ clib_memcpy(mp->destination_ip_address, &dlocv4, sizeof(dlocv4));
+ }
+
+ /* send it... */
+ S;
+
+ /* Wait for a reply... */
+ W;
+
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_lisp_add_del_map_resolver(vat_main_t * vam)
+{
+ unformat_input_t * input = vam->input;
+ vl_api_lisp_add_del_map_resolver_t *mp;
+ f64 timeout = ~0;
+ u8 is_add = 1;
+ u8 ipv4_set = 0;
+ u8 ipv6_set = 0;
+ ip4_address_t ipv4;
+ ip6_address_t ipv6;
+
+ /* Parse args required to build the message */
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
+ if (unformat(input, "del")) {
+ is_add = 0;
+ } else if (unformat(input, "%U", unformat_ip4_address, &ipv4)) {
+ ipv4_set = 1;
+ } else if (unformat(input, "%U", unformat_ip6_address, &ipv6)) {
+ ipv6_set = 1;
+ } else
+ break;
+ }
+
+ if (ipv4_set && ipv6_set) {
+ errmsg ("both eid v4 and v6 addresses set\n");
+ return -99;
+ }
+
+ if (!ipv4_set && !ipv6_set) {
+ errmsg ("eid addresses not set\n");
+ return -99;
+ }
+
+ /* Construct the API message */
+ M(LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver);
+
+ mp->is_add = is_add;
+ if (ipv6_set) {
+ mp->is_ipv6 = 1;
+ clib_memcpy(mp->ip_address, &ipv6, sizeof(ipv6));
+ } else {
+ mp->is_ipv6 = 0;
+ clib_memcpy(mp->ip_address, &ipv4, sizeof(ipv4));
+ }
+
+ /* send it... */
+ S;
+
+ /* Wait for a reply... */
+ W;
+
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_lisp_gpe_enable_disable (vat_main_t * vam)
+{
+ unformat_input_t * input = vam->input;
+ vl_api_lisp_gpe_enable_disable_t *mp;
+ f64 timeout = ~0;
+ u8 is_set = 0;
+ u8 is_en = 1;
+
+ /* Parse args required to build the message */
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
+ if (unformat(input, "enable")) {
+ is_set = 1;
+ is_en = 1;
+ } else if (unformat(input, "disable")) {
+ is_set = 1;
+ is_en = 0;
+ } else
+ break;
+ }
+
+ if (is_set == 0) {
+ errmsg("Value not set\n");
+ return -99;
+ }
+
+ /* Construct the API message */
+ M(LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable);
+
+ mp->is_en = is_en;
+
+ /* send it... */
+ S;
+
+ /* Wait for a reply... */
+ W;
+
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_lisp_enable_disable (vat_main_t * vam)
+{
+ unformat_input_t * input = vam->input;
+ vl_api_lisp_enable_disable_t *mp;
+ f64 timeout = ~0;
+ u8 is_set = 0;
+ u8 is_en = 0;
+
+ /* Parse args required to build the message */
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "enable"))
+ {
+ is_set = 1;
+ is_en = 1;
+ }
+ else if (unformat (input, "disable"))
+ {
+ is_set = 1;
+ }
+ else
+ break;
+ }
+
+ if (!is_set)
+ {
+ errmsg ("Value not set\n");
+ return -99;
+ }
+
+ /* Construct the API message */
+ M(LISP_ENABLE_DISABLE, lisp_enable_disable);
+
+ mp->is_en = is_en;
+
+ /* send it... */
+ S;
+
+ /* Wait for a reply... */
+ W;
+
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_lisp_gpe_add_del_iface(vat_main_t * vam)
+{
+ unformat_input_t * input = vam->input;
+ vl_api_lisp_gpe_add_del_iface_t *mp;
+ f64 timeout = ~0;
+ u8 is_set = 0;
+ u8 is_add = 1;
+ u32 table_id, vni;
+
+ /* Parse args required to build the message */
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
+ if (unformat(input, "up")) {
+ is_set = 1;
+ is_add = 1;
+ } else if (unformat(input, "down")) {
+ is_set = 1;
+ is_add = 0;
+ } else if (unformat(input, "table_id %d", &table_id)) {
+ ;
+ } else if (unformat(input, "vni %d", &vni)) {
+ ;
+ } else
+ break;
+ }
+
+ if (is_set == 0) {
+ errmsg("Value not set\n");
+ return -99;
+ }
+
+ /* Construct the API message */
+ M(LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface);
+
+ mp->is_add = is_add;
+ mp->table_id = table_id;
+ mp->vni = vni;
+
+ /* send it... */
+ S;
+
+ /* Wait for a reply... */
+ W;
+
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_lisp_locator_set_dump(vat_main_t *vam)
+{
+ vl_api_lisp_locator_set_dump_t *mp;
+ f64 timeout = ~0;
+
+ if (!vam->json_output) {
+ fformat(vam->ofp, "%=20s%=16s%=16s%=16s\n",
+ "Locator-set", "Locator", "Priority", "Weight");
+ }
+
+ M(LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
+ /* send it... */
+ S;
+
+ /* Use a control ping for synchronization */
+ {
+ vl_api_control_ping_t * mp;
+ M(CONTROL_PING, control_ping);
+ S;
+ }
+ /* Wait for a reply... */
+ W;
+
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_lisp_local_eid_table_dump(vat_main_t *vam)
+{
+ vl_api_lisp_local_eid_table_dump_t *mp;
+ f64 timeout = ~0;
+
+ if (!vam->json_output) {
+ fformat(vam->ofp, "%=20s%=30s\n",
+ "Locator-set", "Eid");
+ }
+
+ M(LISP_LOCAL_EID_TABLE_DUMP, lisp_local_eid_table_dump);
+ /* send it... */
+ S;
+
+ /* Use a control ping for synchronization */
+ {
+ vl_api_control_ping_t * mp;
+ M(CONTROL_PING, control_ping);
+ S;
+ }
+ /* Wait for a reply... */
+ W;
+
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_lisp_gpe_tunnel_dump(vat_main_t *vam)
+{
+ vl_api_lisp_gpe_tunnel_dump_t *mp;
+ f64 timeout = ~0;
+
+ if (!vam->json_output) {
+ fformat(vam->ofp, "%=20s%=30s%=16s%=16s%=16s%=16s"
+ "%=16s%=16s%=16s%=16s%=16s\n",
+ "Tunel", "Source", "Destination", "Fib encap", "Fib decap",
+ "Decap next", "Lisp version", "Flags", "Next protocol",
+ "ver_res", "res", "iid");
+ }
+
+ M(LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump);
+ /* send it... */
+ S;
+
+ /* Use a control ping for synchronization */
+ {
+ vl_api_control_ping_t * mp;
+ M(CONTROL_PING, control_ping);
+ S;
+ }
+ /* Wait for a reply... */
+ W;
+
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_lisp_map_resolver_dump(vat_main_t *vam)
+{
+ vl_api_lisp_map_resolver_dump_t *mp;
+ f64 timeout = ~0;
+
+ if (!vam->json_output) {
+ fformat(vam->ofp, "%=20s\n",
+ "Map resolver");
+ }
+
+ M(LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump);
+ /* send it... */
+ S;
+
+ /* Use a control ping for synchronization */
+ {
+ vl_api_control_ping_t * mp;
+ M(CONTROL_PING, control_ping);
+ S;
+ }
+ /* Wait for a reply... */
+ W;
+
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_lisp_enable_disable_status_dump(vat_main_t *vam)
+{
+ vl_api_lisp_enable_disable_status_dump_t *mp;
+ f64 timeout = ~0;
+
+ if (!vam->json_output) {
+ fformat(vam->ofp, "%=20s\n",
+ "lisp status:");
+ }
+
+ M(LISP_ENABLE_DISABLE_STATUS_DUMP,
+ lisp_enable_disable_status_dump);
+ /* send it... */
+ S;
+
+ /* Use a control ping for synchronization */
+ {
+ vl_api_control_ping_t * mp;
+ M(CONTROL_PING, control_ping);
+ S;
+ }
+ /* Wait for a reply... */
+ W;
+
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_af_packet_create (vat_main_t * vam)
+{
+ unformat_input_t * i = vam->input;
+ vl_api_af_packet_create_t * mp;
+ f64 timeout;
+ u8 * host_if_name = 0;
+ u8 hw_addr[6];
+ u8 random_hw_addr = 1;
+
+ memset (hw_addr, 0, sizeof (hw_addr));
+
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) {
+ if (unformat (i, "name %s", &host_if_name))
+ vec_add1 (host_if_name, 0);
+ else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
+ random_hw_addr = 0;
+ else
+ break;
+ }
+
+ if (!vec_len (host_if_name)) {
+ errmsg ("host-interface name must be specified");
+ return -99;
+ }
+
+ if (vec_len (host_if_name) > 64) {
+ errmsg ("host-interface name too long");
+ return -99;
+ }
+
+ M(AF_PACKET_CREATE, af_packet_create);
+
+ clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
+ clib_memcpy (mp->hw_addr, hw_addr, 6);
+ mp->use_random_hw_addr = random_hw_addr;
+ vec_free (host_if_name);
+
+ S; W;
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_af_packet_delete (vat_main_t * vam)
+{
+ unformat_input_t * i = vam->input;
+ vl_api_af_packet_delete_t * mp;
+ f64 timeout;
+ u8 * host_if_name = 0;
+
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) {
+ if (unformat (i, "name %s", &host_if_name))
+ vec_add1 (host_if_name, 0);
+ else
+ break;
+ }
+
+ if (!vec_len (host_if_name)) {
+ errmsg ("host-interface name must be specified");
+ return -99;
+ }
+
+ if (vec_len (host_if_name) > 64) {
+ errmsg ("host-interface name too long");
+ return -99;
+ }
+
+ M(AF_PACKET_DELETE, af_packet_delete);
+
+ clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
+ vec_free (host_if_name);
+
+ S; W;
+ /* NOTREACHED */
+ return 0;
+}
+