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]

Re: Can't get socket's IP address w/ new stack?


On Mon, Aug 18, 2003 at 05:25:24PM +0200, Andrew Lunn wrote:

I think the problem is in the sequence of ioctl() calls I'm
using to configure the stack. The SIOCSxxxxx ioctl() seem to
have odd side-effects, and you have to do them in a certain
sequence (and do some of them more than once?).  The magic
sequence must have changed.  I never initialize the "lo"
interface, since I don't use it -- perhaps that's messing
things up.

> > > What happens if you call _show_all_interfaces() (defined in 
> > > net/common/current/src/ifaddrs.c)?
> > 
> >   0x003dfd94 - eth0 - 
> 
> That fact it prints nothing is interesting. That means its not an IPv4
> (or IPv6 if you have it configured) address that the interface has. It
> would be interesting to print ifp->ifa_addr->sa_family and see what
> sort of address it is.

I'm pretty sure it's empty.  Fires up gdb...

The first "eth0" interface record looks like this -- the
ia_addr struct is empty (all 0s). 

[Printed from a breakpoint in in.c:238 where the ioctl() code
loops through the interfaces.  It uses the first one if finds,
unless a subsequent one matches the IP address specified in the
request.]

(gdb) print/x *iap
$15 = {
  ia_ifa = {
    ifa_addr = 0x128238, 
    ifa_dstaddr = 0x128248, 
    ifa_netmask = 0x128258, 
    if_data = {
      ifi_type = 0x0, 
      ifi_physical = 0x0, 
      ifi_addrlen = 0x0, 
      ifi_hdrlen = 0x0, 
      ifi_recvquota = 0x0, 
      ifi_xmitquota = 0x0, 
      ifi_mtu = 0x0, 
      ifi_metric = 0x0, 
      ifi_baudrate = 0x0, 
      ifi_ipackets = 0x0, 
      ifi_ierrors = 0x0, 
      ifi_opackets = 0x0, 
      ifi_oerrors = 0x0, 
      ifi_collisions = 0x0, 
      ifi_ibytes = 0x0, 
      ifi_obytes = 0x0, 
      ifi_imcasts = 0x0, 
      ifi_omcasts = 0x0, 
      ifi_iqdrops = 0x0, 
      ifi_noproto = 0x0, 
      ifi_hwassist = 0x0, 
      ifi_unused = 0x0, 
      ifi_lastchange = {
        tv_sec = 0x0, 
        tv_usec = 0x0
      }
    }, 
    ifa_ifp = 0x6d8fc, 
    ifa_link = {
      tqe_next = 0x1280c0, 
      tqe_prev = 0x1391a0
    }, 
    ifa_rtrequest = 0x0, 
    ifa_flags = 0x0, 
    ifa_refcnt = 0x0, 
    ifa_metric = 0x0, 
    ifa_claim_addr = 0x0
  }, 
  ia_net = 0x0, 
  ia_netmask = 0x0, 
  ia_subnet = 0x0, 
  ia_subnetmask = 0xff000000, 
  ia_netbroadcast = {
    s_addr = 0x0
  }, 
  ia_link = {
    tqe_next = 0x1280c0, 
    tqe_prev = 0x38fd00
  }, 
  ia_addr = {
    sin_len = 0x0, 
    sin_family = 0x0, 
    sin_port = 0x0, 
    sin_addr = {
      s_addr = 0x0
    }, 
    sin_zero = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
  }, 
  ia_dstaddr = {
    sin_len = 0x10, 
    sin_family = 0x2, 
    sin_port = 0x0, 
    sin_addr = {
      s_addr = 0xaffffff
    }, 
    sin_zero = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
  }, 
  ia_sockmask = {
    sin_len = 0x8, 
    sin_family = 0x0, 
    sin_port = 0x0, 
    sin_addr = {
      s_addr = 0xff000000
    }, 
    sin_zero = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
  }
}


The second one has everything filled in:


(gdb) print/x *iap
$16 = {
  ia_ifa = {
    ifa_addr = 0x128158, 
    ifa_dstaddr = 0x128168, 
    ifa_netmask = 0x128178, 
    if_data = {
      ifi_type = 0x0, 
      ifi_physical = 0x0, 
      ifi_addrlen = 0x0, 
      ifi_hdrlen = 0x0, 
      ifi_recvquota = 0x0, 
      ifi_xmitquota = 0x0, 
      ifi_mtu = 0x0, 
      ifi_metric = 0x0, 
      ifi_baudrate = 0x0, 
      ifi_ipackets = 0xb0, 
      ifi_ierrors = 0x0, 
      ifi_opackets = 0xa8, 
      ifi_oerrors = 0x0, 
      ifi_collisions = 0x0, 
      ifi_ibytes = 0x2c67, 
      ifi_obytes = 0x85af, 
      ifi_imcasts = 0x0, 
      ifi_omcasts = 0x0, 
      ifi_iqdrops = 0x0, 
      ifi_noproto = 0x0, 
      ifi_hwassist = 0x0, 
      ifi_unused = 0x0, 
      ifi_lastchange = {
        tv_sec = 0x0, 
        tv_usec = 0x0
      }
    }, 
    ifa_ifp = 0x6d8fc, 
    ifa_link = {
      tqe_next = 0x0, 
      tqe_prev = 0x128200
    }, 
    ifa_rtrequest = 0x4a744, 
    ifa_flags = 0x101, 
    ifa_refcnt = 0x4, 
    ifa_metric = 0x0, 
    ifa_claim_addr = 0x0
  }, 
  ia_net = 0xa000000, 
  ia_netmask = 0xff000000, 
  ia_subnet = 0xa000000, 
  ia_subnetmask = 0xff000000, 
  ia_netbroadcast = {
    s_addr = 0xaffffff
  }, 
  ia_link = {
    tqe_next = 0x0, 
    tqe_prev = 0x128230
  }, 
  ia_addr = {
    sin_len = 0x10, 
    sin_family = 0x2, 
    sin_port = 0x0, 
    sin_addr = {
      s_addr = 0xa000007
    }, 
    sin_zero = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
  }, 
  ia_dstaddr = {
    sin_len = 0x10, 
    sin_family = 0x2, 
    sin_port = 0x0, 
    sin_addr = {
      s_addr = 0xaffffff
    }, 
    sin_zero = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
  }, 
  ia_sockmask = {
    sin_len = 0x5, 
    sin_family = 0x0, 
    sin_port = 0x0, 
    sin_addr = {
      s_addr = 0xff000000
    }, 
    sin_zero = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
  }
}


-- 
Grant Edwards
grante@visi.com

-- 
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]