1 2 /* 3 # Sfront, a SAOL to C translator 4 # This file: Network library -- global variables 5 # 6 # Copyright (c) 2000-2006, Regents of the University of California 7 # All rights reserved. 8 # 9 # Redistribution and use in source and binary forms, with or without 10 # modification, are permitted provided that the following conditions are 11 # met: 12 # 13 # Redistributions of source code must retain the above copyright 14 # notice, this list of conditions and the following disclaimer. 15 # 16 # Redistributions in binary form must reproduce the above copyright 17 # notice, this list of conditions and the following disclaimer in the 18 # documentation and/or other materials provided with the distribution. 19 # 20 # Neither the name of the University of California, Berkeley nor the 21 # names of its contributors may be used to endorse or promote products 22 # derived from this software without specific prior written permission. 23 # 24 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 # 36 # Maintainer: John Lazzaro, lazzaro@cs.berkeley.edu 37 */ 38 39 #ifndef NSYS_NET 40 #include "net_include.h" 41 #endif 42 43 44 /*************************/ 45 /* rtp and rtcp: network */ 46 /*************************/ 47 48 int nsys_rtp_fd; /* fd for rtp */ 49 int nsys_rtcp_fd; /* fd for rtcp */ 50 int nsys_max_fd; /* fd for select */ 51 52 unsigned short nsys_rtp_port; /* actual rtp port */ 53 unsigned short nsys_rtcp_port; /* actual rtcp port */ 54 55 unsigned long nsys_rtp_cseq; /* rtp cseq number */ 56 unsigned long nsys_rtcp_cseq; /* rtcp cseq number */ 57 58 /*************************/ 59 /* rtp and rtcp: packets */ 60 /*************************/ 61 62 unsigned char nsys_netout_rtp_packet[NSYS_UDPMAXSIZE]; /* rtp packet out */ 63 64 unsigned char * nsys_netout_rtcp_packet_rrempty; 65 unsigned char * nsys_netout_rtcp_packet_rr; 66 unsigned char * nsys_netout_rtcp_packet_srempty; 67 unsigned char * nsys_netout_rtcp_packet_sr; 68 unsigned char * nsys_netout_rtcp_packet_bye; 69 70 int nsys_netout_rtcp_len_rrempty; 71 int nsys_netout_rtcp_len_rr; 72 int nsys_netout_rtcp_len_srempty; 73 int nsys_netout_rtcp_len_sr; 74 int nsys_netout_rtcp_len_bye; 75 76 77 unsigned char nsys_netout_rtcp_packet[NSYS_UDPMAXSIZE]; /* rtcp packet out */ 78 int nsys_netout_rtcp_size; /* rtcp packet size*/ 79 80 char * nsys_sdes_typename[NSYS_RTCPVAL_SDES_SIZE] = { /* rtcp debug array */ 81 "ILLEGAL", "Cname", "Name", "Email", "Phone", 82 "Loc", "Tool", "Note", "Priv" }; 83 84 unsigned long nsys_netout_seqnum; /* rtp output sequence number */ 85 unsigned long nsys_netout_tstamp; /* rtp output timestamp */ 86 unsigned char nsys_netout_markbit; /* for setting markerbit */ 87 88 /************************/ 89 /* rtp payload support */ 90 /************************/ 91 92 #if 0 93 /* when adding new codecs, follow this sample */ 94 /* remember to increment NSYS_RTP_PAYSIZE, and */ 95 /* get ordering correct. */ 96 97 struct nsys_payinfo nsys_payload_types[NSYS_RTP_PAYSIZE] = 98 { 99 {NSYS_MPEG4_PINDEX, 96, "mpeg4-generic", (int)(EV(ARATE) + 0.5F)}, 100 {NSYS_NATIVE_PINDEX, 97, "rtp-midi", (int)(EV(ARATE) + 0.5F)} 101 }; 102 #endif 103 104 struct nsys_payinfo nsys_payload_types[NSYS_RTP_PAYSIZE] = 105 { 106 {NSYS_MPEG4_PINDEX, 96, "pre1-mpeg4-generic", (int)(EV(ARATE) + 0.5F)} 107 }; 108 109 /**************/ 110 /* rtcp timer */ 111 /**************/ 112 113 int nsys_sent_last; /* a packet was sent last RTCP period */ 114 int nsys_sent_this; /* a packet was sent this RTCP period */ 115 116 unsigned long nsys_sent_packets; /* number of packets sent */ 117 unsigned long nsys_sent_octets; /* number of octets sent */ 118 119 time_t nsys_nexttime; /* time for next RTCP check */ 120 int nsys_rtcp_ex; /* status flags to check at RTCP time */ 121 122 /******************/ 123 /* identification */ 124 /******************/ 125 126 unsigned long nsys_myssrc; /* SSRC -- hostorder */ 127 unsigned long nsys_myssrc_net; /* SSRC -- netorder */ 128 129 #ifndef NSYS_NET 130 char * nsys_sessionname; 131 char * nsys_sessionkey; 132 int nsys_feclevel = NSYS_SM_FEC_STANDARD; 133 int nsys_lateplay; 134 float nsys_latetime = NSYS_SM_LATETIME; 135 #endif 136 137 unsigned char nsys_keydigest[NSYS_MD5_LENGTH]; 138 unsigned char nsys_session_base64[NSYS_BASE64_LENGTH]; 139 int nsys_msession; 140 int nsys_msessionmirror; 141 142 char nsys_clientname[NSYS_HOSTNAMESIZE]; 143 char nsys_clientip[16]; 144 char * nsys_username; 145 146 char nsys_cname[NSYS_CNAMESIZE]; 147 unsigned char nsys_cname_len; 148 int nsys_powerup_mset; 149 150 /***********/ 151 /* logging */ 152 /***********/ 153 154 int nsys_stderr_size; 155 156 /*********************/ 157 /* MIDI input buffer */ 158 /*********************/ 159 160 unsigned char nsys_buff[NSYS_BUFFSIZE]; 161 long nsys_bufflen; 162 long nsys_buffcnt; 163 164 /*~~~~~~~~~~~*/ 165 /* rtp-midi */ 166 /*___________*/ 167 168 /*************************/ 169 /* command section flags */ 170 /*************************/ 171 172 unsigned char nsys_netout_sm_header; 173 174 /*************************/ 175 /* checkpoint management */ 176 /*************************/ 177 178 unsigned long nsys_netout_jsend_checkpoint_seqnum; /* current checkpoint */ 179 unsigned long nsys_netout_jsend_checkpoint_changed; /* 1 if changed */ 180 181 /*********************/ 182 /* S-list management */ 183 /*********************/ 184 185 unsigned char * nsys_netout_jsend_slist[NSYS_SM_SLISTLEN]; 186 int nsys_netout_jsend_slist_size; 187 188 /*******************************/ 189 /* guard journal state machine */ 190 /*******************************/ 191 192 int nsys_netout_jsend_guard_send; /* flag variable: send a guard packet */ 193 int nsys_netout_jsend_guard_time; /* guard packet timer state */ 194 int nsys_netout_jsend_guard_next; /* reload value for timer */ 195 int nsys_netout_jsend_guard_ontime; /* minimum delay time for noteon */ 196 int nsys_netout_jsend_guard_mintime; /* minimum delay time for (!noteon) */ 197 int nsys_netout_jsend_guard_maxtime; /* maximum delay time */ 198 199 /***************************/ 200 /* recovery journal header */ 201 /***************************/ 202 203 unsigned char nsys_netout_jsend_header[NSYS_SM_JH_SIZE]; /* journal header */ 204 205 /**************************/ 206 /* channel journal record */ 207 /**************************/ 208 209 unsigned char nsys_netout_jsend_channel[CSYS_MIDI_NUMCHAN]; 210 unsigned char nsys_netout_jsend_channel_size; 211 212 /************************/ 213 /* sender channel state */ 214 /************************/ 215 216 nsys_netout_jsend_state nsys_netout_jsend[CSYS_MIDI_NUMCHAN]; 217 218 /***********************/ 219 /* sender system state */ 220 /***********************/ 221 222 nsys_netout_jsend_system_state nsys_netout_jsend_system; 223 nsys_netout_jsend_xstack_element nsys_netout_jsend_xpile[NSYS_SM_CX_MAXSLOTS]; 224 nsys_netout_jsend_xstack_element * nsys_netout_jsend_xstackfree; 225 226 /**************************/ 227 /* receiver channel state */ 228 /**************************/ 229 230 nsys_netout_jrecv_state * nsys_recvfree; 231 nsys_netout_jrecv_system_state * nsys_recvsysfree; 232 233 /****************************/ 234 /* supported SysEx commands */ 235 /****************************/ 236 237 unsigned char nsys_netout_sysconst_manuex[CSYS_MIDI_MANUEX_SIZE] = { 238 0xF0, 0x43, 0x73, 0x7F, 0x32, 0x11, 0x00, 0x00, 0x00, 0xF7 }; 239 240 unsigned char nsys_netout_sysconst_mvolume[CSYS_MIDI_MVOLUME_SIZE] = { 241 0xF0, 0x7F, 0x7F, 0x04, 0x01, 0x00, 0x00, 0xF7}; 242 243 unsigned char nsys_netout_sysconst_gmreset[CSYS_MIDI_GMRESET_SIZE] = { 244 0xF0, 0x7E, 0x7F, 0x09, 0x00, 0xF7}; 245 246 247 /*******/ 248 /* SIP */ 249 /*******/ 250 251 unsigned char nsys_rtp_invite[NSYS_UDPMAXSIZE+1]; 252 unsigned char nsys_rtcp_invite[NSYS_UDPMAXSIZE+1]; 253 254 int nsys_rtp_sipretry; /* sip server retry counter */ 255 int nsys_rtcp_sipretry; 256 257 int nsys_rtp_authretry; /* reauthorization counter */ 258 int nsys_rtcp_authretry; 259 260 struct sockaddr_in nsys_sip_rtp_addr; /* current SIP RTP channel */ 261 char nsys_sip_rtp_ip[16]; 262 unsigned long nsys_sip_rtp_inet_addr; 263 unsigned short nsys_sip_rtp_port; 264 unsigned short nsys_sip_rtp_sin_port; 265 266 struct sockaddr_in nsys_sip_rtcp_addr; /* current SIP RTCP channel */ 267 char nsys_sip_rtcp_ip[16]; 268 unsigned long nsys_sip_rtcp_inet_addr; 269 unsigned short nsys_sip_rtcp_port; 270 unsigned short nsys_sip_rtcp_sin_port; 271 272 int nsys_graceful_exit; /* requests termination */ 273 274 unsigned char nsys_rtp_info[NSYS_UDPMAXSIZE+1]; /* SIP INFO packets */ 275 unsigned char nsys_rtcp_info[NSYS_UDPMAXSIZE+1]; 276 277 int nsys_behind_nat; /* 1 if behind a nat */ 278 int nsys_sipinfo_count; /* INFO sending timer */ 279 int nsys_sipinfo_toggle; /* RTP/RTCP toggle */ 280 281 /***************/ 282 /* SSRC stack */ 283 /***************/ 284 285 struct nsys_source * nsys_srcfree = NULL; /* mset ssrc tokens */ 286 struct nsys_source * nsys_ssrc[NSYS_HASHSIZE]; /* SSRC hash table */ 287 struct nsys_source * nsys_srcroot = NULL; /* points into nsys_ssrc */ 288 289 /* end Network library -- global variables */ 290