0

我想删除必须和联系字段为空的sip数据

INVITE sip:******************* SIP/2.0

Record-Route:

Via: SIP/2.0/UDP *********;branch=z9hG4bK0e44.f7bd2db2.0

Via: SIP/2.0/UDP ************:5060;received=*********;branch=z9hG4bK78f0df76;rport=1122

Max-Forwards: 69

From: "1014" ;tag=as2fff3730

To:

Contact:

Call-ID: **********@*********

CSeq: 103 INVITE

User-Agent: Asterisk PBX 1.6.2.9-2ubuntu2.1

Date: Wed, 09 Oct 2013 15:16:20 GMT

Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO

Supported: replaces, timer

Content-Type: application/sdp

Content-Length: 311 

我正在使用opensips(处理sip数据包的代码在opensips.cfg文件中)。我怎样才能识别这些数据包并丢弃它们?

编辑:相应的解析消息是:

Oct  9 17:16:00 voip /usr/local/sbin/opensips[32325]: ERROR:core:parse_first_line: bad request first line

Oct  9 17:16:00 voip /usr/local/sbin/opensips[32325]: ERROR:core:parse_first_line: at line 0 char 42: 

Oct  9 17:16:00 voip /usr/local/sbin/opensips[32325]: ERROR:core:parse_first_line: parsed so far: INVITE sip:***********************:5060

Oct  9 17:16:00 voip /usr/local/sbin/opensips[32325]: INFO:core:parse_first_line: bad message

 > sendrecv 0-16lephone-event/8000 *************SUBSCRIBE, NOTIFY, INFOg: message=<INVITE sip:*************:5060 SIP/2.0

Oct  9 17:16:00 voip /usr/local/sbin/opensips[32325]: ERROR:core:receive_msg: parse_msg failed

Oct  9 17:16:04 voip /usr/local/sbin/opensips[32303]: ERROR:core:parse_first_line: bad request first line

Oct  9 17:16:04 voip /usr/local/sbin/opensips[32303]: ERROR:core:parse_first_line: at line 0 char 42: 

Oct  9 17:16:04 voip /usr/local/sbin/opensips[32303]: ERROR:core:parse_first_line: parsed so far: INVITE sip:****************:5060

Oct  9 17:16:04 voip /usr/local/sbin/opensips[32303]: INFO:core:parse_first_line: bad message

 > sendrecv 0-16lephone-event/*******************SUBSCRIBE, NOTIFY, INFOg: message=<INVITE sip:*****************:5060 SIP/2.0

Oct  9 17:16:04 voip /usr/local/sbin/opensips[32303]: ERROR:core:receive_msg: parse_msg failed
4

1 回答 1

0

您可以使用此模块识别 sip 数据包的标头

http://www.opensips.org/html/docs/modules/1.6.x/textops.html

或使用核心变量 hdr

$(hdr(name)[N])

之后退出路由,不会发送数据包。

于 2013-10-11T22:39:51.273 回答