home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / unix / volume26 / mcast / part02 < prev    next >
Encoding:
Text File  |  1993-04-05  |  100.1 KB  |  3,126 lines

  1. Newsgroups: comp.sources.unix
  2. From: casey@gauss.llnl.gov (Casey Leedom)
  3. Subject: v26i106: mcast - LLNL IP multicast implementation, V1.2.3, Part02/04
  4. Sender: unix-sources-moderator@vix.com
  5. Approved: paul@vix.com
  6.  
  7. Submitted-By: casey@gauss.llnl.gov (Casey Leedom)
  8. Posting-Number: Volume 26, Issue 106
  9. Archive-Name: mcast/part02
  10.  
  11. #! /bin/sh
  12. # This is a shell archive.  Remove anything before this line, then unpack
  13. # it by saving it into a file and typing "sh file".  To overwrite existing
  14. # files, type "sh file -c".  You can also feed this as standard input via
  15. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  16. # will see the following message at the end:
  17. #        "End of archive 2 (of 4)."
  18. # Contents:  libmcast/_mc_write.c libmcast/mc_bind.c
  19. #   libmcast/mc_connect.c libmcast/mc_fcntl.c libmcast/mc_lib.h
  20. #   libmcast/mc_sendto.c libmcast/mc_socket.c
  21. #   libmcast/mcast_getgroupbyname.c libmcast/mcast_newaddr.c
  22. #   libmcast/mcast_sopen.c man/mc_bind.2 man/mc_connect.2
  23. #   man/mc_fcntl.2 man/mc_getpeername.2 man/mc_getsockname.2
  24. #   man/mc_ioctl.2 man/mc_write.2 man/mcast_getgroupbyname.3
  25. #   test/mc_clock.c test/mc_listen.c test/mc_send.c
  26. # Wrapped by vixie@gw.home.vix.com on Tue Apr  6 12:49:47 1993
  27. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  28. if test -f 'libmcast/_mc_write.c' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'libmcast/_mc_write.c'\"
  30. else
  31. echo shar: Extracting \"'libmcast/_mc_write.c'\" \(4437 characters\)
  32. sed "s/^X//" >'libmcast/_mc_write.c' <<'END_OF_FILE'
  33. X/*
  34. X * $Header: /u0/casey/src/mcast/libmcast/RCS/_mc_write.c,v 1.4 93/01/16 19:37:43 casey Exp $
  35. X */
  36. X
  37. X/*
  38. X * Copyright (c) 1992 The Regents of the University of California.
  39. X * All rights reserved.
  40. X *
  41. X * Redistribution and use in source and binary forms, with or without
  42. X * modification, are permitted provided that the following conditions
  43. X * are met:
  44. X * 1. Redistributions of source code must retain the above copyright
  45. X *    notice, this list of conditions and the following disclaimer.
  46. X * 2. Redistributions in binary form must reproduce the above copyright
  47. X *    notice, this list of conditions and the following disclaimer in the
  48. X *    documentation and/or other materials provided with the distribution.
  49. X * 3. All advertising materials mentioning features or use of this software
  50. X *    must display the following acknowledgement:
  51. X *    This product includes software developed by the University of
  52. X *    California, Lawrence Livermore National Laboratory and its
  53. X *    contributors.
  54. X * 4. Neither the name of the University nor the names of its contributors
  55. X *    may be used to endorse or promote products derived from this software
  56. X *    without specific prior written permission.
  57. X *
  58. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  59. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  60. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  61. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  62. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  63. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  64. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  65. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  66. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  67. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  68. X * SUCH DAMAGE.
  69. X */
  70. X
  71. X#ifndef lint
  72. static char rcsid[] = "$Header: /u0/casey/src/mcast/libmcast/RCS/_mc_write.c,v 1.4 93/01/16 19:37:43 casey Exp $";
  73. static char copyright[] =
  74. X    "Copyright (c) 1992 The Regents of the University of California.\n"
  75. X    "All rights reserved.\n";
  76. static char classification[] =
  77. X    "Unclassified\n";
  78. X#endif
  79. X
  80. X
  81. X/*
  82. X * MCAST SYSLIB PRIVATE: _mc_write helper routine.
  83. X */
  84. X
  85. X
  86. X#include "mc_lib.h"
  87. X
  88. X
  89. static void    SigPipe(int);        /* dead server signal */
  90. static jmp_buf    deadserver;        /* where to go if the server dies */
  91. X
  92. int
  93. X_mc_write(int s, const void *buf, size_t len, int flags, const mc_addr *to)
  94. X    /*
  95. X     * Write len bytes from buf to multicast group attached to socket s.
  96. X     * If to is non-NULL, set multicast message destination address to *to,
  97. X     * otherwise use default remote address.
  98. X     */
  99. X{
  100. X    mc_state *sp = &_mc_state[s];
  101. X    mc_header header;
  102. X    struct sigaction sig, osig;
  103. X    int nwrite, n;
  104. X    struct iovec wv[2];
  105. X    extern writev(int, struct iovec *, int);
  106. X
  107. X    /* we don't support any flags yet ... */
  108. X    if (flags) {
  109. X        errno = ENOPROTOOPT;
  110. X        return(-1);
  111. X    }
  112. X
  113. X    /* construct a transport header */
  114. X    (void)memset(&header, 0, sizeof(header));
  115. X    header.version = MCVERSION;
  116. X    header.hlength = sizeof(header);
  117. X    header.length = htonl(sizeof(header) + len);
  118. X    header.group = sp->group;
  119. X    header.source = sp->local;
  120. X    if (to != NULL)
  121. X        header.destination = *to;
  122. X    else
  123. X        header.destination = sp->remote;
  124. X
  125. X    /*
  126. X     * Send the header and user data to the server.  We have to protect
  127. X     * ourselves from a potential SIGPIPE generated by talking to a
  128. X     * dead server.
  129. X     */
  130. X    wv[0].iov_base = (caddr_t)&header;
  131. X    wv[0].iov_len = sizeof(header);
  132. X    wv[1].iov_base = (caddr_t)buf;
  133. X    wv[1].iov_len = len;
  134. X    n = wv[0].iov_len + wv[1].iov_len;
  135. X    sig.sa_handler = SigPipe;
  136. X    (void)sigemptyset(&sig.sa_mask);
  137. X    sig.sa_flags = 0;
  138. X    (void)sigaction(SIGPIPE, &sig, &osig);
  139. X    if (sigsetjmp(deadserver, 1) != 0) {
  140. X        (void) sigaction(SIGPIPE, &osig, (struct sigaction *)0);
  141. X        (void)fprintf(stderr, "_mc_write: connection to server reset\n");
  142. X        sp->state |= MC_CORRUPTED;
  143. X        errno = EIO;
  144. X        return(-1);
  145. X    }
  146. X    nwrite = writev(s, wv, 2);
  147. X    (void)sigaction(SIGPIPE, &osig, (struct sigaction *)0);
  148. X    if (nwrite < n) {
  149. X        if (nwrite < 0)
  150. X            perror("_mc_write");
  151. X        else
  152. X            (void)fprintf(stderr, "_mc_write: WRITE ONLY WROTE %d of %d"
  153. X                " requested!\n", nwrite, n);
  154. X        sp->state |= MC_CORRUPTED;
  155. X        errno = EIO;
  156. X        return(-1);
  157. X    }
  158. X    return(len);
  159. X}
  160. X
  161. X/*ARGSUSED*/
  162. static void
  163. SigPipe(int sig)
  164. X{
  165. X    siglongjmp(deadserver, 1);
  166. X    /*NOTREACHED*/
  167. X}
  168. END_OF_FILE
  169. if test 4437 -ne `wc -c <'libmcast/_mc_write.c'`; then
  170.     echo shar: \"'libmcast/_mc_write.c'\" unpacked with wrong size!
  171. fi
  172. # end of 'libmcast/_mc_write.c'
  173. fi
  174. if test -f 'libmcast/mc_bind.c' -a "${1}" != "-c" ; then 
  175.   echo shar: Will not clobber existing file \"'libmcast/mc_bind.c'\"
  176. else
  177. echo shar: Extracting \"'libmcast/mc_bind.c'\" \(4249 characters\)
  178. sed "s/^X//" >'libmcast/mc_bind.c' <<'END_OF_FILE'
  179. X/*
  180. X * $Header: /u0/casey/src/mcast/libmcast/RCS/mc_bind.c,v 1.3 93/01/16 19:40:30 casey Exp $
  181. X */
  182. X
  183. X/*
  184. X * Copyright (c) 1992 The Regents of the University of California.
  185. X * All rights reserved.
  186. X *
  187. X * Redistribution and use in source and binary forms, with or without
  188. X * modification, are permitted provided that the following conditions
  189. X * are met:
  190. X * 1. Redistributions of source code must retain the above copyright
  191. X *    notice, this list of conditions and the following disclaimer.
  192. X * 2. Redistributions in binary form must reproduce the above copyright
  193. X *    notice, this list of conditions and the following disclaimer in the
  194. X *    documentation and/or other materials provided with the distribution.
  195. X * 3. All advertising materials mentioning features or use of this software
  196. X *    must display the following acknowledgement:
  197. X *    This product includes software developed by the University of
  198. X *    California, Lawrence Livermore National Laboratory and its
  199. X *    contributors.
  200. X * 4. Neither the name of the University nor the names of its contributors
  201. X *    may be used to endorse or promote products derived from this software
  202. X *    without specific prior written permission.
  203. X *
  204. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  205. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  206. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  207. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  208. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  209. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  210. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  211. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  212. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  213. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  214. X * SUCH DAMAGE.
  215. X */
  216. X
  217. X#ifndef lint
  218. static char rcsid[] = "$Header: /u0/casey/src/mcast/libmcast/RCS/mc_bind.c,v 1.3 93/01/16 19:40:30 casey Exp $";
  219. static char copyright[] =
  220. X    "Copyright (c) 1992 The Regents of the University of California.\n"
  221. X    "All rights reserved.\n";
  222. static char classification[] =
  223. X    "Unclassified\n";
  224. X#endif
  225. X
  226. X
  227. X/*
  228. X * MCAST SYSLIB PUBLIC: mc_bind: bind(2) system call emulation routine.
  229. X */
  230. X
  231. X
  232. X#include "mc_lib.h"
  233. X
  234. X
  235. int
  236. mc_bind(int s, const struct sockaddr *name, int namelen)
  237. X    /*
  238. X     * Bind multicast group and member addresses to local side of socket.
  239. X     * If specified member address is MCADDR_ANY, create a new unique
  240. X     * member address and use that.
  241. X     *
  242. X     * NOTE: We don't allow multiple binds on a socket.
  243. X     */
  244. X{
  245. X    mc_state *sp = &_mc_state[s];
  246. X    struct sockaddr_mcast *np = (struct sockaddr_mcast *)name;
  247. X    mcd_message command;
  248. X    int nwrite;
  249. X
  250. X    if (s < 0 || s >= MC_MAX_CONNECTIONS
  251. X        || !(sp->state & MC_VALID)) {
  252. X        /* return(bind(s, name, namelen)); */
  253. X        errno = EBADF;
  254. X        return(-1);
  255. X    }
  256. X    if (sp->state & MC_CORRUPTED) {
  257. X        errno = EIO;
  258. X        return(-1);
  259. X    }
  260. X    if (namelen < sizeof(struct sockaddr_mcast)) {
  261. X        errno = EINVAL;
  262. X        return(-1);
  263. X    }
  264. X    if (np->family != sp->family) {
  265. X        errno = EAFNOSUPPORT;
  266. X        return(-1);
  267. X    }
  268. X    if (sp->state & MC_BOUND) {
  269. X        /*
  270. X         * The server actually offers the capability of rebinding
  271. X         * addresses to the connection any number of times, but
  272. X         * we don't resell that capability through the socket API.
  273. X         * This restriction is mostly for compatibility with the
  274. X         * other already existing Berkeley socket-interfaced
  275. X         * communication domains.
  276. X         */
  277. X        errno = EISCONN;
  278. X        return(-1);
  279. X    }
  280. X
  281. X    /* bind name to socket */
  282. X    if (MCADDR_EQ(np->member, MCADDR_BROADCAST)
  283. X        || MCADDR_EQ(np->group, MCADDR_ANY)
  284. X        || MCADDR_EQ(np->group, MCADDR_BROADCAST)) {
  285. X        errno = EINVAL;
  286. X        return(-1);
  287. X    }
  288. X    sp->group = np->group;
  289. X    if (MCADDR_EQ(np->member, MCADDR_ANY))
  290. X        mcast_newaddr(&sp->local);
  291. X    else
  292. X        sp->local = np->member;
  293. X    sp->state |= MC_BOUND;
  294. X
  295. X    /* send MCD_BIND to server */
  296. X    (void)memset(&command, 0, sizeof(command));
  297. X    command.request = htonl(MCD_BIND);
  298. X    command.group = sp->group;
  299. X    command.local = sp->local;
  300. X    command.remote = sp->remote;
  301. X    nwrite = _mc_write(s, &command, sizeof(command), 0, &MCD_MCADDR);
  302. X    if (nwrite < 0)
  303. X        return(-1);
  304. X    return(0);
  305. X}
  306. END_OF_FILE
  307. if test 4249 -ne `wc -c <'libmcast/mc_bind.c'`; then
  308.     echo shar: \"'libmcast/mc_bind.c'\" unpacked with wrong size!
  309. fi
  310. # end of 'libmcast/mc_bind.c'
  311. fi
  312. if test -f 'libmcast/mc_connect.c' -a "${1}" != "-c" ; then 
  313.   echo shar: Will not clobber existing file \"'libmcast/mc_connect.c'\"
  314. else
  315. echo shar: Extracting \"'libmcast/mc_connect.c'\" \(4262 characters\)
  316. sed "s/^X//" >'libmcast/mc_connect.c' <<'END_OF_FILE'
  317. X/*
  318. X * $Header: /u0/casey/src/mcast/libmcast/RCS/mc_connect.c,v 1.3 93/01/16 19:42:16 casey Exp $
  319. X */
  320. X
  321. X/*
  322. X * Copyright (c) 1992 The Regents of the University of California.
  323. X * All rights reserved.
  324. X *
  325. X * Redistribution and use in source and binary forms, with or without
  326. X * modification, are permitted provided that the following conditions
  327. X * are met:
  328. X * 1. Redistributions of source code must retain the above copyright
  329. X *    notice, this list of conditions and the following disclaimer.
  330. X * 2. Redistributions in binary form must reproduce the above copyright
  331. X *    notice, this list of conditions and the following disclaimer in the
  332. X *    documentation and/or other materials provided with the distribution.
  333. X * 3. All advertising materials mentioning features or use of this software
  334. X *    must display the following acknowledgement:
  335. X *    This product includes software developed by the University of
  336. X *    California, Lawrence Livermore National Laboratory and its
  337. X *    contributors.
  338. X * 4. Neither the name of the University nor the names of its contributors
  339. X *    may be used to endorse or promote products derived from this software
  340. X *    without specific prior written permission.
  341. X *
  342. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  343. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  344. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  345. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  346. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  347. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  348. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  349. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  350. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  351. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  352. X * SUCH DAMAGE.
  353. X */
  354. X
  355. X#ifndef lint
  356. static char rcsid[] = "$Header: /u0/casey/src/mcast/libmcast/RCS/mc_connect.c,v 1.3 93/01/16 19:42:16 casey Exp $";
  357. static char copyright[] =
  358. X    "Copyright (c) 1992 The Regents of the University of California.\n"
  359. X    "All rights reserved.\n";
  360. static char classification[] =
  361. X    "Unclassified\n";
  362. X#endif
  363. X
  364. X
  365. X/*
  366. X * MCAST SYSLIB PUBLIC: mc_connect: connect(2) system call emulation routine.
  367. X */
  368. X
  369. X
  370. X#include "mc_lib.h"
  371. X
  372. X
  373. int
  374. mc_connect(int s, const struct sockaddr *name, int namelen)
  375. X    /*
  376. X     * ``Connect'' to multicast group (and possibly a specific member).  If
  377. X     * a local group and member address have already been bound to the
  378. X     * socket, the group address in the connect request must match the
  379. X     * group address used in the previous bind request.
  380. X     */
  381. X{
  382. X    mc_state *sp = &_mc_state[s];
  383. X    struct sockaddr_mcast *np = (struct sockaddr_mcast *)name;
  384. X    mcd_message command;
  385. X
  386. X    if (s < 0 || s >= MC_MAX_CONNECTIONS
  387. X        || !(sp->state & MC_VALID)) {
  388. X        /* return(connect(s, name, namelen)); */
  389. X        errno = EBADF;
  390. X        return(-1);
  391. X    }
  392. X    if (sp->state & MC_CORRUPTED) {
  393. X        errno = EIO;
  394. X        return(-1);
  395. X    }
  396. X    if (namelen >= sizeof(struct sockaddr)
  397. X        && name->sa_family == AF_UNSPEC) {
  398. X        if (!(sp->state & MC_BOUND)) {
  399. X            errno = EINVAL;
  400. X            return(-1);
  401. X        }
  402. X        sp->remote = MCADDR_BROADCAST;
  403. X        sp->state &= ~MC_CONNECTED;
  404. X        goto send_bind;
  405. X    }
  406. X    if (namelen < sizeof(struct sockaddr_mcast)) {
  407. X        errno = EINVAL;
  408. X        return(-1);
  409. X    }
  410. X    if (np->family != sp->family) {
  411. X        errno = EAFNOSUPPORT;
  412. X        return(-1);
  413. X    }
  414. X    if (MCADDR_EQ(np->group, MCADDR_BROADCAST)
  415. X        || MCADDR_EQ(np->group, MCADDR_ANY)) {
  416. X        errno = EINVAL;
  417. X        return(-1);
  418. X    }
  419. X
  420. X    /* bind name to socket */
  421. X    if (sp->state & MC_BOUND) {
  422. X        if (!MCADDR_EQ(np->group, sp->group)) {
  423. X            errno = EISCONN;
  424. X            return(-1);
  425. X        }
  426. X    } else {
  427. X        sp->group = np->group;
  428. X        mcast_newaddr(&sp->local);
  429. X        sp->state |= MC_BOUND;
  430. X    }
  431. X    sp->remote = np->member;
  432. X    if (MCADDR_EQ(sp->remote, MCADDR_BROADCAST))
  433. X        sp->state &= ~MC_CONNECTED;
  434. X    else
  435. X        sp->state |= MC_CONNECTED;
  436. X
  437. X    send_bind:
  438. X    /* send MCD_BIND to server */
  439. X    (void)memset(&command, 0, sizeof(command));
  440. X    command.request = htonl(MCD_BIND);
  441. X    command.group = sp->group;
  442. X    command.local = sp->local;
  443. X    command.remote = sp->remote;
  444. X    if (_mc_write(s, &command, sizeof(command), 0, &MCD_MCADDR) < 0)
  445. X        return(-1);
  446. X    return(0);
  447. X}
  448. END_OF_FILE
  449. if test 4262 -ne `wc -c <'libmcast/mc_connect.c'`; then
  450.     echo shar: \"'libmcast/mc_connect.c'\" unpacked with wrong size!
  451. fi
  452. # end of 'libmcast/mc_connect.c'
  453. fi
  454. if test -f 'libmcast/mc_fcntl.c' -a "${1}" != "-c" ; then 
  455.   echo shar: Will not clobber existing file \"'libmcast/mc_fcntl.c'\"
  456. else
  457. echo shar: Extracting \"'libmcast/mc_fcntl.c'\" \(3889 characters\)
  458. sed "s/^X//" >'libmcast/mc_fcntl.c' <<'END_OF_FILE'
  459. X/*
  460. X * $Header: /u0/casey/src/mcast/libmcast/RCS/mc_fcntl.c,v 1.2 92/11/17 16:56:13 casey Exp $
  461. X */
  462. X
  463. X/*
  464. X * Copyright (c) 1992 The Regents of the University of California.
  465. X * All rights reserved.
  466. X *
  467. X * Redistribution and use in source and binary forms, with or without
  468. X * modification, are permitted provided that the following conditions
  469. X * are met:
  470. X * 1. Redistributions of source code must retain the above copyright
  471. X *    notice, this list of conditions and the following disclaimer.
  472. X * 2. Redistributions in binary form must reproduce the above copyright
  473. X *    notice, this list of conditions and the following disclaimer in the
  474. X *    documentation and/or other materials provided with the distribution.
  475. X * 3. All advertising materials mentioning features or use of this software
  476. X *    must display the following acknowledgement:
  477. X *    This product includes software developed by the University of
  478. X *    California, Lawrence Livermore National Laboratory and its
  479. X *    contributors.
  480. X * 4. Neither the name of the University nor the names of its contributors
  481. X *    may be used to endorse or promote products derived from this software
  482. X *    without specific prior written permission.
  483. X *
  484. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  485. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  486. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  487. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  488. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  489. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  490. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  491. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  492. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  493. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  494. X * SUCH DAMAGE.
  495. X */
  496. X
  497. X#ifndef lint
  498. static char rcsid[] = "$Header: /u0/casey/src/mcast/libmcast/RCS/mc_fcntl.c,v 1.2 92/11/17 16:56:13 casey Exp $";
  499. static char copyright[] =
  500. X    "Copyright (c) 1992 The Regents of the University of California.\n"
  501. X    "All rights reserved.\n";
  502. static char classification[] =
  503. X    "Unclassified\n";
  504. X#endif
  505. X
  506. X
  507. X/*
  508. X * MCAST SYSLIB PUBLIC: mc_fcntl: fcntl(2) system call emulation routine.
  509. X */
  510. X
  511. X
  512. X#include "mc_lib.h"
  513. X
  514. X
  515. X/*VARARGS2*/
  516. int
  517. mc_fcntl(int s, int request, ...)
  518. X    /*
  519. X     * Perform file control operation on multicast socket.  Basically only
  520. X     * F_SETFL and F_GETFL are supported, and the only flag controls
  521. X     * supported are O_NONBLOCK and MCO_LOOPBACK.  O_NONBLOCK does the
  522. X     * usual.  MCO_LOOPBACK controls whether we see our own out-bound
  523. X     * messages in our input.
  524. X     */
  525. X{
  526. X    mc_state *sp = &_mc_state[s];
  527. X    va_list va;
  528. X    int arg;
  529. X
  530. X    va_start(va, request);
  531. X    if (s < 0 || s >= MC_MAX_CONNECTIONS
  532. X        || !(sp->state & MC_VALID)) {
  533. X        /* return(fcntl(s, request, va_arg(va, int))); */
  534. X        errno = EBADF;
  535. X        return(-1);
  536. X    }
  537. X    if (sp->state & MC_CORRUPTED) {
  538. X        errno = EIO;
  539. X        return(-1);
  540. X    }
  541. X
  542. X    switch (request) {
  543. X        default:
  544. X        errno = EINVAL;
  545. X        return(-1);
  546. X
  547. X        case F_SETFL:
  548. X        arg = va_arg(va, int);
  549. X        if (arg & ~(O_APPEND|O_NDELAY|O_NONBLOCK|O_SYNC|FASYNC|O_DEV)) {
  550. X            errno = EINVAL;
  551. X            return(-1);
  552. X        }
  553. X        if (arg & ~(O_NONBLOCK|MCO_LOOPBACK)) {
  554. X            /* we only support a few flags ... */
  555. X            errno = EOPNOTSUPP;
  556. X            return(-1);
  557. X        }
  558. X        /* if LOOPBACK changing state, send server LOOPBACK command */
  559. X        if ((arg ^ sp->flags) & MCO_LOOPBACK) {
  560. X            mcd_message command;
  561. X
  562. X            (void)memset(&command, 0, sizeof(command));
  563. X            command.request = htonl(MCD_LOOPBACK);
  564. X            command.option = htonl((long)(arg & MCO_LOOPBACK));
  565. X            if (_mc_write(s, &command, sizeof(command), 0,
  566. X                      &MCD_MCADDR) < 0)
  567. X                return(-1);
  568. X        }
  569. X        sp->flags = arg;
  570. X        return(0);
  571. X
  572. X        case F_GETFL:
  573. X        return(sp->flags);
  574. X    }
  575. X    /*NOTREACHED*/
  576. X    va_end(va);
  577. X}
  578. END_OF_FILE
  579. if test 3889 -ne `wc -c <'libmcast/mc_fcntl.c'`; then
  580.     echo shar: \"'libmcast/mc_fcntl.c'\" unpacked with wrong size!
  581. fi
  582. # end of 'libmcast/mc_fcntl.c'
  583. fi
  584. if test -f 'libmcast/mc_lib.h' -a "${1}" != "-c" ; then 
  585.   echo shar: Will not clobber existing file \"'libmcast/mc_lib.h'\"
  586. else
  587. echo shar: Extracting \"'libmcast/mc_lib.h'\" \(3787 characters\)
  588. sed "s/^X//" >'libmcast/mc_lib.h' <<'END_OF_FILE'
  589. X/*
  590. X * $Header: /u0/casey/src/mcast/libmcast/RCS/mc_lib.h,v 1.2 93/01/16 19:45:47 casey Exp $
  591. X */
  592. X
  593. X/*
  594. X * Copyright (c) 1992 The Regents of the University of California.
  595. X * All rights reserved.
  596. X *
  597. X * Redistribution and use in source and binary forms, with or without
  598. X * modification, are permitted provided that the following conditions
  599. X * are met:
  600. X * 1. Redistributions of source code must retain the above copyright
  601. X *    notice, this list of conditions and the following disclaimer.
  602. X * 2. Redistributions in binary form must reproduce the above copyright
  603. X *    notice, this list of conditions and the following disclaimer in the
  604. X *    documentation and/or other materials provided with the distribution.
  605. X * 3. All advertising materials mentioning features or use of this software
  606. X *    must display the following acknowledgement:
  607. X *    This product includes software developed by the University of
  608. X *    California, Lawrence Livermore National Laboratory and its
  609. X *    contributors.
  610. X * 4. Neither the name of the University nor the names of its contributors
  611. X *    may be used to endorse or promote products derived from this software
  612. X *    without specific prior written permission.
  613. X *
  614. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  615. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  616. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  617. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  618. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  619. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  620. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  621. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  622. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  623. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  624. X * SUCH DAMAGE.
  625. X */
  626. X
  627. X#ifndef _MC_LIB_H_
  628. X#define    _MC_LIB_H_
  629. X
  630. X
  631. X/*
  632. X * ANSI C and POSIX includes
  633. X */
  634. X#include <errno.h>
  635. X#include <fcntl.h>
  636. X#include <setjmp.h>
  637. X#include <signal.h>
  638. X#include <stdarg.h>
  639. X#include <stddef.h>
  640. X#include <stdio.h>
  641. X#include <stdlib.h>
  642. X#include <string.h>
  643. X#include <unistd.h>
  644. X#include <sys/ioctl.h>
  645. X#include <sys/types.h>
  646. X
  647. X/*
  648. X * BSD networking includes
  649. X */
  650. X#include <netdb.h>
  651. X#include <sys/uio.h>
  652. X#include <sys/socket.h>
  653. X#include <netinet/in.h>
  654. X
  655. X/*
  656. X * Multicast transport includes
  657. X */
  658. X#include <netmcast/mcast.h>
  659. X#include <netmcast/mcastd.h>
  660. X
  661. X
  662. typedef struct {
  663. X    /* socket/connection names */
  664. X    int        family;        /* PF_* protocol family */
  665. X    int        type;        /* SOCK_* socket type */
  666. X    int        protocol;    /* protocol */
  667. X    mc_addr        group;        /* bind/connect: multicast group */
  668. X    mc_addr        local;        /* bind: local member address */
  669. X    mc_addr        remote;        /* connect: remote member address */
  670. X    /* socket state */
  671. X    int        state;        /* socket state */
  672. X    int        flags;        /* socket options (see fcntl) */
  673. X    mc_addr        source;        /* source of current message */
  674. X    unsigned int    resid;        /* bytes left to read in current message */
  675. X} mc_state;
  676. X
  677. X/* bits for "state" */
  678. X#define    MC_VALID        0x0001    /* assigned and connected to server */
  679. X#define    MC_CORRUPTED        0x0002    /* connection to server corrupted */
  680. X#define    MC_BOUND        0x0004    /* bound to multicast group */
  681. X#define    MC_CONNECTED        0x0008    /* connected to remote peer */
  682. X#define    MC_SHUTDOWNRECV        0x0010    /* receiving shutdown */
  683. X#define    MC_SHUTDOWNSEND        0x0020    /* sending shutdown */
  684. X
  685. X#define    MC_MAX_CONNECTIONS    FD_SETSIZE
  686. extern mc_state _mc_state[MC_MAX_CONNECTIONS];
  687. X
  688. int _mc_pullup(int s, int flags);
  689. int _mc_read(int s, void *buf, size_t len, int flags, mc_addr *from);
  690. int _mc_write(int s, const void *buf, size_t len, int flags, const mc_addr *to);
  691. X
  692. X#ifndef min
  693. X#define    min(a, b)    ((a) < (b) ? (a) : (b))
  694. X#endif
  695. X
  696. X#endif /* _MC_LIB_H_ */
  697. END_OF_FILE
  698. if test 3787 -ne `wc -c <'libmcast/mc_lib.h'`; then
  699.     echo shar: \"'libmcast/mc_lib.h'\" unpacked with wrong size!
  700. fi
  701. # end of 'libmcast/mc_lib.h'
  702. fi
  703. if test -f 'libmcast/mc_sendto.c' -a "${1}" != "-c" ; then 
  704.   echo shar: Will not clobber existing file \"'libmcast/mc_sendto.c'\"
  705. else
  706. echo shar: Extracting \"'libmcast/mc_sendto.c'\" \(3833 characters\)
  707. sed "s/^X//" >'libmcast/mc_sendto.c' <<'END_OF_FILE'
  708. X/*
  709. X * $Header: /u0/casey/src/mcast/libmcast/RCS/mc_sendto.c,v 1.2 93/01/16 19:50:20 casey Exp $
  710. X */
  711. X
  712. X/*
  713. X * Copyright (c) 1992 The Regents of the University of California.
  714. X * All rights reserved.
  715. X *
  716. X * Redistribution and use in source and binary forms, with or without
  717. X * modification, are permitted provided that the following conditions
  718. X * are met:
  719. X * 1. Redistributions of source code must retain the above copyright
  720. X *    notice, this list of conditions and the following disclaimer.
  721. X * 2. Redistributions in binary form must reproduce the above copyright
  722. X *    notice, this list of conditions and the following disclaimer in the
  723. X *    documentation and/or other materials provided with the distribution.
  724. X * 3. All advertising materials mentioning features or use of this software
  725. X *    must display the following acknowledgement:
  726. X *    This product includes software developed by the University of
  727. X *    California, Lawrence Livermore National Laboratory and its
  728. X *    contributors.
  729. X * 4. Neither the name of the University nor the names of its contributors
  730. X *    may be used to endorse or promote products derived from this software
  731. X *    without specific prior written permission.
  732. X *
  733. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  734. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  735. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  736. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  737. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  738. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  739. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  740. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  741. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  742. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  743. X * SUCH DAMAGE.
  744. X */
  745. X
  746. X#ifndef lint
  747. static char rcsid[] = "$Header: /u0/casey/src/mcast/libmcast/RCS/mc_sendto.c,v 1.2 93/01/16 19:50:20 casey Exp $";
  748. static char copyright[] =
  749. X    "Copyright (c) 1992 The Regents of the University of California.\n"
  750. X    "All rights reserved.\n";
  751. static char classification[] =
  752. X    "Unclassified\n";
  753. X#endif
  754. X
  755. X
  756. X/*
  757. X * MCAST SYSLIB PUBLIC: mc_sendto: sendto(2) system call emulation routine.
  758. X */
  759. X
  760. X
  761. X#include "mc_lib.h"
  762. X
  763. X
  764. int
  765. mc_sendto(int s, const void *buf, int len, int flags,
  766. X      struct sockaddr *to, int tolen)
  767. X{
  768. X    mc_state *sp = &_mc_state[s];
  769. X    struct sockaddr_mcast *np = (struct sockaddr_mcast *)to;
  770. X
  771. X    if (s < 0 || s >= MC_MAX_CONNECTIONS
  772. X        || !(sp->state & MC_VALID)) {
  773. X        /* return(sendto(s, buf, len, flags)); */
  774. X        errno = EBADF;
  775. X        return(-1);
  776. X    }
  777. X    if (sp->state & MC_CORRUPTED) {
  778. X        errno = EIO;
  779. X        return(-1);
  780. X    }
  781. X    if (len < 0) {
  782. X        errno = EINVAL;
  783. X        return(-1);
  784. X    }
  785. X    if (sp->state & MC_SHUTDOWNSEND) {
  786. X        errno = EPIPE;
  787. X        return(-1);
  788. X    }
  789. X    if (to == NULL) {
  790. X        if (!(sp->state & MC_BOUND)) {
  791. X            errno = EPIPE;
  792. X            return(-1);
  793. X        }
  794. X        return(_mc_write(s, buf, len, flags, NULL));
  795. X    }
  796. X    if (tolen < sizeof(struct sockaddr_mcast)) {
  797. X        errno = EINVAL;
  798. X        return(-1);
  799. X    }
  800. X    if (np->family != sp->family) {
  801. X        errno = EAFNOSUPPORT;
  802. X        return(-1);
  803. X    }
  804. X    if (MCADDR_EQ(np->member, MCD_MCADDR)) {
  805. X        /* don't want to let them confuse the server ... */
  806. X        errno = EINVAL;
  807. X        return(-1);
  808. X    }
  809. X    if (sp->state & MC_BOUND) {
  810. X        if (!MCADDR_EQ(np->group, sp->group)) {
  811. X            /* can't send to other groups -- this is a mis-feature
  812. X               according to Birman circa early '92 */
  813. X            errno = EISCONN;
  814. X            return(-1);
  815. X        }
  816. X    } else {
  817. X        /* implied bind ... */
  818. X        struct sockaddr_mcast local;
  819. X
  820. X        local.family = sp->family;
  821. X        local.group = np->group;
  822. X        local.member = MCADDR_ANY;
  823. X        if (mc_bind(s, (struct sockaddr *)&local, sizeof(local)) < 0)
  824. X            return(-1);
  825. X    }
  826. X    return(_mc_write(s, buf, len, flags, &np->member));
  827. X}
  828. END_OF_FILE
  829. if test 3833 -ne `wc -c <'libmcast/mc_sendto.c'`; then
  830.     echo shar: \"'libmcast/mc_sendto.c'\" unpacked with wrong size!
  831. fi
  832. # end of 'libmcast/mc_sendto.c'
  833. fi
  834. if test -f 'libmcast/mc_socket.c' -a "${1}" != "-c" ; then 
  835.   echo shar: Will not clobber existing file \"'libmcast/mc_socket.c'\"
  836. else
  837. echo shar: Extracting \"'libmcast/mc_socket.c'\" \(4363 characters\)
  838. sed "s/^X//" >'libmcast/mc_socket.c' <<'END_OF_FILE'
  839. X/*
  840. X * $Header: /u0/casey/src/mcast/libmcast/RCS/mc_socket.c,v 1.3 93/03/17 09:22:38 casey Exp $
  841. X */
  842. X
  843. X/*
  844. X * Copyright (c) 1992 The Regents of the University of California.
  845. X * All rights reserved.
  846. X *
  847. X * Redistribution and use in source and binary forms, with or without
  848. X * modification, are permitted provided that the following conditions
  849. X * are met:
  850. X * 1. Redistributions of source code must retain the above copyright
  851. X *    notice, this list of conditions and the following disclaimer.
  852. X * 2. Redistributions in binary form must reproduce the above copyright
  853. X *    notice, this list of conditions and the following disclaimer in the
  854. X *    documentation and/or other materials provided with the distribution.
  855. X * 3. All advertising materials mentioning features or use of this software
  856. X *    must display the following acknowledgement:
  857. X *    This product includes software developed by the University of
  858. X *    California, Lawrence Livermore National Laboratory and its
  859. X *    contributors.
  860. X * 4. Neither the name of the University nor the names of its contributors
  861. X *    may be used to endorse or promote products derived from this software
  862. X *    without specific prior written permission.
  863. X *
  864. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  865. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  866. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  867. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  868. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  869. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  870. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  871. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  872. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  873. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  874. X * SUCH DAMAGE.
  875. X */
  876. X
  877. X#ifndef lint
  878. static char rcsid[] = "$Header: /u0/casey/src/mcast/libmcast/RCS/mc_socket.c,v 1.3 93/03/17 09:22:38 casey Exp $";
  879. static char copyright[] =
  880. X    "Copyright (c) 1992 The Regents of the University of California.\n"
  881. X    "All rights reserved.\n";
  882. static char classification[] =
  883. X    "Unclassified\n";
  884. X#endif
  885. X
  886. X
  887. X/*
  888. X * MCAST SYSLIB PUBLIC: mc_socket: socket(2) system call emulation routine.
  889. X */
  890. X
  891. X
  892. X#include "mc_lib.h"
  893. X
  894. X
  895. int
  896. mc_socket(int domain, int type, int protocol)
  897. X{
  898. X    int s;
  899. X    struct sockaddr_in server;
  900. X
  901. X    /* qualify arguments */
  902. X    if (domain != PF_MCAST && domain != PF_AMCAST) {
  903. X        errno = EPFNOSUPPORT;
  904. X        return(-1);
  905. X    }
  906. X    if (type != SOCK_SEQPACKET && type != SOCK_STREAM
  907. X        && (domain == PF_AMCAST
  908. X        || (type != SOCK_DGRAM && type != SOCK_RDM))) {
  909. X        /* note that SOCK_RAW isn't supported -- need to think about
  910. X           what SOCK_RAW would mean ... */
  911. X        errno = EPROTONOSUPPORT;
  912. X        return(-1);
  913. X    }
  914. X    if (protocol != 0) {
  915. X        errno = EPROTONOSUPPORT;
  916. X        return(-1);
  917. X    }
  918. X    s = socket(PF_INET, SOCK_STREAM, 0);
  919. X    if (s < 0)
  920. X        return(-1);
  921. X    if (s >= MC_MAX_CONNECTIONS) {
  922. X        (void)close(s);
  923. X        errno = EMFILE;
  924. X        return(-1);
  925. X    }
  926. X
  927. X    (void)memset(&server, 0, sizeof(server));
  928. X    server.sin_family = PF_INET;
  929. X
  930. X    /* get multicast server information */
  931. X    {
  932. X        char *server_name;
  933. X        struct hostent *hp;
  934. X
  935. X        server_name = getenv(MCD_SERVER_ENV);
  936. X        if (server_name == NULL)
  937. X            server_name = MCD_SERVER_NAME;
  938. X        hp = gethostbyname(server_name);
  939. X        if (hp != NULL)
  940. X            (void)memcpy(&server.sin_addr, hp->h_addr, hp->h_length);
  941. X        else
  942. X            server.sin_addr.s_addr = MCD_SERVER_HOST;
  943. X    }
  944. X
  945. X    /* get multicast server port information */
  946. X    {
  947. X        char *env;
  948. X        struct servent *sp;
  949. X        extern struct servent *getservbyname(const char *, const char *);
  950. X
  951. X        env = getenv(MCD_SERVICE_ENV);
  952. X        if (env != NULL)
  953. X            server.sin_port = htons(atoi(env));
  954. X        else {
  955. X            sp = getservbyname(MCD_SERVICE_NAME, "tcp");
  956. X            if (sp != NULL)
  957. X                server.sin_port = sp->s_port;
  958. X            else
  959. X                server.sin_port = htons(MCD_SERVICE_PORT);
  960. X        }
  961. X    }
  962. X
  963. X    /* try to establish connection with the server */
  964. X    if (connect(s, &server, sizeof(server)) < 0) {
  965. X        int e = errno;
  966. X
  967. X        (void)close(s);
  968. X        errno = e;
  969. X        return(-1);
  970. X    }
  971. X
  972. X    {
  973. X        mc_state *sp = &_mc_state[s];
  974. X
  975. X        sp->type = type;
  976. X        sp->family = domain;
  977. X        sp->protocol = protocol;
  978. X        sp->group = MCADDR_ANY;
  979. X        sp->local = MCADDR_ANY;
  980. X        sp->remote = MCADDR_BROADCAST;
  981. X        sp->state = MC_VALID;
  982. X        sp->flags = O_RDWR;
  983. X        sp->resid = 0;
  984. X    }
  985. X    return(s);
  986. X}
  987. END_OF_FILE
  988. if test 4363 -ne `wc -c <'libmcast/mc_socket.c'`; then
  989.     echo shar: \"'libmcast/mc_socket.c'\" unpacked with wrong size!
  990. fi
  991. # end of 'libmcast/mc_socket.c'
  992. fi
  993. if test -f 'libmcast/mcast_getgroupbyname.c' -a "${1}" != "-c" ; then 
  994.   echo shar: Will not clobber existing file \"'libmcast/mcast_getgroupbyname.c'\"
  995. else
  996. echo shar: Extracting \"'libmcast/mcast_getgroupbyname.c'\" \(3805 characters\)
  997. sed "s/^X//" >'libmcast/mcast_getgroupbyname.c' <<'END_OF_FILE'
  998. X/*
  999. X * $Header: /u0/casey/src/mcast/libmcast/RCS/mcast_getgroupbyname.c,v 1.4 93/03/17 11:36:11 casey Exp $
  1000. X */
  1001. X
  1002. X/*
  1003. X * Copyright (c) 1992 The Regents of the University of California.
  1004. X * All rights reserved.
  1005. X *
  1006. X * Redistribution and use in source and binary forms, with or without
  1007. X * modification, are permitted provided that the following conditions
  1008. X * are met:
  1009. X * 1. Redistributions of source code must retain the above copyright
  1010. X *    notice, this list of conditions and the following disclaimer.
  1011. X * 2. Redistributions in binary form must reproduce the above copyright
  1012. X *    notice, this list of conditions and the following disclaimer in the
  1013. X *    documentation and/or other materials provided with the distribution.
  1014. X * 3. All advertising materials mentioning features or use of this software
  1015. X *    must display the following acknowledgement:
  1016. X *    This product includes software developed by the University of
  1017. X *    California, Lawrence Livermore National Laboratory and its
  1018. X *    contributors.
  1019. X * 4. Neither the name of the University nor the names of its contributors
  1020. X *    may be used to endorse or promote products derived from this software
  1021. X *    without specific prior written permission.
  1022. X *
  1023. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1024. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1025. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1026. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1027. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1028. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1029. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1030. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1031. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1032. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1033. X * SUCH DAMAGE.
  1034. X */
  1035. X
  1036. X#ifndef lint
  1037. static char rcsid[] = "$Header: /u0/casey/src/mcast/libmcast/RCS/mcast_getgroupbyname.c,v 1.4 93/03/17 11:36:11 casey Exp $";
  1038. static char copyright[] =
  1039. X    "Copyright (c) 1992 The Regents of the University of California.\n"
  1040. X    "All rights reserved.\n";
  1041. static char classification[] =
  1042. X    "Unclassified\n";
  1043. X#endif
  1044. X
  1045. X
  1046. X/*
  1047. X * MCAST STDLIB PUBLIC: mcast_getgroupbyname standard library routine.
  1048. X */
  1049. X
  1050. X
  1051. X#include <errno.h>
  1052. X#include <stddef.h>
  1053. X#include <stdlib.h>
  1054. X#include <string.h>
  1055. X#include <unistd.h>
  1056. X
  1057. X#include <sys/types.h>
  1058. X#include <sys/socket.h>
  1059. X#include <netmcast/mcast.h>
  1060. X
  1061. X
  1062. struct ret { /* structure of malloced return */
  1063. X    struct mcastent    ent;        /* MUST BE FIRST! */
  1064. X    char        *aliases[1];    /* alias list */
  1065. X    char        name[1];    /* canonical name */
  1066. X};
  1067. X
  1068. struct mcastent *
  1069. mcast_getgroupbyname(const char *name, int domain)
  1070. X    /*
  1071. X     * Look up multicast group by name in the indicated multicast protocol
  1072. X     * domain and return pointer to a struct mcastent in malloced memory.
  1073. X     * On error return NULL and leave an error in errno.
  1074. X     *
  1075. X     * NOTE: The name lookup is *completely* fake at this point.  All that
  1076. X     *       we do is copy the group name opaquely into the address entry of
  1077. X     *       the mcastent structure ...
  1078. X     *
  1079. X     * NOTE: All these application specific name service thingies are really
  1080. X     *       a pain.  We really should have a completely general name server.
  1081. X     */
  1082. X{
  1083. X    struct ret *rp = (struct ret *)malloc(sizeof(struct ret) + strlen(name));
  1084. X
  1085. X    if (rp == NULL) {
  1086. X        errno = ENOMEM;
  1087. X        return(NULL);
  1088. X    }
  1089. X    rp->ent.name = rp->name;
  1090. X    (void)strcpy(rp->name, name);
  1091. X    rp->ent.aliases = rp->aliases;
  1092. X    rp->aliases[0] = NULL;
  1093. X    rp->ent.family = domain;
  1094. X    (void)memset(&rp->ent.address, 0, sizeof(rp->ent.address));
  1095. X    (void)strncpy((char *)&rp->ent.address, name, sizeof(rp->ent.address));
  1096. X    return(&rp->ent);
  1097. X}
  1098. END_OF_FILE
  1099. if test 3805 -ne `wc -c <'libmcast/mcast_getgroupbyname.c'`; then
  1100.     echo shar: \"'libmcast/mcast_getgroupbyname.c'\" unpacked with wrong size!
  1101. fi
  1102. # end of 'libmcast/mcast_getgroupbyname.c'
  1103. fi
  1104. if test -f 'libmcast/mcast_newaddr.c' -a "${1}" != "-c" ; then 
  1105.   echo shar: Will not clobber existing file \"'libmcast/mcast_newaddr.c'\"
  1106. else
  1107. echo shar: Extracting \"'libmcast/mcast_newaddr.c'\" \(4649 characters\)
  1108. sed "s/^X//" >'libmcast/mcast_newaddr.c' <<'END_OF_FILE'
  1109. X/*
  1110. X * $Header: /u0/casey/src/mcast/libmcast/RCS/mcast_newaddr.c,v 1.2 92/11/17 16:56:17 casey Exp $
  1111. X */
  1112. X
  1113. X/*
  1114. X * Copyright (c) 1992 The Regents of the University of California.
  1115. X * All rights reserved.
  1116. X *
  1117. X * Redistribution and use in source and binary forms, with or without
  1118. X * modification, are permitted provided that the following conditions
  1119. X * are met:
  1120. X * 1. Redistributions of source code must retain the above copyright
  1121. X *    notice, this list of conditions and the following disclaimer.
  1122. X * 2. Redistributions in binary form must reproduce the above copyright
  1123. X *    notice, this list of conditions and the following disclaimer in the
  1124. X *    documentation and/or other materials provided with the distribution.
  1125. X * 3. All advertising materials mentioning features or use of this software
  1126. X *    must display the following acknowledgement:
  1127. X *    This product includes software developed by the University of
  1128. X *    California, Lawrence Livermore National Laboratory and its
  1129. X *    contributors.
  1130. X * 4. Neither the name of the University nor the names of its contributors
  1131. X *    may be used to endorse or promote products derived from this software
  1132. X *    without specific prior written permission.
  1133. X *
  1134. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1135. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1136. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1137. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1138. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1139. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1140. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1141. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1142. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1143. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1144. X * SUCH DAMAGE.
  1145. X */
  1146. X
  1147. X#ifndef lint
  1148. static char rcsid[] = "$Header: /u0/casey/src/mcast/libmcast/RCS/mcast_newaddr.c,v 1.2 92/11/17 16:56:17 casey Exp $";
  1149. static char copyright[] =
  1150. X    "Copyright (c) 1992 The Regents of the University of California.\n"
  1151. X    "All rights reserved.\n";
  1152. static char classification[] =
  1153. X    "Unclassified\n";
  1154. X#endif
  1155. X
  1156. X
  1157. X/*
  1158. X * MCAST STDLIB PUBLIC: mcast_sopen standard library routine.
  1159. X */
  1160. X
  1161. X
  1162. X#include <errno.h>
  1163. X#include <stddef.h>
  1164. X#include <stdlib.h>
  1165. X#include <string.h>
  1166. X#include <unistd.h>
  1167. X
  1168. X#include <sys/types.h>
  1169. X#include <sys/socket.h>
  1170. X#include <netmcast/mcast.h>
  1171. X
  1172. X
  1173. int
  1174. mcast_newaddr(mc_addr *addr)
  1175. X    /*
  1176. X     * Create a new unique multicast address.
  1177. X     *
  1178. X     * Multicast addresses are opaque, so it doesn't matter what makes them
  1179. X     * unique, and in fact, a multicast address created by a process on one
  1180. X     * host can be used by a process on another machine.  This allows for
  1181. X     * the possibility of process migration.
  1182. X     *
  1183. X     * This version of mcast_newaddr uses a combination of the creating
  1184. X     * host and process' IDs, the current time, and a sequence number to
  1185. X     * insure uniqueness.  This allows us to create unique multicast
  1186. X     * addresses in a totally distributed manner.
  1187. X     *
  1188. X     * NOTE: This really needs to be a system call since bind(2) uses it
  1189. X     *       to generate new multicast member addresses when MCADDR_ANY is
  1190. X     *       passed * to bind as a member address.  However, the idea of a
  1191. X     *       system call * unique to the multicast protocol is disgusting.
  1192. X     *       two ideas for candidate system calls are:
  1193. X     *
  1194. X     *           int newaddr(int domain, int level, void *name, int *namelen)
  1195. X     *
  1196. X     *       and
  1197. X     *
  1198. X     *           int newdistid(distid *id)
  1199. X     *
  1200. X     *       The problem with the first is that it assumes that the
  1201. X     *       concept of generating new unique addresses has meaning for
  1202. X     *       anything other than the multicast protocol (i.e. we're guilty
  1203. X     *       of over generalization) and the problem with the second is
  1204. X     *       that it assumes that there will only ever be one form of
  1205. X     *       distributed id that we'll ever need (i.e. we're guilty of
  1206. X     *       naivete).  The answer probably lays somewhere in between.
  1207. X     */
  1208. X{
  1209. X    static time_t lasttime = 0;
  1210. X    static unsigned long lastsequence = 0;
  1211. X    extern long gethostid(void);
  1212. X
  1213. X    (void)memset(addr, 0, sizeof(*addr));
  1214. X    addr->host = gethostid();
  1215. X    addr->process = getpid();
  1216. X    addr->time = time(0);
  1217. X    if (addr->time == lasttime) {
  1218. X        if (lastsequence+1 < lastsequence) {
  1219. X            errno = EAGAIN;
  1220. X            return(-1);
  1221. X        }
  1222. X        lastsequence++;
  1223. X    } else {
  1224. X        lasttime = addr->time;
  1225. X        lastsequence = 0;
  1226. X    }
  1227. X    addr->sequence = lastsequence;
  1228. X    return(0);
  1229. X}
  1230. END_OF_FILE
  1231. if test 4649 -ne `wc -c <'libmcast/mcast_newaddr.c'`; then
  1232.     echo shar: \"'libmcast/mcast_newaddr.c'\" unpacked with wrong size!
  1233. fi
  1234. # end of 'libmcast/mcast_newaddr.c'
  1235. fi
  1236. if test -f 'libmcast/mcast_sopen.c' -a "${1}" != "-c" ; then 
  1237.   echo shar: Will not clobber existing file \"'libmcast/mcast_sopen.c'\"
  1238. else
  1239. echo shar: Extracting \"'libmcast/mcast_sopen.c'\" \(4387 characters\)
  1240. sed "s/^X//" >'libmcast/mcast_sopen.c' <<'END_OF_FILE'
  1241. X/*
  1242. X * $Header: /u0/casey/src/mcast/libmcast/RCS/mcast_sopen.c,v 1.4 93/03/17 11:36:08 casey Exp $
  1243. X */
  1244. X
  1245. X/*
  1246. X * Copyright (c) 1992 The Regents of the University of California.
  1247. X * All rights reserved.
  1248. X *
  1249. X * Redistribution and use in source and binary forms, with or without
  1250. X * modification, are permitted provided that the following conditions
  1251. X * are met:
  1252. X * 1. Redistributions of source code must retain the above copyright
  1253. X *    notice, this list of conditions and the following disclaimer.
  1254. X * 2. Redistributions in binary form must reproduce the above copyright
  1255. X *    notice, this list of conditions and the following disclaimer in the
  1256. X *    documentation and/or other materials provided with the distribution.
  1257. X * 3. All advertising materials mentioning features or use of this software
  1258. X *    must display the following acknowledgement:
  1259. X *    This product includes software developed by the University of
  1260. X *    California, Lawrence Livermore National Laboratory and its
  1261. X *    contributors.
  1262. X * 4. Neither the name of the University nor the names of its contributors
  1263. X *    may be used to endorse or promote products derived from this software
  1264. X *    without specific prior written permission.
  1265. X *
  1266. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1267. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1268. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1269. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1270. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1271. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1272. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1273. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1274. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1275. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1276. X * SUCH DAMAGE.
  1277. X */
  1278. X
  1279. X#ifndef lint
  1280. static char rcsid[] = "$Header: /u0/casey/src/mcast/libmcast/RCS/mcast_sopen.c,v 1.4 93/03/17 11:36:08 casey Exp $";
  1281. static char copyright[] =
  1282. X    "Copyright (c) 1992 The Regents of the University of California.\n"
  1283. X    "All rights reserved.\n";
  1284. static char classification[] =
  1285. X    "Unclassified\n";
  1286. X#endif
  1287. X
  1288. X
  1289. X/*
  1290. X * MCAST STDLIB PUBLIC: mcast_sopen standard library routine.
  1291. X */
  1292. X
  1293. X
  1294. X#include <errno.h>
  1295. X#include <stddef.h>
  1296. X#include <stdlib.h>
  1297. X#include <string.h>
  1298. X#include <unistd.h>
  1299. X
  1300. X#include <fcntl.h>
  1301. X#include <sys/types.h>
  1302. X#include <sys/socket.h>
  1303. X#include <netmcast/mcast.h>
  1304. X
  1305. X
  1306. int
  1307. mcast_sopen(const char *group, int domain, int type, int mode)
  1308. X    /*
  1309. X     * Open a connection to the indicated group and return an open file
  1310. X     * descriptor.
  1311. X     *
  1312. X     * NOTE: This turns out to be a nice little routine.  It allows us to
  1313. X     *       write totally trivial multicast applications of only a few
  1314. X     *       lines.  But it would be nice to generalize it somewhat so it
  1315. X     *       could be used for nicely opening up general socket
  1316. X     *       connections.  Thus, one could do s = sopen(...) and either
  1317. X     *       get a failure or a completely set up, connected, etc. socket.
  1318. X     *       Haven't quite figured out what something like "sopen"
  1319. X     *       should look like though, so for now we have this special
  1320. X     *       purpose routine.
  1321. X     */
  1322. X{
  1323. X     int s, accmode, flags;
  1324. X     struct sockaddr_mcast addr;
  1325. X     struct mcastent *mp;
  1326. X
  1327. X    accmode = mode & O_ACCMODE;
  1328. X    flags = mode & ~O_ACCMODE;
  1329. X    if (accmode != O_RDWR && accmode != O_RDONLY && accmode != O_WRONLY) {
  1330. X        errno = EINVAL;
  1331. X        return(-1);
  1332. X    }
  1333. X    s = mc_socket(domain, type, 0);
  1334. X    if (s < 0)
  1335. X        return(-1);
  1336. X    if (accmode != O_RDWR) {
  1337. X        int how;
  1338. X
  1339. X        if (accmode == O_WRONLY)
  1340. X            how = 0;
  1341. X        else if (accmode == O_RDONLY)
  1342. X            how = 1;
  1343. X        if (mc_shutdown(s, how) < 0) {
  1344. X            int e = errno;
  1345. X
  1346. X            (void)mc_close(s);
  1347. X            errno = e;
  1348. X            return(-1);
  1349. X        }
  1350. X    }
  1351. X    if (flags && mc_fcntl(s, F_SETFL, flags) < 0) {
  1352. X        int e = errno;
  1353. X
  1354. X        (void)mc_close(s);
  1355. X        errno = e;
  1356. X        return(-1);
  1357. X    }
  1358. X    mp = mcast_getgroupbyname(group, domain);
  1359. X    if (mp == NULL) {
  1360. X        int e = errno;
  1361. X
  1362. X        (void)mc_close(s);
  1363. X        errno = e;
  1364. X        return(-1);
  1365. X    }
  1366. X    (void)memset(&addr, 0, sizeof(addr));
  1367. X    addr.family = mp->family;
  1368. X    addr.group = mp->address;
  1369. X    addr.member = MCADDR_ANY;
  1370. X    free(mp);
  1371. X    if (mc_bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
  1372. X        int e = errno;
  1373. X
  1374. X        (void)mc_close(s);
  1375. X        errno = e;
  1376. X        return(-1);
  1377. X    }
  1378. X    return(s);
  1379. X}
  1380. END_OF_FILE
  1381. if test 4387 -ne `wc -c <'libmcast/mcast_sopen.c'`; then
  1382.     echo shar: \"'libmcast/mcast_sopen.c'\" unpacked with wrong size!
  1383. fi
  1384. # end of 'libmcast/mcast_sopen.c'
  1385. fi
  1386. if test -f 'man/mc_bind.2' -a "${1}" != "-c" ; then 
  1387.   echo shar: Will not clobber existing file \"'man/mc_bind.2'\"
  1388. else
  1389. echo shar: Extracting \"'man/mc_bind.2'\" \(4223 characters\)
  1390. sed "s/^X//" >'man/mc_bind.2' <<'END_OF_FILE'
  1391. X.\" Copyright (c) 1992 The Regents of the University of California.
  1392. X.\" All rights reserved.
  1393. X.\"
  1394. X.\" Redistribution and use in source and binary forms, with or without
  1395. X.\" modification, are permitted provided that the following conditions
  1396. X.\" are met:
  1397. X.\" 1. Redistributions of source code must retain the above copyright
  1398. X.\"    notice, this list of conditions and the following disclaimer.
  1399. X.\" 2. Redistributions in binary form must reproduce the above copyright
  1400. X.\"    notice, this list of conditions and the following disclaimer in the
  1401. X.\"    documentation and/or other materials provided with the distribution.
  1402. X.\" 3. All advertising materials mentioning features or use of this software
  1403. X.\"    must display the following acknowledgement:
  1404. X.\"    This product includes software developed by the University of
  1405. X.\"    California, Lawrence Livermore National Laboratory and its
  1406. X.\"    contributors.
  1407. X.\" 4. Neither the name of the University nor the names of its contributors
  1408. X.\"    may be used to endorse or promote products derived from this software
  1409. X.\"    without specific prior written permission.
  1410. X.\"
  1411. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1412. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1413. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1414. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1415. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1416. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1417. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1418. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1419. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1420. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1421. X.\" SUCH DAMAGE.
  1422. X.\"
  1423. X.de Hd
  1424. X.ds Dt \\$4
  1425. X..
  1426. X.Hd $Header: /u0/casey/src/mcast/man/RCS/mc_bind.2,v 1.2 93/01/16 20:00:27 casey Exp $
  1427. X.TH MC_BIND 2 \*(Dt
  1428. X.SH NAME
  1429. mc_bind \- bind a name to a multicast socket
  1430. X.SH SYNOPSIS
  1431. X.nf
  1432. X.ft B
  1433. X#include <sys/types.h>
  1434. X#include <sys/socket.h>
  1435. X#include <netmcast/mcast.h>
  1436. X
  1437. int
  1438. mc_bind(int s, const struct sockaddr *name, int namelen)
  1439. X.ft P
  1440. X.fi
  1441. X.SH DESCRIPTION
  1442. X.I Mc_bind
  1443. assigns a name to an unnamed multicast socket.
  1444. When a multicast socket is created 
  1445. with
  1446. X.IR mc_socket (2)
  1447. it exists in the multicast name space (address family)
  1448. but has no name assigned.
  1449. X.I Mc_bind
  1450. requests that
  1451. X.I name
  1452. be assigned to the multicast socket.
  1453. X.PP
  1454. X.I Mc_bind
  1455. may only be called once on any multicast socket.  If the multicast
  1456. member address specified in
  1457. X.I name
  1458. is
  1459. MCADDR_ANY,
  1460. X.I mc_bind
  1461. will use a new, unique group member address (see
  1462. X.IR mcast_newaddr (3)).
  1463. See the manual page
  1464. X.IR mcast (4)
  1465. for detailed information on the rules for binding names in the
  1466. multicast communication domain.
  1467. X.SH COMPATIBILITY
  1468. The
  1469. X.I mc_bind
  1470. call emulates the
  1471. X.IR bind (2)
  1472. system call for multicast socket descriptors created with the
  1473. X.IR mc_socket (2)
  1474. call.
  1475. See the manual page for
  1476. X.IR bind (2)
  1477. for a description of the emulated semantics.
  1478. X.I Mc_bind
  1479. does not provide any different semantics from
  1480. X.IR bind (2).
  1481. X.SH "RETURN VALUES"
  1482. If the
  1483. X.I mc_bind
  1484. is successful, a 0 value is returned.
  1485. A return value of -1 indicates an error, which is
  1486. further specified in the global variable
  1487. X.IR errno .
  1488. X.SH ERRORS
  1489. See the manual page for
  1490. X.IR bind (2)
  1491. for a detailed list of errors associated with the general
  1492. X.IR bind (2)
  1493. system call.
  1494. X.I Mc_bind
  1495. itself will fail if:
  1496. X.TP 20
  1497. X[EBADF]
  1498. X.I S
  1499. is not a valid multicast socket descriptor as returned by
  1500. X.IR mc_socket (2).
  1501. X.TP 20
  1502. X[EIO]
  1503. The socket state has become corrupted.  This is an artifact of a
  1504. client/server implementation of the multicast communication system.
  1505. X.TP 20
  1506. X[EINVAL]
  1507. X.I Namelen
  1508. is less than
  1509. X.IR sizeof ( mc_addr ).
  1510. X.TP 20
  1511. X[EISCONN]
  1512. The socket already has a local name bound to it.
  1513. X.TP 20
  1514. X[EAFNOSUPPORT]
  1515. The address family specified by
  1516. X.I name
  1517. is not
  1518. AF_MCAST
  1519. X(See
  1520. X.IR mcast (4)).
  1521. X.SH SEE ALSO
  1522. X.IR bind (2),
  1523. X.IR mc_socket (2),
  1524. X.IR mcast (4)
  1525. X.SH STANDARDS
  1526. There are no current standards that address multicast communication.
  1527. The software described in this manual page is experimental and subject
  1528. to change at any time.
  1529. END_OF_FILE
  1530. if test 4223 -ne `wc -c <'man/mc_bind.2'`; then
  1531.     echo shar: \"'man/mc_bind.2'\" unpacked with wrong size!
  1532. fi
  1533. # end of 'man/mc_bind.2'
  1534. fi
  1535. if test -f 'man/mc_connect.2' -a "${1}" != "-c" ; then 
  1536.   echo shar: Will not clobber existing file \"'man/mc_connect.2'\"
  1537. else
  1538. echo shar: Extracting \"'man/mc_connect.2'\" \(4807 characters\)
  1539. sed "s/^X//" >'man/mc_connect.2' <<'END_OF_FILE'
  1540. X.\" Copyright (c) 1992 The Regents of the University of California.
  1541. X.\" All rights reserved.
  1542. X.\"
  1543. X.\" Redistribution and use in source and binary forms, with or without
  1544. X.\" modification, are permitted provided that the following conditions
  1545. X.\" are met:
  1546. X.\" 1. Redistributions of source code must retain the above copyright
  1547. X.\"    notice, this list of conditions and the following disclaimer.
  1548. X.\" 2. Redistributions in binary form must reproduce the above copyright
  1549. X.\"    notice, this list of conditions and the following disclaimer in the
  1550. X.\"    documentation and/or other materials provided with the distribution.
  1551. X.\" 3. All advertising materials mentioning features or use of this software
  1552. X.\"    must display the following acknowledgement:
  1553. X.\"    This product includes software developed by the University of
  1554. X.\"    California, Lawrence Livermore National Laboratory and its
  1555. X.\"    contributors.
  1556. X.\" 4. Neither the name of the University nor the names of its contributors
  1557. X.\"    may be used to endorse or promote products derived from this software
  1558. X.\"    without specific prior written permission.
  1559. X.\"
  1560. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1561. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1562. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1563. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1564. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1565. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1566. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1567. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1568. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1569. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1570. X.\" SUCH DAMAGE.
  1571. X.\"
  1572. X.de Hd
  1573. X.ds Dt \\$4
  1574. X..
  1575. X.Hd $Header: /u0/casey/src/mcast/man/RCS/mc_connect.2,v 1.2 93/01/16 20:01:13 casey Exp $
  1576. X.TH MC_CONNECT 2 \*(Dt
  1577. X.SH NAME
  1578. mc_connect \- create an association between a multicast socket and a remote name
  1579. X.SH SYNOPSIS
  1580. X.nf
  1581. X.ft B
  1582. X#include <sys/types.h>
  1583. X#include <sys/socket.h>
  1584. X#include <netmcast/mcast.h>
  1585. X
  1586. int
  1587. mc_connect(int s, const struct sockaddr *name, int namelen)
  1588. X.ft P
  1589. X.fi
  1590. X.SH DESCRIPTION
  1591. The parameter
  1592. X.I s
  1593. is a multicast socket as returned by
  1594. X.IR mc_socket (2).
  1595. This call specifies the multicast group peer member with which the
  1596. socket is to be associated; messages sent with
  1597. X.I mc_write
  1598. and
  1599. X.I mc_send
  1600. will be sent to the indicated remote address.
  1601. X.PP
  1602. If
  1603. X.I s
  1604. has not had a name bound to it previously,
  1605. X.I mc_connect
  1606. will automatically bind a name to the socket using the multicast group
  1607. specified in
  1608. X.I name
  1609. and a new, local unique group member address (see
  1610. X.IR mcast_newaddr (3)).
  1611. If
  1612. X.I s
  1613. already has a name bound to it,
  1614. X.I name
  1615. must specify the same multicast group as that already bound to
  1616. the socket; only the multicast group peer member may be changed.
  1617. X.PP
  1618. Multicast sockets may use
  1619. X.I mc_connect
  1620. multiple times to change their remote peer association
  1621. regardless of socket type.  Connecting to MCADDR_BROADCAST or to
  1622. any address in the AF_UNSPEC address family causes future
  1623. messages to be sent to the entire multicast group.
  1624. X.SH COMPATIBILITY
  1625. The
  1626. X.I mc_connect
  1627. call emulates the
  1628. X.IR connect (2)
  1629. system call for multicast socket descriptors created with the
  1630. X.IR mc_socket (2)
  1631. call.
  1632. See the manual page for
  1633. X.IR connect (2)
  1634. for a description of the emulated semantics.
  1635. X.I Mc_connect
  1636. does not provide any different semantics from
  1637. X.IR connect (2).
  1638. X.SH "RETURN VALUES"
  1639. If the connection or binding succeeds, 0 is returned.
  1640. Otherwise a -1 is returned, and a more specific error
  1641. code is stored in
  1642. X.IR errno .
  1643. X.SH ERRORS
  1644. See the manual page for
  1645. X.IR connect (2)
  1646. for a detailed list of errors associated with the general
  1647. X.IR connect (2)
  1648. system call.
  1649. X.I Mc_connect
  1650. itself will fail if:
  1651. X.TP 20
  1652. X[EBADF]
  1653. X.I S
  1654. is not a valid multicast socket descriptor as returned by
  1655. X.IR mc_socket (2).
  1656. X.TP 20
  1657. X[EIO]
  1658. The socket state has become corrupted.  This is an artifact of a
  1659. client/server implementation of the multicast communication system.
  1660. X.TP 20
  1661. X[EINVAL]
  1662. X.I Namelen
  1663. is less than
  1664. X.IR sizeof ( mc_addr ).
  1665. X.TP 20
  1666. X[EINVAL]
  1667. The multicast group selected is one of the reserved group addresses
  1668. MCADDR_BROADCAST
  1669. or
  1670. MCADDR_ANY.
  1671. X.TP 20
  1672. X[EISCONN]
  1673. The multicast group selected is not the same as the one already bound to
  1674. the socket.
  1675. X.TP 20
  1676. X[EAFNOSUPPORT]
  1677. The address family specified by
  1678. X.I name
  1679. is neither
  1680. X.I AF_MCAST
  1681. nor
  1682. X.IR AF_UNSPEC .
  1683. X.SH "SEE ALSO"
  1684. X.IR connect (2),
  1685. X.IR mc_bind (2),
  1686. X.IR mc_getpeername (2),
  1687. X.IR mc_socket (2),
  1688. X.IR mcast (4)
  1689. X.SH STANDARDS
  1690. There are no current standards that address multicast communication.
  1691. The software described in this manual page is experimental and subject
  1692. to change at any time.
  1693. END_OF_FILE
  1694. if test 4807 -ne `wc -c <'man/mc_connect.2'`; then
  1695.     echo shar: \"'man/mc_connect.2'\" unpacked with wrong size!
  1696. fi
  1697. # end of 'man/mc_connect.2'
  1698. fi
  1699. if test -f 'man/mc_fcntl.2' -a "${1}" != "-c" ; then 
  1700.   echo shar: Will not clobber existing file \"'man/mc_fcntl.2'\"
  1701. else
  1702. echo shar: Extracting \"'man/mc_fcntl.2'\" \(4466 characters\)
  1703. sed "s/^X//" >'man/mc_fcntl.2' <<'END_OF_FILE'
  1704. X.\" Copyright (c) 1992 The Regents of the University of California.
  1705. X.\" All rights reserved.
  1706. X.\"
  1707. X.\" Redistribution and use in source and binary forms, with or without
  1708. X.\" modification, are permitted provided that the following conditions
  1709. X.\" are met:
  1710. X.\" 1. Redistributions of source code must retain the above copyright
  1711. X.\"    notice, this list of conditions and the following disclaimer.
  1712. X.\" 2. Redistributions in binary form must reproduce the above copyright
  1713. X.\"    notice, this list of conditions and the following disclaimer in the
  1714. X.\"    documentation and/or other materials provided with the distribution.
  1715. X.\" 3. All advertising materials mentioning features or use of this software
  1716. X.\"    must display the following acknowledgement:
  1717. X.\"    This product includes software developed by the University of
  1718. X.\"    California, Lawrence Livermore National Laboratory and its
  1719. X.\"    contributors.
  1720. X.\" 4. Neither the name of the University nor the names of its contributors
  1721. X.\"    may be used to endorse or promote products derived from this software
  1722. X.\"    without specific prior written permission.
  1723. X.\"
  1724. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1725. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1726. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1727. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1728. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1729. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1730. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1731. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1732. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1733. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1734. X.\" SUCH DAMAGE.
  1735. X.\"
  1736. X.de Hd
  1737. X.ds Dt \\$4
  1738. X..
  1739. X.Hd $Header: /u0/casey/src/mcast/man/RCS/mc_fcntl.2,v 1.1 92/10/16 18:23:00 casey Exp $
  1740. X.TH MC_FCNTL 2 \*(Dt
  1741. X.SH NAME
  1742. mc_fcntl \- multicast socket control
  1743. X.SH SYNOPSIS
  1744. X.nf
  1745. X.ft B
  1746. X#include <fcntl.h>
  1747. X#include <sys/types.h>
  1748. X#include <sys/socket.h>
  1749. X#include <netmcast/mast.h>
  1750. X
  1751. int
  1752. mc_fcntl(int s, int request, ...)
  1753. X.ft P
  1754. X.fi
  1755. X.SH DESCRIPTION
  1756. X.I Mc_fcntl
  1757. provides for control over multicast socket descriptors.
  1758. The argument
  1759. X.I s
  1760. is a multicast descriptor.
  1761. X.I Request
  1762. specifies the control operation to be performed on
  1763. X.IR s .
  1764. X.PP
  1765. Some requests require a third argument
  1766. X.BR arg .
  1767. The type of
  1768. X.I arg
  1769. is interpreted differently for different operations.
  1770. XEach
  1771. X.I request
  1772. described below specifies whether
  1773. X.I arg
  1774. is required and, if so, what type it is.
  1775. X.PP
  1776. X.I Requests
  1777. are as follows:
  1778. X.TP 10
  1779. XF_GETFL
  1780. Get descriptor status flags, as described below.
  1781. X.TP 10
  1782. XF_SETFL
  1783. Set descriptor status flags to
  1784. X.IR arg .
  1785. X.PP
  1786. The flags for the
  1787. XF_GETFL
  1788. and
  1789. XF_SETFL
  1790. flags are as follows:
  1791. X.TP 10
  1792. O_NONBLOCK
  1793. Non-blocking I/O; if no data is available to a
  1794. X.I read
  1795. call, or if a
  1796. X.I write
  1797. operation would block,
  1798. the read or write call returns -1 with the error
  1799. XEAGAIN.
  1800. X.TP 10
  1801. MCO_LOOPBACK
  1802. Loop back mode; messages sent on the multicast descriptor
  1803. X.I s
  1804. will be looped back and received on a later read.
  1805. X.SH COMPATIBILITY
  1806. The
  1807. X.I mc_fcntl
  1808. call emulates the
  1809. X.IR fcntl (2)
  1810. system call for multicast socket descriptors created with the
  1811. X.IR mc_socket (2)
  1812. call.
  1813. See the manual page for
  1814. X.IR fcntl (2)
  1815. for a description of the emulated semantics.
  1816. X.I Mc_fcntl
  1817. does not provide any different semantics from
  1818. X.IR fcntl (2).
  1819. X.SH "RETURN VALUES"
  1820. Upon successful completion, the value returned depends on
  1821. X.I request
  1822. as follows:
  1823. X.TP 10
  1824. XF_GETFL
  1825. The value of the descriptor flags.
  1826. X.TP 10
  1827. other
  1828. Value other than -1.
  1829. X.PP
  1830. Otherwise, a value of -1 is returned and
  1831. X.I errno
  1832. is set to indicate the error.
  1833. X.SH ERRORS
  1834. See the manual page for
  1835. X.IR fcntl (2)
  1836. for a detailed list of errors associated with the general
  1837. X.IR fcntl (2)
  1838. system call.
  1839. X.I Mc_fcntl
  1840. itself will fail if:
  1841. X.TP 20
  1842. X[EBADF]
  1843. X.I S
  1844. is not a valid multicast socket descriptor as returned by
  1845. X.IR mc_socket (2).
  1846. X.TP 20
  1847. X[EIO]
  1848. The socket state has become corrupted.  This is an artifact of a
  1849. client/server implementation of the multicast communication system.
  1850. X.TP 20
  1851. X[EINVAL]
  1852. X.I Request
  1853. is not a legal value.
  1854. X.SH SEE ALSO
  1855. X.IR fcntl (2),
  1856. X.IR mc_ioctl (2),
  1857. X.IR mc_socket (2),
  1858. X.IR mcast (4)
  1859. X.SH STANDARDS
  1860. There are no current standards that address multicast communication.
  1861. The software described in this manual page is experimental and subject
  1862. to change at any time.
  1863. END_OF_FILE
  1864. if test 4466 -ne `wc -c <'man/mc_fcntl.2'`; then
  1865.     echo shar: \"'man/mc_fcntl.2'\" unpacked with wrong size!
  1866. fi
  1867. # end of 'man/mc_fcntl.2'
  1868. fi
  1869. if test -f 'man/mc_getpeername.2' -a "${1}" != "-c" ; then 
  1870.   echo shar: Will not clobber existing file \"'man/mc_getpeername.2'\"
  1871. else
  1872. echo shar: Extracting \"'man/mc_getpeername.2'\" \(4059 characters\)
  1873. sed "s/^X//" >'man/mc_getpeername.2' <<'END_OF_FILE'
  1874. X.\" Copyright (c) 1992 The Regents of the University of California.
  1875. X.\" All rights reserved.
  1876. X.\"
  1877. X.\" Redistribution and use in source and binary forms, with or without
  1878. X.\" modification, are permitted provided that the following conditions
  1879. X.\" are met:
  1880. X.\" 1. Redistributions of source code must retain the above copyright
  1881. X.\"    notice, this list of conditions and the following disclaimer.
  1882. X.\" 2. Redistributions in binary form must reproduce the above copyright
  1883. X.\"    notice, this list of conditions and the following disclaimer in the
  1884. X.\"    documentation and/or other materials provided with the distribution.
  1885. X.\" 3. All advertising materials mentioning features or use of this software
  1886. X.\"    must display the following acknowledgement:
  1887. X.\"    This product includes software developed by the University of
  1888. X.\"    California, Lawrence Livermore National Laboratory and its
  1889. X.\"    contributors.
  1890. X.\" 4. Neither the name of the University nor the names of its contributors
  1891. X.\"    may be used to endorse or promote products derived from this software
  1892. X.\"    without specific prior written permission.
  1893. X.\"
  1894. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1895. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1896. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1897. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1898. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1899. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1900. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1901. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1902. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1903. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1904. X.\" SUCH DAMAGE.
  1905. X.\"
  1906. X.de Hd
  1907. X.ds Dt \\$4
  1908. X..
  1909. X.Hd $Header: /u0/casey/src/mcast/man/RCS/mc_getpeername.2,v 1.1 92/10/16 18:23:01 casey Exp $
  1910. X.TH MC_GETPEERNAME 2 \*(Dt
  1911. X.SH NAME
  1912. mc_getpeername \- get remote peer name of multicast socket
  1913. X.SH SYNOPSIS
  1914. X.nf
  1915. X.ft B
  1916. X#include <sys/types.h>
  1917. X#include <sys/socket.h>
  1918. X#include <netmcast/mcast.h>
  1919. X
  1920. int
  1921. mc_getpeername(int s, struct sockaddr *name, int *namelen)
  1922. X.ft P
  1923. X.fi
  1924. X.SH DESCRIPTION
  1925. X.I Mc_getpeername
  1926. returns the name of the remote peer connected to
  1927. multicast socket
  1928. X.IR s .
  1929. The
  1930. X.I namelen
  1931. parameter should be initialized to indicate
  1932. the amount of space pointed to by
  1933. X.IR name .
  1934. On return it contains the actual size of the name
  1935. returned (in bytes).
  1936. The name is truncated if the buffer provided is too small.
  1937. X.PP
  1938. XFor multicast sockets,
  1939. X.I namelen
  1940. should always be equal to
  1941. X.IR "sizeof(struct sockaddr_mcast)" .
  1942. The default remote peer name is
  1943. MCADDR_BROADCAST
  1944. but can be changed via
  1945. X.IR mc_connect (2).
  1946. X.SH COMPATIBILITY
  1947. The
  1948. X.I mc_getpeername
  1949. call emulates the
  1950. X.IR getpeername (2)
  1951. system call for multicast socket descriptors created with the
  1952. X.IR mc_socket (2)
  1953. call.
  1954. See the manual page for
  1955. X.IR getpeername (2)
  1956. for a description of the emulated semantics.
  1957. X.I Mc_getpeername
  1958. does not provide any different semantics from
  1959. X.IR getpeername (2).
  1960. X.SH "RETURN VALUES"
  1961. Upon successful completion, a value of 0 is returned.
  1962. Otherwise, a value of -1 is returned and the global integer variable
  1963. X.I errno
  1964. is set to indicate the error.
  1965. X.SH ERRORS
  1966. See the manual page for
  1967. X.IR getpeername (2)
  1968. for a detailed list of errors associated with the general
  1969. X.IR getpeername (2)
  1970. system call.
  1971. X.I Mc_getpeername
  1972. itself will fail if:
  1973. X.TP 20
  1974. X[EBADF]
  1975. X.I S
  1976. is not a valid multicast socket descriptor as returned by
  1977. X.IR mc_socket (2).
  1978. X.TP 20
  1979. X[EIO]
  1980. The socket state has become corrupted.  This is an artifact of a
  1981. client/server implementation of the multicast communication system.
  1982. X.SH "SEE ALSO"
  1983. X.IR getpeername (2),
  1984. X.IR mc_bind (2),
  1985. X.IR mc_connect (2),
  1986. X.IR mc_getsockname (2),
  1987. X.IR mc_socket (2),
  1988. X.IR mcast (4)
  1989. X.SH STANDARDS
  1990. There are no current standards that address multicast communication.
  1991. The software described in this manual page is experimental and subject
  1992. to change at any time.
  1993. END_OF_FILE
  1994. if test 4059 -ne `wc -c <'man/mc_getpeername.2'`; then
  1995.     echo shar: \"'man/mc_getpeername.2'\" unpacked with wrong size!
  1996. fi
  1997. # end of 'man/mc_getpeername.2'
  1998. fi
  1999. if test -f 'man/mc_getsockname.2' -a "${1}" != "-c" ; then 
  2000.   echo shar: Will not clobber existing file \"'man/mc_getsockname.2'\"
  2001. else
  2002. echo shar: Extracting \"'man/mc_getsockname.2'\" \(4166 characters\)
  2003. sed "s/^X//" >'man/mc_getsockname.2' <<'END_OF_FILE'
  2004. X.\" Copyright (c) 1992 The Regents of the University of California.
  2005. X.\" All rights reserved.
  2006. X.\"
  2007. X.\" Redistribution and use in source and binary forms, with or without
  2008. X.\" modification, are permitted provided that the following conditions
  2009. X.\" are met:
  2010. X.\" 1. Redistributions of source code must retain the above copyright
  2011. X.\"    notice, this list of conditions and the following disclaimer.
  2012. X.\" 2. Redistributions in binary form must reproduce the above copyright
  2013. X.\"    notice, this list of conditions and the following disclaimer in the
  2014. X.\"    documentation and/or other materials provided with the distribution.
  2015. X.\" 3. All advertising materials mentioning features or use of this software
  2016. X.\"    must display the following acknowledgement:
  2017. X.\"    This product includes software developed by the University of
  2018. X.\"    California, Lawrence Livermore National Laboratory and its
  2019. X.\"    contributors.
  2020. X.\" 4. Neither the name of the University nor the names of its contributors
  2021. X.\"    may be used to endorse or promote products derived from this software
  2022. X.\"    without specific prior written permission.
  2023. X.\"
  2024. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  2025. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  2026. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  2027. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  2028. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  2029. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  2030. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  2031. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  2032. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  2033. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  2034. X.\" SUCH DAMAGE.
  2035. X.\"
  2036. X.\"     @(#)getsockname.2    6.4 (Berkeley) 3/10/91
  2037. X.\"
  2038. X.de Hd
  2039. X.ds Dt \\$4
  2040. X..
  2041. X.Hd $Header: /u0/casey/src/mcast/man/RCS/mc_getsockname.2,v 1.1 92/10/16 18:23:01 casey Exp $
  2042. X.TH MC_GETSOCKNAME 2 \*(Dt
  2043. X.SH NAME
  2044. mc_getsockname \- get (local) name of multicast socket
  2045. X.SH SYNOPSIS
  2046. X.nf
  2047. X.ft B
  2048. X#include <sys/types.h>
  2049. X#include <sys/socket.h>
  2050. X#include <netmcast/mcast.h>
  2051. X
  2052. int
  2053. mc_getsockname(int s, struct sockaddr *name, int *namelen)
  2054. X.ft P
  2055. X.fi
  2056. X.SH DESCRIPTION
  2057. X.I Mc_getsockname
  2058. returns the current 
  2059. X.I name
  2060. for the specified socket.  The
  2061. X.I namelen
  2062. parameter should be initialized to indicate
  2063. the amount of space pointed to by
  2064. X.IR name .
  2065. On return it contains the actual size of the name
  2066. returned (in bytes).
  2067. The name is truncated if the buffer provided is too small.
  2068. X.PP
  2069. XFor multicast sockets,
  2070. X.I namelen
  2071. should always be equal to
  2072. X.IR "sizeof(struct sockaddr_mcast)" .
  2073. The default remote sock name is
  2074. MCADDR_ANY
  2075. but can be changed once \- either explicitly or implicitly \- via
  2076. X.IR mc_bind (2),
  2077. X.IR mc_connect (2),
  2078. or
  2079. X.IR mc_sendto (2).
  2080. X.SH COMPATIBILITY
  2081. The
  2082. X.I mc_getsockname
  2083. call emulates the
  2084. X.IR getsockname (2)
  2085. system call for multicast socket descriptors created with the
  2086. X.IR mc_socket (2)
  2087. call.
  2088. See the manual page for
  2089. X.IR getsockname (2)
  2090. for a description of the emulated semantics.
  2091. X.I Mc_getsockname
  2092. does not provide any different semantics from
  2093. X.IR getsockname (2).
  2094. X.SH "RETURN VALUES"
  2095. Upon successful completion, a value of 0 is returned.
  2096. Otherwise, a value of -1 is returned and the global integer variable
  2097. X.I errno
  2098. is set to indicate the error.
  2099. X.SH ERRORS
  2100. See the manual page for
  2101. X.IR getsockname (2)
  2102. for a detailed list of errors associated with the general
  2103. X.IR getsockname (2)
  2104. system call.
  2105. X.I Mc_getsockname
  2106. itself will fail if:
  2107. X.TP 20
  2108. X[EBADF]
  2109. X.I S
  2110. is not a valid multicast socket descriptor as returned by
  2111. X.IR mc_socket (2).
  2112. X.TP 20
  2113. X[EIO]
  2114. The socket state has become corrupted.  This is an artifact of a
  2115. client/server implementation of the multicast communication system.
  2116. X.SH "SEE ALSO"
  2117. X.IR getsockname (2),
  2118. X.IR mc_bind (2),
  2119. X.IR mc_connect (2),
  2120. X.IR mc_getpeername (2),
  2121. X.IR mc_socket (2),
  2122. X.IR mcast (4)
  2123. X.SH STANDARDS
  2124. There are no current standards that address multicast communication.
  2125. The software described in this manual page is experimental and subject
  2126. to change at any time.
  2127. END_OF_FILE
  2128. if test 4166 -ne `wc -c <'man/mc_getsockname.2'`; then
  2129.     echo shar: \"'man/mc_getsockname.2'\" unpacked with wrong size!
  2130. fi
  2131. # end of 'man/mc_getsockname.2'
  2132. fi
  2133. if test -f 'man/mc_ioctl.2' -a "${1}" != "-c" ; then 
  2134.   echo shar: Will not clobber existing file \"'man/mc_ioctl.2'\"
  2135. else
  2136. echo shar: Extracting \"'man/mc_ioctl.2'\" \(4805 characters\)
  2137. sed "s/^X//" >'man/mc_ioctl.2' <<'END_OF_FILE'
  2138. X.\" Copyright (c) 1992 The Regents of the University of California.
  2139. X.\" All rights reserved.
  2140. X.\"
  2141. X.\" Redistribution and use in source and binary forms, with or without
  2142. X.\" modification, are permitted provided that the following conditions
  2143. X.\" are met:
  2144. X.\" 1. Redistributions of source code must retain the above copyright
  2145. X.\"    notice, this list of conditions and the following disclaimer.
  2146. X.\" 2. Redistributions in binary form must reproduce the above copyright
  2147. X.\"    notice, this list of conditions and the following disclaimer in the
  2148. X.\"    documentation and/or other materials provided with the distribution.
  2149. X.\" 3. All advertising materials mentioning features or use of this software
  2150. X.\"    must display the following acknowledgement:
  2151. X.\"    This product includes software developed by the University of
  2152. X.\"    California, Lawrence Livermore National Laboratory and its
  2153. X.\"    contributors.
  2154. X.\" 4. Neither the name of the University nor the names of its contributors
  2155. X.\"    may be used to endorse or promote products derived from this software
  2156. X.\"    without specific prior written permission.
  2157. X.\"
  2158. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  2159. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  2160. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  2161. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  2162. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  2163. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  2164. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  2165. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  2166. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  2167. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  2168. X.\" SUCH DAMAGE.
  2169. X.\"
  2170. X.de Hd
  2171. X.ds Dt \\$4
  2172. X..
  2173. X.Hd $Header: /u0/casey/src/mcast/man/RCS/mc_ioctl.2,v 1.1 92/10/16 18:23:02 casey Exp $
  2174. X.TH MC_IOCTL 2 \*(Dt
  2175. X.SH NAME
  2176. mc_ioctl \- control multicast socket
  2177. X.SH SYNOPSIS
  2178. X.nf
  2179. X.ft B
  2180. X#include <sys/ioctl.h>
  2181. X#include <sys/types.h>
  2182. X#include <sys/socket.h>
  2183. X#include <netmcast/mast.h>
  2184. X
  2185. int
  2186. mc_ioctl(int s, int request, ...)
  2187. X.ft P
  2188. X.fi
  2189. X.SH DESCRIPTION
  2190. The
  2191. X.I mc_ioctl
  2192. function manipulates the underlying parameters of multicast sockets.
  2193. The argument
  2194. X.I s
  2195. must be an open multicast socket descriptor.
  2196. X.I Request
  2197. specifies the control operation to be performed on
  2198. X.IR s .
  2199. X.PP
  2200. The
  2201. X.I request
  2202. parameter encodes whether the operation requires an
  2203. optional third pointer argument,
  2204. X.BR arg ,
  2205. whether it is an
  2206. X\*(lqin\*(rq
  2207. parameter
  2208. or
  2209. X\*(lqout\*(rq
  2210. parameter, and the size in bytes of the object pointed at by
  2211. X.IR arg .
  2212. Macros and defines used in specifying an ioctl
  2213. X.I request
  2214. are located in the files
  2215. X.I <sys/ioctl.h>
  2216. and
  2217. X.IR <netmcast/mcast.h> .
  2218. X.PP
  2219. The following requests are valid:
  2220. X.TP 10
  2221. MCIOLOOPBACK
  2222. Sets loop back mode on the multicast descriptor
  2223. X.IR s .
  2224. When messages are sent on the multicast descriptor
  2225. X.IR s ,
  2226. they will be looped back and received on a later read.
  2227. This call is identical to specifying MCO_LOOPBACK to
  2228. X.I mc_fcntl
  2229. on an F_SETFL operation.
  2230. X.TP 10
  2231. XFIONBIO
  2232. Sets non-blocking mode on the multicast descriptor
  2233. X.IR s .
  2234. If no data is available for to a read call, or if a write
  2235. operation would block, the read or write call returns -1 with the error
  2236. XEAGAIN.
  2237. This call is identical to specifying O_NONBLOCK to
  2238. X.I mc_fcntl
  2239. on an F_SETFL operation.
  2240. X.TP 10
  2241. XFIONREAD
  2242. Returns the number of bytes available for the next read operation.
  2243. The value is returned in the
  2244. X.I long
  2245. pointed to by
  2246. X.IR arg .
  2247. X.SH COMPATIBILITY
  2248. The
  2249. X.I mc_ioctl
  2250. call emulates the
  2251. X.IR ioctl (2)
  2252. system call for multicast socket descriptors created with the
  2253. X.IR mc_socket (2)
  2254. call.
  2255. See the manual page for
  2256. X.IR ioctl (2)
  2257. for a description of the emulated semantics.
  2258. X.I Mc_ioctl
  2259. does not provide any different semantics from
  2260. X.IR ioctl (2).
  2261. X.SH "RETURN VALUES"
  2262. Upon successful completion, a value of 0 is returned.
  2263. Otherwise, a value of -1 is returned and the global integer variable
  2264. X.I errno
  2265. is set to indicate the error.
  2266. X.SH ERRORS
  2267. See the manual page for
  2268. X.IR ioctl (2)
  2269. for a detailed list of errors associated with the general
  2270. X.IR ioctl (2)
  2271. system call.
  2272. X.I Mc_ioctl
  2273. itself will fail if:
  2274. X.TP 20
  2275. X[EBADF]
  2276. X.I S
  2277. is not a valid multicast socket descriptor as returned by
  2278. X.IR mc_socket (2).
  2279. X.TP 20
  2280. X[EIO]
  2281. The socket state has become corrupted.  This is an artifact of a
  2282. client/server implementation of the multicast communication system.
  2283. X.TP 20
  2284. X[EINVAL]
  2285. X.I Request
  2286. is not a legal value.
  2287. X.SH "SEE ALSO"
  2288. X.IR ioctl (2),
  2289. X.IR mc_fcntl (2),
  2290. X.IR mc_socket (2),
  2291. X.IR mcast (4)
  2292. X.SH STANDARDS
  2293. There are no current standards that address multicast communication.
  2294. The software described in this manual page is experimental and subject
  2295. to change at any time.
  2296. END_OF_FILE
  2297. if test 4805 -ne `wc -c <'man/mc_ioctl.2'`; then
  2298.     echo shar: \"'man/mc_ioctl.2'\" unpacked with wrong size!
  2299. fi
  2300. # end of 'man/mc_ioctl.2'
  2301. fi
  2302. if test -f 'man/mc_write.2' -a "${1}" != "-c" ; then 
  2303.   echo shar: Will not clobber existing file \"'man/mc_write.2'\"
  2304. else
  2305. echo shar: Extracting \"'man/mc_write.2'\" \(5022 characters\)
  2306. sed "s/^X//" >'man/mc_write.2' <<'END_OF_FILE'
  2307. X.\" Copyright (c) 1992 The Regents of the University of California.
  2308. X.\" All rights reserved.
  2309. X.\"
  2310. X.\" Redistribution and use in source and binary forms, with or without
  2311. X.\" modification, are permitted provided that the following conditions
  2312. X.\" are met:
  2313. X.\" 1. Redistributions of source code must retain the above copyright
  2314. X.\"    notice, this list of conditions and the following disclaimer.
  2315. X.\" 2. Redistributions in binary form must reproduce the above copyright
  2316. X.\"    notice, this list of conditions and the following disclaimer in the
  2317. X.\"    documentation and/or other materials provided with the distribution.
  2318. X.\" 3. All advertising materials mentioning features or use of this software
  2319. X.\"    must display the following acknowledgement:
  2320. X.\"    This product includes software developed by the University of
  2321. X.\"    California, Lawrence Livermore National Laboratory and its
  2322. X.\"    contributors.
  2323. X.\" 4. Neither the name of the University nor the names of its contributors
  2324. X.\"    may be used to endorse or promote products derived from this software
  2325. X.\"    without specific prior written permission.
  2326. X.\"
  2327. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  2328. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  2329. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  2330. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  2331. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  2332. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  2333. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  2334. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  2335. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  2336. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  2337. X.\" SUCH DAMAGE.
  2338. X.\"
  2339. X.de Hd
  2340. X.ds Dt \\$4
  2341. X..
  2342. X.Hd $Header: /u0/casey/src/mcast/man/RCS/mc_write.2,v 1.3 93/01/16 20:03:45 casey Exp $
  2343. X.TH MC_WRITE 2 \*(Dt
  2344. X.SH NAME
  2345. mc_write, mc_writev \- write output to a multicast socket
  2346. X.SH SYNOPSIS
  2347. X.nf
  2348. X.ft B
  2349. X#include <unistd.h>
  2350. X#include <sys/types.h>
  2351. X#include <sys/uio.h>
  2352. X#include <sys/socket.h>
  2353. X#include <netmcast/mcast.h>
  2354. X
  2355. ssize_t
  2356. mc_write(int s, const void *buf, size_t len)
  2357. X
  2358. int
  2359. mc_writev(int s, const struct iovec *iov, int iovcnt)
  2360. X.ft P
  2361. X.fi
  2362. X.SH DESCRIPTION
  2363. X.I Mc_write
  2364. attempts to write
  2365. X.I len
  2366. bytes of data to the object referenced by the multicast socket descriptor
  2367. X.I d
  2368. from the buffer pointed to by
  2369. X.IR buf .
  2370. X.I Mc_writev
  2371. performs the same action, but gathers the output data
  2372. from the 
  2373. X.I iovcnt
  2374. buffers specified by the members of the
  2375. X.I iov
  2376. array: iov[0], iov[1], ..., iov[iovcnt\|-\|1].
  2377. The multicast socket
  2378. X.I s
  2379. must be bound before either
  2380. X.I mc_write
  2381. or
  2382. X.I mc_writev
  2383. can be used.
  2384. X.PP
  2385. XFor 
  2386. X.IR mc_writev ,
  2387. the 
  2388. X.I iovec
  2389. structure is defined as:
  2390. X.PP
  2391. X.RS
  2392. X.nf
  2393. X.ta \w'struct'u +\w'caddr_tXXXX'u
  2394. struct iovec {
  2395. X    caddr_t    iov_base;
  2396. X    int    iov_len;
  2397. X};
  2398. X.DT
  2399. X.fi
  2400. X.RE
  2401. X.PP
  2402. XEach 
  2403. X.I iovec
  2404. entry specifies the base address and length of an area
  2405. in memory from which data should be written.
  2406. X.I Mc_writev
  2407. will always write a complete area before proceeding
  2408. to the next.
  2409. X.PP
  2410. When using non-blocking I/O,
  2411. X.I mc_write
  2412. and
  2413. X.I mc_writev
  2414. may write fewer bytes than requested;
  2415. the return value must be noted,
  2416. and the remainder of the operation should be retried when possible.
  2417. X.SH COMPATIBILITY
  2418. The
  2419. X.I mc_write
  2420. and
  2421. X.I mc_writev
  2422. calls emulate the
  2423. X.IR write (2)
  2424. and
  2425. X.IR writev (2)
  2426. system calls for multicast socket descriptors created with the
  2427. X.IR mc_socket (2)
  2428. call.
  2429. See the manual pages for
  2430. X.IR write (2)
  2431. and
  2432. X.IR writev (2)
  2433. for a description of the emulated semantics.
  2434. X.I Mc_write
  2435. and
  2436. X.I mc_writev
  2437. do not provide any different semantics from
  2438. X.IR write (2)
  2439. and
  2440. X.IR writev (2).
  2441. X.SH "RETURN VALUES"
  2442. Upon successful completion the number of bytes which were written
  2443. is returned.  Otherwise a -1 is returned and the global variable
  2444. X.I errno
  2445. is set to indicate the error.
  2446. X.SH ERRORS
  2447. See the manual pages for
  2448. X.IR write (2)
  2449. and
  2450. X.IR writev (2)
  2451. for a detailed list of errors associated with the general
  2452. X.IR write (2)
  2453. and
  2454. X.IR writev (2)
  2455. system calls.
  2456. X.I Mc_write
  2457. and
  2458. X.I mc_writev
  2459. themselves will fail if:
  2460. X.TP 20
  2461. X[EBADF]
  2462. X.I S
  2463. is not a valid multicast socket descriptor as returned by
  2464. X.IR mc_socket (2).
  2465. X.TP 20
  2466. X[EIO]
  2467. The socket state has become corrupted.  This is an artifact of a
  2468. client/server implementation of the multicast communication system.
  2469. X.TP 20
  2470. X[EPIPE]
  2471. No name has been bound to the multicast socket yet.
  2472. X.TP 20
  2473. X[EPIPE]
  2474. X.I Mc_shutdown
  2475. was used to shutdown sending on the multicast socket.  All further attempts
  2476. to write on the multicast socket will return EPIPE.
  2477. X.TP 20
  2478. X[EAGAIN]
  2479. The file was marked for non-blocking I/O,
  2480. and no data could be written immediately.
  2481. X.SH "SEE ALSO"
  2482. X.IR mc_fcntl (2),
  2483. X.IR mc_socket (2),
  2484. X.IR mcast (4),
  2485. X.IR select (2),
  2486. X.IR write (2)
  2487. X.SH STANDARDS
  2488. There are no current standards that address multicast communication.
  2489. The software described in this manual page is experimental and subject
  2490. to change at any time.
  2491. END_OF_FILE
  2492. if test 5022 -ne `wc -c <'man/mc_write.2'`; then
  2493.     echo shar: \"'man/mc_write.2'\" unpacked with wrong size!
  2494. fi
  2495. # end of 'man/mc_write.2'
  2496. fi
  2497. if test -f 'man/mcast_getgroupbyname.3' -a "${1}" != "-c" ; then 
  2498.   echo shar: Will not clobber existing file \"'man/mcast_getgroupbyname.3'\"
  2499. else
  2500. echo shar: Extracting \"'man/mcast_getgroupbyname.3'\" \(4276 characters\)
  2501. sed "s/^X//" >'man/mcast_getgroupbyname.3' <<'END_OF_FILE'
  2502. X.\" Copyright (c) 1992 The Regents of the University of California.
  2503. X.\" All rights reserved.
  2504. X.\"
  2505. X.\" Redistribution and use in source and binary forms, with or without
  2506. X.\" modification, are permitted provided that the following conditions
  2507. X.\" are met:
  2508. X.\" 1. Redistributions of source code must retain the above copyright
  2509. X.\"    notice, this list of conditions and the following disclaimer.
  2510. X.\" 2. Redistributions in binary form must reproduce the above copyright
  2511. X.\"    notice, this list of conditions and the following disclaimer in the
  2512. X.\"    documentation and/or other materials provided with the distribution.
  2513. X.\" 3. All advertising materials mentioning features or use of this software
  2514. X.\"    must display the following acknowledgement:
  2515. X.\"    This product includes software developed by the University of
  2516. X.\"    California, Lawrence Livermore National Laboratory and its
  2517. X.\"    contributors.
  2518. X.\" 4. Neither the name of the University nor the names of its contributors
  2519. X.\"    may be used to endorse or promote products derived from this software
  2520. X.\"    without specific prior written permission.
  2521. X.\"
  2522. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  2523. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  2524. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  2525. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  2526. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  2527. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  2528. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  2529. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  2530. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  2531. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  2532. X.\" SUCH DAMAGE.
  2533. X.\"
  2534. X.de Hd
  2535. X.ds Dt \\$4
  2536. X..
  2537. X.Hd $Header: /u0/casey/src/mcast/man/RCS/mcast_getgroupbyname.3,v 1.4 93/03/17 11:35:02 casey Exp $
  2538. X.TH MCAST_GETGROUPBYNAME 3 \*(Dt
  2539. X.SH NAME
  2540. mcast_getgroupbyname \- get multicast address information
  2541. X.SH SYNOPSIS
  2542. X.nf
  2543. X.ft B
  2544. X#include <sys/types.h>
  2545. X#include <sys/socket.h>
  2546. X#include <netmcast/mcast.h>
  2547. X
  2548. struct mcastent *
  2549. mcast_getgroupbyname(const char *name, int domain)
  2550. X.ft P
  2551. X.fi
  2552. X.SH DESCRIPTION
  2553. X.I Mcast_getgroupbyname
  2554. returns information about multicast group
  2555. X.I name
  2556. in the multicast address family
  2557. X.I domain
  2558. X(either AF_MCAST or AF_AMCAST).
  2559. The information
  2560. is returned in the form of a pointer to a
  2561. X.IR malloc 'ed
  2562. X.I mcastent
  2563. structure.  If no information can be returned, NULL is returned.
  2564. X.PP
  2565. X.RS
  2566. X.nf
  2567. X.ta \w'struct'u +\w'struct mc_addrXXXX'u +\w'**aliases;XXXX'u
  2568. X0.5in 2.0in 3.5in
  2569. struct mcastent {
  2570. X    char    *name;    /* official name of group */
  2571. X    char    **aliases;    /* alias list */
  2572. X    int    family;    /* address family */
  2573. X    struct mc_addr    address;    /* address bound to group */
  2574. X};
  2575. X.fi
  2576. X.RE
  2577. X.PP
  2578. It is the responsibility of the caller to free the returned memory with the
  2579. X.IR free (3)
  2580. call.
  2581. X.SH COMPATIBILITY
  2582. X.I Mcast_getgroupbyname
  2583. is unique to the experimental multicast implementation.
  2584. X.I Mcast_getgroupbyname
  2585. is yet another GetFooByBarEnt style routine.  Just what we need.  It's
  2586. especially annoying that we have to pass in the
  2587. X.I domain
  2588. qualifier attribute in such an ad hoc manner.  It
  2589. would be really nice if there was a general name/value server.
  2590. However, since we wanted to get on with our work, we decided not to
  2591. lose time working on a more general scheme.  It's probably attitudes
  2592. like ours that are responsible for the proliferation of special
  2593. purpose name servers and why a general name server still isn't
  2594. available ...
  2595. X.SH "RETURN VALUES"
  2596. Upon successful completion, a pointer to an
  2597. X.I mcastent
  2598. structure in
  2599. X.IR malloc 'ed
  2600. memory is returned.
  2601. Otherwise, a value of NULL is returned and the global integer variable
  2602. X.I errno
  2603. is set to indicate the error.
  2604. X.SH ERRORS
  2605. X.TP 20
  2606. X[ENOENT]
  2607. No information on
  2608. X.I name
  2609. could be found.
  2610. X.TP 20
  2611. X[ENOMEM]
  2612. The attempt to
  2613. X.I malloc
  2614. storage for the return information failed.
  2615. X.SH "SEE ALSO"
  2616. X.IR malloc (3),
  2617. X.IR mcast (4),
  2618. X.IR mcast_newaddr (3),
  2619. X.IR mc_socket (2)
  2620. X.SH STANDARDS
  2621. There are no current standards that address multicast communication.
  2622. The software described in this manual page is experimental and subject
  2623. to change at any time.
  2624. END_OF_FILE
  2625. if test 4276 -ne `wc -c <'man/mcast_getgroupbyname.3'`; then
  2626.     echo shar: \"'man/mcast_getgroupbyname.3'\" unpacked with wrong size!
  2627. fi
  2628. # end of 'man/mcast_getgroupbyname.3'
  2629. fi
  2630. if test -f 'test/mc_clock.c' -a "${1}" != "-c" ; then 
  2631.   echo shar: Will not clobber existing file \"'test/mc_clock.c'\"
  2632. else
  2633. echo shar: Extracting \"'test/mc_clock.c'\" \(4044 characters\)
  2634. sed "s/^X//" >'test/mc_clock.c' <<'END_OF_FILE'
  2635. X/*
  2636. X * $Header: /u0/casey/src/mcast/test/RCS/mc_clock.c,v 1.4 93/01/16 20:18:23 casey Exp $
  2637. X */
  2638. X
  2639. X/*
  2640. X * Copyright (c) 1992 The Regents of the University of California.
  2641. X * All rights reserved.
  2642. X *
  2643. X * Redistribution and use in source and binary forms, with or without
  2644. X * modification, are permitted provided that the following conditions
  2645. X * are met:
  2646. X * 1. Redistributions of source code must retain the above copyright
  2647. X *    notice, this list of conditions and the following disclaimer.
  2648. X * 2. Redistributions in binary form must reproduce the above copyright
  2649. X *    notice, this list of conditions and the following disclaimer in the
  2650. X *    documentation and/or other materials provided with the distribution.
  2651. X * 3. All advertising materials mentioning features or use of this software
  2652. X *    must display the following acknowledgement:
  2653. X *    This product includes software developed by the University of
  2654. X *    California, Lawrence Livermore National Laboratory and its
  2655. X *    contributors.
  2656. X * 4. Neither the name of the University nor the names of its contributors
  2657. X *    may be used to endorse or promote products derived from this software
  2658. X *    without specific prior written permission.
  2659. X *
  2660. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  2661. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  2662. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  2663. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  2664. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  2665. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  2666. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  2667. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  2668. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  2669. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  2670. X * SUCH DAMAGE.
  2671. X */
  2672. X
  2673. X#ifndef lint
  2674. static char rcsid[] = "$Header: /u0/casey/src/mcast/test/RCS/mc_clock.c,v 1.4 93/01/16 20:18:23 casey Exp $";
  2675. static char copyright[] =
  2676. X    "Copyright (c) 1992 The Regents of the University of California.\n"
  2677. X    "All rights reserved.\n";
  2678. static char classification[] =
  2679. X    "Unclassified\n";
  2680. X#endif
  2681. X
  2682. X/*
  2683. X * Emit clock ticks to multicast group.
  2684. X */
  2685. X
  2686. X
  2687. X#include <errno.h>
  2688. X#include <fcntl.h>
  2689. X#include <stddef.h>
  2690. X#include <stdio.h>
  2691. X#include <stdlib.h>
  2692. X#include <string.h>
  2693. X#include <time.h>
  2694. X#include <unistd.h>
  2695. X
  2696. X#include <sys/socket.h>
  2697. X#include <netmcast/mcast.h>
  2698. X
  2699. X
  2700. X/*
  2701. X * Arguments.
  2702. X */
  2703. char    *myname;            /* name we were invoked by */
  2704. int    header = 0;            /* print a header for every message */
  2705. int    debug = 0;            /* print lots of debug information */
  2706. int    interval = 5;            /* tick interval in seconds */
  2707. char    *group;                /* multicast group to listen to */
  2708. X
  2709. X/*
  2710. X * Local routines.
  2711. X */
  2712. void usage();                /* issue usage and exit with error */
  2713. X
  2714. X
  2715. main(int argc, char *argv[])
  2716. X{
  2717. X    int s;
  2718. X    int opt;
  2719. X    extern int getopt(int, char **, char *);
  2720. X    extern char *optarg;
  2721. X    extern int optind;
  2722. X
  2723. X    /*
  2724. X     * Parse any arguments ...
  2725. X     */
  2726. X    myname = argv[0];
  2727. X    while ((opt = getopt(argc, argv, "dhi:")) != EOF)
  2728. X        switch ((char)opt) {
  2729. X            case '?':
  2730. X            usage();
  2731. X            /*NOTREACHED*/
  2732. X            case 'd':
  2733. X            debug = 1;
  2734. X            break;
  2735. X            case 'h':
  2736. X            header = 1;
  2737. X            break;
  2738. X            case 'i':
  2739. X            interval = atoi(optarg);
  2740. X            break;
  2741. X        }
  2742. X    if (argc != optind+1) {
  2743. X        usage();
  2744. X        /*NOTREACHED*/
  2745. X    }
  2746. X    group = argv[optind];
  2747. X
  2748. X    s = mcast_sopen(group, PF_MCAST, SOCK_STREAM, O_WRONLY);
  2749. X    if (s < 0) {
  2750. X        perror("mcast_sopen");
  2751. X        exit(1);
  2752. X    }
  2753. X    for (;;) {
  2754. X        time_t t = time(NULL);
  2755. X        char *buf = ctime(&t);
  2756. X        int len = strlen(buf);
  2757. X        int nwrite;
  2758. X
  2759. X        nwrite = mc_write(s, buf, len);
  2760. X        if (nwrite < 0) {
  2761. X            perror("mc_write");
  2762. X            exit(1);
  2763. X        }
  2764. X        if (nwrite < len) {
  2765. X            fprintf(stderr, "%s: write only wrote %d of %d!\n",
  2766. X                myname, nwrite, len);
  2767. X        }
  2768. X        (void)sleep(interval);
  2769. X    }
  2770. X    /*NOTREACHED*/
  2771. X}
  2772. X
  2773. X
  2774. void
  2775. usage()
  2776. X    /*
  2777. X     * Issue usage message and exit with an error.
  2778. X     */
  2779. X{
  2780. X    fprintf(stderr, "usage: %s [-h] [-d] [-i interval] group\n", myname);
  2781. X    exit(1);
  2782. X}
  2783. END_OF_FILE
  2784. if test 4044 -ne `wc -c <'test/mc_clock.c'`; then
  2785.     echo shar: \"'test/mc_clock.c'\" unpacked with wrong size!
  2786. fi
  2787. # end of 'test/mc_clock.c'
  2788. fi
  2789. if test -f 'test/mc_listen.c' -a "${1}" != "-c" ; then 
  2790.   echo shar: Will not clobber existing file \"'test/mc_listen.c'\"
  2791. else
  2792. echo shar: Extracting \"'test/mc_listen.c'\" \(4047 characters\)
  2793. sed "s/^X//" >'test/mc_listen.c' <<'END_OF_FILE'
  2794. X/*
  2795. X * $Header: /u0/casey/src/mcast/test/RCS/mc_listen.c,v 1.3 93/01/16 20:18:38 casey Exp $
  2796. X */
  2797. X
  2798. X/*
  2799. X * Copyright (c) 1992 The Regents of the University of California.
  2800. X * All rights reserved.
  2801. X *
  2802. X * Redistribution and use in source and binary forms, with or without
  2803. X * modification, are permitted provided that the following conditions
  2804. X * are met:
  2805. X * 1. Redistributions of source code must retain the above copyright
  2806. X *    notice, this list of conditions and the following disclaimer.
  2807. X * 2. Redistributions in binary form must reproduce the above copyright
  2808. X *    notice, this list of conditions and the following disclaimer in the
  2809. X *    documentation and/or other materials provided with the distribution.
  2810. X * 3. All advertising materials mentioning features or use of this software
  2811. X *    must display the following acknowledgement:
  2812. X *    This product includes software developed by the University of
  2813. X *    California, Lawrence Livermore National Laboratory and its
  2814. X *    contributors.
  2815. X * 4. Neither the name of the University nor the names of its contributors
  2816. X *    may be used to endorse or promote products derived from this software
  2817. X *    without specific prior written permission.
  2818. X *
  2819. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  2820. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  2821. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  2822. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  2823. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  2824. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  2825. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  2826. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  2827. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  2828. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  2829. X * SUCH DAMAGE.
  2830. X */
  2831. X
  2832. X#ifndef lint
  2833. static char rcsid[] = "$Header: /u0/casey/src/mcast/test/RCS/mc_listen.c,v 1.3 93/01/16 20:18:38 casey Exp $";
  2834. static char copyright[] =
  2835. X    "Copyright (c) 1992 The Regents of the University of California.\n"
  2836. X    "All rights reserved.\n";
  2837. static char classification[] =
  2838. X    "Unclassified\n";
  2839. X#endif
  2840. X
  2841. X/*
  2842. X * Listen to messages on a specified multicast group and print them on
  2843. X * standard output.
  2844. X */
  2845. X
  2846. X
  2847. X#include <errno.h>
  2848. X#include <fcntl.h>
  2849. X#include <stddef.h>
  2850. X#include <stdio.h>
  2851. X#include <stdlib.h>
  2852. X#include <string.h>
  2853. X#include <unistd.h>
  2854. X
  2855. X#include <sys/socket.h>
  2856. X#include <netmcast/mcast.h>
  2857. X
  2858. X
  2859. X/*
  2860. X * Arguments.
  2861. X */
  2862. char    *myname;            /* name we were invoked by */
  2863. int    header = 0;            /* print a header for every message */
  2864. int    debug = 0;            /* print lots of debug information */
  2865. char    *group;                /* multicast group to listen to */
  2866. X
  2867. X/*
  2868. X * Local routines.
  2869. X */
  2870. void usage();                /* issue usage and exit with error */
  2871. X
  2872. X
  2873. main(int argc, char *argv[])
  2874. X{
  2875. X    int s;
  2876. X    int opt;
  2877. X    extern int getopt(int, char **, char *);
  2878. X    extern char *optarg;
  2879. X    extern int optind;
  2880. X
  2881. X    /*
  2882. X     * Parse any arguments ...
  2883. X     */
  2884. X    myname = argv[0];
  2885. X    while ((opt = getopt(argc, argv, "dh")) != EOF)
  2886. X        switch ((char)opt) {
  2887. X            case '?':
  2888. X            usage();
  2889. X            /*NOTREACHED*/
  2890. X            case 'd':
  2891. X            debug = 1;
  2892. X            break;
  2893. X            case 'h':
  2894. X            header = 1;
  2895. X            break;
  2896. X        }
  2897. X    if (argc != optind+1) {
  2898. X        usage();
  2899. X        /*NOTREACHED*/
  2900. X    }
  2901. X    group = argv[optind];
  2902. X
  2903. X    s = mcast_sopen(group, PF_MCAST, SOCK_STREAM, O_RDONLY);
  2904. X    if (s < 0) {
  2905. X        perror("mcast_sopen");
  2906. X        exit(1);
  2907. X    }
  2908. X    for (;;) {
  2909. X        char buf[1024];
  2910. X        int nread, nwrite;
  2911. X
  2912. X        nread = mc_read(s, buf, sizeof(buf));
  2913. X        if (nread == 0)
  2914. X            break;
  2915. X        if (nread < 0) {
  2916. X            perror("read");
  2917. X            exit(1);
  2918. X        }
  2919. X        nwrite = write(STDOUT_FILENO, buf, nread);
  2920. X        if (nwrite < 0) {
  2921. X            perror("write");
  2922. X            exit(1);
  2923. X        }
  2924. X        if (nwrite < nread) {
  2925. X            fprintf(stderr, "%s: write only wrote %d of %d!\n",
  2926. X                myname, nwrite, nread);
  2927. X        }
  2928. X    }
  2929. X    (void)mc_close(s);
  2930. X    exit(0);
  2931. X    /*NOTREACHED*/
  2932. X}
  2933. X
  2934. X
  2935. void
  2936. usage()
  2937. X    /*
  2938. X     * Issue usage message and exit with an error.
  2939. X     */
  2940. X{
  2941. X    fprintf(stderr, "usage: %s [-h] [-d] group\n", myname);
  2942. X    exit(1);
  2943. X}
  2944. END_OF_FILE
  2945. if test 4047 -ne `wc -c <'test/mc_listen.c'`; then
  2946.     echo shar: \"'test/mc_listen.c'\" unpacked with wrong size!
  2947. fi
  2948. # end of 'test/mc_listen.c'
  2949. fi
  2950. if test -f 'test/mc_send.c' -a "${1}" != "-c" ; then 
  2951.   echo shar: Will not clobber existing file \"'test/mc_send.c'\"
  2952. else
  2953. echo shar: Extracting \"'test/mc_send.c'\" \(3986 characters\)
  2954. sed "s/^X//" >'test/mc_send.c' <<'END_OF_FILE'
  2955. X/*
  2956. X * $Header: /u0/casey/src/mcast/test/RCS/mc_send.c,v 1.3 93/01/16 20:18:40 casey Exp $
  2957. X */
  2958. X
  2959. X/*
  2960. X * Copyright (c) 1992 The Regents of the University of California.
  2961. X * All rights reserved.
  2962. X *
  2963. X * Redistribution and use in source and binary forms, with or without
  2964. X * modification, are permitted provided that the following conditions
  2965. X * are met:
  2966. X * 1. Redistributions of source code must retain the above copyright
  2967. X *    notice, this list of conditions and the following disclaimer.
  2968. X * 2. Redistributions in binary form must reproduce the above copyright
  2969. X *    notice, this list of conditions and the following disclaimer in the
  2970. X *    documentation and/or other materials provided with the distribution.
  2971. X * 3. All advertising materials mentioning features or use of this software
  2972. X *    must display the following acknowledgement:
  2973. X *    This product includes software developed by the University of
  2974. X *    California, Lawrence Livermore National Laboratory and its
  2975. X *    contributors.
  2976. X * 4. Neither the name of the University nor the names of its contributors
  2977. X *    may be used to endorse or promote products derived from this software
  2978. X *    without specific prior written permission.
  2979. X *
  2980. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  2981. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  2982. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  2983. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  2984. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  2985. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  2986. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  2987. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  2988. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  2989. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  2990. X * SUCH DAMAGE.
  2991. X */
  2992. X
  2993. X#ifndef lint
  2994. static char rcsid[] = "$Header: /u0/casey/src/mcast/test/RCS/mc_send.c,v 1.3 93/01/16 20:18:40 casey Exp $";
  2995. static char copyright[] =
  2996. X    "Copyright (c) 1992 The Regents of the University of California.\n"
  2997. X    "All rights reserved.\n";
  2998. static char classification[] =
  2999. X    "Unclassified\n";
  3000. X#endif
  3001. X
  3002. X/*
  3003. X * Copy standard input to a specified multicast group.
  3004. X */
  3005. X
  3006. X
  3007. X#include <errno.h>
  3008. X#include <fcntl.h>
  3009. X#include <stddef.h>
  3010. X#include <stdio.h>
  3011. X#include <stdlib.h>
  3012. X#include <string.h>
  3013. X#include <unistd.h>
  3014. X
  3015. X#include <sys/socket.h>
  3016. X#include <netmcast/mcast.h>
  3017. X
  3018. X
  3019. X/*
  3020. X * Arguments.
  3021. X */
  3022. char    *myname;            /* name we were invoked by */
  3023. int    header = 0;            /* print a header for every message */
  3024. int    debug = 0;            /* print lots of debug information */
  3025. char    *group;                /* multicast group to listen to */
  3026. X
  3027. X/*
  3028. X * Local routines.
  3029. X */
  3030. void usage();                /* issue usage and exit with error */
  3031. X
  3032. X
  3033. main(int argc, char *argv[])
  3034. X{
  3035. X    int s;
  3036. X    int opt;
  3037. X    extern int getopt(int, char **, char *);
  3038. X    extern char *optarg;
  3039. X    extern int optind;
  3040. X
  3041. X    /*
  3042. X     * Parse any arguments ...
  3043. X     */
  3044. X    myname = argv[0];
  3045. X    while ((opt = getopt(argc, argv, "dh")) != EOF)
  3046. X        switch ((char)opt) {
  3047. X            case '?':
  3048. X            usage();
  3049. X            /*NOTREACHED*/
  3050. X            case 'd':
  3051. X            debug = 1;
  3052. X            break;
  3053. X            case 'h':
  3054. X            header = 1;
  3055. X            break;
  3056. X        }
  3057. X    if (argc != optind+1) {
  3058. X        usage();
  3059. X        /*NOTREACHED*/
  3060. X    }
  3061. X    group = argv[optind];
  3062. X
  3063. X    s = mcast_sopen(group, PF_MCAST, SOCK_STREAM, O_WRONLY);
  3064. X    if (s < 0) {
  3065. X        perror("mcast_sopen");
  3066. X        exit(1);
  3067. X    }
  3068. X    for (;;) {
  3069. X        char buf[8192];
  3070. X        int nread, nwrite;
  3071. X
  3072. X        nread = read(STDIN_FILENO, buf, sizeof(buf));
  3073. X        if (nread == 0)
  3074. X            break;
  3075. X        if (nread < 0) {
  3076. X            perror("read");
  3077. X            exit(1);
  3078. X        }
  3079. X        nwrite = mc_write(s, buf, nread);
  3080. X        if (nwrite < 0) {
  3081. X            perror("write");
  3082. X            exit(1);
  3083. X        }
  3084. X        if (nwrite < nread) {
  3085. X            fprintf(stderr, "%s: write only wrote %d of %d!\n",
  3086. X                myname, nwrite, nread);
  3087. X        }
  3088. X    }
  3089. X    exit(0);
  3090. X    /*NOTREACHED*/
  3091. X}
  3092. X
  3093. X
  3094. void
  3095. usage()
  3096. X    /*
  3097. X     * Issue usage message and exit with an error.
  3098. X     */
  3099. X{
  3100. X    fprintf(stderr, "usage: %s [-h] [-d] group\n", myname);
  3101. X    exit(1);
  3102. X}
  3103. END_OF_FILE
  3104. if test 3986 -ne `wc -c <'test/mc_send.c'`; then
  3105.     echo shar: \"'test/mc_send.c'\" unpacked with wrong size!
  3106. fi
  3107. # end of 'test/mc_send.c'
  3108. fi
  3109. echo shar: End of archive 2 \(of 4\).
  3110. cp /dev/null ark2isdone
  3111. MISSING=""
  3112. for I in 1 2 3 4 ; do
  3113.     if test ! -f ark${I}isdone ; then
  3114.     MISSING="${MISSING} ${I}"
  3115.     fi
  3116. done
  3117. if test "${MISSING}" = "" ; then
  3118.     echo You have unpacked all 4 archives.
  3119.     rm -f ark[1-9]isdone
  3120. else
  3121.     echo You still need to unpack the following archives:
  3122.     echo "        " ${MISSING}
  3123. fi
  3124. ##  End of shell archive.
  3125. exit 0
  3126.