summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-09-22 18:42:09 +0000
committerBenny Prijono <bennylp@teluu.com>2006-09-22 18:42:09 +0000
commit0228f9f0db50b781d00dc3f5936b4a99504fddc7 (patch)
treec97d868ac360d1ad19fede3227c7e78ee18203e8
parente7e08fc3b6b09d3dba5dce0307dfc0dbad5f9aef (diff)
Handle incoming empty packets sent by some user agents (to refresh NAT)
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@735 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjsip/src/pjsip/sip_parser.c7
-rw-r--r--pjsip/src/pjsip/sip_transport.c13
2 files changed, 17 insertions, 3 deletions
diff --git a/pjsip/src/pjsip/sip_parser.c b/pjsip/src/pjsip/sip_parser.c
index 48ce50b1..b3f13bdb 100644
--- a/pjsip/src/pjsip/sip_parser.c
+++ b/pjsip/src/pjsip/sip_parser.c
@@ -908,6 +908,13 @@ static pjsip_msg *int_parse_msg( pjsip_parse_ctx *ctx,
pj_scan_get_newline(scanner);
}
+ /* Check if we still have valid packet.
+ * Sometimes endpoints just send blank (CRLF) packets just to keep
+ * NAT bindings open.
+ */
+ if (pj_scan_is_eof(scanner))
+ return NULL;
+
/* Parse request or status line */
if (pj_scan_stricmp_alnum( scanner, PJSIP_VERSION, 7) == 0) {
msg = pjsip_msg_create(pool, PJSIP_RESPONSE_MSG);
diff --git a/pjsip/src/pjsip/sip_transport.c b/pjsip/src/pjsip/sip_transport.c
index 909632e8..c4ae9659 100644
--- a/pjsip/src/pjsip/sip_transport.c
+++ b/pjsip/src/pjsip/sip_transport.c
@@ -1083,7 +1083,7 @@ PJ_DEF(pj_ssize_t) pjsip_tpmgr_receive_packet( pjsip_tpmgr *mgr,
while (err != &rdata->msg_info.parse_err) {
int len;
len = pj_ansi_snprintf(tmp.ptr+tmp.slen, sizeof(buf)-tmp.slen,
- ": %s exception when parsing %.*s "
+ ": %s exception when parsing '%.*s' "
"header on line %d col %d",
pj_exception_id_name(err->except_code),
(int)err->hname.slen, err->hname.ptr,
@@ -1094,16 +1094,23 @@ PJ_DEF(pj_ssize_t) pjsip_tpmgr_receive_packet( pjsip_tpmgr *mgr,
err = err->next;
}
- PJ_LOG(1, (THIS_FILE,
- "Error processing %d bytes packet from %s:%d %.*s:\n"
+ /* Only print error message if there's error.
+ * Sometimes we receive blank packets (packets with only CRLF)
+ * which were sent to keep NAT bindings.
+ */
+ if (tmp.slen) {
+ PJ_LOG(1, (THIS_FILE,
+ "Error processing %d bytes packet from %s %s:%d %.*s:\n"
"%.*s\n"
"-- end of packet.",
msg_fragment_size,
+ rdata->tp_info.transport->type_name,
rdata->pkt_info.src_name,
rdata->pkt_info.src_port,
(int)tmp.slen, tmp.ptr,
(int)msg_fragment_size,
rdata->msg_info.msg_buf));
+ }
goto finish_process_fragment;
}