-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshell_ip.c
39 lines (35 loc) · 1.55 KB
/
shell_ip.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "shell.h"
void shell_ip(char ** argv, int elem) {
if (elem == 1) {
printf(" ip [show|dhcp|set] \n");
return;
}
if (strncmp(argv[1], "show", 2) == 0) {
printf("IP:\t\t");
printIp(settings.ip);
printf("DHCP:\t\t%s\n", settings.dhcp == 0x01 ? "ON":"OFF");
printf("Subnetmask:\t");
printIp(settings.subnetmask);
printf("Gateway:\t");
printIp(settings.gateway);
printf("\n");
return;
}
if (strncmp(argv[1], "dhcp", 4) == 0) {
if (elem == 2) {
printf("ip dhcp [on|off|renew]\n");
printf(" on: Turn on DHCP\n");
printf(" off: Turn off DHCP, current IP will be taken\n");
printf(" renew: renew IP-Address via DHCP (turns on DHCP too)\n");
}else {
password();
if (strncmp(argv[2], "on", 2) == 0) {
printError(gs105e_dhcpSettings(DHCP_ON));
} else if (strncmp(argv[2], "off", 3) == 0) {
printError(gs105e_dhcpSettings(DHCP_OFF));
} else if (strncmp(argv[2], "renew", 5) == 0) {
printError(gs105e_dhcpSettings(DHCP_RENEW));
}
}
}
}