home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11tl.lha / lbl / sun / lib2 / rtcp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-09  |  2.6 KB  |  90 lines

  1. /*    RTCP . C
  2. #
  3. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  4.  
  5. This software is copyright (C) by the Lawrence Berkeley Laboratory.
  6. Permission is granted to reproduce this software for non-commercial
  7. purposes provided that this notice is left intact.
  8.  
  9. It is acknowledged that the U.S. Government has rights to this software
  10. under Contract DE-AC03-765F00098 between the U.S.  Department of Energy
  11. and the University of California.
  12.  
  13. This software is provided as a professional and academic contribution
  14. for joint exchange. Thus, it is experimental, and is provided ``as is'',
  15. with no warranties of any kind whatsoever, no support, no promise of
  16. updates, or printed documentation. By using this software, you
  17. acknowledge that the Lawrence Berkeley Laboratory and Regents of the
  18. University of California shall have no liability with respect to the
  19. infringement of other copyrights by any part of this software.
  20.  
  21. For further information about this notice, contact William Johnston,
  22. Bld. 50B, Rm. 2239, Lawrence Berkeley Laboratory, Berkeley, CA, 94720.
  23. (wejohnston@lbl.gov)
  24.  
  25. For further information about this software, contact:
  26.     Jin Guojun
  27.     Bld. 50B, Rm. 2275, Lawrence Berkeley Laboratory, Berkeley, CA, 94720.
  28.     g_jin@lbl.gov
  29.  
  30. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  31. %
  32. % Author:    Jin Guojun - LBL    3/1/93
  33. */
  34.  
  35. #include "net_need.h"
  36. #include "rtp.h"
  37. #include <varargs.h>
  38.  
  39. typedef    struct  {
  40.     int    type;
  41.     VType   **list;
  42.     } pointer_pair;
  43.  
  44.  
  45. rtcp_getoptions(VType*    buf, int num_options, va_list    va_alist)
  46. {
  47. rtphdr_t *rtp=(rtphdr_t *)buf;
  48. rtpopthdr_t *opt=(rtpopthdr_t *)(rtp+1);
  49. pointer_pair*    rtp_opts=NULL;
  50. va_list    ap;
  51.  
  52.     if (rtp->rh_opts)    {
  53.     register int    i;
  54.     if (num_options)    {
  55.         rtp_opts = ZALLOC(num_options, sizeof(pointer_pair), "rtp_opt");
  56.         va_start(ap);
  57.         for (i=0; i<num_options; i++)    {
  58.             rtp_opts[i].type = va_arg(ap, int);
  59.             rtp_opts[i].list = va_arg(ap, VType*);
  60.         }
  61.         va_end(ap);
  62.     }
  63.     do    {
  64.         for (i=num_options; i--;)    /* if request option, set it */
  65.         if (opt->roh_type == rtp_opts[i].type)    {
  66.             *rtp_opts[i].list = (VType*)opt;
  67.             break;
  68.         }
  69.         /*    (opt->roh_optlen << 2) - sizeof(rtphdr_t)    */
  70.         i = opt->roh_fin;    /* skip to next option    */
  71.         opt = (rtpopthdr_t *)((long*)opt + opt->roh_optlen);
  72.     } while (!i);
  73.     if (rtp_opts)    free(rtp_opts);
  74.     }
  75.  
  76. return    (int) opt - (int) buf;    /* header length in bytes, not words */
  77. }
  78.  
  79.  
  80. rtcp_setoption(rtpopthdr_t* opt, char *o_mesg, int mesg_len, int opt_type,
  81.         bool    fin)
  82. {
  83.  
  84.     opt->roh_fin = fin;
  85.     opt->roh_type = opt_type;
  86.     opt->roh_optlen = (mesg_len >> 2) + 2;    /* length in long words    */
  87.     memcpy(opt + 1, o_mesg, mesg_len);
  88. }
  89.  
  90.