OpenWrt Forum Archive

Topic: Sending SIP messages through netcat not working

The content of this topic has been archived on 17 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,

I'm trying to reboot my sip phone using netcat on my wrt54g running KAMIKAZE (7.07).

For some reason I just can get it to work.

I have the following code below in a file called rebootphone

NOTIFY sip:305@172.23.112.144 SIP/2.0
Via: SIP/2.0/UDP 172.23.3.5:5060;branch=z9hG4bK7b359876
From: "no_callerid" <sip:no_callerid@172.23.3.5>;tag=as78a85cfe
To: <sip:305@172.23.112.144>
Contact: <sip:no_callerid@172.23.3.5>
Call-ID: 015118886c22a1a45cb8833b41abf969@172.23.3.5
CSeq: 102 NOTIFY
User-Agent: Asterisk PBX
Max-Forwards: 70
Event: check-sync
Content-Length: 0

I then try this: cat rebootphone | nc 172.23.112.144 5060

but nothing happens.

However if I do the same thing in putty.  Eg open putty.  Set the hostname to 172.23.112.144 port to 5060 and connection type to raw.  Then when it connects I just paste in the above code and phone reboots.

What am I doing wrong?  I've tried all sorts things, but nothing works.

I am open for other alternatives if people have any.  I have already tried telnet but I can't make that work either.  I read something about being able to write to /dev/tcp or /dev/udp in bash but it seems that /dev/tcp and udp don't exist.

curl might be able to do this for me, but I couldn't figure out how to get it to use http headers from a file.

Any help appreciated.

Thanks,

-Joel

never mind I got it working with bash sockets

#!/bin/bash
exec 3<>/dev/udp/172.23.112.144/5060
cat rebootphone >&3

The discussion might have continued from here.