public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* Re: [ECOS] Dynamic IP/DHCP/Routing the 'right way'
@ 2006-06-06 12:38 FALL
  2006-06-06 21:26 ` Laurie Gellatly
  0 siblings, 1 reply; 10+ messages in thread
From: FALL @ 2006-06-06 12:38 UTC (permalink / raw)
  To: ecos-discuss, laurie.gellatly

I suppose you use LWIP stack. At the end of your mail, you write tat you will do the same for DNS, I don't think that LWIP supports DNS. If you want to change IP/gateway... while your programme is running, i think the best way is to use ioctl functions. Most of  ioctl commands are not supported by LWIP. I think you should chose freebsd stack for your project. Of course LWIP is very light and simple to undestand but freebsd is more complete. you have to make a choice:)
FALL Birahim
Elsys-Design 
PACA

---------- Original Message ----------------------------------
From: "Laurie Gellatly" <laurie.gellatly@netic.com>
Reply-To: <laurie.gellatly@netic.com>
Date:  Tue, 6 Jun 2006 20:36:52 +1000

>Hi All,
>I'll be working with the PHYTEC2294 board in preparation to using the
>Philips LPC2210 and LPC2102 in production.
>
>My project will allow the user to change the various IP settings
>(Address/Mask/gateway/DHCP) while the system is running. I.E. address
>and mask are updated (old addresses are deleted).
>Gateway changes cause the default route to be updated. DHCP can be
>turned off/on.
>
>I've found some older posts about this and tried them. Maybe I missed
>something but so far I've not found a single solution that covers all my
>needs. Is there such a solution or is there a 'right way' to achieve
>this?
>
>Also saw a post about using an incoming packet to learn the IP when the
>device is ping'ed for instance. This could be quite useful as well.
>Anyone have this in code already or can at least point me in the right
>direction of what to do?
>
>After these I'll need to do the same for NTP and DNS.
>
>Cheers			...Laurie:{)
>
>
>-- 
>Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
>and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
>
>
 




________________________________________________________________
Sent via the WebMail system at elsys-design.com


 
                   

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [ECOS] Dynamic IP/DHCP/Routing the 'right way'
  2006-06-06 12:38 [ECOS] Dynamic IP/DHCP/Routing the 'right way' FALL
@ 2006-06-06 21:26 ` Laurie Gellatly
  0 siblings, 0 replies; 10+ messages in thread
From: Laurie Gellatly @ 2006-06-06 21:26 UTC (permalink / raw)
  To: birahim.fall, ecos-discuss

Hi,
I should have been more specific. I'm already using the freeBSD stack. 

Thanks			...Laurie:{)

-----Original Message-----
From: ecos-discuss-owner@ecos.sourceware.org
[mailto:ecos-discuss-owner@ecos.sourceware.org] On Behalf Of FALL
Sent: Tuesday, 6 June 2006 10:37 PM
To: ecos-discuss@ecos.sourceware.org; laurie.gellatly@netic.com
Subject: Re: [ECOS] Dynamic IP/DHCP/Routing the 'right way'


I suppose you use LWIP stack. At the end of your mail, you write tat you
will do the same for DNS, I don't think that LWIP supports DNS. If you
want to change IP/gateway... while your programme is running, i think
the best way is to use ioctl functions. Most of  ioctl commands are not
supported by LWIP. I think you should chose freebsd stack for your
project. Of course LWIP is very light and simple to undestand but
freebsd is more complete. you have to make a choice:) FALL Birahim
Elsys-Design 
PACA

---------- Original Message ----------------------------------
From: "Laurie Gellatly" <laurie.gellatly@netic.com>
Reply-To: <laurie.gellatly@netic.com>
Date:  Tue, 6 Jun 2006 20:36:52 +1000

>Hi All,
>I'll be working with the PHYTEC2294 board in preparation to using the 
>Philips LPC2210 and LPC2102 in production.
>
>My project will allow the user to change the various IP settings
>(Address/Mask/gateway/DHCP) while the system is running. I.E. address 
>and mask are updated (old addresses are deleted). Gateway changes cause

>the default route to be updated. DHCP can be turned off/on.
>
>I've found some older posts about this and tried them. Maybe I missed 
>something but so far I've not found a single solution that covers all 
>my needs. Is there such a solution or is there a 'right way' to achieve

>this?
>
>Also saw a post about using an incoming packet to learn the IP when the

>device is ping'ed for instance. This could be quite useful as well. 
>Anyone have this in code already or can at least point me in the right 
>direction of what to do?
>
>After these I'll need to do the same for NTP and DNS.
>
>Cheers			...Laurie:{)
>
>
>--
>Before posting, please read the FAQ:
http://ecos.sourceware.org/fom/ecos
>and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
>
>
 




________________________________________________________________
Sent via the WebMail system at elsys-design.com


 
                   

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [ECOS] Dynamic IP/DHCP/Routing the 'right way'
  2006-07-29  1:52             ` Joe Porthouse
@ 2006-07-31  7:32               ` Laurie Gellatly
  0 siblings, 0 replies; 10+ messages in thread
From: Laurie Gellatly @ 2006-07-31  7:32 UTC (permalink / raw)
  To: jporthouse, ecos-discuss

[-- Attachment #1: Type: text/plain, Size: 3448 bytes --]

Hi Joe,
I've attached my network_support.c file.
You'll see references to MCB... (that's my master control block structure)
that holds the devices configuration like DHCP enabled or not.
MCB.ucXXX are unsigned chars holding the IPv4 address as 4 bytes.

It only assumes a single eth0 (and not eth1) though it would be easy to add
that back in.

HTH			...Laurie:{)

-----Original Message-----
From: ecos-discuss-owner@ecos.sourceware.org
[mailto:ecos-discuss-owner@ecos.sourceware.org]On Behalf Of Joe
Porthouse
Sent: Saturday, 29 July 2006 11:53 AM
To: laurie.gellatly@netic.com; ecos-discuss@ecos.sourceware.org
Subject: RE: [ECOS] Dynamic IP/DHCP/Routing the 'right way'


Laurie,
	See a copy, definitely.  Many thanks!!! :)

	I have been digging through eCos files attempting to get an
understanding of how things are working with the network, but it's kinda
like walking through an unfamiliar house with only a flashlight to show you
the way.  I have not been able to see the entire picture yet.

	I was originally looking at the DHCP code and saw during a renewal
it was shutting down the interface just before calling net_init() again.
Still having lots to do, I would rather use a solution that has worked for
someone else.

	BTW, grepping through the eCos packages I could not find StackInit,
IP_SetIP, or IP_SetMask.  Is there another package I need to install or are
these your functions?

Thanks,
Joe Porthouse
Toptech Systems, Inc.
Longwood, FL 32750
-----Original Message-----
From: Laurie Gellatly [mailto:laurie.gellatly@netic.com]
Sent: Friday, July 28, 2006 6:01 PM
To: jporthouse@toptech.com; ecos-discuss@ecos.sourceware.org
Subject: RE: [ECOS] Dynamic IP/DHCP/Routing the 'right way'

Hi Joe,
Taking Andrew's suggestion I rolled my own. Would you like to see a copy?

			...Laurie:{)

-----Original Message-----
From: Joe Porthouse [mailto:jporthouse@toptech.com]
Sent: Saturday, 29 July 2006 7:30 AM
To: ecos-discuss@ecos.sourceware.org; 'Laurie Gellatly'
Subject: RE: [ECOS] Dynamic IP/DHCP/Routing the 'right way'


Laurie,
Did you find a solution that worked?  I'm also dealing with this same issue.
Thanks,
Joe Porthouse
Toptech Systems, Inc.
Longwood, FL 32750

-----Original Message-----
From: ecos-discuss-owner@ecos.sourceware.org
[mailto:ecos-discuss-owner@ecos.sourceware.org] On Behalf Of Andrew Lunn
Sent: Tuesday, June 06, 2006 7:19 AM
To: Laurie Gellatly
Cc: ecos-discuss@ecos.sourceware.org
Subject: Re: [ECOS] Dynamic IP/DHCP/Routing the 'right way'

On Tue, Jun 06, 2006 at 09:09:29PM +1000, Laurie Gellatly wrote:
> Hi Andrew,
> Thanks for the swift response.
> SNTP - yes. Thanks for the tips there and with DNS, I'll look at those.
>
> init_net() was not sufficient. It left the old addresses active. I've
> combined StackInit and IP_SetIP, IP_SetMask to remove the old address
> and mask. Still think the routing is not being updated, but before I
> launched into debugging all that I wanted to ensure I wasn't
> re-inventing the wheel.

I think this is a new wheel, at least i've not seen a public available
wheel which does this.

cyg_route_reinit() might help with your routing problem.

     Andrew

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss






--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

[-- Attachment #2: network_support.c --]
[-- Type: application/octet-stream, Size: 10948 bytes --]

//==========================================================================
//
// Adapted from    network_support.c
//
//      Misc network support functions
//  $Id: network_support.c,v 1.7 2006/07/18 04:58:44 gellatly Exp $
//==========================================================================
// BOOTP support

#include <pkgconf/net.h>
#undef _KERNEL
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/errno.h>

#include <net/if.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <net/route.h>

#include <cyg/infra/diag.h>
#include <cyg/kernel/kapi.h>

#include <stdio.h>    // for 'sprintf()'

#include <bootp.h>
#include <network.h>
#include <arpa/inet.h>

#include <dhcp.h>

#include <pkgconf/ns_dns.h>
#include "mydev.h"

#define CYGHWR_NET_DRIVER_ETH0_BOOTP_SHOW 1
struct bootp eth0_bootp_data;
cyg_bool_t   eth0_up = false;
const char  *eth0_name = "eth0";

#define _string(s) #s
#define string(s) _string(s)

#ifndef CYGPKG_LIBC_STDIO
#define perror(s) diag_printf(#s ": %s\n", strerror(errno))
#endif

#ifdef CYGPKG_NET_NLOOP
#if 0 < CYGPKG_NET_NLOOP
//  
//   Initialize loopback interface  ----------   Added by sorin@netappi.com 
//
cyg_bool_t init_loopback_interface(int lo)
{
    struct sockaddr_in *addrp;
    struct ifreq ifr;
    int s;
    int one = 1;
    struct ecos_rtentry route;
    struct in_addr netmask, gateway;

    s = socket(AF_INET, SOCK_DGRAM, 0); 
    if (s < 0) {
        perror("socket");
        return false;
    }
    if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one))) {
        perror("setsockopt");
	close(s);
        return false;
    }

    addrp = (struct sockaddr_in *) &ifr.ifr_addr;
    memset(addrp, 0, sizeof(*addrp));
    addrp->sin_family = AF_INET;
    addrp->sin_len = sizeof(*addrp);
    addrp->sin_port = 0;
    // Make an address 127.0.<lo>.1 to manage multiple loopback ifs.
    // (There is normally only 1, so it's the standard 127.0.0.1)
    addrp->sin_addr.s_addr = htonl((0x100 * lo) + INADDR_LOOPBACK) ; 

#if CYGPKG_NET_NLOOP > 1
    // Init the one we were told to
    sprintf(ifr.ifr_name, "lo%d", lo);
#else
    strcpy(ifr.ifr_name, "lo0");
#endif    

    if (ioctl(s, SIOCSIFADDR, &ifr)) {
        perror("SIOCIFADDR");
        close(s);
        return false;
    }
    
#if 1 < CYGPKG_NET_NLOOP
    // We cheat to make different nets for multiple loopback devs
    addrp->sin_addr.s_addr = netmask.s_addr = htonl(IN_CLASSC_NET);
#else
    // 
    addrp->sin_addr.s_addr = netmask.s_addr = htonl(IN_CLASSA_NET);
#endif
    if (ioctl(s, SIOCSIFNETMASK, &ifr)) {
        perror("SIOCSIFNETMASK");
        return false;
    }
    ifr.ifr_flags = IFF_UP | IFF_BROADCAST | IFF_RUNNING;
    if (ioctl(s, SIOCSIFFLAGS, &ifr)) {
        perror("SIOCSIFFLAGS");
        close(s);
        return false;
    }

    gateway.s_addr = htonl(INADDR_LOOPBACK);  
    memset(&route, 0, sizeof(route));
    addrp->sin_family = AF_INET;
    addrp->sin_len = sizeof(*addrp);
    addrp->sin_port = 0;
    addrp->sin_addr.s_addr = htonl((0x100 * lo) + INADDR_LOOPBACK) & netmask.s_addr;
    memcpy(&route.rt_dst, addrp, sizeof(*addrp));
    addrp->sin_addr = netmask;
    memcpy(&route.rt_genmask, addrp, sizeof(*addrp));
    addrp->sin_addr = gateway;
    memcpy(&route.rt_gateway, addrp, sizeof(*addrp));
    
    route.rt_dev = ifr.ifr_name;
    route.rt_flags = RTF_UP|RTF_GATEWAY;
    route.rt_metric = 0;

    if (ioctl(s, SIOCADDRT, &route)) {
        diag_printf("Route - dst: %s", inet_ntoa(((struct sockaddr_in *)&route.rt_dst)->sin_addr));
        diag_printf(", mask: %s", inet_ntoa(((struct sockaddr_in *)&route.rt_genmask)->sin_addr));
        diag_printf(", gateway: %s\n", inet_ntoa(((struct sockaddr_in *)&route.rt_gateway)->sin_addr));
        if (errno != EEXIST) {
            perror("SIOCADDRT 3");
            close(s);
            return false;
        }
    }
    close(s);
    return true;
}
#endif
#endif


//
// Internal function which builds up a fake BOOTP database for
// an interface.
//

static unsigned char * add_tag(unsigned char *vp,
        unsigned char tag,
        void *val,
        int len) {
    int i;
    unsigned char *xp = (unsigned char *)val;
    *vp++ = tag;
    *vp++ = len;
    for (i = 0;  i < len;  i++) {
        *vp++ = *xp++;
    }
    return vp;
}

static void build_bootp_struct(struct bootp *bp,
                   const char * if_name,
                   unsigned char addrs_ip[],
                   unsigned char addrs_netmask[],
                   unsigned char addrs_gateway[],
                   unsigned char addrs_DNSsv1[],
                   unsigned char addrs_DNSsv2[],
                   unsigned char addrs_NTPsv1[],
                   unsigned char addrs_NTPsv2[]){
    int i, s;
    in_addr_t addr[2];
    unsigned char *vp,ucAddrBuf[4];
    unsigned char cookie[] = VM_RFC1048;
    struct ifreq ifr;

    bzero(bp, sizeof(struct bootp));
    bp->bp_op = BOOTREPLY;
    bp->bp_htype = HTYPE_ETHERNET;
    bp->bp_hlen = 6;

    // Query the hardware address
    for (i = 0;  i < bp->bp_hlen;  i++) {
        bp->bp_chaddr[i] = 0xFF;  // Unknown
    }
    s = socket(AF_INET, SOCK_DGRAM, 0);
    if (s >= 0) {
        strcpy(ifr.ifr_name, if_name);
        if (ioctl(s, SIOCGIFHWADDR, &ifr) >= 0) {
            bcopy(ifr.ifr_hwaddr.sa_data, bp->bp_chaddr, bp->bp_hlen);
        }
        close(s);
    }

    // Fill in the provided IP addresses
    memcpy(&bp->bp_ciaddr.s_addr,addrs_ip,4);
    memcpy(&bp->bp_yiaddr.s_addr,addrs_ip,4);
    memcpy(&bp->bp_siaddr.s_addr,addrs_DNSsv1,4);
    memcpy(&bp->bp_giaddr.s_addr,addrs_gateway,4);
    for(i=0;i<4;++i) ucAddrBuf[i]=addrs_ip[i] | (0xFF ^ addrs_netmask[i]); //Make  the broadcast addr
    vp = &bp->bp_vend[0];
    bcopy(&cookie, vp, sizeof(cookie));
    vp += sizeof(cookie);
    vp = add_tag(vp, TAG_SUBNET_MASK, addrs_netmask, sizeof(in_addr_t));
    vp = add_tag(vp, TAG_IP_BROADCAST, ucAddrBuf, sizeof(in_addr_t));
    vp = add_tag(vp, TAG_GATEWAY, addrs_gateway, sizeof(in_addr_t));
    i=0;
    if(*(long*)addrs_DNSsv1) memcpy(&addr[i++],addrs_DNSsv1, sizeof(in_addr_t));
    if(*(long*)addrs_DNSsv2) memcpy(&addr[i++],addrs_DNSsv2, sizeof(in_addr_t));
    if(i) vp = add_tag(vp, TAG_DOMAIN_SERVER, addr, (i==2)? sizeof(in_addr_t)+sizeof(in_addr_t):sizeof(in_addr_t));
    i=0;
    if(*(long*)addrs_NTPsv1) memcpy(&addr[i++],addrs_NTPsv1, sizeof(in_addr_t));
    if(*(long*)addrs_NTPsv2) memcpy(&addr[i++],addrs_NTPsv2, sizeof(in_addr_t));
    if(i) vp = add_tag(vp, TAG_NTP_SERVER, addr, (i==2)? sizeof(in_addr_t)+sizeof(in_addr_t):sizeof(in_addr_t));
    *vp = TAG_END;
}

void del_eth0( void ) {
  int s;
  struct ifreq ifr;
  
  s = socket(PF_INET, SOCK_DGRAM, 0);
  
  if (s < 0){
      diag_printf("socket: %d\n",s);
      return;
  }
  memset(&ifr,0,sizeof( struct ifreq ) );

  strcpy(ifr.ifr_name, "eth0");

   if( ioctl( s, SIOCGIFADDR, &ifr ) == -1 ){
      diag_printf("Impossible to obtain an IP address of '%s' because '%s'",ifr.ifr_name,strerror(errno));
   } else {
      if( ioctl( s, SIOCDIFADDR, &ifr ) != 0 ){
         diag_printf("Impossible to remove IP address '%s' because '%s'",ifr.ifr_name,strerror(errno));
      }
   }
  diag_printf("del_eth0 complete.\n");
  close(s);
}

//
// Initialize network interface[s] using BOOTP/DHCP
//
void init_all_network_interfaces(void) {
    static volatile int in_init_all_network_interfaces = 0;
#ifdef CYGOPT_NET_IPV6_ROUTING_THREAD
    int rs_wait = 40;
#endif

    cyg_scheduler_lock();  // Make this call idempotent
    while ( in_init_all_network_interfaces ) {
        // Another thread is doing this...
        cyg_scheduler_unlock();
        cyg_thread_delay( 10 );
        cyg_scheduler_lock();
    }
    in_init_all_network_interfaces = 1;
    cyg_scheduler_unlock();
    if(eth0_up && ((MCB.icIPUseDHCP == 3) || ! MCB.icIPUseDHCP)){ // DHCP is coming up or not running
       del_eth0();      // Delete the old static address first
    }
    // Deal with DHCP start/stop first then static addressing
    if(MCB.icIPUseDHCP == 3){          // Change in state of DHCP to UP
       // Perform a complete initialization, using BOOTP/DHCP
       eth0_up = true;
       eth0_dhcpstate = 0; // Says that initialization is external to dhcp
       if (!do_dhcp(eth0_name, &eth0_bootp_data, &eth0_dhcpstate, &eth0_lease)){
          diag_printf("BOOTP/DHCP failed on eth0\n");
          eth0_up = false;
       }
    }else if(MCB.icIPUseDHCP == 2){    // Change in state of DHCP to down
       if ( eth0_up )  {
          // eth0_dhcpstate = 0; // Says that initialization is external to dhcp
          do_dhcp_down_net(eth0_name, &eth0_bootp_data, &eth0_dhcpstate, &eth0_lease);
       }
       eth0_up = true;
    }
    if(!(MCB.icIPUseDHCP & 1)){ // DHCP is down so set static address
       //Build the bootp data so gateway & mask tags are set correctly
       build_bootp_struct(&eth0_bootp_data,
          eth0_name,
          MCB.ucSNMPIPV4Addr,
          MCB.ucSNMPIPV4Mask,
          MCB.ucSNMPIPV4Gate,
          MCB.ucIPV4DNSServ1Addr,
          MCB.ucIPV4DNSServ2Addr,
          MCB.ucIPV4NTPServ1Addr,
          MCB.ucIPV4NTPServ2Addr);
       eth0_up = true;
    }
#ifdef CYGHWR_NET_DRIVER_ETH0_BOOTP_SHOW
    //Show what HDCP or static addresses have been setup
    show_bootp(eth0_name, &eth0_bootp_data);
#endif
    if (eth0_up) {
        if (!init_net(eth0_name, &eth0_bootp_data)) {
            diag_printf("Network initialization failed for eth0\n");
            eth0_up = false;
        }
#ifdef CYGHWR_NET_DRIVER_ETH0_IPV6_PREFIX
        if (!init_net_IPv6(eth0_name, &eth0_bootp_data, 
                           string(CYGHWR_NET_DRIVER_ETH0_IPV6_PREFIX))) {
            diag_printf("Static IPv6 network initialization failed for eth0\n");
            eth0_up = false;  // ???
        }
#endif
    }

    if(MCB.icIPUseDHCP == 3) dhcp_start_dhcp_mgt_thread();

#ifdef CYGOPT_NET_IPV6_ROUTING_THREAD
    ipv6_start_routing_thread();

    // Wait for router solicit process to happen.
    while (rs_wait-- && !cyg_net_get_ipv6_advrouter(NULL)) {
      cyg_thread_delay(10);
    }
    if (rs_wait == 0 ) {
      diag_printf("No router solicit received\n");
    } else {
      // Give Duplicate Address Detection time to work
      cyg_thread_delay(200);
    }
#endif
#ifdef CYGDAT_NS_DNS_DOMAINNAME_NAME
    {
      const char buf[] = "mycompany.com";
      int len = strlen(buf);
      
      setdomainname(buf,len);
    }
#endif
    // Open the monitor to other threads.
    in_init_all_network_interfaces = 0;
}

// EOF network_support.c


[-- Attachment #3: Type: text/plain, Size: 148 bytes --]

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [ECOS] Dynamic IP/DHCP/Routing the 'right way'
  2006-07-28 21:59           ` Laurie Gellatly
@ 2006-07-29  1:52             ` Joe Porthouse
  2006-07-31  7:32               ` Laurie Gellatly
  0 siblings, 1 reply; 10+ messages in thread
From: Joe Porthouse @ 2006-07-29  1:52 UTC (permalink / raw)
  To: laurie.gellatly, ecos-discuss

Laurie,
	See a copy, definitely.  Many thanks!!! :)

	I have been digging through eCos files attempting to get an
understanding of how things are working with the network, but it's kinda
like walking through an unfamiliar house with only a flashlight to show you
the way.  I have not been able to see the entire picture yet.

	I was originally looking at the DHCP code and saw during a renewal
it was shutting down the interface just before calling net_init() again.
Still having lots to do, I would rather use a solution that has worked for
someone else.

	BTW, grepping through the eCos packages I could not find StackInit,
IP_SetIP, or IP_SetMask.  Is there another package I need to install or are
these your functions?

Thanks,
Joe Porthouse
Toptech Systems, Inc.
Longwood, FL 32750
-----Original Message-----
From: Laurie Gellatly [mailto:laurie.gellatly@netic.com] 
Sent: Friday, July 28, 2006 6:01 PM
To: jporthouse@toptech.com; ecos-discuss@ecos.sourceware.org
Subject: RE: [ECOS] Dynamic IP/DHCP/Routing the 'right way'

Hi Joe,
Taking Andrew's suggestion I rolled my own. Would you like to see a copy?

			...Laurie:{)

-----Original Message-----
From: Joe Porthouse [mailto:jporthouse@toptech.com]
Sent: Saturday, 29 July 2006 7:30 AM
To: ecos-discuss@ecos.sourceware.org; 'Laurie Gellatly'
Subject: RE: [ECOS] Dynamic IP/DHCP/Routing the 'right way'


Laurie,
Did you find a solution that worked?  I'm also dealing with this same issue.
Thanks,
Joe Porthouse
Toptech Systems, Inc.
Longwood, FL 32750

-----Original Message-----
From: ecos-discuss-owner@ecos.sourceware.org
[mailto:ecos-discuss-owner@ecos.sourceware.org] On Behalf Of Andrew Lunn
Sent: Tuesday, June 06, 2006 7:19 AM
To: Laurie Gellatly
Cc: ecos-discuss@ecos.sourceware.org
Subject: Re: [ECOS] Dynamic IP/DHCP/Routing the 'right way'

On Tue, Jun 06, 2006 at 09:09:29PM +1000, Laurie Gellatly wrote:
> Hi Andrew,
> Thanks for the swift response.
> SNTP - yes. Thanks for the tips there and with DNS, I'll look at those.
>
> init_net() was not sufficient. It left the old addresses active. I've
> combined StackInit and IP_SetIP, IP_SetMask to remove the old address
> and mask. Still think the routing is not being updated, but before I
> launched into debugging all that I wanted to ensure I wasn't
> re-inventing the wheel.

I think this is a new wheel, at least i've not seen a public available
wheel which does this.

cyg_route_reinit() might help with your routing problem.

     Andrew

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss






-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [ECOS] Dynamic IP/DHCP/Routing the 'right way'
  2006-07-28 21:30         ` Joe Porthouse
@ 2006-07-28 21:59           ` Laurie Gellatly
  2006-07-29  1:52             ` Joe Porthouse
  0 siblings, 1 reply; 10+ messages in thread
From: Laurie Gellatly @ 2006-07-28 21:59 UTC (permalink / raw)
  To: jporthouse, ecos-discuss

Hi Joe,
Taking Andrew's suggestion I rolled my own. Would you like to see a copy?

			...Laurie:{)

-----Original Message-----
From: Joe Porthouse [mailto:jporthouse@toptech.com]
Sent: Saturday, 29 July 2006 7:30 AM
To: ecos-discuss@ecos.sourceware.org; 'Laurie Gellatly'
Subject: RE: [ECOS] Dynamic IP/DHCP/Routing the 'right way'


Laurie,
Did you find a solution that worked?  I'm also dealing with this same issue.
Thanks,
Joe Porthouse
Toptech Systems, Inc.
Longwood, FL 32750

-----Original Message-----
From: ecos-discuss-owner@ecos.sourceware.org
[mailto:ecos-discuss-owner@ecos.sourceware.org] On Behalf Of Andrew Lunn
Sent: Tuesday, June 06, 2006 7:19 AM
To: Laurie Gellatly
Cc: ecos-discuss@ecos.sourceware.org
Subject: Re: [ECOS] Dynamic IP/DHCP/Routing the 'right way'

On Tue, Jun 06, 2006 at 09:09:29PM +1000, Laurie Gellatly wrote:
> Hi Andrew,
> Thanks for the swift response.
> SNTP - yes. Thanks for the tips there and with DNS, I'll look at those.
>
> init_net() was not sufficient. It left the old addresses active. I've
> combined StackInit and IP_SetIP, IP_SetMask to remove the old address
> and mask. Still think the routing is not being updated, but before I
> launched into debugging all that I wanted to ensure I wasn't
> re-inventing the wheel.

I think this is a new wheel, at least i've not seen a public available
wheel which does this.

cyg_route_reinit() might help with your routing problem.

     Andrew

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss




-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [ECOS] Dynamic IP/DHCP/Routing the 'right way'
  2006-06-06 11:19       ` Andrew Lunn
@ 2006-07-28 21:30         ` Joe Porthouse
  2006-07-28 21:59           ` Laurie Gellatly
  0 siblings, 1 reply; 10+ messages in thread
From: Joe Porthouse @ 2006-07-28 21:30 UTC (permalink / raw)
  To: ecos-discuss, 'Laurie Gellatly'

Laurie,
Did you find a solution that worked?  I'm also dealing with this same issue.
Thanks,
Joe Porthouse
Toptech Systems, Inc.
Longwood, FL 32750

-----Original Message-----
From: ecos-discuss-owner@ecos.sourceware.org
[mailto:ecos-discuss-owner@ecos.sourceware.org] On Behalf Of Andrew Lunn
Sent: Tuesday, June 06, 2006 7:19 AM
To: Laurie Gellatly
Cc: ecos-discuss@ecos.sourceware.org
Subject: Re: [ECOS] Dynamic IP/DHCP/Routing the 'right way'

On Tue, Jun 06, 2006 at 09:09:29PM +1000, Laurie Gellatly wrote:
> Hi Andrew,
> Thanks for the swift response.
> SNTP - yes. Thanks for the tips there and with DNS, I'll look at those.
> 
> init_net() was not sufficient. It left the old addresses active. I've
> combined StackInit and IP_SetIP, IP_SetMask to remove the old address
> and mask. Still think the routing is not being updated, but before I
> launched into debugging all that I wanted to ensure I wasn't
> re-inventing the wheel.

I think this is a new wheel, at least i've not seen a public available
wheel which does this.

cyg_route_reinit() might help with your routing problem.

     Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss




-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [ECOS] Dynamic IP/DHCP/Routing the 'right way'
  2006-06-06 11:09     ` Laurie Gellatly
@ 2006-06-06 11:19       ` Andrew Lunn
  2006-07-28 21:30         ` Joe Porthouse
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Lunn @ 2006-06-06 11:19 UTC (permalink / raw)
  To: Laurie Gellatly; +Cc: ecos-discuss

On Tue, Jun 06, 2006 at 09:09:29PM +1000, Laurie Gellatly wrote:
> Hi Andrew,
> Thanks for the swift response.
> SNTP - yes. Thanks for the tips there and with DNS, I'll look at those.
> 
> init_net() was not sufficient. It left the old addresses active. I've
> combined StackInit and IP_SetIP, IP_SetMask to remove the old address
> and mask. Still think the routing is not being updated, but before I
> launched into debugging all that I wanted to ensure I wasn't
> re-inventing the wheel.

I think this is a new wheel, at least i've not seen a public available
wheel which does this.

cyg_route_reinit() might help with your routing problem.

     Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [ECOS] Dynamic IP/DHCP/Routing the 'right way'
  2006-06-06 10:56   ` Andrew Lunn
@ 2006-06-06 11:09     ` Laurie Gellatly
  2006-06-06 11:19       ` Andrew Lunn
  0 siblings, 1 reply; 10+ messages in thread
From: Laurie Gellatly @ 2006-06-06 11:09 UTC (permalink / raw)
  To: 'Andrew Lunn'; +Cc: ecos-discuss

Hi Andrew,
Thanks for the swift response.
SNTP - yes. Thanks for the tips there and with DNS, I'll look at those.

init_net() was not sufficient. It left the old addresses active. I've
combined StackInit and IP_SetIP, IP_SetMask to remove the old address
and mask. Still think the routing is not being updated, but before I
launched into debugging all that I wanted to ensure I wasn't
re-inventing the wheel.

Thanks			...Laurie:{)

-----Original Message-----
From: Andrew Lunn [mailto:andrew@lunn.ch] 
Sent: Tuesday, 6 June 2006 8:56 PM
To: Laurie Gellatly
Cc: ecos-discuss@ecos.sourceware.org
Subject: Re: [ECOS] Dynamic IP/DHCP/Routing the 'right way'


On Tue, Jun 06, 2006 at 08:36:52PM +1000, Laurie Gellatly wrote:
> Hi All,
> I'll be working with the PHYTEC2294 board in preparation to using the 
> Philips LPC2210 and LPC2102 in production.
> 
> My project will allow the user to change the various IP settings
> (Address/Mask/gateway/DHCP) while the system is running. I.E. address 
> and mask are updated (old addresses are deleted). Gateway changes 
> cause the default route to be updated. DHCP can be turned off/on.
> 
> I've found some older posts about this and tried them. Maybe I missed 
> something but so far I've not found a single solution that covers all 
> my needs. Is there such a solution or is there a 'right way' to 
> achieve this?

You might need to write your own dhcp management thread which calls the
dhcp state machine as needed, or calls the init_net() function with your
static addressing information.

> After these I'll need to do the same for NTP and DNS.

By NTP you mean SNTP? You should be able to call
cyg_sntp_set_servers() at anytime to tell it about a change of unicast
SNTP server.

With DNS similarly cyg_dns_res_start() can be called at any time to
indicate a new server. 

         Andrew


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [ECOS] Dynamic IP/DHCP/Routing the 'right way'
  2006-06-06 10:37 ` [ECOS] Dynamic IP/DHCP/Routing the 'right way' Laurie Gellatly
@ 2006-06-06 10:56   ` Andrew Lunn
  2006-06-06 11:09     ` Laurie Gellatly
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Lunn @ 2006-06-06 10:56 UTC (permalink / raw)
  To: Laurie Gellatly; +Cc: ecos-discuss

On Tue, Jun 06, 2006 at 08:36:52PM +1000, Laurie Gellatly wrote:
> Hi All,
> I'll be working with the PHYTEC2294 board in preparation to using the
> Philips LPC2210 and LPC2102 in production.
> 
> My project will allow the user to change the various IP settings
> (Address/Mask/gateway/DHCP) while the system is running. I.E. address
> and mask are updated (old addresses are deleted).
> Gateway changes cause the default route to be updated. DHCP can be
> turned off/on.
> 
> I've found some older posts about this and tried them. Maybe I missed
> something but so far I've not found a single solution that covers all my
> needs. Is there such a solution or is there a 'right way' to achieve
> this?

You might need to write your own dhcp management thread which calls
the dhcp state machine as needed, or calls the init_net() function
with your static addressing information.

> After these I'll need to do the same for NTP and DNS.

By NTP you mean SNTP? You should be able to call
cyg_sntp_set_servers() at anytime to tell it about a change of unicast
SNTP server.

With DNS similarly cyg_dns_res_start() can be called at any time to
indicate a new server. 

         Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [ECOS] Dynamic IP/DHCP/Routing the 'right way'
  2006-06-05 17:08 [ECOS] Re: LPC2214 Porting issue: Garbage data on Serial Console Tom B
@ 2006-06-06 10:37 ` Laurie Gellatly
  2006-06-06 10:56   ` Andrew Lunn
  0 siblings, 1 reply; 10+ messages in thread
From: Laurie Gellatly @ 2006-06-06 10:37 UTC (permalink / raw)
  To: ecos-discuss

Hi All,
I'll be working with the PHYTEC2294 board in preparation to using the
Philips LPC2210 and LPC2102 in production.

My project will allow the user to change the various IP settings
(Address/Mask/gateway/DHCP) while the system is running. I.E. address
and mask are updated (old addresses are deleted).
Gateway changes cause the default route to be updated. DHCP can be
turned off/on.

I've found some older posts about this and tried them. Maybe I missed
something but so far I've not found a single solution that covers all my
needs. Is there such a solution or is there a 'right way' to achieve
this?

Also saw a post about using an incoming packet to learn the IP when the
device is ping'ed for instance. This could be quite useful as well.
Anyone have this in code already or can at least point me in the right
direction of what to do?

After these I'll need to do the same for NTP and DNS.

Cheers			...Laurie:{)


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2006-07-31  7:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-06 12:38 [ECOS] Dynamic IP/DHCP/Routing the 'right way' FALL
2006-06-06 21:26 ` Laurie Gellatly
  -- strict thread matches above, loose matches on Subject: below --
2006-06-05 17:08 [ECOS] Re: LPC2214 Porting issue: Garbage data on Serial Console Tom B
2006-06-06 10:37 ` [ECOS] Dynamic IP/DHCP/Routing the 'right way' Laurie Gellatly
2006-06-06 10:56   ` Andrew Lunn
2006-06-06 11:09     ` Laurie Gellatly
2006-06-06 11:19       ` Andrew Lunn
2006-07-28 21:30         ` Joe Porthouse
2006-07-28 21:59           ` Laurie Gellatly
2006-07-29  1:52             ` Joe Porthouse
2006-07-31  7:32               ` Laurie Gellatly

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).