mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 00:32:25 -04:00
Some additional optimizations for using DHCP.
This commit is contained in:
parent
2a622f9d9f
commit
43d5ccb239
10 changed files with 38 additions and 21 deletions
|
|
@ -4,7 +4,7 @@
|
|||
* This is probably the last program in the `sysinstall' line - the next
|
||||
* generation being essentially a complete rewrite.
|
||||
*
|
||||
* $Id: install.c,v 1.240 1999/07/06 09:19:35 jkh Exp $
|
||||
* $Id: install.c,v 1.241 1999/07/16 11:13:09 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
|
|
@ -533,7 +533,7 @@ nodisks:
|
|||
dialog_clear_norefresh();
|
||||
tmp = tcpDeviceSelect();
|
||||
dialog_clear_norefresh();
|
||||
if (tmp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name))
|
||||
if (tmp && !((DevInfo *)tmp->private)->use_dhcp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name))
|
||||
if (!tmp->init(tmp))
|
||||
msgConfirm("Initialization of %s device failed.", tmp->name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
* This is probably the last attempt in the `sysinstall' line, the next
|
||||
* generation being slated to essentially a complete rewrite.
|
||||
*
|
||||
* $Id: network.c,v 1.35 1999/03/11 18:22:23 brian Exp $
|
||||
* $Id: network.c,v 1.36 1999/05/19 10:49:43 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
|
|
@ -123,6 +123,8 @@ mediaInitNetwork(Device *dev)
|
|||
"in the Networking configuration menu before proceeding.", dev->name);
|
||||
return FALSE;
|
||||
}
|
||||
else if (!strcmp(cp, "DHCP"))
|
||||
goto bail;
|
||||
msgNotify("ifconfig %s %s", dev->name, cp);
|
||||
i = vsystem("ifconfig %s %s", dev->name, cp);
|
||||
if (i) {
|
||||
|
|
@ -140,6 +142,7 @@ mediaInitNetwork(Device *dev)
|
|||
msgNotify("Adding default route to %s.", rp);
|
||||
vsystem("route -n add default %s", rp);
|
||||
}
|
||||
bail:
|
||||
if (isDebug())
|
||||
msgDebug("Network initialized successfully.\n");
|
||||
networkInitialized = TRUE;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
* This is probably the last attempt in the `sysinstall' line, the next
|
||||
* generation being slated to essentially a complete rewrite.
|
||||
*
|
||||
* $Id: sysinstall.h,v 1.168 1999/07/06 08:45:40 jkh Exp $
|
||||
* $Id: sysinstall.h,v 1.169 1999/07/16 11:13:09 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
|
|
@ -316,6 +316,7 @@ typedef int (*commandFunc)(char *key, void *data);
|
|||
|
||||
/* This is the structure that Network devices carry around in their private, erm, structures */
|
||||
typedef struct _devPriv {
|
||||
int use_dhcp;
|
||||
char ipaddr[IPADDR_FIELD_LEN];
|
||||
char netmask[IPADDR_FIELD_LEN];
|
||||
char extras[EXTRAS_FIELD_LEN];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Id: tcpip.c,v 1.80 1999/07/16 11:13:09 jkh Exp $
|
||||
* $Id: tcpip.c,v 1.81 1999/07/18 02:20:56 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Gary J Palmer. All rights reserved.
|
||||
|
|
@ -39,6 +39,7 @@
|
|||
|
||||
#include "sysinstall.h"
|
||||
#include <sys/param.h>
|
||||
#include <netdb.h>
|
||||
|
||||
/* The help file for the TCP/IP setup screen */
|
||||
#define TCP_HELPFILE "tcp"
|
||||
|
|
@ -164,23 +165,23 @@ tcpOpenDialog(Device *devp)
|
|||
SAFE_STRCPY(ipaddr, di->ipaddr);
|
||||
SAFE_STRCPY(netmask, di->netmask);
|
||||
SAFE_STRCPY(extras, di->extras);
|
||||
use_dhcp = di->use_dhcp;
|
||||
}
|
||||
else { /* See if there are any defaults */
|
||||
char *cp;
|
||||
|
||||
/* First try a DHCP scan if such behavior is desired */
|
||||
if (!variable_cmp(VAR_TRY_DHCP, "YES")) {
|
||||
if (!variable_cmp(VAR_TRY_DHCP, "YES") || !msgYesNo("Do you want to try DHCP configuration of the interface?")) {
|
||||
Mkdir("/var/db");
|
||||
Mkdir("/var/run");
|
||||
Mkdir("/tmp");
|
||||
msgNotify("Scanning for DHCP servers...");
|
||||
vsystem("ifconfig %s inet 0.0.0.0 netmask 0.0.0.0 broadcast 255.255.255.255 up", devp->name);
|
||||
if (!vsystem("dhclient %s", devp->name)) {
|
||||
FILE *ifp;
|
||||
char cmd[256];
|
||||
|
||||
if (isDebug())
|
||||
msgConfirm("Successful return from dhclient");
|
||||
msgDebug("Successful return from dhclient");
|
||||
snprintf(cmd, sizeof cmd, "ifconfig %s", devp->name);
|
||||
ifp = popen(cmd, "r");
|
||||
if (ifp) {
|
||||
|
|
@ -223,6 +224,8 @@ tcpOpenDialog(Device *devp)
|
|||
use_dhcp = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
use_dhcp = FALSE;
|
||||
|
||||
/* Get old IP address from variable space, if available */
|
||||
if (!ipaddr[0]) {
|
||||
|
|
@ -365,6 +368,7 @@ netconfig:
|
|||
SAFE_STRCPY(di->ipaddr, ipaddr);
|
||||
SAFE_STRCPY(di->netmask, netmask);
|
||||
SAFE_STRCPY(di->extras, extras);
|
||||
di->use_dhcp = use_dhcp;
|
||||
|
||||
sprintf(ifn, "%s%s", VAR_IFCONFIG, devp->name);
|
||||
if (use_dhcp)
|
||||
|
|
@ -461,7 +465,7 @@ tcpMenuSelect(dialogMenuItem *self)
|
|||
Device *tmp;
|
||||
|
||||
tmp = tcpDeviceSelect();
|
||||
if (tmp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name))
|
||||
if (tmp && !((DevInfo *)tmp->private)->use_dhcp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name))
|
||||
if (!tmp->init(tmp))
|
||||
msgConfirm("Initialization of %s device failed.", tmp->name);
|
||||
return DITEM_SUCCESS | DITEM_RESTORE;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
* This is probably the last program in the `sysinstall' line - the next
|
||||
* generation being essentially a complete rewrite.
|
||||
*
|
||||
* $Id: install.c,v 1.240 1999/07/06 09:19:35 jkh Exp $
|
||||
* $Id: install.c,v 1.241 1999/07/16 11:13:09 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
|
|
@ -533,7 +533,7 @@ nodisks:
|
|||
dialog_clear_norefresh();
|
||||
tmp = tcpDeviceSelect();
|
||||
dialog_clear_norefresh();
|
||||
if (tmp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name))
|
||||
if (tmp && !((DevInfo *)tmp->private)->use_dhcp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name))
|
||||
if (!tmp->init(tmp))
|
||||
msgConfirm("Initialization of %s device failed.", tmp->name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
* This is probably the last attempt in the `sysinstall' line, the next
|
||||
* generation being slated to essentially a complete rewrite.
|
||||
*
|
||||
* $Id: sysinstall.h,v 1.168 1999/07/06 08:45:40 jkh Exp $
|
||||
* $Id: sysinstall.h,v 1.169 1999/07/16 11:13:09 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
|
|
@ -316,6 +316,7 @@ typedef int (*commandFunc)(char *key, void *data);
|
|||
|
||||
/* This is the structure that Network devices carry around in their private, erm, structures */
|
||||
typedef struct _devPriv {
|
||||
int use_dhcp;
|
||||
char ipaddr[IPADDR_FIELD_LEN];
|
||||
char netmask[IPADDR_FIELD_LEN];
|
||||
char extras[EXTRAS_FIELD_LEN];
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
* This is probably the last program in the `sysinstall' line - the next
|
||||
* generation being essentially a complete rewrite.
|
||||
*
|
||||
* $Id: install.c,v 1.240 1999/07/06 09:19:35 jkh Exp $
|
||||
* $Id: install.c,v 1.241 1999/07/16 11:13:09 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
|
|
@ -533,7 +533,7 @@ nodisks:
|
|||
dialog_clear_norefresh();
|
||||
tmp = tcpDeviceSelect();
|
||||
dialog_clear_norefresh();
|
||||
if (tmp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name))
|
||||
if (tmp && !((DevInfo *)tmp->private)->use_dhcp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name))
|
||||
if (!tmp->init(tmp))
|
||||
msgConfirm("Initialization of %s device failed.", tmp->name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
* This is probably the last attempt in the `sysinstall' line, the next
|
||||
* generation being slated to essentially a complete rewrite.
|
||||
*
|
||||
* $Id: network.c,v 1.35 1999/03/11 18:22:23 brian Exp $
|
||||
* $Id: network.c,v 1.36 1999/05/19 10:49:43 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
|
|
@ -123,6 +123,8 @@ mediaInitNetwork(Device *dev)
|
|||
"in the Networking configuration menu before proceeding.", dev->name);
|
||||
return FALSE;
|
||||
}
|
||||
else if (!strcmp(cp, "DHCP"))
|
||||
goto bail;
|
||||
msgNotify("ifconfig %s %s", dev->name, cp);
|
||||
i = vsystem("ifconfig %s %s", dev->name, cp);
|
||||
if (i) {
|
||||
|
|
@ -140,6 +142,7 @@ mediaInitNetwork(Device *dev)
|
|||
msgNotify("Adding default route to %s.", rp);
|
||||
vsystem("route -n add default %s", rp);
|
||||
}
|
||||
bail:
|
||||
if (isDebug())
|
||||
msgDebug("Network initialized successfully.\n");
|
||||
networkInitialized = TRUE;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
* This is probably the last attempt in the `sysinstall' line, the next
|
||||
* generation being slated to essentially a complete rewrite.
|
||||
*
|
||||
* $Id: sysinstall.h,v 1.168 1999/07/06 08:45:40 jkh Exp $
|
||||
* $Id: sysinstall.h,v 1.169 1999/07/16 11:13:09 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
|
|
@ -316,6 +316,7 @@ typedef int (*commandFunc)(char *key, void *data);
|
|||
|
||||
/* This is the structure that Network devices carry around in their private, erm, structures */
|
||||
typedef struct _devPriv {
|
||||
int use_dhcp;
|
||||
char ipaddr[IPADDR_FIELD_LEN];
|
||||
char netmask[IPADDR_FIELD_LEN];
|
||||
char extras[EXTRAS_FIELD_LEN];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Id: tcpip.c,v 1.80 1999/07/16 11:13:09 jkh Exp $
|
||||
* $Id: tcpip.c,v 1.81 1999/07/18 02:20:56 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Gary J Palmer. All rights reserved.
|
||||
|
|
@ -39,6 +39,7 @@
|
|||
|
||||
#include "sysinstall.h"
|
||||
#include <sys/param.h>
|
||||
#include <netdb.h>
|
||||
|
||||
/* The help file for the TCP/IP setup screen */
|
||||
#define TCP_HELPFILE "tcp"
|
||||
|
|
@ -164,23 +165,23 @@ tcpOpenDialog(Device *devp)
|
|||
SAFE_STRCPY(ipaddr, di->ipaddr);
|
||||
SAFE_STRCPY(netmask, di->netmask);
|
||||
SAFE_STRCPY(extras, di->extras);
|
||||
use_dhcp = di->use_dhcp;
|
||||
}
|
||||
else { /* See if there are any defaults */
|
||||
char *cp;
|
||||
|
||||
/* First try a DHCP scan if such behavior is desired */
|
||||
if (!variable_cmp(VAR_TRY_DHCP, "YES")) {
|
||||
if (!variable_cmp(VAR_TRY_DHCP, "YES") || !msgYesNo("Do you want to try DHCP configuration of the interface?")) {
|
||||
Mkdir("/var/db");
|
||||
Mkdir("/var/run");
|
||||
Mkdir("/tmp");
|
||||
msgNotify("Scanning for DHCP servers...");
|
||||
vsystem("ifconfig %s inet 0.0.0.0 netmask 0.0.0.0 broadcast 255.255.255.255 up", devp->name);
|
||||
if (!vsystem("dhclient %s", devp->name)) {
|
||||
FILE *ifp;
|
||||
char cmd[256];
|
||||
|
||||
if (isDebug())
|
||||
msgConfirm("Successful return from dhclient");
|
||||
msgDebug("Successful return from dhclient");
|
||||
snprintf(cmd, sizeof cmd, "ifconfig %s", devp->name);
|
||||
ifp = popen(cmd, "r");
|
||||
if (ifp) {
|
||||
|
|
@ -223,6 +224,8 @@ tcpOpenDialog(Device *devp)
|
|||
use_dhcp = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
use_dhcp = FALSE;
|
||||
|
||||
/* Get old IP address from variable space, if available */
|
||||
if (!ipaddr[0]) {
|
||||
|
|
@ -365,6 +368,7 @@ netconfig:
|
|||
SAFE_STRCPY(di->ipaddr, ipaddr);
|
||||
SAFE_STRCPY(di->netmask, netmask);
|
||||
SAFE_STRCPY(di->extras, extras);
|
||||
di->use_dhcp = use_dhcp;
|
||||
|
||||
sprintf(ifn, "%s%s", VAR_IFCONFIG, devp->name);
|
||||
if (use_dhcp)
|
||||
|
|
@ -461,7 +465,7 @@ tcpMenuSelect(dialogMenuItem *self)
|
|||
Device *tmp;
|
||||
|
||||
tmp = tcpDeviceSelect();
|
||||
if (tmp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name))
|
||||
if (tmp && !((DevInfo *)tmp->private)->use_dhcp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name))
|
||||
if (!tmp->init(tmp))
|
||||
msgConfirm("Initialization of %s device failed.", tmp->name);
|
||||
return DITEM_SUCCESS | DITEM_RESTORE;
|
||||
|
|
|
|||
Loading…
Reference in a new issue