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