#include "commands.h"
+int do_netconf_show (int argc, const char **argv UNUSED, struct ngadmin *nga)
+{
+ const struct swi_attr *sa;
+ const struct net_conf *nc;
+
+
+ if (argc > 0) {
+ printf("this command takes no argument\n");
+ return 1;
+ }
+
+ sa = ngadmin_getCurrentSwitch(nga);
+ if (sa == NULL) {
+ printf("must be logged\n");
+ return 1;
+ }
+ nc = &sa->nc;
+
+ printf("DHCP\t : %s\n", nc->dhcp ? "yes" : "no");
+ printf("IP\t : %s\n", inet_ntoa(nc->ip));
+ printf("Netmask\t : %s\n", inet_ntoa(nc->netmask));
+ printf("Gateway\t : %s\n", inet_ntoa(nc->gw));
+
+
+ return 0;
+}
+
+
int do_netconf_set (int argc, const char **argv, struct ngadmin *nga)
{
int i, k, ret = 0;
return 1;
}
- memset(&nc, 0, sizeof(struct net_conf));
+ memcpy(&nc, &sa->nc, sizeof(struct net_conf));
- for (k = 0; k < argc; k += 2) {
+ for (k = 0; k < argc - 1; k += 2) {
if (strcasecmp(argv[k], "dhcp") == 0) {
if (strcasecmp(argv[k + 1], "yes") == 0) {
nc.dhcp = true;