[Serusers] Asterisk + OpenSER integration successful

satish patel linuxtrap at yahoo.co.in
Fri Apr 4 15:12:53 CEST 2008


Dear ser guys..
 
 
                    I have done asterisk with openser integration after spending 2 and 3 days...not time to get nice cold beer... 
 
 I am user openser front of Asterisk. All sip client register on OpenSER server  and call to local extension without Asterisk. caz Asterisk is a media server which are useing only for PSTN calling. When any sip client dialing outside number means mobile number or any outside number Openser forward call to Asterisk and asterisk forward it on PSTN use the E1 or FXO line. ( In my case it is E1 ). 
 
 OpenSER only user for SIP users or SIP proxy server it can only handle sip request.
 
 Asterisk is Media server which can handle IVR , confrance , VoiceMail, and Meetmee or PSTN application. when call come down from PSTN Asterisk forward it on OpenSER as per dialplan configuration.
 
 It can handle 1000 of call and you can use it on large production.
 
 [sip_client]------------->[Openser]--------->[Asterisk]----[PSTN]
 
 My Openser configuration file.
 
 #cat ser.cfg
 
 debug=6
 fork=yes
 log_stderror=yes
 listen=<openser_ipaddress>           # INSERT YOUR IP ADDRESS HERE
 port=5060
 children=4
 check_via=no    # (cmd. line: -v)
 dns=no           # (cmd. line: -r)
 rev_dns=no      # (cmd. line: -R)
 fifo="/tmp/ser_fifo"
 # ------------------ module loading ----------------------------------
 # Uncomment this if you want to use SQL database
 #loadmodule "/usr/local/lib/ser/modules/mysql.so"
 loadmodule "/usr/local/lib/ser/modules/sl.so"
 loadmodule "/usr/local/lib/ser/modules/tm.so"
 loadmodule "/usr/local/lib/ser/modules/rr.so"
 loadmodule "/usr/local/lib/ser/modules/maxfwd.so"
 loadmodule "/usr/local/lib/ser/modules/usrloc.so"
 loadmodule "/usr/local/lib/ser/modules/registrar.so"
 loadmodule "/usr/local/lib/ser/modules/textops.so"
 # Uncomment this if you want digest authentication
 # mysql.so must be loaded !
 #loadmodule "/usr/local/lib/ser/modules/auth.so"
 #loadmodule "/usr/local/lib/ser/modules/auth_db.so"
 # ----------------- setting module-specific parameters ---------------
 # -- usrloc params --
 modparam("usrloc", "db_mode",   0)
 # Uncomment this if you want to use SQL database
 # for persistent storage and comment the previous line
 #modparam("usrloc", "db_mode", 2)
 # -- auth params --
 # Uncomment if you are using auth module
 #
 #modparam("auth_db", "calculate_ha1", yes)
 #
 # If you set "calculate_ha1" parameter to yes (which true in this config),
 # uncomment also the following parameter)
 #
 #modparam("auth_db", "password_column", "password")
 # -- rr params --
 # add value to ;lr param to make some broken UAs happy
 modparam("rr", "enable_full_lr", 1)
 # -------------------------  request routing logic -------------------
 # main routing logic
 route{
         # initial sanity checks -- messages with
         # max_forwards==0, or excessively long requests
         if (!mf_process_maxfwd_header("10")) {
                 sl_send_reply("483","Too Many Hops");
                 break;
         };
         if (msg:len >=  2048 ) {
                 sl_send_reply("513", "Message too big");
                 break;
         };
 
         # we record-route all messages -- to make sure that
         # subsequent messages will go through our proxy; that's
         # particularly good if upstream and downstream entities
         # use different transport protocol
         if (!method=="REGISTER") record_route();
         # subsequent messages withing a dialog should take the
         # path determined by record-routing
         if (loose_route()) {
                 # mark routing logic in request
                 append_hf("P-hint: rr-enforced\r\n");
                 route(1);
                 break;
         };
         if (!uri==myself) {
                 # mark routing logic in request
                 append_hf("P-hint: outbound\r\n");
                 route(1);
                 break;
         };
         # if the request is for other domain use UsrLoc
         # (in case, it does not work, use the following command
         # with proper names and addresses in it)
         if (uri==myself) {
                 if (method=="REGISTER") {
 # Uncomment this if you want to use digest authentication
 #                       if (!www_authorize("iptel.org", "subscriber")) {
 #                               www_challenge("iptel.org", "0");
 #                               break;
 #                       };
                         save("location");
                         break;
                 };
 # requests for Media server
                 if(method=="INVITE") {
                         if (uri =~ "sip:0[1-9]@*"){
                         route(3);
                         break;
                 }
                 }
                 lookup("aliases");
                 if (!uri==myself) {
                         append_hf("P-hint: outbound alias\r\n");
                         route(1);
                         break;
                 };
                 # native SIP destinations are handled using our USRLOC DB
                 if (!lookup("location")) {
                         sl_send_reply("404", "Not Found");
                         break;
                 };
         };
         append_hf("P-hint: usrloc applied\r\n");
         route(1);
 }
 route[1]
 {
         # send it out now; use stateful forwarding as it works reliably
         # even for UDP2TCP
         if (!t_relay()) {
                 sl_reply_error();
         };
 }
 route[3]{
 
    if (uri =~ "sip:0[1-9]@*"){
         log(1, "Forwarding to Asterisk\n");
         rewritehostport("<asterisk_ip>:5060");
         route(1);
         break;
     }
 
 }
 
 #---------END------------#
 
 #Asterisk extension.conf
 
 [globals]
 SERADDRESS=203.124.16.109
 [outgoing]
 
 exten => 5500,1,Playback(hello-world)
 
 exten => 5000,1,Answer()
 exten => 5000,2,Dial(SIP/5000)
 exten => 5000,3,Hangup()
 
 ;  XXXX use to forward call on openser extensions.
 exten => _XXXX,1,Dial(SIP/${EXTEN}@${SERADDRESS},20,r)
 
 
 
 

$ cat ~/satish/url.txt                                                      

http://www.linuxbug.org
_____________________________________________________________________________________________________

       
---------------------------------
 Explore your hobbies and interests. Click here to begin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20080404/2aff89b5/attachment.htm>


More information about the sr-users mailing list