[OpenSIPS-Users] Rebooting a Linksys through OpenSIPS

Matti Zemack Matti.Zemack at rtcfactory.com
Mon May 11 10:01:21 CEST 2009


Hi all,

 

I'm still dipping my toes in deep waters with OpenSips 1.5...

And I've come across a small problem. I would like to reboot Linksys ATA
(PAP2 etc...) using OpenSIPS.

Can this maybe be done?

 

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?

 

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. J

 

 

 

 

<?

# Using the XML-RPC extension to format the XML package

echo("<plaintext>"); #For pretty browser output

$params[]= "NOTIFY";

$params[]= 'sip:1001 at 172.16.245.128';

$params[]= '.';

$params[]= '.';

$params[]= "From: sip:xxx.xx.xxx.xxx\r\nTo:
<sip:1001 at xxx.xx.xxx.xxx>\r\nEvent: reboot_now\r\nContact:
<sip:daemon@!!>\r\nContent-Length: 0\r\nContent-Type: text/plain\r\n";

 

$request = xmlrpc_encode_request("t_uac_dlg", $params);

#$request = xmlrpc_encode_request("which", NULL);  # For testing of
XMLRPC

 

# Using the cURL extension to send it off, first creating a custom
header block

$header[] = "Host: 127.0.0.1";

$header[] = "Connection: close";

$header[] = "User-Agent: OpenSIPg XML_RPC Client";

$header[] = "Content-type: text/xml";

 

print_r($request); #debug

echo("\n\n"); #debug

print_r($header); #debug

 

$ch = curl_init();

curl_setopt( $ch, CURLOPT_URL, "http://127.0.0.1/RPC2"); # URL to post
to

curl_setopt( $ch, CURLOPT_PORT, "8080"); # URL to post to

curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); # return into a variable

curl_setopt( $ch, CURLOPT_HTTPHEADER, $header ); # custom headers, see
above

curl_setopt( $ch, CURLOPT_POSTFIELDS, $request );

curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'POST' ); # This POST is
special, and uses its specified Content-type

$result = curl_exec( $ch ); # run!

curl_close($ch); 

echo $result;

?>

 

 

Best Regards,

Matti Zemack, Stockholm, Sweden

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.opensips.org/pipermail/users/attachments/20090511/bff448ae/attachment.htm 


More information about the Users mailing list