Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - usr/include/net/if.h ifprefix changes from 6.3.2 to 6.4.1: (6 Items)
   
usr/include/net/if.h ifprefix changes from 6.3.2 to 6.4.1  
Hello,

I have a piece of software that used to cycle through the interface list in the ifnet struct in if.h when compiled 
against the older 6.3.2 release of QNX.  Where has this functionality been moved in 6.4.1 or has it been removed all 
together?  How can one iterate through the list of interfaces in io-pkt?

Thanks,
Liam
Re: usr/include/net/if.h ifprefix changes from 6.3.2 to 6.4.1  
On Tue, Aug 18, 2009 at 10:08:02AM -0400, Liam Howlett wrote:
> Hello,
> 
> I have a piece of software that used to cycle through the interface list in the ifnet struct in if.h when compiled 
against the older 6.3.2 release of QNX.  Where has this functionality been moved in 6.4.1 or has it been removed all 
together?  How can one iterate through the list of interfaces in io-pkt?

The suggested way is to use getifaddrs() / freeifaddrs().

Regards,

-seanb
Re: usr/include/net/if.h ifprefix changes from 6.3.2 to 6.4.1  
The addrs don't have enough information to replace the structure we are missing.

How can I rebuild the information in this struct with the current stack?

struct ifprefix {
        struct  sockaddr *ifpr_prefix;  /* prefix of interface */
        struct  ifnet *ifpr_ifp;        /* back-pointer to interface */
        struct ifprefix *ifpr_next;
        unsigned char   ifpr_plen;              /* prefix length in bits */
        unsigned char   ifpr_type;              /* protocol dependent prefix type */
};
Re: usr/include/net/if.h ifprefix changes from 6.3.2 to 6.4.1  
On Tue, Aug 18, 2009 at 05:06:02PM -0400, Liam Howlett wrote:
> The addrs don't have enough information to replace the structure we are missing.
> 
> How can I rebuild the information in this struct with the current stack?
> 
> struct ifprefix {
>         struct  sockaddr *ifpr_prefix;  /* prefix of interface */
>         struct  ifnet *ifpr_ifp;        /* back-pointer to interface */
>         struct ifprefix *ifpr_next;
>         unsigned char   ifpr_plen;              /* prefix length in bits */
>         unsigned char   ifpr_type;              /* protocol dependent prefix type */
> };
> 

The list of interfaces and addrs can be obtained with
getifaddrs().  A particular IPv6 addr's prefixlen can be
obtained with the SIOCGIFNETMASK_IN6 ioctl.  Check out the
ifconfig utility for an example.

Regards,

-seanb
Re: usr/include/net/if.h ifprefix changes from 6.3.2 to 6.4.1  
So in ifconfig, the struct that's used is an in6_ifreq.  How do I get from an ifnet to an in6_ifreq?  Or how do I get 
from the sockaddr returned from the getifaddrs to an in6_ifreq?

Basically I have to match up an ifnet to a prefix, but I don't know how to get the information from an ifnet or from a 
sockaddr directly or indirectly.
Re: usr/include/net/if.h ifprefix changes from 6.3.2 to 6.4.1  
On Thu, Aug 20, 2009 at 05:48:14PM -0400, Liam Howlett wrote:
> So in ifconfig, the struct that's used is an in6_ifreq.  How do I get from an ifnet to an in6_ifreq?  Or how do I get 
from the sockaddr returned from the getifaddrs to an in6_ifreq?
> 
> Basically I have to match up an ifnet to a prefix, but I don't know how to get the information from an ifnet or from a
 sockaddr directly or indirectly.

prefixes are associated with addresses which in turn are
associated with interfaces (struct ifnet).  An interface
may have more than one address and therefore more than
one prefix.  As per the ifconfig example:

memset(&ifr6, 0, sizeof(ifr6));
strlcpy(ifr6.ifr_name, name, sizeof(ifr6.ifr_name));
ifr6.ifr_addr = creq->ifr_addr;
if (ioctl(s, SIOCGIFNETMASK_IN6, &ifr6) == -1) {
 ...
 ...
}


You put the interface name in ifr6.ifr_name and the
address you want the prefix for in ifr6.ifr_addr.
The SIOCGIFNETMASK_IN6 ioctl will return out the
prefix for that address on that particular interface.

-seanb