--- res/res_srtp.c (revision 388769) +++ res/res_srtp.c (working copy) @@ -48,6 +48,9 @@ #include "asterisk/rtp_engine.h" #include "asterisk/astobj2.h" +#include +#include + struct ast_srtp { struct ast_rtp_instance *rtp; struct ao2_container *policies; @@ -401,9 +404,33 @@ return -1; } + /* debug part */ + if (buf) { + srtp_hdr_t *hdr = (srtp_hdr_t *) buf; + srtp_stream_ctx_t *stream = srtp_get_stream(srtp->session, hdr->ssrc); + if (stream) { + rdbx_t *rdbx = &stream->rtp_rdbx; + if (rdbx) { + xtd_seq_num_t *pi = &rdbx->index; + if (pi) { + if (res == err_status_auth_fail) { + ast_log(AST_LOG_NOTICE, "SRTP unprotect gave %s, ROC 0x%012lx SEQ %i\n", srtp_errstr(res), stream->rtp_rdbx.index, ntohs(hdr->seq)); + //stream->rtp_services = sec_serv_conf; /* uncomment to turn-off authentication-check */ + } else if (0x0000 == ntohs(hdr->seq)) { + ast_log(AST_LOG_NOTICE, "SRTP unprotect gave %s, ROC 0x%012lx SEQ %i\n", srtp_errstr(res), stream->rtp_rdbx.index, ntohs(hdr->seq)); + } + } + } + } + } /* end of debug */ + if (res != err_status_ok && res != err_status_replay_fail ) { if ((srtp->warned >= 10) && !((srtp->warned - 10) % 100)) { - ast_log(AST_LOG_WARNING, "SRTP unprotect failed with: %s %d\n", srtp_errstr(res), srtp->warned); + if (rtcp) { + ast_log(AST_LOG_WARNING, "SRTcP unprotect failed with: %s %d\n", srtp_errstr(res), srtp->warned); + } else { + ast_log(AST_LOG_WARNING, "SRTP unprotect failed with: %s %d\n", srtp_errstr(res), srtp->warned); + } srtp->warned = 11; } else { srtp->warned++; --- res/res_rtp_asterisk.c (revision 401620) +++ res/res_rtp_asterisk.c (working copy) @@ -1779,7 +1779,7 @@ /* Set default parameters on the newly created RTP structure */ rtp->ssrc = ast_random(); - rtp->seqno = ast_random() & 0xffff; + rtp->seqno = 65285; /* sequence number (SEQ) wraps after five seconds, roll over counter (ROC) gets increased */ rtp->strict_rtp_state = (strictrtp ? STRICT_RTP_LEARN : STRICT_RTP_OPEN); if (strictrtp) { rtp_learning_seq_init(&rtp->rtp_source_learn, (uint16_t)rtp->seqno); @@ -3732,8 +3732,10 @@ ast_log(LOG_WARNING, "scheduling RTCP transmission failed.\n"); } } - if ((int)rtp->lastrxseqno - (int)seqno > 100) /* if so it would indicate that the sender cycled; allow for misordering */ + if ((int)rtp->lastrxseqno - (int)seqno > 100) { /* if so it would indicate that the sender cycled; allow for misordering */ rtp->cycles += RTP_SEQ_MOD; + ast_log(LOG_NOTICE, "RTP-ROC %i, current/received RTP-SEQ %i, last seen/received RTP-SEQ %i\n", rtp->cycles >> 16, seqno, rtp->lastrxseqno); + } prev_seqno = rtp->lastrxseqno; rtp->lastrxseqno = seqno;