netdev
[Top] [All Lists]

setting ip address from within driver

To: <netdev@xxxxxxxxxxx>
Subject: setting ip address from within driver
From: "Bjoern A. Zeeb" <bzeeb+netdev@xxxxxxxxxxxx>
Date: Thu, 30 Aug 2001 12:00:49 +0200 (CEST)
Sender: owner-netdev@xxxxxxxxxxx
Hi,

I am currently having a look at 'cisco Serial Line Encapsulation'.
They have a feature that enables one end of a pointopoint connection
to come up without IP address and get it from the remote end:

--- snipp ---
...
The serial line model supported by SLARP assumes that each serial line is
a separate IP subnet, and that one end of the line is host number 1, while
the other end is host number 2. The SLARP address resolution protocol allows
system A to request that system B tell system A system B's IP address,
along with the IP netmask to be used on the network. It does this by sending
a SLARP address resolution request packet, to which system B responds with a
SLARP address resolution reply packet. System A then attempts to determine its
own IP address based on the address of system B. If the host portion of system
B's address is 1, system A will use 2 for the host portion of its own IP
address. Conversely, if system B's IP host number is 2, system A will use IP
host number 1. If system B replies with any IP host number other than 1 or 2,
system A assumes that system B is unable to provide it with an address via
SLARP.
...
--- snipp ---

It is no problem to check all that but is it also possible to set ip
address from within driver without problems ?

Would setting ifa_list->* be some kind of right approach ?
--- some kind of this ---
...
/* take primary(first) address of interface */
struct in_ifaddr *ifa = in_dev->ifa_list;
if (ifa != NULL) {
        /*
         * according to
         * ip addr add 10.1.2.206 peer 10.1.2.205/30 dev ifname
         * set
         * ifa->ifa_local to local address (binary, net byte order)
         * ifa->ifa_address to remote addr (  --    ""     --     )
         * ifa->ifa_mask to 255.255.255.252
         * ifa->ifa_prefixlen to 30
         * ifa->ifa_label to ifname
         *
         * how to explicitly state pointopoint ? needed ?
         * do I also need to set scope ?
         * what did I make oops now ?
         */
}
...
--- end ---

-- 
Bjoern A. Zeeb                          bzeeb at Zabbadoz dot NeT
56 69 73 69 74                          http://www.zabbadoz.net/


<Prev in Thread] Current Thread [Next in Thread>