At 2:36 PM -0400 5/16/02, [EMAIL PROTECTED] wrote:
>Craig Berry wrote:
>!Peter,
>!
>!Thanks for working on this.  With that head start I am now able to nail
>the
>!exact problem with gethostbyaddr, though integrating a fix into Perl will
>!still be a bit messy.  With the socktest.c program at the end of this
>!message, I get an address length of 58 by using the headers and routines
>!supplied with the C RTL:
>
>This is interesting.  Indeed, later last night I wrote a program
>very similar to yours with which I can also see a h->h_length problem.
>The value I obtained (62) matches the length of the perl hostent.t
>test return: C<gethost("127.0.0.1");> returns a perl scalar string of
>length 62 for me with my set up (hence I wonder if your is length 58?).

Yes, I get 58.

>
>On further investigation I found that with my 4.3A Multinet
>gethostbyaddr() is documented as:
>
> (struct hostent *) gethostbyaddr(Addr, Length, Family);
>             char *Addr;
>             unsigned int Length;
>             unsigned int Family;
>
>The prototype inside of the multinet netdb.h header is:
>
>struct hostent  *gethostbyaddr __P((const void *, int, int));
>
>I was curious about possible updates to Multinet and was
>intrigued that the docs for Multinet 4.4 (based on the 4.4 BSD
>behavior???) at:
>
>http://www.multinet.process.com/ftp/docs/html/programmers_reference/Ch02.htm#E48E13
>
>also mentions "char *Addr", but then goes on to add:
>"Addr is a pointer to an in_addr structure." -- ???

Well, it's a struct that contains 4, 1-byte integers, at least for
IPv4.  The examples I found all use a calling sequence similar to the
following:

    struct hostent *h;
    struct in_addr myaddr;
    printf( "%d\n", __CRTL_VER );
    myaddr.s_addr = inet_addr("127.0.0.1");
    h = gethostbyaddr( (char*) &myaddr, 4, AF_INET );


>
>The other concern that I have is: what to do with the extra
>characters?  Should we simply truncate the returned address(es)
>at 4? 

The 58/62 is, I think, due to a structure mismatch, not because there really are 
addresses that long.

>What about IPv6 addresses?  Basically: can we accomdate
>the difference between the hostent in DECC and the hostent in
>Multinet land?

You raise a good point about IPv6 and I don't know the answer.  I
doubt if BSD 4.3-compatible structures have any hope of handling
IPv6.  Note that in the release notes for the latest version of
Multinet there is mention of BSD 4.4-compatible versions of some of
the socket routines.  See
<http://www.multinet.process.com/ftp/docs/html/multinet_release_notes.txt>.


>!Making use of this will be a bit of a mess since configure.com will have
>to
>!detect Multinet and define the MULTINET_SOCKETS macro.  Then probably
>!sockadapt.h will have to be modified to include the alternate headers when
>
>!the macro is defined.  Then one of the linker options files (I'm not sure
>!which one) will need to have a line added to link against the Multinet
>!socket library.  Any takers?
>
>If this proves necessary I already have a strategy mapped out:

Sounds good.



-- 
____________________________________________
Craig A. Berry                  
mailto:[EMAIL PROTECTED]

"Literary critics usually know what they're
talking about. Even if they're wrong."
        -- Perl creator Larry Wall

Reply via email to