Reply by Steve November 3, 20112011-11-03
Thanks Scott.

Steve

--- In r..., Scott Henion wrote:
>
> On 11/2/2011 12:53 PM, Steve wrote:
> > For finding the ipaddress, there is the simple function gethostid(), but there don't appear to be similar functions for the netmask or gateway (router). By combing through the related libraries I found the following "solutions":
> >
> > netmask: _if_tab[0].mask
> >
> > router: ath = router_for_iface(0, NULL, NULL, IF_ANY);
> > arpcache_ipaddr(ath, &router);
> >
> > Since I do not fully understand the above, I do not know how reliable they are.
> >
> > Is there a better way to find these two parameters?
> >
> > I am using DC 10.66 on an RCM4310.
>
> The ifconfig() has defines for both set and read of parameters.
> If I remember right:
>
> IFS_NETMASK - Pass long mask
> IFG_NETMASK - pass long pointer to receive parameter.
>
> IFS_* set parameter
> IFG_* get parameter.
>
> look at the net.lib defines and you can see what is available.
>
> --
> ------
> Scott G. Henion, Consultant
> Web site: http://SHDesigns.org
> ------
>

Reply by Steve November 3, 20112011-11-03
Steve,

Thanks.

Steve

--- In r..., Steve Trigero wrote:
>
> To get the Net Mask:
>  
> ifconfig( IF_DEFAULT, IFS_NETMASK, &long_value, IFS_END );
>  
> inet_ntoa( net_mask_str, long_value ); // Convert long to dotted string: "255.255.255.0"
>  
> To get the router/gatway IP:
>  
> ifconfig( IF_ETH0, IFG_ROUTER_DEFAULT, &long_value, IFS_END );
>  inet_ntoa( router_ip_str, long_value ); // Convert long to dotted string: "192.168.0.10"
>  
>
>
> >________________________________
> >From: Steve
> >To: r...
> >Sent: Wednesday, November 2, 2011 9:53 AM
> >Subject: [rabbit-semi] Finding Current ipaddress, Netmask and Gateway
> >
> >
> > 
> >For finding the ipaddress, there is the simple function gethostid(), but there don't appear to be similar functions for the netmask or gateway (router). By combing through the related libraries I found the following "solutions":
> >
> >netmask: _if_tab[0].mask
> >
> >router: ath = router_for_iface(0, NULL, NULL, IF_ANY);
> >arpcache_ipaddr(ath, &router);
> >
> >Since I do not fully understand the above, I do not know how reliable they are.
> >
> >Is there a better way to find these two parameters?
> >
> >I am using DC 10.66 on an RCM4310.
> >
> >Regards,
> >
> >Steve
> >
> >
> >
> >
>

Reply by Steve Trigero November 2, 20112011-11-02
To get the Net Mask:
 
ifconfig( IF_DEFAULT, IFS_NETMASK, &long_value, IFS_END );
 
inet_ntoa( net_mask_str, long_value ); // Convert long to dotted string: "255.255.255.0"
 
To get the router/gatway IP:
 
ifconfig( IF_ETH0, IFG_ROUTER_DEFAULT, &long_value, IFS_END );
 inet_ntoa( router_ip_str, long_value ); // Convert long to dotted string: "192.168.0.10"
 
>________________________________
>From: Steve
>To: r...
>Sent: Wednesday, November 2, 2011 9:53 AM
>Subject: [rabbit-semi] Finding Current ipaddress, Netmask and Gateway

>For finding the ipaddress, there is the simple function gethostid(), but there don't appear to be similar functions for the netmask or gateway (router). By combing through the related libraries I found the following "solutions":
>
>netmask: _if_tab[0].mask
>
>router: ath = router_for_iface(0, NULL, NULL, IF_ANY);
>arpcache_ipaddr(ath, &router);
>
>Since I do not fully understand the above, I do not know how reliable they are.
>
>Is there a better way to find these two parameters?
>
>I am using DC 10.66 on an RCM4310.
>
>Regards,
>
>Steve
>
Reply by Scott Henion November 2, 20112011-11-02
On 11/2/2011 12:53 PM, Steve wrote:
> For finding the ipaddress, there is the simple function gethostid(), but there don't appear to be similar functions for the netmask or gateway (router). By combing through the related libraries I found the following "solutions":
>
> netmask: _if_tab[0].mask
>
> router: ath = router_for_iface(0, NULL, NULL, IF_ANY);
> arpcache_ipaddr(ath, &router);
>
> Since I do not fully understand the above, I do not know how reliable they are.
>
> Is there a better way to find these two parameters?
>
> I am using DC 10.66 on an RCM4310.

The ifconfig() has defines for both set and read of parameters.
If I remember right:

IFS_NETMASK - Pass long mask
IFG_NETMASK - pass long pointer to receive parameter.

IFS_* set parameter
IFG_* get parameter.

look at the net.lib defines and you can see what is available.

--
------
Scott G. Henion, Consultant
Web site: http://SHDesigns.org
------

Reply by Steve November 2, 20112011-11-02
For finding the ipaddress, there is the simple function gethostid(), but there don't appear to be similar functions for the netmask or gateway (router). By combing through the related libraries I found the following "solutions":

netmask: _if_tab[0].mask

router: ath = router_for_iface(0, NULL, NULL, IF_ANY);
arpcache_ipaddr(ath, &router);

Since I do not fully understand the above, I do not know how reliable they are.

Is there a better way to find these two parameters?

I am using DC 10.66 on an RCM4310.

Regards,

Steve