summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pjnath/build/pjnath.dsp12
-rw-r--r--pjnath/build/pjstun_client.dsp4
-rw-r--r--pjnath/build/pjstun_srv_test.dsp4
-rw-r--r--pjnath/include/pjnath.h2
-rw-r--r--pjnath/include/pjnath/stun_config.h (renamed from pjnath/include/pjnath/stun_setting.h)20
-rw-r--r--pjnath/include/pjnath/stun_session.h2
-rw-r--r--pjnath/include/pjnath/stun_transaction.h2
-rw-r--r--pjnath/src/pjnath/ice.c224
-rw-r--r--pjnath/src/pjnath/stun_setting.c23
-rw-r--r--pjnath/src/pjstun-client/client_main.c10
-rw-r--r--pjnath/src/pjstun-srv-test/bind_usage.c4
-rw-r--r--pjnath/src/pjstun-srv-test/server.c7
-rw-r--r--pjnath/src/pjstun-srv-test/server.h2
-rw-r--r--pjnath/src/pjstun-srv-test/turn_usage.c24
14 files changed, 152 insertions, 188 deletions
diff --git a/pjnath/build/pjnath.dsp b/pjnath/build/pjnath.dsp
index c46df1fa..999bf065 100644
--- a/pjnath/build/pjnath.dsp
+++ b/pjnath/build/pjnath.dsp
@@ -111,10 +111,6 @@ SOURCE=..\src\pjnath\stun_session.c
# End Source File
# Begin Source File
-SOURCE=..\src\pjnath\stun_setting.c
-# End Source File
-# Begin Source File
-
SOURCE=..\src\pjnath\stun_transaction.c
# End Source File
# End Group
@@ -143,19 +139,19 @@ SOURCE=..\include\pjnath\stun_auth.h
# End Source File
# Begin Source File
-SOURCE=..\include\pjnath\stun_doc.h
+SOURCE=..\include\pjnath\stun_config.h
# End Source File
# Begin Source File
-SOURCE=..\include\pjnath\stun_msg.h
+SOURCE=..\include\pjnath\stun_doc.h
# End Source File
# Begin Source File
-SOURCE=..\include\pjnath\stun_session.h
+SOURCE=..\include\pjnath\stun_msg.h
# End Source File
# Begin Source File
-SOURCE=..\include\pjnath\stun_setting.h
+SOURCE=..\include\pjnath\stun_session.h
# End Source File
# Begin Source File
diff --git a/pjnath/build/pjstun_client.dsp b/pjnath/build/pjstun_client.dsp
index 2d5705b7..9cbbbfde 100644
--- a/pjnath/build/pjstun_client.dsp
+++ b/pjnath/build/pjstun_client.dsp
@@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "../include" /I "../../pjlib/include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
@@ -66,7 +66,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../include" /I "../../pjlib/include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
diff --git a/pjnath/build/pjstun_srv_test.dsp b/pjnath/build/pjstun_srv_test.dsp
index fa1a5656..428467e1 100644
--- a/pjnath/build/pjstun_srv_test.dsp
+++ b/pjnath/build/pjstun_srv_test.dsp
@@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MD /W4 /GX /O2 /I "../include" /I "../../pjlib/include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /YX /FD /c
+# ADD CPP /nologo /MD /W4 /GX /O2 /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
@@ -66,7 +66,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "../include" /I "../../pjlib/include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
diff --git a/pjnath/include/pjnath.h b/pjnath/include/pjnath.h
index 42fc3ca3..750a613e 100644
--- a/pjnath/include/pjnath.h
+++ b/pjnath/include/pjnath.h
@@ -20,7 +20,7 @@
#include <pjnath/config.h>
#include <pjnath/errno.h>
#include <pjnath/stun_auth.h>
-#include <pjnath/stun_setting.h>
+#include <pjnath/stun_config.h>
#include <pjnath/stun_msg.h>
#include <pjnath/stun_session.h>
#include <pjnath/stun_transaction.h>
diff --git a/pjnath/include/pjnath/stun_setting.h b/pjnath/include/pjnath/stun_config.h
index 66a5f7aa..d0914267 100644
--- a/pjnath/include/pjnath/stun_setting.h
+++ b/pjnath/include/pjnath/stun_config.h
@@ -25,6 +25,7 @@
*/
#include <pjnath/stun_msg.h>
+#include <pj/string.h>
PJ_BEGIN_DECL
@@ -32,40 +33,33 @@ PJ_BEGIN_DECL
/* **************************************************************************/
/**
- * @defgroup PJNATH_STUN_SETTING STUN Settings
- * @brief STUN settings.
+ * @defgroup PJNATH_STUN_CONFIG STUN Config
+ * @brief STUN config
* @ingroup PJNATH_STUN
* @{
*/
/**
- * Opaque declaration for STUN setting.
+ * STUN configuration.
*/
typedef struct pj_stun_config
{
/**
- * Pool factory to be used by the STUN endpoint and all objects created
- * that use this STUN endpoint.
+ * Pool factory to be used.
*/
pj_pool_factory *pf;
/**
- * Ioqueue used by this endpoint.
+ * Ioqueue.
*/
pj_ioqueue_t *ioqueue;
/**
- * Timer heap instance used by this endpoint.
+ * Timer heap instance.
*/
pj_timer_heap_t *timer_heap;
/**
- * Internal pool used by this endpoint. This shouldn't be used by
- * application.
- */
- pj_pool_t *pool;
-
- /**
* Options.
*/
unsigned options;
diff --git a/pjnath/include/pjnath/stun_session.h b/pjnath/include/pjnath/stun_session.h
index bd28ecb6..3c5daee7 100644
--- a/pjnath/include/pjnath/stun_session.h
+++ b/pjnath/include/pjnath/stun_session.h
@@ -21,7 +21,7 @@
#include <pjnath/stun_msg.h>
#include <pjnath/stun_auth.h>
-#include <pjnath/stun_endpoint.h>
+#include <pjnath/stun_config.h>
#include <pjnath/stun_transaction.h>
#include <pj/list.h>
#include <pj/timer.h>
diff --git a/pjnath/include/pjnath/stun_transaction.h b/pjnath/include/pjnath/stun_transaction.h
index f4858863..02b0af9e 100644
--- a/pjnath/include/pjnath/stun_transaction.h
+++ b/pjnath/include/pjnath/stun_transaction.h
@@ -25,7 +25,7 @@
*/
#include <pjnath/stun_msg.h>
-#include <pjnath/stun_endpoint.h>
+#include <pjnath/stun_config.h>
PJ_BEGIN_DECL
diff --git a/pjnath/src/pjnath/ice.c b/pjnath/src/pjnath/ice.c
index e8babab0..334262ea 100644
--- a/pjnath/src/pjnath/ice.c
+++ b/pjnath/src/pjnath/ice.c
@@ -211,108 +211,6 @@ PJ_DEF(pj_status_t) pj_ice_destroy(pj_ice *ice)
}
-/* This function is called when ICE processing completes */
-static void on_ice_complete(pj_ice *ice, pj_status_t status)
-{
-}
-
-
-/* This function is called when one check completes */
-static pj_bool_t on_check_complete(pj_ice *ice,
- pj_ice_check *check)
-{
- unsigned i;
-
- /* If there is at least one nominated pair in the valid list:
- * - The agent MUST remove all Waiting and Frozen pairs in the check
- * list for the same component as the nominated pairs for that
- * media stream
- * - If an In-Progress pair in the check list is for the same
- * component as a nominated pair, the agent SHOULD cease
- * retransmissions for its check if its pair priority is lower
- * than the lowest priority nominated pair for that component
- */
- if (check->nominated) {
- for (i=0; i<ice->clist.count; ++i) {
- pj_ice_check *c;
- if (c->lcand->comp_id == check->lcand->comp_id &&
- (c->state==PJ_ICE_CHECK_STATE_FROZEN ||
- c->state==PJ_ICE_CHECK_STATE_WAITING)
- {
- check_set_state(ice, check, PJ_ICE_CHECK_STATE_FAILED,
- PJ_ECANCELLED);
- }
- }
- }
-
- /* Once there is at least one nominated pair in the valid list for
- * every component of at least one media stream:
- * - The agent MUST change the state of processing for its check
- * list for that media stream to Completed.
- * - The agent MUST continue to respond to any checks it may still
- * receive for that media stream, and MUST perform triggered
- * checks if required by the processing of Section 7.2.
- * - The agent MAY begin transmitting media for this media stream as
- * described in Section 11.1
- */
- /* TODO */
-
- /* Once there is at least one nominated pair in the valid list for
- * each component of each media stream:
- * - The agent sets the state of ICE processing overall to
- * Completed.
- * - If an agent is controlling, it examines the highest priority
- * nominated candidate pair for each component of each media
- * stream. If any of those candidate pairs differ from the
- * default candidate pairs in the most recent offer/answer
- * exchange, the controlling agent MUST generate an updated offer
- * as described in Section 9. If the controlling agent is using
- * an aggressive nomination algorithm, this may result in several
- * updated offers as the pairs selected for media change. An
- * agent MAY delay sending the offer for a brief interval (one
- * second is RECOMMENDED) in order to allow the selected pairs to
- * stabilize.
- */
- /* TODO */
-
-
- /* For now, just see if we have a valid pair in component 1 and
- * just terminate ICE.
- */
- for (i=0; i<ice->valid_cnt; ++i) {
- pj_ice_check *c = ice->clist.checks[ice->valid_list[i]];
- if (c->lcand->comp_id == 1)
- break;
- }
-
- if (i != ice->valid_cnt) {
- /* ICE succeeded */
- on_ice_complete(ice, PJ_SUCCESS);
- return PJ_TRUE;
- }
-
- /* We don't have valid pair for component 1.
- * See if we have performed all checks in the checklist. If we do,
- * then mark ICE processing as failed.
- */
- for (i=0; i<ice->clist.count; ++i) {
- pj_ice_check *c = &ice->clist.checks[i];
- if (c->state < PJ_ICE_CHECK_STATE_SUCCEEDED) {
- break;
- }
- }
-
- if (i == ice->clist.count) {
- /* All checks have completed */
- on_ice_complete(ice, -1);
- return PJ_TRUE;
- }
-
- /* We still have checks to perform */
- return PJ_FALSE;
-}
-
-
static void resolver_cb(void *user_data,
pj_status_t status,
pj_dns_parsed_packet *response)
@@ -919,7 +817,6 @@ static pj_uint64_t CALC_CHECK_PRIO(const pj_ice *ice,
}
static const char *dump_check(char *buffer, unsigned bufsize,
- const pj_ice *ice,
const pj_ice_check *check)
{
const pj_ice_cand *lcand = check->lcand;
@@ -960,7 +857,7 @@ static void dump_checklist(const char *title, const pj_ice *ice,
for (i=0; i<clist->count; ++i) {
const pj_ice_check *c = &clist->checks[i];
LOG((ice->obj_name, " %d: %s (prio=%u, state=%s)",
- i, dump_check(buffer, sizeof(buffer), ice, c),
+ i, dump_check(buffer, sizeof(buffer), c),
c->prio, check_state_name[c->state]));
}
}
@@ -974,7 +871,7 @@ static void check_set_state(pj_ice *ice, pj_ice_check *check,
{
char buf[CHECK_NAME_LEN];
LOG((ice->obj_name, "Check %s: state changed from %s to %s",
- dump_check(buf, sizeof(buf), ice, check),
+ dump_check(buf, sizeof(buf), check),
check_state_name[check->state],
check_state_name[st]));
check->state = st;
@@ -1021,10 +918,10 @@ static void sort_valid_list(pj_ice *ice)
for (i=0; i<ice->valid_cnt-1; ++i) {
unsigned j, highest = i;
- pj_ice_check *ci = ice->clist.checks[ice->valid_list[i]];
+ pj_ice_check *ci = &ice->clist.checks[ice->valid_list[i]];
for (j=i+1; j<ice->valid_cnt; ++j) {
- pj_ice_check *cj = ice->clist.checks[ice->valid_list[j]];
+ pj_ice_check *cj = &ice->clist.checks[ice->valid_list[j]];
if (cj->prio > ci->prio) {
highest = j;
@@ -1111,7 +1008,7 @@ static void prune_checklist(pj_ice *ice, pj_ice_checklist *clist)
char buf[CHECK_NAME_LEN];
LOG((ice->obj_name, "Check %s pruned",
- dump_check(buf, sizeof(buf), ice, &clist->checks[j])));
+ dump_check(buf, sizeof(buf), &clist->checks[j])));
pj_array_erase(clist->checks, sizeof(clist->checks[0]),
clist->count, j);
@@ -1124,6 +1021,111 @@ static void prune_checklist(pj_ice *ice, pj_ice_checklist *clist)
}
}
+/* This function is called when ICE processing completes */
+static void on_ice_complete(pj_ice *ice, pj_status_t status)
+{
+}
+
+
+/* This function is called when one check completes */
+static pj_bool_t on_check_complete(pj_ice *ice,
+ pj_ice_check *check)
+{
+ unsigned i;
+
+ /* If there is at least one nominated pair in the valid list:
+ * - The agent MUST remove all Waiting and Frozen pairs in the check
+ * list for the same component as the nominated pairs for that
+ * media stream
+ * - If an In-Progress pair in the check list is for the same
+ * component as a nominated pair, the agent SHOULD cease
+ * retransmissions for its check if its pair priority is lower
+ * than the lowest priority nominated pair for that component
+ */
+ if (check->nominated) {
+ for (i=0; i<ice->clist.count; ++i) {
+ pj_ice_check *c = &ice->clist.checks[i];
+ if (c->lcand->comp_id == check->lcand->comp_id &&
+ (c->state==PJ_ICE_CHECK_STATE_FROZEN ||
+ c->state==PJ_ICE_CHECK_STATE_WAITING))
+ {
+ check_set_state(ice, check, PJ_ICE_CHECK_STATE_FAILED,
+ PJ_ECANCELLED);
+ }
+ }
+ }
+
+ /* Once there is at least one nominated pair in the valid list for
+ * every component of at least one media stream:
+ * - The agent MUST change the state of processing for its check
+ * list for that media stream to Completed.
+ * - The agent MUST continue to respond to any checks it may still
+ * receive for that media stream, and MUST perform triggered
+ * checks if required by the processing of Section 7.2.
+ * - The agent MAY begin transmitting media for this media stream as
+ * described in Section 11.1
+ */
+ /* TODO */
+
+ /* Once there is at least one nominated pair in the valid list for
+ * each component of each media stream:
+ * - The agent sets the state of ICE processing overall to
+ * Completed.
+ * - If an agent is controlling, it examines the highest priority
+ * nominated candidate pair for each component of each media
+ * stream. If any of those candidate pairs differ from the
+ * default candidate pairs in the most recent offer/answer
+ * exchange, the controlling agent MUST generate an updated offer
+ * as described in Section 9. If the controlling agent is using
+ * an aggressive nomination algorithm, this may result in several
+ * updated offers as the pairs selected for media change. An
+ * agent MAY delay sending the offer for a brief interval (one
+ * second is RECOMMENDED) in order to allow the selected pairs to
+ * stabilize.
+ */
+ /* TODO */
+
+
+ /* For now, just see if we have a valid pair in component 1 and
+ * just terminate ICE.
+ */
+ for (i=0; i<ice->valid_cnt; ++i) {
+ pj_ice_check *c = &ice->clist.checks[ice->valid_list[i]];
+ if (c->lcand->comp_id == 1)
+ break;
+ }
+
+ if (i != ice->valid_cnt) {
+ /* ICE succeeded */
+ on_ice_complete(ice, PJ_SUCCESS);
+ return PJ_TRUE;
+ }
+
+ /* We don't have valid pair for component 1.
+ * See if we have performed all checks in the checklist. If we do,
+ * then mark ICE processing as failed.
+ */
+ for (i=0; i<ice->clist.count; ++i) {
+ pj_ice_check *c = &ice->clist.checks[i];
+ if (c->state < PJ_ICE_CHECK_STATE_SUCCEEDED) {
+ break;
+ }
+ }
+
+ if (i == ice->clist.count) {
+ /* All checks have completed */
+ on_ice_complete(ice, -1);
+ return PJ_TRUE;
+ }
+
+ /* We still have checks to perform */
+ return PJ_FALSE;
+}
+
+
+
+
+
typedef struct timer_data
{
pj_ice *ice;
@@ -1241,7 +1243,7 @@ static pj_status_t perform_check(pj_ice *ice, pj_ice_checklist *clist,
LOG((ice->obj_name,
"Sending connectivity check for check %d: %s",
- check_id, dump_check(buffer, sizeof(buffer), ice, check)));
+ check_id, dump_check(buffer, sizeof(buffer), check)));
/* Create request */
status = pj_stun_session_create_req(comp->stun_sess,
@@ -1433,7 +1435,7 @@ static void on_stun_request_complete(pj_stun_session *stun_sess,
{
struct req_data *rd = (struct req_data*) tdata->user_data;
pj_ice *ice;
- pj_ice_check *check, *valid_check;
+ pj_ice_check *check;
const pj_ice_cand *lcand;
const pj_ice_cand *rcand;
pj_ice_checklist *clist;
@@ -1455,7 +1457,7 @@ static void on_stun_request_complete(pj_stun_session *stun_sess,
LOG((ice->obj_name,
"Connectivity check %s for check %s",
(status==PJ_SUCCESS ? "SUCCESS" : "FAILED"),
- dump_check(buffer, sizeof(buffer), ice, check)));
+ dump_check(buffer, sizeof(buffer), check)));
if (status != PJ_SUCCESS) {
check_set_state(ice, check, PJ_ICE_CHECK_STATE_FAILED, status);
diff --git a/pjnath/src/pjnath/stun_setting.c b/pjnath/src/pjnath/stun_setting.c
deleted file mode 100644
index 79196441..00000000
--- a/pjnath/src/pjnath/stun_setting.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/* $Id$ */
-/*
- * Copyright (C) 2003-2005 Benny Prijono <benny@prijono.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-#include <pjnath/stun_endpoint.h>
-#include <pjnath/errno.h>
-#include <pj/assert.h>
-#include <pj/pool.h>
-
diff --git a/pjnath/src/pjstun-client/client_main.c b/pjnath/src/pjstun-client/client_main.c
index 9bb249f1..7d6b8ebc 100644
--- a/pjnath/src/pjstun-client/client_main.c
+++ b/pjnath/src/pjstun-client/client_main.c
@@ -32,7 +32,7 @@
static struct global
{
- pj_stun_endpoint *endpt;
+ pj_stun_config stun_config;
pj_pool_t *pool;
pj_caching_pool cp;
pj_timer_heap_t *th;
@@ -104,7 +104,7 @@ static void on_request_complete(pj_stun_session *sess,
pj_stun_msg_find_attr(response,
PJ_STUN_ATTR_RELAY_ADDR, 0);
if (ar) {
- pj_memcpy(&g.relay_addr, &ar->addr.ipv4,
+ pj_memcpy(&g.relay_addr, &ar->sockaddr.ipv4,
sizeof(pj_sockaddr_in));
PJ_LOG(3,(THIS_FILE, "Relay address is %s:%d",
pj_inet_ntoa(g.relay_addr.sin_addr),
@@ -208,7 +208,7 @@ static int init()
status = pj_timer_heap_create(g.pool, 1000, &g.th);
pj_assert(status == PJ_SUCCESS);
- status = pj_stun_endpoint_create(&g.cp.factory, 0, NULL, g.th, &g.endpt);
+ pj_stun_config_init(&g.stun_config, &g.cp.factory, 0, NULL, g.th);
pj_assert(status == PJ_SUCCESS);
status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &g.sock);
@@ -235,7 +235,7 @@ static int init()
stun_cb.on_send_msg = &on_send_msg;
stun_cb.on_request_complete = &on_request_complete;
- status = pj_stun_session_create(g.endpt, NULL, &stun_cb,
+ status = pj_stun_session_create(&g.stun_config, NULL, &stun_cb,
o.use_fingerprint!=0, &g.sess);
pj_assert(status == PJ_SUCCESS);
@@ -281,8 +281,6 @@ static int shutdown()
}
if (g.sess)
pj_stun_session_destroy(g.sess);
- if (g.endpt)
- pj_stun_endpoint_destroy(g.endpt);
if (g.sock != PJ_INVALID_SOCKET)
pj_sock_close(g.sock);
if (g.th)
diff --git a/pjnath/src/pjstun-srv-test/bind_usage.c b/pjnath/src/pjstun-srv-test/bind_usage.c
index 3c1825f9..680dd5c0 100644
--- a/pjnath/src/pjstun-srv-test/bind_usage.c
+++ b/pjnath/src/pjstun-srv-test/bind_usage.c
@@ -85,8 +85,8 @@ PJ_DEF(pj_status_t) pj_stun_bind_usage_create(pj_stun_server *srv,
pj_bzero(&sess_cb, sizeof(sess_cb));
sess_cb.on_send_msg = &sess_on_send_msg;
sess_cb.on_rx_request = &sess_on_rx_request;
- status = pj_stun_session_create(si->cfg, "bind%p", &sess_cb, PJ_FALSE,
- &bu->session);
+ status = pj_stun_session_create(&si->stun_cfg, "bind%p", &sess_cb,
+ PJ_FALSE, &bu->session);
if (status != PJ_SUCCESS) {
pj_stun_usage_destroy(bu->usage);
return status;
diff --git a/pjnath/src/pjstun-srv-test/server.c b/pjnath/src/pjstun-srv-test/server.c
index d0fe426d..eb1e12b0 100644
--- a/pjnath/src/pjstun-srv-test/server.c
+++ b/pjnath/src/pjstun-srv-test/server.c
@@ -83,10 +83,8 @@ PJ_DEF(pj_status_t) pj_stun_server_create(pj_pool_factory *pf,
if (status != PJ_SUCCESS)
goto on_error;
- status = pj_stun_config_create(srv->si.pf, 0, srv->si.ioqueue,
- srv->si.timer_heap, &srv->si.cfg);
- if (status != PJ_SUCCESS)
- goto on_error;
+ pj_stun_config_init(&srv->si.stun_cfg, srv->si.pf, 0, srv->si.ioqueue,
+ srv->si.timer_heap);
srv->si.thread_cnt = thread_cnt;
srv->threads = pj_pool_calloc(pool, thread_cnt, sizeof(pj_thread_t*));
@@ -174,7 +172,6 @@ PJ_DEF(pj_status_t) pj_stun_server_destroy(pj_stun_server *srv)
srv->threads[i] = NULL;
}
- pj_stun_config_destroy(srv->si.cfg);
pj_timer_heap_destroy(srv->si.timer_heap);
pj_ioqueue_destroy(srv->si.ioqueue);
pj_pool_release(srv->pool);
diff --git a/pjnath/src/pjstun-srv-test/server.h b/pjnath/src/pjstun-srv-test/server.h
index 6c61da39..633131c6 100644
--- a/pjnath/src/pjstun-srv-test/server.h
+++ b/pjnath/src/pjstun-srv-test/server.h
@@ -31,7 +31,7 @@ typedef struct pj_stun_server pj_stun_server;
typedef struct pj_stun_server_info
{
pj_pool_factory *pf;
- pj_stun_config *cfg;
+ pj_stun_config stun_cfg;
pj_ioqueue_t *ioqueue;
pj_timer_heap_t *timer_heap;
unsigned thread_cnt;
diff --git a/pjnath/src/pjstun-srv-test/turn_usage.c b/pjnath/src/pjstun-srv-test/turn_usage.c
index c1f83d15..d5677f9e 100644
--- a/pjnath/src/pjstun-srv-test/turn_usage.c
+++ b/pjnath/src/pjstun-srv-test/turn_usage.c
@@ -165,7 +165,7 @@ PJ_DEF(pj_status_t) pj_stun_turn_usage_create(pj_stun_server *srv,
tu->pool = pool;
tu->type = type;
tu->pf = si->pf;
- tu->cfg = si->cfg;
+ tu->cfg = &si->stun_cfg;
tu->ioqueue = si->ioqueue;
tu->timer_heap = si->timer_heap;
tu->next_port = START_PORT;
@@ -197,8 +197,8 @@ PJ_DEF(pj_status_t) pj_stun_turn_usage_create(pj_stun_server *srv,
pj_bzero(&sess_cb, sizeof(sess_cb));
sess_cb.on_send_msg = &tu_sess_on_send_msg;
sess_cb.on_rx_request = &tu_sess_on_rx_request;
- status = pj_stun_session_create(si->cfg, "turns%p", &sess_cb, PJ_FALSE,
- &tu->default_session);
+ status = pj_stun_session_create(&si->stun_cfg, "turns%p", &sess_cb,
+ PJ_FALSE, &tu->default_session);
if (status != PJ_SUCCESS) {
pj_stun_usage_destroy(tu->usage);
return status;
@@ -933,13 +933,13 @@ static pj_status_t client_handle_allocate_req(struct turn_client *client,
}
/* Process REQUESTED-IP attribute */
- if (a_rip && a_rip->addr.addr.sa_family != PJ_AF_INET) {
+ if (a_rip && a_rip->sockaddr.addr.sa_family != PJ_AF_INET) {
client_respond(client, msg, PJ_STUN_SC_INVALID_IP_ADDR, NULL,
src_addr, src_addr_len);
return PJ_SUCCESS;
} else if (a_rip) {
- req_addr.sin_addr.s_addr = a_rip->addr.ipv4.sin_addr.s_addr;
+ req_addr.sin_addr.s_addr = a_rip->sockaddr.ipv4.sin_addr.s_addr;
}
/* Process REQUESTED-PORT-PROPS attribute */
@@ -1106,7 +1106,7 @@ static pj_status_t client_handle_sad(struct turn_client *client,
/* Remote active destination needs to be cleared */
client->active_peer = NULL;
- } else if (a_raddr->addr.addr.sa_family != PJ_AF_INET) {
+ } else if (a_raddr->sockaddr.addr.sa_family != PJ_AF_INET) {
/* Bad request (not IPv4) */
client_respond(client, msg, PJ_STUN_SC_BAD_REQUEST, NULL,
src_addr, src_addr_len);
@@ -1125,9 +1125,9 @@ static pj_status_t client_handle_sad(struct turn_client *client,
pj_uint32_t hval = 0;
/* Add a new peer/permission if we don't have one for this address */
- peer = client_get_peer(client, &a_raddr->addr.ipv4, &hval);
+ peer = client_get_peer(client, &a_raddr->sockaddr.ipv4, &hval);
if (peer==NULL) {
- peer = client_add_peer(client, &a_raddr->addr.ipv4, hval);
+ peer = client_add_peer(client, &a_raddr->sockaddr.ipv4, hval);
}
/* Set active destination */
@@ -1172,7 +1172,7 @@ static pj_status_t client_handle_send_ind(struct turn_client *client,
/* REMOTE-ADDRESS not present, discard packet */
return PJ_SUCCESS;
- } else if (a_raddr->addr.addr.sa_family != PJ_AF_INET) {
+ } else if (a_raddr->sockaddr.addr.sa_family != PJ_AF_INET) {
/* REMOTE-ADDRESS present but not IPv4, discard packet */
return PJ_SUCCESS;
@@ -1195,13 +1195,13 @@ static pj_status_t client_handle_send_ind(struct turn_client *client,
}
/* Add to peer table if necessary */
- if (client_get_peer(client, &a_raddr->addr.ipv4, &hval)==NULL)
- client_add_peer(client, &a_raddr->addr.ipv4, hval);
+ if (client_get_peer(client, &a_raddr->sockaddr.ipv4, &hval)==NULL)
+ client_add_peer(client, &a_raddr->sockaddr.ipv4, hval);
/* Send the packet */
pj_ioqueue_sendto(client->key, &client->pkt_write_key,
data, &datalen, 0,
- &a_raddr->addr.ipv4, sizeof(a_raddr->addr.ipv4));
+ &a_raddr->sockaddr.ipv4, sizeof(pj_sockaddr_in));
return PJ_SUCCESS;
}