home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11tl.lha / lbl / include / net_need.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-27  |  4.4 KB  |  181 lines

  1. /*    NET_NEED . H
  2.  
  3. %    for network user
  4. %
  5. % Author:    Jin Guojun - LBL    1/1/92
  6. */
  7.  
  8. #ifdef vax11c
  9. #include "multinet_root:[multinet.include]errno.h"
  10. #include "multinet_root:[multinet.include.sys]types.h"
  11. #include "multinet_root:[multinet.include.sys]socket.h"
  12. #include "multinet_root:[multinet.include.netinet]in.h"
  13. #include "multinet_root:[multinet.include]netdb.h"
  14. #include "multinet_root:[multinet.include.sys]time.h"   /* struct timeval */
  15. #ifdef errno
  16. #undef errno
  17. #endif
  18. #define errno socket_errno
  19. #define perror socket_perror
  20. #else
  21. #include <errno.h>
  22. #include <sys/types.h>
  23. #if    defined    KERNEL | defined USE_RTP
  24. # include <sys/uio.h>
  25. #endif
  26. #include <sys/socket.h>
  27. #include <netinet/in.h>
  28. #include <netdb.h>
  29. #include <sys/time.h>           /* struct timeval */
  30. #endif
  31.  
  32. #include <signal.h>
  33. #include "stdef.h"
  34.  
  35. #ifndef    SV_PORT
  36. #define    SV_PORT    1991    /*    second server port for extended X server */
  37. #endif            /*    first one is called SERVER    */
  38.  
  39. #define    UNKNOWN_SOCK    -1
  40. #define    TCP_SOCK    0    /* SOCK # are equal to SOCK_protocol - 1 */
  41. #define    UDP_SOCK    1
  42. #define    RTP_SOCK    2
  43. #define    IP_SOCK        3
  44.  
  45. typedef    struct    {
  46.     char    ctrl_word,
  47.         bitmap_seq;
  48.     short    TID;
  49.     }    atp_udp_hd;    /* atp_udp header */
  50.  
  51. typedef struct    {
  52.     int    as, so;        /* accepted socket & original socket fd    */
  53.     FILE    *fp;        /* fdopen()    */
  54.     short    connected, m_port;
  55.     long    dp, stat,
  56.         total, packet_size;
  57.     char    *bp;
  58.     struct    timeval ts, te;
  59.         }    magic_server;
  60.  
  61. typedef    struct    {
  62.  unsigned short    seq_num, size;    /* sequence # and packet size    */
  63.     short    t_frame, type;    /* time interval, protocol    */
  64.     long    tss_s, tss_us,    /* start sending    */
  65.         tes_s, tes_us,    /* end of sending    */
  66.         tsr_s, tsr_us,    /* start receiving    */
  67.         ter_s, ter_us,    /* end of receiving    */
  68.         rss_s, rss_us,    /* start sending back    */
  69.         res_s, res_us,    /* end of sending back    */
  70.         rsr_s, rsr_us,    /* start receiving back    */
  71.         rer_s, rer_us;    /* end of r.b.        */
  72.     long    t_err_s, t_err_us;    /* clock diff    */
  73.     char    name[12];
  74.     union    {
  75.         char    *bufp;
  76.         struct    sl    {
  77.             short    pkt_id, pkt_dir;
  78.         } pkt_info;
  79.     } udp_nif;
  80.     } rtpmsg_hd;    /* round trip message    */
  81.  
  82. #define    pkt_num    udp_nif.pkt_info.pkt_id
  83. #define    pkt_dir    udp_nif.pkt_info.pkt_dir
  84. #define    pkt_buf    udp_nif.bufp
  85.  
  86. typedef    struct    {    /* overlaid on rtpmsg_hd structure    */
  87.     float    min_s, min_r;
  88.     struct    timeval    tss, tes,
  89.             tsr, ter,
  90.             rss, res,
  91.             rsr, rer;
  92.     union    {
  93.         double    t_err;
  94.         long    t_err_s[2];
  95.         } clock_dif;
  96.     char    name[12];
  97.     float    max_tt;    /* max transmitting time */
  98.     } pt_inf;
  99.  
  100. typedef    struct    {        /* total must 8 bytes long    */
  101.  unsigned short    npackets,    /* maximum packets per group    */
  102.         window;        /* maximum bytes per packet    */
  103.     char    clock_tick,    /* clock quality, not used    */
  104. #if defined (vax) || defined (i386)
  105.         pp_hl:4,    /* in words.    */
  106.         flow_id:4;    /* EOF and 0 mean same (end)    */
  107. #else
  108.         flow_id:4,    /* EOF and 0 mean same (end)    */
  109.         pp_hl:4;    /* in words.    */
  110. #endif
  111.     short    servtype;
  112.     } PacketProto;
  113.  
  114. #define    htonhdr    htons
  115. #define    ntohdr    ntohs
  116. #define    nttype    short
  117.  
  118. #define PROT_CORRECT_TIME    1
  119. #define    MAGIC_HEADER_LEN    4
  120.  
  121. #if    defined    KERNEL | defined USE_RTP
  122. #include "rtp.h"
  123. typedef    struct    {
  124.     rtphdr_t    *rtphdrp;
  125.     char    *buf;    /* buffer saves data for next group    */
  126.     short    port,    /* communication port    */
  127.         aux;    /* packet transmitting size    */
  128.     long    len;    /* data in buffer    */
  129.     short    flag;
  130.     char    ignore_err, header_len;
  131. #define    kludgeGID    1    /* has to be non-zero    */
  132.     unsigned short    group_id,
  133.         miss,    /* number of missing packets    */
  134.         udelay,    /* packet delay in us.    */
  135.         command;/* communication command    */
  136.     int*    list,
  137.         tcp;    /* accepted socket descriptor    */
  138.     struct sockaddr_in    soaddr;
  139.     struct msghdr    rtpmsg;
  140.     struct iovec    rtpiov[2];
  141.     } rtp_flow_ctrl;
  142. #endif
  143.  
  144. #include <math.h>
  145.  
  146. typedef    struct Packet {
  147.     long npackets;
  148.     long nbytes;
  149. } *PBuffer;    /* packet buffer */
  150.  
  151. #ifdef    DEC
  152. #undef    fabs
  153. #define    fabs(x)    (x<0 ? -x : x)
  154. #endif
  155.  
  156. #ifndef    Default_Sleep
  157. #define    Default_Sleep    5000    /*    millisec.    */
  158. #endif
  159.  
  160. #define    UDP_BD    sizeof(PacketProto)
  161.  
  162. #define IP_HDR_MINLEN    (5 << 2)    /* 5 words    */
  163. #define UDP_HDR_LENGTH_BYTE    UDP_BD
  164. #define SYS_HDR_LENGTH        (IP_HDR_MINLEN + UDP_BD)
  165. #define HDR_BYTE_LENGTH        SYS_HDR_LENGTH
  166. #define    WINDOW_SIZE        32768    /* 0x8000    */
  167. #ifndef    Max_WINDOW_SIZE
  168. #define    Max_WINDOW_SIZE        52428    /* 0xCCCC    */
  169. #endif
  170.  
  171. #ifndef    FRAGMENT_SIZE
  172. #define    FRAGMENT_SIZE    (4328 - SYS_HDR_LENGTH)
  173. #endif
  174. #ifndef    UDP_BUF_LIMIT    /* WINDOW_SIZE - SYS_HDR_LENGTH    */
  175. #define    UDP_BUF_LIMIT    32739    /* 0x7FE3, MAX for BSD    */
  176. #endif
  177. #define    MAX_IP_PACKET    28752    /* 0x7050, MAX for BSD    */
  178. #define    Max_UDP_MESG    28672    /* 0x7000    */
  179.  
  180. extern    struct sockaddr_in* get_soaddr(/*int rot, struct sockaddr_in *saddr*/);
  181.