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:[email protected]';

$params[]= '.';

$params[]= '.';

$params[]= "From: sip:xxx.xx.xxx.xxx\r\nTo:
<sip:[email protected]>\r\nEvent: reboot_now\r\nContact:
<sip:dae...@!!>\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

 

_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

Reply via email to