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]
24 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
28 #pragma ident "%Z%%M% %I% %E% SMI"
31 #include <sys/types.h>
34 #include <netconfig.h>
39 __yp_clnt_create_rsvdport_netid_req(const char *hostname
, rpcprog_t prog
,
40 rpcvers_t vers
, const char *nettype
,
41 const uint_t sendsz
, const uint_t recvsz
)
43 struct netconfig
*nconf
;
44 struct netbuf
*svcaddr
;
55 if (strcmp(nt
, "udp") && strcmp(nt
, "tcp") &&
56 strcmp(nt
, "udp6") && strcmp(nt
, "tcp6"))
57 return (clnt_create(hostname
, prog
, vers
, nt
));
59 if ((nconf
= getnetconfigent((void *) nt
)) == NULL
)
62 if ((fd
= t_open(nconf
->nc_device
, O_RDWR
, NULL
)) == -1) {
63 freenetconfigent(nconf
);
67 /* Attempt to set reserved port, but we don't care if it fails */
68 (void) netdir_options(nconf
, ND_SET_RESERVEDPORT
, fd
, NULL
);
70 /* LINTED pointer cast */
71 if ((tbind
= (struct t_bind
*)t_alloc(fd
, T_BIND
, T_ADDR
)) == NULL
) {
72 freenetconfigent(nconf
);
76 svcaddr
= &(tbind
->addr
);
78 if (!rpcb_getaddr(prog
, vers
, nconf
, svcaddr
, hostname
)) {
80 (void) t_free((char *)tbind
, T_BIND
);
81 freenetconfigent(nconf
);
85 if ((clnt
= clnt_tli_create(fd
, nconf
, svcaddr
,
86 prog
, vers
, sendsz
, recvsz
)) == NULL
) {
88 (void) t_free((char *)tbind
, T_BIND
);
90 (void) t_free((char *)tbind
, T_BIND
);
91 clnt_control(clnt
, CLSET_FD_CLOSE
, NULL
);
93 freenetconfigent(nconf
);
99 __yp_clnt_create_rsvdport(const char *hostname
, rpcprog_t prog
,
100 rpcvers_t vers
, const char *nettype
,
101 const uint_t sendsz
, const uint_t recvsz
)
105 ret
= __yp_clnt_create_rsvdport_netid_req(hostname
, prog
,
106 vers
, "udp6", sendsz
, recvsz
);
108 ret
= __yp_clnt_create_rsvdport_netid_req(hostname
,
109 prog
, vers
, "udp", sendsz
, recvsz
);
112 return (__yp_clnt_create_rsvdport_netid_req(hostname
, prog
,