Return to BSD News archive
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!simtel!zombie.ncsc.mil!news.mathworks.com!newshost.marcam.com!usc!cs.utexas.edu!news.sprintlink.net!EU.net!Germany.EU.net!zib-berlin.de!news.tu-chemnitz.de!irz401!uriah.heep!bonnie.heep!not-for-mail From: j@bonnie.heep.sax.de (J Wunsch) Newsgroups: comp.unix.bsd.freebsd.misc Subject: Re: Idea for Talk to PPP host Date: 17 Jul 1995 11:59:52 +0200 Organization: Private U**x site, Dresden. Lines: 55 Message-ID: <3udcao$62@bonnie.tcd-dresden.de> References: <3te4fb$mt@news.simplex.nl> <3ttt96$8dm@hydra.msgi.com> <3tvub5$nol@bonnie.tcd-dresden.de> <3u3cro$ija@hydra.msgi.com> Reply-To: joerg_wunsch@uriah.heep.sax.de NNTP-Posting-Host: 192.109.108.139 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Coranth Gryphon <gryphon@msgi.com> wrote: >In article <3tvub5$nol@bonnie.tcd-dresden.de>, >J Wunsch <joerg_wunsch@uriah.heep.sax.de> wrote: >>Coranth Gryphon <gryphon@msgi.com> wrote: >> >>>Do you have both IP addresses registed as the same host name ? >> >>Same hostname, but the 192.168 address is not officially registered >>(apparently -- it's a `private' network address). > >Can you give two seperate host names for the different addresses? Not easily. >I know this configuration works. How? get_names(argc, argv) int argc; char *argv[]; { ... gethostname(hostname, sizeof (hostname)); my_machine_name = hostname; get_addrs(my_machine_name, his_machine_name); ... } get_addrs(my_machine_name, his_machine_name) char *my_machine_name, *his_machine_name; { ... hp = gethostbyname(my_machine_name); ... bcopy(hp->h_addr, (char *)&my_machine_addr, hp->h_length); } So it's looking up `my_machine_name' by gethostname(), returning what- ever i've entered as the primary host name. Later, it uses this name for a gethostbyname() call, and obtains `my_machine_addr' out of the returned ``primary'' address for the machine. It should however extract the appropriate local address (wrt. to the route to the remote side) out of the following field: char **h_addr_list; /* list of addresses from name server */ -- cheers, J"org private: joerg_wunsch@uriah.heep.sax.de http://www.sax.de/~joerg/ Never trust an operating system you don't have sources for. ;-)