5 int do_netconf_set (int argc, const char **argv, struct ngadmin *nga)
8 const struct swi_attr *sa;
13 printf("usage: netconf set [dhcp yes|no] [ip <ip>] [mask <mask>] [gw <gw>]\n");
17 sa = ngadmin_getCurrentSwitch(nga);
19 printf("must be logged\n");
23 memset(&nc, 0, sizeof(struct net_conf));
25 for (k = 0; k < argc; k += 2) {
26 if (strcasecmp(argv[k], "dhcp") == 0) {
27 if (strcasecmp(argv[k + 1], "yes") == 0) {
29 } else if (strcasecmp(argv[k + 1], "no") == 0) {
32 printf("Incorrect DHCP value\n");
36 } else if (strcasecmp(argv[k], "ip") == 0) {
37 if (inet_aton(argv[k + 1], &nc.ip) == 0) {
38 printf("Incorrect IP value\n");
42 } else if (strcasecmp(argv[k], "mask") == 0) {
43 /* TODO: check if it is a correct mask */
44 if (inet_aton(argv[k + 1], &nc.netmask) == 0) {
45 printf("Incorrect mask value\n");
49 } else if (strcasecmp(argv[k], "gw") == 0) {
50 if (inet_aton(argv[k + 1], &nc.gw) == 0) {
51 printf("Incorrect gateway value\n");
58 i = ngadmin_setNetConf(nga, &nc);