diff options
author | Benny Prijono <bennylp@teluu.com> | 2007-09-24 19:46:41 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2007-09-24 19:46:41 +0000 |
commit | c326f938bbf72127885ac09179912b8a2cbfb030 (patch) | |
tree | 3ed5b986b9ec57dc1a5c3614f68ea3fcfeee907d /pjnath | |
parent | 21f0a8aa71305095f9d7682c571ca56c1559ac6e (diff) |
Ticket #382: Updated ICE from draft-ietf-mmusic-ice-14 to ice-18 specification, and also done some other tweaks as well
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1450 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjnath')
-rw-r--r-- | pjnath/include/pjnath/config.h | 10 | ||||
-rw-r--r-- | pjnath/include/pjnath/types.h | 4 | ||||
-rw-r--r-- | pjnath/src/pjnath/ice_session.c | 14 | ||||
-rw-r--r-- | pjnath/src/pjnath/ice_strans.c | 17 | ||||
-rw-r--r-- | pjnath/src/pjnath/stun_msg_dump.c | 2 |
5 files changed, 32 insertions, 15 deletions
diff --git a/pjnath/include/pjnath/config.h b/pjnath/include/pjnath/config.h index 25eb5b73..9ae03d22 100644 --- a/pjnath/include/pjnath/config.h +++ b/pjnath/include/pjnath/config.h @@ -234,6 +234,16 @@ #endif +/** + * This constant specifies the length of random string generated for ICE + * ufrag and password. + * + * Default: 8 (characters) + */ +#ifndef PJ_ICE_UFRAG_LEN +# define PJ_ICE_UFRAG_LEN 8 +#endif + /** * @} diff --git a/pjnath/include/pjnath/types.h b/pjnath/include/pjnath/types.h index 0714c4c3..31683eb3 100644 --- a/pjnath/include/pjnath/types.h +++ b/pjnath/include/pjnath/types.h @@ -157,8 +157,8 @@ PJ_END_DECL * Interactive Connectivity Establishment (ICE) is a standard based * methodology for traversing Network Address Translator (NAT), and * is described in - * <A HREF="http://www.ietf.org/internet-drafts/draft-ietf-mmusic-ice-14.txt"> - * <B>draft-ietf-mmusic-ice-14.txt</B></A> draft. The PJNATH ICE + * <A HREF="http://www.ietf.org/internet-drafts/draft-ietf-mmusic-ice-18.txt"> + * <B>draft-ietf-mmusic-ice-18.txt</B></A> draft. The PJNATH ICE * implementation is aimed to provide a usable and generic ICE transports * for different types of application, including but not limited to * the usage of ICE in SIP/SDP offer/answer. diff --git a/pjnath/src/pjnath/ice_session.c b/pjnath/src/pjnath/ice_session.c index 94e5989d..695c66d0 100644 --- a/pjnath/src/pjnath/ice_session.c +++ b/pjnath/src/pjnath/ice_session.c @@ -214,7 +214,7 @@ static pj_status_t init_comp(pj_ice_sess *ice, /* Create STUN session for this candidate */ status = pj_stun_session_create(&ice->stun_cfg, NULL, - &sess_cb, PJ_FALSE, + &sess_cb, PJ_TRUE, &comp->stun_sess); if (status != PJ_SUCCESS) return status; @@ -296,17 +296,17 @@ PJ_DEF(pj_status_t) pj_ice_sess_create(pj_stun_config *stun_cfg, } if (local_ufrag == NULL) { - ice->rx_ufrag.ptr = (char*) pj_pool_alloc(ice->pool, 16); - pj_create_random_string(ice->rx_ufrag.ptr, 16); - ice->rx_ufrag.slen = 16; + ice->rx_ufrag.ptr = (char*) pj_pool_alloc(ice->pool, PJ_ICE_UFRAG_LEN); + pj_create_random_string(ice->rx_ufrag.ptr, PJ_ICE_UFRAG_LEN); + ice->rx_ufrag.slen = PJ_ICE_UFRAG_LEN; } else { pj_strdup(ice->pool, &ice->rx_ufrag, local_ufrag); } if (local_passwd == NULL) { - ice->rx_pass.ptr = (char*) pj_pool_alloc(ice->pool, 16); - pj_create_random_string(ice->rx_pass.ptr, 16); - ice->rx_pass.slen = 16; + ice->rx_pass.ptr = (char*) pj_pool_alloc(ice->pool, PJ_ICE_UFRAG_LEN); + pj_create_random_string(ice->rx_pass.ptr, PJ_ICE_UFRAG_LEN); + ice->rx_pass.slen = PJ_ICE_UFRAG_LEN; } else { pj_strdup(ice->pool, &ice->rx_pass, local_passwd); } diff --git a/pjnath/src/pjnath/ice_strans.c b/pjnath/src/pjnath/ice_strans.c index 6278f9ff..f8a20d19 100644 --- a/pjnath/src/pjnath/ice_strans.c +++ b/pjnath/src/pjnath/ice_strans.c @@ -590,7 +590,9 @@ static void ka_timer_cb(pj_timer_heap_t *th, pj_timer_entry *te) /* Send STUN binding request */ - PJ_LOG(5,(ice_st->obj_name, "Sending STUN keep-alive")); + PJ_LOG(5,(ice_st->obj_name, "Sending STUN keep-alive from %s;%d", + pj_inet_ntoa(comp->local_addr.ipv4.sin_addr), + pj_ntohs(comp->local_addr.ipv4.sin_port))); status = pj_stun_session_send_msg(comp->stun_sess, PJ_FALSE, &ice_st->stun_srv, sizeof(pj_sockaddr_in), tdata); @@ -1137,15 +1139,20 @@ static void stun_on_request_complete(pj_stun_session *sess, return; } + /* Save IP address for logging */ + pj_ansi_strcpy(ip, pj_inet_ntoa(comp->local_addr.ipv4.sin_addr)); + /* Ignore response if it reports the same address */ - if (cand->addr.ipv4.sin_addr.s_addr == mapped_addr->ipv4.sin_addr.s_addr && - cand->addr.ipv4.sin_port == mapped_addr->ipv4.sin_port) + if (comp->local_addr.ipv4.sin_addr.s_addr == mapped_addr->ipv4.sin_addr.s_addr && + comp->local_addr.ipv4.sin_port == mapped_addr->ipv4.sin_port) { + PJ_LOG(4,(comp->ice_st->obj_name, + "Candidate %s:%d is directly connected to Internet, " + "STUN mapped address is ignored", + ip, pj_ntohs(comp->local_addr.ipv4.sin_port))); return; } - pj_ansi_strcpy(ip, pj_inet_ntoa(comp->local_addr.ipv4.sin_addr)); - PJ_LOG(4,(comp->ice_st->obj_name, "STUN mapped address for %s:%d is %s:%d", ip, (int)pj_ntohs(comp->local_addr.ipv4.sin_port), diff --git a/pjnath/src/pjnath/stun_msg_dump.c b/pjnath/src/pjnath/stun_msg_dump.c index 3745ebe3..3ca9a80b 100644 --- a/pjnath/src/pjnath/stun_msg_dump.c +++ b/pjnath/src/pjnath/stun_msg_dump.c @@ -115,7 +115,7 @@ static int print_attr(char *buffer, unsigned length, attr = (const pj_stun_uint_attr*)ahdr; len = pj_ansi_snprintf(p, end-p, - ", value=%d (0x%x)\n", + ", value=%u (0x%x)\n", (pj_uint32_t)attr->value, (pj_uint32_t)attr->value); APPLY(); |