Show the switch name.
.
.TP
+\fBnetconf show
+Show the network configuration.
+.
+.TP
\fBnetconf set\fR [ dhcp yes|no ] [ ip \fIip\fR ] [ mask\fI mask\fR ] \
[ gw\fI gw\fR ]
Set various network related options. \fIip\fR, \fImask\fR and \fIgw\fR must be
#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;
/* netconf */
+int do_netconf_show (int argc, const char **argv, struct ngadmin *nga);
int do_netconf_set (int argc, const char **argv, struct ngadmin *nga);
COM_END
COM_START(netconf)
+ COM_TERM(show, do_netconf_show)
COM_TERM(set, do_netconf_set)
COM_END
return;
}
- printf("Num\tMac\t\t\tProduct\t\tName\t\t\tIP/mask\t\t\tDHCP\tPorts\tFirmware\n");
+ printf("Num\tMac\t\t\tProduct\t\tName\t\t\tIP\t\tPorts\tFirmware\n");
- for (i = 0; i < nb; i++) {
- printf("%i\t%s\t%s\t%s\t\t%s/", i, ether_ntoa(&sa[i].mac), sa[i].product, sa[i].name, inet_ntoa(sa[i].nc.ip));
- printf("%s\t%s\t%i\t%s\n", inet_ntoa(sa[i].nc.netmask), ( sa[i].nc.dhcp ? "Yes" : "No" ), sa[i].ports, sa[i].firmware);
- }
+ for (i = 0; i < nb; i++)
+ printf("%i\t%s\t%s\t%s\t\t%s\t%i\t%s\n", i, ether_ntoa(&sa[i].mac), sa[i].product, sa[i].name, inet_ntoa(sa[i].nc.ip), sa[i].ports, sa[i].firmware);
printf("\nfound %i switch(es)\n", nb);
}