[omniORB] Re: gethostbyname/addr on win32.

jon.kristensen@kongsberg-simrad.com jon.kristensen@kongsberg-simrad.com
Thu Dec 19 12:06:52 2002


On Thu, 19th Dec 2002 Daniel Bell wrote:

>However, if the win32 machine does not have a reverse DNS entry for it in
>the DNS, then the host information is failed to be retrieved.

I have made several posts to this list about the same problem over the past
year, the last one on December 12th titled: "Re: [omniORB] ETS issues for
upcoming 4.0 release"

You may not have observed these posts, because many of them deals with ETS
issues. The ETS real-time kernel is win32 compatible, and I do ETS
development and debugging using Microsoft Visual Studio. As none of my ETS
machines have DNS enabled, I have run into the same probles as you have.
unfortunately, I initially though this to be an ETS specific problem, hence
the titles of the posts.

I have proposed a simple patch that solves this, and repeated this proposal
several times, last time in my post december 12th as an attempt to get it
into the 4.0.1 release. I have not yet seen any response to that last post.

The patch is changing all the time as the source code also changes. Based
on the snapshot from november 17th, the patch is now:

replace the code line libcWrapper.cc:213

      hp = ::gethostbyaddr((char*)&IP, sizeof(IP), AF_INET);

with:

      {
         // Fake a hostent structure based on our IP address
         static char * Aliases[1] = { NULL };
         static unsigned long * Adresses[2] = { &IP, NULL };

         hp = &myhp;
         hp->h_name      = (char*)name;
         hp->h_aliases   = (char**)Aliases;
         hp->h_addrtype  = PF_INET;
         hp->h_length    = 4;
         hp->h_addr_list = (char**)Adresses;
      }

This patch skips the gethostbyaddr call and instead fakes a hostent
structure that has the correct h_addr field and has the h_name field set to
the dotted decimal string. The only things actually used further down-line
are these two fields, so this patch works perfectly.

I have been using this patch (or something similar) on ETS, NT4 and on
Win2k all the way since this part of the omniORB code were rewritten
heavily just less than a year ago. Never had any problems.

I hope we now can get this or something similar into the sources so I no
longer have to edit and recompile every time a new snapshot is downloaded.

Regards,
Jon Kristensen


--------------
Jon Kristensen
Principal Engineer, SW Embedded Systems
Kongsberg Simrad AS, Horten, Norway
phone:      +47 33 02 39 34
fax:  +47 33 04 76 19
email:      jon.kristensen@kongsberg-simrad.com