Author: cgutman
Date: Sat Jul 4 07:36:19 2009
New Revision: 41763
URL:
http://svn.reactos.org/svn/reactos?rev=41763&view=rev
Log:
- Don't use a global interface_info struct
- This should allow for multiple NIC support but it's currently broken because
GetIfTable returns invalid information for NICs after the first one which prevents DHCP
initialization for those adapters
Modified:
trunk/reactos/base/services/dhcp/adapter.c
trunk/reactos/base/services/dhcp/dhclient.c
trunk/reactos/base/services/dhcp/include/dhcpd.h
trunk/reactos/base/services/dhcp/include/rosdhcp.h
trunk/reactos/base/services/dhcp/util.c
Modified: trunk/reactos/base/services/dhcp/adapter.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/dhcp/adapter…
==============================================================================
--- trunk/reactos/base/services/dhcp/adapter.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/dhcp/adapter.c [iso-8859-1] Sat Jul 4 07:36:19 2009
@@ -3,7 +3,6 @@
static SOCKET DhcpSocket = INVALID_SOCKET;
static LIST_ENTRY AdapterList;
static WSADATA wsd;
-extern struct interface_info *ifi;
PCHAR *GetSubkeyNames( PCHAR MainKeyName, PCHAR Append ) {
int i = 0;
@@ -215,6 +214,7 @@
PMIB_IFTABLE Table = (PMIB_IFTABLE) malloc(sizeof(MIB_IFTABLE));
DWORD Error, Size, i;
PDHCP_ADAPTER Adapter = NULL;
+ struct interface_info *ifi = NULL;
WSAStartup(0x0101,&wsd);
Modified: trunk/reactos/base/services/dhcp/dhclient.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/dhcp/dhclien…
==============================================================================
--- trunk/reactos/base/services/dhcp/dhclient.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/dhcp/dhclient.c [iso-8859-1] Sat Jul 4 07:36:19 2009
@@ -100,8 +100,6 @@
int unknown_ok = 1;
int routefd;
-struct interface_info *ifi = NULL;
-
void usage(void);
int check_option(struct client_lease *l, int option);
int ipv4addrs(char * buf);
@@ -135,6 +133,7 @@
main(int argc, char *argv[])
{
int i = 0;
+ PDHCP_ADAPTER Adapter;
ApiInit();
AdapterInit();
PipeInit();
@@ -150,32 +149,29 @@
DH_DbgPrint(MID_TRACE,("DHCP Service Started\n"));
- read_client_conf();
-
- if (!interface_link_status(ifi->name)) {
- DH_DbgPrint(MID_TRACE,("%s: no link ", ifi->name));
- Sleep(1000);
- while (!interface_link_status(ifi->name)) {
- DH_DbgPrint(MID_TRACE,("."));
- if (++i > 10) {
- DH_DbgPrint(MID_TRACE,("Giving up for now on adapter
[%s]\n", ifi->name));
- }
- Sleep(1000);
- }
- DH_DbgPrint(MID_TRACE,("Got link on [%s]\n", ifi->name));
- }
-
- DH_DbgPrint(MID_TRACE,("Discover Interfaces\n"));
-
- /* If no adapters were found, just idle for now ... If any show up,
- * then we'll start it later */
- if( ifi ) {
- /* set up the interface */
- discover_interfaces(ifi);
-
- DH_DbgPrint
- (MID_TRACE,
- ("Setting init state and restarting interface %p\n",ifi));
+ for (Adapter = AdapterGetFirst();
+ Adapter != NULL;
+ Adapter = AdapterGetNext(Adapter))
+ {
+ read_client_conf(&Adapter->DhclientInfo);
+
+ if (!interface_link_status(Adapter->DhclientInfo.name)) {
+ DH_DbgPrint(MID_TRACE,("%s: no link ",
Adapter->DhclientInfo.name));
+ Sleep(1000);
+ while (!interface_link_status(Adapter->DhclientInfo.name)) {
+ DH_DbgPrint(MID_TRACE,("."));
+ if (++i > 10) {
+ DH_DbgPrint(MID_TRACE,("Giving up for now on adapter
[%s]\n", Adapter->DhclientInfo.name));
+ }
+ Sleep(1000);
+ }
+ DH_DbgPrint(MID_TRACE,("Got link on [%s]\n",
Adapter->DhclientInfo.name));
+ }
+
+ DH_DbgPrint(MID_TRACE,("Discover Interfaces\n"));
+
+ /* set up the interface */
+ discover_interfaces(&Adapter->DhclientInfo);
}
bootp_packet_handler = do_packet;
@@ -1556,7 +1552,7 @@
FILE *leaseFile;
void
-rewrite_client_leases(void)
+rewrite_client_leases(struct interface_info *ifi)
{
struct client_lease *lp;
@@ -1587,7 +1583,7 @@
if (!rewrite) {
if (leases_written++ > 20) {
- rewrite_client_leases();
+ rewrite_client_leases(ip);
leases_written = 0;
}
}
@@ -1674,19 +1670,16 @@
}
void
-priv_script_init(char *reason, char *medium)
-{
- struct interface_info *ip = ifi;
-
+priv_script_init(struct interface_info *ip, char *reason, char *medium)
+{
if (ip) {
// XXX Do we need to do anything?
}
}
void
-priv_script_write_params(char *prefix, struct client_lease *lease)
-{
- struct interface_info *ip = ifi;
+priv_script_write_params(struct interface_info *ip, char *prefix, struct client_lease
*lease)
+{
u_int8_t dbuf[1500];
int i, len = 0;
Modified: trunk/reactos/base/services/dhcp/include/dhcpd.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/dhcp/include…
==============================================================================
--- trunk/reactos/base/services/dhcp/include/dhcpd.h [iso-8859-1] (original)
+++ trunk/reactos/base/services/dhcp/include/dhcpd.h [iso-8859-1] Sat Jul 4 07:36:19
2009
@@ -426,11 +426,11 @@
void make_decline(struct interface_info *, struct client_lease *);
void free_client_lease(struct client_lease *);
-void rewrite_client_leases(void);
+void rewrite_client_leases(struct interface_info *);
void write_client_lease(struct interface_info *, struct client_lease *, int);
-void priv_script_init(char *, char *);
-void priv_script_write_params(char *, struct client_lease *);
+void priv_script_init(struct interface_info *, char *, char *);
+void priv_script_write_params(struct interface_info *, char *, struct client_lease *);
int priv_script_go(void);
void script_init(char *, struct string_list *);
@@ -466,7 +466,7 @@
int, struct hardware *);
/* clparse.c */
-int read_client_conf(void);
+int read_client_conf(struct interface_info *);
void read_client_leases(void);
void parse_client_statement(FILE *, struct interface_info *,
struct client_config *);
Modified: trunk/reactos/base/services/dhcp/include/rosdhcp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/dhcp/include…
==============================================================================
--- trunk/reactos/base/services/dhcp/include/rosdhcp.h [iso-8859-1] (original)
+++ trunk/reactos/base/services/dhcp/include/rosdhcp.h [iso-8859-1] Sat Jul 4 07:36:19
2009
@@ -72,6 +72,8 @@
void AdapterInit(VOID);
HANDLE PipeInit(VOID);
+extern PDHCP_ADAPTER AdapterGetFirst();
+extern PDHCP_ADAPTER AdapterGetNext(PDHCP_ADAPTER);
extern PDHCP_ADAPTER AdapterFindIndex( unsigned int AdapterIndex );
extern PDHCP_ADAPTER AdapterFindInfo( struct interface_info *info );
extern VOID ApiInit();
Modified: trunk/reactos/base/services/dhcp/util.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/dhcp/util.c?…
==============================================================================
--- trunk/reactos/base/services/dhcp/util.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/dhcp/util.c [iso-8859-1] Sat Jul 4 07:36:19 2009
@@ -3,8 +3,6 @@
#define NDEBUG
#include <reactos/debug.h>
-
-extern struct interface_info *ifi;
char *piaddr( struct iaddr addr ) {
struct sockaddr_in sa;
@@ -96,7 +94,7 @@
void *dmalloc( int size, char *name ) { return malloc( size ); }
-int read_client_conf(void) {
+int read_client_conf(struct interface_info *ifi) {
/* What a strange dance */
struct client_config *config;
char ComputerName [MAX_COMPUTERNAME_LENGTH + 1];