help with inet_aton IP conversion...

help with inet_aton IP conversion...

Post by ronleav.. » Wed, 13 Sep 2000 08:01:09



I've traced my "attempt to connect to a broadcast address" problem to
a -1 returned from inet_addr (-1 = IP broadcast address hence a connect
error).  I've since added error checking to a call to inet_aton
(inet_addr is obsolete)

why does inet_aton return a bad address (returns 0 with s_addr = 0)?

my routing is setup for the
class B network: 168.84.0.0, netmask: 255.255.0.0

my routing table (/sbin/route) is:

168.84.252.71    *     255.255.255.255  UH   0   0    0  eth0
168.84.252.1     *     255.255.255.255  UH   0   0    0  eth0
168.84.0.0       *     255.255.0.0      U    0   0    0  eth0
127.0.0.0        *     255.0.0.0        U    0   0    0  eth0

252.71    = self
252.1     = server
0.0       = network address
127.0.0.0 = loopback adderss

all appears as it should be, but  inet_aton maps 168.84.252.1 into
oblivion!!  WHY?

Ron

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

help with inet_aton IP conversion...

Post by David K. Mean » Wed, 13 Sep 2000 10:25:19


This function depends on being able to resolve the address to a hostname via
DNS.
From where my machines sit, 164.84.252.1 does not resolve.  You will need to
look
into where your DNS service is coming from, and get the inverse mapping
fixed so that
this will work.


Quote:> I've traced my "attempt to connect to a broadcast address" problem to
> a -1 returned from inet_addr (-1 = IP broadcast address hence a connect
> error).  I've since added error checking to a call to inet_aton
> (inet_addr is obsolete)

> why does inet_aton return a bad address (returns 0 with s_addr = 0)?

> my routing is setup for the
> class B network: 168.84.0.0, netmask: 255.255.0.0

> my routing table (/sbin/route) is:

> 168.84.252.71    *     255.255.255.255  UH   0   0    0  eth0
> 168.84.252.1     *     255.255.255.255  UH   0   0    0  eth0
> 168.84.0.0       *     255.255.0.0      U    0   0    0  eth0
> 127.0.0.0        *     255.0.0.0        U    0   0    0  eth0

> 252.71    = self
> 252.1     = server
> 0.0       = network address
> 127.0.0.0 = loopback adderss

> all appears as it should be, but  inet_aton maps 168.84.252.1 into
> oblivion!!  WHY?

> Ron

> Sent via Deja.com http://www.deja.com/
> Before you buy.


 
 
 

help with inet_aton IP conversion...

Post by David Efflan » Wed, 13 Sep 2000 14:42:47



>I've traced my "attempt to connect to a broadcast address" problem to
>a -1 returned from inet_addr (-1 = IP broadcast address hence a connect
>error).  I've since added error checking to a call to inet_aton
>(inet_addr is obsolete)

>why does inet_aton return a bad address (returns 0 with s_addr = 0)?

>my routing is setup for the
>class B network: 168.84.0.0, netmask: 255.255.0.0

>my routing table (/sbin/route) is:

>168.84.252.71    *     255.255.255.255  UH   0   0    0  eth0
>168.84.252.1     *     255.255.255.255  UH   0   0    0  eth0
>168.84.0.0       *     255.255.0.0      U    0   0    0  eth0
>127.0.0.0        *     255.0.0.0        U    0   0    0  eth0

Is this a typo or does your loopback actually go to eth0 instead of lo?

Quote:>252.71    = self
>252.1     = server
>0.0       = network address
>127.0.0.0 = loopback adderss

>all appears as it should be, but  inet_aton maps 168.84.252.1 into
>oblivion!!  WHY?

Try this Perl script:

#!/usr/bin/perl -w
use Socket;
&lookup('localhost');
$_ = `hostname`;
chomp;
&lookup($_);
&lookup('bogustest');
&lookup('168.84.252.71');
print "\n";
sub lookup {
    my $name = shift;
    my $iaddr = inet_aton($name);
    if ($iaddr) {
        my $peer_addr = inet_ntoa($iaddr);
        my $peer_host = gethostbyaddr($iaddr,AF_INET) || '(unresolved)';
        print "\n$name is IP $peer_addr\nwhich is $peer_host\n";
    } else {
        print "\n$name does not resolve\n";
    }

Quote:}

Which gives me:

localhost is IP 127.0.0.1
which is localhost.localdomain

efflandt.xnet.com is IP 127.0.0.2
which is efflandt.xnet.com

bogustest does not resolve

168.84.252.71 is IP 168.84.252.71
which is (unresolved)

PS: The loopback IP for my hostname in /etc/hosts allows everything to
work offline as well as online (where DNS can find me).

--

http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/

 
 
 

1. Help: IP to TTY/PTTY Conversion

Hello,

I have a problem and I hope that someone out there has an answer for me.

I am running an application on SCO (Switchview).  This application can
only communicate to remote systems via serial, either modem or tty.  

I am setting up a frame relay network that is going to remove all dial up
access into the remote systems and replace them with ethernet.  I need to
figure out a way to convert/translate IP addresses to TTY's.  There is a
software product from Digi called Real Port that converts IP addresses
and allows serial applications to access IP's as ptty's, but it only works
with Digi terminal servers.  My problem is that my network people will not
support Digi terminal servers, they only support Cisco.

Does anyone know of another software out there that can accomplish the
same thing, AND work with Cisco products?

Please reply via email if you can help.  

Thanks much,

Allan Bourque
Motorola, Inc.

2. usb scanner

3. IP/hostname conversion problem: HELP

4. i2c update to 2.6.0 for 2.4.7

5. inet_aton() function problems Any help appreciated!

6. Please contact me

7. weird structure conversion in bsd TCP/IP src..

8. 3C905 Woes

9. URL to IP address conversion?

10. IP address to name conversion... How?

11. Conversion between IP addresses (string and long int)

12. IP address string conversion

13. IP <-> host name conversion