ReactOS 0.4.15-dev-7958-gcd0bb1a
clnt_bcast.c File Reference
#include <wintirpc.h>
#include <sys/types.h>
#include <rpc/rpc.h>
#include <rpc/nettype.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include "rpc_com.h"
Include dependency graph for clnt_bcast.c:

Go to the source code of this file.

Classes

struct  broadif
 

Macros

#define MAXBCAST   20 /* Max no of broadcasting transports */
 
#define INITTIME   4000 /* Time to wait initially */
 
#define WAITTIME   8000 /* Maximum time to wait */
 
#define POLLRDNORM   0x040 /* Normal data may be read. */
 
#define POLLRDBAND   0x080 /* Priority data may be read. */
 
#define TAILQ_NEXT(elm, field)   ((elm)->field.tqe_next)
 
#define TAILQ_FIRST(head)   ((head)->tqh_first)
 

Functions

typedef TAILQ_HEAD (broadif)
 
void __rpc_freebroadifs (broadlist_t *list)
 
int __rpc_broadenable (int af, int s, struct broadif *bip)
 
enum clnt_stat rpc_broadcast_exp (rpcprog_t prog, rpcvers_t vers, rpcproc_t proc, xdrproc_t xargs, caddr_t argsp, xdrproc_t xresults, caddr_t resultsp, resultproc_t eachresult, int inittime, int waittime, const char *nettype)
 
enum clnt_stat rpc_broadcast (rpcprog_t prog, rpcvers_t vers, rpcproc_t proc, xdrproc_t xargs, caddr_t argsp, xdrproc_t xresults, caddr_t resultsp, resultproc_t eachresult, const char *nettype)
 

Macro Definition Documentation

◆ INITTIME

#define INITTIME   4000 /* Time to wait initially */

Definition at line 76 of file clnt_bcast.c.

◆ MAXBCAST

#define MAXBCAST   20 /* Max no of broadcasting transports */

Definition at line 75 of file clnt_bcast.c.

◆ POLLRDBAND

#define POLLRDBAND   0x080 /* Priority data may be read. */

Definition at line 83 of file clnt_bcast.c.

◆ POLLRDNORM

#define POLLRDNORM   0x040 /* Normal data may be read. */

Definition at line 80 of file clnt_bcast.c.

◆ TAILQ_FIRST

#define TAILQ_FIRST (   head)    ((head)->tqh_first)

Definition at line 136 of file clnt_bcast.c.

◆ TAILQ_NEXT

#define TAILQ_NEXT (   elm,
  field 
)    ((elm)->field.tqe_next)

Definition at line 134 of file clnt_bcast.c.

◆ WAITTIME

#define WAITTIME   8000 /* Maximum time to wait */

Definition at line 77 of file clnt_bcast.c.

Function Documentation

◆ __rpc_broadenable()

int __rpc_broadenable ( int  af,
int  s,
struct broadif bip 
)

Definition at line 244 of file clnt_bcast.c.

245{
246 int o = 1;
247
248#if 0
249 if (af == AF_INET6) {
250 fprintf(stderr, "set v6 multicast if to %d\n", bip->index);
251 if (setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_IF, &bip->index,
252 sizeof bip->index) < 0)
253 return -1;
254 } else
255#endif
256 if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &o, sizeof o) == SOCKET_ERROR)
257 return -1;
258
259 return 0;
260}
GLdouble s
Definition: gl.h:2039
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
Definition: sockctrl.c:421
int index
Definition: clnt_bcast.c:140
#define SOCKET_ERROR
Definition: winsock.h:333
#define SOL_SOCKET
Definition: winsock.h:398
#define AF_INET6
Definition: winsock.h:369
#define SO_BROADCAST
Definition: winsock.h:183
#define IPV6_MULTICAST_IF
Definition: ws2ipdef.h:94

Referenced by rpc_broadcast_exp().

◆ __rpc_freebroadifs()

void __rpc_freebroadifs ( broadlist_t *  list)

Definition at line 229 of file clnt_bcast.c.

230{
231 struct broadif *bip, *next;
232
233 bip = TAILQ_FIRST(list);
234
235 while (bip != NULL) {
236 next = TAILQ_NEXT(bip, link);
237 free(bip);
238 bip = next;
239 }
240}
Definition: list.h:37
#define TAILQ_FIRST(head)
Definition: clnt_bcast.c:136
#define TAILQ_NEXT(elm, field)
Definition: clnt_bcast.c:134
const WCHAR * link
Definition: db.cpp:997
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112
static unsigned __int64 next
Definition: rand_nt.c:6

Referenced by rpc_broadcast_exp().

◆ rpc_broadcast()

enum clnt_stat rpc_broadcast ( rpcprog_t  prog,
rpcvers_t  vers,
rpcproc_t  proc,
xdrproc_t  xargs,
caddr_t  argsp,
xdrproc_t  xresults,
caddr_t  resultsp,
resultproc_t  eachresult,
const char nettype 
)

Definition at line 687 of file clnt_bcast.c.

698{
699 enum clnt_stat dummy;
700
701 dummy = rpc_broadcast_exp(prog, vers, proc, xargs, argsp,
702 xresults, resultsp, eachresult,
703 INITTIME, WAITTIME, nettype);
704 return (dummy);
705}
enum clnt_stat rpc_broadcast_exp(rpcprog_t prog, rpcvers_t vers, rpcproc_t proc, xdrproc_t xargs, caddr_t argsp, xdrproc_t xresults, caddr_t resultsp, resultproc_t eachresult, int inittime, int waittime, const char *nettype)
Definition: clnt_bcast.c:264
#define INITTIME
Definition: clnt_bcast.c:76
#define WAITTIME
Definition: clnt_bcast.c:77
clnt_stat
Definition: clnt_stat.h:21
char * prog
Definition: isohybrid.c:47
static HANDLE proc()
Definition: pdb.c:34

◆ rpc_broadcast_exp()

enum clnt_stat rpc_broadcast_exp ( rpcprog_t  prog,
rpcvers_t  vers,
rpcproc_t  proc,
xdrproc_t  xargs,
caddr_t  argsp,
xdrproc_t  xresults,
caddr_t  resultsp,
resultproc_t  eachresult,
int  inittime,
int  waittime,
const char nettype 
)

Definition at line 264 of file clnt_bcast.c.

277{
278 enum clnt_stat stat = RPC_SUCCESS; /* Return status */
279 XDR xdr_stream; /* XDR stream */
280 XDR *xdrs = &xdr_stream;
281 struct rpc_msg msg; /* RPC message */
282 struct timeval t;
283 char *outbuf = NULL; /* Broadcast msg buffer */
284 char *inbuf = NULL; /* Reply buf */
285 int inlen;
286 u_int maxbufsize = 0;
287 AUTH *sys_auth = authunix_create_default();
288 int i;
289 void *handle;
290 char uaddress[1024]; /* A self imposed limit */
291 char *uaddrp = uaddress;
292 int pmap_reply_flag; /* reply recvd from PORTMAP */
293 /* An array of all the suitable broadcast transports */
294 struct {
295 int fd; /* File descriptor */
296 int af;
297 int proto;
298 struct netconfig *nconf; /* Netconfig structure */
299 u_int asize; /* Size of the addr buf */
300 u_int dsize; /* Size of the data buf */
301 struct sockaddr_storage raddr; /* Remote address */
302 broadlist_t nal;
303 } fdlist[MAXBCAST];
304 struct pollfd pfd[MAXBCAST];
305 size_t fdlistno = 0;
306 struct r_rpcb_rmtcallargs barg; /* Remote arguments */
307 struct r_rpcb_rmtcallres bres; /* Remote results */
308 size_t outlen;
309 struct netconfig *nconf;
310 int msec;
311 int pollretval;
312 int fds_found;
313
314#ifdef PORTMAP
315 size_t outlen_pmap = 0;
316 u_long port; /* Remote port number */
317 int pmap_flag = 0; /* UDP exists ? */
318 char *outbuf_pmap = NULL;
319 struct rmtcallargs barg_pmap; /* Remote arguments */
320 struct rmtcallres bres_pmap; /* Remote results */
321 u_int udpbufsz = 0;
322#endif /* PORTMAP */
323
324 if (sys_auth == NULL) {
325 return (RPC_SYSTEMERROR);
326 }
327 /*
328 * initialization: create a fd, a broadcast address, and send the
329 * request on the broadcast transport.
330 * Listen on all of them and on replies, call the user supplied
331 * function.
332 */
333
334 if (nettype == NULL)
335 nettype = "datagram_n";
336 if ((handle = __rpc_setconf(nettype)) == NULL) {
337 return (RPC_UNKNOWNPROTO);
338 }
339 while ((nconf = __rpc_getconf(handle)) != NULL) {
340 int fd;
341 struct __rpc_sockinfo si;
342
343 if (nconf->nc_semantics != NC_TPI_CLTS)
344 continue;
345 if (fdlistno >= MAXBCAST)
346 break; /* No more slots available */
347 if (!__rpc_nconf2sockinfo(nconf, &si))
348 continue;
349
350 TAILQ_INIT(&fdlist[fdlistno].nal);
351 if (__rpc_getbroadifs(si.si_af, si.si_proto, si.si_socktype,
352 &fdlist[fdlistno].nal) == 0)
353 continue;
354
355 fd = socket(si.si_af, si.si_socktype, si.si_proto);
356 if (fd == INVALID_SOCKET) {
358 continue;
359 }
360 fdlist[fdlistno].af = si.si_af;
361 fdlist[fdlistno].proto = si.si_proto;
362 fdlist[fdlistno].fd = fd;
363 fdlist[fdlistno].nconf = nconf;
364 fdlist[fdlistno].asize = __rpc_get_a_size(si.si_af);
365 pfd[fdlistno].events = POLLIN | POLLPRI |
367 pfd[fdlistno].fd = fdlist[fdlistno].fd = fd;
368 fdlist[fdlistno].dsize = __rpc_get_t_size(si.si_af, si.si_proto,
369 0);
370
371 if (maxbufsize <= fdlist[fdlistno].dsize)
372 maxbufsize = fdlist[fdlistno].dsize;
373
374#ifdef PORTMAP
375 if (si.si_af == AF_INET && si.si_proto == IPPROTO_UDP) {
376 udpbufsz = fdlist[fdlistno].dsize;
377 if ((outbuf_pmap = malloc(udpbufsz)) == NULL) {
380 goto done_broad;
381 }
382 pmap_flag = 1;
383 }
384#endif /* PORTMAP */
385 fdlistno++;
386 }
387
388 if (fdlistno == 0) {
389 if (stat == RPC_SUCCESS)
391 goto done_broad;
392 }
393 if (maxbufsize == 0) {
394 if (stat == RPC_SUCCESS)
396 goto done_broad;
397 }
398 inbuf = malloc(maxbufsize);
399 outbuf = malloc(maxbufsize);
400 if ((inbuf == NULL) || (outbuf == NULL)) {
402 goto done_broad;
403 }
404
405 /* Serialize all the arguments which have to be sent */
406 (void) gettimeofday(&t, NULL);
407 msg.rm_xid = __RPC_GETXID(&t);
408 msg.rm_direction = CALL;
409 msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
410 msg.rm_call.cb_prog = RPCBPROG;
411 msg.rm_call.cb_vers = RPCBVERS;
412 msg.rm_call.cb_proc = RPCBPROC_CALLIT;
413 barg.prog = prog;
414 barg.vers = vers;
415 barg.proc = proc;
416 barg.args.args_val = argsp;
417 barg.xdr_args = xargs;
418 bres.addr = uaddrp;
419 bres.results.results_val = resultsp;
420 bres.xdr_res = xresults;
421 msg.rm_call.cb_cred = sys_auth->ah_cred;
422 msg.rm_call.cb_verf = sys_auth->ah_verf;
423 xdrmem_create(xdrs, outbuf, maxbufsize, XDR_ENCODE);
424 if ((!xdr_callmsg(xdrs, &msg)) ||
426 (struct rpcb_rmtcallargs *)(void *)&barg))) {
428 goto done_broad;
429 }
430 outlen = xdr_getpos(xdrs);
431 xdr_destroy(xdrs);
432
433#ifdef PORTMAP
434 /* Prepare the packet for version 2 PORTMAP */
435 if (pmap_flag) {
436 msg.rm_xid++; /* One way to distinguish */
437 msg.rm_call.cb_prog = PMAPPROG;
438 msg.rm_call.cb_vers = PMAPVERS;
439 msg.rm_call.cb_proc = PMAPPROC_CALLIT;
440 barg_pmap.prog = prog;
441 barg_pmap.vers = vers;
442 barg_pmap.proc = proc;
443 barg_pmap.args_ptr = argsp;
444 barg_pmap.xdr_args = xargs;
445 bres_pmap.port_ptr = &port;
446 bres_pmap.xdr_results = xresults;
447 bres_pmap.results_ptr = resultsp;
448 xdrmem_create(xdrs, outbuf_pmap, udpbufsz, XDR_ENCODE);
449 if ((! xdr_callmsg(xdrs, &msg)) ||
450 (! xdr_rmtcall_args(xdrs, &barg_pmap))) {
452 goto done_broad;
453 }
454 outlen_pmap = xdr_getpos(xdrs);
455 xdr_destroy(xdrs);
456 }
457#endif /* PORTMAP */
458
459 /*
460 * Basic loop: broadcast the packets to transports which
461 * support data packets of size such that one can encode
462 * all the arguments.
463 * Wait a while for response(s).
464 * The response timeout grows larger per iteration.
465 */
466 for (msec = inittime; msec <= waittime; msec += msec) {
467 struct broadif *bip;
468
469 /* Broadcast all the packets now */
470 for (i = 0; i < fdlistno; i++) {
471 if (fdlist[i].dsize < outlen) {
473 continue;
474 }
475 for (bip = TAILQ_FIRST(&fdlist[i].nal); bip != NULL;
476 bip = TAILQ_NEXT(bip, link)) {
477 void *addr;
478
479 addr = &bip->broadaddr;
480
481 __rpc_broadenable(fdlist[i].af, fdlist[i].fd,
482 bip);
483
484 /*
485 * Only use version 3 if lowvers is not set
486 */
487
488 if (!__rpc_lowvers)
489 if (sendto(fdlist[i].fd, outbuf,
490 outlen, 0, (struct sockaddr*)addr,
491 (size_t)fdlist[i].asize) !=
492 outlen) {
493#ifdef RPC_DEBUG
494 perror("sendto");
495#endif
496 warnx("clnt_bcast: cannot send"
497 "broadcast packet");
499 continue;
500 };
501#ifdef RPC_DEBUG
502 if (!__rpc_lowvers)
503 fprintf(stderr, "Broadcast packet sent "
504 "for %s\n",
505 fdlist[i].nconf->nc_netid);
506#endif
507#ifdef PORTMAP
508 /*
509 * Send the version 2 packet also
510 * for UDP/IP
511 */
512 if (pmap_flag &&
513 fdlist[i].proto == IPPROTO_UDP) {
514 if (sendto(fdlist[i].fd, outbuf_pmap,
515 outlen_pmap, 0, addr,
516 (size_t)fdlist[i].asize) !=
517 outlen_pmap) {
518 warnx("clnt_bcast: "
519 "Cannot send broadcast packet");
521 continue;
522 }
523 }
524#ifdef RPC_DEBUG
525 fprintf(stderr, "PMAP Broadcast packet "
526 "sent for %s\n",
527 fdlist[i].nconf->nc_netid);
528#endif
529#endif /* PORTMAP */
530 }
531 /* End for sending all packets on this transport */
532 } /* End for sending on all transports */
533
534 if (eachresult == NULL) {
536 goto done_broad;
537 }
538
539 /*
540 * Get all the replies from these broadcast requests
541 */
542 recv_again:
543
544 switch (pollretval = poll(pfd, fdlistno, msec)) {
545 case 0: /* timed out */
547 continue;
548 case -1: /* some kind of error - we ignore it */
549 goto recv_again;
550 } /* end of poll results switch */
551
552 for (i = fds_found = 0;
553 i < fdlistno && fds_found < pollretval; i++) {
554 bool_t done = FALSE;
555
556 if (pfd[i].revents == 0)
557 continue;
558 else if (pfd[i].revents & POLLNVAL) {
559 /*
560 * Something bad has happened to this descri-
561 * ptor. We can cause _poll() to ignore
562 * it simply by using a negative fd. We do that
563 * rather than compacting the pfd[] and fdlist[]
564 * arrays.
565 */
566 pfd[i].fd = -1;
567 fds_found++;
568 continue;
569 } else
570 fds_found++;
571#ifdef RPC_DEBUG
572 fprintf(stderr, "response for %s\n",
573 fdlist[i].nconf->nc_netid);
574#endif
575 try_again:
576 inlen = recvfrom(fdlist[i].fd, inbuf, fdlist[i].dsize,
577 0, (struct sockaddr *)(void *)&fdlist[i].raddr,
578 &fdlist[i].asize);
579 if (inlen < 0) {
580 if (errno == EINTR)
581 goto try_again;
582 warnx("clnt_bcast: Cannot receive reply to "
583 "broadcast");
585 continue;
586 }
587 if (inlen < sizeof (u_int32_t))
588 continue; /* Drop that and go ahead */
589 /*
590 * see if reply transaction id matches sent id.
591 * If so, decode the results. If return id is xid + 1
592 * it was a PORTMAP reply
593 */
594 if (*((u_int32_t *)(void *)(inbuf)) ==
595 *((u_int32_t *)(void *)(outbuf))) {
596 pmap_reply_flag = 0;
597 msg.acpted_rply.ar_verf = _null_auth;
598 msg.acpted_rply.ar_results.where =
599 (caddr_t)(void *)&bres;
600 msg.acpted_rply.ar_results.proc =
602#ifdef PORTMAP
603 } else if (pmap_flag &&
604 *((u_int32_t *)(void *)(inbuf)) ==
605 *((u_int32_t *)(void *)(outbuf_pmap))) {
606 pmap_reply_flag = 1;
607 msg.acpted_rply.ar_verf = _null_auth;
608 msg.acpted_rply.ar_results.where =
609 (caddr_t)(void *)&bres_pmap;
610 msg.acpted_rply.ar_results.proc =
612#endif /* PORTMAP */
613 } else
614 continue;
615 xdrmem_create(xdrs, inbuf, (u_int)inlen, XDR_DECODE);
616 if (xdr_replymsg(xdrs, &msg)) {
617 if ((msg.rm_reply.rp_stat == MSG_ACCEPTED) &&
618 (msg.acpted_rply.ar_stat == SUCCESS)) {
619 struct netbuf *np;
620#ifdef PORTMAP
621 struct netbuf taddr;
622 struct sockaddr_in sin;
623
624 if (pmap_flag && pmap_reply_flag) {
625 memcpy(&sin, &fdlist[i].raddr, sizeof(sin));
626 sin.sin_port = htons((u_short)port);
627 memcpy(&fdlist[i].raddr, &sin, sizeof(sin));
628 taddr.len = taddr.maxlen =
629 sizeof(fdlist[i].raddr);
630 taddr.buf = &fdlist[i].raddr;
631 done = (*eachresult)(resultsp,
632 &taddr, fdlist[i].nconf);
633 } else {
634#endif /* PORTMAP */
635#ifdef RPC_DEBUG
636 fprintf(stderr, "uaddr %s\n",
637 uaddrp);
638#endif
639 np = uaddr2taddr(
640 fdlist[i].nconf, uaddrp);
641 done = (*eachresult)(resultsp,
642 np, fdlist[i].nconf);
643 free(np);
644#ifdef PORTMAP
645 }
646#endif /* PORTMAP */
647 }
648 /* otherwise, we just ignore the errors ... */
649 }
650 /* else some kind of deserialization problem ... */
651
652 xdrs->x_op = XDR_FREE;
653 msg.acpted_rply.ar_results.proc = (xdrproc_t) xdr_void;
654 (void) xdr_replymsg(xdrs, &msg);
655 (void) (*xresults)(xdrs, resultsp);
656 XDR_DESTROY(xdrs);
657 if (done) {
659 goto done_broad;
660 } else {
661 goto recv_again;
662 }
663 } /* The recv for loop */
664 } /* The giant for loop */
665
666done_broad:
667 if (inbuf)
668 (void) free(inbuf);
669 if (outbuf)
670 (void) free(outbuf);
671#ifdef PORTMAP
672 if (outbuf_pmap)
673 (void) free(outbuf_pmap);
674#endif /* PORTMAP */
675 for (i = 0; i < fdlistno; i++) {
676 (void)closesocket(fdlist[i].fd);
677 __rpc_freebroadifs(&fdlist[i].nal);
678 }
679 AUTH_DESTROY(sys_auth);
681
682 return (stat);
683}
bool_t xdr_void(void)
Definition: xdr.c:92
_STLP_DECLSPEC complex< float > _STLP_CALL sin(const complex< float > &)
#define EINTR
Definition: acclib.h:80
#define gettimeofday(tv, tz)
Definition: adns_win32.h:159
static int inbuf
Definition: adnsresfilter.c:73
#define msg(x)
Definition: auth_time.c:54
AUTH * authunix_create_default()
Definition: auth_unix.c:198
#define caddr_t
Definition: ftp.c:24
void __rpc_freebroadifs(broadlist_t *list)
Definition: clnt_bcast.c:229
#define POLLRDBAND
Definition: clnt_bcast.c:83
#define POLLRDNORM
Definition: clnt_bcast.c:80
int __rpc_broadenable(int af, int s, struct broadif *bip)
Definition: clnt_bcast.c:244
#define MAXBCAST
Definition: clnt_bcast.c:75
@ RPC_SUCCESS
Definition: clnt_stat.h:22
@ RPC_TIMEDOUT
Definition: clnt_stat.h:31
@ RPC_CANTSEND
Definition: clnt_stat.h:28
@ RPC_CANTRECV
Definition: clnt_stat.h:29
@ RPC_CANTENCODEARGS
Definition: clnt_stat.h:26
@ RPC_UNKNOWNPROTO
Definition: clnt_stat.h:49
@ RPC_SYSTEMERROR
Definition: clnt_stat.h:43
#define malloc
Definition: debug_ros.c:4
#define AUTH_DESTROY(auth)
Definition: auth.h:257
UINT32 u_int
Definition: types.h:82
int32_t bool_t
Definition: types.h:101
unsigned short u_short
Definition: types.h:81
#define FALSE
Definition: types.h:117
USHORT port
Definition: uri.c:228
INT WSAAPI recvfrom(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags, OUT LPSOCKADDR from, IN OUT INT FAR *fromlen)
Definition: recv.c:87
INT WSAAPI sendto(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags, IN CONST struct sockaddr *to, IN INT tolen)
Definition: send.c:82
#define IPPROTO_UDP
Definition: ip.h:197
#define POLLIN
Definition: linux.h:1853
unsigned long u_long
Definition: linux.h:269
#define POLLPRI
Definition: linux.h:1854
#define POLLNVAL
Definition: linux.h:1858
#define AF_INET
Definition: tcpip.h:117
GLdouble GLdouble t
Definition: gl.h:2047
GLenum const GLvoid * addr
Definition: glext.h:9621
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
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define htons(x)
Definition: module.h:215
#define closesocket
Definition: ncftp.h:477
#define NC_TPI_CLTS
Definition: netconfig.h:35
#define PMAPPROC_CALLIT
Definition: pmap_prot.h:86
#define PMAPVERS
Definition: pmap_prot.h:78
#define PMAPPROG
Definition: pmap_prot.h:77
bool_t xdr_rmtcallres(XDR *xdrs, struct rmtcallres *crp)
Definition: pmap_rmt.c:153
bool_t xdr_rmtcall_args(XDR *xdrs, struct rmtcallargs *cap)
Definition: pmap_rmt.c:119
#define warnx(...)
#define SUCCESS
Definition: regproc.h:26
unsigned int u_int32_t
Definition: rosdhcp.h:35
bool_t xdr_callmsg(XDR *xdrs, struct rpc_msg *cmsg)
Definition: rpc_callmsg.c:50
struct opaque_auth _null_auth
void * __rpc_setconf(char *nettype) const
Definition: rpc_generic.c:305
u_int __rpc_get_t_size(int af, int proto, int size)
Definition: rpc_generic.c:139
struct netconfig * __rpc_getconf(void *vhandle)
Definition: rpc_generic.c:348
void __rpc_endconf(void *vhandle)
Definition: rpc_generic.c:425
int __rpc_nconf2sockinfo(const struct netconfig *nconf, struct __rpc_sockinfo *sip)
Definition: rpc_generic.c:540
struct netbuf * uaddr2taddr(const struct netconfig *nconf, const char *uaddr)
Definition: rpc_generic.c:619
@ MSG_ACCEPTED
Definition: rpc_msg.h:83
#define RPC_MSG_VERSION
Definition: rpc_msg.h:66
@ CALL
Definition: rpc_msg.h:78
bool_t xdr_replymsg(XDR *xdrs, struct rpc_msg *rmsg)
Definition: rpc_prot.c:188
int __rpc_lowvers
bool_t xdr_rpcb_rmtcallres(XDR *xdrs, struct rpcb_rmtcallres *p)
Definition: rpcb_prot.c:322
bool_t xdr_rpcb_rmtcallargs(XDR *xdrs, struct rpcb_rmtcallargs *p)
Definition: rpcb_prot.c:270
#define RPCBPROG
Definition: rpcb_prot.h:626
#define RPCBPROC_CALLIT
Definition: rpcb_prot.h:694
#define RPCBVERS
Definition: rpcb_prot.h:627
#define errno
Definition: errno.h:18
static int fd
Definition: io.c:51
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
__BEGIN_DECLS u_int __rpc_get_a_size(int)
Definition: rpc_generic.c:172
#define __RPC_GETXID(now)
Definition: rpc_com.h:58
static PIXELFORMATDESCRIPTOR pfd
Definition: ssstars.c:67
Definition: auth.h:205
struct opaque_auth ah_cred
Definition: auth.h:206
struct opaque_auth ah_verf
Definition: auth.h:207
Definition: xdr.h:103
enum xdr_op x_op
Definition: xdr.h:104
struct sockaddr_storage broadaddr
Definition: clnt_bcast.c:141
Definition: types.h:144
unsigned long nc_semantics
Definition: netconfig.h:17
char * nc_netid
Definition: netconfig.h:16
Definition: linux.h:1867
Definition: stat.h:55
#define TAILQ_INIT(head)
Definition: queue.h:348
#define INVALID_SOCKET
Definition: winsock.h:332
#define poll
Definition: wintirpc.h:59
@ XDR_DECODE
Definition: xdr.h:86
@ XDR_FREE
Definition: xdr.h:87
@ XDR_ENCODE
Definition: xdr.h:85
#define XDR_DESTROY(xdrs)
Definition: xdr.h:214
bool_t(* xdrproc_t)(XDR *,...)
Definition: xdr.h:144
#define xdr_getpos(xdrs)
Definition: xdr.h:201
#define xdr_destroy(xdrs)
Definition: xdr.h:217
void xdrmem_create(XDR *xdrs, char *addr, u_int size, enum xdr_op op)
Definition: xdr_mem.c:94

Referenced by rpc_broadcast().

◆ TAILQ_HEAD()

typedef TAILQ_HEAD ( broadif  )

Definition at line 145 of file clnt_bcast.c.

155{
156 int count = 0;
157 struct broadif *bip;
158 struct ifaddrs *ifap, *ifp;
159#ifdef INET6
160 struct sockaddr_in6 *sin6;
161#endif
162 struct sockaddr_in *sin;
163 struct addrinfo hints, *res;
164
165#if 0 /* WINDOWS */
166 if (getifaddrs(&ifp) < 0)
167 return 0;
168#else
169 /* Use GetAdaptersAddresses() ? */
170#endif
171
172 memset(&hints, 0, sizeof hints);
173
174 hints.ai_family = af;
175 hints.ai_protocol = proto;
176 hints.ai_socktype = socktype;
177
178 if (getaddrinfo(NULL, "sunrpc", &hints, &res) != 0)
179 return 0;
180
181 for (ifap = ifp; ifap != NULL; ifap = ifap->ifa_next) {
182 if (ifap->ifa_addr->sa_family != af ||
183 !(ifap->ifa_flags & IFF_UP))
184 continue;
185 bip = (struct broadif *)malloc(sizeof *bip);
186 if (bip == NULL)
187 break;
188 bip->index = if_nametoindex(ifap->ifa_name);
189 if (
190#ifdef INET6
191 af != AF_INET6 &&
192#endif
193 (ifap->ifa_flags & IFF_BROADCAST) &&
194 ifap->ifa_broadaddr) {
195 /* memcpy(&bip->broadaddr, ifap->ifa_broadaddr,
196 (size_t)ifap->ifa_broadaddr->sa_len);*/
197 memcpy(&bip->broadaddr, ifap->ifa_broadaddr,
198 sizeof(bip->broadaddr));
199 sin = (struct sockaddr_in *)(void *)&bip->broadaddr;
200 sin->sin_port =
201 ((struct sockaddr_in *)
202 (void *)res->ai_addr)->sin_port;
203 } else
204#ifdef INET6
205 if (af == AF_INET6 && (ifap->ifa_flags & IFF_MULTICAST)) {
206 sin6 = (struct sockaddr_in6 *)(void *)&bip->broadaddr;
208 sin6->sin6_family = af;
209 sin6->sin6_port =
210 ((struct sockaddr_in6 *)
211 (void *)res->ai_addr)->sin6_port;
212 sin6->sin6_scope_id = bip->index;
213 } else
214#endif
215 {
216 free(bip);
217 continue;
218 }
220 count++;
221 }
222 freeifaddrs(ifp);
224
225 return count;
226}
#define RPCB_MULTICAST_ADDR
Definition: clnt.h:77
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint res
Definition: glext.h:9613
#define memset(x, y, z)
Definition: compat.h:39
namespace GUID const ADDRINFOEXW * hints
Definition: sock.c:80
ULONG sin6_scope_id
Definition: ws2ipdef.h:184
ADDRESS_FAMILY sin6_family
Definition: ws2ipdef.h:179
IN6_ADDR sin6_addr
Definition: ws2ipdef.h:182
USHORT sin6_port
Definition: ws2ipdef.h:180
u_short sin_port
Definition: winsock.h:511
#define TAILQ_INSERT_TAIL(head, elm, field)
Definition: queue.h:363
#define IFF_MULTICAST
Definition: ws2ipdef.h:25
#define IFF_BROADCAST
Definition: ws2ipdef.h:22
#define IFF_UP
Definition: ws2ipdef.h:21
WINSOCK_API_LINKAGE INT WSAAPI inet_pton(_In_ INT Family, _In_ PCSTR pszAddrString, _Out_writes_bytes_(sizeof(IN6_ADDR)) PVOID pAddrBuf)
#define getaddrinfo
Definition: wspiapi.h:44
#define freeaddrinfo
Definition: wspiapi.h:46