Reputation: 11
In my scenario UAS receives two Via headers. Using [last_Via:] it replies 183, 200 OK for subsequent PRACK but for 180 Ringing and 200 OK for the original INVITE it needs those two Via headers. How do I store them in a variable so that I can use here ?
Approach that I goggled:
<ereg regexp="[Vv][Ii][Aa][ ]*:[ ](.*)$" search_in="msg" check_it="true" assign_to="1"/>
$1= It has both the Via headers but also the rest of the message including SDP.
Upvotes: 1
Views: 2557
Reputation: 11
Do this right before your <send>
:
<nop>
<action>
<assignstr assign_to="lvia" value="[last_Via:]" />
<ereg regexp="[Vv][Ii][Aa]: (.*), (.*)" search_in="var" variable="lvia" assign_to="5,6,7"/>
<exec command="echo Via1: [$5], via2: [$6], via3: [$7]"/>
</action>
</nop>
Then use the values store in variables 6 and 7.
This works for 2 Vias, you may need to adapt if you need to handle more.
Upvotes: 0
Reputation: 1425
<nop>
<action>
<assignstr assign_to="1" value="[last_Via:]" />
</action>
</nop>
Otherwise, using your regex approach, you should be able to consume everything until the next CR LF characters with something like: "[^\r\n]*\r\n"
.
Upvotes: 3