Changeset 1913 for pjproject/trunk/pjnath/src/pjturn-srv/turn.h
- Timestamp:
- Apr 9, 2008 9:38:12 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjnath/src/pjturn-srv/turn.h
r1879 r1913 23 23 #include <pjnath.h> 24 24 25 typedef struct pj_turn_relay_res 25 typedef struct pj_turn_relay_res pj_turn_relay_res; 26 26 typedef struct pj_turn_listener pj_turn_listener; 27 typedef struct pj_turn_permission pj_turn_permission; 28 typedef struct pj_turn_allocation pj_turn_allocation; 27 typedef struct pj_turn_transport pj_turn_transport; 28 typedef struct pj_turn_permission pj_turn_permission; 29 typedef struct pj_turn_allocation pj_turn_allocation; 29 30 typedef struct pj_turn_srv pj_turn_srv; 30 31 typedef struct pj_turn_pkt pj_turn_pkt; … … 133 134 pj_lock_t *lock; 134 135 135 /** TURN listener. */136 pj_turn_ listener *listener;137 138 /** Client socket, if connection to client is using TCP. */139 pj_ sock_t clt_sock;136 /** Server instance. */ 137 pj_turn_srv *server; 138 139 /** Transport to send/receive packets to/from client. */ 140 pj_turn_transport *transport; 140 141 141 142 /** The relay resource for this allocation. */ … … 181 182 /** Hash table key */ 182 183 pj_turn_permission_key hkey; 183 184 /** Transport socket. If TCP is used, the value will be the actual185 * TCP socket. If UDP is used, the value will be the relay address186 */187 pj_sock_t sock;188 184 189 185 /** TURN allocation that owns this permission/channel */ … … 202 198 * Create new allocation. 203 199 */ 204 PJ_DECL(pj_status_t) pj_turn_allocation_create(pj_turn_ listener *listener,205 const pj_sockaddr_t *src_addr,206 unsigned src_addr_len,207 const pj_stun_rx_data *rdata,208 pj_stun_session *srv_sess,209 pj_turn_allocation **p_alloc);200 PJ_DECL(pj_status_t) pj_turn_allocation_create(pj_turn_transport *transport, 201 const pj_sockaddr_t *src_addr, 202 unsigned src_addr_len, 203 const pj_stun_rx_data *rdata, 204 pj_stun_session *srv_sess, 205 pj_turn_allocation **p_alloc); 210 206 /** 211 207 * Destroy allocation. … … 218 214 */ 219 215 PJ_DECL(void) pj_turn_allocation_on_rx_client_pkt(pj_turn_allocation *alloc, 220 pj_turn_pkt *pkt); 216 pj_turn_pkt *pkt); 217 218 /** 219 * Handle transport closure. 220 */ 221 PJ_DECL(void) pj_turn_allocation_on_transport_closed(pj_turn_allocation *alloc, 222 pj_turn_transport *tp); 221 223 222 224 /****************************************************************************/ … … 258 260 unsigned flags; 259 261 262 /** Destroy handler */ 263 pj_status_t (*destroy)(pj_turn_listener*); 264 }; 265 266 267 /** 268 * This structure describes TURN transport socket which is used to send and 269 * receive packets towards client. 270 */ 271 struct pj_turn_transport 272 { 273 /** Object name/identification */ 274 char *obj_name; 275 276 /** Slightly longer info about this listener */ 277 char *info; 278 279 /** Listener instance */ 280 pj_turn_listener *listener; 281 260 282 /** Sendto handler */ 261 pj_status_t (*sendto)(pj_turn_ listener *listener,283 pj_status_t (*sendto)(pj_turn_transport *tp, 262 284 const void *packet, 263 285 pj_size_t size, … … 266 288 int addr_len); 267 289 268 /** Destroy handler */ 269 pj_status_t (*destroy)(pj_turn_listener*); 290 /** Addref handler */ 291 void (*add_ref)(pj_turn_transport *tp, 292 pj_turn_allocation *alloc); 293 294 /** Decref handler */ 295 void (*dec_ref)(pj_turn_transport *tp, 296 pj_turn_allocation *alloc); 297 270 298 }; 271 299 … … 279 307 pj_pool_t *pool; 280 308 281 /** Listener that owns this. */282 pj_turn_ listener *listener;309 /** Transport where the packet was received. */ 310 pj_turn_transport *transport; 283 311 284 312 /** Packet buffer (must be 32bit aligned). */ … … 300 328 301 329 /** 302 * Create a newlistener on the specified port.330 * Create a UDP listener on the specified port. 303 331 */ 304 332 PJ_DECL(pj_status_t) pj_turn_listener_create_udp(pj_turn_srv *srv, 305 int af, 306 const pj_str_t *bound_addr, 307 unsigned port, 308 unsigned concurrency_cnt, 309 unsigned flags, 310 pj_turn_listener **p_listener); 311 312 /** 313 * Send packet with this listener. 314 */ 315 PJ_DECL(pj_status_t) pj_turn_listener_sendto(pj_turn_listener *listener, 316 const void *packet, 317 pj_size_t size, 318 unsigned flag, 319 const pj_sockaddr_t *addr, 320 int addr_len); 333 int af, 334 const pj_str_t *bound_addr, 335 unsigned port, 336 unsigned concurrency_cnt, 337 unsigned flags, 338 pj_turn_listener **p_lis); 339 340 /** 341 * Create a TCP listener on the specified port. 342 */ 343 PJ_DECL(pj_status_t) pj_turn_listener_create_tcp(pj_turn_srv *srv, 344 int af, 345 const pj_str_t *bound_addr, 346 unsigned port, 347 unsigned concurrency_cnt, 348 unsigned flags, 349 pj_turn_listener **p_lis); 321 350 322 351 /** … … 324 353 */ 325 354 PJ_DECL(pj_status_t) pj_turn_listener_destroy(pj_turn_listener *listener); 355 356 357 /** 358 * Add a reference to a transport. 359 */ 360 PJ_DECL(void) pj_turn_transport_add_ref(pj_turn_transport *transport, 361 pj_turn_allocation *alloc); 362 363 364 /** 365 * Decrement transport reference counter. 366 */ 367 PJ_DECL(void) pj_turn_transport_dec_ref(pj_turn_transport *transport, 368 pj_turn_allocation *alloc); 369 326 370 327 371 … … 361 405 pj_turn_listener **listener; 362 406 363 /** Array of STUN sessions, one for each listeners. */364 pj_stun_session * *stun_sess;407 /** STUN session to handle initial Allocate request. */ 408 pj_stun_session *stun_sess; 365 409 366 410 /** Number of worker threads. */ … … 457 501 */ 458 502 PJ_DECL(void) pj_turn_srv_on_rx_pkt(pj_turn_srv *srv, 459 pj_turn_pkt *pkt);503 pj_turn_pkt *pkt); 460 504 461 505
Note: See TracChangeset
for help on using the changeset viewer.