6 bool do_netconf_set (int nb, const char **com, struct ngadmin *nga) {
9 const struct swi_attr *sa;
15 printf("Usage: netconf set [dhcp yes|no] [ip <ip>] [mask <mask>] [gw <gw>]\n");
19 if ( (sa=ngadmin_getCurrentSwitch(nga))==NULL ) {
20 printf("must be logged\n");
25 memset(&nc, 0, sizeof(struct net_conf));
27 for (k=0; k<nb; k+=2) {
29 if ( strcasecmp(com[k], "dhcp")==0 ) {
30 if ( strcasecmp(com[k+1], "yes")==0 ) {
32 } else if ( strcasecmp(com[k+1], "no")==0 ) {
35 printf("Incorrect DHCP value\n");
40 } else if ( strcasecmp(com[k], "ip")==0 ) {
41 if ( inet_aton(com[k+1], &nc.ip)==0 ) {
42 printf("Incorrect IP value\n");
47 } else if ( strcasecmp(com[k], "mask")==0 ) {
48 if ( inet_aton(com[k+1], &nc.netmask)==0 ) { // TODO: check if it is a correct mask
49 printf("Incorrect mask value\n");
54 } else if ( strcasecmp(com[k], "gw")==0 ) {
55 if ( inet_aton(com[k+1], &nc.gw)==0 ) {
56 printf("Incorrect gateway value\n");
66 i=ngadmin_setNetConf(nga, &nc);