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]
22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23 /* All Rights Reserved */
26 #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5.1.1 */
32 * Send service request message to remote listener
33 * on previously established virtual circuit to remote
36 * If an error occurrs, t_errno will contain an error code.
38 * Setting the external integer "_nlslog" to any non-zero
39 * value before calling nlsrequest, will cause nlsrequest
40 * to print debug information on stderr.
42 * client/server process pairs should include their own
43 * initial handshake to insure connectivity.
45 * This version of nlsrequest includes the
46 * service request response message.
56 #include <sys/tiuser.h>
59 extern int _nlslog
; /* non-zero allows use of stderr */
60 char *_nlsrmsg
= NULL
;
61 static char _nlsbuf
[256];
65 nlsrequest(int fd
, char *svc_code
)
73 t_errno
= 0; /* indicates a 'name' problem */
77 * Validate service code
80 if (!svc_code
|| !strlen(svc_code
) ||
81 (strlen(svc_code
) >= (size_t)SVC_CODE_SZ
)) {
83 fprintf(stderr
, "nlsrequest: invalid service code format\n");
88 * send protocol message requesting the service
91 len
= sprintf(buf
, nls_v2_msg
, svc_code
)+1;/* inc trailing null */
93 if (t_snd(fd
, buf
, len
, 0) < len
) {
95 t_error("t_snd of listener request message failed");
103 if (++len
> sizeof(_nlsbuf
)) {
105 fprintf(stderr
, "nlsrequest: _nlsbuf not large enough\n");
108 if (t_rcv(fd
, p
, sizeof(char), &flags
) != sizeof(char)) {
110 t_error("t_rcv of listener response msg failed");
114 } while (*p
++ != '\0');
117 if ((p
= strtok(_nlsbuf
, ":")) == NULL
)
121 if ((p
= strtok(NULL
, ":")) == NULL
)
124 _nlsrmsg
= p
+ strlen(p
) + 1;
126 fprintf(stderr
, "%s\n", _nlsrmsg
); /* debug only */
131 fprintf(stderr
, "nlsrequest: failed parse of response message\n");