[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: Network configuration
From:       Denis Vlasenko <vda.linux () googlemail ! com>
Date:       2007-06-29 16:31:28
Message-ID: 200706291831.28523.vda.linux () googlemail ! com
[Download RAW message or body]

On Wednesday 27 June 2007 20:53, Jason Curl wrote:
> Hello,
> 
> Besides the documentation in the busybox tarball (1.5.0 is what I'm 
> currently using), where can I find an overview of how busybox's zcip, 
> udhcp and mdev work? Even better would be examples. The 
> scripts/command-line info/source code all seem a little terse.

I would just do some experiments and use google.

> I need to connect to a control device that can be connected directly to 
> my box or over a DHCP controlled network. I'd like to startup and have 
> an IP address as soon as possible. The other device appears to use ZCIP 
> from Windows CE.
> 
> Do I need to use both tools (udhcpc, zcip), or will zcip manage 
> everything? How are other people using zcip/udhcpc in their embedded 
> applications?

Usage: zcip [OPTIONS] ifname script

Manage a ZeroConf IPv4 link-local address

Options:
        -f              Foreground mode
        -q              Quit after address (no daemon)
        -r 169.254.x.x  Request this address first
        -v              Verbose

Apparently zcip invents some random IP and then runs "script"
Experimentation (or reading the code) will tell you that script
is started with one param ("init", "config", etc) and two env vars -
"interface" and "ip".

It's expected that script will run ip (or ifconfig) and will assign this
IP to the interface.

Obvously it's enough if you sit on the same net and want to connect to the device.

Otherwise you need to run udhcpc. It works similarly (does DHCP protoclo thing
and runs your script).

You can have both running. Having two IP addresses on one interface is not a crime.

> Is mdev capable of notifying on when a cable is connected/disconnected 
> from ethernet that can then be used also to control the network 
> interface? I'm using the e100.o driver in kernel 2.6.21.1 and it prints 
> stuff on the console when the link status changes, so at least the 
> driver itself knows.

Sorry, I am not using mdev.

> How does zcip obtain an IP address? Is it based off the MAC or something 
> similar, so it's pretty much the same for each device, or is it trying 
> to be as random as possible?

        // start with some stable ip address, either a function of
        // the hardware address or else the last address we used.
        // NOTE: the sequence of addresses we try changes only
        // depending on when we detect conflicts.
        // (SVID 3 bogon: who says that "short" is always 16 bits?)
        seed48( (unsigned short*)&ifr.ifr_hwaddr.sa_data );
        if (ip.s_addr == 0)
                pick(&ip);

> And my device doesn't have a writable partition to save info across 
> powercycles (I can't guarantee how the system shuts down and I'm just 
> using ext2fs, hence I make it readonly).

For zcip / udhcpc, you don't need to save anything.
--
vda
_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic