Path: blob/main/crypto/krb5/src/lib/rpc/pmap_getmaps.c
39536 views
/* @(#)pmap_getmaps.c 2.2 88/08/01 4.0 RPCSRC */1/*2* Copyright (c) 2010, Oracle America, Inc.3*4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions are met:8*9* * Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11*12* * Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in14* the documentation and/or other materials provided with the15* distribution.16*17* * Neither the name of the "Oracle America, Inc." nor the names of18* its contributors may be used to endorse or promote products19* derived from this software without specific prior written permission.20*21* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS22* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED23* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A24* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT25* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,26* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED27* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR28* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF29* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING30* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS31* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.32*/33#if !defined(lint) && defined(SCCSIDS)34static char sccsid[] = "@(#)pmap_getmaps.c 1.10 87/08/11 Copyr 1984 Sun Micro";35#endif3637/*38* pmap_getmap.c39* Client interface to pmap rpc service.40* contains pmap_getmaps, which is only tcp service involved41*/4243#include <gssrpc/rpc.h>44#include <gssrpc/pmap_prot.h>45#include <gssrpc/pmap_clnt.h>46#include <sys/socket.h>47#include <netdb.h>48#include <stdio.h>49#include <unistd.h>50#include <errno.h>51#ifdef OSF152#include <net/route.h>53#include <sys/mbuf.h>54#endif55#include <net/if.h>56#include <sys/ioctl.h>57#define NAMELEN 25558#define MAX_BROADCAST_SIZE 1400596061/*62* Get a copy of the current port maps.63* Calls the pmap service remotely to do get the maps.64*/65struct pmaplist *66pmap_getmaps(struct sockaddr_in *address)67{68struct pmaplist *head = (struct pmaplist *)NULL;69int sock = -1;70struct timeval minutetimeout;71CLIENT *client;7273minutetimeout.tv_sec = 60;74minutetimeout.tv_usec = 0;75address->sin_port = htons(PMAPPORT);76client = clnttcp_create(address, PMAPPROG,77PMAPVERS, &sock, 50, 500);78if (client != (CLIENT *)NULL) {79if (CLNT_CALL(client, PMAPPROC_DUMP, xdr_void, NULL,80(xdrproc_t)xdr_pmaplist, &head,81minutetimeout) != RPC_SUCCESS) {82clnt_perror(client, "pmap_getmaps rpc problem");83}84CLNT_DESTROY(client);85}86(void)close(sock);87address->sin_port = 0;88return (head);89}909192