20 #include <vpp/app/version.h> 47 clib_mem_free (sg->key);
64 return dt < 0 ? -1 : (dt > 0 ? +1 : 0);
175 igmp->
header.
type = IGMP_TYPE_membership_report_v3;
176 igmp->
n_groups = clib_host_to_net_u16 (1);
207 for (i = 0; i < n; i++)
216 clib_net_to_host_u16 (
group_ptr (igmp, l)->n_src_addresses) *
233 u16 n_groups = 0, n_srcs = 0;
241 igmp->
header.
type = IGMP_TYPE_membership_report_v3;
252 if (ip4_lookup (&sg0->gaddr.ip4, igmp, n_groups, sg0->group_type))
254 memset (igmp + len, 0, grp_s);
255 clib_memcpy (&group_ptr (igmp, len)->dst_address, &sg0->gaddr.ip4, sizeof (ip4_address_t));
256 group_ptr (igmp, len)->type = sg0->group_type;
259 pool_foreach (sg1, config->sg, (
261 if ((!ip4_address_compare (&group_ptr (igmp, len - grp_s)->dst_address,
262 &sg1->gaddr.ip4)) && (group_ptr (igmp, len - grp_s)->type == (sg1->group_type)))
264 clib_memcpy (group_ptr (igmp, len + sizeof (ip4_address_t) * n_srcs),
265 &sg1->saddr.ip4, sizeof (ip4_address_t));
269 group_ptr (igmp, len - grp_s)->n_src_addresses = clib_host_to_net_u16 (n_srcs);
275 igmp->n_groups = clib_host_to_net_u16 (n_groups);
279 igmp->header.checksum = csum;
281 b->current_data += len;
282 b->current_length += len;
295 igmp->
header.
type = IGMP_TYPE_membership_query;
361 _vec_len (im->
buffers[thread_index]) = n_free_bufs;
365 u32 next0 = next_index;
368 if (n_left_to_next > 0)
376 bi = im->
buffers[thread_index][last_buf];
378 _vec_len (im->
buffers[thread_index]) = last_buf;
385 _vec_len (im->
buffers[thread_index]) = n_free_bufs;
396 b->
flags = VLIB_BUFFER_TOTAL_LENGTH_VALID;
399 b->
flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
407 n_left_to_next, bi, next0);
494 if (sg->
group_type == IGMP_MEMBERSHIP_GROUP_change_to_filter_include)
496 sg->
group_type = IGMP_MEMBERSHIP_GROUP_mode_is_filter_include;
498 else if (sg->
group_type == IGMP_MEMBERSHIP_GROUP_block_old_sources)
548 uword *event_data = 0, event_type;
572 timer->
func (vm, rt, im, timer);
585 .name =
"igmp-timer-process",
596 ip46_address_t saddr, ip46_address_t gaddr,
597 u8 cli_api_configured)
624 if (!cli_api_configured)
649 sg->
group_type = IGMP_MEMBERSHIP_GROUP_change_to_filter_include;
650 if (cli_api_configured)
657 sg->
group_type = IGMP_MEMBERSHIP_GROUP_mode_is_filter_include;
683 sg->
group_type = IGMP_MEMBERSHIP_GROUP_block_old_sources;
687 if (!cli_api_configured)
721 hw_if_index)->sw_if_index);
752 #define igmp_type(n,s) \ 754 vec_add2 (im->type_infos, ti, 1); \ 756 ti->name = (u8 *) #s; \ 759 #define igmp_report_type(n,s) \ 761 vec_add2 (im->report_type_infos, rti, 1); \ 763 rti->name = (u8 *) #s; \ 769 #undef igmp_report_type 784 ip46_address_t addr0;
785 addr0.ip4.as_u8[0] = 224;
786 addr0.ip4.as_u8[1] = 0;
787 addr0.ip4.as_u8[2] = 0;
788 addr0.ip4.as_u8[3] = 1;
790 ip46_address_t addr1;
791 addr1.ip4.as_u8[0] = 224;
792 addr1.ip4.as_u8[1] = 0;
793 addr1.ip4.as_u8[2] = 0;
794 addr1.ip4.as_u8[3] = 22;
799 .frp_sw_if_index = 0xffffffff,
807 .fp_grp_addr = addr0,
812 .fp_grp_addr = addr1,
832 .version = VPP_BUILD_VER,
833 .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
#define IGMP_CONFIG_FLAG_CAN_SEND_REPORT
static igmp_timer_t * igmp_get_next_timer(igmp_main_t *im)
#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.
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 igmp_sg_t * igmp_sg_lookup(igmp_config_t *config, igmp_sg_key_t *key)
static f64 vlib_time_now(vlib_main_t *vm)
igmp_config_t * configs
pool of igmp configurations
static void igmp_send_msg(vlib_main_t *vm, vlib_node_runtime_t *node, igmp_main_t *im, igmp_config_t *config, u8 is_report)
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)
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)
#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)
static clib_error_t * igmp_init(vlib_main_t *vm)
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)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
void igmp_clear_config(igmp_config_t *config)
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
ip_csum_t ip_incremental_checksum(ip_csum_t sum, void *_data, uword n_bytes)
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 void igmp_create_report_v32(vlib_buffer_t *b, igmp_config_t *config)
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)
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.
#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_membership_group_v3_type_t group_type
#define hash_create_mem(elts, key_bytes, value_bytes)
u8 ip4_lookup(ip4_address_t *a, igmp_membership_report_v3_t *igmp, u16 n, igmp_membership_group_v3_type_t type)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#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)
uword * igmp_config_by_sw_if_index
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)
#define VLIB_REGISTER_NODE(x,...)
static_always_inline uword vlib_get_thread_index(void)
int ip4_address_compare(ip4_address_t *a1, ip4_address_t *a2)
void igmp_event(igmp_main_t *im, igmp_config_t *config, igmp_sg_t *sg)
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)
igmp_membership_group_v3_type_t type
static void clib_mem_free(void *p)
u32 ** buffers
buffer cache
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)
clib_error_t * ip4_lookup_init(vlib_main_t *vm)
static void * clib_mem_alloc(uword size)
void igmp_sg_exp(vlib_main_t *vm, vlib_node_runtime_t *rt, igmp_main_t *im, igmp_timer_t *timer)
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)
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)
void qsort(void *base, uword n, uword size, int(*compar)(const void *, const void *))
void igmp_create_sg_timer(f64 time, u32 sw_if_index, igmp_sg_key_t *key, igmp_timer_function_t *func)
#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)
void igmp_send_query(vlib_main_t *vm, vlib_node_runtime_t *rt, igmp_main_t *im, igmp_timer_t *timer)
igmp_timer_t * timers
pool of igmp timers
static void igmp_create_report_v31(vlib_buffer_t *b, igmp_config_t *config)
ip4_address_t src_addresses[0]
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 igmp_create_ip4(vlib_buffer_t *b, igmp_config_t *config, u8 is_report)
static void * ip_interface_address_get_address(ip_lookup_main_t *lm, ip_interface_address_t *a)
void igmp_create_int_timer(f64 time, u32 sw_if_index, igmp_timer_function_t *func)
#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_create_general_query_v3(vlib_buffer_t *b, igmp_config_t *config)
create_msg_t * next_create_msg
static uword pool_elts(void *v)
Number of active elements in a pool.