FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
igmp_ssm_range.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * Copyright (c) 2017 Cisco and/or its affiliates.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *------------------------------------------------------------------
16  */
17 
18 #include <igmp/igmp_ssm_range.h>
19 
20 typedef struct igmp_group_prefix_t
21 {
25 
27 
28 u8 *
29 format_igmp_group_prefix_type (u8 * s, va_list * args)
30 {
31  igmp_group_prefix_type_t type = va_arg (*args, int);
32 
33  switch (type)
34  {
35 #define _(n,f) case IGMP_GROUP_PREFIX_TYPE_##f: return (format (s, "%s", #f));
37 #undef _
38  }
39  return format (s, "unknown:%d", type);
40 }
41 
42 static int
44  const fib_prefix_t * p)
45 {
46  return (fib_prefix_cmp (&gp1->igp_prefix, p));
47 }
48 
49 void
52 {
53  u32 pos;
54 
55  pos =
57 
58  if ((~0 == pos) && (IGMP_GROUP_PREFIX_TYPE_SSM == type))
59  {
60  igmp_group_prefix_t gp = {
61  .igp_prefix = *pfx,
62  .igp_type = type,
63  };
64 
66  }
67  if ((~0 != pos) && (IGMP_GROUP_PREFIX_TYPE_ASM == type))
68  {
70  }
71 }
72 
73 static void
75 {
76  igmp_group_prefix_t *ssm_default;
77 
78  vec_add2 (igmp_group_prefixs, ssm_default, 1);
79 
80  ssm_default->igp_prefix.fp_addr.ip4.as_u32 = IGMP_SSM_DEFAULT;
81  ssm_default->igp_prefix.fp_proto = FIB_PROTOCOL_IP4;
82  ssm_default->igp_prefix.fp_len = 8;
83  ssm_default->igp_type = IGMP_GROUP_PREFIX_TYPE_SSM;
84 }
85 
87 igmp_group_prefix_get_type (const ip46_address_t * gaddr)
88 {
90 
92  {
94  &gaddr->ip4,
95  &igp->igp_prefix.fp_addr.ip4,
96  igp->igp_prefix.fp_len))
97  return (IGMP_GROUP_PREFIX_TYPE_SSM);
98  }
99 
100  return (IGMP_GROUP_PREFIX_TYPE_ASM);
101 }
102 
103 void
105 {
106  igmp_group_prefix_t *igp;
107 
109  {
110  if (WALK_STOP == fn (&igp->igp_prefix, igp->igp_type, ctx))
111  break;
112  }
113 }
114 
115 static clib_error_t *
117  unformat_input_t * input, vlib_cli_command_t * cmd)
118 {
119  igmp_group_prefix_t *igp;
120 
122  {
123  vlib_cli_output (vm, "%U => %U",
126  }
127  return (NULL);
128 }
129 
130 /* *INDENT-OFF* */
132  .path = "show igmp ssm-ranges",
133  .short_help = "show igmp ssm-ranges",
134  .function = igmp_ssm_range_show,
135 };
136 /* *INDENT-ON* */
137 
138 static clib_error_t *
140 {
142 
143  IGMP_DBG ("ssm-range-initialized");
144 
145  return (0);
146 }
147 
148 /* *INDENT-OFF* */
150 {
151  .runs_after = VLIB_INITS("igmp_init"),
152 };
153 /* *INDENT-ON* */
154 
155 /*
156  * fd.io coding-style-patch-verification: ON
157  *
158  * Local Variables:
159  * eval: (c-set-style "gnu")
160  * End:
161  */
igmp_ssm_range_walk_t
walk_rc_t(* igmp_ssm_range_walk_t)(const fib_prefix_t *pfx, igmp_group_prefix_type_t type, void *ctx)
Definition: igmp_ssm_range.h:44
fib_prefix_cmp
int fib_prefix_cmp(const fib_prefix_t *p1, const fib_prefix_t *p2)
Compare two prefixes for equality.
Definition: fib_types.c:177
IGMP_DBG
#define IGMP_DBG(...)
Definition: igmp.h:38
igmp_ssm_range_show
static clib_error_t * igmp_ssm_range_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: igmp_ssm_range.c:116
ip4_main
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1105
vlib_cli_command_t::path
char * path
Definition: cli.h:96
igmp_group_prefix_t::igp_type
igmp_group_prefix_type_t igp_type
Definition: igmp_ssm_range.c:23
fib_prefix_t_::fp_len
u16 fp_len
The mask length.
Definition: fib_types.h:206
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
unformat_input_t
struct _unformat_input_t unformat_input_t
igmp_group_prefix_type_t
enum igmp_group_prefix_type_t_ igmp_group_prefix_type_t
vec_search_with_function
#define vec_search_with_function(v, E, fn)
Search a vector for the index of the entry that matches.
Definition: vec.h:1075
vec_add2
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:644
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
igmp_group_prefixs
static igmp_group_prefix_t * igmp_group_prefixs
Definition: igmp_ssm_range.c:26
igmp_ssm_range_populate
static void igmp_ssm_range_populate(void)
Definition: igmp_ssm_range.c:74
IGMP_SSM_DEFAULT
#define IGMP_SSM_DEFAULT
Definition: igmp.h:53
format_igmp_group_prefix_type
u8 * format_igmp_group_prefix_type(u8 *s, va_list *args)
Definition: igmp_ssm_range.c:29
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
FIB_PROTOCOL_IP4
@ FIB_PROTOCOL_IP4
Definition: fib_types.h:36
vlib_cli_output
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:716
fib_prefix_t_::fp_addr
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:225
ip4_destination_matches_route
static uword ip4_destination_matches_route(const ip4_main_t *im, const ip4_address_t *key, const ip4_address_t *dest, uword dest_length)
Definition: ip4.h:188
igmp_ssm_range.h
igmp_group_prefix_cmp
static int igmp_group_prefix_cmp(const igmp_group_prefix_t *gp1, const fib_prefix_t *p)
Definition: igmp_ssm_range.c:43
igmp_ssm_range_init
static clib_error_t * igmp_ssm_range_init(vlib_main_t *vm)
Definition: igmp_ssm_range.c:139
format
description fragment has unexpected format
Definition: map.api:433
igmp_group_prefix_set
void igmp_group_prefix_set(const fib_prefix_t *pfx, igmp_group_prefix_type_t type)
Definition: igmp_ssm_range.c:50
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
igmp_group_prefix_t
struct igmp_group_prefix_t igmp_group_prefix_t
gaddr
vl_api_ip4_address_t gaddr
Definition: igmp.api:70
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
format_fib_prefix
u8 * format_fib_prefix(u8 *s, va_list *args)
Definition: fib_types.c:283
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
igmp_group_prefix_t
Definition: igmp_ssm_range.c:20
fib_prefix_t_::fp_proto
fib_protocol_t fp_proto
protocol type
Definition: fib_types.h:211
igmp_group_prefix_t::igp_prefix
fib_prefix_t igp_prefix
Definition: igmp_ssm_range.c:22
igmp_ssm_range_walk
void igmp_ssm_range_walk(igmp_ssm_range_walk_t fn, void *ctx)
Definition: igmp_ssm_range.c:104
igmp_group_prefix_get_type
igmp_group_prefix_type_t igmp_group_prefix_get_type(const ip46_address_t *gaddr)
Definition: igmp_ssm_range.c:87
vlib_main_t
Definition: main.h:102
VLIB_INITS
#define VLIB_INITS(...)
Definition: init.h:352
foreach_igmp_group_prefix_type
@ foreach_igmp_group_prefix_type
Definition: igmp_ssm_range.h:33
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
igmp_show_timers_command
static vlib_cli_command_t igmp_show_timers_command
(constructor) VLIB_CLI_COMMAND (igmp_show_timers_command)
Definition: igmp_ssm_range.c:131
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
vlib_cli_command_t
Definition: cli.h:92
WALK_STOP
@ WALK_STOP
Definition: interface_funcs.h:173
fib_prefix_t_
Aggregate type for a prefix.
Definition: fib_types.h:202
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
vec_del1
#define vec_del1(v, i)
Delete the element at index I.
Definition: vec.h:896