Home --> Documentations --> PJNATH Reference

stun_session.h
Go to the documentation of this file.
1 /* $Id: stun_session.h 4606 2013-10-01 05:00:57Z ming $ */
2 /*
3  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 #ifndef __PJNATH_STUN_SESSION_H__
21 #define __PJNATH_STUN_SESSION_H__
22 
28 #include <pjnath/stun_msg.h>
29 #include <pjnath/stun_auth.h>
30 #include <pjnath/stun_config.h>
32 #include <pj/list.h>
33 #include <pj/lock.h>
34 #include <pj/timer.h>
35 
37 
38 
39 /* **************************************************************************/
169 typedef struct pj_stun_tx_data pj_stun_tx_data;
170 
172 typedef struct pj_stun_rx_data pj_stun_rx_data;
173 
176 
177 
183 typedef struct pj_stun_session_cb
184 {
207  void *token,
208  const void *pkt,
209  pj_size_t pkt_size,
210  const pj_sockaddr_t *dst_addr,
211  unsigned addr_len);
212 
237  const pj_uint8_t *pkt,
238  unsigned pkt_len,
239  const pj_stun_rx_data *rdata,
240  void *token,
241  const pj_sockaddr_t *src_addr,
242  unsigned src_addr_len);
243 
275  pj_status_t status,
276  void *token,
277  pj_stun_tx_data *tdata,
278  const pj_stun_msg *response,
279  const pj_sockaddr_t *src_addr,
280  unsigned src_addr_len);
281 
282 
303  const pj_uint8_t *pkt,
304  unsigned pkt_len,
305  const pj_stun_msg *msg,
306  void *token,
307  const pj_sockaddr_t *src_addr,
308  unsigned src_addr_len);
309 
311 
312 
317 {
322 
329 };
330 
331 
337 {
340 
345  void *token;
354  void *pkt;
355  unsigned max_len;
358  unsigned addr_len;
362 };
363 
364 
369 {
378 
379 
395  const char *name,
396  const pj_stun_session_cb *cb,
397  pj_bool_t fingerprint,
398  pj_grp_lock_t *grp_lock,
399  pj_stun_session **p_sess);
400 
414 
425  void *user_data);
426 
435 PJ_DECL(void*) pj_stun_session_get_user_data(pj_stun_session *sess);
436 
445 
457  const pj_str_t *sw);
458 
475  pj_stun_auth_type auth_type,
476  const pj_stun_auth_cred *cred);
483 PJ_DECL(void) pj_stun_session_set_log(pj_stun_session *sess,
484  unsigned flags);
496  pj_bool_t use);
497 
514  int msg_type,
515  pj_uint32_t magic,
516  const pj_uint8_t tsx_id[12],
517  pj_stun_tx_data **p_tdata);
518 
534  int msg_type,
535  pj_stun_tx_data **p_tdata);
536 
559  const pj_stun_rx_data *rdata,
560  unsigned err_code,
561  const pj_str_t *err_msg,
562  pj_stun_tx_data **p_tdata);
563 
601  void *token,
602  pj_bool_t cache_res,
603  pj_bool_t retransmit,
604  const pj_sockaddr_t *dst_addr,
605  unsigned addr_len,
606  pj_stun_tx_data *tdata);
607 
644  const pj_stun_rx_data *rdata,
645  unsigned code,
646  const char *err_msg,
647  void *token,
648  pj_bool_t cache,
649  const pj_sockaddr_t *dst_addr,
650  unsigned addr_len);
651 
671  pj_stun_tx_data *tdata,
672  pj_bool_t notify,
673  pj_status_t status);
674 
691  pj_stun_tx_data *tdata,
692  pj_bool_t mod_count);
693 
694 
732  const void *packet,
733  pj_size_t pkt_size,
734  unsigned options,
735  void *token,
736  pj_size_t *parsed_len,
737  const pj_sockaddr_t *src_addr,
738  unsigned src_addr_len);
739 
750 PJ_DECL(void) pj_stun_msg_destroy_tdata(pj_stun_session *sess,
751  pj_stun_tx_data *tdata);
752 
753 
759 PJ_END_DECL
760 
761 #endif /* __PJNATH_STUN_SESSION_H__ */
762 
STUN message components.
pj_status_t pj_stun_session_create_ind(pj_stun_session *sess, int msg_type, pj_stun_tx_data **p_tdata)
STUN authentication.
pj_size_t pkt_size
Definition: stun_session.h:356
int pj_bool_t
Definition: stun_auth.h:114
Definition: stun_session.h:371
pj_pool_t * pool
Definition: stun_session.h:341
void * user_data
pj_status_t pj_stun_session_cancel_req(pj_stun_session *sess, pj_stun_tx_data *tdata, pj_bool_t notify, pj_status_t status)
Definition: stun_session.h:183
void pj_stun_msg_destroy_tdata(pj_stun_session *sess, pj_stun_tx_data *tdata)
pj_bool_t retransmit
Definition: stun_session.h:348
const pj_sockaddr_t * dst_addr
Definition: stun_session.h:359
unsigned max_len
Definition: stun_session.h:355
unsigned addr_len
Definition: stun_session.h:358
pj_uint8_t msg_key[12]
Definition: stun_session.h:350
Definition: stun_session.h:316
int pj_status_t
Definition: stun_auth.h:299
pj_status_t pj_stun_session_destroy(pj_stun_session *sess)
pj_bool_t pj_stun_session_use_fingerprint(pj_stun_session *sess, pj_bool_t use)
pj_status_t pj_stun_session_create(pj_stun_config *cfg, const char *name, const pj_stun_session_cb *cb, pj_bool_t fingerprint, pj_grp_lock_t *grp_lock, pj_stun_session **p_sess)
Definition: stun_config.h:48
Definition: stun_session.h:370
void pj_sockaddr_t
pj_status_t pj_stun_session_create_res(pj_stun_session *sess, const pj_stun_rx_data *rdata, unsigned err_code, const pj_str_t *err_msg, pj_stun_tx_data **p_tdata)
pj_stun_req_cred_info info
Definition: stun_session.h:328
struct pj_grp_lock_t pj_grp_lock_t
pj_status_t(* on_rx_indication)(pj_stun_session *sess, const pj_uint8_t *pkt, unsigned pkt_len, const pj_stun_msg *msg, void *token, const pj_sockaddr_t *src_addr, unsigned src_addr_len)
Definition: stun_session.h:302
unsigned int pj_uint32_t
pj_status_t pj_stun_session_create_req(pj_stun_session *sess, int msg_type, pj_uint32_t magic, const pj_uint8_t tsx_id[12], pj_stun_tx_data **p_tdata)
pj_status_t pj_stun_session_set_credential(pj_stun_session *sess, pj_stun_auth_type auth_type, const pj_stun_auth_cred *cred)
void(* on_request_complete)(pj_stun_session *sess, pj_status_t status, void *token, pj_stun_tx_data *tdata, const pj_stun_msg *response, const pj_sockaddr_t *src_addr, unsigned src_addr_len)
Definition: stun_session.h:274
STUN transaction.
pj_status_t pj_stun_session_respond(pj_stun_session *sess, const pj_stun_rx_data *rdata, unsigned code, const char *err_msg, void *token, pj_bool_t cache, const pj_sockaddr_t *dst_addr, unsigned addr_len)
struct pj_stun_session pj_stun_session
Definition: stun_session.h:175
pj_status_t pj_stun_session_retransmit_req(pj_stun_session *sess, pj_stun_tx_data *tdata, pj_bool_t mod_count)
pj_uint32_t flags
#define PJ_BEGIN_DECL
pj_stun_msg * msg
Definition: stun_session.h:343
Definition: stun_session.h:375
pj_status_t pj_stun_session_on_rx_pkt(pj_stun_session *sess, const void *packet, pj_size_t pkt_size, unsigned options, void *token, pj_size_t *parsed_len, const pj_sockaddr_t *src_addr, unsigned src_addr_len)
pj_stun_req_cred_info auth_info
Definition: stun_session.h:352
Definition: stun_session.h:372
pj_stun_msg * msg
Definition: stun_session.h:321
void * token
Definition: stun_session.h:345
void * pkt
Definition: stun_session.h:354
pj_stun_auth_type
Definition: stun_auth.h:45
unsigned char pj_uint8_t
PJ_DECL_LIST_MEMBER(struct pj_stun_tx_data)
Definition: stun_session.h:374
pj_stun_sess_msg_log_flag
Definition: stun_session.h:368
pj_status_t(* on_rx_request)(pj_stun_session *sess, const pj_uint8_t *pkt, unsigned pkt_len, const pj_stun_rx_data *rdata, void *token, const pj_sockaddr_t *src_addr, unsigned src_addr_len)
Definition: stun_session.h:236
Definition: stun_session.h:336
pj_uint32_t msg_magic
Definition: stun_session.h:349
pj_stun_session * sess
Definition: stun_session.h:342
pj_status_t pj_stun_session_send_msg(pj_stun_session *sess, void *token, pj_bool_t cache_res, pj_bool_t retransmit, const pj_sockaddr_t *dst_addr, unsigned addr_len, pj_stun_tx_data *tdata)
struct pj_stun_client_tsx pj_stun_client_tsx
Definition: stun_transaction.h:59
pj_status_t pj_stun_session_set_software_name(pj_stun_session *sess, const pj_str_t *sw)
STUN endpoint.
void * pj_stun_session_get_user_data(pj_stun_session *sess)
pj_timer_entry res_timer
Definition: stun_session.h:361
Definition: stun_msg.h:1141
pj_status_t pj_stun_session_set_user_data(pj_stun_session *sess, void *user_data)
Definition: stun_session.h:376
pj_grp_lock_t * pj_stun_session_get_grp_lock(pj_stun_session *sess)
pj_status_t(* on_send_msg)(pj_stun_session *sess, void *token, const void *pkt, pj_size_t pkt_size, const pj_sockaddr_t *dst_addr, unsigned addr_len)
Definition: stun_session.h:206
pj_stun_client_tsx * client_tsx
Definition: stun_session.h:347
void pj_stun_session_set_log(pj_stun_session *sess, unsigned flags)
size_t pj_size_t

 


PJNATH - Open Source NAT traversal helper library supporting STUN, TURN, and ICE
Copyright (C) 2006-2009 Teluu Inc.