Module: sip-router Branch: master Commit: 682f002698c761c5570e587db5c48653668a1bb8 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=682f0026...
Author: Peter Dunkley peter.dunkley@crocodile-rcs.com Committer: Peter Dunkley peter.dunkley@crocodile-rcs.com Date: Thu Oct 25 21:34:23 2012 +0100
modules/msrp: Updated example in README
- Use new pv_www_authenticate() variant to pass in $msrp(method) - Send responses to SEND that we are relaying to clients - Handle REPORTS as end-to-end requests (that are not responded to) - Send 501 for requests that are not AUTH, SEND, or REPORT
---
modules/msrp/README | 34 +++++++++++++++++++--------------- modules/msrp/doc/msrp_admin.xml | 34 +++++++++++++++++++--------------- 2 files changed, 38 insertions(+), 30 deletions(-)
diff --git a/modules/msrp/README b/modules/msrp/README index cc778fd..22a583b 100644 --- a/modules/msrp/README +++ b/modules/msrp/README @@ -432,11 +432,8 @@ event_route[msrp:frame-in] { if(msrp_is_reply()) { msrp_relay(); - exit; } - - # handle AUTH MSRP requests - if($msrp(method)=="AUTH") + else if($msrp(method)=="AUTH") { if($msrp(nexthops)>0) { @@ -447,12 +444,13 @@ event_route[msrp:frame-in] { # frame for local server - send Use-Path # -- passwd can be loaded from DB based on $au $var(passwd) = "xyz123"; - if(!pv_www_authenticate("myrealm", "$var(passwd)", "0")) + if(!pv_www_authenticate("myrealm", "$var(passwd)", "0", + "$msrp(method)")) { if(auth_get_www_authenticate("myrealm", "1", - "$var(wauth)")) + "$var(wauth)")) { - msrp_reply("401", "Authorization Required", + msrp_reply("401", "Unauthorized", "$var(wauth)"); } else { msrp_reply("500", "Server Error"); @@ -485,14 +483,15 @@ event_route[msrp:frame-in] { + $var(sessid) + ";tcp\r\n" + "Expires: " + $var(expires) + "\r\n"; msrp_reply("200", "OK", "$var(headers)"); - exit; } - - if($msrp(method)=="SEND") + else if($msrp(method)=="SEND" || $msrp(method)=="REPORT") { if($msrp(nexthops)>1) { - msrp_reply("200", "Received"); + if ($msrp(method)!="REPORT") + { + msrp_reply("200", "OK"); + } msrp_relay(); exit; } @@ -500,17 +499,22 @@ event_route[msrp:frame-in] { if($sht(msrp=>$var(sessid)::srcaddr) == $null) { # one more hop, but we don't have address in htable - msrp_reply("481", "No Such Session"); + msrp_reply("481", "Session-does-not-exist"); exit; } + else if($msrp(method)!="REPORT") + { + msrp_reply("200", "OK"); + } msrp_relay_flags("1"); msrp_set_dst("$sht(msrp=>$var(sessid)::srcaddr)", "$sht(msrp=>$var(sessid)::srcsock)"); msrp_relay(); - exit; } - - msrp_relay(); + else + { + msrp_reply("501", "Request-method-not-understood"); + } }
... diff --git a/modules/msrp/doc/msrp_admin.xml b/modules/msrp/doc/msrp_admin.xml index 0b20bc8..1422e8e 100644 --- a/modules/msrp/doc/msrp_admin.xml +++ b/modules/msrp/doc/msrp_admin.xml @@ -477,11 +477,8 @@ event_route[msrp:frame-in] { if(msrp_is_reply()) { msrp_relay(); - exit; } - - # handle AUTH MSRP requests - if($msrp(method)=="AUTH") + else if($msrp(method)=="AUTH") { if($msrp(nexthops)>0) { @@ -492,12 +489,13 @@ event_route[msrp:frame-in] { # frame for local server - send Use-Path # -- passwd can be loaded from DB based on $au $var(passwd) = "xyz123"; - if(!pv_www_authenticate("myrealm", "$var(passwd)", "0")) + if(!pv_www_authenticate("myrealm", "$var(passwd)", "0", + "$msrp(method)")) { if(auth_get_www_authenticate("myrealm", "1", - "$var(wauth)")) + "$var(wauth)")) { - msrp_reply("401", "Authorization Required", + msrp_reply("401", "Unauthorized", "$var(wauth)"); } else { msrp_reply("500", "Server Error"); @@ -530,14 +528,15 @@ event_route[msrp:frame-in] { + $var(sessid) + ";tcp\r\n" + "Expires: " + $var(expires) + "\r\n"; msrp_reply("200", "OK", "$var(headers)"); - exit; } - - if($msrp(method)=="SEND") + else if($msrp(method)=="SEND" || $msrp(method)=="REPORT") { if($msrp(nexthops)>1) { - msrp_reply("200", "Received"); + if ($msrp(method)!="REPORT") + { + msrp_reply("200", "OK"); + } msrp_relay(); exit; } @@ -545,17 +544,22 @@ event_route[msrp:frame-in] { if($sht(msrp=>$var(sessid)::srcaddr) == $null) { # one more hop, but we don't have address in htable - msrp_reply("481", "No Such Session"); + msrp_reply("481", "Session-does-not-exist"); exit; } + else if($msrp(method)!="REPORT") + { + msrp_reply("200", "OK"); + } msrp_relay_flags("1"); msrp_set_dst("$sht(msrp=>$var(sessid)::srcaddr)", "$sht(msrp=>$var(sessid)::srcsock)"); msrp_relay(); - exit; } - - msrp_relay(); + else + { + msrp_reply("501", "Request-method-not-understood"); + } } ]]> ...