2 * Copyright (c) 2015 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
17 #include <vlibapi/api.h>
18 #include <vlibmemory/api.h>
19 #include <vppinfra/error.h>
21 #include <vnet/ip/ip.h>
22 #include <vnet/ip/ip_format_fns.h>
23 #include <vnet/ethernet/ethernet_format_fns.h>
25 /* define message IDs */
26 #include <lldp/lldp.api_enum.h>
27 #include <lldp/lldp.api_types.h>
31 /* API message ID base */
36 lldp_test_main_t lldp_test_main;
38 #define __plugin_msg_base lldp_test_main.msg_id_base
39 #include <vlibapi/vat_helper_macros.h>
43 vlib_cli_output (handle, (char *) s); \
48 api_lldp_config (vat_main_t * vam)
50 unformat_input_t *i = vam->input;
51 vl_api_lldp_config_t *mp;
57 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
59 if (unformat (i, "system-name %s", &sys_name))
61 else if (unformat (i, "tx-hold %d", &tx_hold))
63 else if (unformat (i, "tx-interval %d", &tx_interval))
67 clib_warning ("parse error '%U'", format_unformat_error, i);
72 vec_add1 (sys_name, 0);
75 mp->tx_hold = htonl (tx_hold);
76 mp->tx_interval = htonl (tx_interval);
77 vl_api_vec_to_api_string (sys_name, &mp->system_name);
86 api_sw_interface_set_lldp (vat_main_t * vam)
88 unformat_input_t *i = vam->input;
89 vl_api_sw_interface_set_lldp_t *mp;
92 u8 *port_desc = NULL, *mgmt_oid = NULL;
93 ip4_address_t ip4_addr;
94 ip6_address_t ip6_addr;
97 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
98 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
100 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
102 if (unformat (i, "disable"))
105 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
107 else if (unformat (i, "sw_if_index %d", &sw_if_index))
109 else if (unformat (i, "port-desc %s", &port_desc))
111 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
113 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
115 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
121 if (sw_if_index == ~0)
123 errmsg ("missing interface name or sw_if_index");
127 /* Construct the API message */
128 vec_add1 (port_desc, 0);
129 vec_add1 (mgmt_oid, 0);
130 M (SW_INTERFACE_SET_LLDP, mp);
131 mp->sw_if_index = ntohl (sw_if_index);
133 vl_api_vec_to_api_string (port_desc, &mp->port_desc);
134 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
135 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
136 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
137 vec_free (port_desc);
145 #include <lldp/lldp.api_test.c>