ReactOS 0.4.15-dev-7958-gcd0bb1a
pmap_clnt.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009, Sun Microsystems, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * - Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.
9 * - Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12 * - Neither the name of Sun Microsystems, Inc. nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29//#include <sys/cdefs.h>
30
31/*
32 * pmap_clnt.c
33 * Client interface to pmap rpc service.
34 *
35 * Copyright (C) 1984, Sun Microsystems, Inc.
36 */
37
38#include <wintirpc.h>
39#include <sys/types.h>
40#include <sys/stat.h>
41//#include <unistd.h>
42
43#include <rpc/rpc.h>
44#include <rpc/pmap_prot.h>
45#include <rpc/pmap_clnt.h>
46#include <rpc/nettype.h>
47//#include <netinet/in.h>
48
49#include <stdio.h>
50#include <stdlib.h>
51
52#include "rpc_com.h"
53
56{
57 bool_t rslt;
58 struct netbuf *na;
59 struct netconfig *nconf;
60 char buf[32];
61
62 if ((protocol != IPPROTO_UDP) && (protocol != IPPROTO_TCP)) {
63 return (FALSE);
64 }
65 nconf = __rpc_getconfip(protocol == IPPROTO_UDP ? "udp" : "tcp");
66 if (nconf == NULL) {
67 return (FALSE);
68 }
69 snprintf(buf, sizeof buf, "0.0.0.0.%d.%d",
70 (((u_int32_t)port) >> 8) & 0xff, port & 0xff);
71 na = uaddr2taddr(nconf, buf);
72 if (na == NULL) {
73 freenetconfigent(nconf);
74 return (FALSE);
75 }
76 rslt = rpcb_set((rpcprog_t)program, (rpcvers_t)version, nconf, na);
77 free(na);
78 freenetconfigent(nconf);
79 return (rslt);
80}
81
82/*
83 * Remove the mapping between program, version and port.
84 * Calls the pmap service remotely to do the un-mapping.
85 */
88{
89 struct netconfig *nconf;
90 bool_t udp_rslt = FALSE;
91 bool_t tcp_rslt = FALSE;
92
93 nconf = __rpc_getconfip("udp");
94 if (nconf != NULL) {
96 nconf);
97 freenetconfigent(nconf);
98 }
99 nconf = __rpc_getconfip("tcp");
100 if (nconf != NULL) {
102 nconf);
103 freenetconfigent(nconf);
104 }
105 /*
106 * XXX: The call may still succeed even if only one of the
107 * calls succeeded. This was the best that could be
108 * done for backward compatibility.
109 */
110 return (tcp_rslt || udp_rslt);
111}
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112
u_int32_t rpcprog_t
Definition: types.h:104
int32_t bool_t
Definition: types.h:101
#define FALSE
Definition: types.h:117
u_int32_t rpcvers_t
Definition: types.h:105
static const WCHAR version[]
Definition: asmname.c:66
USHORT port
Definition: uri.c:228
#define IPPROTO_TCP
Definition: ip.h:196
#define IPPROTO_UDP
Definition: ip.h:197
unsigned long u_long
Definition: linux.h:269
void freenetconfigent(struct netconfig *netconfigp)
Definition: getnetconfig.c:530
GLuint program
Definition: glext.h:6723
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
bool_t pmap_set(u_long program, u_long version, int protocol, int port)
Definition: pmap_clnt.c:55
bool_t pmap_unset(u_long program, u_long version)
Definition: pmap_clnt.c:87
unsigned int u_int32_t
Definition: rosdhcp.h:35
struct netconfig * __rpc_getconfip(char *nettype) const
Definition: rpc_generic.c:235
struct netbuf * uaddr2taddr(const struct netconfig *nconf, const char *uaddr)
Definition: rpc_generic.c:619
bool_t rpcb_unset(rpcprog_t program, rpcvers_t version, const struct netconfig *nconf)
Definition: rpcb_clnt.c:581
bool_t rpcb_set(rpcprog_t program, rpcvers_t version, const struct netconfig *nconf, const struct netbuf *address)
Definition: rpcb_clnt.c:520
Definition: types.h:144
#define snprintf
Definition: wintirpc.h:48