summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-09-24 19:46:41 +0000
committerBenny Prijono <bennylp@teluu.com>2007-09-24 19:46:41 +0000
commitc326f938bbf72127885ac09179912b8a2cbfb030 (patch)
tree3ed5b986b9ec57dc1a5c3614f68ea3fcfeee907d
parent21f0a8aa71305095f9d7682c571ca56c1559ac6e (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
-rw-r--r--pjlib/include/pj/doxygen.h2
-rw-r--r--pjlib/src/pj/ip_helper_win32.c37
-rw-r--r--pjmedia/include/pjmedia/doxygen.h4
-rw-r--r--pjnath/include/pjnath/config.h10
-rw-r--r--pjnath/include/pjnath/types.h4
-rw-r--r--pjnath/src/pjnath/ice_session.c14
-rw-r--r--pjnath/src/pjnath/ice_strans.c17
-rw-r--r--pjnath/src/pjnath/stun_msg_dump.c2
8 files changed, 72 insertions, 18 deletions
diff --git a/pjlib/include/pj/doxygen.h b/pjlib/include/pj/doxygen.h
index fa09c40f..f65066f9 100644
--- a/pjlib/include/pj/doxygen.h
+++ b/pjlib/include/pj/doxygen.h
@@ -55,7 +55,7 @@
*
* @subsection doc_ver_subsec Version
*
- * This document corresponds to PJLIB version 0.5.10.
+ * This document corresponds to PJLIB version 0.7.0-trunk.
*
*
* @subsection find_samples_subsec How to Read This Document
diff --git a/pjlib/src/pj/ip_helper_win32.c b/pjlib/src/pj/ip_helper_win32.c
index 69ff16a2..1a937d72 100644
--- a/pjlib/src/pj/ip_helper_win32.c
+++ b/pjlib/src/pj/ip_helper_win32.c
@@ -34,16 +34,22 @@
#include <pj/errno.h>
#include <pj/string.h>
+#ifndef PJ_IP_HELPER_IGNORE_LOOPBACK_IF
+# define PJ_IP_HELPER_IGNORE_LOOPBACK_IF 1
+#endif
+
typedef DWORD (WINAPI *PFN_GetIpAddrTable)(PMIB_IPADDRTABLE pIpAddrTable,
PULONG pdwSize,
BOOL bOrder);
typedef DWORD (WINAPI *PFN_GetIpForwardTable)(PMIB_IPFORWARDTABLE pIpForwardTable,
PULONG pdwSize,
BOOL bOrder);
+typedef DWORD (WINAPI *PFN_GetIfEntry)(PMIB_IFROW pIfRow);
static HANDLE s_hDLL;
static PFN_GetIpAddrTable s_pfnGetIpAddrTable;
static PFN_GetIpForwardTable s_pfnGetIpForwardTable;
+static PFN_GetIfEntry s_pfnGetIfEntry;
static void unload_iphlp_module(void)
{
@@ -85,6 +91,23 @@ static DWORD MyGetIpAddrTable(PMIB_IPADDRTABLE pIpAddrTable,
}
+#if PJ_IP_HELPER_IGNORE_LOOPBACK_IF
+static DWORD MyGetIfEntry(MIB_IFROW *pIfRow)
+{
+ if(NULL == s_pfnGetIfEntry) {
+ s_pfnGetIfEntry = (PFN_GetIfEntry)
+ GetIpHlpApiProc(PJ_T("GetIfEntry"));
+ }
+
+ if(NULL != s_pfnGetIfEntry) {
+ return s_pfnGetIfEntry(pIfRow);
+ }
+
+ return ERROR_NOT_SUPPORTED;
+}
+#endif
+
+
static DWORD MyGetIpForwardTable(PMIB_IPFORWARDTABLE pIpForwardTable,
PULONG pdwSize,
BOOL bOrder)
@@ -134,9 +157,23 @@ PJ_DEF(pj_status_t) pj_enum_ip_interface(unsigned *p_cnt,
count = (pTab->dwNumEntries < *p_cnt) ? pTab->dwNumEntries : *p_cnt;
*p_cnt = 0;
for (i=0; i<count; ++i) {
+ MIB_IFROW ifRow;
+
/* Some Windows returns 0.0.0.0! */
if (pTab->table[i].dwAddr == 0)
continue;
+
+#if PJ_IP_HELPER_IGNORE_LOOPBACK_IF
+ /* Investigate the type of this interface */
+ pj_bzero(&ifRow, sizeof(ifRow));
+ ifRow.dwIndex = pTab->table[i].dwIndex;
+ if (MyGetIfEntry(&ifRow) != 0)
+ continue;
+
+ if (ifRow.dwType == MIB_IF_TYPE_LOOPBACK)
+ continue;
+#endif
+
ifs[*p_cnt].s_addr = pTab->table[i].dwAddr;
(*p_cnt)++;
}
diff --git a/pjmedia/include/pjmedia/doxygen.h b/pjmedia/include/pjmedia/doxygen.h
index fc254fd9..8d93175c 100644
--- a/pjmedia/include/pjmedia/doxygen.h
+++ b/pjmedia/include/pjmedia/doxygen.h
@@ -91,8 +91,8 @@
* @ref enc_dec_codec,
* @ref plc_codec,
* @ref PJMEDIA_CONF,
- * @ref PJMED_G711 "G711/G.711 (PCMA/PCMU) codec with PLC",
- * @ref PJMED_GSM "GSM codec with PLC",
+ * @ref PJMED_G711 "G711/G.711 (PCMA/PCMU) codec",
+ * @ref PJMED_GSM "GSM codec",
* @ref PJMED_L16 "linear codecs (multiple clockrate, stereo support, etc)",
* @ref PJMED_SPEEX "Speex codec (narrowband, wideband, ultra-wideband)",
* @ref PJMED_JBUF "portable, adaptive jitter buffer with PLC support",
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();