CMD_LOAD,
CMD_HELP,
CMD_SHOW,
+ CMD_PORTMAP,
};
static void
static void
print_usage(void)
{
+ printf("swconfig list\n");
printf("swconfig dev <dev> [port <port>|vlan <vlan>] (help|set <key> <value>|get <key>|load <config>|show)\n");
exit(1);
}
{
struct uci_context *ctx;
struct uci_package *p = NULL;
- struct uci_element *e;
int ret = -1;
ctx = uci_alloc_context();
struct switch_dev *dev;
struct switch_attr *a;
struct switch_val val;
- int err;
int i;
int cmd = CMD_NONE;
int cvlan = -1;
char *ckey = NULL;
char *cvalue = NULL;
+ char *csegment = NULL;
+
+ if((argc == 2) && !strcmp(argv[1], "list")) {
+ swlib_list();
+ return 0;
+ }
if(argc < 4)
print_usage();
print_usage();
cmd = CMD_LOAD;
ckey = argv[++i];
+ } else if (!strcmp(arg, "portmap")) {
+ if (i + 1 < argc)
+ csegment = argv[++i];
+ cmd = CMD_PORTMAP;
} else if (!strcmp(arg, "show")) {
cmd = CMD_SHOW;
} else {
dev = swlib_connect(cdev);
if (!dev) {
- fprintf(stderr, "Failed to connect to the switch\n");
+ fprintf(stderr, "Failed to connect to the switch. Use the \"list\" command to see which switches are available.\n");
return 1;
}
if(!a)
{
fprintf(stderr, "Unknown attribute \"%s\"\n", ckey);
+ retval = -1;
goto out;
}
}
case CMD_HELP:
list_attributes(dev);
break;
+ case CMD_PORTMAP:
+ swlib_print_portmap(dev, csegment);
+ break;
case CMD_SHOW:
if (cport >= 0 || cvlan >= 0) {
if (cport >= 0)
out:
swlib_free_all(dev);
- return 0;
+ return retval;
}