summaryrefslogtreecommitdiffstats
path: root/src/client/conf-system.c
blob: 0700ec26ab01a53e69fbcd258dbc07604603d74b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
/* -*- mode: c; c-file-style: "openbsd" -*- */
/*
 * Copyright (c) 2013 Vincent Bernat <bernat@luffy.cx>
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include <unistd.h>
#include <string.h>
#include <sys/utsname.h>

#include "client.h"
#include "../log.h"

static int
cmd_iface_pattern(struct lldpctl_conn_t *conn, struct writer *w, struct cmd_env *env,
    const void *arg)
{
	log_debug("lldpctl", "set iface pattern");

	lldpctl_atom_t *config = lldpctl_get_configuration(conn);
	if (config == NULL) {
		log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
		    lldpctl_last_strerror(conn));
		return 0;
	}

	const char *value = cmdenv_get(env, "iface-pattern");
	if (lldpctl_atom_set_str(config, lldpctl_k_config_iface_pattern, value) ==
	    NULL) {
		log_warnx("lldpctl", "unable to set iface-pattern. %s",
		    lldpctl_last_strerror(conn));
		lldpctl_atom_dec_ref(config);
		return 0;
	}
	log_info("lldpctl", "iface-pattern set to new value %s",
	    value ? value : "(none)");
	lldpctl_atom_dec_ref(config);
	return 1;
}

static int
cmd_perm_iface_pattern(struct lldpctl_conn_t *conn, struct writer *w,
    struct cmd_env *env, const void *arg)
{
	log_debug("lldpctl", "set permanent iface pattern");

	lldpctl_atom_t *config = lldpctl_get_configuration(conn);
	if (config == NULL) {
		log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
		    lldpctl_last_strerror(conn));
		return 0;
	}

	const char *value = cmdenv_get(env, "iface-pattern");
	if (lldpctl_atom_set_str(config, lldpctl_k_config_perm_iface_pattern, value) ==
	    NULL) {
		log_warnx("lldpctl", "unable to set permanent iface pattern. %s",
		    lldpctl_last_strerror(conn));
		lldpctl_atom_dec_ref(config);
		return 0;
	}
	log_info("lldpctl", "permanent iface pattern set to new value %s",
	    value ? value : "(none)");
	lldpctl_atom_dec_ref(config);
	return 1;
}

static int
cmd_iface_promisc(struct lldpctl_conn_t *conn, struct writer *w, struct cmd_env *env,
    const void *arg)
{
	lldpctl_atom_t *config = lldpctl_get_configuration(conn);
	if (config == NULL) {
		log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
		    lldpctl_last_strerror(conn));
		return 0;
	}
	if (lldpctl_atom_set_int(config, lldpctl_k_config_iface_promisc, arg ? 1 : 0) ==
	    NULL) {
		log_warnx("lldpctl", "unable to %s promiscuous mode: %s",
		    arg ? "enable" : "disable", lldpctl_last_strerror(conn));
		lldpctl_atom_dec_ref(config);
		return 0;
	}
	log_info("lldpctl", "interface promiscuous mode %s",
	    arg ? "enabled" : "disabled");
	lldpctl_atom_dec_ref(config);
	return 1;
}

static int
cmd_system_description(struct lldpctl_conn_t *conn, struct writer *w,
    struct cmd_env *env, const void *arg)
{
	int platform = 0;
	const char *what = arg;
	const char *value;
	if (!strcmp(what, "system")) {
		value = cmdenv_get(env, "description");
	} else {
		value = cmdenv_get(env, "platform");
		platform = 1;
	}
	log_debug("lldpctl", "set %s description", what);
	lldpctl_atom_t *config = lldpctl_get_configuration(conn);
	if (config == NULL) {
		log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
		    lldpctl_last_strerror(conn));
		return 0;
	}
	if (lldpctl_atom_set_str(config,
		platform ? lldpctl_k_config_platform : lldpctl_k_config_description,
		value) == NULL) {
		log_warnx("lldpctl", "unable to set description. %s",
		    lldpctl_last_strerror(conn));
		lldpctl_atom_dec_ref(config);
		return 0;
	}
	log_info("lldpctl", "description set to new value %s",
	    value ? value : "(none)");
	lldpctl_atom_dec_ref(config);
	return 1;
}

static int
cmd_system_chassisid(struct lldpctl_conn_t *conn, struct writer *w, struct cmd_env *env,
    const void *arg)
{
	const char *value;
	value = cmdenv_get(env, "description");
	log_debug("lldpctl", "set chassis ID");
	lldpctl_atom_t *config = lldpctl_get_configuration(conn);
	if (config == NULL) {
		log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
		    lldpctl_last_strerror(conn));
		return 0;
	}
	if (lldpctl_atom_set_str(config, lldpctl_k_config_cid_string, value) == NULL) {
		log_warnx("lldpctl", "unable to set chassis ID. %s",
		    lldpctl_last_strerror(conn));
		lldpctl_atom_dec_ref(config);
		return 0;
	}
	log_info("lldpctl", "chassis ID set to new value %s", value ? value : "(none)");
	lldpctl_atom_dec_ref(config);
	return 1;
}

static int
cmd_management(struct lldpctl_conn_t *conn, struct writer *w, struct cmd_env *env,
    const void *arg)
{
	log_debug("lldpctl", "set management pattern");

	lldpctl_atom_t *config = lldpctl_get_configuration(conn);
	if (config == NULL) {
		log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
		    lldpctl_last_strerror(conn));
		return 0;
	}

	const char *value = cmdenv_get(env, "management-pattern");
	if (lldpctl_atom_set_str(config, lldpctl_k_config_mgmt_pattern, value) ==
	    NULL) {
		log_warnx("lldpctl", "unable to set management pattern. %s",
		    lldpctl_last_strerror(conn));
		lldpctl_atom_dec_ref(config);
		return 0;
	}
	log_info("lldpctl", "management pattern set to new value %s",
	    value ? value : "(none)");
	lldpctl_atom_dec_ref(config);
	return 1;
}

static int
cmd_hostname(struct lldpctl_conn_t *conn, struct writer *w, struct cmd_env *env,
    const void *arg)
{
	struct utsname un;
	log_debug("lldpctl", "set system name");

	lldpctl_atom_t *config = lldpctl_get_configuration(conn);
	if (config == NULL) {
		log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
		    lldpctl_last_strerror(conn));
		return 0;
	}

	const char *value = cmdenv_get(env, "hostname");
	if (value && strlen(value) == 1 && value[0] == '.') {
		if (uname(&un) < 0) {
			log_warn("lldpctl", "cannot get node name");
			lldpctl_atom_dec_ref(config);
			return 0;
		}
		char *c = strchr(un.nodename, '.');
		if (c) *c = 0;
		value = un.nodename;
	}
	if (lldpctl_atom_set_str(config, lldpctl_k_config_hostname, value) == NULL) {
		log_warnx("lldpctl", "unable to set system name. %s",
		    lldpctl_last_strerror(conn));
		lldpctl_atom_dec_ref(config);
		return 0;
	}
	log_info("lldpctl", "system name set to new value %s",
	    value ? value : "(none)");
	lldpctl_atom_dec_ref(config);
	return 1;
}

static int
cmd_capability(struct lldpctl_conn_t *conn, struct writer *w, struct cmd_env *env,
    const void *arg)
{
	log_debug("lldpctl", "set capabilities");

	int ret = 0;
	lldpctl_atom_t *config = lldpctl_get_configuration(conn);
	lldpctl_atom_t *chassis = NULL;
	if (config == NULL) {
		log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
		    lldpctl_last_strerror(conn));
		goto cmd_capability_end;
	}

	if (!strcmp(arg, "configure")) {

		const char *s = cmdenv_get(env, "capabilities");
		if (s) {
			chassis = lldpctl_get_local_chassis(conn);
			if (chassis == NULL) {
				log_warnx("lldpctl",
				    "unable to get local chassis from lldpd. %s",
				    lldpctl_last_strerror(conn));
				goto cmd_capability_end;
			}
			u_int16_t value = 0;
			const char delim[] = ",";
			char *s_copy = strdup(s);
			char *token = strtok(s_copy, delim);
			while (token != NULL) {
				if (!strcmp(token, "other")) {
					value |= LLDP_CAP_OTHER;
				} else if (!strcmp(token, "repeater")) {
					value |= LLDP_CAP_REPEATER;
				} else if (!strcmp(token, "bridge")) {
					value |= LLDP_CAP_BRIDGE;
				} else if (!strcmp(token, "wlan")) {
					value |= LLDP_CAP_WLAN;
				} else if (!strcmp(token, "router")) {
					value |= LLDP_CAP_ROUTER;
				} else if (!strcmp(token, "telephone")) {
					value |= LLDP_CAP_TELEPHONE;
				} else if (!strcmp(token, "docsis")) {
					value |= LLDP_CAP_DOCSIS;
				} else if (!strcmp(token, "station")) {
					value |= LLDP_CAP_STATION;
				} else {
					log_warnx("lldpctl", "capability %s not found",
					    token);
				}
				token = strtok(NULL, delim);
			}
			free(s_copy);

			if (lldpctl_atom_set_int(chassis, lldpctl_k_chassis_cap_enabled,
				value) == NULL) {
				log_warnx("lldpctl",
				    "unable to set system capabilities. %s",
				    lldpctl_last_strerror(conn));
				goto cmd_capability_end;
			}
			if (lldpctl_atom_set_int(config,
				lldpctl_k_config_chassis_cap_override, 1) == NULL) {
				log_warnx("lldpctl",
				    "unable to set system capabilities override. %s",
				    lldpctl_last_strerror(conn));
				goto cmd_capability_end;
			}
			log_debug("lldpctl", "system capabilities set to new value %d",
			    value);
		}
	} else {
		if (lldpctl_atom_set_int(config, lldpctl_k_config_chassis_cap_override,
			0) == NULL) {
			log_warnx("lldpctl",
			    "unable to set system capabilities to not override. %s",
			    lldpctl_last_strerror(conn));
			goto cmd_capability_end;
		}
	}

	ret = 1;
cmd_capability_end:
	lldpctl_atom_dec_ref(chassis);
	lldpctl_atom_dec_ref(config);
	return ret;
}

static int
cmd_update_descriptions(struct lldpctl_conn_t *conn, struct writer *w,
    struct cmd_env *env, const void *arg)
{
	lldpctl_atom_t *config = lldpctl_get_configuration(conn);
	if (config == NULL) {
		log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
		    lldpctl_last_strerror(conn));
		return 0;
	}
	if (lldpctl_atom_set_int(config, lldpctl_k_config_ifdescr_update,
		arg ? 1 : 0) == NULL) {
		log_warnx("lldpctl", "unable to %s interface description update: %s",
		    arg ? "enable" : "disable", lldpctl_last_strerror(conn));
		lldpctl_atom_dec_ref(config);
		return 0;
	}
	log_info("lldpctl", "interface description update %s",
	    arg ? "enabled" : "disabled");
	lldpctl_atom_dec_ref(config);
	return 1;
}

static int
cmd_bondslave_srcmac_type(struct lldpctl_conn_t *conn, struct writer *w,
    struct cmd_env *env, const void *arg)
{
	const char *value_str = 0;
	int value = -1;

	log_debug("lldpctl", "bond slave src mac");

	lldpctl_atom_t *config = lldpctl_get_configuration(conn);
	if (config == NULL) {
		log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
		    lldpctl_last_strerror(conn));
		return 0;
	}

	value_str = arg;
	for (lldpctl_map_t *b_map =
		 lldpctl_key_get_map(lldpctl_k_config_bond_slave_src_mac_type);
	     b_map->string; b_map++) {
		if (!strcmp(b_map->string, value_str)) {
			value = b_map->value;
			break;
		}
	}

	if (value == -1) {
		log_warnx("lldpctl", "invalid value");
		lldpctl_atom_dec_ref(config);
		return 0;
	}

	if (lldpctl_atom_set_int(config, lldpctl_k_config_bond_slave_src_mac_type,
		value) == NULL) {
		log_warnx("lldpctl",
		    "unable to set bond slave src mac type."
		    " %s",
		    lldpctl_last_strerror(conn));
		lldpctl_atom_dec_ref(config);
		return 0;
	}

	log_info("lldpctl", "bond slave src mac set to new value: %s", value_str);
	lldpctl_atom_dec_ref(config);

	return 1;
}

static int
cmd_maxneighs(struct lldpctl_conn_t *conn, struct writer *w, struct cmd_env *env,
    const void *arg)
{
	log_debug("lldpctl", "set maximum neighbors");

	lldpctl_atom_t *config = lldpctl_get_configuration(conn);
	if (config == NULL) {
		log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
		    lldpctl_last_strerror(conn));
		return 0;
	}
	if (lldpctl_atom_set_str(config, lldpctl_k_config_max_neighbors,
		cmdenv_get(env, "max-neighbors")) == NULL) {
		log_warnx("lldpctl", "unable to set maximum of neighbors. %s",
		    lldpctl_last_strerror(conn));
		lldpctl_atom_dec_ref(config);
		return 0;
	}
	log_info("lldpctl", "maximum neighbors set to new value %s",
	    cmdenv_get(env, "max-neighbors"));
	lldpctl_atom_dec_ref(config);
	return 1;
}

/**
 * Register `configure system bond-slave-src-mac-type`
 */
static void
register_commands_srcmac_type(struct cmd_node *configure)
{
	struct cmd_node *bond_slave_src_mac_type =
	    commands_new(configure, "bond-slave-src-mac-type",
		"Set LLDP bond slave source MAC type", NULL, NULL, NULL);

	for (lldpctl_map_t *b_map =
		 lldpctl_key_get_map(lldpctl_k_config_bond_slave_src_mac_type);
	     b_map->string; b_map++) {
		if (!strcmp(b_map->string, "real")) {
			commands_new(commands_new(bond_slave_src_mac_type,
					 b_map->string, "Real mac", NULL, NULL, NULL),
			    NEWLINE, NULL, NULL, cmd_bondslave_srcmac_type,
			    b_map->string);
		} else if (!strcmp(b_map->string, "zero")) {
			commands_new(commands_new(bond_slave_src_mac_type,
					 b_map->string, "All zero mac", NULL, NULL,
					 NULL),
			    NEWLINE, NULL, NULL, cmd_bondslave_srcmac_type,
			    b_map->string);
		} else if (!strcmp(b_map->string, "fixed")) {
			commands_new(commands_new(bond_slave_src_mac_type,
					 b_map->string, "Fixed value (3Com card)", NULL,
					 NULL, NULL),
			    NEWLINE, NULL, NULL, cmd_bondslave_srcmac_type,
			    b_map->string);
		} else if (!strcmp(b_map->string, "local")) {
			commands_new(commands_new(bond_slave_src_mac_type,
					 b_map->string,
					 "Real Mac with locally "
					 "administered bit set",
					 NULL, NULL, NULL),
			    NEWLINE, NULL, NULL, cmd_bondslave_srcmac_type,
			    b_map->string);
		}
	}
}

static void
register_commands_capabilities(struct cmd_node *configure, struct cmd_node *unconfigure)
{
	struct cmd_node *configure_capability = commands_new(configure, "capabilities",
	    "Capabilities configuration", cmd_check_no_env, NULL, "ports");
	struct cmd_node *unconfigure_capability =
	    commands_new(unconfigure, "capabilities", "Capabilities configuration",
		cmd_check_no_env, NULL, "ports");

	/* Override */
	commands_new(commands_new(commands_new(configure_capability, "enabled",
				      "Override capabilities", NULL, NULL, NULL),
			 NULL, " Set of capabilities separated by commas", NULL,
			 cmd_store_env_value, "capabilities"),
	    NEWLINE, "Override capabilities", NULL, cmd_capability, "configure");

	/* Do not override */
	commands_new(commands_new(unconfigure_capability, "enabled",
			 "Do not override capabilities", NULL, NULL, NULL),
	    NEWLINE, "Do not override capabilities", NULL, cmd_capability,
	    "unconfigure");
}

/**
 * Register `configure system` commands.
 *
 * Those are the commands to configure protocol-independant stuff.
 */
void
register_commands_configure_system(struct cmd_node *configure,
    struct cmd_node *unconfigure)
{
	struct cmd_node *configure_system = commands_new(configure, "system",
	    "System configuration", cmd_check_no_env, NULL, "ports");
	struct cmd_node *unconfigure_system = commands_new(unconfigure, "system",
	    "System configuration", cmd_check_no_env, NULL, "ports");
	struct cmd_node *configure_interface = commands_new(configure_system,
	    "interface", "Interface related items", NULL, NULL, NULL);
	struct cmd_node *unconfigure_interface = commands_new(unconfigure_system,
	    "interface", "Interface related items", NULL, NULL, NULL);

	commands_new(commands_new(commands_new(configure_system, "description",
				      "Override chassis description", NULL, NULL, NULL),
			 NULL, "Chassis description", NULL, cmd_store_env_value,
			 "description"),
	    NEWLINE, "Override chassis description", NULL, cmd_system_description,
	    "system");
	commands_new(commands_new(unconfigure_system, "description",
			 "Don't override chassis description", NULL, NULL, NULL),
	    NEWLINE, "Don't override chassis description", NULL, cmd_system_description,
	    "system");

	commands_new(commands_new(commands_new(configure_system, "chassisid",
				      "Override chassis ID", NULL, NULL, NULL),
			 NULL, "Chassis ID", NULL, cmd_store_env_value, "description"),
	    NEWLINE, "Override chassis ID", NULL, cmd_system_chassisid, "system");
	commands_new(commands_new(unconfigure_system, "chassisid",
			 "Don't override chassis ID", NULL, NULL, NULL),
	    NEWLINE, "Don't override chassis ID", NULL, cmd_system_chassisid, "system");

	commands_new(commands_new(commands_new(configure_system, "platform",
				      "Override platform description", NULL, NULL,
				      NULL),
			 NULL, "Platform description (CDP)", NULL, cmd_store_env_value,
			 "platform"),
	    NEWLINE, "Override platform description", NULL, cmd_system_description,
	    "platform");
	commands_new(commands_new(unconfigure_system, "platform",
			 "Don't override platform description", NULL, NULL, NULL),
	    NEWLINE, "Don't override platform description", NULL,
	    cmd_system_description, "platform");

	commands_new(commands_new(commands_new(configure_system, "hostname",
				      "Override system name", NULL, NULL, NULL),
			 NULL, "System name", NULL, cmd_store_env_value, "hostname"),
	    NEWLINE, "Override system name", NULL, cmd_hostname, NULL);
	commands_new(commands_new(unconfigure_system, "hostname",
			 "Don't override system name", NULL, NULL, NULL),
	    NEWLINE, "Don't override system name", NULL, cmd_hostname, NULL);

	commands_new(commands_new(commands_new(configure_system, "max-neighbors",
				      "Set maximum number of neighbors per port",
				      cmd_check_no_env, NULL, "ports"),
			 NULL, "Maximum number of neighbors", NULL, cmd_store_env_value,
			 "max-neighbors"),
	    NEWLINE, "Set maximum number of neighbors per port", NULL, cmd_maxneighs,
	    NULL);

	commands_new(
	    commands_new(commands_new(commands_new(commands_new(configure_system, "ip",
						       "IP related options", NULL, NULL,
						       NULL),
					  "management", "IP management related options",
					  NULL, NULL, NULL),
			     "pattern", "Set IP management pattern", NULL, NULL, NULL),
		NULL, "IP management pattern (comma-separated list of wildcards)", NULL,
		cmd_store_env_value, "management-pattern"),
	    NEWLINE, "Set IP management pattern", NULL, cmd_management, NULL);
	commands_new(
	    commands_new(commands_new(commands_new(unconfigure_system, "ip",
					  "IP related options", NULL, NULL, NULL),
			     "management", "IP management related options", NULL, NULL,
			     NULL),
		"pattern", "Delete any IP management pattern", NULL, NULL, NULL),
	    NEWLINE, "Delete any IP management pattern", NULL, cmd_management, NULL);

	commands_new(commands_new(commands_new(configure_interface, "pattern",
				      "Set active interface pattern", NULL, NULL, NULL),
			 NULL, "Interface pattern (comma-separated list of wildcards)",
			 NULL, cmd_store_env_value, "iface-pattern"),
	    NEWLINE, "Set active interface pattern", NULL, cmd_iface_pattern, NULL);
	commands_new(commands_new(unconfigure_interface, "pattern",
			 "Delete any interface pattern", NULL, NULL, NULL),
	    NEWLINE, "Clear interface pattern", NULL, cmd_iface_pattern, NULL);

	commands_new(
	    commands_new(commands_new(configure_interface, "permanent",
			     "Set permanent interface pattern", NULL, NULL, NULL),
		NULL, "Permanent interface pattern (comma-separated list of wildcards)",
		NULL, cmd_store_env_value, "iface-pattern"),
	    NEWLINE, "Set permanent interface pattern", NULL, cmd_perm_iface_pattern,
	    NULL);
	commands_new(commands_new(unconfigure_interface, "permanent",
			 "Clear permanent interface pattern", NULL, NULL, NULL),
	    NEWLINE, "Delete any interface pattern", NULL, cmd_perm_iface_pattern,
	    NULL);

	commands_new(commands_new(configure_interface, "description",
			 "Update interface descriptions with neighbor name", NULL, NULL,
			 NULL),
	    NEWLINE, "Update interface descriptions with neighbor name", NULL,
	    cmd_update_descriptions, "enable");
	commands_new(commands_new(unconfigure_interface, "description",
			 "Don't update interface descriptions with neighbor name", NULL,
			 NULL, NULL),
	    NEWLINE, "Don't update interface descriptions with neighbor name", NULL,
	    cmd_update_descriptions, NULL);

	commands_new(commands_new(configure_interface, "promiscuous",
			 "Enable promiscuous mode on managed interfaces", NULL, NULL,
			 NULL),
	    NEWLINE, "Enable promiscuous mode on managed interfaces", NULL,
	    cmd_iface_promisc, "enable");
	commands_new(commands_new(unconfigure_interface, "promiscuous",
			 "Don't enable promiscuous mode on managed interfaces", NULL,
			 NULL, NULL),
	    NEWLINE, "Don't enable promiscuous mode on managed interfaces", NULL,
	    cmd_iface_promisc, NULL);

	register_commands_capabilities(configure_system, unconfigure_system);
	register_commands_srcmac_type(configure_system);
}