Changeset 1850 for pjproject/trunk/pjnath/src/pjturn-srv/turn.h
- Timestamp:
- Mar 8, 2008 12:54:04 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjnath/src/pjturn-srv/turn.h
r1812 r1850 34 34 #define PJTURN_NO_TIMEOUT ((long)0x7FFFFFFF) 35 35 #define PJTURN_MAX_PKT_LEN 3000 36 #define PJTURN_PERM_TIMEOUT 300 37 #define PJTURN_CHANNEL_TIMEOUT 600 36 38 37 39 /** Transport types */ … … 41 43 }; 42 44 45 /** 46 * Get transport type name string. 47 */ 48 PJ_DECL(const char*) pjturn_tp_type_name(int tp_type); 43 49 44 50 /** … … 55 61 /** Transport/relay address */ 56 62 pj_sockaddr addr; 57 } key; 58 59 /** Pool for this resource. */ 60 pj_pool_t *pool; 61 62 /** Mutex */ 63 pj_lock_t *lock; 63 } hkey; 64 64 65 65 /** Allocation who requested or reserved this resource. */ 66 66 pjturn_allocation *allocation; 67 67 68 /** Time when this resource times out */69 pj_time_val timeout;70 71 68 /** Username used in credential */ 72 69 pj_str_t user; … … 75 72 pj_str_t realm; 76 73 77 /** Transport/relay socket */ 78 pj_sock_t sock; 74 /** Lifetime, in seconds. */ 75 unsigned lifetime; 76 77 /** Relay/allocation expiration time */ 78 pj_time_val expiry; 79 80 /** Timeout timer entry */ 81 pj_timer_entry timer; 82 83 /** Transport. */ 84 struct { 85 /** Transport/relay socket */ 86 pj_sock_t sock; 87 88 /** Transport/relay ioqueue */ 89 pj_ioqueue_key_t *key; 90 91 /** Read operation key. */ 92 pj_ioqueue_op_key_t read_key; 93 94 /** The incoming packet buffer */ 95 char rx_pkt[PJTURN_MAX_PKT_LEN]; 96 97 /** Source address of the packet. */ 98 pj_sockaddr src_addr; 99 100 /** Source address length */ 101 int src_addr_len; 102 103 /** The outgoing packet buffer. This must be 3wbit aligned. */ 104 char tx_pkt[PJTURN_MAX_PKT_LEN+4]; 105 } tp; 79 106 }; 80 107 … … 105 132 106 133 /** Requested IP */ 107 pj_sockaddr addr;134 char addr[PJ_INET6_ADDRSTRLEN]; 108 135 109 136 /** Requested bandwidth */ … … 128 155 { 129 156 /** Hash table key to identify client. */ 130 pjturn_allocation_key key;157 pjturn_allocation_key hkey; 131 158 132 159 /** Pool for this allocation. */ 133 160 pj_pool_t *pool; 134 161 162 /** Object name for logging identification */ 163 char *obj_name; 164 165 /** Client info (IP address and port) */ 166 char info[80]; 167 135 168 /** Mutex */ 136 169 pj_lock_t *lock; … … 148 181 pjturn_relay_res *resv; 149 182 150 }; 183 /** Requested bandwidth */ 184 unsigned bandwidth; 185 186 /** STUN session for this client */ 187 pj_stun_session *sess; 188 189 /** Peer hash table (keyed by peer address) */ 190 pj_hash_table_t *peer_table; 191 192 /** Channel hash table (keyed by channel number) */ 193 pj_hash_table_t *ch_table; 194 }; 195 196 197 /** 198 * This structure describes the hash table key to lookup TURN 199 * permission. 200 */ 201 typedef struct pjturn_permission_key 202 { 203 /** Peer address. */ 204 pj_sockaddr peer_addr; 205 206 } pjturn_permission_key; 151 207 152 208 … … 157 213 { 158 214 /** Hash table key */ 159 struct { 160 /** Transport type. */ 161 pj_uint16_t tp_type; 162 163 /** Transport socket. If TCP is used, the value will be the actual 164 * TCP socket. If UDP is used, the value will be the relay address 165 */ 166 pj_sock_t sock; 167 168 /** Peer address. */ 169 pj_sockaddr peer_addr; 170 } key; 171 172 /** Pool for this permission. */ 173 pj_pool_t *pool; 174 175 /** Mutex */ 176 pj_lock_t *lock; 215 pjturn_permission_key hkey; 216 217 /** Transport socket. If TCP is used, the value will be the actual 218 * TCP socket. If UDP is used, the value will be the relay address 219 */ 220 pj_sock_t sock; 177 221 178 222 /** TURN allocation that owns this permission/channel */ … … 184 228 pj_uint16_t channel; 185 229 186 /** Permission timeout. */ 187 pj_time_val timeout; 188 }; 189 190 /** 191 * Handle incoming packet. 192 */ 193 PJ_DECL(void) pjturn_allocation_on_rx_pkt(pjturn_allocation *alloc, 194 pjturn_pkt *pkt); 195 230 /** Permission expiration time. */ 231 pj_time_val expiry; 232 }; 233 234 /** 235 * Create new allocation. 236 */ 237 PJ_DECL(pj_status_t) pjturn_allocation_create(pjturn_listener *listener, 238 const pj_sockaddr_t *src_addr, 239 unsigned src_addr_len, 240 const pj_stun_msg *msg, 241 const pjturn_allocation_req *req, 242 pjturn_allocation **p_alloc); 243 /** 244 * Destroy allocation. 245 */ 246 PJ_DECL(void) pjturn_allocation_destroy(pjturn_allocation *alloc); 247 248 /** 249 * Create relay. 250 */ 251 PJ_DECL(pj_status_t) pjturn_allocation_create_relay(pjturn_srv *srv, 252 pjturn_allocation *alloc, 253 const pj_stun_msg *msg, 254 const pjturn_allocation_req *req, 255 pjturn_relay_res *relay); 256 257 /** 258 * Handle incoming packet from client. 259 */ 260 PJ_DECL(void) pjturn_allocation_on_rx_client_pkt(pjturn_allocation *alloc, 261 pjturn_pkt *pkt); 196 262 197 263 /****************************************************************************/ … … 251 317 pjturn_listener *listener; 252 318 253 /** Packet buffer . */319 /** Packet buffer (must be 32bit aligned). */ 254 320 pj_uint8_t pkt[PJTURN_MAX_PKT_LEN]; 255 321 … … 358 424 pj_hash_table_t *res; 359 425 360 /** Permission hash table, indexed by transport type, socket handle,361 * and peer address.362 */363 pj_hash_table_t *peer;364 365 426 } tables; 366 427 … … 408 469 409 470 /** 471 * Register an allocation. 472 */ 473 PJ_DECL(pj_status_t) pjturn_srv_register_allocation(pjturn_srv *srv, 474 pjturn_allocation *alloc); 475 476 /** 477 * Unregister an allocation. 478 */ 479 PJ_DECL(pj_status_t) pjturn_srv_unregister_allocation(pjturn_srv *srv, 480 pjturn_allocation *alloc); 481 482 /** 410 483 * This callback is called by UDP listener on incoming packet. 411 484 */
Note: See TracChangeset
for help on using the changeset viewer.