4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
40 #pragma ident "%Z%%M% %I% %E% SMI"
46 #define bcmp(a, b, c) memcmp((a), (b), (c))
47 #define bcopy(a, b, c) memcpy((b), (a), (c))
50 struct hostent
*gethostbyname();
51 struct servent
*getservbyname();
54 get_addrs(my_machine_name
, rem_machine_name
)
55 char *my_machine_name
;
56 char *rem_machine_name
;
63 /* look up the address of the local host */
65 hp
= gethostbyname(my_machine_name
);
67 if (hp
== (struct hostent
*) 0) {
69 gettext("This machine doesn't exist. Boy, am I confused!\n"));
73 if (hp
->h_addrtype
!= AF_INET
) {
75 gettext("Protocol mix up with local machine address\n"));
79 bcopy(hp
->h_addr
, (char *)&my_machine_addr
, hp
->h_length
);
81 /* if on the same machine, then simply copy */
83 if (bcmp((char *)&rem_machine_name
, (char *)&my_machine_name
,
84 sizeof (rem_machine_name
)) == 0) {
85 bcopy((char *)&my_machine_addr
, (char *)&rem_machine_addr
,
86 sizeof (rem_machine_name
));
89 if ((rem_machine_addr
.s_addr
=
90 (unsigned long)inet_addr(rem_machine_name
)) == -1) {
92 /* look up the address of the recipient's machine */
94 hp
= gethostbyname(rem_machine_name
);
96 if (hp
== (struct hostent
*) 0) {
98 gettext("%s is an unknown host\n"), rem_machine_name
);
102 if (hp
->h_addrtype
!= AF_INET
) {
104 gettext("Protocol mix up with remote machine address\n"));
108 bcopy(hp
->h_addr
, (char *) &rem_machine_addr
, hp
->h_length
);
113 /* find the daemon portal */
116 sp
= getservbyname("ntalk", "udp");
118 sp
= getservbyname("talk", "udp");
121 if (strcmp(sp
->s_proto
, "udp") != 0) {
122 fprintf(stderr
, gettext("Protocol mix up with talk daemon\n"));
128 gettext("This machine doesn't support a tcp talk daemon"));
132 daemon_port
= sp
->s_port
;