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"
47 /* the amount of time to wait for a response, in seconds */
51 * SOCKDGRAM is unreliable, so we must repeat messages if we have
52 * not recieved an acknowledgement within a reasonable amount of time
56 ctl_transact(target
, msg
, type
, response
)
57 struct in_addr target
;
60 CTL_RESPONSE
*response
;
70 wait
.tv_sec
= CTL_WAIT
;
75 daemon_addr
.sin_addr
= target
;
76 daemon_addr
.sin_port
= daemon_port
;
78 ctl_mask
= 1 << ctl_sockt
;
81 * keep sending the message until a response of the right
86 /* keep sending the message until a response is obtained */
89 cc
= sendto(ctl_sockt
,
90 (char *)&msg
, sizeof (CTL_MSG
), 0,
91 (struct sockaddr
*)&daemon_addr
, sizeof (daemon_addr
));
93 if (cc
!= sizeof (CTL_MSG
)) {
95 /* we are returning from an interupt */
99 gettext("Error on write to talk daemon"));
103 read_mask
= ctl_mask
;
105 while ((nready
= select(32, (fd_set
*)&read_mask
,
107 if (errno
== EINTR
) {
108 /* we are returning from an interupt */
112 gettext("Error on waiting for response from daemon"));
115 } while (nready
== 0);
118 * keep reading while there are queued messages
119 * (this is not necessary, it just saves extra
120 * request/acknowledgements being sent)
125 junk_size
= (socklen_t
)sizeof (junk
);
126 cc
= recvfrom(ctl_sockt
, (char *)response
,
127 sizeof (CTL_RESPONSE
), 0, &junk
, &junk_size
);
129 if (errno
== EINTR
) {
132 p_error(gettext("Error on read from talk daemon"));
135 read_mask
= ctl_mask
;
137 /* an immediate poll */
140 nready
= select(32, (fd_set
*)&read_mask
, 0, 0, &wait
);
142 } while (nready
> 0 && response
->type
!= type
);
144 } while (response
->type
!= type
);