1 /* @(#) option definitions and associated structures for udpxy 2 * 3 * Copyright 2008-2011 Pavel V. Cherenkov (pcherenkov@gmail.com) 4 * 5 * This file is part of udpxy. 6 * 7 * udpxy is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * udpxy is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with udpxy. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 #ifndef UOPT_H_0215082300 22 #define UOPT_H_0215082300 23 24 #include <sys/types.h> 25 #include <stdio.h> 26 #include <time.h> 27 #include <unistd.h> 28 29 #include "udpxy.h" 30 31 static const int MIN_CLIENT_COUNT = 1; 32 static const int MAX_CLIENT_COUNT = 5000; 33 static const int DEFAULT_CLIENT_COUNT = 3; 34 35 static const ssize_t MIN_MCACHE_LEN = 4 * 1024; 36 static const ssize_t MAX_MCACHE_LEN = 2048 * 1024; 37 static const ssize_t DEFAULT_CACHE_LEN = 2 * 1024; 38 static const u_short DEFAULT_MCAST_REFRESH = 0; 39 40 static const ssize_t MIN_SOCKBUF_LEN = (1024 * 64); 41 42 43 /* udpxy options 44 */ 45 struct udpxy_opt { 46 flag_t is_verbose; /* verbose output on/off */ 47 flag_t cl_tpstat; /* client reports throughput stats */ 48 int nice_incr; /* value to increment nice by */ 49 ssize_t rbuf_len; /* size of read buffer */ 50 int rbuf_msgs; /* max msgs in read buffer (-1 = all) */ 51 int max_clients; /* max clients to accept */ 52 u_short mcast_refresh; /* refresh rate (sec) for multicast 53 subscription */ 54 55 time_t rcv_tmout; /* receive (mcast) socket timeout */ 56 time_t dhold_tmout; /* timeout to hold buffered data (milisec) */ 57 58 time_t sr_tmout, /* server READ/RCV timeout (sec) */ 59 sw_tmout; /* server WRITE/SND timeout (sec) */ 60 long ssel_tmout; /* server select/poll timeout (sec) */ 61 int lq_backlog; /* accept queue length for listening socket */ 62 int rcv_lwmark; /* receive low watermark on listening socket */ 63 64 flag_t nosync_sbuf, /* do not alter source-socket's buffer size */ 65 nosync_dbuf; /* do not alter dest-socket's buffer size */ 66 67 char* srcfile; /* file to read (video stream) from */ 68 char* dstfile; /* file to save (video stream) to */ 69 70 char h200_ftr[2048]; /* text to add to HTTP 200 response */ 71 flag_t tcp_nodelay; /* apply TCP_NODELAY option to 72 newly-accepted sockets */ 73 char cnt_type[80]; /* custom HTTP 200 content type */ 74 }; 75 76 77 #ifdef UDPXREC_MOD 78 /* udpxrec options 79 */ 80 struct udpxrec_opt { 81 flag_t is_verbose; /* verbose output on/off */ 82 int nice_incr; /* value to increment nice by */ 83 84 time_t bg_time; /* time to start recording */ 85 time_t end_time; /* time to end recording */ 86 int64_t max_fsize; /* max size of dest file (in bytes) */ 87 ssize_t bufsize; /* size of receiving socket buffer */ 88 int rbuf_msgs; /* max number of messages to save 89 in buffer (-1 = as many as would fit) */ 90 91 /* address of the multicast interface */ 92 char mcast_addr[ IPADDR_STR_SIZE ]; 93 char rec_channel[ IPADDR_STR_SIZE ]; 94 int rec_port; 95 int waitupd_sec; /* update every N seconds while waiting 96 to start recording */ 97 98 time_t rcv_tmout; /* receive (mcast) socket timeout */ 99 time_t sr_tmout, /* server READ/RCV timeout (sec) */ 100 sw_tmout; /* server WRITE/SND timeout (sec) */ 101 102 flag_t nosync_sbuf, /* do not alter source-socket's buffer size */ 103 nosync_dbuf; /* do not alter dest-socket's buffer size */ 104 105 106 char* pidfile; /* file to store app's PID */ 107 char* dstfile; /* file to save (video stream) to */ 108 }; 109 #endif /* UDPXREC_MOD */ 110 111 #ifdef __cplusplus 112 extern "C" { 113 #endif 114 115 /* populate udpxy options with default/initial values 116 */ 117 int 118 init_uopt( struct udpxy_opt* uo ); 119 120 121 /* release udpxy resources allocated for udpxy options 122 */ 123 void 124 free_uopt( struct udpxy_opt* uo ); 125 126 127 #ifdef UDPXREC_MOD 128 /* populate udpxrec options with default/initial values 129 */ 130 int 131 init_recopt( struct udpxrec_opt* ro ); 132 133 134 /* release resources allocated for udpxy options 135 */ 136 void 137 free_recopt( struct udpxrec_opt* ro ); 138 139 /* print udpxrec options to stream 140 */ 141 void 142 fprint_recopt( FILE* stream, struct udpxrec_opt* ro ); 143 144 #endif /* UDPXREC_MOD */ 145 146 /* set verbose output on 147 */ 148 void 149 set_verbose( flag_t* verbose ); 150 151 152 #ifdef __cplusplus 153 } /* extern "C" */ 154 #endif 155 156 #endif /* UOPT_H_0215082300 */ 157 158 /* __EOF__ */ 159 160