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