X-Git-Url: https://git.kernelconcepts.de/?p=karo-tx-redboot.git;a=blobdiff_plain;f=packages%2Fnet%2Fcommon%2Fv2_0%2Fsrc%2Fdhcp_support.c;h=b7b5c604e5b6e6ac5816a0e2a8c126e89bd32313;hp=8ec2352b45fef263b3ed0faa716091a7e5261bee;hb=7a4ea0a4d67744fd3f6b5f207d857005fc707b46;hpb=f0c1bd5d9f8457be4a43912a28ca2df207a7f5a4 diff --git a/packages/net/common/v2_0/src/dhcp_support.c b/packages/net/common/v2_0/src/dhcp_support.c index 8ec2352b..b7b5c604 100644 --- a/packages/net/common/v2_0/src/dhcp_support.c +++ b/packages/net/common/v2_0/src/dhcp_support.c @@ -196,9 +196,19 @@ int dhcp_release( void ) // ------------------------------------------------------------------------ // The management thread function +// +// Note: 2007-01-15 +// This single management thread attempts to keep all configured +// interfaces alive via DHCP. While this may be sufficient for +// many systems, it falls short of perfect. There should probably +// be a separate thread for each possible interface, along with +// appropriate CDL to control how each inteface is managed. +// void dhcp_mgt_entry( cyg_addrword_t loop_on_failure ) { int j; + bool any_interfaces_up; + while ( 1 ) { while ( 1 ) { cyg_semaphore_wait( &dhcp_needs_attention ); @@ -208,7 +218,17 @@ void dhcp_mgt_entry( cyg_addrword_t loop_on_failure ) dhcp_halt(); // tear everything down if ( !loop_on_failure ) return; // exit the thread/return - init_all_network_interfaces(); // re-initialize + do { + init_all_network_interfaces(); // re-initialize + // If at least one interface is up, then the DHCP machine will run + any_interfaces_up = false; +#ifdef CYGHWR_NET_DRIVER_ETH0 + any_interfaces_up |= eth0_up; +#endif +#ifdef CYGHWR_NET_DRIVER_ETH1 + any_interfaces_up |= eth1_up; +#endif + } while (!any_interfaces_up); for ( j = 0; j < CYGPKG_NET_NLOOP; j++ ) init_loopback_interface( j ); #ifdef CYGPKG_SNMPAGENT @@ -222,22 +242,21 @@ void dhcp_mgt_entry( cyg_addrword_t loop_on_failure ) cyg_handle_t dhcp_mgt_thread_h = 0; cyg_thread dhcp_mgt_thread; -#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + sizeof(struct bootp)) -static cyg_uint8 dhcp_mgt_stack[ STACK_SIZE ]; +static cyg_uint8 dhcp_mgt_stack[ CYGPKG_NET_DHCP_THREAD_STACK_SIZE ]; void dhcp_start_dhcp_mgt_thread( void ) { if ( ! dhcp_mgt_thread_h ) { cyg_semaphore_init( &dhcp_needs_attention, 0 ); cyg_thread_create( - CYGPKG_NET_DHCP_THREAD_PRIORITY, /* scheduling info (eg pri) */ - dhcp_mgt_entry, /* entry point function */ + CYGPKG_NET_DHCP_THREAD_PRIORITY, /* scheduling info (eg pri) */ + dhcp_mgt_entry, /* entry point function */ CYGOPT_NET_DHCP_DHCP_THREAD_PARAM, /* entry data */ - "DHCP lease mgt", /* optional thread name */ - dhcp_mgt_stack, /* stack base, NULL = alloc */ - STACK_SIZE, /* stack size, 0 = default */ - &dhcp_mgt_thread_h, /* returned thread handle */ - &dhcp_mgt_thread /* put thread here */ + "DHCP lease mgt", /* optional thread name */ + dhcp_mgt_stack, /* stack base, NULL = alloc */ + CYGPKG_NET_DHCP_THREAD_STACK_SIZE, /* stack size, 0 = default */ + &dhcp_mgt_thread_h, /* returned thread handle */ + &dhcp_mgt_thread /* put thread here */ ); cyg_thread_resume(dhcp_mgt_thread_h);