JSIP-SDP消息的StringMsgParser,消息长度为Content-Lenght = 0且\ r \ n \ r \ n

时间:2018-11-19 17:08:33

标签: sip sdp jain-sip

更改 SDP 邮件包含

的情况下,我遇到了问题
  • 内容长度:0
  • \ r \ n \ r \ n 在邮件末尾
  • 严格设置为 true

在这种情况下,JSIP库的StringMsgParser方法不会检测到错误消息。举一个例子:

INVITE sip:mrwhite@10.101.5.120 SIP/2.0 
From: \"company\" <sip:company@10.101.6.120>;tag=35b8d8a74ca0f4e34e0adfa7_F10.101.6.120
To: sip:mrwhite@10.101.5.120
Call-ID: f_169eac17a017b0a4e0adfa8_I@10.101.6.120
CSeq: 15 INVITE
Via: SIP/2.0/UDP 10.101.6.120;branch=z9hG4bKf_169eac12baa17054e0adfb3_I
Content-Length: 0
Max-Forwards: 70
Contact: sip:company@10.101.6.120;transport=udp
Content-Type: application/sdp
User-Agent: SIP
Supported: replaces

v=0
o=sip:company@10.101.6.120 1 16 IN IP4 10.101.6.120
s=sip:company@10.101.6.120
c=IN IP4 10.101.6.120
t=0 0
m=audio 5000 RTP/AVP 0 8 18 4 120
a=rtpmap:0 PCMU/8000/1
a=rtpmap:8 PCMA/8000/1
a=rtpmap:18 G729/8000/1
a=fmtp:18 annexb=no
a=rtpmap:4 G723/8000/1
a=rtpmap:120 telephone-event/8000/1
"\r\n at the end"

是否需要进行任何设置,或者是库中有故障?

StringMsgParser.java处的StringMsgParser代码

// Check for content legth header
    if (readBody && message.getContentLength() != null ) {
      if ( message.getContentLength().getContentLength() != 0) {
          int bodyLength = msgBuffer.length - i;

          byte[] body = new byte[bodyLength];
          System.arraycopy(msgBuffer, i, body, 0, bodyLength);
          message.setMessageContent(body,!strict,computeContentLengthFromMessage,message.getContentLength().getContentLength());
       } else if (!computeContentLengthFromMessage && message.getContentLength().getContentLength() == 0 & strict) {
           String last4Chars = new String(msgBuffer, msgBuffer.length - 4, 4);
           if(!"\r\n\r\n".equals(last4Chars)) {
               throw new ParseException("Extraneous characters at the end of the message ",i);
           }
       } 

未检测到错误消息。 有什么必须设置的,或者是库错误吗? 谢谢

0 个答案:

没有答案