| Remove UCI dependencies from swconfig command |
| |
| swconfig was a tool developped by OpenWrt maintainers, and obviously for |
| OpenWrt. The tool allow to set configuration parameters to a hardware switch |
| using the swconfig Netlink API. |
| |
| Most of the tool is generic, however the load sub-command relies on an OpenWrt |
| specific mechanism: UCI. In OpenWrt, UCI is a system-wide database which can be |
| used to configure all the system. |
| |
| As Chrome OS does not use UCI, this patch removes all the UCI dependencies. |
| --- a/src/cli.c |
| +++ b/src/cli.c |
| @@ -17,13 +17,13 @@ |
| #include <stdio.h> |
| #include <string.h> |
| #include <stdlib.h> |
| +#include <stdbool.h> |
| #include <inttypes.h> |
| #include <errno.h> |
| #include <stdint.h> |
| #include <getopt.h> |
| #include <sys/types.h> |
| #include <sys/socket.h> |
| -#include <uci.h> |
| |
| #include <linux/types.h> |
| #include <linux/netlink.h> |
| @@ -38,7 +38,6 @@ enum { |
| CMD_NONE, |
| CMD_GET, |
| CMD_SET, |
| - CMD_LOAD, |
| CMD_HELP, |
| CMD_SHOW, |
| CMD_PORTMAP, |
| @@ -169,36 +168,10 @@ 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"); |
| + printf("swconfig dev <dev> [port <port>|vlan <vlan>] (help|set <key> <value>|get <key>|show)\n"); |
| exit(1); |
| } |
| |
| -static void |
| -swconfig_load_uci(struct switch_dev *dev, const char *name) |
| -{ |
| - struct uci_context *ctx; |
| - struct uci_package *p = NULL; |
| - int ret = -1; |
| - |
| - ctx = uci_alloc_context(); |
| - if (!ctx) |
| - return; |
| - |
| - uci_load(ctx, name, &p); |
| - if (!p) { |
| - uci_perror(ctx, "Failed to load config file: "); |
| - goto out; |
| - } |
| - |
| - ret = swlib_apply_from_uci(dev, p); |
| - if (ret < 0) |
| - fprintf(stderr, "Failed to apply configuration for switch '%s'\n", dev->dev_name); |
| - |
| -out: |
| - uci_free_context(ctx); |
| - exit(ret); |
| -} |
| - |
| int main(int argc, char **argv) |
| { |
| int retval = 0; |
| @@ -247,11 +220,6 @@ int main(int argc, char **argv) |
| } else if (!strcmp(arg, "get") && i+1 < argc) { |
| cmd = CMD_GET; |
| ckey = argv[++i]; |
| - } else if (!strcmp(arg, "load") && i+1 < argc) { |
| - if ((cport >= 0) || (cvlan >= 0)) |
| - print_usage(); |
| - cmd = CMD_LOAD; |
| - ckey = argv[++i]; |
| } else if (!strcmp(arg, "portmap")) { |
| if (i + 1 < argc) |
| csegment = argv[++i]; |
| @@ -323,9 +291,6 @@ int main(int argc, char **argv) |
| print_attr_val(a, &val); |
| putchar('\n'); |
| break; |
| - case CMD_LOAD: |
| - swconfig_load_uci(dev, ckey); |
| - break; |
| case CMD_HELP: |
| list_attributes(dev); |
| break; |
| --- a/src/Makefile |
| +++ b/src/Makefile |
| @@ -13,5 +13,5 @@ all: swconfig |
| %.o: %.c |
| $(CC) $(CFLAGS) -c -o $@ $^ |
| |
| -swconfig: cli.o swlib.o uci.o |
| +swconfig: cli.o swlib.o |
| $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) |