MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ipfw_table_handler

Function ipfw_table_handler

tools/ipfw/tables.c:159–311  ·  view source on GitHub ↗

* This one handles all table-related commands * ipfw table NAME create ... * ipfw table NAME modify ... * ipfw table {NAME | all} destroy * ipfw table NAME swap NAME * ipfw table NAME lock * ipfw table NAME unlock * ipfw table NAME add addr[/masklen] [value] * ipfw table NAME add [addr[/masklen] value] [addr[/masklen] value] .. * ipfw table NAME delete addr[/masklen] [addr[/mask

Source from the content-addressed store, hash-verified

157 * ipfw table {NAME | all} detail
158 */
159void
160ipfw_table_handler(int ac, char *av[])
161{
162 int do_add, is_all;
163 int atomic, error, tcmd;
164 ipfw_xtable_info i;
165 ipfw_obj_header oh;
166 char *tablename;
167 uint8_t set;
168 void *arg;
169
170 memset(&oh, 0, sizeof(oh));
171 is_all = 0;
172 if (g_co.use_set != 0)
173 set = g_co.use_set - 1;
174 else
175 set = 0;
176
177 ac--; av++;
178 NEED1("table needs name");
179 tablename = *av;
180
181 if (table_check_name(tablename) == 0) {
182 table_fill_ntlv(&oh.ntlv, *av, set, 1);
183 oh.idx = 1;
184 } else {
185 if (strcmp(tablename, "all") == 0)
186 is_all = 1;
187 else
188 errx(EX_USAGE, "table name %s is invalid", tablename);
189 }
190 ac--; av++;
191 NEED1("table needs command");
192
193 tcmd = get_token(tablecmds, *av, "table command");
194 /* Check if atomic operation was requested */
195 atomic = 0;
196 if (tcmd == TOK_ATOMIC) {
197 ac--; av++;
198 NEED1("atomic needs command");
199 tcmd = get_token(tablecmds, *av, "table command");
200 switch (tcmd) {
201 case TOK_ADD:
202 break;
203 default:
204 errx(EX_USAGE, "atomic is not compatible with %s", *av);
205 }
206 atomic = 1;
207 }
208
209 switch (tcmd) {
210 case TOK_LIST:
211 case TOK_INFO:
212 case TOK_DETAIL:
213 case TOK_FLUSH:
214 case TOK_DESTROY:
215 break;
216 default:

Callers 1

main.cFile · 0.85

Calls 15

memsetFunction · 0.85
table_check_nameFunction · 0.85
table_fill_ntlvFunction · 0.85
strcmpFunction · 0.85
table_modify_recordFunction · 0.85
table_modifyFunction · 0.85
table_destroyFunction · 0.85
tables_foreachFunction · 0.85
table_flushFunction · 0.85
table_swapFunction · 0.85
table_lockFunction · 0.85
table_get_infoFunction · 0.85

Tested by

no test coverage detected