40 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 58 if (ni == (
uword) ~ 0)
104 * client_state,
u32 type)
115 u32 dhcp_opt_len = 0;
135 if (src_addr.
as_u8[0] != 0xfe)
137 clib_warning (
"Could not find source address to send DHCPv6 packet");
154 b->
flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
163 clib_host_to_net_u32 (0x6 << 28);
177 void *d = (
void *) dhcp->
data;
178 dhcpv6_option_t *duid;
179 dhcpv6_elapsed_t *elapsed;
180 dhcpv6_ia_header_t *ia_hdr;
181 dhcpv6_ia_opt_pd_t *opt_pd;
186 duid = (dhcpv6_option_t *) d;
187 duid->option = clib_host_to_net_u16 (DHCPV6_OPTION_CLIENTID);
197 duid = (dhcpv6_option_t *) d;
198 duid->option = clib_host_to_net_u16 (DHCPV6_OPTION_SERVERID);
199 duid->length = clib_host_to_net_u16 (se->
len);
201 d +=
sizeof (*duid) + se->
len;
204 elapsed = (dhcpv6_elapsed_t *) d;
205 elapsed->opt.option = clib_host_to_net_u16 (DHCPV6_OPTION_ELAPSED_TIME);
206 elapsed->opt.length =
207 clib_host_to_net_u16 (
sizeof (*elapsed) -
sizeof (elapsed->opt));
208 elapsed->elapsed_10ms = 0;
210 (
char *) &elapsed->elapsed_10ms -
212 d +=
sizeof (*elapsed);
214 ia_hdr = (dhcpv6_ia_header_t *) d;
215 ia_hdr->opt.option = clib_host_to_net_u16 (DHCPV6_OPTION_IA_PD);
217 ia_hdr->t1 = clib_host_to_net_u32 (client_state->
params.
T1);
218 ia_hdr->t2 = clib_host_to_net_u32 (client_state->
params.
T2);
219 d +=
sizeof (*ia_hdr);
224 clib_host_to_net_u16 (
sizeof (*ia_hdr) +
225 n_prefixes *
sizeof (*opt_pd) -
226 sizeof (ia_hdr->opt));
228 for (i = 0; i < n_prefixes; i++)
232 opt_pd = (dhcpv6_ia_opt_pd_t *) d;
233 opt_pd->opt.option = clib_host_to_net_u16 (DHCPV6_OPTION_IAPREFIX);
235 clib_host_to_net_u16 (
sizeof (*opt_pd) -
sizeof (opt_pd->opt));
236 opt_pd->addr = pref->
prefix;
238 opt_pd->valid = clib_host_to_net_u32 (pref->
valid_lt);
239 opt_pd->preferred = clib_host_to_net_u32 (pref->
preferred_lt);
240 d +=
sizeof (*opt_pd);
248 dhcp_opt_len = ((
u8 *) d) - dhcp->
data;
250 clib_host_to_net_u16 (
sizeof (*udp) +
sizeof (*dhcp) + dhcp_opt_len);
253 sizeof (*ip) +
sizeof (*udp) +
sizeof (*dhcp) + dhcp_opt_len;
263 f64 current_time,
f64 * due_time)
273 int bogus_length = 0;
282 params = &client_state->
params;
284 if (client_state->
due_time > current_time)
290 p0 = client_state->
buffer;
302 clib_host_to_net_u16 ((
u16)
315 if (params->
mrc != 0 && --client_state->
n_left == 0)
344 uword *event_data = 0;
345 f64 sleep_time = 1e9;
360 due_time = current_time + 1e9;
367 (vm, client_state, current_time, &dt) && (dt < due_time))
372 while (due_time < current_time);
374 sleep_time = due_time - current_time;
384 .name =
"send-dhcp6-pd-client-message-process",
398 ASSERT (~0 != sw_if_index);
415 client_state->
params = *params;
426 if (!client_state->
buffer)
439 vl_api_dhcp6_pd_send_client_message_reply_t *rmp;
449 REPLY_MACRO (VL_API_DHCP6_PD_SEND_CLIENT_MESSAGE_REPLY);
456 params.
irt = ntohl (mp->
irt);
457 params.
mrt = ntohl (mp->
mrt);
458 params.
mrc = ntohl (mp->
mrc);
459 params.
mrd = ntohl (mp->
mrd);
461 params.
T1 = ntohl (mp->
T1);
462 params.
T2 = ntohl (mp->
T2);
467 for (i = 0; i < n_prefixes; i++)
484 _vnet_dhcp6_pd_reply_event_function_list_elt_t
491 error = elt->fp (data);
494 elt = elt->next_dhcp6_pd_reply_event_function;
518 for (i = 0; i <
vec_len (events); i++)
522 vec_len (events[i].prefixes) *
526 memset (event, 0, event_size);
528 event->sw_if_index = htonl (events[i].body.sw_if_index);
529 event->server_index = htonl (events[i].body.server_index);
531 event->T1 = htonl (events[i].body.T1);
532 event->T2 = htonl (events[i].body.T2);
533 event->inner_status_code =
534 htons (events[i].body.inner_status_code);
535 event->status_code = htons (events[i].body.status_code);
538 event->n_prefixes = htonl (vec_len (events[i].prefixes));
540 (typeof (prefix)) event->prefixes;
542 for (j = 0; j <
vec_len (events[i].prefixes); j++)
561 vl_api_registration_t *vl_reg;
563 vl_api_client_index_to_registration (reg->client_index);
564 if (vl_reg && vl_api_can_send_msg (vl_reg))
566 vl_api_dhcp6_pd_reply_event_t *msg =
567 vl_msg_api_alloc (event_size);
568 clib_memcpy (msg, event, event_size);
569 msg->_vl_msg_id = htons (VL_API_DHCP6_PD_REPLY_EVENT);
570 msg->client_index = reg->client_index;
571 msg->pid = reg->client_pid;
572 vl_api_send_msg (vl_reg, (u8 *) msg);
590 .name =
"dhcp6-pd-reply-publisher-process",
599 vl_api_want_dhcp6_pd_reply_events_reply_t *rmp;
610 rv = VNET_API_ERROR_INVALID_REGISTRATION;
617 pool_put (am->dhcp6_pd_reply_events_registrations, rp);
618 hash_unset (am->dhcp6_pd_reply_events_registration_hash,
620 if (
pool_elts (am->dhcp6_pd_reply_events_registrations) == 0)
628 rv = VNET_API_ERROR_INVALID_REGISTRATION;
631 pool_get (am->dhcp6_pd_reply_events_registrations, rp);
635 rp - am->dhcp6_pd_reply_events_registrations);
640 REPLY_MACRO (VL_API_WANT_DHCP6_PD_REPLY_EVENTS_REPLY);
653 cm->
seed = 0xdeaddabe;
#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.
#define hash_set(h, key, value)
static clib_error_t * call_dhcp6_pd_reply_event_callbacks(void *data, _vnet_dhcp6_pd_reply_event_function_list_elt_t *elt)
static clib_error_t * dhcp6_pd_client_init(vlib_main_t *vm)
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
#define hash_unset(h, key)
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
static uword * vlib_process_wait_for_event(vlib_main_t *vm)
dhcp6_pd_client_main_t dhcp6_pd_client_main
vnet_main_t * vnet_get_main(void)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
dhcp6_pd_client_state_t * client_state_by_sw_if_index
static f64 vlib_time_now(vlib_main_t *vm)
dhcp6_pd_send_client_message_params_prefix_t * prefixes
for(i=1;i<=collision_buckets;i++)
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 vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
#define DHCPV6_CLIENT_PORT
#define VNET_HW_INTERFACE_FLAG_LINK_UP
int dhcp6_pd_publish_report(prefix_report_t *r)
static uword send_dhcp6_pd_client_message_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f0)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
static vlib_buffer_t * vlib_buffer_copy(vlib_main_t *vm, vlib_buffer_t *b)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
vlib_node_registration_t ip6_rewrite_mcast_node
(constructor) VLIB_REGISTER_NODE (ip6_rewrite_mcast_node)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type...
static u8 check_pd_send_client_message(vlib_main_t *vm, dhcp6_pd_client_state_t *client_state, f64 current_time, f64 *due_time)
static vnet_sw_interface_t * vnet_get_sup_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
void dhcp6_pd_set_publisher_node(uword node_index, uword event_type)
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
void vl_api_rpc_call_main_thread(void *fp, u8 *data, u32 data_length)
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Struct representing DHCPv6 PD prefix.
u16 current_length
Nbytes between current data and the end of this buffer.
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
#define pool_put(P, E)
Free an object E in pool P.
static void stop_sending_client_message(vlib_main_t *vm, dhcp6_pd_client_state_t *client_state)
dhcp6_pd_client_public_main_t dhcp6_pd_client_public_main
#define vec_dup(V)
Return copy of vector (no header, no alignment)
static void * vlib_process_signal_event_data(vlib_main_t *vm, uword node_index, uword type_opaque, uword n_data_elts, uword n_data_elt_bytes)
static vlib_buffer_t * create_buffer_for_client_message(vlib_main_t *vm, u32 sw_if_index, dhcp6_pd_client_state_t *client_state, u32 type)
dhcpv6_duid_ll_string_t client_duid
void vl_api_dhcp6_pd_send_client_message_t_handler(vl_api_dhcp6_pd_send_client_message_t *mp)
#define CLIENT_DUID_LENGTH
_vnet_dhcp6_pd_reply_event_function_list_elt_t * functions
#define BAD_SW_IF_INDEX_LABEL
#define VLIB_REGISTER_NODE(x,...)
#define DHCPV6_CLIENT_IAID
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
#define clib_memcpy(a, b, c)
static vlib_node_registration_t send_dhcp6_pd_client_message_process_node
(constructor) VLIB_REGISTER_NODE (send_dhcp6_pd_client_message_process_node)
u16 ip6_tcp_udp_icmp_compute_checksum(vlib_main_t *vm, vlib_buffer_t *p0, ip6_header_t *ip0, int *bogus_lengthp)
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
static void signal_report(prefix_report_t *r)
dhcp6_report_common_t body
static void clib_mem_free(void *p)
u8 keep_sending_client_message
Tell client about a DHCPv6 PD server reply event.
static uword dhcp6_pd_reply_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
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)
dhcp6_client_common_main_t dhcp6_client_common_main
Register for DHCPv6 PD reply events.
ip6_address_t ip6_neighbor_get_link_local_address(u32 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)
void vl_api_want_dhcp6_pd_reply_events_t_handler(vl_api_want_dhcp6_pd_reply_events_t *mp)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
#define DHCPV6_SERVER_PORT
static u32 random_u32(u32 *seed)
32-bit random number generator
vlib_node_registration_t dhcp6_pd_reply_process_node
(constructor) VLIB_REGISTER_NODE (dhcp6_pd_reply_process_node)
static void vlib_process_put_event_data(vlib_main_t *vm, void *event_data)
adj_index_t adj_mcast_add_or_lock(fib_protocol_t proto, vnet_link_t link_type, u32 sw_if_index)
Mcast Adjacency.
dhcp6_pd_send_client_message_params_t params
static const ip6_address_t all_dhcp6_relay_agents_and_servers
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header, unspecified alignment)
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
vpe_api_main_t vpe_api_main
static u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
dhcp6_prefix_info_t * prefixes
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
#define VALIDATE_SW_IF_INDEX(mp)
static_always_inline f64 random_f64_from_to(f64 from, f64 to)
static uword pool_elts(void *v)
Number of active elements in a pool.