ReactOS 0.4.15-dev-7788-g1ad9096
rpc.h File Reference
#include <rpc/types.h>
#include "winsock2.h"
#include <rpc/xdr.h>
#include <rpc/auth.h>
#include <rpc/clnt.h>
#include <rpc/rpc_msg.h>
#include <rpc/auth_unix.h>
#include <rpc/auth_des.h>
#include <rpc/svc_auth.h>
#include <rpc/svc.h>
#include <rpc/pmap_clnt.h>
#include <rpc/pmap_prot.h>
#include <rpc/rpcb_clnt.h>
#include <rpc/rpcent.h>
Include dependency graph for rpc.h:

Go to the source code of this file.

Macros

#define UDPMSGSIZE   8800
 

Functions

__BEGIN_DECLS int get_myaddress (struct sockaddr_in *)
 
int bindresvport (SOCKET, struct sockaddr_in *) __THROW
 
int registerrpc (int, int, int, char *(*)(char[UDPMSGSIZE]), xdrproc_t, xdrproc_t)
 
int callrpc (const char *, int, int, int, xdrproc_t, void *, xdrproc_t, void *)
 
int getrpcport (char *, int, int, int)
 
chartaddr2uaddr (const struct netconfig *, const struct netbuf *)
 
struct netbufuaddr2taddr (const struct netconfig *, const char *)
 
void freeuaddr (char *)
 
void freenetbuf (struct netbuf *)
 
int bindresvport_sa (SOCKET, struct sockaddr *)
 
__END_DECLS __BEGIN_DECLS SOCKET __rpc_nconf2fd (const struct netconfig *)
 
int __rpc_nconf2sockinfo (const struct netconfig *, struct __rpc_sockinfo *)
 
int __rpc_fd2sockinfo (SOCKET, struct __rpc_sockinfo *)
 
u_int __rpc_get_t_size (int, int, int)
 

Macro Definition Documentation

◆ UDPMSGSIZE

#define UDPMSGSIZE   8800

Definition at line 80 of file rpc.h.

Function Documentation

◆ __rpc_fd2sockinfo()

int __rpc_fd2sockinfo ( SOCKET  fd,
struct __rpc_sockinfo sip 
)

Definition at line 481 of file rpc_generic.c.

482{
484 int type, proto;
485 struct sockaddr_storage ss;
486
487#ifdef _WIN32
488 WSAPROTOCOL_INFO proto_info;
489 int proto_info_size = sizeof(proto_info);
490 if (getsockopt(fd, SOL_SOCKET, SO_PROTOCOL_INFO, (char *)&proto_info, &proto_info_size) == SOCKET_ERROR) {
491#ifndef __REACTOS__
492 int err = WSAGetLastError();
493#endif
494 return 0;
495 }
496 len = proto_info.iMaxSockAddr;
497 ss.ss_family = (ADDRESS_FAMILY)proto_info.iAddressFamily;
498#else
499 len = sizeof ss;
500 if (getsockname(fd, (struct sockaddr *)&ss, &len) == SOCKET_ERROR) {
501 return 0;
502 }
503#endif
504 sip->si_alen = len;
505
506 len = sizeof type;
507 if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&type, &len) == SOCKET_ERROR) {
508#ifndef __REACTOS__
509 int err = WSAGetLastError();
510#endif
511 return 0;
512 }
513
514 /* XXX */
515#ifdef AF_LOCAL
516 if (ss.ss_family != AF_LOCAL) {
517#endif
518 if (type == SOCK_STREAM)
520 else if (type == SOCK_DGRAM)
522 else
523 return 0;
524#ifdef AF_LOCAL
525 } else
526 proto = 0;
527#endif
528
529 sip->si_af = ss.ss_family;
530 sip->si_proto = proto;
531 sip->si_socktype = type;
532
533 return 1;
534}
#define IPPROTO_TCP
Definition: ip.h:196
#define IPPROTO_UDP
Definition: ip.h:197
#define SOCK_STREAM
Definition: tcpip.h:118
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLenum GLsizei len
Definition: glext.h:6722
#define ss
Definition: i386-dis.c:441
if(dx< 0)
Definition: linetemp.h:194
int socklen_t
Definition: tcp.c:35
#define err(...)
static int fd
Definition: io.c:51
INT WSAAPI getsockname(IN SOCKET s, OUT LPSOCKADDR name, IN OUT INT FAR *namelen)
Definition: sockctrl.c:213
INT WSAAPI getsockopt(IN SOCKET s, IN INT level, IN INT optname, OUT CHAR FAR *optval, IN OUT INT FAR *optlen)
Definition: sockctrl.c:271
int si_socktype
Definition: types.h:167
int si_alen
Definition: types.h:168
ADDRESS_FAMILY si_af
Definition: types.h:165
int si_proto
Definition: types.h:166
#define SO_PROTOCOL_INFO
Definition: winsock2.h:253
int PASCAL FAR WSAGetLastError(void)
Definition: dllmain.c:112
#define SOCK_DGRAM
Definition: winsock.h:336
#define SOCKET_ERROR
Definition: winsock.h:333
#define SO_TYPE
Definition: winsock.h:195
#define SOL_SOCKET
Definition: winsock.h:398
USHORT ADDRESS_FAMILY
Definition: ws2def.h:25

Referenced by __rpcgettp(), clnt_dg_create(), clnt_tli_create(), clnt_vc_create(), makefd_xprt(), rendezvous_request(), rpc_reg(), svc_dg_create(), svc_tli_create(), and svc_vc_create().

◆ __rpc_get_t_size()

u_int __rpc_get_t_size ( int  af,
int  proto,
int  size 
)

Definition at line 139 of file rpc_generic.c.

142{
143 int maxsize, defsize;
144
145 maxsize = 256 * 1024; /* XXX */
146 switch (proto) {
147 case IPPROTO_TCP:
148 defsize = 1024 * 1024; /* XXX */
149 break;
150 case IPPROTO_UDP:
151 defsize = UDPMSGSIZE;
152 break;
153 default:
154 defsize = RPC_MAXDATASIZE;
155 break;
156 }
157 if (size == 0)
158 return defsize;
159#if 1
160 /* cbodley- give us the size we ask for, or we'll get fragmented! */
161 return (u_int)size;
162#else
163 /* Check whether the value is within the upper max limit */
164 return (size > maxsize ? (u_int)maxsize : (u_int)size);
165#endif
166}
UINT32 u_int
Definition: types.h:82
GLsizeiptr size
Definition: glext.h:5919
#define RPC_MAXDATASIZE
Definition: rpc_com.h:51
#define UDPMSGSIZE
Definition: svc_raw.c:49

Referenced by clnt_dg_create(), clnt_vc_create(), local_rpcb(), rpc_broadcast_exp(), rpc_reg(), svc_dg_create(), and svc_vc_create().

◆ __rpc_nconf2fd()

__END_DECLS __BEGIN_DECLS SOCKET __rpc_nconf2fd ( const struct netconfig nconf)

Definition at line 562 of file rpc_generic.c.

563{
564 struct __rpc_sockinfo si;
565 SOCKET fd;
566
567 if (!__rpc_nconf2sockinfo(nconf, &si))
568 return 0;
569
570 if ((fd = socket(si.si_af, si.si_socktype, si.si_proto)) != INVALID_SOCKET &&
571 si.si_af == AF_INET6) {
572 int val = 1;
573
574 setsockopt(fd, SOL_IPV6, IPV6_V6ONLY, (const char *)&val, sizeof(val));
575 }
576 return fd;
577}
GLuint GLfloat * val
Definition: glext.h:7180
int __rpc_nconf2sockinfo(const struct netconfig *nconf, struct __rpc_sockinfo *sip)
Definition: rpc_generic.c:540
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
Definition: sockctrl.c:421
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
#define INVALID_SOCKET
Definition: winsock.h:332
UINT_PTR SOCKET
Definition: winsock.h:47
#define AF_INET6
Definition: winsock.h:369
#define SOL_IPV6
Definition: wintirpc.h:84
#define IPV6_V6ONLY
Definition: ws2ipdef.h:108

Referenced by clnt_tli_create(), and svc_tli_create().

◆ __rpc_nconf2sockinfo()

int __rpc_nconf2sockinfo ( const struct netconfig nconf,
struct __rpc_sockinfo sip 
)

Definition at line 540 of file rpc_generic.c.

541{
542 int i;
543
544 for (i = 0; i < (sizeof na_cvt) / (sizeof (struct netid_af)); i++)
545 if (strcmp(na_cvt[i].netid, nconf->nc_netid) == 0 || (
546 strcmp(nconf->nc_netid, "unix") == 0 &&
547 strcmp(na_cvt[i].netid, "local") == 0)) {
548 sip->si_af = na_cvt[i].af;
549 sip->si_proto = na_cvt[i].protocol;
550 sip->si_socktype =
552 if (sip->si_socktype == -1)
553 return 0;
554 sip->si_alen = __rpc_get_a_size(sip->si_af);
555 return 1;
556 }
557
558 return 0;
559}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static const struct netid_af na_cvt[]
Definition: rpc_generic.c:88
int __rpc_seman2socktype(int semantics)
Definition: rpc_generic.c:842
u_int __rpc_get_a_size(int af)
Definition: rpc_generic.c:172
unsigned long nc_semantics
Definition: netconfig.h:17
char * nc_netid
Definition: netconfig.h:16

Referenced by __rpc_nconf2fd(), getclnthandle(), rpc_broadcast_exp(), svc_tli_create(), taddr2uaddr(), and uaddr2taddr().

◆ bindresvport()

int bindresvport ( SOCKET  sd,
struct sockaddr_in sin 
)

Definition at line 53 of file bindresvport.c.

56{
57 return bindresvport_sa(sd, (struct sockaddr *)sin);
58}
_STLP_DECLSPEC complex< float > _STLP_CALL sin(const complex< float > &)
int bindresvport_sa(SOCKET sd, struct sockaddr *sa)
Definition: bindresvport.c:161
static const WCHAR sd[]
Definition: suminfo.c:286

Referenced by clnt_tli_create(), and svc_tli_create().

◆ bindresvport_sa()

int bindresvport_sa ( SOCKET  sd,
struct sockaddr sa 
)

Definition at line 161 of file bindresvport.c.

164{
165#ifdef IPV6_PORTRANGE
166 int old;
167#endif
168 int error, af;
169 struct sockaddr_storage myaddr;
170 struct sockaddr_in *sin;
171#ifdef INET6
172 struct sockaddr_in6 *sin6;
173#endif
174 int proto, portrange, portlow;
175 u_int16_t *portp;
176 socklen_t salen;
177#ifdef _WIN32
178 WSAPROTOCOL_INFO proto_info;
179 int proto_info_size = sizeof(proto_info);
180#endif
181
182 if (sa == NULL) {
183 salen = sizeof(myaddr);
184 sa = (struct sockaddr *)&myaddr;
185
186#ifdef _WIN32
187 memset(sa, 0, salen);
188 if (error = getsockopt(sd, SOL_SOCKET, SO_PROTOCOL_INFO, (char *)&proto_info, &proto_info_size) == SOCKET_ERROR) {
189#ifndef __REACTOS__
190 int sockerr = WSAGetLastError();
191#endif
192 return -1;
193 }
194 af = proto_info.iAddressFamily;
195#else
196 if (getsockname(sd, sa, &salen) == -1)
197 return -1; /* errno is correctly set */
198
199 af = sa->sa_family;
200 memset(sa, 0, salen);
201#endif
202 } else
203 af = sa->sa_family;
204
205 switch (af) {
206 case AF_INET:
208 portrange = IP_PORTRANGE;
209 portlow = IP_PORTRANGE_LOW;
210 sin = (struct sockaddr_in *)sa;
211 salen = sizeof(struct sockaddr_in);
212 portp = &sin->sin_port;
213 break;
214#ifdef INET6
215 case AF_INET6:
216 proto = IPPROTO_IPV6;
217#ifdef IPV6_PORTRANGE
218 portrange = IPV6_PORTRANGE;
219 portlow = IPV6_PORTRANGE_LOW;
220#endif
221 sin6 = (struct sockaddr_in6 *)sa;
222 salen = sizeof(struct sockaddr_in6);
223 portp = &sin6->sin6_port;
224 break;
225#endif /* INET6 */
226 default:
228 return (-1);
229 }
230 sa->sa_family = (ADDRESS_FAMILY) af;
231
232#ifdef IPV6_PORTRANGE
233 if (*portp == 0) {
234 socklen_t oldlen = sizeof(old);
235
236 error = getsockopt(sd, proto, portrange, &old, &oldlen);
237 if (error < 0)
238 return (error);
239
240 error = setsockopt(sd, proto, portrange, &portlow,
241 sizeof(portlow));
242 if (error < 0)
243 return (error);
244 }
245#endif
246
247 error = bind(sd, sa, salen);
248 if (error) {
249#ifndef __REACTOS__
250 int err = WSAGetLastError();
251#endif
252 }
253
254#ifdef IPV6_PORTRANGE
255 if (*portp == 0) {
256 int saved_errno = errno;
257
258 if (error < 0) {
259 if (setsockopt(sd, proto, portrange, &old,
260 sizeof(old)) < 0)
261 errno = saved_errno;
262 return (error);
263 }
264
265 if (sa != (struct sockaddr *)&myaddr) {
266 /* Hmm, what did the kernel assign? */
267 if (getsockname(sd, sa, &salen) < 0)
268 errno = saved_errno;
269 return (error);
270 }
271 }
272#endif
273 return (error);
274}
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
#define IP_PORTRANGE
Definition: bindresvport.c:154
#define IP_PORTRANGE_LOW
Definition: bindresvport.c:155
#define NULL
Definition: types.h:112
#define AF_INET
Definition: tcpip.h:117
#define error(str)
Definition: mkdosfs.c:1605
unsigned short u_int16_t
Definition: rosdhcp.h:34
#define errno
Definition: errno.h:18
#define memset(x, y, z)
Definition: compat.h:39
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36
USHORT sin6_port
Definition: ws2ipdef.h:180
#define WSAEPFNOSUPPORT
Definition: winerror.h:1959
#define IPPROTO_IP
Definition: winsock.h:255

Referenced by bindresvport(), and clnt_dg_create().

◆ callrpc()

int callrpc ( const char ,
int  ,
int  ,
int  ,
xdrproc_t  ,
void ,
xdrproc_t  ,
void  
)

◆ freenetbuf()

void freenetbuf ( struct netbuf nbuf)

Definition at line 633 of file rpc_generic.c.

634{
635 if (nbuf) {
636 free(nbuf->buf);
637 free(nbuf);
638 }
639}
#define free
Definition: debug_ros.c:5
void * buf
Definition: types.h:147

Referenced by get_client_for_netaddr().

◆ freeuaddr()

void freeuaddr ( char uaddr)

Definition at line 628 of file rpc_generic.c.

629{
630 free(uaddr);
631}

Referenced by nfs41_server_resolve().

◆ get_myaddress()

__BEGIN_DECLS int get_myaddress ( struct sockaddr_in )

◆ getrpcport()

int getrpcport ( char host,
int  prognum,
int  versnum,
int  proto 
)

Definition at line 47 of file getrpcport.c.

50{
51 struct sockaddr_in addr;
52 struct hostent *hp;
53
54 assert(host != NULL);
55
56 if ((hp = gethostbyname(host)) == NULL)
57 return (0);
58 memset(&addr, 0, sizeof(addr));
59 addr.sin_family = AF_INET;
60 addr.sin_port = 0;
61 if (hp->h_length > sizeof(addr))
62 hp->h_length = sizeof(addr);
63 memcpy(&addr.sin_addr.s_addr, hp->h_addr, (size_t)hp->h_length);
64 /* Inconsistent interfaces need casts! :-( */
65 return (pmap_getport(&addr, (u_long)prognum, (u_long)versnum,
66 (u_int)proto));
67}
#define assert(x)
Definition: debug.h:53
unsigned long u_long
Definition: linux.h:269
PHOSTENT WSAAPI gethostbyname(IN const char FAR *name)
Definition: getxbyxx.c:221
GLenum const GLvoid * addr
Definition: glext.h:9621
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
u_short pmap_getport(struct sockaddr_in *address, u_long program, u_long version, u_int protocol)
Definition: pmap_getport.c:74
short h_length
Definition: winsock.h:137
char * host
Definition: whois.c:55

◆ registerrpc()

int registerrpc ( int  ,
int  ,
int  ,
char *)(char[UDPMSGSIZE],
xdrproc_t  ,
xdrproc_t   
)

◆ taddr2uaddr()

char * taddr2uaddr ( const struct netconfig nconf,
const struct netbuf nbuf 
)

Definition at line 609 of file rpc_generic.c.

610{
611 struct __rpc_sockinfo si;
612
613 if (!__rpc_nconf2sockinfo(nconf, &si))
614 return NULL;
615 return __rpc_taddr2uaddr_af(si.si_af, nbuf);
616}
char * __rpc_taddr2uaddr_af(int af, const struct netbuf *nbuf)
Definition: rpc_generic.c:663

Referenced by cache_get(), cache_set(), getclnthandle(), nfs41_server_resolve(), and rpcb_set().

◆ uaddr2taddr()

struct netbuf * uaddr2taddr ( const struct netconfig nconf,
const char uaddr 
)

Definition at line 619 of file rpc_generic.c.

620{
621 struct __rpc_sockinfo si;
622
623 if (!__rpc_nconf2sockinfo(nconf, &si))
624 return NULL;
625 return __rpc_uaddr2taddr_af(si.si_af, uaddr);
626}
struct netbuf * __rpc_uaddr2taddr_af(int af, const char *uaddr)
Definition: rpc_generic.c:734

Referenced by __rpcb_findaddr_timed(), get_client_for_netaddr(), pmap_set(), and rpc_broadcast_exp().