rpc_soc.c revision 261046
16735Samurai/*	$NetBSD: rpc_soc.c,v 1.6 2000/07/06 03:10:35 christos Exp $	*/
26735Samurai
36735Samurai/*-
46735Samurai * Copyright (c) 2009, Sun Microsystems, Inc.
56735Samurai * All rights reserved.
66735Samurai *
76735Samurai * Redistribution and use in source and binary forms, with or without
86735Samurai * modification, are permitted provided that the following conditions are met:
96735Samurai * - Redistributions of source code must retain the above copyright notice,
106735Samurai *   this list of conditions and the following disclaimer.
116735Samurai * - Redistributions in binary form must reproduce the above copyright notice,
126735Samurai *   this list of conditions and the following disclaimer in the documentation
136735Samurai *   and/or other materials provided with the distribution.
146735Samurai * - Neither the name of Sun Microsystems, Inc. nor the names of its
156735Samurai *   contributors may be used to endorse or promote products derived
166735Samurai *   from this software without specific prior written permission.
176735Samurai *
186735Samurai * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
198857Srgrimes * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2050479Speter * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
218857Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
226735Samurai * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
236735Samurai * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
246735Samurai * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
256735Samurai * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
266735Samurai * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
276735Samurai * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2843313Sbrian * POSSIBILITY OF SUCH DAMAGE.
296735Samurai */
306735Samurai
316735Samurai/* #ident	"@(#)rpc_soc.c	1.17	94/04/24 SMI" */
326735Samurai
336735Samurai/*
346735Samurai * Copyright (c) 1986-1991 by Sun Microsystems Inc.
3532721Sbrian * In addition, portions of such source code were derived from Berkeley
3636285Sbrian * 4.3 BSD under license from the Regents of the University of
3736285Sbrian * California.
3836285Sbrian */
3930715Sbrian
4046085Sbrian#if defined(LIBC_SCCS) && !defined(lint)
4130715Sbrianstatic char sccsid[] = "@(#)rpc_soc.c 1.41 89/05/02 Copyr 1988 Sun Micro";
4232616Sbrian#endif
4330715Sbrian#include <sys/cdefs.h>
4432616Sbrian__FBSDID("$FreeBSD: stable/10/lib/libc/rpc/rpc_soc.c 261046 2014-01-22 23:45:27Z mav $");
4546686Sbrian
4630715Sbrian#ifdef PORTMAP
4730715Sbrian/*
4846686Sbrian * rpc_soc.c
4930715Sbrian *
5029265Sbrian * The backward compatibility routines for the earlier implementation
5131061Sbrian * of RPC, where the only transports supported were tcp/ip and udp/ip.
5236285Sbrian * Based on berkeley socket abstraction, now implemented on the top
5336285Sbrian * of TLI/Streams
5436285Sbrian */
5536285Sbrian
5636285Sbrian#include "namespace.h"
5736285Sbrian#include "reentrant.h"
5838557Sbrian#include <sys/types.h>
5938557Sbrian#include <sys/socket.h>
6081634Sbrian#include <stdio.h>
6136285Sbrian#include <rpc/rpc.h>
6281634Sbrian#include <rpc/pmap_clnt.h>
6336285Sbrian#include <rpc/pmap_prot.h>
6436285Sbrian#include <rpc/nettype.h>
6536285Sbrian#include <syslog.h>
6636285Sbrian#include <netinet/in.h>
6736285Sbrian#include <netdb.h>
6881634Sbrian#include <errno.h>
6981634Sbrian#include <syslog.h>
7043313Sbrian#include <stdlib.h>
7143313Sbrian#include <string.h>
7243313Sbrian#include <unistd.h>
7336285Sbrian#include "un-namespace.h"
7458032Sbrian
7530715Sbrian#include "rpc_com.h"
766735Samurai#include "mt_misc.h"
7732616Sbrian
786735Samuraistatic CLIENT *clnt_com_create(struct sockaddr_in *, rpcprog_t, rpcvers_t,
796735Samurai    int *, u_int, u_int, char *);
806735Samuraistatic SVCXPRT *svc_com_create(int, u_int, u_int, char *);
816735Samuraistatic bool_t rpc_wrap_bcast(char *, struct netbuf *, struct netconfig *);
8230715Sbrian
836735Samurai/* XXX */
846735Samurai#define IN4_LOCALHOST_STRING    "127.0.0.1"
856735Samurai#define IN6_LOCALHOST_STRING    "::1"
866735Samurai
876735Samurai/*
886735Samurai * A common clnt create routine
896735Samurai */
9036285Sbrianstatic CLIENT *
916735Samuraiclnt_com_create(raddr, prog, vers, sockp, sendsz, recvsz, tp)
926735Samurai	struct sockaddr_in *raddr;
9328679Sbrian	rpcprog_t prog;
9428679Sbrian	rpcvers_t vers;
9528679Sbrian	int *sockp;
9628679Sbrian	u_int sendsz;
9730715Sbrian	u_int recvsz;
986735Samurai	char *tp;
9940665Sbrian{
10040665Sbrian	CLIENT *cl;
1016735Samurai	int madefd = FALSE;
10228679Sbrian	int fd = *sockp;
1036735Samurai	struct netconfig *nconf;
10428679Sbrian	struct netbuf bindaddr;
10528679Sbrian
10628679Sbrian	mutex_lock(&rpcsoc_lock);
10728679Sbrian	if ((nconf = __rpc_getconfip(tp)) == NULL) {
10840665Sbrian		rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
10931962Sbrian		mutex_unlock(&rpcsoc_lock);
11080730Sbrian		return (NULL);
11140665Sbrian	}
11240665Sbrian	if (fd == RPC_ANYSOCK) {
11328679Sbrian		fd = __rpc_nconf2fd(nconf);
11428679Sbrian		if (fd == -1)
11589422Sbrian			goto syserror;
11631061Sbrian		madefd = TRUE;
11736285Sbrian	}
11828679Sbrian
11928679Sbrian	if (raddr->sin_port == 0) {
12028679Sbrian		u_int proto;
12140665Sbrian		u_short sport;
12228679Sbrian
12328679Sbrian		mutex_unlock(&rpcsoc_lock);	/* pmap_getport is recursive */
12436285Sbrian		proto = strcmp(tp, "udp") == 0 ? IPPROTO_UDP : IPPROTO_TCP;
12528679Sbrian		sport = pmap_getport(raddr, (u_long)prog, (u_long)vers,
12628679Sbrian		    proto);
12728679Sbrian		if (sport == 0) {
12828679Sbrian			goto err;
12936285Sbrian		}
13028679Sbrian		raddr->sin_port = htons(sport);
1316735Samurai		mutex_lock(&rpcsoc_lock);	/* pmap_getport is recursive */
13228679Sbrian	}
13328679Sbrian
13440665Sbrian	/* Transform sockaddr_in to netbuf */
13540665Sbrian	bindaddr.maxlen = bindaddr.len =  sizeof (struct sockaddr_in);
13683775Sru	bindaddr.buf = raddr;
13740665Sbrian
13840665Sbrian	bindresvport(fd, NULL);
13940665Sbrian	cl = clnt_tli_create(fd, nconf, &bindaddr, prog, vers,
1406735Samurai				sendsz, recvsz);
14128679Sbrian	if (cl) {
14228679Sbrian		if (madefd == TRUE) {
14328679Sbrian			/*
14428679Sbrian			 * The fd should be closed while destroying the handle.
1456735Samurai			 */
1466735Samurai			(void) CLNT_CONTROL(cl, CLSET_FD_CLOSE, NULL);
14740665Sbrian			*sockp = fd;
14840665Sbrian		}
14940665Sbrian		(void) freenetconfigent(nconf);
15040665Sbrian		mutex_unlock(&rpcsoc_lock);
15140665Sbrian		return (cl);
15240665Sbrian	}
1536735Samurai	goto err;
15436285Sbrian
1556735Samuraisyserror:
1566735Samurai	rpc_createerr.cf_stat = RPC_SYSTEMERROR;
15736285Sbrian	rpc_createerr.cf_error.re_errno = errno;
1586735Samurai
15940665Sbrianerr:	if (madefd == TRUE)
1606735Samurai		(void)_close(fd);
1616735Samurai	(void) freenetconfigent(nconf);
16228679Sbrian	mutex_unlock(&rpcsoc_lock);
1636735Samurai	return (NULL);
1646735Samurai}
16536285Sbrian
1666735SamuraiCLIENT *
1676735Samuraiclntudp_bufcreate(raddr, prog, vers, wait, sockp, sendsz, recvsz)
16836285Sbrian	struct sockaddr_in *raddr;
1696735Samurai	u_long prog;
17028679Sbrian	u_long vers;
17128679Sbrian	struct timeval wait;
17228679Sbrian	int *sockp;
17328679Sbrian	u_int sendsz;
17428679Sbrian	u_int recvsz;
1756735Samurai{
17631962Sbrian	CLIENT *cl;
1776735Samurai
17828679Sbrian	cl = clnt_com_create(raddr, (rpcprog_t)prog, (rpcvers_t)vers, sockp,
17928679Sbrian	    sendsz, recvsz, "udp");
18028679Sbrian	if (cl == NULL) {
18128679Sbrian		return (NULL);
18280730Sbrian	}
18367912Sbrian	(void) CLNT_CONTROL(cl, CLSET_RETRY_TIMEOUT, &wait);
18467912Sbrian	return (cl);
18528679Sbrian}
18628679Sbrian
18728679SbrianCLIENT *
18828679Sbrianclntudp_create(raddr, program, version, wait, sockp)
18930715Sbrian	struct sockaddr_in *raddr;
19028679Sbrian	u_long program;
19136285Sbrian	u_long version;
19228679Sbrian	struct timeval wait;
19336285Sbrian	int *sockp;
19437019Sbrian{
19537019Sbrian
19628679Sbrian	return clntudp_bufcreate(raddr, program, version, wait, sockp,
19728679Sbrian					UDPMSGSIZE, UDPMSGSIZE);
19828679Sbrian}
1996735Samurai
2006735SamuraiCLIENT *
2016735Samuraiclnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
20236285Sbrian	struct sockaddr_in *raddr;
2036735Samurai	u_long prog;
2046735Samurai	u_long vers;
20536285Sbrian	int *sockp;
2066735Samurai	u_int sendsz;
20728679Sbrian	u_int recvsz;
2086735Samurai{
20931962Sbrian
21028679Sbrian	return clnt_com_create(raddr, (rpcprog_t)prog, (rpcvers_t)vers, sockp,
21136285Sbrian	    sendsz, recvsz, "tcp");
21236285Sbrian}
21337019Sbrian
21437019SbrianCLIENT *
21528679Sbrianclntraw_create(prog, vers)
21628679Sbrian	u_long prog;
21728679Sbrian	u_long vers;
2186735Samurai{
2196735Samurai
22028679Sbrian	return clnt_raw_create((rpcprog_t)prog, (rpcvers_t)vers);
2216735Samurai}
22228679Sbrian
2236735Samurai/*
22480730Sbrian * A common server create routine
2256735Samurai */
2266735Samuraistatic SVCXPRT *
2276735Samuraisvc_com_create(fd, sendsize, recvsize, netid)
22836285Sbrian	int fd;
22980730Sbrian	u_int sendsize;
23080730Sbrian	u_int recvsize;
2316735Samurai	char *netid;
23258032Sbrian{
23332721Sbrian	struct netconfig *nconf;
23432721Sbrian	SVCXPRT *svc;
23532721Sbrian	int madefd = FALSE;
23632721Sbrian	int port;
23732616Sbrian	struct sockaddr_in sin;
23858032Sbrian
2396735Samurai	if ((nconf = __rpc_getconfip(netid)) == NULL) {
24032616Sbrian		(void) syslog(LOG_ERR, "Could not get %s transport", netid);
24132616Sbrian		return (NULL);
24232616Sbrian	}
24332616Sbrian	if (fd == RPC_ANYSOCK) {
24432721Sbrian		fd = __rpc_nconf2fd(nconf);
24532616Sbrian		if (fd == -1) {
24632721Sbrian			(void) freenetconfigent(nconf);
24732616Sbrian			(void) syslog(LOG_ERR,
24880730Sbrian			"svc%s_create: could not open connection", netid);
24932723Sbrian			return (NULL);
25032616Sbrian		}
25128679Sbrian		madefd = TRUE;
25232721Sbrian	}
25332721Sbrian
25428679Sbrian	memset(&sin, 0, sizeof sin);
25532721Sbrian	sin.sin_family = AF_INET;
25632721Sbrian	bindresvport(fd, &sin);
25732721Sbrian	_listen(fd, SOMAXCONN);
25832616Sbrian	svc = svc_tli_create(fd, nconf, NULL, sendsize, recvsize);
25932616Sbrian	(void) freenetconfigent(nconf);
26032721Sbrian	if (svc == NULL) {
2616735Samurai		if (madefd)
26232721Sbrian			(void)_close(fd);
26332721Sbrian		return (NULL);
26432721Sbrian	}
26532721Sbrian	port = (((struct sockaddr_in *)svc->xp_ltaddr.buf)->sin_port);
26632721Sbrian	svc->xp_port = ntohs(port);
26732721Sbrian	return (svc);
26832721Sbrian}
26932721Sbrian
27032721SbrianSVCXPRT *
27132721Sbriansvctcp_create(fd, sendsize, recvsize)
27232721Sbrian	int fd;
27332721Sbrian	u_int sendsize;
27432721Sbrian	u_int recvsize;
27532721Sbrian{
27632721Sbrian
27732721Sbrian	return svc_com_create(fd, sendsize, recvsize, "tcp");
27832721Sbrian}
27932721Sbrian
28036285SbrianSVCXPRT *
28132721Sbriansvcudp_bufcreate(fd, sendsz, recvsz)
28236285Sbrian	int fd;
28332721Sbrian	u_int sendsz, recvsz;
28458032Sbrian{
28558032Sbrian
28658032Sbrian	return svc_com_create(fd, sendsz, recvsz, "udp");
28758032Sbrian}
28858032Sbrian
28958032SbrianSVCXPRT *
29058032Sbriansvcfd_create(fd, sendsize, recvsize)
29158032Sbrian	int fd;
29258032Sbrian	u_int sendsize;
29358032Sbrian	u_int recvsize;
29458032Sbrian{
29558032Sbrian
29658032Sbrian	return svc_fd_create(fd, sendsize, recvsize);
29758032Sbrian}
29858032Sbrian
29958032Sbrian
30032616SbrianSVCXPRT *
30158032Sbriansvcudp_create(fd)
30258032Sbrian	int fd;
30358032Sbrian{
30480730Sbrian
30580730Sbrian	return svc_com_create(fd, UDPMSGSIZE, UDPMSGSIZE, "udp");
30680730Sbrian}
30758032Sbrian
30858032SbrianSVCXPRT *
30958032Sbriansvcraw_create()
31032721Sbrian{
31132616Sbrian
3126735Samurai	return svc_raw_create();
31328679Sbrian}
31432721Sbrian
31532721Sbrianint
31628679Sbrianget_myaddress(addr)
3176735Samurai	struct sockaddr_in *addr;
318{
319
320	memset((void *) addr, 0, sizeof(*addr));
321	addr->sin_family = AF_INET;
322	addr->sin_port = htons(PMAPPORT);
323	addr->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
324	return (0);
325}
326
327/*
328 * For connectionless "udp" transport. Obsoleted by rpc_call().
329 */
330int
331callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
332	const char *host;
333	int prognum, versnum, procnum;
334	xdrproc_t inproc, outproc;
335	void *in, *out;
336{
337
338	return (int)rpc_call(host, (rpcprog_t)prognum, (rpcvers_t)versnum,
339	    (rpcproc_t)procnum, inproc, in, outproc, out, "udp");
340}
341
342/*
343 * For connectionless kind of transport. Obsoleted by rpc_reg()
344 */
345int
346registerrpc(prognum, versnum, procnum, progname, inproc, outproc)
347	int prognum, versnum, procnum;
348	char *(*progname)(char [UDPMSGSIZE]);
349	xdrproc_t inproc, outproc;
350{
351
352	return rpc_reg((rpcprog_t)prognum, (rpcvers_t)versnum,
353	    (rpcproc_t)procnum, progname, inproc, outproc, "udp");
354}
355
356/*
357 * All the following clnt_broadcast stuff is convulated; it supports
358 * the earlier calling style of the callback function
359 */
360static thread_key_t	clnt_broadcast_key;
361static resultproc_t	clnt_broadcast_result_main;
362static once_t		clnt_broadcast_once = ONCE_INITIALIZER;
363
364static void
365clnt_broadcast_key_init(void)
366{
367
368	thr_keycreate(&clnt_broadcast_key, free);
369}
370
371/*
372 * Need to translate the netbuf address into sockaddr_in address.
373 * Dont care about netid here.
374 */
375/* ARGSUSED */
376static bool_t
377rpc_wrap_bcast(resultp, addr, nconf)
378	char *resultp;		/* results of the call */
379	struct netbuf *addr;	/* address of the guy who responded */
380	struct netconfig *nconf; /* Netconf of the transport */
381{
382	resultproc_t clnt_broadcast_result;
383
384	if (strcmp(nconf->nc_netid, "udp"))
385		return (FALSE);
386	if (thr_main())
387		clnt_broadcast_result = clnt_broadcast_result_main;
388	else
389		clnt_broadcast_result = (resultproc_t)thr_getspecific(clnt_broadcast_key);
390	return (*clnt_broadcast_result)(resultp,
391				(struct sockaddr_in *)addr->buf);
392}
393
394/*
395 * Broadcasts on UDP transport. Obsoleted by rpc_broadcast().
396 */
397enum clnt_stat
398clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
399	u_long		prog;		/* program number */
400	u_long		vers;		/* version number */
401	u_long		proc;		/* procedure number */
402	xdrproc_t	xargs;		/* xdr routine for args */
403	void	       *argsp;		/* pointer to args */
404	xdrproc_t	xresults;	/* xdr routine for results */
405	void	       *resultsp;	/* pointer to results */
406	resultproc_t	eachresult;	/* call with each result obtained */
407{
408
409	if (thr_main())
410		clnt_broadcast_result_main = eachresult;
411	else {
412		thr_once(&clnt_broadcast_once, clnt_broadcast_key_init);
413		thr_setspecific(clnt_broadcast_key, (void *) eachresult);
414	}
415	return rpc_broadcast((rpcprog_t)prog, (rpcvers_t)vers,
416	    (rpcproc_t)proc, xargs, argsp, xresults, resultsp,
417	    (resultproc_t) rpc_wrap_bcast, "udp");
418}
419
420/*
421 * Create the client des authentication object. Obsoleted by
422 * authdes_seccreate().
423 */
424AUTH *
425authdes_create(servername, window, syncaddr, ckey)
426	char *servername;		/* network name of server */
427	u_int window;			/* time to live */
428	struct sockaddr *syncaddr;	/* optional hostaddr to sync with */
429	des_block *ckey;		/* optional conversation key to use */
430{
431	AUTH *dummy;
432	AUTH *nauth;
433	char hostname[NI_MAXHOST];
434
435	if (syncaddr) {
436		/*
437		 * Change addr to hostname, because that is the way
438		 * new interface takes it.
439		 */
440		if (getnameinfo(syncaddr, syncaddr->sa_len, hostname,
441		    sizeof hostname, NULL, 0, 0) != 0)
442			goto fallback;
443
444		nauth = authdes_seccreate(servername, window, hostname, ckey);
445		return (nauth);
446	}
447fallback:
448	dummy = authdes_seccreate(servername, window, NULL, ckey);
449	return (dummy);
450}
451
452/*
453 * Create a client handle for a unix connection. Obsoleted by clnt_vc_create()
454 */
455CLIENT *
456clntunix_create(raddr, prog, vers, sockp, sendsz, recvsz)
457	struct sockaddr_un *raddr;
458	u_long prog;
459	u_long vers;
460	int *sockp;
461	u_int sendsz;
462	u_int recvsz;
463{
464	struct netbuf *svcaddr;
465	struct netconfig *nconf;
466	CLIENT *cl;
467	int len;
468
469	cl = NULL;
470	nconf = NULL;
471	svcaddr = NULL;
472	if ((raddr->sun_len == 0) ||
473	   ((svcaddr = malloc(sizeof(struct netbuf))) == NULL ) ||
474	   ((svcaddr->buf = malloc(sizeof(struct sockaddr_un))) == NULL)) {
475		if (svcaddr != NULL)
476			free(svcaddr);
477		rpc_createerr.cf_stat = RPC_SYSTEMERROR;
478		rpc_createerr.cf_error.re_errno = errno;
479		return(cl);
480	}
481	if (*sockp < 0) {
482		*sockp = _socket(AF_LOCAL, SOCK_STREAM, 0);
483		len = raddr->sun_len = SUN_LEN(raddr);
484		if ((*sockp < 0) || (_connect(*sockp,
485		    (struct sockaddr *)raddr, len) < 0)) {
486			rpc_createerr.cf_stat = RPC_SYSTEMERROR;
487			rpc_createerr.cf_error.re_errno = errno;
488			if (*sockp != -1)
489				(void)_close(*sockp);
490			goto done;
491		}
492	}
493	svcaddr->buf = raddr;
494	svcaddr->len = raddr->sun_len;
495	svcaddr->maxlen = sizeof (struct sockaddr_un);
496	cl = clnt_vc_create(*sockp, svcaddr, prog,
497	    vers, sendsz, recvsz);
498done:
499	free(svcaddr->buf);
500	free(svcaddr);
501	return(cl);
502}
503
504/*
505 * Creates, registers, and returns a (rpc) unix based transporter.
506 * Obsoleted by svc_vc_create().
507 */
508SVCXPRT *
509svcunix_create(sock, sendsize, recvsize, path)
510	int sock;
511	u_int sendsize;
512	u_int recvsize;
513	char *path;
514{
515	struct netconfig *nconf;
516	void *localhandle;
517	struct sockaddr_un sun;
518	struct sockaddr *sa;
519	struct t_bind taddr;
520	SVCXPRT *xprt;
521	int addrlen;
522
523	xprt = (SVCXPRT *)NULL;
524	localhandle = setnetconfig();
525	while ((nconf = getnetconfig(localhandle)) != NULL) {
526		if (nconf->nc_protofmly != NULL &&
527		    strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0)
528			break;
529	}
530	if (nconf == NULL)
531		return(xprt);
532
533	if ((sock = __rpc_nconf2fd(nconf)) < 0)
534		goto done;
535
536	memset(&sun, 0, sizeof sun);
537	sun.sun_family = AF_LOCAL;
538	if (strlcpy(sun.sun_path, path, sizeof(sun.sun_path)) >=
539	    sizeof(sun.sun_path))
540		goto done;
541	sun.sun_len = SUN_LEN(&sun);
542	addrlen = sizeof (struct sockaddr_un);
543	sa = (struct sockaddr *)&sun;
544
545	if (_bind(sock, sa, addrlen) < 0)
546		goto done;
547
548	taddr.addr.len = taddr.addr.maxlen = addrlen;
549	taddr.addr.buf = malloc(addrlen);
550	if (taddr.addr.buf == NULL)
551		goto done;
552	memcpy(taddr.addr.buf, sa, addrlen);
553
554	if (nconf->nc_semantics != NC_TPI_CLTS) {
555		if (_listen(sock, SOMAXCONN) < 0) {
556			free(taddr.addr.buf);
557			goto done;
558		}
559	}
560
561	xprt = (SVCXPRT *)svc_tli_create(sock, nconf, &taddr, sendsize, recvsize);
562
563done:
564	endnetconfig(localhandle);
565	return(xprt);
566}
567
568/*
569 * Like svunix_create(), except the routine takes any *open* UNIX file
570 * descriptor as its first input. Obsoleted by svc_fd_create();
571 */
572SVCXPRT *
573svcunixfd_create(fd, sendsize, recvsize)
574	int fd;
575	u_int sendsize;
576	u_int recvsize;
577{
578 	return (svc_fd_create(fd, sendsize, recvsize));
579}
580
581#endif /* PORTMAP */
582