Commit 8bca6c3a authored by Sébastien Blin's avatar Sébastien Blin Committed by Andreas Traczyk

pjproject: handle WSAECONNRESET for stun message

Change-Id: I06b505620ec980af97a5ee5b8526b5a1efdd4bee
parent c9670a0e
...@@ -28,7 +28,7 @@ on behalf of Savoir-faire Linux. ...@@ -28,7 +28,7 @@ on behalf of Savoir-faire Linux.
pjnath/src/pjnath-test/concur_test.c | 5 +- pjnath/src/pjnath-test/concur_test.c | 5 +-
pjnath/src/pjnath-test/sess_auth.c | 14 +- pjnath/src/pjnath-test/sess_auth.c | 14 +-
pjnath/src/pjnath-test/stun_sock_test.c | 7 +- pjnath/src/pjnath-test/stun_sock_test.c | 7 +-
pjnath/src/pjnath/ice_session.c | 490 +++++++++-- pjnath/src/pjnath/ice_session.c | 505 +++++++++--
pjnath/src/pjnath/ice_strans.c | 745 +++++++++++++--- pjnath/src/pjnath/ice_strans.c | 745 +++++++++++++---
pjnath/src/pjnath/nat_detect.c | 7 +- pjnath/src/pjnath/nat_detect.c | 7 +-
pjnath/src/pjnath/stun_session.c | 15 +- pjnath/src/pjnath/stun_session.c | 15 +-
...@@ -41,7 +41,7 @@ on behalf of Savoir-faire Linux. ...@@ -41,7 +41,7 @@ on behalf of Savoir-faire Linux.
pjnath/src/pjturn-srv/server.c | 2 +- pjnath/src/pjturn-srv/server.c | 2 +-
pjsip-apps/src/samples/icedemo.c | 116 ++- pjsip-apps/src/samples/icedemo.c | 116 ++-
pjsip/src/pjsua-lib/pjsua_core.c | 2 +- pjsip/src/pjsua-lib/pjsua_core.c | 2 +-
21 files changed, 2429 insertions(+), 409 deletions(-) 21 files changed, 2444 insertions(+), 409 deletions(-)
diff --git a/pjnath/include/pjnath/ice_session.h b/pjnath/include/pjnath/ice_session.h diff --git a/pjnath/include/pjnath/ice_session.h b/pjnath/include/pjnath/ice_session.h
index 8971220f0..4cccd7c64 100644 index 8971220f0..4cccd7c64 100644
...@@ -648,7 +648,7 @@ index fff4fad26..e7f8b84eb 100644 ...@@ -648,7 +648,7 @@ index fff4fad26..e7f8b84eb 100644
if (status != PJ_SUCCESS && status != PJ_EPENDING) { if (status != PJ_SUCCESS && status != PJ_EPENDING) {
app_perror(" error: server sending data", status); app_perror(" error: server sending data", status);
diff --git a/pjnath/src/pjnath/ice_session.c b/pjnath/src/pjnath/ice_session.c diff --git a/pjnath/src/pjnath/ice_session.c b/pjnath/src/pjnath/ice_session.c
index 2a4125bc5..3f8c03cd2 100644 index 2a4125bc5..d4e20a508 100644
--- a/pjnath/src/pjnath/ice_session.c --- a/pjnath/src/pjnath/ice_session.c
+++ b/pjnath/src/pjnath/ice_session.c +++ b/pjnath/src/pjnath/ice_session.c
@@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
...@@ -1129,7 +1129,7 @@ index 2a4125bc5..3f8c03cd2 100644 ...@@ -1129,7 +1129,7 @@ index 2a4125bc5..3f8c03cd2 100644
} }
pj_grp_lock_release(ice->grp_lock); pj_grp_lock_release(ice->grp_lock);
@@ -2181,6 +2393,178 @@ static pj_status_t on_stun_send_msg(pj_stun_session *sess, @@ -2181,6 +2393,193 @@ static pj_status_t on_stun_send_msg(pj_stun_session *sess,
return status; return status;
} }
...@@ -1231,13 +1231,28 @@ index 2a4125bc5..3f8c03cd2 100644 ...@@ -1231,13 +1231,28 @@ index 2a4125bc5..3f8c03cd2 100644
+ PJ_FALSE, PJ_FALSE, &rcand->addr, + PJ_FALSE, PJ_FALSE, &rcand->addr,
+ pj_sockaddr_get_len(&rcand->addr), + pj_sockaddr_get_len(&rcand->addr),
+ check->tdata); + check->tdata);
+ if (status_send_msg == PJ_EBUSY /* EBUSY */) { +
+ if ((status_send_msg == 120104 || status_send_msg == 130054)/* CONNECTION RESET BY PEER */
+ && rcand->type == PJ_ICE_CAND_TYPE_RELAYED) {
+ /**
+ * This part of the code is triggered when using ICE over TCP via TURN
+ * In fact, the other peer has to authorize this peer to connect to
+ * the relayed candidate. This is done by set_perm from the other case.
+ * But from this side, we can't know if the peer has authorized us. If it's
+ * not the case, the connection will got a CONNECTION RESET BY PEER status.
+ * In this case, we can try to reconnect a bit after and this until the check
+ * reached its timeout.
+ */
+ check->state = PJ_ICE_SESS_CHECK_STATE_NEEDS_RETRY;
+ check_set_state(ice, check,PJ_ICE_SESS_CHECK_STATE_NEEDS_RETRY,
+ status_send_msg);
+ return;
+ } else if (status_send_msg == PJ_EBUSY /* EBUSY */) {
+ check->state = PJ_ICE_SESS_CHECK_STATE_NEEDS_FIRST_PACKET; + check->state = PJ_ICE_SESS_CHECK_STATE_NEEDS_FIRST_PACKET;
+ check_set_state(ice, check, PJ_ICE_SESS_CHECK_STATE_NEEDS_FIRST_PACKET, + check_set_state(ice, check, PJ_ICE_SESS_CHECK_STATE_NEEDS_FIRST_PACKET,
+ status_send_msg); + status_send_msg);
+ return; + return;
+ } + } else if (status_send_msg == 120032 /* BROKEN PIPE */) {
+ if (status_send_msg == 120032 /* BROKEN PIPE */) {
+ check->state = PJ_ICE_SESS_CHECK_STATE_NEEDS_RETRY; + check->state = PJ_ICE_SESS_CHECK_STATE_NEEDS_RETRY;
+ check_set_state(ice, check, PJ_ICE_SESS_CHECK_STATE_NEEDS_RETRY, + check_set_state(ice, check, PJ_ICE_SESS_CHECK_STATE_NEEDS_RETRY,
+ status_send_msg); + status_send_msg);
...@@ -1308,7 +1323,7 @@ index 2a4125bc5..3f8c03cd2 100644 ...@@ -1308,7 +1323,7 @@ index 2a4125bc5..3f8c03cd2 100644
/* This callback is called when outgoing STUN request completed */ /* This callback is called when outgoing STUN request completed */
static void on_stun_request_complete(pj_stun_session *stun_sess, static void on_stun_request_complete(pj_stun_session *stun_sess,
@@ -2411,7 +2795,9 @@ static void on_stun_request_complete(pj_stun_session *stun_sess, @@ -2411,7 +2810,9 @@ static void on_stun_request_complete(pj_stun_session *stun_sess,
&check->lcand->base_addr, &check->lcand->base_addr,
&check->lcand->base_addr, &check->lcand->base_addr,
pj_sockaddr_get_len(&xaddr->sockaddr), pj_sockaddr_get_len(&xaddr->sockaddr),
...@@ -1319,7 +1334,7 @@ index 2a4125bc5..3f8c03cd2 100644 ...@@ -1319,7 +1334,7 @@ index 2a4125bc5..3f8c03cd2 100644
if (status != PJ_SUCCESS) { if (status != PJ_SUCCESS) {
check_set_state(ice, check, PJ_ICE_SESS_CHECK_STATE_FAILED, check_set_state(ice, check, PJ_ICE_SESS_CHECK_STATE_FAILED,
status); status);
@@ -2474,11 +2860,7 @@ static void on_stun_request_complete(pj_stun_session *stun_sess, @@ -2474,11 +2875,7 @@ static void on_stun_request_complete(pj_stun_session *stun_sess,
/* Perform 7.1.2.2.2. Updating Pair States. /* Perform 7.1.2.2.2. Updating Pair States.
* This may terminate ICE processing. * This may terminate ICE processing.
*/ */
...@@ -1332,7 +1347,7 @@ index 2a4125bc5..3f8c03cd2 100644 ...@@ -1332,7 +1347,7 @@ index 2a4125bc5..3f8c03cd2 100644
pj_grp_lock_release(ice->grp_lock); pj_grp_lock_release(ice->grp_lock);
} }
@@ -2673,7 +3055,9 @@ static pj_status_t on_stun_rx_request(pj_stun_session *sess, @@ -2673,7 +3070,9 @@ static pj_status_t on_stun_rx_request(pj_stun_session *sess,
msg_data->has_req_data = PJ_FALSE; msg_data->has_req_data = PJ_FALSE;
/* Send the response */ /* Send the response */
...@@ -1343,7 +1358,7 @@ index 2a4125bc5..3f8c03cd2 100644 ...@@ -1343,7 +1358,7 @@ index 2a4125bc5..3f8c03cd2 100644
src_addr, src_addr_len, tdata); src_addr, src_addr_len, tdata);
@@ -2794,12 +3178,12 @@ static void handle_incoming_check(pj_ice_sess *ice, @@ -2794,12 +3193,12 @@ static void handle_incoming_check(pj_ice_sess *ice,
/* Just get candidate with the highest priority and same transport ID /* Just get candidate with the highest priority and same transport ID
* for the specified component ID in the checklist. * for the specified component ID in the checklist.
*/ */
...@@ -2514,7 +2529,7 @@ index f2b4f7058..ed17b904f 100644 ...@@ -2514,7 +2529,7 @@ index f2b4f7058..ed17b904f 100644
+ return sess ? sess->conn_type : PJ_STUN_TP_UDP; + return sess ? sess->conn_type : PJ_STUN_TP_UDP;
+} +}
diff --git a/pjnath/src/pjnath/stun_sock.c b/pjnath/src/pjnath/stun_sock.c diff --git a/pjnath/src/pjnath/stun_sock.c b/pjnath/src/pjnath/stun_sock.c
index 5fe825cf5..05461676e 100644 index 5fe825cf5..eee81f268 100644
--- a/pjnath/src/pjnath/stun_sock.c --- a/pjnath/src/pjnath/stun_sock.c
+++ b/pjnath/src/pjnath/stun_sock.c +++ b/pjnath/src/pjnath/stun_sock.c
@@ -40,6 +40,36 @@ @@ -40,6 +40,36 @@
...@@ -4112,5 +4127,5 @@ index 474a8d07c..9257f07a4 100644 ...@@ -4112,5 +4127,5 @@ index 474a8d07c..9257f07a4 100644
if (status != PJ_SUCCESS) { if (status != PJ_SUCCESS) {
char errmsg[PJ_ERR_MSG_SIZE]; char errmsg[PJ_ERR_MSG_SIZE];
-- --
2.25.4 2.26.2
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment