diff options
-rw-r--r-- | pjsip/src/pjsip/sip_parser.c | 7 | ||||
-rw-r--r-- | pjsip/src/pjsip/sip_transport.c | 13 |
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; } |