Lior Gradstein’s Blog

Archive for the ‘asterisk’ Category

If you want to use any Asterisk module that needs a timer, like MeetMe, you have to use a module named dahdi (previously named zaptel). DAHDI has one module for each Digium supported card (B410P), and a dummy module (named dahdi_dummy) if you don’t have a hardware card, like me.

The problem appears when you have your Asterisk in a Xen environment. Xen does not allow the use of the RTC, so when using Dahdi/meetme, you get the following in you logs:

res_timing_dahdi.c: Asterisk has detected a problem with your DAHDI configuration and will shutdown for your protection.

So get the sources, and let’s patch it!

svn co  http://svn.digium.com/svn/dahdi/linux-complete/trunk DAHDI

In dahdi_dummy.c, you’ll have to comment the two defines USE_RTC, as in a Xen, you can’t use it:


# diff -u dahdi_dummy.c.ori dahdi_dummy.c
— dahdi_dummy.c.ori 2009-03-23 09:50:36.000000000 +0000
+++ dahdi_dummy.c 2009-03-23 08:55:38.000000000 +0000
@@ -59,11 +59,11 @@
#if defined(CONFIG_HIGH_RES_TIMERS) && LINUX_VERSION_CODE >= VERSION_CODE(2,6,22)
#define USE_HIGHRESTIMER
#else
-#define USE_RTC
+//#define USE_RTC
#endif
#else
#if 0
-#define USE_RTC
+//#define USE_RTC
#endif
#endif
#endif

Then compile the module, as usual, with :

/etc/init.d/dahdi stop
make all
make install
make config

Verify that your module has been correctly installed:

ls -al ./2.6.24-19-xen/dahdi/dahdi_dummy.ko

Comment out all the defined modules in the /etc/dahdi/modules file.

/etc/init.d/dahdi start
#> dmesg
1007539.576458] dahdi: Telephony Interface Registered on major 196
[1007539.576468] dahdi: Version: SVN-trunk-r6201M
[1007540.642839] dahdi: Registered tone zone 2 (France)

  • 5 Comments
  • Filed under: asterisk, software, voip
  • If you configured your Asterisk/FreeSWITCH server to talk to your freephonie.net (french Free ISP provider), you’ll see in the logs the following warning message:

    [Feb 12 09:29:06] WARNING[9228]: chan_sip.c:6624 determine_firstline_parts: Bad request protocol Packet

    This is not really a problem, but an annoyance, as it fills up your logs. This is a known problem for more than years, but has never been corrected (neither by Asterisk nor by Cirpack devs). The usual correction was to add the following line to your startup scripts (/etc/rc.local on Debian for example):

    iptables -A INPUT -p udp -m udp –dport 5060 -m stringstring "Cirpack KeepAlive Packet" -j DROP

    But the syntax has changed in iptables, and you’ll get the error:

    iptables v1.3.6: STRING match: You must specify `–algo

    so, just add one of the 2 available algorithms (bm and kmp):

    iptables -A INPUT -p udp -m udp –dport 5060 -m stringstring "Cirpack KeepAlive Packet" –algo bm -j DROP

  • 0 Comments
  • Filed under: asterisk, software, voip
  • How to dial a number using Asterisk and Python

    I didn’t find any example in Python on how to Dial a number from an Asterisk server and link it to another channel. So here’s a quick code to do it. You just need to have a manager defined in your /etc/asterisk/manager.conf defined.

    import socket

    HOST="192.168.1.116"
    PORT=5038

    p = """Action: login
    Events: off
    Username: %(username)s
    Secret: %(password)s

    Action: originate
    Channel: SIP/%(local_user)s
    WaitTime: 60
    CallerId: 600
    Exten: %(phone_to_dial)s
    Context: default
    Priority: 1

    Action: Logoff
    """
    def click_to_call(phone_to_dial, username, password, local_user):
        pattern = p % {
                ‘phone_to_dial’: phone_to_dial,
                ‘username’: username,
                ‘password’: password,
                ‘local_user’: local_user}

        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect((HOST, PORT))

        data = s.recv(1024)
        for l in pattern.split(‘n’):
            print "Sending>", l
            s.send(l+‘rn’)
            if l == "":
                data = s.recv(1024)
                print data
        data = s.recv(1024)
        s.close()

    if __name__ == ‘__main__’:
        click_to_call(phone_to_dial=‘123456789′,
                      username=‘manager_login’, password=‘yourpass’,
                      local_user=‘600′)

  • 1 Comment
  • Filed under: asterisk, python, voip
  • Since Asterisk 1.2+, the methods to access the AstDB database (a berkeley local database) were changed from DBGet,DBPut,DBDel to the merged “simpler” one named Set (except for DbDel which seems to still exist). There was a functionnality that when a key was not found in AstDB, a jump would be done to n+101. So the following would be OK:

    exten = s,1,Set(forward_number=${DB(FORWARD/1234)})
    exten = s,2,Background(one_local/forward/forward_number_is)
    exten = s,3,sayalpha(${forward_number})
    exten = s,4,Goto(s-report_mode,1)
    exten = s,102,NoOp(Pas de valeur ce qui est normal)
    exten = s,103,Goto(s-not_set,1)

    But with my newly installed Asterisk 1.4.4, it doesn’t jump anymore. It continues to s,2 :-(.
    So I guess I need to add a supplementary line to explicitely test the presence of the key:

    exten = s,1,GotoIf(${DB_EXISTS(FORWARD/${F_EXT})}?:102)
    exten = s,2,Set(forward_number=${DB_RESULT})
    exten = s,3,Background(one_local/forward/forward_number_is)
    exten = s,4,sayalpha(${forward_number})

    exten = s,102,NoOp(Pas de valeur ce qui est normal)

  • 0 Comments
  • Filed under: asterisk
  • Photos of Ido and Oren

    2009-11-22 14.53.56.jpg2009-11-22 14.53.40.jpg2009-11-22 14.33.25.jpg2009-11-22 14.33.14.jpg2009-11-22 14.30.32.jpg2009-11-22 14.28.49.jpg2009-11-22 14.05.22.jpg2009-11-22 14.05.12.jpg2009-11-22 14.05.07.jpg

    Search engine optimization by SEO Design Solutions