[OpenSIPS-Users] Rebooting a Linksys through OpenSIPS
Bogdan-Andrei Iancu
bogdan at voice-system.ro
Tue May 12 10:32:57 CEST 2009
Hi Matti,
Well, it should be possible - you do a 2 steps interaction with the Linkys :
- first send the NOTIFY via the t_uac_dlg MI command and get from the
result the auth challenge (in the MI command response you do have access
to the SIP reply)
- generate a new NOTIFY request including the Authorize header
calculated based on the received challenge.
Regards,
Bogdan
Matti Zemack wrote:
>
> 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//
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
More information about the Users
mailing list