35 #include <dhcp/dhcp.api_enum.h> 36 #include <dhcp/dhcp.api_types.h> 42 #define REPLY_MSG_ID_BASE dhcp_base_msg_id 46 #define DHCP_PLUGIN_VERSION_MAJOR 1 47 #define DHCP_PLUGIN_VERSION_MINOR 0 54 int msg_size =
sizeof (*rmp);
82 rmp->
vpe_pid = ntohl (getpid ());
90 vl_api_dhcp6_duid_ll_set_reply_t *rmp;
97 rv = VNET_API_ERROR_INVALID_VALUE;
109 vl_api_dhcp_proxy_set_vss_reply_t *rmp;
128 vl_api_dhcp_proxy_set_vss_reply_t *rmp;
129 ip46_address_t
src, server;
134 rv = VNET_API_ERROR_INVALID_ARGUMENT;
181 vl_api_dhcp_server_t *v_server;
189 n =
sizeof (*mp) + (count *
sizeof (vl_api_dhcp_server_t));
233 v_server->server_vrf_id = htonl (s_fib->
ft_table_id);
237 memcpy (&v_server->dhcp_server.un, &server->
dhcp_server.ip6, 16);
242 memcpy (&v_server->dhcp_server.un, &server->
dhcp_server.ip4, 4);
267 lease->state = ntohl (client->
state);
270 lease->hostname[
len] = 0;
281 for (i = 0; i < lease->count; i++)
295 vclient->sw_if_index = ntohl (client->
sw_if_index);
298 vclient->hostname[
len] = 0;
300 len =
clib_min (
sizeof (vclient->id) - 1,
303 vclient->id[
len] = 0;
306 vclient->want_dhcp_event = 1;
308 vclient->want_dhcp_event = 0;
311 vclient->pid = client->
pid;
338 vl_api_dhcp_client_config_reply_t *rmp;
345 sw_if_index = ntohl (mp->
client.sw_if_index);
354 (mp->
client.want_dhcp_event ?
357 mp->
client.set_broadcast_flag,
381 n =
sizeof (*mp) + (count *
sizeof (vl_api_domain_server_t));
418 vl_api_dhcp6_clients_enable_disable_reply_t *rmp;
423 REPLY_MACRO (VL_API_DHCP6_CLIENTS_ENABLE_DISABLE_REPLY);
431 vl_api_want_dhcp6_reply_events_reply_t *rmp;
442 rv = VNET_API_ERROR_INVALID_REGISTRATION;
448 pool_put (am->dhcp6_reply_events_registrations, rp);
449 hash_unset (am->dhcp6_reply_events_registration_hash,
451 if (
pool_elts (am->dhcp6_reply_events_registrations) == 0)
459 rv = VNET_API_ERROR_INVALID_REGISTRATION;
462 pool_get (am->dhcp6_reply_events_registrations, rp);
466 rp - am->dhcp6_reply_events_registrations);
471 REPLY_MACRO (VL_API_WANT_DHCP6_REPLY_EVENTS_REPLY);
479 vl_api_want_dhcp6_pd_reply_events_reply_t *rmp;
490 rv = VNET_API_ERROR_INVALID_REGISTRATION;
497 pool_put (am->dhcp6_pd_reply_events_registrations, rp);
498 hash_unset (am->dhcp6_pd_reply_events_registration_hash,
500 if (
pool_elts (am->dhcp6_pd_reply_events_registrations) == 0)
508 rv = VNET_API_ERROR_INVALID_REGISTRATION;
511 pool_get (am->dhcp6_pd_reply_events_registrations, rp);
515 rp - am->dhcp6_pd_reply_events_registrations);
520 REPLY_MACRO (VL_API_WANT_DHCP6_PD_REPLY_EVENTS_REPLY);
527 vl_api_dhcp6_send_client_message_reply_t *rmp;
537 REPLY_MACRO (VL_API_DHCP6_SEND_CLIENT_MESSAGE_REPLY);
544 params.
irt = ntohl (mp->
irt);
545 params.
mrt = ntohl (mp->
mrt);
546 params.
mrc = ntohl (mp->
mrc);
547 params.
mrd = ntohl (mp->
mrd);
549 params.
T1 = ntohl (mp->
T1);
550 params.
T2 = ntohl (mp->
T2);
555 rv = VNET_API_ERROR_INVALID_VALUE;
556 goto bad_sw_if_index;
561 for (i = 0; i < n_addresses; i++)
563 vl_api_dhcp6_address_info_t *ai = &mp->
addresses[
i];
566 addr->
valid_lt = ntohl (ai->valid_time);
577 vl_api_dhcp6_pd_send_client_message_reply_t *rmp;
587 REPLY_MACRO (VL_API_DHCP6_PD_SEND_CLIENT_MESSAGE_REPLY);
594 params.
irt = ntohl (mp->
irt);
595 params.
mrt = ntohl (mp->
mrt);
596 params.
mrc = ntohl (mp->
mrc);
597 params.
mrd = ntohl (mp->
mrd);
599 params.
T1 = ntohl (mp->
T1);
600 params.
T2 = ntohl (mp->
T2);
606 rv = VNET_API_ERROR_INVALID_VALUE;
607 goto bad_sw_if_index;
613 for (i = 0; i < n_prefixes; i++)
615 vl_api_dhcp6_pd_prefix_info_t *pi = &mp->
prefixes[
i];
619 pref->
valid_lt = ntohl (pi->valid_time);
630 _vnet_dhcp6_reply_event_function_list_elt_t
637 error = elt->fp (data);
640 elt = elt->next_dhcp6_reply_event_function;
664 for (i = 0; i <
vec_len (events); i++)
668 vec_len (events[i].addresses) *
669 sizeof (vl_api_dhcp6_address_info_t);
673 event->sw_if_index = htonl (events[i].body.sw_if_index);
674 event->server_index = htonl (events[i].body.server_index);
676 event->T1 = htonl (events[i].body.T1);
677 event->T2 = htonl (events[i].body.T2);
678 event->inner_status_code =
679 htons (events[i].body.inner_status_code);
680 event->status_code = htons (events[i].body.status_code);
683 event->n_addresses = htonl (vec_len (events[i].addresses));
684 vl_api_dhcp6_address_info_t *
address =
685 (typeof (address)) event->addresses;
687 for (j = 0; j <
vec_len (events[i].addresses); j++)
691 address->valid_time = htonl (info->
valid_time);
705 vl_api_registration_t *vl_reg;
707 vl_api_client_index_to_registration (reg->client_index);
708 if (vl_reg && vl_api_can_send_msg (vl_reg))
710 vl_api_dhcp6_reply_event_t *msg =
711 vl_msg_api_alloc (event_size);
712 clib_memcpy (msg, event, event_size);
713 msg->_vl_msg_id = htons (VL_API_DHCP6_REPLY_EVENT + REPLY_MSG_ID_BASE);
714 msg->client_index = reg->client_index;
715 msg->pid = reg->client_pid;
716 vl_api_send_msg (vl_reg, (u8 *) msg);
734 .name =
"dhcp6-reply-publisher-process",
740 _vnet_dhcp6_pd_reply_event_function_list_elt_t
747 error = elt->fp (data);
750 elt = elt->next_dhcp6_pd_reply_event_function;
774 for (i = 0; i <
vec_len (events); i++)
778 vec_len (events[i].prefixes) *
779 sizeof (vl_api_dhcp6_pd_prefix_info_t);
784 event->sw_if_index = htonl (events[i].body.sw_if_index);
785 event->server_index = htonl (events[i].body.server_index);
787 event->T1 = htonl (events[i].body.T1);
788 event->T2 = htonl (events[i].body.T2);
789 event->inner_status_code =
790 htons (events[i].body.inner_status_code);
791 event->status_code = htons (events[i].body.status_code);
794 event->n_prefixes = htonl (vec_len (events[i].prefixes));
795 vl_api_dhcp6_pd_prefix_info_t *
prefix =
796 (typeof (prefix)) event->prefixes;
798 for (j = 0; j <
vec_len (events[i].prefixes); j++)
803 prefix->valid_time = htonl (info->
valid_time);
817 vl_api_registration_t *vl_reg;
819 vl_api_client_index_to_registration (reg->client_index);
820 if (vl_reg && vl_api_can_send_msg (vl_reg))
822 vl_api_dhcp6_pd_reply_event_t *msg =
823 vl_msg_api_alloc (event_size);
824 clib_memcpy (msg, event, event_size);
825 msg->_vl_msg_id = htons (VL_API_DHCP6_PD_REPLY_EVENT + REPLY_MSG_ID_BASE);
826 msg->client_index = reg->client_index;
827 msg->pid = reg->client_pid;
828 vl_api_send_msg (vl_reg, (u8 *) msg);
846 .name =
"dhcp6-pd-reply-publisher-process",
857 #include <dhcp/dhcp.api.c> 878 #include <vpp/app/version.h> 882 .version = VPP_BUILD_VER,
883 .description =
"Dynamic Host Configuration Protocol (DHCP)",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Send DHCPv6 PD client message of specified type.
Enable/disable listening on DHCPv6 client port.
DHCP Proxy set / unset vss request.
vl_api_dhcp_lease_t lease
#define vec_foreach_index(var, v)
Iterate over vector indices.
static dhcp_vss_t * dhcp_get_vss_info(dhcp_proxy_main_t *dm, u32 rx_fib_index, fib_protocol_t proto)
Get the VSS data for the FIB index.
#define hash_set(h, key, value)
vl_api_address_t dhcp_src_address
vl_api_dhcpv6_msg_type_t msg_type
#define hash_unset(h, key)
static uword * vlib_process_wait_for_event(vlib_main_t *vm)
static clib_error_t * dhcp_api_hookup(vlib_main_t *vm)
ip4_address_t router_address
The address of this client's default gateway - may not be present.
DHCP Client details returned from dump.
static void vl_api_dhcp6_duid_ll_set_t_handler(vl_api_dhcp6_duid_ll_set_t *mp)
dhcp_server_t * dhcp_servers
The set of DHCP servers to which messages are relayed.
#define REPLY_MACRO2(t, body)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
dhcp_proxy_main_t dhcp_proxy_main
Shard 4/6 instance of DHCP main.
_vnet_dhcp6_reply_event_function_list_elt_t * functions
int dhcp6_proxy_set_server(ip46_address_t *addr, ip46_address_t *src_addr, u32 rx_table_id, u32 server_table_id, int is_del)
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
void ip6_address_decode(const vl_api_ip6_address_t in, ip6_address_t *out)
ip46_address_t dhcp_src_address
The source address to use in relayed messaes.
The Virtual Sub-net Selection information for a given RX FIB.
dhcp6_pd_send_client_message_params_prefix_t * prefixes
for(i=1;i<=collision_buckets;i++)
void dhcp_send_details(fib_protocol_t proto, void *opaque, u32 context, dhcp_proxy_t *proxy)
Send the details of a proxy session to the API client during a dump.
u32 rx_fib_index
The FIB index (not the external Table-ID) in which the client is resides.
void dhcp6_pd_send_client_message(vlib_main_t *vm, u32 sw_if_index, u8 stop, dhcp6_pd_send_client_message_params_t *params)
static uword dhcp6_reply_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
void vl_api_dhcp6_pd_send_client_message_t_handler(vl_api_dhcp6_pd_send_client_message_t *mp)
static u32 dhcp_base_msg_id
Base message ID fot the plugin.
dhcp_client_fwd_addresses_t installed
u8 vss_type
VSS type as defined in RFC 6607: 0 for NVT ASCII VPN Identifier 1 for RFC 2685 VPN-ID of 7 octects - ...
static void vl_api_dhcp_client_dump_t_handler(vl_api_dhcp_client_dump_t *mp)
dhcp_client_state_t state
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
void * vl_msg_api_alloc(int nbytes)
void dhcp6_set_publisher_node(uword node_index, uword event_type)
static clib_error_t * call_dhcp6_reply_event_callbacks(void *data, _vnet_dhcp6_reply_event_function_list_elt_t *elt)
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
ip_dscp_t ip_dscp_decode(vl_api_ip_dscp_t in)
Dump the DHCP client configurations.
#define clib_memcpy(d, s, n)
void dhcp_proxy_dump(fib_protocol_t proto, void *opaque, u32 context)
Dump the proxy configs to the API.
void vl_api_want_dhcp6_reply_events_t_handler(vl_api_want_dhcp6_reply_events_t *mp)
vl_api_dhcp_client_t client
u32 vl_msg_api_max_length(void *mp)
vl_api_dhcp_server_t servers[count]
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
vl_api_interface_index_t sw_if_index
static void vl_api_dhcp_proxy_config_t_handler(vl_api_dhcp_proxy_config_t *mp)
#define DHCP_PLUGIN_VERSION_MINOR
static int send_dhcp_client_entry(const dhcp_client_t *client, void *arg)
Send DHCPv6 client message of specified type.
dhcp_event_cb_t event_callback
static void vl_api_dhcp_plugin_get_version_t_handler(vl_api_dhcp_plugin_get_version_t *mp)
void dhcp6_pd_set_publisher_node(uword node_index, uword event_type)
void vl_api_dhcp6_send_client_message_t_handler(vl_api_dhcp6_send_client_message_t *mp)
ip46_type_t ip_address_decode(const vl_api_address_t *in, ip46_address_t *out)
Decode/Encode for struct/union types.
u32 server_fib_index
The FIB index (not the external Table-ID) in which the server is reachable.
#define DHCP_PLUGIN_VERSION_MAJOR
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
struct dhcp_client_send_walk_ctx_t_ dhcp_client_send_walk_ctx_t
ip4_address_t leased_address
the address assigned to this client and it's mask
#define pool_put(P, E)
Free an object E in pool P.
dhcp6_pd_client_public_main_t dhcp6_pd_client_public_main
vl_api_dhcpv6_msg_type_t msg_type
static void vl_api_dhcp_proxy_dump_t_handler(vl_api_dhcp_proxy_dump_t *mp)
int dhcp_proxy_set_vss(fib_protocol_t proto, u32 tbl_id, u8 vss_type, u8 *vpn_ascii_id, u32 oui, u32 vpn_index, u8 is_del)
Configure/set a new VSS info.
Control ping from client to api server request.
static void dhcp_client_data_encode(vl_api_dhcp_client_t *vclient, const dhcp_client_t *client)
u8 client_hardware_address[6]
dhcpv6_duid_ll_string_t client_duid
static clib_error_t * call_dhcp6_pd_reply_event_callbacks(void *data, _vnet_dhcp6_pd_reply_event_function_list_elt_t *elt)
dhcp6_ia_na_client_public_main_t dhcp6_ia_na_client_public_main
_vnet_dhcp6_pd_reply_event_function_list_elt_t * functions
static void vl_api_dhcp_plugin_control_ping_t_handler(vl_api_dhcp_plugin_control_ping_t *mp)
An API client registration, only in vpp/vlib.
#define BAD_SW_IF_INDEX_LABEL
vl_api_vss_type_t vss_type
#define VLIB_REGISTER_NODE(x,...)
u8 * vpn_ascii_id
Type 0 ASCII VPN Identifier.
u32 ft_table_id
Table ID (hash key) for this FIB.
dhcp6_send_client_message_params_address_t * addresses
sll srl srl sll sra u16x4 i
ip4_address_t * domain_server_address
#define vec_free(V)
Free vector's memory (no header).
static void dhcp_compl_event_callback(u32 client_index, const dhcp_client_t *client)
#define clib_warning(format, args...)
string vss_vpn_ascii_id[129]
vl_api_registration_t * reg
A representation of a single DHCP Server within a given VRF config.
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
int dhcp4_proxy_set_server(ip46_address_t *addr, ip46_address_t *src_addr, u32 rx_table_id, u32 server_table_id, int is_del)
ip46_address_t dhcp_server
The address of the DHCP server to which to relay the client's messages.
manual_print typedef address
vl_api_ip_dscp_t ip_dscp_encode(ip_dscp_t dscp)
enum ip_dscp_t_ ip_dscp_t
dhcp6_report_common_t body
VLIB_API_INIT_FUNCTION(dhcp_api_hookup)
static void clib_mem_free(void *p)
static void vl_api_dhcp6_clients_enable_disable_t_handler(vl_api_dhcp6_clients_enable_disable_t *mp)
#define REPLY_MSG_ID_BASE
void dhcp_client_walk(dhcp_client_walk_cb_t cb, void *ctx)
Walk (visit each) DHCP client configuration.
Tell client about a DHCPv6 PD server reply event.
void ip6_address_encode(const ip6_address_t *in, vl_api_ip6_address_t out)
void dhcp6_send_client_message(vlib_main_t *vm, u32 sw_if_index, u8 stop, dhcp6_send_client_message_params_t *params)
vl_api_dhcp_lease_t lease
static void * clib_mem_alloc(uword size)
vl_api_dhcp6_pd_prefix_info_t prefixes[n_prefixes]
static vlib_main_t * vlib_get_main(void)
static uword dhcp6_pd_reply_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Tell client about a DHCP completion event.
Register for DHCPv6 PD reply events.
Tell client about a DHCPv6 server reply event.
vl_api_address_t dhcp_src_address
A DHCP proxy representation fpr per-client VRF config.
Reply to get the plugin version.
vl_api_interface_index_t sw_if_index
static void * vlib_process_get_event_data(vlib_main_t *vm, uword *return_event_type_opaque)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u8 vpn_id[7]
Type 1 VPN-ID.
vl_api_address_t dhcp_server
vl_api_interface_index_t sw_if_index
dhcp6_address_info_t * addresses
vl_api_dhcp6_address_info_t addresses[n_addresses]
vl_api_dhcp_client_t client
static void vl_api_dhcp_client_config_t_handler(vl_api_dhcp_client_config_t *mp)
Register for DHCPv6 reply events.
fib_table_t * fib_table_get(fib_node_index_t index, fib_protocol_t proto)
Get a pointer to a FIB table.
void vl_api_want_dhcp6_pd_reply_events_t_handler(vl_api_want_dhcp6_pd_reply_events_t *mp)
static void vl_api_dhcp_proxy_set_vss_t_handler(vl_api_dhcp_proxy_set_vss_t *mp)
void dhcp6_clients_enable_disable(u8 enable)
Control ping from the client to the server response.
static void vlib_process_put_event_data(vlib_main_t *vm, void *event_data)
vlib_node_registration_t dhcp6_reply_process_node
(constructor) VLIB_REGISTER_NODE (dhcp6_reply_process_node)
static void setup_message_id_table(snat_main_t *sm, api_main_t *am)
u32 dhcp_proxy_rx_table_get_table_id(fib_protocol_t proto, u32 fib_index)
static void dhcp_client_lease_encode(vl_api_dhcp_lease_t *lease, const dhcp_client_t *client)
vl_api_vss_type_t vss_type
dhcp6_report_common_t body
vpe_api_main_t vpe_api_main
Tell client about a DHCP completion event.
dhcp6_prefix_info_t * prefixes
DHCP Client config add / del request.
DHCP Proxy config add / del request.
#define VALIDATE_SW_IF_INDEX(mp)
A protocol Independent FIB table.
int dhcp_client_config(u32 is_add, u32 client_index, vlib_main_t *vm, u32 sw_if_index, u8 *hostname, u8 *client_id, dhcp_event_cb_t event_callback, u8 set_broadcast_flag, ip_dscp_t dscp, u32 pid)
Add/Delete DHCP clients.
static uword pool_elts(void *v)
Number of active elements in a pool.