2012-05-12 4 views
0

J'ai un message SIP. Et je dois prendre un paramètre ce message SIP.Rechercher un paramètre avec regex

SIP Message:

INVITE sip:[email protected]:5002 SIP/2.0 
Via: SIP/2.0/UDP 192.168.1.33:5060;branch=z9hG4bK-d8754z-be6b8b6e6a23b03f-1---d8754z-;rport 
Max-Forwards: 70 
Contact: <sip:[email protected]:5060> 
To: <sip:[email protected]:5060> 
From: "102"<sip:[email protected]:5060>;tag=653bd245 
Call-ID: NjY1NzU1YTZhZjIzMTYwM2MxMWY5YWNlZDM1MmEwZTg. 
CSeq: 1 INVITE 
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REGISTER, SUBSCRIBE, NOTIFY, REFER, INFO, MESSAGE 
Content-Type: application/sdp 
Supported: replaces 
User-Agent: 3CXPhoneSystem 10.0.23053.0 
Content-Length: 855 

v=0 
o=3cxPS 257748369408 287175606273 IN IP4 192.168.1.33 
s=3cxPS Audio call 
c=IN IP4 192.168.1.33 
t=0 0 
m=audio 5007 RTP/AVP 8 0 101 98 9 3 100 97 103 15 4 104 105 106 107 18 
a=rtpmap:8 PCMA/8000 
a=rtpmap:0 PCMU/8000 
a=rtpmap:101 telephone-event/8000 
a=rtpmap:98 iLBC/8000 
a=fmtp:98 mode=30 
a=rtpmap:9 G722/8000 
a=fmtp:9 bitrate=64000 
a=rtpmap:3 GSM/8000 
a=rtpmap:100 SPEEX/16000 
a=rtpmap:97 SPEEX/8000 
a=rtpmap:103 L16/8000 
a=rtpmap:15 G728/8000 
a=rtpmap:4 G723/8000 
a=rtpmap:104 G726-16/8000 
a=rtpmap:105 G726-24/8000 
a=rtpmap:106 G726-32/8000 
a=rtpmap:107 G726-40/8000 
a=rtpmap:18 G729/8000 
a=fmtp:18 annexb=no 
a=sendrecv 
m=video 5009 RTP/AVP 102 99 34 
a=rtpmap:102 H263-1998/90000 
a=fmtp:102 QCIF=1;CIF=1 
a=rtpmap:99 H264/90000 
a=fmtp:99 packetization-mode=1 
a=rtpmap:34 H263/90000 
a=fmtp:34 QCIF=1;CIF=1 
a=sendrecv 

dans le message, dans 'De' paramètre ' "102"' place par.

Et dans le paramètre 'Contact', '102 @ 192.168.1.33' par.

Comment puis-je faire pour cela?

+0

vous avez probablement une pile sip pour le gérer (je veux dire, mettre à jour le nom de l'appelant) –

Répondre

0

Voici les regex:

From: +"(.+?)" 

Cela placerait 102 dans le groupe capture 1.

Contact: +<sip:(.+)?:.+> 

Cela placerait '[email protected]' dans le groupe 1. capture