]> git.ipfire.org Git - thirdparty/lldpd.git/blame - src/client/conf-system.c
Extra capabilities bitflags and configurability.
[thirdparty/lldpd.git] / src / client / conf-system.c
CommitLineData
994b3371
VB
1/* -*- mode: c; c-file-style: "openbsd" -*- */
2/*
3 * Copyright (c) 2013 Vincent Bernat <bernat@luffy.cx>
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include <unistd.h>
19#include <string.h>
a9d00cbd 20#include <sys/utsname.h>
994b3371
VB
21
22#include "client.h"
23#include "../log.h"
24
25static int
8b549648 26cmd_iface_pattern(struct lldpctl_conn_t *conn, struct writer *w, struct cmd_env *env,
f540397c 27 const void *arg)
994b3371
VB
28{
29 log_debug("lldpctl", "set iface pattern");
30
31 lldpctl_atom_t *config = lldpctl_get_configuration(conn);
32 if (config == NULL) {
33 log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
34 lldpctl_last_strerror(conn));
35 return 0;
36 }
6dd83015
VB
37
38 const char *value = cmdenv_get(env, "iface-pattern");
8b549648
VB
39 if (lldpctl_atom_set_str(config, lldpctl_k_config_iface_pattern, value) ==
40 NULL) {
994b3371
VB
41 log_warnx("lldpctl", "unable to set iface-pattern. %s",
42 lldpctl_last_strerror(conn));
43 lldpctl_atom_dec_ref(config);
44 return 0;
45 }
6dd83015 46 log_info("lldpctl", "iface-pattern set to new value %s",
8b549648 47 value ? value : "(none)");
994b3371
VB
48 lldpctl_atom_dec_ref(config);
49 return 1;
50}
51
0a78e14f
VB
52static int
53cmd_perm_iface_pattern(struct lldpctl_conn_t *conn, struct writer *w,
f540397c 54 struct cmd_env *env, const void *arg)
0a78e14f
VB
55{
56 log_debug("lldpctl", "set permanent iface pattern");
57
58 lldpctl_atom_t *config = lldpctl_get_configuration(conn);
59 if (config == NULL) {
60 log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
61 lldpctl_last_strerror(conn));
62 return 0;
63 }
64
65 const char *value = cmdenv_get(env, "iface-pattern");
8b549648
VB
66 if (lldpctl_atom_set_str(config, lldpctl_k_config_perm_iface_pattern, value) ==
67 NULL) {
0a78e14f
VB
68 log_warnx("lldpctl", "unable to set permanent iface pattern. %s",
69 lldpctl_last_strerror(conn));
70 lldpctl_atom_dec_ref(config);
71 return 0;
72 }
73 log_info("lldpctl", "permanent iface pattern set to new value %s",
8b549648 74 value ? value : "(none)");
0a78e14f
VB
75 lldpctl_atom_dec_ref(config);
76 return 1;
77}
78
f84199dd 79static int
8b549648 80cmd_iface_promisc(struct lldpctl_conn_t *conn, struct writer *w, struct cmd_env *env,
f540397c 81 const void *arg)
f84199dd
VB
82{
83 lldpctl_atom_t *config = lldpctl_get_configuration(conn);
84 if (config == NULL) {
85 log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
86 lldpctl_last_strerror(conn));
87 return 0;
88 }
8b549648
VB
89 if (lldpctl_atom_set_int(config, lldpctl_k_config_iface_promisc, arg ? 1 : 0) ==
90 NULL) {
f84199dd 91 log_warnx("lldpctl", "unable to %s promiscuous mode: %s",
8b549648 92 arg ? "enable" : "disable", lldpctl_last_strerror(conn));
f84199dd
VB
93 lldpctl_atom_dec_ref(config);
94 return 0;
95 }
96 log_info("lldpctl", "interface promiscuous mode %s",
8b549648 97 arg ? "enabled" : "disabled");
f84199dd
VB
98 lldpctl_atom_dec_ref(config);
99 return 1;
100}
101
decaec0d
VB
102static int
103cmd_system_description(struct lldpctl_conn_t *conn, struct writer *w,
f540397c 104 struct cmd_env *env, const void *arg)
decaec0d 105{
3f70e118 106 int platform = 0;
6dd83015
VB
107 const char *what = arg;
108 const char *value;
109 if (!strcmp(what, "system")) {
110 value = cmdenv_get(env, "description");
111 } else {
3f70e118 112 value = cmdenv_get(env, "platform");
6dd83015 113 platform = 1;
3f70e118 114 }
6dd83015 115 log_debug("lldpctl", "set %s description", what);
decaec0d
VB
116 lldpctl_atom_t *config = lldpctl_get_configuration(conn);
117 if (config == NULL) {
118 log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
119 lldpctl_last_strerror(conn));
120 return 0;
121 }
122 if (lldpctl_atom_set_str(config,
8b549648 123 platform ? lldpctl_k_config_platform : lldpctl_k_config_description,
3f70e118
VB
124 value) == NULL) {
125 log_warnx("lldpctl", "unable to set description. %s",
decaec0d
VB
126 lldpctl_last_strerror(conn));
127 lldpctl_atom_dec_ref(config);
128 return 0;
129 }
3f70e118 130 log_info("lldpctl", "description set to new value %s",
8b549648 131 value ? value : "(none)");
decaec0d
VB
132 lldpctl_atom_dec_ref(config);
133 return 1;
134}
135
8481f490 136static int
8b549648 137cmd_system_chassisid(struct lldpctl_conn_t *conn, struct writer *w, struct cmd_env *env,
f540397c 138 const void *arg)
8481f490
VB
139{
140 const char *value;
141 value = cmdenv_get(env, "description");
142 log_debug("lldpctl", "set chassis ID");
143 lldpctl_atom_t *config = lldpctl_get_configuration(conn);
144 if (config == NULL) {
145 log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
146 lldpctl_last_strerror(conn));
147 return 0;
148 }
8b549648 149 if (lldpctl_atom_set_str(config, lldpctl_k_config_cid_string, value) == NULL) {
8481f490
VB
150 log_warnx("lldpctl", "unable to set chassis ID. %s",
151 lldpctl_last_strerror(conn));
152 lldpctl_atom_dec_ref(config);
153 return 0;
154 }
8b549648 155 log_info("lldpctl", "chassis ID set to new value %s", value ? value : "(none)");
8481f490
VB
156 lldpctl_atom_dec_ref(config);
157 return 1;
158}
159
622d14bb 160static int
8b549648 161cmd_management(struct lldpctl_conn_t *conn, struct writer *w, struct cmd_env *env,
f540397c 162 const void *arg)
622d14bb
VB
163{
164 log_debug("lldpctl", "set management pattern");
165
166 lldpctl_atom_t *config = lldpctl_get_configuration(conn);
167 if (config == NULL) {
168 log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
169 lldpctl_last_strerror(conn));
170 return 0;
171 }
622d14bb 172
6dd83015 173 const char *value = cmdenv_get(env, "management-pattern");
8b549648
VB
174 if (lldpctl_atom_set_str(config, lldpctl_k_config_mgmt_pattern, value) ==
175 NULL) {
622d14bb
VB
176 log_warnx("lldpctl", "unable to set management pattern. %s",
177 lldpctl_last_strerror(conn));
178 lldpctl_atom_dec_ref(config);
179 return 0;
180 }
2322c315 181 log_info("lldpctl", "management pattern set to new value %s",
8b549648 182 value ? value : "(none)");
622d14bb
VB
183 lldpctl_atom_dec_ref(config);
184 return 1;
185}
186
ce347d29 187static int
8b549648 188cmd_hostname(struct lldpctl_conn_t *conn, struct writer *w, struct cmd_env *env,
f540397c 189 const void *arg)
ce347d29 190{
a9d00cbd 191 struct utsname un;
ce347d29
JJ
192 log_debug("lldpctl", "set system name");
193
194 lldpctl_atom_t *config = lldpctl_get_configuration(conn);
195 if (config == NULL) {
196 log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
197 lldpctl_last_strerror(conn));
198 return 0;
199 }
ce347d29 200
6dd83015 201 const char *value = cmdenv_get(env, "hostname");
a9d00cbd
VB
202 if (value && strlen(value) == 1 && value[0] == '.') {
203 if (uname(&un) < 0) {
204 log_warn("lldpctl", "cannot get node name");
e1926a99 205 lldpctl_atom_dec_ref(config);
a9d00cbd
VB
206 return 0;
207 }
b8955080 208 char *c = strchr(un.nodename, '.');
43a885b2 209 if (c) *c = 0;
a9d00cbd
VB
210 value = un.nodename;
211 }
8b549648 212 if (lldpctl_atom_set_str(config, lldpctl_k_config_hostname, value) == NULL) {
ce347d29
JJ
213 log_warnx("lldpctl", "unable to set system name. %s",
214 lldpctl_last_strerror(conn));
215 lldpctl_atom_dec_ref(config);
216 return 0;
217 }
6dd83015 218 log_info("lldpctl", "system name set to new value %s",
8b549648 219 value ? value : "(none)");
ce347d29
JJ
220 lldpctl_atom_dec_ref(config);
221 return 1;
222}
223
4c8e6e37 224static int
8b549648 225cmd_capability(struct lldpctl_conn_t *conn, struct writer *w, struct cmd_env *env,
f540397c 226 const void *arg)
4c8e6e37
ISN
227{
228 log_debug("lldpctl", "set capabilities");
229
230 int ret = 0;
231 lldpctl_atom_t *config = lldpctl_get_configuration(conn);
232 lldpctl_atom_t *chassis = NULL;
233 if (config == NULL) {
234 log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
235 lldpctl_last_strerror(conn));
236 goto cmd_capability_end;
237 }
238
239 if (!strcmp(arg, "configure")) {
240
241 const char *s = cmdenv_get(env, "capabilities");
242 if (s) {
243 chassis = lldpctl_get_local_chassis(conn);
244 if (chassis == NULL) {
8b549648
VB
245 log_warnx("lldpctl",
246 "unable to get local chassis from lldpd. %s",
4c8e6e37
ISN
247 lldpctl_last_strerror(conn));
248 goto cmd_capability_end;
249 }
250 u_int16_t value = 0;
251 const char delim[] = ",";
252 char *s_copy = strdup(s);
253 char *token = strtok(s_copy, delim);
254 while (token != NULL) {
255 if (!strcmp(token, "other")) {
256 value |= LLDP_CAP_OTHER;
257 } else if (!strcmp(token, "repeater")) {
258 value |= LLDP_CAP_REPEATER;
259 } else if (!strcmp(token, "bridge")) {
260 value |= LLDP_CAP_BRIDGE;
261 } else if (!strcmp(token, "wlan")) {
262 value |= LLDP_CAP_WLAN;
263 } else if (!strcmp(token, "router")) {
264 value |= LLDP_CAP_ROUTER;
265 } else if (!strcmp(token, "telephone")) {
266 value |= LLDP_CAP_TELEPHONE;
267 } else if (!strcmp(token, "docsis")) {
268 value |= LLDP_CAP_DOCSIS;
269 } else if (!strcmp(token, "station")) {
270 value |= LLDP_CAP_STATION;
9f181945
PD
271 } else if (!strcmp(token, "cvlan")) {
272 value |= LLDP_CAP_CVLAN;
273 } else if (!strcmp(token, "svlan")) {
274 value |= LLDP_CAP_SVLAN;
275 } else if (!strcmp(token, "tpmr")) {
276 value |= LLDP_CAP_TPMRCOMP;
4c8e6e37 277 } else {
8b549648
VB
278 log_warnx("lldpctl", "capability %s not found",
279 token);
4c8e6e37
ISN
280 }
281 token = strtok(NULL, delim);
282 }
283 free(s_copy);
284
8b549648
VB
285 if (lldpctl_atom_set_int(chassis, lldpctl_k_chassis_cap_enabled,
286 value) == NULL) {
287 log_warnx("lldpctl",
288 "unable to set system capabilities. %s",
4c8e6e37
ISN
289 lldpctl_last_strerror(conn));
290 goto cmd_capability_end;
291 }
8b549648
VB
292 if (lldpctl_atom_set_int(config,
293 lldpctl_k_config_chassis_cap_override, 1) == NULL) {
294 log_warnx("lldpctl",
295 "unable to set system capabilities override. %s",
4c8e6e37
ISN
296 lldpctl_last_strerror(conn));
297 goto cmd_capability_end;
298 }
299 log_debug("lldpctl", "system capabilities set to new value %d",
300 value);
301 }
302 } else {
8b549648
VB
303 if (lldpctl_atom_set_int(config, lldpctl_k_config_chassis_cap_override,
304 0) == NULL) {
305 log_warnx("lldpctl",
306 "unable to set system capabilities to not override. %s",
4c8e6e37
ISN
307 lldpctl_last_strerror(conn));
308 goto cmd_capability_end;
309 }
310 }
311
312 ret = 1;
8b549648 313cmd_capability_end:
4c8e6e37
ISN
314 lldpctl_atom_dec_ref(chassis);
315 lldpctl_atom_dec_ref(config);
316 return ret;
317}
318
bb37268d
VB
319static int
320cmd_update_descriptions(struct lldpctl_conn_t *conn, struct writer *w,
f540397c 321 struct cmd_env *env, const void *arg)
bb37268d
VB
322{
323 lldpctl_atom_t *config = lldpctl_get_configuration(conn);
324 if (config == NULL) {
325 log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
326 lldpctl_last_strerror(conn));
327 return 0;
328 }
8b549648
VB
329 if (lldpctl_atom_set_int(config, lldpctl_k_config_ifdescr_update,
330 arg ? 1 : 0) == NULL) {
bb37268d 331 log_warnx("lldpctl", "unable to %s interface description update: %s",
8b549648 332 arg ? "enable" : "disable", lldpctl_last_strerror(conn));
bb37268d
VB
333 lldpctl_atom_dec_ref(config);
334 return 0;
335 }
336 log_info("lldpctl", "interface description update %s",
8b549648 337 arg ? "enabled" : "disabled");
bb37268d
VB
338 lldpctl_atom_dec_ref(config);
339 return 1;
340}
341
dfbd7185
RP
342static int
343cmd_bondslave_srcmac_type(struct lldpctl_conn_t *conn, struct writer *w,
f540397c 344 struct cmd_env *env, const void *arg)
dfbd7185 345{
f540397c 346 const char *value_str = 0;
bae18e13 347 int value = -1;
dfbd7185
RP
348
349 log_debug("lldpctl", "bond slave src mac");
350
351 lldpctl_atom_t *config = lldpctl_get_configuration(conn);
352 if (config == NULL) {
8b549648
VB
353 log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
354 lldpctl_last_strerror(conn));
dfbd7185
RP
355 return 0;
356 }
357
358 value_str = arg;
359 for (lldpctl_map_t *b_map =
8b549648
VB
360 lldpctl_key_get_map(lldpctl_k_config_bond_slave_src_mac_type);
361 b_map->string; b_map++) {
dfbd7185
RP
362 if (!strcmp(b_map->string, value_str)) {
363 value = b_map->value;
364 break;
365 }
366 }
367
368 if (value == -1) {
369 log_warnx("lldpctl", "invalid value");
e1926a99 370 lldpctl_atom_dec_ref(config);
dfbd7185
RP
371 return 0;
372 }
373
8b549648
VB
374 if (lldpctl_atom_set_int(config, lldpctl_k_config_bond_slave_src_mac_type,
375 value) == NULL) {
376 log_warnx("lldpctl",
377 "unable to set bond slave src mac type."
378 " %s",
379 lldpctl_last_strerror(conn));
dfbd7185
RP
380 lldpctl_atom_dec_ref(config);
381 return 0;
382 }
383
8b549648 384 log_info("lldpctl", "bond slave src mac set to new value: %s", value_str);
dfbd7185
RP
385 lldpctl_atom_dec_ref(config);
386
387 return 1;
388}
389
6e3cb2f5 390static int
8b549648 391cmd_maxneighs(struct lldpctl_conn_t *conn, struct writer *w, struct cmd_env *env,
f540397c 392 const void *arg)
6e3cb2f5
VB
393{
394 log_debug("lldpctl", "set maximum neighbors");
395
396 lldpctl_atom_t *config = lldpctl_get_configuration(conn);
397 if (config == NULL) {
398 log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
399 lldpctl_last_strerror(conn));
400 return 0;
401 }
8b549648
VB
402 if (lldpctl_atom_set_str(config, lldpctl_k_config_max_neighbors,
403 cmdenv_get(env, "max-neighbors")) == NULL) {
6e3cb2f5
VB
404 log_warnx("lldpctl", "unable to set maximum of neighbors. %s",
405 lldpctl_last_strerror(conn));
406 lldpctl_atom_dec_ref(config);
407 return 0;
408 }
8b549648
VB
409 log_info("lldpctl", "maximum neighbors set to new value %s",
410 cmdenv_get(env, "max-neighbors"));
6e3cb2f5
VB
411 lldpctl_atom_dec_ref(config);
412 return 1;
413}
414
c9703b96
VB
415/**
416 * Register `configure system bond-slave-src-mac-type`
417 */
418static void
419register_commands_srcmac_type(struct cmd_node *configure)
420{
421 struct cmd_node *bond_slave_src_mac_type =
8b549648
VB
422 commands_new(configure, "bond-slave-src-mac-type",
423 "Set LLDP bond slave source MAC type", NULL, NULL, NULL);
c9703b96
VB
424
425 for (lldpctl_map_t *b_map =
8b549648
VB
426 lldpctl_key_get_map(lldpctl_k_config_bond_slave_src_mac_type);
427 b_map->string; b_map++) {
c9703b96 428 if (!strcmp(b_map->string, "real")) {
8b549648
VB
429 commands_new(commands_new(bond_slave_src_mac_type,
430 b_map->string, "Real mac", NULL, NULL, NULL),
431 NEWLINE, NULL, NULL, cmd_bondslave_srcmac_type,
432 b_map->string);
c9703b96 433 } else if (!strcmp(b_map->string, "zero")) {
8b549648
VB
434 commands_new(commands_new(bond_slave_src_mac_type,
435 b_map->string, "All zero mac", NULL, NULL,
436 NULL),
437 NEWLINE, NULL, NULL, cmd_bondslave_srcmac_type,
438 b_map->string);
2746d430 439 } else if (!strcmp(b_map->string, "fixed")) {
8b549648
VB
440 commands_new(commands_new(bond_slave_src_mac_type,
441 b_map->string, "Fixed value (3Com card)", NULL,
442 NULL, NULL),
443 NEWLINE, NULL, NULL, cmd_bondslave_srcmac_type,
444 b_map->string);
c9703b96 445 } else if (!strcmp(b_map->string, "local")) {
8b549648
VB
446 commands_new(commands_new(bond_slave_src_mac_type,
447 b_map->string,
448 "Real Mac with locally "
449 "administered bit set",
450 NULL, NULL, NULL),
451 NEWLINE, NULL, NULL, cmd_bondslave_srcmac_type,
452 b_map->string);
c9703b96
VB
453 }
454 }
455}
456
4c8e6e37
ISN
457static void
458register_commands_capabilities(struct cmd_node *configure, struct cmd_node *unconfigure)
459{
8b549648
VB
460 struct cmd_node *configure_capability = commands_new(configure, "capabilities",
461 "Capabilities configuration", cmd_check_no_env, NULL, "ports");
462 struct cmd_node *unconfigure_capability =
463 commands_new(unconfigure, "capabilities", "Capabilities configuration",
464 cmd_check_no_env, NULL, "ports");
4c8e6e37
ISN
465
466 /* Override */
8b549648
VB
467 commands_new(commands_new(commands_new(configure_capability, "enabled",
468 "Override capabilities", NULL, NULL, NULL),
469 NULL, " Set of capabilities separated by commas", NULL,
470 cmd_store_env_value, "capabilities"),
471 NEWLINE, "Override capabilities", NULL, cmd_capability, "configure");
4c8e6e37
ISN
472
473 /* Do not override */
8b549648
VB
474 commands_new(commands_new(unconfigure_capability, "enabled",
475 "Do not override capabilities", NULL, NULL, NULL),
476 NEWLINE, "Do not override capabilities", NULL, cmd_capability,
477 "unconfigure");
4c8e6e37
ISN
478}
479
994b3371
VB
480/**
481 * Register `configure system` commands.
482 *
483 * Those are the commands to configure protocol-independant stuff.
484 */
485void
bb37268d
VB
486register_commands_configure_system(struct cmd_node *configure,
487 struct cmd_node *unconfigure)
994b3371 488{
8b549648
VB
489 struct cmd_node *configure_system = commands_new(configure, "system",
490 "System configuration", cmd_check_no_env, NULL, "ports");
491 struct cmd_node *unconfigure_system = commands_new(unconfigure, "system",
492 "System configuration", cmd_check_no_env, NULL, "ports");
493 struct cmd_node *configure_interface = commands_new(configure_system,
494 "interface", "Interface related items", NULL, NULL, NULL);
495 struct cmd_node *unconfigure_interface = commands_new(unconfigure_system,
496 "interface", "Interface related items", NULL, NULL, NULL);
497
498 commands_new(commands_new(commands_new(configure_system, "description",
499 "Override chassis description", NULL, NULL, NULL),
500 NULL, "Chassis description", NULL, cmd_store_env_value,
501 "description"),
502 NEWLINE, "Override chassis description", NULL, cmd_system_description,
503 "system");
504 commands_new(commands_new(unconfigure_system, "description",
505 "Don't override chassis description", NULL, NULL, NULL),
506 NEWLINE, "Don't override chassis description", NULL, cmd_system_description,
507 "system");
508
509 commands_new(commands_new(commands_new(configure_system, "chassisid",
510 "Override chassis ID", NULL, NULL, NULL),
511 NULL, "Chassis ID", NULL, cmd_store_env_value, "description"),
512 NEWLINE, "Override chassis ID", NULL, cmd_system_chassisid, "system");
513 commands_new(commands_new(unconfigure_system, "chassisid",
514 "Don't override chassis ID", NULL, NULL, NULL),
515 NEWLINE, "Don't override chassis ID", NULL, cmd_system_chassisid, "system");
516
517 commands_new(commands_new(commands_new(configure_system, "platform",
518 "Override platform description", NULL, NULL,
519 NULL),
520 NULL, "Platform description (CDP)", NULL, cmd_store_env_value,
521 "platform"),
522 NEWLINE, "Override platform description", NULL, cmd_system_description,
523 "platform");
524 commands_new(commands_new(unconfigure_system, "platform",
525 "Don't override platform description", NULL, NULL, NULL),
526 NEWLINE, "Don't override platform description", NULL,
527 cmd_system_description, "platform");
528
529 commands_new(commands_new(commands_new(configure_system, "hostname",
530 "Override system name", NULL, NULL, NULL),
531 NULL, "System name", NULL, cmd_store_env_value, "hostname"),
532 NEWLINE, "Override system name", NULL, cmd_hostname, NULL);
533 commands_new(commands_new(unconfigure_system, "hostname",
534 "Don't override system name", NULL, NULL, NULL),
535 NEWLINE, "Don't override system name", NULL, cmd_hostname, NULL);
536
537 commands_new(commands_new(commands_new(configure_system, "max-neighbors",
538 "Set maximum number of neighbors per port",
539 cmd_check_no_env, NULL, "ports"),
540 NULL, "Maximum number of neighbors", NULL, cmd_store_env_value,
541 "max-neighbors"),
542 NEWLINE, "Set maximum number of neighbors per port", NULL, cmd_maxneighs,
543 NULL);
8481f490 544
3f70e118 545 commands_new(
8b549648
VB
546 commands_new(commands_new(commands_new(commands_new(configure_system, "ip",
547 "IP related options", NULL, NULL,
548 NULL),
549 "management", "IP management related options",
550 NULL, NULL, NULL),
551 "pattern", "Set IP management pattern", NULL, NULL, NULL),
552 NULL, "IP management pattern (comma-separated list of wildcards)", NULL,
553 cmd_store_env_value, "management-pattern"),
554 NEWLINE, "Set IP management pattern", NULL, cmd_management, NULL);
6dd83015 555 commands_new(
8b549648
VB
556 commands_new(commands_new(commands_new(unconfigure_system, "ip",
557 "IP related options", NULL, NULL, NULL),
558 "management", "IP management related options", NULL, NULL,
559 NULL),
560 "pattern", "Delete any IP management pattern", NULL, NULL, NULL),
561 NEWLINE, "Delete any IP management pattern", NULL, cmd_management, NULL);
562
563 commands_new(commands_new(commands_new(configure_interface, "pattern",
564 "Set active interface pattern", NULL, NULL, NULL),
565 NULL, "Interface pattern (comma-separated list of wildcards)",
566 NULL, cmd_store_env_value, "iface-pattern"),
567 NEWLINE, "Set active interface pattern", NULL, cmd_iface_pattern, NULL);
568 commands_new(commands_new(unconfigure_interface, "pattern",
569 "Delete any interface pattern", NULL, NULL, NULL),
570 NEWLINE, "Clear interface pattern", NULL, cmd_iface_pattern, NULL);
decaec0d 571
ce347d29 572 commands_new(
8b549648
VB
573 commands_new(commands_new(configure_interface, "permanent",
574 "Set permanent interface pattern", NULL, NULL, NULL),
575 NULL, "Permanent interface pattern (comma-separated list of wildcards)",
576 NULL, cmd_store_env_value, "iface-pattern"),
577 NEWLINE, "Set permanent interface pattern", NULL, cmd_perm_iface_pattern,
578 NULL);
579 commands_new(commands_new(unconfigure_interface, "permanent",
580 "Clear permanent interface pattern", NULL, NULL, NULL),
581 NEWLINE, "Delete any interface pattern", NULL, cmd_perm_iface_pattern,
582 NULL);
583
584 commands_new(commands_new(configure_interface, "description",
585 "Update interface descriptions with neighbor name", NULL, NULL,
586 NULL),
587 NEWLINE, "Update interface descriptions with neighbor name", NULL,
588 cmd_update_descriptions, "enable");
589 commands_new(commands_new(unconfigure_interface, "description",
590 "Don't update interface descriptions with neighbor name", NULL,
591 NULL, NULL),
592 NEWLINE, "Don't update interface descriptions with neighbor name", NULL,
593 cmd_update_descriptions, NULL);
594
595 commands_new(commands_new(configure_interface, "promiscuous",
596 "Enable promiscuous mode on managed interfaces", NULL, NULL,
597 NULL),
598 NEWLINE, "Enable promiscuous mode on managed interfaces", NULL,
599 cmd_iface_promisc, "enable");
600 commands_new(commands_new(unconfigure_interface, "promiscuous",
601 "Don't enable promiscuous mode on managed interfaces", NULL,
602 NULL, NULL),
603 NEWLINE, "Don't enable promiscuous mode on managed interfaces", NULL,
604 cmd_iface_promisc, NULL);
f84199dd 605
4c8e6e37 606 register_commands_capabilities(configure_system, unconfigure_system);
c9703b96 607 register_commands_srcmac_type(configure_system);
994b3371 608}