calling a sip phone - voip

im searching for a simple method to "ping" a sip:user#ip and get back a status like "available for call" , "busy" , "not connected" if the first two require to make his phone ring, thats ok
(optionally if necessary to call them to see the status then it was nice to include a senders number so that i can identify my server on the phone display when its checking the status or to play a short signal .wav in case someone takes up, so that they know what it was)
.....something like sipsak -x 1200 -C random#ownip -s sip:adressee#hisip -vvv...
gives me "406 Not Acceptable without Contact header"
i did not try anything else yet
i already wonder if the sending call still needs to be logged in at an isp then?

You're probably looking for the OPTIONS message. The reply to an OPTIONS does two things - first, it tells you the capabilities of the remote party and second, more importantly, the Status-Code returned is the Status-Code you would get if you'd sent an INVITE.
According to sipsak's documentation you're looking for this:
sipsak -vv -s sip:nobody#foo.bar

SIMPLE will work, but it may be overkill for what you want to do. See http://en.wikipedia.org/wiki/SIMPLE
Of course, not all SIP phones support SIMPLE.

Related

how to make outgoing call from freeswitch and play file after destination answer call?

I want to write a web app that connects to freeswitch and makes outgoing call to some destination number (gateway for landline or internal sip devices) and plays some sounds (may be do some logic in lua script).
After reading freeswitch wiki, I found originate command but it doesn't work for me (I just test for internal sip number - sofia/internal/username#ip ). If originate command can do this, how to use it properly? If there is another way please tell me.
Originate command is used to make the call and bridge command is used to bridge the call. You can call originate command externally by using esl socket.
Examples:
originate {ignore_early_media=true,originate_timeout=60}sofia/gateway/name/number &playback(message)
Refer to this for esl written in node.js
https://github.com/englercj/node-esl
one way that I test and it work is run a lua script from freeswitch console or ESL:(ex "luarun test.lua")
https://freeswitch.org/confluence/display/FREESWITCH/Lua+API+Reference#LuaAPIReference-session:hangupCause
obSession = freeswitch.Session("sofia/192.168.0.4/1002")
-- Check to see if the call was answered
if obSession:ready() then
-- Play file here
else
-- This means the call was not answered ... Check for the reason
local obCause = obSession:hangupCause()
freeswitch.consoleLog("info", "obSession:hangupCause() = " .. obCause )
if ( obCause == "USER_BUSY" ) then -- SIP 486
-- For BUSY you may reschedule the call for later
elseif ( obCause == "NO_ANSWER" ) then
-- Call them back in an hour
elseif ( obCause == "ORIGINATOR_CANCEL" ) then -- SIP 487
-- May need to check for network congestion or problems
else
-- Log these issues
end
end
You can do it very easily from dial plan:
<action function="play-file" data="myfile.wav"/>
You can make the wav play when someone start a call, follow these steps.
Place your wave into your freeswitch/conf folder.
Add the code bellow to your freeswitch/conf/autoload_configs
Run a HTTP server that receives a POST request and returns your dialplan(which tells freeswitch to play your wav).
Make sure your freeswitch/conf/autoload_configs/xml_curl.conf.xml looks like this
<param name="gateway-url" value="http://yourIP:yourServerPort/dialplan.xml" bindings="dialplan"/>
Hope this helps.
you can achieve By using a socket[ESL] application.
https://wiki.freeswitch.org/wiki/Event_Socket_Outbound

poplib mark as seen

I am using poplib in Python 3.3 to fetch emails from a gmail account and everything is working well, except that the mails are not marked as read after retrieving them with the retr() method, despite the fact that the documentation says "Retrieve whole message number which, and set its seen flag."
Here is the code:
pop = poplib.POP3_SSL("pop.gmail.com", "995")
pop.user("recent:mymail#gmail.com")
pop.pass_("mypassword")
numMessages = len(pop.list()[1])
for i in range(numMessages):
for j in pop.retr(i+1)[1]:
print(j)
pop.quit()
Am I doing something wrong or does the documentation lie? (or, did I just misinterpret it?)
The POP protocol has no concept of "read" or "unread" messages; the LIST command simply shows all existing messages. You may want to use another protocol, like IMAP, if the server supports it.
You could delete messages after successful retrieval, using the DELE command. Only after a successful QUIT command will the server actually delete them.

Gmail IMAP via php ouath2 Zend_Mail_Protocol_Imap - getting the X-GM-THRID

I'm accessing GMail via IMAP using OAuth2 authentication and Zend_Mail_Protocol_Imap.
It all works great.
What I need to do is present emails in thread form just like the GMail interface. Google make this really easy because they have an X-GM-THRID header that links a conversation with a 64-bit unsigned integer.
My problem is: when presented with a single email, how do I find out what X-GM-THRID it belongs to?
First off Google says that there is a server extension X-GM-EXT-1 which is active. You can check it is there using the CAPABILITY command (and I have).
All the information suggests that if this is active then the X-GM-THRID will simply be returned as a header, but it isn't.
Perhaps I need to ask Google to return it via the fetch command. Google does describe a simple fetch process here:
https://developers.google.com/google-apps/gmail/imap_extensions
My code is sending TAG5 FETCH 3673 (FLAGS RFC822.HEADER X-GM-THRID) but the headers do not include an entry for X-GM-THRID.
I've even simplified it to TAG6 FETCH 3673 (X-GM-THRID) to be exactly as described in the google example. In this case no headers are returned.
I'm not massively familiar with IMAP commands and I'm not sure if Zend_Mail_Protocol_Imap is abstracting some handling which means this header is being removed.
But I do know that this is driving me mad.
Am I missing something? Is it not a header?
Okay, so it looks like it is not a header. It is an attribute in the IMAP command and response.
The standard fetch command sent by Zend_Mail_Protocol_Imap is "TAG5 FETCH 3673 (FLAGS RFC822.HEADER)"
The code that handles the response only expects to be dealing with 'FLAGS' and 'RFC822.HEADER'. It passes this information to a Zend_Mail_Message object which extends Zend_Mail_Part.
Zend_Mail_Part parses information about flag. It also parses the header.
The additional 'X-GM-THRID' attribute that I added does actually get a response. but since it is not passed back to Zend_Mail_Message there is no way for me to use it. It gets lost in the ether (at around line 171 of Zend_Mail_Storage_Imap in my Zend Library to be exact).
So I've hacked the core... Zend_Mail_Storage_Imap::getMessage now expects $data['X-GM-THRID'] and passes it to the constructor Zend_Mail_Part. And I now have a method Zend_Mail_Part::getXGmThrid which solves all my problems. I'll obviously refactor them into my own classes extending Zend_Mail_Storage_Imap and Zend_Mail_Part in the not too distant... but for now I know this works.

Using RMAIL to send an e-mail

I'm struggling to find documentation that gives a clear example of how to enter a message in the rmail application.
I need to specify who the email is from, the subject of the email, and then follow that with some content. It's for a small school assignment where we are relaying "status updates" from imaginary machines on an imaginary factory floor.
This is the closest I've found, but it is not very clear: http://www.s-gms.ms.edus.si/cgi-bin/man-cgi?rmail+1
Can anyone give me an example of how I would send a message that looked like this? (obviously not including the comments...)
/* header stuff */
From: something#something.com
Subject: Status update for machine 5
/* message content */
Machine ID: 7
Status Reported: Machine going offline (status 6)
Status effective: 2012-06-02 12:30:23
I am opening rmail via software controlled pipe in my application without problems, I'm just not sure how to format the data I am feeding to it since I can't find any examples online.
Thanks!
You are probably interested in using /usr/bin/mail on most modern Unixes, not rmail.
You should read the man page, but generally, it would be sufficient to use the "-s" flag to set the subject of the mail, and input the content of the message on stdin. There is no need to set the From: line, as the system will do that for you (and in the general case, the system will not let you specify arbitrary from addresses to prevent forgeries.)

[Asterisk]Attended transfer using hook flash on a SIP channel

Within our organisation we use quite a few different models of telephone sets. The only thing they have in common, apart from the dialpad, is the ability to "send" hook flash. I prefer using this type of signaling for attended transfers above combinations of the usual dialpad keys to prevent the other end from receiving DTMF-tones (to prevent unwanted interactions with IVRs or bothering people on the other end).
2 questions:
How is a flash hook represented in features.conf? According to RFC2833 section 3.10 (DTMF Events) and this article (which is about a ZAP- instead of SIP-configuration, thus my doubt... see next question, also), it should be just "flash".
From my Google-quest I've learned that hook flash gets ignored by the PBX when using the SIP-protocol in Asterisk... I do get an error message when sending it: "WARNING[26159]: chan_sip.c:6487 sip_indicate: Don't know how to indicate condition 9". Is there a way to fix it/work around it?
Asterisk version: 1.8.3.2
Using "info" for dtmfmode
Tnx in advance!
In most cases you have in you adapter settings what to do with hook. IF you have, you can change that to transfer code.
Update: after code review i can say that DTMF 16 received ok and sended in 1.8.x. BUT features.c have no any action on flash(event 16)
So posible create audiohook application for asterisk to change that DTMF 16 to 2 DTMF values or invoke transfer. Will work for DTMF method SIPInfo, and such patch complexity is below-average(5-6 hours for expert)

Resources