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 */
29 * Send service request message to remote listener
30 * on previously established virtual circuit to remote
33 * If an error occurrs, t_errno will contain an error code.
35 * Setting the external integer "_nlslog" to any non-zero
36 * value before calling nlsrequest, will cause nlsrequest
37 * to print debug information on stderr.
39 * client/server process pairs should include their own
40 * initial handshake to insure connectivity.
42 * This version of nlsrequest includes the
43 * service request response message.
53 #include <sys/tiuser.h>
56 extern int _nlslog
; /* non-zero allows use of stderr */
57 char *_nlsrmsg
= NULL
;
58 static char _nlsbuf
[256];
62 nlsrequest(int fd
, char *svc_code
)
70 t_errno
= 0; /* indicates a 'name' problem */
74 * Validate service code
77 if (!svc_code
|| !strlen(svc_code
) ||
78 (strlen(svc_code
) >= (size_t)SVC_CODE_SZ
)) {
81 "nlsrequest: invalid service code format\n");
87 * send protocol message requesting the service
90 len
= sprintf(buf
, nls_v2_msg
, svc_code
) + 1; /* inc trailing null */
92 if (t_snd(fd
, buf
, len
, 0) < len
) {
94 t_error("t_snd of listener request message failed");
102 if (++len
> sizeof (_nlsbuf
)) {
105 "nlsrequest: _nlsbuf not large enough\n");
109 if (t_rcv(fd
, p
, sizeof (char), &flags
) != sizeof (char)) {
111 t_error("t_rcv of listener response msg "
117 } while (*p
++ != '\0');
120 if ((p
= strtok(_nlsbuf
, ":")) == NULL
)
124 * We ignore the version number here as we do not have any use for it.
125 * Previous versions of the code looked at it by calling atoi() on it,
126 * which did not mutate the actual string and did not use it.
129 if ((p
= strtok(NULL
, ":")) == NULL
)
132 _nlsrmsg
= p
+ strlen(p
) + 1;
134 fprintf(stderr
, "%s\n", _nlsrmsg
); /* debug only */
140 "nlsrequest: failed parse of response message\n");