Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sip_transport: tcp: Notify app if unable to keep decoding stream #3961

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 59 additions & 32 deletions pjsip/src/pjsip/sip_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -2156,41 +2156,68 @@ PJ_DEF(pj_ssize_t) pjsip_tpmgr_receive_packet( pjsip_tpmgr *mgr,

msg_status = pjsip_find_msg(current_pkt, remaining_len, PJ_FALSE,
&msg_fragment_size);
if (msg_status != PJ_SUCCESS) {
if (remaining_len == PJSIP_MAX_PKT_LEN) {
mgr->on_rx_msg(mgr->endpt, PJSIP_ERXOVERFLOW, rdata);

/* Notify application about the message overflow */
if (mgr->tp_drop_data_cb) {
pjsip_tp_dropped_data dd;
pj_bzero(&dd, sizeof(dd));
dd.tp = tr;
dd.data = current_pkt;
dd.len = msg_fragment_size;
dd.status = PJSIP_ERXOVERFLOW;
(*mgr->tp_drop_data_cb)(&dd);
}

if (rdata->tp_info.transport->idle_timer.id ==
INITIAL_IDLE_TIMER_ID)
{
/* We are not getting the first valid SIP message
* as expected, close the transport.
*/
PJ_LOG(4, (THIS_FILE, "Unexpected data was received "\
"while waiting for a valid initial SIP messages. "\
"Shutting down transport %s",
rdata->tp_info.transport->obj_name));

pjsip_transport_shutdown(rdata->tp_info.transport);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@trengginas I added the transport_shutdown in the new extended code path because I saw in the other code path it was already being done. So not sure if then this path was wrong then?
Let me know whether you want to merge as it, drop the pjsip_transport_shutdown() from the new path or from both paths.

}

/* Exhaust all data. */
return rdata->pkt_info.len;
} else {
switch (msg_status) {
case PJ_SUCCESS:
/* continue below */
break;
case PJSIP_EPARTIALMSG:
if (remaining_len != PJSIP_MAX_PKT_LEN) {
/* Not enough data in packet. */
return total_processed;
}
mgr->on_rx_msg(mgr->endpt, PJSIP_ERXOVERFLOW, rdata);
/* Notify application about the message overflow */
if (mgr->tp_drop_data_cb) {
pjsip_tp_dropped_data dd;
pj_bzero(&dd, sizeof(dd));
dd.tp = tr;
dd.data = current_pkt;
dd.len = msg_fragment_size;
dd.status = PJSIP_ERXOVERFLOW;
(*mgr->tp_drop_data_cb)(&dd);
}

if (rdata->tp_info.transport->idle_timer.id ==
INITIAL_IDLE_TIMER_ID)
{
/* We are not getting the first valid SIP message
* as expected, close the transport.
*/
PJ_LOG(4, (THIS_FILE, "Unexpected data was received "\
"while waiting for a valid initial SIP messages. "\
"Shutting down transport %s",
rdata->tp_info.transport->obj_name));

pjsip_transport_shutdown(rdata->tp_info.transport);
}
/* Exhaust all data. */
return rdata->pkt_info.len;
case PJSIP_EMISSINGHDR:
case PJSIP_EINVALIDHDR:
default:
{
char errbuf[128];
pj_str_t errstr;

errstr = pjsip_strerror(msg_status, errbuf, sizeof(errbuf) - 1);
errstr.ptr[errstr.slen] = '\0';
PJ_LOG(1, (THIS_FILE, "%s Unable to match whole message: %s",
rdata->tp_info.transport->obj_name, errstr.ptr));

mgr->on_rx_msg(mgr->endpt, msg_status, rdata);
/* Notify application about the missing header. */
if (mgr->tp_drop_data_cb) {
pjsip_tp_dropped_data dd;
pj_bzero(&dd, sizeof(dd));
dd.tp = tr;
dd.data = current_pkt;
dd.len = msg_fragment_size;
dd.status = msg_status;
(*mgr->tp_drop_data_cb)(&dd);
}

return rdata->pkt_info.len;
}
}
}

Expand Down
Loading