Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 1 file changed
  • 0 comments
  • 1 contributor

Showing 1 changed file with 40 additions and 22 deletions. Show diff stats Hide diff stats

  1. 62  src/sysconfig.c
62  src/sysconfig.c
@@ -138,8 +138,11 @@ static struct sysconfig sysconfig = {
138 138
 	.language = SC_LANGUAGE_ENGLISH,
139 139
 	.keyboard_layout = SC_KEYBOARD_LAYOUT_US,
140 140
 	.dhcp_enable = 1,
141  
-	.ip = 0xc0a8002a,
142  
-	.netmask = 0xffffff00,
  141
+	.ip = 0xc0a8002a,	/* 192.168.0.42 */
  142
+	.netmask = 0xffffff00,	/* 255.255.255.0 */
  143
+	.gateway = 0xc0a80001,	/* 192.168.0.1 */
  144
+	.dns1 = 0xd043dede,	/* 208.67.222.222 */
  145
+	.dns2 = 0xd043dedc,	/* 208.67.222.220 */
143 146
 	.autostart_as = 1
144 147
 };
145 148
 
@@ -358,16 +361,29 @@ void sysconfig_get_ipconfig(int *dhcp_enable, unsigned int *ip, unsigned int *ne
358 361
 {
359 362
 	*dhcp_enable = sysconfig.dhcp_enable;
360 363
 
361  
-	if(ip != NULL)
362  
-		*ip = ifconfig_get_ip(SIOCGIFADDR);
363  
-	if(netmask != NULL)
364  
-		*netmask = ifconfig_get_ip(SIOCGIFNETMASK);
365  
-	if(gateway != NULL)
366  
-		*gateway = route_get_gateway();
367  
-	if(dns1 != NULL)
368  
-		*dns1 = rtems_bsdnet_nameserver_count > 0 ? rtems_bsdnet_nameserver[0].s_addr : 0;
369  
-	if(dns2 != NULL)
370  
-		*dns2 = rtems_bsdnet_nameserver_count > 1 ? rtems_bsdnet_nameserver[1].s_addr : 0;
  364
+	if(*dhcp_enable) {
  365
+		if(ip != NULL)
  366
+			*ip = ifconfig_get_ip(SIOCGIFADDR);
  367
+		if(netmask != NULL)
  368
+			*netmask = ifconfig_get_ip(SIOCGIFNETMASK);
  369
+		if(gateway != NULL)
  370
+			*gateway = route_get_gateway();
  371
+		if(dns1 != NULL)
  372
+			*dns1 = rtems_bsdnet_nameserver_count > 0 ? rtems_bsdnet_nameserver[0].s_addr : 0;
  373
+		if(dns2 != NULL)
  374
+			*dns2 = rtems_bsdnet_nameserver_count > 1 ? rtems_bsdnet_nameserver[1].s_addr : 0;
  375
+	} else {
  376
+		if(ip != NULL)
  377
+			*ip = sysconfig.ip;
  378
+		if(netmask != NULL)
  379
+			*netmask = sysconfig.netmask;
  380
+		if(gateway != NULL)
  381
+			*gateway = sysconfig.gateway;
  382
+		if(dns1 != NULL)
  383
+			*dns1 = sysconfig.dns1;
  384
+		if(dns2 != NULL)
  385
+			*dns2 = sysconfig.dns2;
  386
+	}
371 387
 }
372 388
 
373 389
 void sysconfig_get_credentials(char *login, char *password)
@@ -523,16 +539,18 @@ void sysconfig_set_ipconfig(int dhcp_enable, unsigned int ip, unsigned int netma
523 539
 	}
524 540
 
525 541
 	sysconfig.dhcp_enable = dhcp_enable;
526  
-	if(ip != 0)
527  
-		sysconfig.ip = ip;
528  
-	if(netmask != 0)
529  
-		sysconfig.netmask = netmask;
530  
-	if(gateway != 0)
531  
-		sysconfig.gateway = gateway;
532  
-	if(dns1 != 0)
533  
-		sysconfig.dns1 = dns1;
534  
-	if(dns2 != 0)
535  
-		sysconfig.dns2 = dns2;
  542
+	if(!dhcp_enable) {
  543
+		if(ip != 0)
  544
+			sysconfig.ip = ip;
  545
+		if(netmask != 0)
  546
+			sysconfig.netmask = netmask;
  547
+		if(gateway != 0)
  548
+			sysconfig.gateway = gateway;
  549
+		if(dns1 != 0)
  550
+			sysconfig.dns1 = dns1;
  551
+		if(dns2 != 0)
  552
+			sysconfig.dns2 = dns2;
  553
+	}
536 554
 }
537 555
 
538 556
 void sysconfig_set_credentials(char *login, char *password)

No commit comments for this range

Something went wrong with that request. Please try again.