1 2 /* 3 # Sfront, a SAOL to C translator 4 # This file: Network library -- constants and externs 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 40 41 /*************************/ 42 /* network include files */ 43 /*************************/ 44 45 #ifndef NSYS_NET_INCLUDE 46 47 #define NSYS_NET_INCLUDE 48 49 #ifndef NSYS_NET 50 51 #include <stdio.h> 52 #include <stdlib.h> 53 #include <errno.h> 54 #include <string.h> 55 #include <ctype.h> 56 #include "net_local.h" 57 58 #endif 59 60 #include <sys/ioctl.h> 61 #include <unistd.h> 62 #include <fcntl.h> 63 #include <time.h> 64 #include <sys/time.h> 65 #include <sys/types.h> 66 #include <sys/socket.h> 67 #include <netdb.h> 68 #include <arpa/inet.h> 69 #include <netinet/in.h> 70 #include <net/if.h> 71 72 #if (defined(sun) || defined(__sun__)) 73 #include <sys/sockio.h> 74 #endif 75 76 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ 77 /* Constants */ 78 /*________________________________________________________________________*/ 79 80 /***********************/ 81 /* debug/warning flags */ 82 /***********************/ 83 84 #define NSYS_WARN_NONE 0 /* never warn about anything */ 85 #define NSYS_WARN_STANDARD 1 /* print connect messages */ 86 #define NSYS_WARN_UNUSUAL 2 /* print unusual events */ 87 88 #define NSYS_WARN NSYS_WARN_UNUSUAL 89 90 #define NSYS_JOURNAL_DEBUG_OFF 0 91 #define NSYS_JOURNAL_DEBUG_ON 1 92 93 #define NSYS_JOURNAL_DEBUG NSYS_JOURNAL_DEBUG_OFF 94 95 #define NSYS_LATENOTES_DEBUG_OFF 0 96 #define NSYS_LATENOTES_DEBUG_ON 1 97 98 #define NSYS_LATENOTES_DEBUG NSYS_LATENOTES_DEBUG_OFF 99 100 #define NSYS_LOSSMODEL_OFF 0 101 #define NSYS_LOSSMODEL_ON 1 102 103 #define NSYS_LOSSMODEL_LOSSRATE 0.2F /* between 0.0F and 1.0F */ 104 #define NSYS_LOSSMODEL NSYS_LOSSMODEL_OFF 105 106 #define NSYS_NETOUT_CHAPTERE_OFF 0 /* don't send Chapter E */ 107 #define NSYS_NETOUT_CHAPTERE_ON 1 /* send Chapter E */ 108 109 #define NSYS_NETOUT_CHAPTERE_STATUS NSYS_NETOUT_CHAPTERE_OFF 110 111 /********************/ 112 /* network constants */ 113 /********************/ 114 115 #define NSYS_MAXRETRY 256 116 #define NSYS_DONE 0 117 #define NSYS_ERROR 1 118 119 #define NSYS_NONBLOCK 0 120 #define NSYS_BLOCK 1 121 122 #define NSYS_BUFFSIZE 5120 123 124 /*****************************/ 125 /* default system parameters */ 126 /*****************************/ 127 128 #ifndef EV 129 #define EV(x) x 130 #endif 131 132 #if defined(__APPLE__) /* variable-length ifconf */ 133 #define NSYS_IFCONF_VARLEN 1 134 #else 135 #define NSYS_IFCONF_VARLEN 0 136 #endif 137 138 #ifndef SO_BSDCOMPAT 139 #define SO_BSDCOMPAT 0 140 #endif 141 142 #ifndef NSYS_MSETS 143 #define NSYS_MSETS 5 144 #endif 145 146 #ifndef ACYCLE 147 #define ACYCLE 42L 148 #endif 149 150 #ifndef ARATE 151 #define ARATE 44100.0F 152 #endif 153 154 #ifndef APPNAME 155 #define APPNAME "unknown" 156 #endif 157 158 #ifndef APPVERSION 159 #define APPVERSION "0.0" 160 #endif 161 162 #ifndef CSYS_MIDI_NUMCHAN 163 #define CSYS_MIDI_NUMCHAN 16 164 #endif 165 166 #ifndef CSYS_MIDI_NOOP 167 #define CSYS_MIDI_NOOP 0x70u 168 #endif 169 170 #ifndef CSYS_MIDI_POWERUP 171 #define CSYS_MIDI_POWERUP 0x73u 172 #endif 173 174 #ifndef CSYS_MIDI_TSTART 175 #define CSYS_MIDI_TSTART 0x7Du 176 #endif 177 178 #ifndef CSYS_MIDI_MANUEX 179 #define CSYS_MIDI_MANUEX 0x7Du 180 #endif 181 182 #ifndef CSYS_MIDI_MVOLUME 183 #define CSYS_MIDI_MVOLUME 0x7Eu 184 #endif 185 186 #ifndef CSYS_MIDI_GMRESET 187 #define CSYS_MIDI_GMRESET 0x7Fu 188 #endif 189 190 #ifndef CSYS_MIDI_NOTEOFF 191 #define CSYS_MIDI_NOTEOFF 0x80u 192 #endif 193 194 #ifndef CSYS_MIDI_NOTEON 195 #define CSYS_MIDI_NOTEON 0x90u 196 #endif 197 198 #ifndef CSYS_MIDI_PTOUCH 199 #define CSYS_MIDI_PTOUCH 0xA0u 200 #endif 201 202 #ifndef CSYS_MIDI_CC 203 #define CSYS_MIDI_CC 0xB0u 204 #endif 205 206 #ifndef CSYS_MIDI_PROGRAM 207 #define CSYS_MIDI_PROGRAM 0xC0u 208 #endif 209 210 #ifndef CSYS_MIDI_CTOUCH 211 #define CSYS_MIDI_CTOUCH 0xD0u 212 #endif 213 214 #ifndef CSYS_MIDI_WHEEL 215 #define CSYS_MIDI_WHEEL 0xE0u 216 #endif 217 218 #ifndef CSYS_MIDI_SYSTEM 219 #define CSYS_MIDI_SYSTEM 0xF0u 220 #endif 221 222 #ifndef CSYS_MIDI_SYSTEM_SYSEX_START 223 #define CSYS_MIDI_SYSTEM_SYSEX_START 0xF0u 224 #endif 225 226 #ifndef CSYS_MIDI_SYSTEM_QFRAME 227 #define CSYS_MIDI_SYSTEM_QFRAME 0xF1u 228 #endif 229 230 #ifndef CSYS_MIDI_SYSTEM_SONG_PP 231 #define CSYS_MIDI_SYSTEM_SONG_PP 0xF2u 232 #endif 233 234 #ifndef CSYS_MIDI_SYSTEM_SONG_SELECT 235 #define CSYS_MIDI_SYSTEM_SONG_SELECT 0xF3u 236 #endif 237 238 #ifndef CSYS_MIDI_SYSTEM_UNUSED1 239 #define CSYS_MIDI_SYSTEM_UNUSED1 0xF4u 240 #endif 241 242 #ifndef CSYS_MIDI_SYSTEM_UNUSED2 243 #define CSYS_MIDI_SYSTEM_UNUSED2 0xF5u 244 #endif 245 246 #ifndef CSYS_MIDI_SYSTEM_TUNE_REQUEST 247 #define CSYS_MIDI_SYSTEM_TUNE_REQUEST 0xF6u 248 #endif 249 250 #ifndef CSYS_MIDI_SYSTEM_SYSEX_END 251 #define CSYS_MIDI_SYSTEM_SYSEX_END 0xF7u 252 #endif 253 254 #ifndef CSYS_MIDI_SYSTEM_CLOCK 255 #define CSYS_MIDI_SYSTEM_CLOCK 0xF8u 256 #endif 257 258 #ifndef CSYS_MIDI_SYSTEM_TICK 259 #define CSYS_MIDI_SYSTEM_TICK 0xF9u 260 #endif 261 262 #ifndef CSYS_MIDI_SYSTEM_START 263 #define CSYS_MIDI_SYSTEM_START 0xFAu 264 #endif 265 266 #ifndef CSYS_MIDI_SYSTEM_CONTINUE 267 #define CSYS_MIDI_SYSTEM_CONTINUE 0xFBu 268 #endif 269 270 #ifndef CSYS_MIDI_SYSTEM_STOP 271 #define CSYS_MIDI_SYSTEM_STOP 0xFCu 272 #endif 273 274 #ifndef CSYS_MIDI_SYSTEM_UNUSED3 275 #define CSYS_MIDI_SYSTEM_UNUSED3 0xFDu 276 #endif 277 278 #ifndef CSYS_MIDI_SYSTEM_SENSE 279 #define CSYS_MIDI_SYSTEM_SENSE 0xFEu 280 #endif 281 282 #ifndef CSYS_MIDI_SYSTEM_RESET 283 #define CSYS_MIDI_SYSTEM_RESET 0xFFu 284 #endif 285 286 #ifndef CSYS_MIDI_CC_BANKSELECT_MSB 287 #define CSYS_MIDI_CC_BANKSELECT_MSB 0x00u 288 #endif 289 290 #ifndef CSYS_MIDI_CC_MODWHEEL_MSB 291 #define CSYS_MIDI_CC_MODWHEEL_MSB 0x01u 292 #endif 293 294 #ifndef CSYS_MIDI_CC_DATAENTRY_MSB 295 #define CSYS_MIDI_CC_DATAENTRY_MSB 0x06u 296 #endif 297 298 #ifndef CSYS_MIDI_CC_CHANVOLUME_MSB 299 #define CSYS_MIDI_CC_CHANVOLUME_MSB 0x07u 300 #endif 301 302 #ifndef CSYS_MIDI_CC_BANKSELECT_LSB 303 #define CSYS_MIDI_CC_BANKSELECT_LSB 0x20u 304 #endif 305 306 #ifndef CSYS_MIDI_CC_DATAENTRY_LSB 307 #define CSYS_MIDI_CC_DATAENTRY_LSB 0x26u 308 #endif 309 310 #ifndef CSYS_MIDI_CC_SUSTAIN 311 #define CSYS_MIDI_CC_SUSTAIN 0x40u 312 #endif 313 314 #ifndef CSYS_MIDI_CC_PORTAMENTOSRC 315 #define CSYS_MIDI_CC_PORTAMENTOSRC 0x54u 316 #endif 317 318 #ifndef CSYS_MIDI_CC_DATAENTRYPLUS 319 #define CSYS_MIDI_CC_DATAENTRYPLUS 0x60u 320 #endif 321 322 #ifndef CSYS_MIDI_CC_DATAENTRYMINUS 323 #define CSYS_MIDI_CC_DATAENTRYMINUS 0x61u 324 #endif 325 326 #ifndef CSYS_MIDI_CC_NRPN_LSB 327 #define CSYS_MIDI_CC_NRPN_LSB 0x62u 328 #endif 329 330 #ifndef CSYS_MIDI_CC_NRPN_MSB 331 #define CSYS_MIDI_CC_NRPN_MSB 0x63u 332 #endif 333 334 #ifndef CSYS_MIDI_CC_RPN_LSB 335 #define CSYS_MIDI_CC_RPN_LSB 0x64u 336 #endif 337 338 #ifndef CSYS_MIDI_CC_RPN_MSB 339 #define CSYS_MIDI_CC_RPN_MSB 0x65u 340 #endif 341 342 #ifndef CSYS_MIDI_CC_ALLSOUNDOFF 343 #define CSYS_MIDI_CC_ALLSOUNDOFF 0x78u 344 #endif 345 346 #ifndef CSYS_MIDI_CC_RESETALLCONTROL 347 #define CSYS_MIDI_CC_RESETALLCONTROL 0x79u 348 #endif 349 350 #ifndef CSYS_MIDI_CC_LOCALCONTROL 351 #define CSYS_MIDI_CC_LOCALCONTROL 0x7Au 352 #endif 353 354 #ifndef CSYS_MIDI_CC_ALLNOTESOFF 355 #define CSYS_MIDI_CC_ALLNOTESOFF 0x7Bu 356 #endif 357 358 #ifndef CSYS_MIDI_CC_OMNI_OFF 359 #define CSYS_MIDI_CC_OMNI_OFF 0x7Cu 360 #endif 361 362 #ifndef CSYS_MIDI_CC_OMNI_ON 363 #define CSYS_MIDI_CC_OMNI_ON 0x7Du 364 #endif 365 366 #ifndef CSYS_MIDI_CC_MONOMODE 367 #define CSYS_MIDI_CC_MONOMODE 0x7Eu 368 #endif 369 370 #ifndef CSYS_MIDI_CC_POLYMODE 371 #define CSYS_MIDI_CC_POLYMODE 0x7Fu 372 #endif 373 374 #define CSYS_MIDI_RPN_NULL_MSB 0x7Fu 375 #define CSYS_MIDI_RPN_NULL_LSB 0x7Fu 376 #define CSYS_MIDI_NRPN_NULL_MSB 0x7Fu 377 #define CSYS_MIDI_NRPN_NULL_LSB 0x7Fu 378 379 #define CYS_MIDI_RPN_0_DEFAULT_MSB 0x02u 380 #define CYS_MIDI_RPN_0_DEFAULT_LSB 0x00u 381 382 #define CYS_MIDI_RPN_1_DEFAULT_MSB 0x04u 383 #define CYS_MIDI_RPN_1_DEFAULT_LSB 0x00u 384 385 #define CYS_MIDI_RPN_2_DEFAULT_MSB 0x04u 386 #define CYS_MIDI_RPN_2_DEFAULT_LSB 0x00u 387 388 #define CSYS_MIDI_MANUEX_SIZE 10 /* size of Manufacturers sample Sysex */ 389 #define CSYS_MIDI_MVOLUME_SIZE 8 /* size of Master Volume Sysex */ 390 #define CSYS_MIDI_GMRESET_SIZE 6 /* size of General MIDI Reset Sysex */ 391 392 #define NSYS_NETIN_SYSBUFF (CSYS_MIDI_MANUEX_SIZE - 2) 393 394 #ifndef NSYS_DISPLAY_RTCP 395 #define NSYS_DISPLAY_RTCP 0 396 #endif 397 398 #ifndef NSYS_DISPLAY_RTCP_HDR 399 #define NSYS_DISPLAY_RTCP_HDR 0 400 #endif 401 402 #ifndef NSYS_DISPLAY_RTCP_SRINFO 403 #define NSYS_DISPLAY_RTCP_SRINFO 0 404 #endif 405 406 #ifndef NSYS_DISPLAY_RTCP_SDES 407 #define NSYS_DISPLAY_RTCP_SDES 0 408 #endif 409 410 #ifndef NSYS_DISPLAY_RTCP_RRINFO 411 #define NSYS_DISPLAY_RTCP_RRINFO 0 412 #endif 413 414 #ifndef NSYS_DISPLAY_RTCP_RRTCOMP 415 #define NSYS_DISPLAY_RTCP_RRTCOMP 0 416 #endif 417 418 /***************/ 419 /* rtp defines */ 420 /***************/ 421 422 /* SSRC hash table constants */ 423 424 #define NSYS_HASHSIZE 32 /* table size */ 425 #define NSYS_HASHMASK 31 /* table mask */ 426 427 /* preferred value for bidirectional RTP port */ 428 429 #define NSYS_RTP_PORT 5004 430 #define NSYS_RTP_MAXPORT 65535 431 432 /* Based on Ethernet default MTU of 1500 bytes */ 433 434 #define NSYS_UDPMAXSIZE 1472 435 #define NSYS_RTPMAXSIZE 1460 436 437 /* masks for combing usec and sec for srand() seed */ 438 439 #define NSYS_USECMASK (0x000FFFFF) 440 #define NSYS_SECMASK (0xFFF00000) 441 #define NSYS_SECSHIFT 20 442 443 /* positions of interesting parts of RTP header */ 444 445 #define NSYS_RTPLOC_BYTE1 0 446 #define NSYS_RTPLOC_PTYPE 1 447 #define NSYS_RTPLOC_SEQNUM 2 448 #define NSYS_RTPLOC_TSTAMP 4 449 #define NSYS_RTPLOC_SSRC 8 450 451 /* extended sequence number constants */ 452 453 #define NSYS_RTPSEQ_MAXDIFF 4000 /* max number of lost packets */ 454 #define NSYS_RTPSEQ_HIGHEST 0xFFFFFFFF /* highest sequence number */ 455 #define NSYS_RTPSEQ_LOWLIMIT 4095 /* lo edge of 16-bit sequence */ 456 #define NSYS_RTPSEQ_HILIMIT 61440 /* hi edge of 16-bit sequence */ 457 #define NSYS_RTPSEQ_EXMASK 0xFFFF0000 /* masks out extension */ 458 #define NSYS_RTPSEQ_LOMASK 0x0000FFFF /* masks out 16-bit seqnum */ 459 #define NSYS_RTPSEQ_EXINCR 0x00010000 /* increments extension */ 460 461 #define NSYS_RTPSEQ_MAXLOSS 8388607 /* max number of lost packets */ 462 #define NSYS_RTPSEQ_MINLOSS -8388608 /* min number of lost packets */ 463 #define NSYS_RTPSEQ_FMASK 0x00FFFFFF /* bit mask to add fraction */ 464 #define NSYS_RTPSEQ_TSIGN 0x00800000 /* bit mask for sign-extend */ 465 466 /* other RTP constants */ 467 468 #define NSYS_RTPVAL_BYTE1 0x80 /* V=2, P=X=CC=0 */ 469 #define NSYS_RTPVAL_SETMARK 0x80 /* | to set marker */ 470 #define NSYS_RTPVAL_CLRMARK 0x7F /* & to clr marker */ 471 #define NSYS_RTPVAL_CHKMARK 0x80 /* & to chk marker */ 472 473 #define NSYS_RTPLEN_HDR 12 474 475 /* condition codes for a new RTP packet */ 476 477 #define NSYS_RTPCODE_NORMAL 0 /* seqnum directly follows last packet */ 478 #define NSYS_RTPCODE_LOSTONE 1 /* one packet has been lost */ 479 #define NSYS_RTPCODE_LOSTMANY 2 /* many packets have been lost */ 480 #define NSYS_RTPCODE_DISCARD 3 /* too late to use, or duplicate */ 481 #define NSYS_RTPCODE_SECURITY 4 /* possible replay attack, discard */ 482 483 /* number of bytes of digest to append */ 484 485 #define NSYS_RTPSIZE_DIGEST 4 486 487 /**************/ 488 /* rtcp sizes */ 489 /**************/ 490 491 /* sizes of complete RTCP packets */ 492 493 #define NSYS_RTCPLEN_BYE 8 /* BYE packet */ 494 #define NSYS_RTCPLEN_RREMPTY 8 /* RR with no report */ 495 #define NSYS_RTCPLEN_RR 32 /* RR with one report */ 496 #define NSYS_RTCPLEN_SREMPTY 28 /* SR with no reciept report */ 497 #define NSYS_RTCPLEN_SR 52 /* SR with one receipt report */ 498 #define NSYS_RTCPLEN_MINIMUM 8 /* the minimum packet size */ 499 500 /* sizes of RTCP headers */ 501 502 #define NSYS_RTCPLEN_SRHDR 8 503 #define NSYS_RTCPLEN_RRHDR 8 504 #define NSYS_RTCPLEN_SDESHDR 4 505 #define NSYS_RTCPLEN_BYEHDR 4 506 507 /* sizes of RTCP segments */ 508 509 #define NSYS_RTCPLEN_SENDER 20 510 #define NSYS_RTCPLEN_REPORT 24 511 512 /* sizes of SDES headers */ 513 514 #define NSYS_RTCPLEN_SDES_CHUNKHDR 4 515 #define NSYS_RTCPLEN_SDES_ITEMHDR 2 516 517 /******************/ 518 /* rtcp locations */ 519 /******************/ 520 521 /* interesting shared locations in RR/SR headers */ 522 523 #define NSYS_RTCPLOC_BYTE1 0 524 #define NSYS_RTCPLOC_PTYPE 1 525 #define NSYS_RTCPLOC_LENGTH 2 526 #define NSYS_RTCPLOC_SSRC 4 527 528 /* locations of SR sender info */ 529 530 #define NSYS_RTCPLOC_SR_NTPMSB 8 531 #define NSYS_RTCPLOC_SR_NTPLSB 12 532 #define NSYS_RTCPLOC_SR_TSTAMP 16 533 #define NSYS_RTCPLOC_SR_PACKET 20 534 #define NSYS_RTCPLOC_SR_OCTET 24 535 536 /* interesting offsets into RR sender info */ 537 538 #define NSYS_RTCPLOC_RR_SSRC 0 539 #define NSYS_RTCPLOC_RR_FRACTLOSS 4 540 #define NSYS_RTCPLOC_RR_NUMLOST 5 541 #define NSYS_RTCPLOC_RR_HISEQ 8 542 #define NSYS_RTCPLOC_RR_JITTER 12 543 #define NSYS_RTCPLOC_RR_LASTSR 16 544 #define NSYS_RTCPLOC_RR_DELAY 20 545 546 /* interesting locations in an SDES packet ITEM */ 547 548 #define NSYS_RTCPLOC_SDESITEM_TYPE 0 549 #define NSYS_RTCPLOC_SDESITEM_LENGTH 1 550 551 /* interesting locations in RTCP BYE packet */ 552 553 #define NSYS_RTCPLEN_BYE_SSRC 4 554 555 /***************/ 556 /* rtcp values */ 557 /***************/ 558 559 #define NSYS_RTCPVAL_BYTE1 0x80 /* V=2, P=XC=0 */ 560 561 #define NSYS_RTCPVAL_COUNTMASK 0x1F /* mask for RC value */ 562 #define NSYS_RTCPVAL_COOKIEMASK 0xE0 /* mask for VP bits */ 563 564 #define NSYS_RTCPVAL_SR 0xC8 /* RTCP sender */ 565 #define NSYS_RTCPVAL_RR 0xC9 /* RTCP receiver */ 566 #define NSYS_RTCPVAL_SDES 0xCA /* RTCP source desc */ 567 #define NSYS_RTCPVAL_BYE 0xCB /* RTCP bye */ 568 #define NSYS_RTCPVAL_APP 0xCC /* RTCP APP packet */ 569 570 #define NSYS_RTCPVAL_SDES_CNAME 0x01 /* CNAME for SDES */ 571 #define NSYS_RTCPVAL_SDES_NAME 0x02 /* NAME for SDES */ 572 #define NSYS_RTCPVAL_SDES_EMAIL 0x03 /* EMAIL for SDES */ 573 #define NSYS_RTCPVAL_SDES_PHONE 0x04 /* PHONE for SDES */ 574 #define NSYS_RTCPVAL_SDES_LOC 0x05 /* LOC for SDES */ 575 #define NSYS_RTCPVAL_SDES_TOOL 0x06 /* TOOL for SDES */ 576 #define NSYS_RTCPVAL_SDES_NOTE 0x07 /* NOTE for SDES */ 577 #define NSYS_RTCPVAL_SDES_PRIV 0x08 /* PRIV for SDES */ 578 579 #define NSYS_RTCPVAL_SDES_SIZE 9 /* number of SDES types */ 580 581 /****************/ 582 /* rtcp control */ 583 /****************/ 584 585 /* RTCP and SIP INFO timer constants */ 586 587 #define NSYS_RTCPTIME_INCR 5 /* 5 seconds between RTCP sends */ 588 #define NSYS_RTCPTIME_SKIP 2 /* threshold for retransmit skip */ 589 #define NSYS_RTCPTIME_TIMEOUT 25 /* 25 second SSRC timeout */ 590 #define NSYS_RTCPTIME_MLENGTH 300 /* 5 minute limit for msession */ 591 #define NSYS_SIPINFO_TRIGGER 6 /* every 5 RTCP send a SIP INFO */ 592 593 /* RTCP-monitored exceptions */ 594 595 #define NSYS_RTCPEX_RTPSIP 1 /* no response on SIP RTP channel */ 596 #define NSYS_RTCPEX_RTPNEXT 2 /* skip RTP retransmission cycle */ 597 #define NSYS_RTCPEX_RTCPSIP 4 /* no response on SIP RTP channel */ 598 #define NSYS_RTCPEX_RTCPNEXT 8 /* skip RTCP retransmission cycle */ 599 #define NSYS_RTCPEX_NULLROOT 16 /* if nsys_srcroot == NULL */ 600 #define NSYS_RTCPEX_SRCDUPL 32 /* SSRC clash */ 601 602 /********************/ 603 /* rtp-midi payload */ 604 /********************/ 605 606 /*+++++++++++++++++++++++*/ 607 /* midi command payload */ 608 /*+++++++++++++++++++++++*/ 609 610 #define NSYS_SM_MLENMASK 15 /* minimal LEN field mask */ 611 #define NSYS_SM_EXPANDMAX 4095 /* worst case buffer expansion */ 612 613 #define NSYS_SM_DTIME 128 /* & for continuing delta-time octet */ 614 615 #define NSYS_SM_SETB 128 /* | to set B header bit */ 616 #define NSYS_SM_CLRB 127 /* & to clear B header bit */ 617 #define NSYS_SM_CHKB 128 /* & to check B header bit */ 618 619 #define NSYS_SM_SETJ 64 /* | to set J header bit */ 620 #define NSYS_SM_CLRJ 191 /* & to clear J header bit */ 621 #define NSYS_SM_CHKJ 64 /* & to check J header bit */ 622 623 #define NSYS_SM_SETZ 32 /* | to set Z header bit */ 624 #define NSYS_SM_CLRZ 223 /* & to clear Z header bit */ 625 #define NSYS_SM_CHKZ 32 /* & to check Z header bit */ 626 627 #define NSYS_SM_SETP 16 /* | to set P header bit */ 628 #define NSYS_SM_CLRP 239 /* & to clear P header bit */ 629 #define NSYS_SM_CHKP 16 /* & to check P header bit */ 630 631 /*++++++++++++++++++++++++++++*/ 632 /* recovery journal constants */ 633 /*++++++++++++++++++++++++++++*/ 634 635 #define NSYS_SM_SETS 128 /* | to set S header bit */ 636 #define NSYS_SM_CLRS 127 /* & to clear S header bit */ 637 #define NSYS_SM_CHKS 128 /* & to check S header bit */ 638 639 #define NSYS_SM_SETH 128 /* | to set H history bit */ 640 #define NSYS_SM_CLRH 127 /* & to clear H history bit */ 641 #define NSYS_SM_CHKH 128 /* & to check H history bit */ 642 643 #define NSYS_SM_SLISTLEN 128 /* maximum S list size */ 644 645 #define NSYS_SM_SETHI 128 /* for MIDI data bytes */ 646 #define NSYS_SM_CLRHI 127 647 #define NSYS_SM_CHKHI 128 648 649 /*+++++++++++++++++++++++++*/ 650 /* recovery journal header */ 651 /*+++++++++++++++++++++++++*/ 652 653 #define NSYS_SM_JH_SIZE 3 /* journal header size */ 654 #define NSYS_SM_JH_LOC_FLAGS 0 /* byte 0: flags */ 655 #define NSYS_SM_JH_LOC_CHECK 1 /* bytes 1-2: checkpoint packet */ 656 657 #define NSYS_SM_JH_CHANMASK 0x0F /* to mask channel number */ 658 659 #define NSYS_SM_JH_SETH 16 /* | to set H header bit */ 660 #define NSYS_SM_JH_CLRH 239 /* & to clear A header bit */ 661 #define NSYS_SM_JH_CHKH 16 /* & to check H header bit */ 662 663 #define NSYS_SM_JH_SETA 32 /* | to set A header bit */ 664 #define NSYS_SM_JH_CLRA 223 /* & to clear A header bit */ 665 #define NSYS_SM_JH_CHKA 32 /* & to check A header bit */ 666 667 #define NSYS_SM_JH_SETY 64 /* | to set Y header bit */ 668 #define NSYS_SM_JH_CLRY 191 /* & to clear Y header bit */ 669 #define NSYS_SM_JH_CHKY 64 /* & to check Y header bit */ 670 671 /*+++++++++++++++++++++++*/ 672 /* system journal header */ 673 /*+++++++++++++++++++++++*/ 674 675 #define NSYS_SM_SH_SIZE 2 /* system journal header size */ 676 #define NSYS_SM_SH_LOC_FLAGS 0 /* octet 0: flags */ 677 #define NSYS_SM_SH_LOC_LENLSB 1 /* octet 1: length lsb */ 678 679 #define NSYS_SM_SH_MSBMASK 0x03 /* to mask length msb */ 680 #define NSYS_SM_SH_LSBMASK 0x00FF /* to mask length lsb */ 681 682 #define NSYS_SM_SH_SETD 64 /* | to set D header bit */ 683 #define NSYS_SM_SH_CLRD 191 /* & to clear D header bit */ 684 #define NSYS_SM_SH_CHKD 64 /* & to check D header bit */ 685 686 #define NSYS_SM_SH_SETV 32 /* | to set V header bit */ 687 #define NSYS_SM_SH_CLRV 223 /* & to clear V header bit */ 688 #define NSYS_SM_SH_CHKV 32 /* & to check V header bit */ 689 690 #define NSYS_SM_SH_SETQ 16 /* | to set Q header bit */ 691 #define NSYS_SM_SH_CLRQ 239 /* & to clear Q header bit */ 692 #define NSYS_SM_SH_CHKQ 16 /* & to check Q header bit */ 693 694 #define NSYS_SM_SH_SETF 8 /* | to set F header bit */ 695 #define NSYS_SM_SH_CLRF 247 /* & to clear F header bit */ 696 #define NSYS_SM_SH_CHKF 8 /* & to check F header bit */ 697 698 #define NSYS_SM_SH_SETX 4 /* | to set X header bit */ 699 #define NSYS_SM_SH_CLRX 251 /* & to clear X header bit */ 700 #define NSYS_SM_SH_CHKX 4 /* & to check X header bit */ 701 702 /*++++++++++++++++*/ 703 /* channel header */ 704 /*++++++++++++++++*/ 705 706 #define NSYS_SM_CH_SIZE 3 /* channel header size */ 707 708 #define NSYS_SM_CH_LOC_FLAGS 0 /* location of S bit & channel */ 709 #define NSYS_SM_CH_LOC_LEN 0 /* location of 10-bit length */ 710 #define NSYS_SM_CH_LOC_TOC 2 /* location of table of contents */ 711 712 #define NSYS_SM_CH_SETH 4 /* | to set H header bit */ 713 #define NSYS_SM_CH_CLRH 251 /* & to clear H header bit */ 714 #define NSYS_SM_CH_CHKH 4 /* & to check H header bit */ 715 716 #define NSYS_SM_CH_CHANMASK 0x78 /* to extract channel number */ 717 #define NSYS_SM_CH_LENMASK 0x03FF /* to extract channel length */ 718 719 #define NSYS_SM_CH_CHANSHIFT 3 /* to align channel number */ 720 721 #define NSYS_SM_CH_TOC_SETP 128 /* Program Change (0xC) */ 722 #define NSYS_SM_CH_TOC_CLRP 127 723 #define NSYS_SM_CH_TOC_CHKP 128 724 725 #define NSYS_SM_CH_TOC_SETC 64 /* Control Change (0xB) */ 726 #define NSYS_SM_CH_TOC_CLRC 191 727 #define NSYS_SM_CH_TOC_CHKC 64 728 729 #define NSYS_SM_CH_TOC_SETM 32 /* Parameter System (part of 0xB) */ 730 #define NSYS_SM_CH_TOC_CLRM 223 731 #define NSYS_SM_CH_TOC_CHKM 32 732 733 #define NSYS_SM_CH_TOC_SETW 16 /* Pitch Wheel (0xE) */ 734 #define NSYS_SM_CH_TOC_CLRW 239 735 #define NSYS_SM_CH_TOC_CHKW 16 736 737 #define NSYS_SM_CH_TOC_SETN 8 /* NoteOff (0x8), NoteOn (0x9) */ 738 #define NSYS_SM_CH_TOC_CLRN 247 739 #define NSYS_SM_CH_TOC_CHKN 8 740 741 #define NSYS_SM_CH_TOC_SETE 4 /* Note Command Extras (0x8, 0x9) */ 742 #define NSYS_SM_CH_TOC_CLRE 251 743 #define NSYS_SM_CH_TOC_CHKE 4 744 745 #define NSYS_SM_CH_TOC_SETT 2 /* Channel Aftertouch (0xD) */ 746 #define NSYS_SM_CH_TOC_CLRT 253 747 #define NSYS_SM_CH_TOC_CHKT 2 748 749 #define NSYS_SM_CH_TOC_SETA 1 /* Poly Aftertouch (0xA) */ 750 #define NSYS_SM_CH_TOC_CLRA 254 751 #define NSYS_SM_CH_TOC_CHKA 1 752 753 /*++++++++++++++++++++++++++++*/ 754 /* chapter P (program change) */ 755 /*++++++++++++++++++++++++++++*/ 756 757 #define NSYS_SM_CP_SIZE 3 /* chapter size */ 758 759 #define NSYS_SM_CP_LOC_PROGRAM 0 /* PROGRAM octet */ 760 #define NSYS_SM_CP_LOC_BANKMSB 1 /* BANK-MSB octet */ 761 #define NSYS_SM_CP_LOC_BANKLSB 2 /* BANK-LSB octet */ 762 763 #define NSYS_SM_CP_SETB 128 /* | to set B header bit */ 764 #define NSYS_SM_CP_CLRB 127 /* & to clear B header bit */ 765 #define NSYS_SM_CP_CHKB 128 /* & to check B header bit */ 766 767 #define NSYS_SM_CP_SETX 128 /* | to set X header bit */ 768 #define NSYS_SM_CP_CLRX 127 /* & to clear X header bit */ 769 #define NSYS_SM_CP_CHKX 128 /* & to check X header bit */ 770 771 /*++++++++++++++++++++++++++++*/ 772 /* chapter C (control change) */ 773 /*++++++++++++++++++++++++++++*/ 774 775 #define NSYS_SM_CC_SIZE 257 /* maximum chapter size */ 776 777 #define NSYS_SM_CC_LOC_LENGTH 0 /* LENGTH byte */ 778 #define NSYS_SM_CC_LOC_LOGSTART 1 /* start of controller logs */ 779 780 #define NSYS_SM_CC_HDRSIZE 1 /* size of chapter c header */ 781 #define NSYS_SM_CC_LOGSIZE 2 /* size of each controller log */ 782 783 #define NSYS_SM_CC_LOC_LNUM 0 /* CONTROLLER byte in each log */ 784 #define NSYS_SM_CC_LOC_LVAL 1 /* VALUE/COUNT byte in each log */ 785 786 #define NSYS_SM_CC_ARRAYSIZE 128 /* size of controller state arrays */ 787 788 #define NSYS_SM_CC_SETA 128 /* | to set A log bit */ 789 #define NSYS_SM_CC_CLRA 127 /* & to clear A log bit */ 790 #define NSYS_SM_CC_CHKA 128 /* & to check A log bit */ 791 792 #define NSYS_SM_CC_SETT 64 /* | to set T log bit */ 793 #define NSYS_SM_CC_CLRT 191 /* & to clear T log bit */ 794 #define NSYS_SM_CC_CHKT 64 /* & to check T log bit */ 795 796 #define NSYS_SM_CC_ALTMOD 0x3F /* for updating ALT state */ 797 798 /*++++++++++++++++++++++++++++++*/ 799 /* chapter M (parameter change) */ 800 /*++++++++++++++++++++++++++++++*/ 801 802 /* chapter M: header */ 803 804 #define NSYS_SM_CM_LOC_HDR 0 /* header location */ 805 #define NSYS_SM_CM_LOC_PENDING 2 /* pending field */ 806 807 #define NSYS_SM_CM_HDRSIZE 2 /* Chapter M header size */ 808 #define NSYS_SM_CM_PENDINGSIZE 1 /* PENDING field size */ 809 810 #define NSYS_SM_CM_LENMASK 0x03FF /* LENGTH header field mask */ 811 812 #define NSYS_SM_CM_HDR_SETP 64 /* Pending header bit */ 813 #define NSYS_SM_CM_HDR_CLRP 191 814 #define NSYS_SM_CM_HDR_CHKP 64 815 816 #define NSYS_SM_CM_HDR_SETE 32 /* progress header bit */ 817 #define NSYS_SM_CM_HDR_CLRE 223 818 #define NSYS_SM_CM_HDR_CHKE 32 819 820 #define NSYS_SM_CM_HDR_SETU 16 /* ALL-RPN bit */ 821 #define NSYS_SM_CM_HDR_CLRU 239 822 #define NSYS_SM_CM_HDR_CHKU 16 823 824 #define NSYS_SM_CM_HDR_SETW 8 /* ALL-NRPN bit */ 825 #define NSYS_SM_CM_HDR_CLRW 247 826 #define NSYS_SM_CM_HDR_CHKW 8 827 828 #define NSYS_SM_CM_HDR_SETZ 4 /* PNUM-MSB == 0x00 bit*/ 829 #define NSYS_SM_CM_HDR_CLRZ 251 830 #define NSYS_SM_CM_HDR_CHKZ 4 831 832 #define NSYS_SM_CM_PENDING_SETQ 128 /* RPN/NRPN flag for PENDING */ 833 #define NSYS_SM_CM_PENDING_CLRQ 127 834 #define NSYS_SM_CM_PENDING_CHKQ 128 835 836 #define NSYS_SM_CM_LOC_LIST 0 /* list location in chapterl[] */ 837 838 /* Chapter M: parameter log */ 839 840 #define NSYS_SM_CM_LOGMAXSIZE 10 /* maximum size of a log */ 841 842 #define NSYS_SM_CM_LOC_PNUMLSB 0 843 #define NSYS_SM_CM_LOC_PNUMMSB 1 844 #define NSYS_SM_CM_LOC_TOC 2 845 #define NSYS_SM_CM_LOC_INFOBITS 2 846 847 #define NSYS_SM_CM_LOGHDRSIZE 3 /* parameter log header size */ 848 849 #define NSYS_SM_CM_SETQ 128 /* | to set Q log bit */ 850 #define NSYS_SM_CM_CLRQ 127 /* & to clear Q log bit */ 851 #define NSYS_SM_CM_CHKQ 128 /* & to check Q log bit */ 852 853 #define NSYS_SM_CM_SETX 128 /* | to set X log bit */ 854 #define NSYS_SM_CM_CLRX 127 /* & to clear X log bit */ 855 #define NSYS_SM_CM_CHKX 128 /* & to check X log bit */ 856 857 #define NSYS_SM_CM_BUTTON_SETG 128 /* | to set G log bit */ 858 #define NSYS_SM_CM_BUTTON_CLRG 127 /* & to clear G log bit */ 859 #define NSYS_SM_CM_BUTTON_CHKG 128 /* & to check G log bit */ 860 861 #define NSYS_SM_CM_BUTTON_SETX 64 /* | to set X log bit */ 862 #define NSYS_SM_CM_BUTTON_CLRX 191 /* & to clear X log bit */ 863 #define NSYS_SM_CM_BUTTON_CHKX 64 /* & to check X log bit */ 864 865 #define NSYS_SM_CM_BUTTON_SETR 64 /* | to set R log bit */ 866 #define NSYS_SM_CM_BUTTON_CLRR 191 /* & to clear R log bit */ 867 #define NSYS_SM_CM_BUTTON_CHKR 64 /* & to check R log bit */ 868 869 #define NSYS_SM_CM_COUNT_SIZE 1 870 871 #define NSYS_SM_CM_ENTRYMSB_SIZE 1 872 #define NSYS_SM_CM_ENTRYLSB_SIZE 1 873 874 #define NSYS_SM_CM_ABUTTON_SIZE 2 875 #define NSYS_SM_CM_CBUTTON_SIZE 2 876 877 #define NSYS_SM_CM_BUTTON_LIMIT 0x3FFF /* 16383 decimal */ 878 879 #define NSYS_SM_CM_TOC_SETJ 128 /* ENTRY-MSB field */ 880 #define NSYS_SM_CM_TOC_CLRJ 127 881 #define NSYS_SM_CM_TOC_CHKJ 128 882 883 #define NSYS_SM_CM_TOC_SETK 64 /* ENTRY-LSB field */ 884 #define NSYS_SM_CM_TOC_CLRK 191 885 #define NSYS_SM_CM_TOC_CHKK 64 886 887 #define NSYS_SM_CM_TOC_SETL 32 /* A-BUTTON field */ 888 #define NSYS_SM_CM_TOC_CLRL 223 889 #define NSYS_SM_CM_TOC_CHKL 32 890 891 #define NSYS_SM_CM_TOC_SETM 16 /* C-BUTTON field */ 892 #define NSYS_SM_CM_TOC_CLRM 239 893 #define NSYS_SM_CM_TOC_CHKM 16 894 895 #define NSYS_SM_CM_TOC_SETN 8 /* COUNT field */ 896 #define NSYS_SM_CM_TOC_CLRN 247 897 #define NSYS_SM_CM_TOC_CHKN 8 898 899 #define NSYS_SM_CM_INFO_SETT 4 /* Count-mode*/ 900 #define NSYS_SM_CM_INFO_CLRT 251 901 #define NSYS_SM_CM_INFO_CHKT 4 902 903 #define NSYS_SM_CM_INFO_SETV 2 /* Value-mode */ 904 #define NSYS_SM_CM_INFO_CLRV 253 905 #define NSYS_SM_CM_INFO_CHKV 2 906 907 #define NSYS_SM_CM_INFO_SETA 1 /* active-mode */ 908 #define NSYS_SM_CM_INFO_CLRA 254 909 #define NSYS_SM_CM_INFO_CHKA 1 910 911 /* Chapter M: implementation-specific */ 912 913 /* state machine */ 914 915 #define NSYS_SM_CM_STATE_OFF 0 916 #define NSYS_SM_CM_STATE_PENDING_RPN 1 917 #define NSYS_SM_CM_STATE_PENDING_NRPN 2 918 #define NSYS_SM_CM_STATE_RPN 3 919 #define NSYS_SM_CM_STATE_NRPN 4 920 921 /* transaction constants */ 922 923 #define NSYS_SM_CM_TRANS_NONE 0 924 #define NSYS_SM_CM_TRANS_NRPN 1 925 #define NSYS_SM_CM_TRANS_RPN 2 /* transaction type */ 926 #define NSYS_SM_CM_TRANS_NO_OPEN 4 /* do not open transaction */ 927 #define NSYS_SM_CM_TRANS_NO_SET 8 /* do not set values */ 928 #define NSYS_SM_CM_TRANS_NO_CLOSE 16 /* do not close transaction */ 929 930 /* size restrictions */ 931 932 #define NSYS_SM_CM_HDRMAXSIZE 3 /* 2 octets w/o pending */ 933 #define NSYS_SM_CM_LISTMAXSIZE 30 /* 3 10-octet logs */ 934 935 #define NSYS_SM_CM_ARRAYSIZE 3 /* 3 RPNs: */ 936 /* MSB=00 LSB=00 Pitch Bend */ 937 /* MSB=00 LSB=01 Fine Tuning */ 938 /* MSB=00 LSB=02 Coarse Tuning */ 939 940 /*+++++++++++++++++++++++++*/ 941 /* chapter W (pitch wheel) */ 942 /*+++++++++++++++++++++++++*/ 943 944 #define NSYS_SM_CW_SIZE 2 /* chapter size */ 945 946 #define NSYS_SM_CW_LOC_FIRST 0 /* FIRST byte */ 947 #define NSYS_SM_CW_LOC_SECOND 1 /* SECOND byte */ 948 949 #define NSYS_SM_CW_SETD 128 /* | to set D header bit */ 950 #define NSYS_SM_CW_CLRD 127 /* & to clear D header bit */ 951 #define NSYS_SM_CW_CHKD 128 /* & to check D header bit */ 952 953 /*+++++++++++++++++++*/ 954 /* chapter N (notes) */ 955 /*+++++++++++++++++++*/ 956 957 #define NSYS_SM_CN_SIZE 258 /* maximum chapter size (front) */ 958 #define NSYS_SM_CB_SIZE 16 /* maximum bitfield size */ 959 960 #define NSYS_SM_CN_LOC_LENGTH 0 /* LENGTH byte */ 961 #define NSYS_SM_CN_LOC_LOWHIGH 1 /* LOWHIGH byte */ 962 #define NSYS_SM_CN_LOC_LOGSTART 2 /* start of note logs */ 963 964 #define NSYS_SM_CN_LOWMASK 0xF0 /* mask for LOW */ 965 #define NSYS_SM_CN_HIGHMASK 0x0F /* mask for HIGH */ 966 #define NSYS_SM_CN_LOWSHIFT 4 /* shift align for LOW */ 967 968 #define NSYS_SM_CN_HDRSIZE 2 /* size of chapter n header */ 969 #define NSYS_SM_CN_LOGSIZE 2 /* size of each note log */ 970 971 #define NSYS_SM_CN_LOC_NUM 0 /* note number byte in each log */ 972 #define NSYS_SM_CN_LOC_VEL 1 /* velocity byte in each log */ 973 974 #define NSYS_SM_CN_SETB 128 /* | to set B header bit */ 975 #define NSYS_SM_CN_CLRB 127 /* & to clear B header bit */ 976 #define NSYS_SM_CN_CHKB 128 /* & to check B header bit */ 977 978 #define NSYS_SM_CN_SETY 128 /* | to set Y header bit */ 979 #define NSYS_SM_CN_CLRY 127 /* & to clear Y header bit */ 980 #define NSYS_SM_CN_CHKY 128 /* & to check Y header bit */ 981 982 #define NSYS_SM_CN_ARRAYSIZE 128 /* size of note state arrays */ 983 984 #define NSYS_SM_CN_BFMIN 0 /* minimum bitfield value */ 985 #define NSYS_SM_CN_BFMAX 15 /* maximum bitfield value */ 986 #define NSYS_SM_CN_BFSHIFT 3 /* note to bitfield byte shift */ 987 #define NSYS_SM_CN_BFMASK 0x07 /* mask for bit position */ 988 989 #define NSYS_SM_CN_MAXDELAY 0.020F /* lifetime of Y bit (seconds) */ 990 #define NSYS_SM_CN_RECDELAY 0.10F /* receiver test for Y lifetime */ 991 992 /*+++++++++++++++++++++++++*/ 993 /* chapter E (note extras) */ 994 /*+++++++++++++++++++++++++*/ 995 996 #define NSYS_SM_CE_SIZE 257 /* maximum size: header + ref logs */ 997 998 #define NSYS_SM_CE_LOC_LENGTH 0 /* LENGTH byte */ 999 #define NSYS_SM_CE_LOC_LOGSTART 1 /* start of note logs */ 1000 1001 #define NSYS_SM_CE_HDRSIZE 1 /* size of chapter E header */ 1002 #define NSYS_SM_CE_LOGSIZE 2 /* size of each note log */ 1003 1004 #define NSYS_SM_CE_LOC_NUM 0 /* NOTENUM byte in each log */ 1005 #define NSYS_SM_CE_LOC_COUNTVEL 1 /* COUNT/VEL byte in each log */ 1006 1007 #define NSYS_SM_CE_SETV 128 /* | to set V header bit */ 1008 #define NSYS_SM_CE_CLRV 127 /* & to clear V header bit */ 1009 #define NSYS_SM_CE_CHKV 128 /* & to check V header bit */ 1010 1011 #define NSYS_SM_CE_ARRAYSIZE 128 /* size of note extra state arrays */ 1012 #define NSYS_SM_CE_DEFREL 64 /* default release velocity value */ 1013 #define NSYS_SM_CE_MAXCOUNT 127 /* maximum reference count */ 1014 1015 /*++++++++++++++++++++++++++++++++*/ 1016 /* chapter T (channel aftertouch) */ 1017 /*++++++++++++++++++++++++++++++++*/ 1018 1019 #define NSYS_SM_CT_SIZE 1 /* chapter size */ 1020 1021 #define NSYS_SM_CT_LOC_PRESSURE 0 /* PRESSURE byte */ 1022 1023 /*++++++++++++++++++++++++*/ 1024 /* chapter A (poly touch) */ 1025 /*++++++++++++++++++++++++*/ 1026 1027 #define NSYS_SM_CA_SIZE 257 /* maximum chapter size */ 1028 1029 #define NSYS_SM_CA_LOC_LENGTH 0 /* LENGTH byte */ 1030 #define NSYS_SM_CA_LOC_LOGSTART 1 /* start of note logs */ 1031 1032 #define NSYS_SM_CA_HDRSIZE 1 /* size of chapter A header */ 1033 #define NSYS_SM_CA_LOGSIZE 2 /* size of each note log */ 1034 1035 #define NSYS_SM_CA_LOC_NUM 0 /* NOTENUM byte in each log */ 1036 #define NSYS_SM_CA_LOC_PRESSURE 1 /* PRESSURE byte in each log */ 1037 1038 #define NSYS_SM_CA_SETX 128 /* | to set X header bit */ 1039 #define NSYS_SM_CA_CLRX 127 /* & to clear X header bit */ 1040 #define NSYS_SM_CA_CHKX 128 /* & to check X header bit */ 1041 1042 #define NSYS_SM_CA_ARRAYSIZE 128 /* size of ptouch state arrays */ 1043 1044 /*+++++++++++++++++++++++++*/ 1045 /* system journal chapters */ 1046 /*+++++++++++++++++++++++++*/ 1047 1048 /*+++++++++++++++++++++++++++*/ 1049 /* chapter D (miscellaneous) */ 1050 /*+++++++++++++++++++++++++++*/ 1051 1052 #define NSYS_SM_CD_LOC_TOC 0 /* Table of Contents */ 1053 #define NSYS_SM_CD_LOC_LOGS 1 /* start of command logs */ 1054 1055 #define NSYS_SM_CD_SIZE_TOC 1 /* TOC header size */ 1056 #define NSYS_SM_CD_SIZE_RESET 1 /* Reset field size */ 1057 #define NSYS_SM_CD_SIZE_TUNE 1 /* Tune Request field size */ 1058 #define NSYS_SM_CD_SIZE_SONG 1 /* Song Select field size */ 1059 1060 #define NSYS_SM_CD_FRONT_MAXSIZE 4 /* maximum size (J = K = Y = Z = 0) */ 1061 1062 #define NSYS_SM_CD_TOC_SETB 64 /* Reset field */ 1063 #define NSYS_SM_CD_TOC_CLRB 191 1064 #define NSYS_SM_CD_TOC_CHKB 64 1065 1066 #define NSYS_SM_CD_TOC_SETG 32 /* Tune Request field */ 1067 #define NSYS_SM_CD_TOC_CLRG 223 1068 #define NSYS_SM_CD_TOC_CHKG 32 1069 1070 #define NSYS_SM_CD_TOC_SETH 16 /* Song Select field */ 1071 #define NSYS_SM_CD_TOC_CLRH 239 1072 #define NSYS_SM_CD_TOC_CHKH 16 1073 1074 #define NSYS_SM_CD_TOC_SETJ 8 /* Common 0xF4 field */ 1075 #define NSYS_SM_CD_TOC_CLRJ 247 1076 #define NSYS_SM_CD_TOC_CHKJ 8 1077 1078 #define NSYS_SM_CD_TOC_SETK 4 /* Common 0xF5 field */ 1079 #define NSYS_SM_CD_TOC_CLRK 251 1080 #define NSYS_SM_CD_TOC_CHKK 4 1081 1082 #define NSYS_SM_CD_TOC_SETY 2 /* Real-time 0xF9 field */ 1083 #define NSYS_SM_CD_TOC_CLRY 253 1084 #define NSYS_SM_CD_TOC_CHKY 2 1085 1086 #define NSYS_SM_CD_TOC_SETZ 1 /* Real-time 0xFD field */ 1087 #define NSYS_SM_CD_TOC_CLRZ 254 1088 #define NSYS_SM_CD_TOC_CHKZ 1 1089 1090 /* undefined System Common log */ 1091 1092 #define NSYS_SM_CD_COMMON_LOC_TOC 0 /* Table of Contents */ 1093 #define NSYS_SM_CD_COMMON_LOC_LENGTH 1 /* Log length */ 1094 #define NSYS_SM_CD_COMMON_LOC_FIELDS 2 /* Start of fields */ 1095 1096 #define NSYS_SM_CD_COMMON_TOC_SIZE 1 /* TOC size */ 1097 #define NSYS_SM_CD_COMMON_LENGTH_SIZE 1 /* Log Length Size (+2 bits) */ 1098 #define NSYS_SM_CD_COMMON_COUNT_SIZE 1 /* Count Field Size */ 1099 1100 #define NSYS_SM_CD_COMMON_TOC_SETC 64 /* Count field */ 1101 #define NSYS_SM_CD_COMMON_TOC_CLRC 191 1102 #define NSYS_SM_CD_COMMON_TOC_CHKC 64 1103 1104 #define NSYS_SM_CD_COMMON_TOC_SETV 32 /* Value field */ 1105 #define NSYS_SM_CD_COMMON_TOC_CLRV 223 1106 #define NSYS_SM_CD_COMMON_TOC_CHKV 32 1107 1108 #define NSYS_SM_CD_COMMON_TOC_SETL 16 /* Legal field */ 1109 #define NSYS_SM_CD_COMMON_TOC_CLRL 239 1110 #define NSYS_SM_CD_COMMON_TOC_CHKL 16 1111 1112 #define NSYS_SM_CD_COMMON_DSZ_MASK 0x0C /* bit-mask for DSZ field */ 1113 #define NSYS_SM_CD_COMMON_LENMSB_MASK 0x03 /* bit-mask for LEN MSBs */ 1114 1115 #define NSYS_SM_CD_COMMON_SIZE 5 /* implementation-specific */ 1116 1117 1118 /* undefined System Real-Time log */ 1119 1120 #define NSYS_SM_CD_REALTIME_LOC_TOC 0 /* Table of Contents */ 1121 #define NSYS_SM_CD_REALTIME_LOC_FIELDS 1 /* Start of fields */ 1122 1123 #define NSYS_SM_CD_REALTIME_TOC_SIZE 1 /* TOC size */ 1124 #define NSYS_SM_CD_REALTIME_COUNT_SIZE 1 /* Count field */ 1125 1126 #define NSYS_SM_CD_REALTIME_TOC_SETC 64 /* Count field */ 1127 #define NSYS_SM_CD_REALTIME_TOC_CLRC 191 1128 #define NSYS_SM_CD_REALTIME_TOC_CHKC 64 1129 1130 #define NSYS_SM_CD_REALTIME_TOC_SETL 32 /* Legal field */ 1131 #define NSYS_SM_CD_REALTIME_TOC_CLRL 223 1132 #define NSYS_SM_CD_REALTIME_TOC_CHKL 32 1133 1134 #define NSYS_SM_CD_REALTIME_LENGTH_MASK 0x1F /* LENGTH bit-mask */ 1135 #define NSYS_SM_CD_REALTIME_SIZE 2 /* implementation-specific */ 1136 1137 /*+++++++++++++++++++++++++++*/ 1138 /* chapter V (active sense) */ 1139 /*+++++++++++++++++++++++++++*/ 1140 1141 #define NSYS_SM_CV_SIZE 1 /* chapter size */ 1142 #define NSYS_SM_CV_LOC_COUNT 0 /* COUNT field location */ 1143 1144 /*+++++++++++++++++++++++++++*/ 1145 /* chapter Q (sequencer) */ 1146 /*+++++++++++++++++++++++++++*/ 1147 1148 #define NSYS_SM_CQ_LOC_HDR 0 /* chapter header */ 1149 #define NSYS_SM_CQ_LOC_FIELDS 1 /* start of sequencer fields */ 1150 1151 #define NSYS_SM_CQ_SIZE_HDR 1 /* chapter header size */ 1152 #define NSYS_SM_CQ_SIZE_CLOCK 2 /* CLOCK field size */ 1153 #define NSYS_SM_CQ_SIZE_TIMETOOLS 3 /* TIMETOOLS field size */ 1154 1155 #define NSYS_SM_CQ_MAXSIZE 3 /* maximum chapter size (if T = 0) */ 1156 1157 #define NSYS_SM_CQ_HDR_SETN 64 /* Start/Stop bit */ 1158 #define NSYS_SM_CQ_HDR_CLRN 191 1159 #define NSYS_SM_CQ_HDR_CHKN 64 1160 1161 #define NSYS_SM_CQ_HDR_SETD 32 /* Download field */ 1162 #define NSYS_SM_CQ_HDR_CLRD 223 1163 #define NSYS_SM_CQ_HDR_CHKD 32 1164 1165 #define NSYS_SM_CQ_HDR_SETC 16 /* CLOCK TOC bit */ 1166 #define NSYS_SM_CQ_HDR_CLRC 239 1167 #define NSYS_SM_CQ_HDR_CHKC 16 1168 1169 #define NSYS_SM_CQ_HDR_SETT 8 /* TIMETOOLS TOC bit */ 1170 #define NSYS_SM_CQ_HDR_CLRT 247 1171 #define NSYS_SM_CQ_HDR_CHKT 8 1172 1173 #define NSYS_SM_CQ_TOP_MASK 0x07 /* TOP field bit-mask */ 1174 #define NSYS_SM_CQ_BOTTOM_MASK 0x0000FFFF /* bottom 16-bits for CLOCK */ 1175 1176 #define NSYS_SM_CQ_TIMETOOLS_SETB 128 /* TIMETOOLS B bit */ 1177 #define NSYS_SM_CQ_TIMETOOLS_CLRB 127 1178 #define NSYS_SM_CQ_TIMETOOLS_CHKB 128 1179 1180 /*++++++++++++++++++++++++++++*/ 1181 /* chapter F (MIDI Time Code) */ 1182 /*++++++++++++++++++++++++++++*/ 1183 1184 #define NSYS_SM_CF_LOC_HDR 0 /* chapter header */ 1185 #define NSYS_SM_CF_LOC_FIELDS 1 /* start of timecode fields */ 1186 1187 #define NSYS_SM_CF_SIZE_HDR 1 /* chapter header size */ 1188 #define NSYS_SM_CF_SIZE_COMPLETE 4 /* COMPLETE timestamp */ 1189 #define NSYS_SM_CF_SIZE_PARTIAL 4 /* PARTIAL timestamp */ 1190 #define NSYS_SM_CF_MAXSIZE 9 /* maximum chapter size */ 1191 1192 #define NSYS_SM_CF_HDR_SETC 64 /* COMPLETE field TOC bit */ 1193 #define NSYS_SM_CF_HDR_CLRC 191 1194 #define NSYS_SM_CF_HDR_CHKC 64 1195 1196 #define NSYS_SM_CF_HDR_SETP 32 /* PARTIAL field TOC bit */ 1197 #define NSYS_SM_CF_HDR_CLRP 223 1198 #define NSYS_SM_CF_HDR_CHKP 32 1199 1200 #define NSYS_SM_CF_HDR_SETQ 16 /* Quarter-Frame status bit */ 1201 #define NSYS_SM_CF_HDR_CLRQ 239 1202 #define NSYS_SM_CF_HDR_CHKQ 16 1203 1204 #define NSYS_SM_CF_HDR_SETD 8 /* tape direction status bit */ 1205 #define NSYS_SM_CF_HDR_CLRD 247 1206 #define NSYS_SM_CF_HDR_CHKD 8 1207 1208 #define NSYS_SM_CF_POINT_MASK 0x07 /* mask POINT field bit-mask */ 1209 #define NSYS_SM_CF_POINT_CLR 0xF8 /* clear POINT field bit-mask */ 1210 1211 #define NSYS_SM_CF_SIZE_MT 1 /* message-type size */ 1212 #define NSYS_SM_CF_SIZE_HR 1 /* hours FF size */ 1213 #define NSYS_SM_CF_SIZE_MN 1 /* minutes FF size */ 1214 #define NSYS_SM_CF_SIZE_SC 1 /* seconds FF size */ 1215 #define NSYS_SM_CF_SIZE_FR 1 /* frames FF size */ 1216 1217 #define NSYS_SM_CF_FF_LOC_HR 0 /* hours FF location */ 1218 #define NSYS_SM_CF_FF_LOC_MN 1 /* minutes FF location */ 1219 #define NSYS_SM_CF_FF_LOC_SC 2 /* seconds FF location */ 1220 #define NSYS_SM_CF_FF_LOC_FR 3 /* frames FF location */ 1221 1222 #define NSYS_SM_CF_QF_LOC_FR_LSN 0 /* Frame LSN location */ 1223 #define NSYS_SM_CF_QF_LOC_FR_MSN 0 /* Frame MSN location */ 1224 #define NSYS_SM_CF_QF_LOC_SC_LSN 1 /* Seconds LSN location */ 1225 #define NSYS_SM_CF_QF_LOC_SC_MSN 1 /* Seconds MSN location */ 1226 #define NSYS_SM_CF_QF_LOC_MN_LSN 2 /* Minutes LSN location */ 1227 #define NSYS_SM_CF_QF_LOC_MN_MSN 2 /* Minutes MSN location */ 1228 #define NSYS_SM_CF_QF_LOC_HR_LSN 3 /* Hours LSN location */ 1229 #define NSYS_SM_CF_QF_LOC_HR_MSN 3 /* Hours MSN location */ 1230 1231 #define NSYS_SM_CF_IDNUM_MASK 0x70 /* MT ID # bit-mask */ 1232 #define NSYS_SM_CF_PAYLOAD_MASK 0x0F /* MT PAYLOAD # bit-mask */ 1233 1234 #define NSYS_SM_CF_EVEN_MASK 0xF0 /* mask even MTs */ 1235 #define NSYS_SM_CF_EVEN_CLR 0x0F /* clear even MTs */ 1236 1237 #define NSYS_SM_CF_ODD_MASK 0x0F /* mask odd MTs */ 1238 #define NSYS_SM_CF_ODD_CLR 0xF0 /* clear odd MTs */ 1239 1240 #define NSYS_SM_CF_IDNUM_FR_LSN 0 /* Frame LSN ID Number */ 1241 #define NSYS_SM_CF_IDNUM_FR_MSN 1 /* Frame MSN ID Number */ 1242 #define NSYS_SM_CF_IDNUM_SC_LSN 2 /* Seconds LSN ID Number */ 1243 #define NSYS_SM_CF_IDNUM_SC_MSN 3 /* Seconds MSN ID Number */ 1244 #define NSYS_SM_CF_IDNUM_MN_LSN 4 /* Minutes LSN ID Number */ 1245 #define NSYS_SM_CF_IDNUM_MN_MSN 5 /* Minutes MSN ID Number */ 1246 #define NSYS_SM_CF_IDNUM_HR_LSN 6 /* Hours LSN ID Number */ 1247 #define NSYS_SM_CF_IDNUM_HR_MSN 7 /* Hours MSN ID Number */ 1248 1249 /*++++++++++++++++++++++++++++++*/ 1250 /* chapter X (System Exclusive) */ 1251 /*++++++++++++++++++++++++++++++*/ 1252 1253 #define NSYS_SM_CX_LOC_HDR 0 /* chapter header */ 1254 #define NSYS_SM_CX_LOC_FIELDS 1 /* TCOUNT, COUNT, FIRST, DATA */ 1255 1256 #define NSYS_SM_CX_SIZE_HDR 1 /* chapter header */ 1257 #define NSYS_SM_CX_SIZE_TCOUNT 1 /* TCOUNT field */ 1258 #define NSYS_SM_CX_SIZE_COUNT 1 /* COUNT field */ 1259 1260 #define NSYS_SM_CX_HDR_SETT 64 /* TCOUNT field TOC bit */ 1261 #define NSYS_SM_CX_HDR_CLRT 191 1262 #define NSYS_SM_CX_HDR_CHKT 64 1263 1264 #define NSYS_SM_CX_HDR_SETC 32 /* COUNT field TOC bit */ 1265 #define NSYS_SM_CX_HDR_CLRC 223 1266 #define NSYS_SM_CX_HDR_CHKC 32 1267 1268 #define NSYS_SM_CX_HDR_SETF 16 /* FIRST field TOC bit */ 1269 #define NSYS_SM_CX_HDR_CLRF 239 1270 #define NSYS_SM_CX_HDR_CHKF 16 1271 1272 #define NSYS_SM_CX_HDR_SETD 8 /* DATA field TOC bit */ 1273 #define NSYS_SM_CX_HDR_CLRD 247 1274 #define NSYS_SM_CX_HDR_CHKD 8 1275 1276 #define NSYS_SM_CX_HDR_SETL 4 /* list/recency bit */ 1277 #define NSYS_SM_CX_HDR_CLRL 251 1278 #define NSYS_SM_CX_HDR_CHKL 4 1279 1280 #define NSYS_SM_CX_STA_MASK 0x03 /* STA field bit-mask */ 1281 1282 #define NSYS_SM_CX_STA_UNFINISHED 0x00 /* unfinished SysEx */ 1283 #define NSYS_SM_CX_STA_CANCELLED 0x01 /* cancelled SysEx */ 1284 #define NSYS_SM_CX_STA_DROPPEDF7 0x02 /* dropped-F7 SysEx */ 1285 #define NSYS_SM_CX_STA_NORMAL 0x03 /* normal finished SysEx */ 1286 1287 #define NSYS_SM_CX_DATA_SETEND 0x80 1288 #define NSYS_SM_CX_DATA_CHKEND 0x80 1289 #define NSYS_SM_CX_DATA_CLREND 0x7F 1290 #define NSYS_SM_CX_DATA_MASK 0x7F 1291 1292 #define NSYS_SM_CX_GMRESET_ONVAL 0x01 /* GM Reset on ndata value */ 1293 #define NSYS_SM_CX_GMRESET_OFFVAL 0x02 /* GM Reset on ndata value */ 1294 1295 /* implementation specific */ 1296 1297 #define NSYS_SM_CX_SIZE_GMRESET 6 /* log for GM Resets */ 1298 #define NSYS_SM_CX_SIZE_MVOLUME 8 /* log for Master Volume */ 1299 #define NSYS_SM_CX_SIZE_MAXLOG 8 /* maximum log size */ 1300 1301 #define NSYS_SM_CX_MAXSLOTS 3 /* at most, 3 logs in Chapter X */ 1302 1303 /*++++++++++++++++++++*/ 1304 /* rtp-midi: receiver */ 1305 /*++++++++++++++++++++*/ 1306 1307 /* number of MIDI channels to pre-allocate per receiver */ 1308 1309 #define NSYS_RECVCHAN 2 1310 1311 /* constants to handle flag bit */ 1312 1313 #define NSYS_SM_RV_SETF 128 /* | to set flag bit */ 1314 #define NSYS_SM_RV_CLRF 127 /* & to clear flag bit */ 1315 #define NSYS_SM_RV_CHKF 128 /* & to check flag bit */ 1316 1317 /* return values for nsys_netin_journal_recovery() */ 1318 1319 #define NSYS_JOURNAL_RECOVERED 0 /* must be zero */ 1320 #define NSYS_JOURNAL_FILLEDBUFF 1 1321 #define NSYS_JOURNAL_CORRUPTED 2 1322 1323 /*++++++++++++++++++*/ 1324 /* rtp-midi: sender */ 1325 /*++++++++++++++++++*/ 1326 1327 #define NSYS_SM_GUARD_ONTIME NSYS_SM_CN_MAXDELAY 1328 #define NSYS_SM_GUARD_MINTIME 0.25F 1329 #define NSYS_SM_GUARD_STDTIME 0.10F 1330 #define NSYS_SM_GUARD_MAXTIME 1.0F 1331 1332 #ifndef NSYS_NET 1333 #define NSYS_SM_FEC_NONE 0 1334 #define NSYS_SM_FEC_NOGUARD 1 1335 #define NSYS_SM_FEC_MINIMAL 2 1336 #define NSYS_SM_FEC_STANDARD 3 1337 #define NSYS_SM_FEC_EXTRA 4 1338 #endif 1339 1340 #define NSYS_SM_LATETIME 0.040F /* maximum lateness */ 1341 #define NSYS_SM_LATEWINDOW 3.5F /* time window for reset */ 1342 1343 /*******/ 1344 /* SIP */ 1345 /*******/ 1346 1347 #ifndef NSYS_SIP_IP 1348 #define NSYS_SIP_IP "169.229.59.210" 1349 #endif 1350 1351 #ifndef NSYS_SIP_RTP_PORT 1352 #define NSYS_SIP_RTP_PORT 5060 1353 #endif 1354 1355 #ifndef NSYS_SIP_RTCP_PORT 1356 #define NSYS_SIP_RTCP_PORT 5061 1357 #endif 1358 1359 #define NSYS_HOSTNAMESIZE 256 1360 #define NSYS_SDPNATSIZE 128 1361 #define NSYS_CNAMESIZE 32 1362 1363 #define NSYS_NETIN_SIPSTATE 0 /* SIP INVITE state machine states */ 1364 #define NSYS_NETIN_SDPSTATE 1 1365 #define NSYS_NETIN_EOFSTATE 2 1366 #define NSYS_NETIN_ERRSTATE 3 1367 1368 #define NSYS_SIP_RETRYMAX 5 /* max retry for initial connect */ 1369 #define NSYS_SIP_AUTHRETRYMAX 4 /* max retry for authentication */ 1370 1371 #define NSYS_SIP_UNIXTONTP 2208988800UL /* add to UNIX time for NTP (s) */ 1372 1373 /********/ 1374 /* SDP */ 1375 /********/ 1376 1377 /* number of supported payload types */ 1378 1379 #define NSYS_RTP_PAYSIZE 1 1380 1381 /* pindex values for payload types */ 1382 1383 #define NSYS_MPEG4_PINDEX 0 1384 #define NSYS_NATIVE_PINDEX 1 1385 1386 /*******************/ 1387 /* Crypto/Security */ 1388 /*******************/ 1389 1390 #define NSYS_MD5_LENGTH 16 /* array size for an MD5 digest in binary */ 1391 #define NSYS_MD5_ROUNDS 10000 /* number of MD5 passes for keydigest */ 1392 1393 #define NSYS_BASE64_LENGTH 25 /* string size of a BASE64 MD5 digest */ 1394 #define NSYS_MKEY_LENGTH 32 /* length of random key for mirror */ 1395 1396 #define NSYS_MAXLATETIME 5400 /* clocks no more than 90 minutes fast */ 1397 #define NSYS_MAXSSESIONTIME 21600 /* session maxtime is 6 hours */ 1398 1399 #define NSYS_MSESSION_NAME "mirror" /* change if sfront hashes names */ 1400 1401 #ifndef NSYS_MSESSION_INTERVAL 1402 #define NSYS_MSESSION_INTERVAL 12 /* pitch shift for mirror */ 1403 #endif 1404 1405 #define NSYS_MSESSION_MAXRTP 9000 /* maximum RTP packets in session */ 1406 #define NSYS_MSESSION_MAXRTCP 200 /* maximum RTCP packets in session */ 1407 1408 1409 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ 1410 /* Variable externs */ 1411 /*________________________________________________________________________*/ 1412 1413 1414 /*************************/ 1415 /* rtp and rtcp: network */ 1416 /*************************/ 1417 1418 extern int nsys_rtp_fd; /* fd for rtp */ 1419 extern int nsys_rtcp_fd; /* fd for rtcp */ 1420 extern int nsys_max_fd; /* fd for select */ 1421 1422 extern unsigned short nsys_rtp_port; /* actual rtp port */ 1423 extern unsigned short nsys_rtcp_port; /* actual rtcp port */ 1424 1425 extern unsigned long nsys_rtp_cseq; /* rtp cseq number */ 1426 extern unsigned long nsys_rtcp_cseq; /* rtcp cseq number */ 1427 1428 /*************************/ 1429 /* rtp and rtcp: packets */ 1430 /*************************/ 1431 1432 extern unsigned char nsys_netout_rtp_packet[]; /* rtp packet out */ 1433 1434 /* rtcp packets and lengths */ 1435 1436 extern unsigned char * nsys_netout_rtcp_packet_bye; 1437 extern unsigned char * nsys_netout_rtcp_packet_rrempty; 1438 extern unsigned char * nsys_netout_rtcp_packet_rr; 1439 extern unsigned char * nsys_netout_rtcp_packet_srempty; 1440 extern unsigned char * nsys_netout_rtcp_packet_sr; 1441 1442 extern int nsys_netout_rtcp_len_bye; 1443 extern int nsys_netout_rtcp_len_rrempty; 1444 extern int nsys_netout_rtcp_len_rr; 1445 extern int nsys_netout_rtcp_len_srempty; 1446 extern int nsys_netout_rtcp_len_sr; 1447 1448 extern char * nsys_sdes_typename[]; /* rtcp debug array */ 1449 1450 extern unsigned long nsys_netout_seqnum; /* rtp output sequence number */ 1451 extern unsigned long nsys_netout_tstamp; /* rtp output timestamp */ 1452 extern unsigned char nsys_netout_markbit; /* for setting markerbit */ 1453 1454 /************************/ 1455 /* rtp payload support */ 1456 /************************/ 1457 1458 typedef struct nsys_payinfo { 1459 1460 int pindex; /* index into nsys_payload_types */ 1461 unsigned char ptype; /* RTP payload number */ 1462 char name[32]; /* name of payload */ 1463 int srate; /* audio sample rate */ 1464 1465 } nsys_payinfo; 1466 1467 extern struct nsys_payinfo nsys_payload_types[]; 1468 1469 /**************/ 1470 /* rtcp state */ 1471 /**************/ 1472 1473 extern int nsys_sent_last; /* a packet was sent last RTCP period */ 1474 extern int nsys_sent_this; /* a packet was sent this RTCP period */ 1475 1476 extern unsigned long nsys_sent_packets; /* number of packets sent */ 1477 extern unsigned long nsys_sent_octets; /* number of octets sent */ 1478 1479 extern time_t nsys_nexttime; /* time for next RTCP check */ 1480 extern int nsys_rtcp_ex; /* status flags to check at RTCP time */ 1481 1482 /******************/ 1483 /* identification */ 1484 /******************/ 1485 1486 extern unsigned long nsys_myssrc; /* SSRC -- hostorder */ 1487 extern unsigned long nsys_myssrc_net; /* SSRC -- netorder */ 1488 1489 extern char * nsys_sessionname; 1490 extern char * nsys_sessionkey; 1491 1492 extern unsigned char nsys_keydigest[]; /* digested key */ 1493 extern unsigned char nsys_session_base64[]; /* signed session name */ 1494 extern int nsys_msession; /* mirror session flag */ 1495 extern int nsys_msessionmirror; /* mirror in mirror session */ 1496 1497 extern int nsys_feclevel; 1498 extern int nsys_lateplay; 1499 extern float nsys_latetime; 1500 1501 extern char nsys_clientname[]; 1502 extern char nsys_clientip[]; 1503 extern char * nsys_username; 1504 1505 extern char nsys_cname[]; 1506 extern unsigned char nsys_cname_len; 1507 1508 extern int nsys_powerup_mset; 1509 1510 /***********/ 1511 /* logging */ 1512 /***********/ 1513 1514 extern int nsys_stderr_size; 1515 1516 /*********************/ 1517 /* MIDI input buffer */ 1518 /*********************/ 1519 1520 extern unsigned char nsys_buff[]; 1521 extern long nsys_bufflen; 1522 extern long nsys_buffcnt; 1523 1524 /*~~~~~~~~~~~~~~~~~~~~~~~~*/ 1525 /* rtp-midi: sender state */ 1526 /*________________________*/ 1527 1528 /*************************/ 1529 /* command section flags */ 1530 /*************************/ 1531 1532 extern unsigned char nsys_netout_sm_header; 1533 1534 /*************************/ 1535 /* checkpoint management */ 1536 /*************************/ 1537 1538 extern unsigned long nsys_netout_jsend_checkpoint_seqnum; /* current checkpoint */ 1539 extern unsigned long nsys_netout_jsend_checkpoint_changed; /* 1 if changed */ 1540 1541 /*********************/ 1542 /* S-list management */ 1543 /*********************/ 1544 1545 extern unsigned char * nsys_netout_jsend_slist[]; 1546 extern int nsys_netout_jsend_slist_size; 1547 1548 /*******************************/ 1549 /* guard journal state machine */ 1550 /*******************************/ 1551 1552 extern int nsys_netout_jsend_guard_send; /* flag variable: send guard packet */ 1553 extern int nsys_netout_jsend_guard_time; /* guard packet timer state */ 1554 extern int nsys_netout_jsend_guard_next; /* reload value for timer */ 1555 extern int nsys_netout_jsend_guard_ontime; /* minimum delay time for noteon */ 1556 extern int nsys_netout_jsend_guard_mintime; /* minimum delay time for (!noteon) */ 1557 extern int nsys_netout_jsend_guard_maxtime; /* maximum delay time */ 1558 1559 /***************************/ 1560 /* recovery journal header */ 1561 /***************************/ 1562 1563 extern unsigned char nsys_netout_jsend_header[]; /* journal header */ 1564 1565 /**************************/ 1566 /* channel journal record */ 1567 /**************************/ 1568 1569 extern unsigned char nsys_netout_jsend_channel[]; 1570 extern unsigned char nsys_netout_jsend_channel_size; 1571 1572 /******************************************/ 1573 /* structure holding sender channel state */ 1574 /******************************************/ 1575 1576 typedef struct nsys_netout_jsend_state { 1577 1578 unsigned char chan; /* MIDI channel */ 1579 unsigned short clen; /* first two bytes of cheader */ 1580 1581 /* most recent MIDI commands, used for new source init */ 1582 1583 unsigned char history_active; /* flag for channel activity */ 1584 unsigned char history_cc_bank_msb; /* current cc values */ 1585 unsigned char history_cc_bank_lsb; 1586 unsigned char history_cc_modwheel; 1587 unsigned char history_cc_volume; 1588 1589 unsigned char history_program; /* last program change */ 1590 unsigned char history_program_bank_msb; 1591 unsigned char history_program_bank_lsb; 1592 1593 /* sequence numbers -- 0 or highest seqnum */ 1594 1595 unsigned long cheader_seqnum; 1596 unsigned long chapterp_seqnum; 1597 unsigned long chapterc_seqnum; 1598 unsigned long chapterc_seqarray[NSYS_SM_CC_ARRAYSIZE]; 1599 unsigned long chapterm_seqnum; 1600 unsigned long chapterm_seqarray[NSYS_SM_CM_ARRAYSIZE]; 1601 unsigned long chapterm_dummy_seqnum; 1602 unsigned long chapterw_seqnum; 1603 unsigned long chaptern_seqnum; 1604 unsigned long chaptern_seqarray[NSYS_SM_CN_ARRAYSIZE]; 1605 unsigned long chaptere_seqnum; 1606 unsigned long chapterer_seqarray[NSYS_SM_CE_ARRAYSIZE]; 1607 unsigned long chapterev_seqarray[NSYS_SM_CE_ARRAYSIZE]; 1608 unsigned long chaptert_seqnum; 1609 unsigned long chaptera_seqnum; 1610 unsigned long chaptera_seqarray[NSYS_SM_CA_ARRAYSIZE]; 1611 1612 /* sender state for chapter c */ 1613 1614 unsigned long chapterc_logptr[NSYS_SM_CC_ARRAYSIZE]; /* log positions */ 1615 int chapterc_sset; /* S bit indicators */ 1616 1617 unsigned char chapterc_sustain; /* ALT state holders */ 1618 unsigned char chapterc_allsound; 1619 unsigned char chapterc_rac; 1620 unsigned char chapterc_allnotes; 1621 unsigned char chapterc_omni_off; 1622 unsigned char chapterc_omni_on; 1623 unsigned char chapterc_monomode; 1624 unsigned char chapterc_polymode; 1625 1626 /* sender state for chapter m */ 1627 1628 unsigned long chapterm_logptr[NSYS_SM_CM_ARRAYSIZE]; /* log positions */ 1629 unsigned long chapterm_dummy_logptr; 1630 int chapterm_sset; /* S bit indicators */ 1631 1632 unsigned char chapterm_state; /* state machine */ 1633 unsigned char chapterm_rpn_msb; 1634 unsigned char chapterm_rpn_lsb; 1635 unsigned char chapterm_nrpn_msb; 1636 unsigned char chapterm_nrpn_lsb; 1637 1638 short chapterm_cbutton[NSYS_SM_CM_ARRAYSIZE]; /* C-active button count */ 1639 1640 /* sender state for chapter n */ 1641 1642 unsigned char chapterb_low; 1643 unsigned char chapterb_high; 1644 unsigned long chaptern_logptr[NSYS_SM_CN_ARRAYSIZE]; /* note log position */ 1645 unsigned long chaptern_timer[NSYS_SM_CN_ARRAYSIZE]; /* Y timer values */ 1646 unsigned long chaptern_timernum; /* number of values */ 1647 int chaptern_sset; /* S bit indicators */ 1648 1649 /* sender state for chapter e */ 1650 1651 unsigned char chaptere_ref[NSYS_SM_CE_ARRAYSIZE]; /* reference count */ 1652 unsigned long chapterer_logptr[NSYS_SM_CE_ARRAYSIZE]; /* ref log positions */ 1653 unsigned long chapterev_logptr[NSYS_SM_CE_ARRAYSIZE]; /* off vel positions */ 1654 int chaptere_sset; /* S bit indicator */ 1655 1656 /* sender state for chapter a */ 1657 1658 unsigned long chaptera_logptr[NSYS_SM_CA_ARRAYSIZE]; /* log positions */ 1659 int chaptera_sset; /* S bit indicators */ 1660 1661 /* sizes for dynamic chapters */ 1662 1663 int chapterc_size; /* chapter c */ 1664 int chapterm_size; /* chapter m -- header */ 1665 int chapterl_size; /* chapter m -- loglist */ 1666 int chaptern_size; /* chapter n */ 1667 int chapterb_size; /* chapter n - bitfields */ 1668 int chaptere_size; /* chapter e - header + ref log array */ 1669 int chaptera_size; /* chapter a */ 1670 1671 /* holds current packet bytes */ 1672 1673 unsigned char cheader[NSYS_SM_CH_SIZE]; /* chapter header */ 1674 unsigned char chapterp[NSYS_SM_CP_SIZE]; /* chapter p */ 1675 unsigned char chapterc[NSYS_SM_CC_SIZE]; /* chapter c */ 1676 unsigned char chapterm[NSYS_SM_CM_HDRMAXSIZE]; /* chapter m */ 1677 unsigned char chapterl[NSYS_SM_CM_LISTMAXSIZE]; /* chapter m - loglist */ 1678 unsigned char chapterw[NSYS_SM_CW_SIZE]; /* chapter w */ 1679 unsigned char chaptern[NSYS_SM_CN_SIZE]; /* chapter n */ 1680 unsigned char chapterb[NSYS_SM_CB_SIZE]; /* chapter n - bfields */ 1681 unsigned char chaptere[NSYS_SM_CE_SIZE]; /* chapter e */ 1682 unsigned char chaptert[NSYS_SM_CT_SIZE]; /* chapter t */ 1683 unsigned char chaptera[NSYS_SM_CA_SIZE]; /* chapter a */ 1684 1685 } nsys_netout_jsend_state; 1686 1687 extern nsys_netout_jsend_state nsys_netout_jsend[]; 1688 1689 /***********************************************/ 1690 /* structure holding a chapter x stack element */ 1691 /***********************************************/ 1692 1693 typedef struct nsys_netout_jsend_xstack_element { 1694 1695 int size; 1696 int index; /* stack position */ 1697 unsigned long seqnum; 1698 struct nsys_netout_jsend_xstack_element ** cmdptr; /* command pointer */ 1699 1700 struct nsys_netout_jsend_xstack_element * next; 1701 1702 unsigned char log[NSYS_SM_CX_SIZE_MAXLOG]; 1703 1704 } nsys_netout_jsend_xstack_element; 1705 1706 extern nsys_netout_jsend_xstack_element nsys_netout_jsend_xpile[]; /* element array */ 1707 extern nsys_netout_jsend_xstack_element * nsys_netout_jsend_xstackfree; /* freelist */ 1708 1709 /*****************************************/ 1710 /* structure holding sender system state */ 1711 /*****************************************/ 1712 1713 typedef struct nsys_netout_jsend_system_state { 1714 1715 unsigned short slen; /* value of LENGTH header field */ 1716 1717 /* sequence numbers -- 0 or highest seqnum */ 1718 1719 unsigned long sheader_seqnum; 1720 unsigned long chapterd_seqnum; 1721 unsigned long chapterd_reset_seqnum; 1722 unsigned long chapterd_tune_seqnum; 1723 unsigned long chapterd_song_seqnum; 1724 unsigned long chapterd_scj_seqnum; 1725 unsigned long chapterd_sck_seqnum; 1726 unsigned long chapterd_rty_seqnum; 1727 unsigned long chapterd_rtz_seqnum; 1728 unsigned long chapterv_seqnum; 1729 unsigned long chapterq_seqnum; 1730 unsigned long chapterf_seqnum; 1731 unsigned long chapterfc_seqnum; 1732 unsigned long chapterx_seqnum; 1733 1734 /* sizes for dynamic chapters */ 1735 1736 int chapterd_front_size; 1737 int chapterd_scj_size; 1738 int chapterd_sck_size; 1739 int chapterq_size; 1740 int chapterf_size; 1741 1742 /* state for Chapter D (Simple System Commands) */ 1743 1744 unsigned char chapterd_reset; 1745 unsigned char chapterd_tune; 1746 unsigned char chapterd_song; 1747 1748 /* state for Chapter F (MIDI Time Code) */ 1749 1750 unsigned char chapterf_point; 1751 1752 /* state for Chapter X (SysEx) */ 1753 1754 int chapterx_stacklen; /* number of logs in stack */ 1755 1756 nsys_netout_jsend_xstack_element * chapterx_gmreset_off; /* points into stack */ 1757 nsys_netout_jsend_xstack_element * chapterx_gmreset_on; 1758 nsys_netout_jsend_xstack_element * chapterx_mvolume; 1759 1760 unsigned char chapterx_mvolume_count; /* session history counts */ 1761 unsigned char chapterx_gmreset_off_count; 1762 unsigned char chapterx_gmreset_on_count; 1763 1764 /* holds current packet bytes */ 1765 1766 unsigned char sheader[NSYS_SM_SH_SIZE]; /* chapter header */ 1767 unsigned char chapterd_front[NSYS_SM_CD_FRONT_MAXSIZE]; /* chapter d (front) */ 1768 unsigned char chapterd_scj[NSYS_SM_CD_COMMON_SIZE]; /* chapter d (common J) */ 1769 unsigned char chapterd_sck[NSYS_SM_CD_COMMON_SIZE]; /* chapter d (common K) */ 1770 unsigned char chapterd_rty[NSYS_SM_CD_REALTIME_SIZE]; /* chapter d (realtime Y) */ 1771 unsigned char chapterd_rtz[NSYS_SM_CD_REALTIME_SIZE]; /* chapter d (realtime Z) */ 1772 unsigned char chapterv[NSYS_SM_CV_SIZE]; /* chapter v */ 1773 unsigned char chapterq[NSYS_SM_CQ_MAXSIZE]; /* chapter q */ 1774 unsigned char chapterf[NSYS_SM_CF_MAXSIZE]; /* chapter f */ 1775 nsys_netout_jsend_xstack_element * chapterx_stack[NSYS_SM_CX_MAXSLOTS]; /* ch x */ 1776 1777 } nsys_netout_jsend_system_state; 1778 1779 extern nsys_netout_jsend_system_state nsys_netout_jsend_system; 1780 1781 /********************************************/ 1782 /* structure holding receiver channel state */ 1783 /********************************************/ 1784 1785 typedef struct nsys_netout_jrecv_state { 1786 1787 /* chapter p */ 1788 1789 unsigned char chapterp_program; 1790 unsigned char chapterp_bank_msb; 1791 unsigned char chapterp_bank_lsb; 1792 1793 /* chapter c */ 1794 1795 unsigned char chapterc_value[NSYS_SM_CC_ARRAYSIZE]; 1796 1797 /* chapter m */ 1798 1799 unsigned char chapterm_value_lsb[NSYS_SM_CM_ARRAYSIZE]; 1800 unsigned char chapterm_value_msb[NSYS_SM_CM_ARRAYSIZE]; 1801 short chapterm_cbutton[NSYS_SM_CM_ARRAYSIZE]; 1802 1803 unsigned char chapterm_state; /* state machine */ 1804 unsigned char chapterm_rpn_msb; 1805 unsigned char chapterm_rpn_lsb; 1806 unsigned char chapterm_nrpn_msb; 1807 unsigned char chapterm_nrpn_lsb; 1808 1809 /* chapter w */ 1810 1811 unsigned char chapterw_first; 1812 unsigned char chapterw_second; 1813 1814 /* chapter n */ 1815 1816 unsigned char chaptern_ref[NSYS_SM_CN_ARRAYSIZE]; 1817 unsigned char chaptern_vel[NSYS_SM_CN_ARRAYSIZE]; 1818 unsigned long chaptern_tstamp[NSYS_SM_CN_ARRAYSIZE]; 1819 unsigned long chaptern_extseq[NSYS_SM_CN_ARRAYSIZE]; 1820 1821 /* chapter t */ 1822 1823 unsigned char chaptert_pressure; 1824 1825 /* chapter a */ 1826 1827 unsigned char chaptera_pressure[NSYS_SM_CA_ARRAYSIZE]; 1828 1829 /* navigation */ 1830 1831 unsigned char chan; 1832 struct nsys_netout_jrecv_state * next; 1833 1834 } nsys_netout_jrecv_state; 1835 1836 extern nsys_netout_jrecv_state * nsys_recvfree; /* channel free list */ 1837 1838 /*******************************************/ 1839 /* structure holding receiver system state */ 1840 /*******************************************/ 1841 1842 typedef struct nsys_netout_jrecv_system_state { 1843 1844 /* chapter d */ 1845 1846 unsigned char chapterd_reset; 1847 unsigned char chapterd_tune; 1848 unsigned char chapterd_song; 1849 unsigned char chapterd_scj_count; 1850 unsigned char chapterd_scj_data1; 1851 unsigned char chapterd_scj_data2; 1852 unsigned char chapterd_sck_count; 1853 unsigned char chapterd_sck_data1; 1854 unsigned char chapterd_sck_data2; 1855 unsigned char chapterd_rty; 1856 unsigned char chapterd_rtz; 1857 1858 /* chapter v */ 1859 1860 unsigned char chapterv_count; 1861 1862 /* chapter q */ 1863 1864 unsigned char chapterq_shadow[NSYS_SM_CQ_MAXSIZE]; 1865 1866 /* chapter f */ 1867 1868 unsigned char chapterf_has_complete; 1869 unsigned char chapterf_quarter; 1870 unsigned char chapterf_has_partial; 1871 unsigned char chapterf_direction; 1872 unsigned char chapterf_point; 1873 1874 unsigned char chapterf_complete[NSYS_SM_CF_SIZE_COMPLETE]; 1875 unsigned char chapterf_partial[NSYS_SM_CF_SIZE_PARTIAL]; 1876 1877 /* chapter x */ 1878 1879 unsigned char chapterx_gmreset; 1880 unsigned char chapterx_gmreset_off_count; 1881 unsigned char chapterx_gmreset_on_count; 1882 1883 unsigned char chapterx_mvolume_lsb; 1884 unsigned char chapterx_mvolume_msb; 1885 1886 /* navigation */ 1887 1888 struct nsys_netout_jrecv_system_state * next; 1889 1890 } nsys_netout_jrecv_system_state; 1891 1892 extern nsys_netout_jrecv_system_state * nsys_recvsysfree; /* system free list */ 1893 1894 /****************************/ 1895 /* supported SysEx commands */ 1896 /****************************/ 1897 1898 extern unsigned char nsys_netout_sysconst_manuex[]; 1899 extern unsigned char nsys_netout_sysconst_mvolume[]; 1900 extern unsigned char nsys_netout_sysconst_gmreset[]; 1901 1902 /*******/ 1903 /* SIP */ 1904 /*******/ 1905 1906 extern unsigned char nsys_rtp_invite[]; 1907 extern unsigned char nsys_rtcp_invite[]; 1908 1909 extern int nsys_rtp_sipretry; /* sip server retry counter */ 1910 extern int nsys_rtcp_sipretry; 1911 1912 extern int nsys_rtp_authretry; /* reauthorization counter */ 1913 extern int nsys_rtcp_authretry; 1914 1915 extern struct sockaddr_in nsys_sip_rtp_addr; /* current SIP RTP channel */ 1916 extern char nsys_sip_rtp_ip[]; 1917 extern unsigned long nsys_sip_rtp_inet_addr; 1918 extern unsigned short nsys_sip_rtp_port; 1919 extern unsigned short nsys_sip_rtp_sin_port; 1920 1921 extern struct sockaddr_in nsys_sip_rtcp_addr; /* current SIP RTCP channel */ 1922 extern char nsys_sip_rtcp_ip[]; 1923 extern unsigned long nsys_sip_rtcp_inet_addr; 1924 extern unsigned short nsys_sip_rtcp_port; 1925 extern unsigned short nsys_sip_rtcp_sin_port; 1926 1927 extern int nsys_graceful_exit; /* requests termination */ 1928 1929 extern unsigned char nsys_rtp_info[]; /* SIP INFO packets */ 1930 extern unsigned char nsys_rtcp_info[]; 1931 1932 extern int nsys_behind_nat; /* 1 if behind a nat */ 1933 extern int nsys_sipinfo_count; /* INFO sending timer */ 1934 extern int nsys_sipinfo_toggle; /* RTP/RTCP toggle */ 1935 1936 /***************/ 1937 /* SSRC stack */ 1938 /***************/ 1939 1940 typedef struct nsys_source { 1941 1942 /* information */ 1943 1944 int mset; /* MIDI extchan set */ 1945 unsigned long ssrc; /* RTP SSRC number */ 1946 unsigned long birthtime; /* Time SSRC was born (UNIX) */ 1947 1948 unsigned long siptime; /* SIP INVITE sessiontime (UNIX) */ 1949 struct sockaddr_in * sdp_addr; /* IP/port in SDP packet, unchanged */ 1950 1951 struct sockaddr_in * rtp_addr; /* RTP IP/port of source */ 1952 struct sockaddr_in * alt_rtp_addr; /* RTP IP/port of NATing */ 1953 1954 struct sockaddr_in * rtcp_addr; /* RTCP IP/port of source */ 1955 struct sockaddr_in * alt_rtcp_addr; /* RTCP IP/port of NATing */ 1956 1957 unsigned char ptype; /* payload type to send/recv */ 1958 int pindex; /* index into nsys_payload_types[] */ 1959 int srate; /* SDP-assigned srate */ 1960 1961 /* navigation */ 1962 1963 struct nsys_source * xtra; /* if hash clashes */ 1964 struct nsys_source * prev; /* doubly-linked list */ 1965 struct nsys_source * next; 1966 1967 /* reception statistics */ 1968 1969 unsigned long received; /* total num packets received */ 1970 unsigned long received_prior; /* total at last SR/RR */ 1971 unsigned long expected_prior; /* total expected at last SR/RR */ 1972 1973 unsigned long base_seq; /* initial extended seq num */ 1974 unsigned long hi_lobits; /* highest seq num low 16b */ 1975 unsigned long hi_ext; /* highest extended seq num */ 1976 1977 /* rtcp items */ 1978 1979 int j_delta; /* state variable for jitter */ 1980 unsigned long jitter; /* current jitter value */ 1981 unsigned char lsr[4]; /* last SR timestamp received */ 1982 struct timeval arrival; /* arrival time of last SR */ 1983 time_t expire_rtcp; /* time to expire ssrc entry */ 1984 char * cname; /* canonical name */ 1985 unsigned long rtcp_received; /* for DoS detection */ 1986 1987 /* time model */ 1988 1989 int ontime; /* flags on-time RTP packets */ 1990 unsigned long tm_convert; /* local/remote time offset */ 1991 unsigned long tm_margin; /* maximum lateness allowed */ 1992 unsigned long tm_lateflag; /* congestion detection flag */ 1993 unsigned long tm_latetime; /* tstamp of first late packet */ 1994 1995 #if (NSYS_LATENOTES_DEBUG == NSYS_LATENOTES_DEBUG_ON) 1996 unsigned long tm_first; /* temporary for printfs */ 1997 FILE * tm_fd; /* file pointer for dat files */ 1998 #endif 1999 2000 /* journal items */ 2001 2002 unsigned long last_hiseq_rec; /* RTCP extended sequence number */ 2003 unsigned long last_hiseq_ext; /* local-adjusted RTCP ext seq num */ 2004 2005 struct nsys_netout_jrecv_state 2006 * jrecv[CSYS_MIDI_NUMCHAN]; /* reciever channel journal state */ 2007 2008 nsys_netout_jrecv_system_state * jrecvsys; /* receiver system state */ 2009 2010 } nsys_source; 2011 2012 extern struct nsys_source * nsys_srcfree; /* mset ssrc tokens */ 2013 extern struct nsys_source * nsys_ssrc[]; /* SSRC hash table */ 2014 extern struct nsys_source * nsys_srcroot; /* points into nsys_ssrc */ 2015 2016 2017 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ 2018 /* Macros */ 2019 /*________________________________________________________________________*/ 2020 2021 2022 /******************/ 2023 /* error-checking */ 2024 /******************/ 2025 2026 #define NSYS_ERROR_RETURN(x) do {\ 2027 nsys_stderr_size+=fprintf(stderr, " Error: %s.\n", x);\ 2028 nsys_stderr_size+=fprintf(stderr, " Errno Message: %s\n\n", strerror(errno));\ 2029 return NSYS_ERROR; } while (0) 2030 2031 #define NSYS_ERROR_TERMINATE(x) do {\ 2032 nsys_stderr_size+=fprintf(stderr, " Runtime Errno Message: %s\n", strerror(errno));\ 2033 epr(0,NULL,NULL, "Network error -- " x );} while (0) 2034 2035 2036 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ 2037 /* Function Externs */ 2038 /*________________________________________________________________________*/ 2039 2040 /******************/ 2041 /* error checking */ 2042 /******************/ 2043 2044 extern void epr(int linenum, char * filename, char * token, char * message); 2045 2046 /****************/ 2047 /* net_siplib.c */ 2048 /****************/ 2049 2050 extern int nsys_initsip(void); 2051 extern void nsys_netin_reply(int fd, struct sockaddr_in * addr, 2052 unsigned char * packet, unsigned short status); 2053 2054 extern void nsys_netin_invite(int fd, struct sockaddr_in * addr, 2055 unsigned char * packet); 2056 2057 extern void nsys_createsip(int fd, char * method, unsigned char * sip, 2058 char * natline, char * nonce); 2059 extern void nsys_sendsip(int fd, struct sockaddr_in * addr, 2060 unsigned char * sip); 2061 2062 extern unsigned char * nsys_netin_readmethod(int fd, struct sockaddr_in * addr, 2063 unsigned char * packet); 2064 extern void nsys_netin_ack(int fd, unsigned char * reply, 2065 unsigned long callid, unsigned long cseq); 2066 extern int nsys_netin_replyparse(int fd, unsigned char * packet, 2067 char *nonce, char * natline, 2068 unsigned long * callid, unsigned long * cseq); 2069 extern void nsys_netin_redirect(int fd, unsigned char * packet, 2070 unsigned short status); 2071 2072 extern int nsys_netin_sipaddr(int fd, char * ip, unsigned short port); 2073 extern int nsys_netin_siporigin(int fd, struct sockaddr_in * addr); 2074 extern int nsys_netin_make_marray(struct nsys_payinfo ** marray, char * media); 2075 extern int nsys_netin_set_marray(char * line, struct nsys_payinfo marray[], 2076 int mlen); 2077 2078 extern int nsys_netin_payvalid(struct nsys_payinfo marray[], int mlen, int fd); 2079 extern void nsys_netin_payset(struct nsys_source * sptr, struct nsys_payinfo marray[], 2080 int mlen); 2081 extern int nsys_netin_noreplay(char * ip, unsigned short port, 2082 unsigned long sdp_time); 2083 extern void nsys_sip_shutdown(void); 2084 2085 /****************/ 2086 /* net_rtplib.c */ 2087 /****************/ 2088 2089 extern int nsys_setup(int block); 2090 extern void nsys_shutdown(void); 2091 2092 extern nsys_source * nsys_netin_addsrc(int fd, long ssrc, 2093 char * ip, unsigned short port); 2094 extern int nsys_netin_rtpstats(nsys_source * sptr, unsigned char * packet); 2095 extern void nsys_warning(int level, char * message); 2096 extern void nsys_terminate_error(char * message); 2097 extern void nsys_status(nsys_source * sptr, char * message); 2098 extern int nsys_netin_ptypevalid(unsigned char ptype); 2099 extern void nsys_netin_ptypeset(struct nsys_source * sptr, unsigned char ptype); 2100 extern nsys_netout_jrecv_state * nsys_netin_newrecv(unsigned char chan); 2101 extern nsys_netout_jrecv_system_state * nsys_netin_newrecvsys(void); 2102 extern char * nsys_find_clientip(char * ip); 2103 2104 /****************/ 2105 /* net_rtcplib.c */ 2106 /****************/ 2107 2108 extern nsys_source * nsys_netin_rtcp(unsigned char * packet, int len, 2109 struct sockaddr_in * ipaddr); 2110 extern int nsys_make_rtcp(void); 2111 extern int nsys_make_rtcpbye(void); 2112 extern void nsys_netout_rtcptime(void); 2113 extern void nsys_delete_ssrc(unsigned long ssrc, char * reason); 2114 extern nsys_source * nsys_harvest_ssrc(int fd, struct sockaddr_in * ipaddr); 2115 extern void nsys_late_windowcheck(nsys_source * sptr, unsigned long tstamp); 2116 extern char * nsys_netin_newcname(unsigned char * packet, int len); 2117 extern void nsys_netin_bye(unsigned char * packet, int len); 2118 extern int nsys_netout_excheck(void); 2119 extern void nsys_netout_keepalive(void); 2120 extern void nsys_netin_rtcp_display(unsigned char * packet, int len, 2121 struct timeval * now); 2122 extern void nsys_netout_rtcpreport(void); 2123 extern void nsys_netout_rtcpsend(unsigned char * p, int len); 2124 extern int nsys_netin_clear_mset(unsigned char * buff, long * fill, 2125 long size); 2126 2127 extern void nsys_netout_rtcp_initpackets(void); 2128 extern void nsys_netout_rtcp_initrr(unsigned char * p, int len); 2129 extern void nsys_netout_rtcp_initsr(unsigned char * p, int len); 2130 extern void nsys_netout_rtcp_initsdes(unsigned char * p, int len); 2131 extern void nsys_netout_rtcp_initbye(unsigned char * p); 2132 extern void nsys_netin_rtcp_trunc(int sub); 2133 extern void nsys_netin_latenotes_open(nsys_source * sptr); 2134 2135 /****************/ 2136 /* net_sfront.c */ 2137 /****************/ 2138 2139 extern int nsys_sysex_parse(unsigned char * cmd, unsigned char *ndata, 2140 unsigned char * vdata, unsigned char * sysbuf, 2141 int sysidx); 2142 2143 /***************/ 2144 /* net_jsend.c */ 2145 /***************/ 2146 2147 extern int nsys_netin_journal_create(unsigned char * packet, int len); 2148 2149 extern void nsys_netout_journal_addstate(unsigned char cmd, 2150 unsigned char ndata, 2151 unsigned char vdata); 2152 2153 extern void nsys_netout_journal_addhistory(unsigned char cmd, 2154 unsigned char ndata, 2155 unsigned char vdata); 2156 2157 extern void nsys_netin_journal_trimstate(nsys_source * lptr); 2158 2159 extern void nsys_netout_midistate_init(void); 2160 2161 extern void nsys_netout_guard_tick(void); 2162 2163 extern void nsys_netout_journal_changecheck(void); 2164 2165 extern void nsys_netout_journal_addprogram(nsys_netout_jsend_state * jsend, 2166 unsigned char ndata); 2167 2168 extern void nsys_netout_journal_addcontrol(nsys_netout_jsend_state * jsend, 2169 unsigned char ndata, 2170 unsigned char vdata); 2171 2172 extern void nsys_netout_journal_addparameter(nsys_netout_jsend_state * jsend, 2173 unsigned char ndata, 2174 unsigned char vdata); 2175 2176 extern void nsys_netout_journal_addpwheel(nsys_netout_jsend_state * jsend, 2177 unsigned char ndata, 2178 unsigned char vdata); 2179 2180 extern void nsys_netout_journal_addnoteoff(nsys_netout_jsend_state * jsend, 2181 unsigned char ndata, 2182 unsigned char vdata); 2183 2184 extern void nsys_netout_journal_addnoteon(nsys_netout_jsend_state * jsend, 2185 unsigned char ndata, 2186 unsigned char vdata); 2187 2188 extern void nsys_netout_journal_addnoteon_extras(nsys_netout_jsend_state * jsend, 2189 unsigned char ndata); 2190 2191 extern void nsys_netout_journal_addnoteoff_extras(nsys_netout_jsend_state * jsend, 2192 unsigned char ndata, 2193 unsigned char vdata); 2194 2195 extern void nsys_netout_journal_addctouch(nsys_netout_jsend_state * jsend, 2196 unsigned char ndata); 2197 2198 extern void nsys_netout_journal_addptouch(nsys_netout_jsend_state * jsend, 2199 unsigned char ndata, 2200 unsigned char vdata); 2201 2202 extern void nsys_netout_journal_addsong(unsigned char ndata); 2203 extern void nsys_netout_journal_addtune(void); 2204 extern void nsys_netout_journal_addreset(void); 2205 extern void nsys_netout_journal_addsc(unsigned char cmd, unsigned char ndata, 2206 unsigned char vdata); 2207 extern void nsys_netout_journal_addrt(unsigned char cmd); 2208 2209 extern void nsys_netout_journal_addsense(void); 2210 2211 extern void nsys_netout_journal_addsequence(unsigned char cmd, unsigned char ndata, 2212 unsigned char vdata); 2213 2214 extern void nsys_netout_journal_addtimecode(unsigned char ndata); 2215 2216 extern void nsys_netout_journal_addsysex(unsigned char cmd, unsigned char ndata, 2217 unsigned char vdata); 2218 2219 extern void nsys_netout_journal_trimchapter(nsys_netout_jsend_state * jsend, 2220 int channel); 2221 2222 extern void nsys_netout_journal_trimprogram(nsys_netout_jsend_state * jsend); 2223 2224 extern void nsys_netout_journal_trimallcontrol(nsys_netout_jsend_state * jsend); 2225 2226 extern void nsys_netout_journal_trimpartcontrol(nsys_netout_jsend_state * jsend, 2227 unsigned long minseq); 2228 2229 extern void nsys_netout_journal_trimallparams(nsys_netout_jsend_state * jsend); 2230 2231 extern void nsys_netout_journal_trimpartparams(nsys_netout_jsend_state * jsend, 2232 unsigned long minseq); 2233 2234 extern void nsys_netout_journal_trimpwheel(nsys_netout_jsend_state * jsend); 2235 2236 extern void nsys_netout_journal_trimallnote(nsys_netout_jsend_state * jsend); 2237 2238 extern void nsys_netout_journal_trimpartnote(nsys_netout_jsend_state * jsend, 2239 unsigned long minseq); 2240 2241 extern void nsys_netout_journal_trimallextras(nsys_netout_jsend_state * jsend); 2242 2243 extern void nsys_netout_journal_trimpartextras(nsys_netout_jsend_state * jsend, 2244 unsigned long minseq); 2245 2246 extern void nsys_netout_journal_trimctouch(nsys_netout_jsend_state * jsend); 2247 2248 extern void nsys_netout_journal_trimallptouch(nsys_netout_jsend_state * jsend); 2249 2250 extern void nsys_netout_journal_trimpartptouch(nsys_netout_jsend_state * jsend, 2251 unsigned long minseq); 2252 2253 extern void nsys_netout_journal_trimsystem(void); 2254 extern void nsys_netout_journal_trimsimple(void); 2255 extern void nsys_netout_journal_trimreset(void); 2256 extern void nsys_netout_journal_trimtune(void); 2257 extern void nsys_netout_journal_trimsong(void); 2258 extern void nsys_netout_journal_trimscj(void); 2259 extern void nsys_netout_journal_trimsck(void); 2260 extern void nsys_netout_journal_trimrty(void); 2261 extern void nsys_netout_journal_trimrtz(void); 2262 extern void nsys_netout_journal_trimsense(void); 2263 extern void nsys_netout_journal_trimsequence(void); 2264 extern void nsys_netout_journal_trimtimecode(void); 2265 extern void nsys_netout_journal_trimparttimecode(void); 2266 extern void nsys_netout_journal_trimsysex(void); 2267 extern void nsys_netout_journal_trimpartsysex(unsigned long minseq); 2268 2269 extern void nsys_netout_journal_clear_nactive(nsys_netout_jsend_state * jsend); 2270 2271 extern void nsys_netout_journal_clear_cactive(nsys_netout_jsend_state * jsend); 2272 2273 extern void nsys_netout_journal_clear_active(unsigned char cmd); 2274 2275 extern void nsys_netout_journal_clear_clog(nsys_netout_jsend_state * jsend, 2276 unsigned char number); 2277 2278 /**************/ 2279 /* net_recv.c */ 2280 /**************/ 2281 2282 extern int nsys_netin_journal_recovery(nsys_source * sptr, int rtpcode, 2283 unsigned char * packet, int numbytes, 2284 unsigned char * buff, long * fill, 2285 long size); 2286 2287 extern void nsys_netin_journal_trackstate(nsys_source * sptr, unsigned char cmd, 2288 unsigned char ndata, 2289 unsigned char vdata); 2290 2291 extern int nsys_netin_journal_addcmd_three(nsys_source * sptr, unsigned char * buff, 2292 long * fill, long size, 2293 unsigned char cmd, unsigned char ndata, 2294 unsigned char vdata); 2295 2296 extern int nsys_netin_journal_addcmd_two(nsys_source * sptr, unsigned char * buff, 2297 long * fill, long size, 2298 unsigned char cmd, unsigned char ndata); 2299 2300 extern int nsys_netin_journal_addcmd_one(nsys_source * sptr, unsigned char * buff, 2301 long * fill, long size, unsigned char cmd); 2302 2303 extern int nsys_netin_journal_trans(nsys_source * sptr, unsigned char * buff, 2304 long * fill, long size, unsigned char chan, 2305 int flags, unsigned char msb_num, 2306 unsigned char lsb_num, unsigned char msb_val, 2307 unsigned char lsb_val); 2308 2309 extern int nsys_netin_journal_button_trans(nsys_source * sptr, unsigned char * buff, 2310 long * fill, long size, 2311 unsigned char chan, int flags, 2312 unsigned char msb_num, 2313 unsigned char lsb_num, short count); 2314 2315 extern void nsys_netin_journal_clear_active(unsigned char cmd); 2316 2317 extern int nsys_netin_jrec_program(nsys_source * sptr, unsigned char * p, 2318 nsys_netout_jrecv_state * jrecv, 2319 unsigned char * buff, 2320 long * fill, long size); 2321 2322 extern int nsys_netin_jrec_control(nsys_source * sptr, unsigned char * p, 2323 nsys_netout_jrecv_state * jrecv, short loglen, 2324 unsigned char many, unsigned char * buff, 2325 long * fill, long size); 2326 2327 extern int nsys_netin_jrec_param(nsys_source * sptr, unsigned char * p, 2328 nsys_netout_jrecv_state * jrecv, 2329 short paramlen, unsigned char many, 2330 unsigned char * buff, long * fill, 2331 long size); 2332 2333 extern int nsys_netin_jrec_wheel(nsys_source * sptr, unsigned char * p, 2334 nsys_netout_jrecv_state * jrecv, 2335 unsigned char * buff, 2336 long * fill, long size); 2337 2338 extern int nsys_netin_jrec_notelog(nsys_source * sptr, unsigned char * p, 2339 nsys_netout_jrecv_state * jrecv, 2340 unsigned char many, 2341 short loglen, unsigned char * checkptr, 2342 unsigned char * buff, 2343 long * fill, long size); 2344 2345 extern int nsys_netin_jrec_bitfield(nsys_source * sptr, unsigned char * p, 2346 nsys_netout_jrecv_state * jrecv, 2347 unsigned char low, unsigned char high, 2348 unsigned char * buff, long * fill, 2349 long size); 2350 2351 extern int nsys_netin_jrec_ctouch(nsys_source * sptr, unsigned char * p, 2352 nsys_netout_jrecv_state * jrecv, 2353 unsigned char * buff, 2354 long * fill, long size); 2355 2356 extern int nsys_netin_jrec_ptouch(nsys_source * sptr, unsigned char * p, 2357 nsys_netout_jrecv_state * jrecv, short loglen, 2358 unsigned char many, unsigned char * buff, 2359 long * fill, long size); 2360 2361 extern int nsys_netin_jrec_reset(nsys_source * sptr, unsigned char * ps, 2362 nsys_netout_jrecv_system_state * jrecvsys, 2363 unsigned char * buff, long * fill, long size); 2364 2365 extern int nsys_netin_jrec_tune(nsys_source * sptr, unsigned char * ps, 2366 nsys_netout_jrecv_system_state * jrecvsys, 2367 unsigned char * buff, long * fill, long size); 2368 2369 extern int nsys_netin_jrec_song(nsys_source * sptr, unsigned char * ps, 2370 nsys_netout_jrecv_system_state * jrecvsys, 2371 unsigned char * buff, long * fill, long size); 2372 2373 extern int nsys_netin_jrec_scj(nsys_source * sptr, unsigned char * ps, 2374 nsys_netout_jrecv_system_state * jrecvsys, 2375 unsigned char * buff, long * fill, long size); 2376 2377 extern int nsys_netin_jrec_sck(nsys_source * sptr, unsigned char * ps, 2378 nsys_netout_jrecv_system_state * jrecvsys, 2379 unsigned char * buff, long * fill, long size); 2380 2381 extern int nsys_netin_jrec_rty(nsys_source * sptr, unsigned char * ps, 2382 nsys_netout_jrecv_system_state * jrecvsys, 2383 unsigned char * buff, long * fill, long size); 2384 2385 extern int nsys_netin_jrec_rtz(nsys_source * sptr, unsigned char * ps, 2386 nsys_netout_jrecv_system_state * jrecvsys, 2387 unsigned char * buff, long * fill, long size); 2388 2389 extern int nsys_netin_jrec_sense(nsys_source * sptr, unsigned char * ps, 2390 nsys_netout_jrecv_system_state * jrecvsys, 2391 unsigned char * buff, long * fill, long size); 2392 2393 extern int nsys_netin_jrec_sequence(nsys_source * sptr, unsigned char * ps, 2394 nsys_netout_jrecv_system_state * jrecvsys, 2395 unsigned char * buff, long * fill, long size); 2396 2397 extern int nsys_netin_jrec_timecode(nsys_source * sptr, unsigned char * ps, 2398 nsys_netout_jrecv_system_state * jrecvsys, 2399 unsigned char * buff, long * fill, long size); 2400 2401 extern int nsys_netin_jrec_sysex(nsys_source * sptr, unsigned char * ps, int syslen, 2402 nsys_netout_jrecv_system_state * jrecvsys, 2403 unsigned char * buff, long * fill, long size); 2404 2405 extern void nsys_netin_track_timecode(nsys_netout_jrecv_system_state * jrecvsys, 2406 unsigned char ndata); 2407 2408 /****************/ 2409 /* net_crypto.c */ 2410 /****************/ 2411 2412 extern unsigned char * nsys_md5(unsigned char * digest, unsigned char * text, 2413 int len); 2414 2415 extern char * nsys_hmac_md5(unsigned char* text, int text_len, 2416 unsigned char * keydigest, unsigned char * digest); 2417 2418 extern unsigned char * nsys_digest_base64(unsigned char * output, 2419 unsigned char * input); 2420 2421 extern int nsys_digest_syntaxcheck(char * s); 2422 2423 #endif /* NSYS_NET_INCLUDE */ 2424 2425 /* end Network library -- constants and externs */ 2426 2427