This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Could not follow the Route initialisation code


Hi,

I was debugging the function init_net() present in 
boot_support.c

I am unable to follow the piece of code given below

strcpy(ifr.ifr_name, intf);
     if (ioctl(s, strcpy(ifr.ifr_name, intf);
     if (ioctl(s, SIOCSIFADDR, &ifr)) {
         perror("SIOCIFADDR");
         return false;
     }

     if (get_bootp_option(bp, TAG_SUBNET_MASK, &addrp->sin_addr)) 
{
         netmask = addrp->sin_addr;
         if (ioctl(s, SIOCSIFNETMASK, &ifr)) {
             perror("SIOCSIFNETMASK");
             return false;
         }
         // Must do this again so that [sub]netmask (and so 
default route)
         // is taken notice of.
         addrp->sin_addr = bp->bp_yiaddr;  // The address BOOTP 
gave us
         if (ioctl(s, SIOCSIFADDR, &ifr)) {
             perror("SIOCIFADDR 2");
             return false;
         }
     }

     if (get_bootp_option(bp, TAG_IP_BROADCAST, &addrp->sin_addr)) 
{
         if (ioctl(s, SIOCSIFBRDADDR, &ifr)) {
             perror("SIOCSIFBRDADDR");
             return false;
         }
         // Do not re-set the IFADDR after this; doing *that* 
resets the
         // BRDADDR to the default!
     }

     ifr.ifr_flags = IFF_UP | IFF_BROADCAST | IFF_RUNNING;
     if (ioctl(s, SIOCSIFFLAGS, &ifr)) {
         perror("SIOCSIFFLAGS");
         return false;, &ifr)) {
         perror("SIOCIFADDR");
         return false;
     }

     if (get_bootp_option(bp, TAG_SUBNET_MASK, &addrp->sin_addr)) 
{
         netmask = addrp->sin_addr;
         if (ioctl(s, SIOCSIFNETMASK, &ifr)) {
             perror("SIOCSIFNETMASK");
             return false;
         }
         // Must do this again so that [sub]netmask (and so 
default route)
         // is taken notice of.
         addrp->sin_addr = bp->bp_yiaddr;  // The address BOOTP 
gave us
         if (ioctl(s, SIOCSIFADDR, &ifr)) {
             perror("SIOCIFADDR 2");
             return false;
         }
     }

     if (get_bootp_option(bp, TAG_IP_BROADCAST, &addrp->sin_addr)) 
{
         if (ioctl(s, SIOCSIFBRDADDR, &ifr)) {
             perror("SIOCSIFBRDADDR");
             return false;
         }
         // Do not re-set the IFADDR after this; doing *that* 
resets the
         // BRDADDR to the default!
     }

     ifr.ifr_flags = IFF_UP | IFF_BROADCAST | IFF_RUNNING;
     if (ioctl(s, SIOCSIFFLAGS, &ifr)) {
         perror("SIOCSIFFLAGS");
         return false;

Why two ioctl's function are called for only one command
SIOCSIFADDR it appears to be setting the IP address again. Kindly 
help me clarify what this function does

Regards,

Kaustubh




_________________________________________________________
Click below to visit monsterindia.com and review jobs in India or 
Abroad
http://monsterindia.rediff.com/jobs


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]