<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=SV link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span lang=EN-US>Hi all,<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US>I’m still dipping my toes in deep
waters with OpenSips 1.5…<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>And I’ve come across a small problem.
I would like to reboot Linksys ATA (PAP2 etc…) using OpenSIPS.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>Can this maybe be done?<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US>Basically I use XML-RPC FIFO to send the
SIP command. The problem is that Linksys replies with 401 challenge. Can I, or
is it at all possible to reply to this challenge using OpenSIPS?<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US>Below is my PHP for this request. Note that
I have coded end user IP and no in the PHP as this gives me one less place for
problems. </span><span lang=EN-US style='font-family:Wingdings'>J</span><span
lang=EN-US><o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US><?<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US># Using the XML-RPC extension to format the
XML package<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>echo("<plaintext>"); #For
pretty browser output<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>$params[]= "NOTIFY";<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>$params[]= 'sip:1001@172.16.245.128';<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>$params[]= '.';<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>$params[]= '.';<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>$params[]= "From: sip:xxx.xx.xxx.xxx\r\nTo:
<sip:1001@xxx.xx.xxx.xxx>\r\nEvent: reboot_now\r\nContact:
<sip:daemon@!!>\r\nContent-Length: 0\r\nContent-Type:
text/plain\r\n";<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US>$request =
xmlrpc_encode_request("t_uac_dlg", $params);<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>#$request =
xmlrpc_encode_request("which", NULL); # For testing of XMLRPC<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US># Using the cURL extension to send it off, first
creating a custom header block<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>$header[] = "Host: 127.0.0.1";<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>$header[] = "Connection: close";<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>$header[] = "User-Agent: OpenSIPg
XML_RPC Client";<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>$header[] = "Content-type:
text/xml";<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US>print_r($request); #debug<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>echo("\n\n"); #debug<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>print_r($header); #debug<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US>$ch = curl_init();<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>curl_setopt( $ch, CURLOPT_URL,
"http://127.0.0.1/RPC2"); # URL to post to<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>curl_setopt( $ch, CURLOPT_PORT,
"8080"); # URL to post to<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1
); # return into a variable<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>curl_setopt( $ch, CURLOPT_HTTPHEADER,
$header ); # custom headers, see above<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>curl_setopt( $ch, CURLOPT_POSTFIELDS,
$request );<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>curl_setopt( $ch, CURLOPT_CUSTOMREQUEST,
'POST' ); # This POST is special, and uses its specified Content-type<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>$result = curl_exec( $ch ); # run!<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>curl_close($ch); <o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>echo $result;<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>?><o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='color:#1F497D'>Best Regards,<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='color:#1F497D'>Matti Zemack,
Stockholm, Sweden</span><i><span lang=EN-US style='font-size:9.0pt;color:#7F7F7F'><o:p></o:p></span></i></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
</div>
</body>
</html>