20 #include <vpp/app/version.h> 50 clib_mem_free (src->key);
71 igmp_clear_group (config, group);
93 return dt < 0 ? -1 : (dt > 0 ? +1 : 0);
241 igmp->
header.
type = IGMP_TYPE_membership_report_v3;
246 igmp_group = igmp->
groups;
260 igmp_group->src_addresses[i++] = src->addr.ip4;
271 memset (igmp_group, 0, sizeof (igmp_membership_group_v3_t));
272 igmp_group->type = group->type;
273 igmp_group->n_src_addresses =
274 clib_host_to_net_u16 (pool_elts (group->srcs));
275 igmp_group->dst_address = group->addr.ip4;
277 pool_foreach (src, group->srcs, (
279 igmp_group->src_addresses[i++] = src->addr.ip4;
290 igmp->header.checksum = csum;
292 b->current_data += len;
293 b->current_length += len;
317 igmp->
header.
type = IGMP_TYPE_membership_query;
415 _vec_len (im->
buffers[thread_index]) = n_free_bufs;
419 u32 next0 = next_index;
422 if (n_left_to_next > 0)
430 bi = im->
buffers[thread_index][last_buf];
432 _vec_len (im->
buffers[thread_index]) = last_buf;
439 _vec_len (im->
buffers[thread_index]) = n_free_bufs;
450 b->
flags = VLIB_BUFFER_TOTAL_LENGTH_VALID;
453 b->
flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
461 n_left_to_next, bi, next0);
559 IGMP_DBG (
"sw_if_index %d", sw_if_index);
579 if (group->
type == IGMP_MEMBERSHIP_GROUP_change_to_filter_include)
586 new_gkey.
group_type = IGMP_MEMBERSHIP_GROUP_mode_is_filter_include;
599 sizeof (ip46_address_t));
608 new_group - config->
groups);
615 new_src = igmp_src_lookup (new_group, src->key);
618 pool_get (new_group->srcs, new_src);
619 memset (new_src, 0, sizeof (igmp_src_t));
620 new_group->n_srcs += 1;
621 new_src->key = clib_mem_alloc (sizeof (igmp_key_t));
622 clib_memcpy (new_src->key, src->key, sizeof (igmp_key_t));
623 clib_memcpy (&new_src->addr, &src->addr,
624 sizeof (ip46_address_t));
626 hash_set_mem (new_group->igmp_src_by_key, new_src->key,
627 new_src - new_group->srcs);
638 hash_unset (im->igmp_config_by_sw_if_index, config->sw_if_index);
673 ip46_address_t saddr;
674 ip46_address_t gaddr;
697 uword *event_data = 0, event_type;
716 timer->
func (vm, rt, im, timer);
728 .name =
"igmp-timer-process",
739 ip46_address_t saddr, ip46_address_t gaddr,
740 u8 cli_api_configured)
750 (cli_api_configured) ?
751 IGMP_MEMBERSHIP_GROUP_change_to_filter_include :
752 IGMP_MEMBERSHIP_GROUP_mode_is_filter_include;
778 if (!cli_api_configured)
808 if (cli_api_configured)
828 if (!cli_api_configured)
850 gkey.
group_type = IGMP_MEMBERSHIP_GROUP_mode_is_filter_include;
863 IGMP_MEMBERSHIP_GROUP_block_old_sources;
876 sizeof (ip46_address_t));
883 new_group - config->
groups);
896 sizeof (ip46_address_t));
898 new_src - new_group->
srcs);
902 if (!cli_api_configured)
957 hw_if_index)->sw_if_index);
989 #define igmp_type(n,s) \ 991 vec_add2 (im->type_infos, ti, 1); \ 993 ti->name = (u8 *) #s; \ 995 #define igmp_report_type(n,s) \ 997 vec_add2 (im->report_type_infos, rti, 1); \ 999 rti->name = (u8 *) #s; \ 1003 #undef igmp_report_type 1017 ip46_address_t addr0 = {
1024 ip46_address_t addr1 = {
1033 .frp_sw_if_index = 0xffffffff,
1042 .fp_grp_addr = addr0,
1048 .fp_grp_addr = addr1,
1070 .version = VPP_BUILD_VER,
1071 .description =
"IGMP messaging",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
igmp_membership_group_v3_type_t type
igmp_membership_group_v3_type_t type
#define IGMP_CONFIG_FLAG_CAN_SEND_REPORT
#define IGMP_GROUP_FLAG_QUERY_RESP_RECVED
reponse to query was received
static igmp_timer_t * igmp_get_next_timer(igmp_main_t *im)
igmp get next timer
#define hash_set(h, key, value)
vlib_node_registration_t igmp_timer_process_node
(constructor) VLIB_REGISTER_NODE (igmp_timer_process_node)
igmp_membership_group_v3_t groups[0]
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 uword * vlib_process_wait_for_event(vlib_main_t *vm)
A representation of a path as described by a route producer.
void igmp_clear_group(igmp_config_t *config, igmp_group_t *group)
igmp clear group
ip_interface_address_t * if_address_pool
Pool of addresses that are assigned to interfaces.
static int ip4_header_bytes(ip4_header_t *i)
static f64 vlib_time_now(vlib_main_t *vm)
VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION(igmp_hw_interface_link_up_down)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
static igmp_group_t * igmp_group_lookup(igmp_config_t *config, igmp_key_t *key)
igmp group lookup
igmp_membership_group_v3_type_t
static clib_error_t * igmp_hw_interface_link_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
igmp hardware interface link up down
#define hash_set_mem(h, key, value)
ip_lookup_main_t lookup_main
fib_node_index_t mfib_table_entry_update(u32 fib_index, const mfib_prefix_t *prefix, mfib_source_t source, fib_rpf_id_t rpf_id, mfib_entry_flags_t entry_flags)
Add a new (with no replication) or lock an existing entry.
dpo_proto_t frp_proto
The protocol of the address below.
#define VNET_HW_INTERFACE_FLAG_LINK_UP
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
#define IGMP_GENERAL_QUERY_ADDRESS
General Query address - 224.0.0.1.
static clib_error_t * igmp_init(vlib_main_t *vm)
igmp initialization
void ip4_register_protocol(u32 protocol, u32 node_index)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
void igmp_sort_timers(igmp_timer_t *timers)
igmp sort timers
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
void igmp_clear_config(igmp_config_t *config)
igmp clear config
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
static void igmp_create_ip4(vlib_buffer_t *b, igmp_config_t *config, igmp_group_t *group, u8 is_report)
igmp create ip4
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
igmp_type_info_t * type_infos
#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 timer_callback_t * timers
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
void igmp_send_report(vlib_main_t *vm, vlib_node_runtime_t *rt, igmp_main_t *im, igmp_timer_t *timer)
igmp send report (igmp_timer_function_t)
fib_node_index_t mfib_table_entry_path_update(u32 fib_index, const mfib_prefix_t *prefix, mfib_source_t source, const fib_route_path_t *rpath, mfib_itf_flags_t itf_flags)
Add n paths to an entry (aka route) in the FIB.
void igmp_src_exp(vlib_main_t *vm, vlib_node_runtime_t *rt, igmp_main_t *im, igmp_timer_t *timer)
igmp source expiration (igmp_timer_function_t)
#define vlib_call_init_function(vm, x)
void igmp_send_state_changed(vlib_main_t *vm, vlib_node_runtime_t *rt, igmp_main_t *im, igmp_timer_t *timer)
igmp send state changed (igmp_timer_function_t)
void igmp_create_group_timer(f64 time, u32 sw_if_index, igmp_key_t *gkey, igmp_timer_function_t *func)
igmp create group timer
uword * igmp_group_by_key
void igmp_create_src_timer(f64 time, u32 sw_if_index, igmp_key_t *gkey, igmp_key_t *skey, igmp_timer_function_t *func)
igmp create group timer
#define hash_create_mem(elts, key_bytes, value_bytes)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static void igmp_create_query_v3(vlib_buffer_t *b, igmp_config_t *config, igmp_group_t *group)
igmp create query (v3)
#define hash_unset_mem(h, key)
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)
#define IGMP_DEFAULT_ROBUSTNESS_VARIABLE
int igmp_timer_compare(const void *_a, const void *_b)
igmp timer compare
uword * igmp_config_by_sw_if_index
#define IGMP_MEMBERSHIP_REPORT_ADDRESS
Membership Report address - 224.0.0.22.
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.
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#define IGMP_CONFIG_FLAG_QUERY_RESP_RECVED
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
#define pool_free(p)
Free a pool.
void( igmp_timer_function_t)(vlib_main_t *vm, vlib_node_runtime_t *rt, igmp_main_t *im, igmp_timer_t *timer)
igmp timer function
#define VLIB_REGISTER_NODE(x,...)
static_always_inline uword vlib_get_thread_index(void)
static igmp_src_t * igmp_src_lookup(igmp_group_t *group, igmp_key_t *key)
igmp group lookup
static ip_csum_t ip_incremental_checksum(ip_csum_t sum, void *_data, uword n_bytes)
vlib_node_registration_t igmp_input_node
(constructor) VLIB_REGISTER_NODE (igmp_input_node)
#define clib_memcpy(a, b, c)
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
ip4_address_t dst_address
Aggregrate type for a prefix.
u32 * if_address_pool_index_by_sw_if_index
Head of doubly linked list of interface addresses for each software interface.
#define hash_create(elts, value_bytes)
void igmp_event(igmp_main_t *im, igmp_config_t *config, igmp_group_t *group, igmp_src_t *src)
igmp event
igmp_membership_group_v3_type_t type
static void clib_mem_free(void *p)
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
void igmp_query_resp_exp(vlib_main_t *vm, vlib_node_runtime_t *rt, igmp_main_t *im, igmp_timer_t *timer)
igmp query response expiration (igmp_timer_function_t)
clib_error_t * ip4_lookup_init(vlib_main_t *vm)
static void * clib_mem_alloc(uword size)
uword * report_type_info_by_report_type
static vlib_main_t * vlib_get_main(void)
int igmp_listen(vlib_main_t *vm, u8 enable, u32 sw_if_index, ip46_address_t saddr, ip46_address_t gaddr, u8 cli_api_configured)
igmp listen
u32 total_length_not_including_first_buffer
Only valid for first buffer in chain.
fib_protocol_t fp_proto
protocol type
static igmp_config_t * igmp_config_lookup(igmp_main_t *im, u32 sw_if_index)
igmp config lookup
void qsort(void *base, uword n, uword size, int(*compar)(const void *, const void *))
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static uword igmp_timer_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
igmp timer process
void igmp_send_query(vlib_main_t *vm, vlib_node_runtime_t *rt, igmp_main_t *im, igmp_timer_t *timer)
igmp send query (igmp_timer_function_t)
static void igmp_create_report_v3(vlib_buffer_t *b, igmp_config_t *config, igmp_group_t *group)
igmp create report all (v3)
ip4_main_t ip4_main
Global ip4 main structure.
static vlib_thread_main_t * vlib_get_thread_main()
adj_index_t adj_mcast_add_or_lock(fib_protocol_t proto, vnet_link_t link_type, u32 sw_if_index)
Mcast Adjacency.
igmp_timer_function_t * func
uword * igmp_api_client_by_client_index
static void * ip_interface_address_get_address(ip_lookup_main_t *lm, ip_interface_address_t *a)
#define group_ptr(p, l)
helper macro to get igmp mebership group from pointer plus offset
void igmp_create_int_timer(f64 time, u32 sw_if_index, igmp_timer_function_t *func)
igmp create int timer
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
static u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static u16 ip4_header_checksum(ip4_header_t *i)
static u16 ip_csum_fold(ip_csum_t c)
const ip46_address_t zero_addr
uword * type_info_by_type
igmp_report_type_info_t * report_type_infos
static void igmp_send_msg(vlib_main_t *vm, vlib_node_runtime_t *node, igmp_main_t *im, igmp_config_t *config, igmp_group_t *group, u8 is_report)
igmp send message
create_msg_t * next_create_msg
static uword pool_elts(void *v)
Number of active elements in a pool.