<div dir="ltr">You are a star Anthony!<div>Thanks a lot for sharing your config. It is much appreciated.</div><div>I'm going to study your config in detail and see if I can get it to work on my install.</div><div><br></div>
<div>Cheers,</div><div>Peter</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jul 18, 2014 at 6:39 PM, Anthony Messina <span dir="ltr"><<a href="mailto:amessina@messinet.com" target="_blank">amessina@messinet.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Friday, July 18, 2014 12:01:41 AM Daniel-Constantin Mierla wrote:<br>
> You should not call m_store() if src_ip==myself -- in this way you avoid to<br>
> store notification messages that cannot be delivered.<br>
><br>
> Why notifications are not delivered has to be troubleshooted there. Have you<br>
> tried also with UDP?<br>
><br>
> Cheers,<br>
> Daniel<br>
><br>
> On 17/07/14 23:46, Peter Villeneuve wrote:<br>
> Well I've been experimenting with this for hours and still no joy<br>
>  :(  Hair pulling continues<br>
<br>
<br>
</div>Peter, I'm trying to accomplish something similar, also as a new user to<br>
Kamailio and initially starting from the guide at<br>
<a href="http://kb.asipto.com/asterisk:realtime:kamailio-4.0.x-asterisk-11.3.0-astdb" target="_blank">http://kb.asipto.com/asterisk:realtime:kamailio-4.0.x-asterisk-11.3.0-astdb</a><br>
though I am using Asterisk 12 and Kamailio devel (built for Fedora here<br>
<a href="https://messinet.com/rpms/browser/kamailio" target="_blank">https://messinet.com/rpms/browser/kamailio</a>)<br>
<br>
My goal is that Kamailio does MESSAGE processing with MSILO storage *only* for<br>
users who actually exist -- not just any username in my domain, but a user who<br>
is in the subscribers table -- there is no sense storing a message for a<br>
username who will never register to receive it.<br>
<br>
Here are the relevant blocks in my kamailio.cfg -- I've included full routing<br>
blocks so you can see how the route is laid out.  I admit that I am equally<br>
not sure that this is the right way or the most efficient way to do it, but it<br>
does work with UDP, TCP, and TLS including notifications.<br>
<br>
Now that I have it "working," and understand more about routing in Kamailio,<br>
I'm likely going to consolidate duplication.  For instance, since I don't want<br>
to store messages for invalid or non-existent accounts, I will probably do the<br>
if(is_subscriber("$ou", "ps_auths", "1")) and add<br>
t_on_failure("MANAGE_FAILURE"); in the request_route, etc.<br>
<br>
Perhaps 1) this will help you, and 2) others may be able to give advice on my<br>
configuration.<br>
<br>
<br>
<br>
#!define WITH_AUTH<br>
#!define WITH_MSILO<br>
<br>
<br>
#!ifdef WITH_AUTH<br>
loadmodule "auth.so"<br>
loadmodule "auth_db.so"<br>
#!ifdef WITH_IPAUTH<br>
loadmodule "permissions.so"<br>
#!endif<br>
#!endif<br>
<br>
<br>
#!ifdef WITH_MSILO<br>
loadmodule "msilo.so"<br>
#!endif<br>
<br>
<br>
#!ifdef WITH_AUTH<br>
# ----- auth_db params -----<br>
modparam("auth_db", "calculate_ha1", yes)<br>
modparam("auth_db", "load_credentials", "")<br>
<br>
#!ifdef WITH_ASTERISK<br>
modparam("auth_db", "user_column", "username")<br>
modparam("auth_db", "domain_column", "realm")<br>
modparam("auth_db", "password_column", "password")<br>
# Workaround <a href="http://lists.sip-router.org/pipermail/sr-users/2013-August/079267.html" target="_blank">http://lists.sip-router.org/pipermail/sr-users/2013-August/079267.html</a><br>
modparam("auth_db", "load_credentials", "username")<br>
# End workaround<br>
modparam("auth_db", "db_url", DBASTURL)<br>
modparam("auth_db", "version_table", 0)<br>
#!else<br>
modparam("auth_db", "db_url", DBURL)<br>
modparam("auth_db", "password_column", "password")<br>
modparam("auth_db", "use_domain", MULTIDOMAIN)<br>
#!endif<br>
<br>
#!ifdef WITH_IPAUTH<br>
# ----- permissions params -----<br>
modparam("permissions", "db_url", DBURL)<br>
modparam("permissions", "db_mode", 1)<br>
#!endif<br>
#!endif<br>
<br>
<br>
#!ifdef WITH_MSILO<br>
# ----- msilo params -----<br>
modparam("msilo", "db_url", DBURL)<br>
modparam("msilo", "from_address", "sip:$<a href="mailto:rU@my-domain.com">rU@my-domain.com</a>")<br>
modparam("msilo", "offline_message", "I'll get my messages when I'm back<br>
online.")<br>
modparam("msilo", "content_type_hdr", "Content-Type: text/plain\r\n")<br>
modparam("msilo", "expire_time", 604800)<br>
#!endif<br>
<br>
<br>
#######################<br>
route[RELAY] {<br>
<br>
        # enable additional event routes for forwarded requests<br>
        # - serial forking, RTP relaying handling, a.s.o.<br>
        if (is_method("INVITE|BYE|SUBSCRIBE|UPDATE")) {<br>
                if(!t_is_set("branch_route")) t_on_branch("MANAGE_BRANCH");<br>
        }<br>
        if (is_method("INVITE|SUBSCRIBE|UPDATE")) {<br>
                if(!t_is_set("onreply_route")) t_on_reply("MANAGE_REPLY");<br>
        }<br>
        if (is_method("INVITE")) {<br>
                if(!t_is_set("failure_route")) t_on_failure("MANAGE_FAILURE");<br>
        }<br>
<br>
#!ifdef WITH_MSILO<br>
        if (is_method("MESSAGE")) {<br>
                if(!t_is_set("failure_route")) t_on_failure("MANAGE_FAILURE");<br>
        }<br>
#!endif<br>
<br>
        if (!t_relay()) {<br>
                sl_reply_error();<br>
        }<br>
        exit;<br>
}<br>
<br>
<br>
#######################<br>
<div class="">route[REGISTRAR] {<br>
        if (is_method("REGISTER"))<br>
        {<br>
                if(isflagset(FLT_NATS))<br>
                {<br>
                        setbflag(FLB_NATB);<br>
                        # uncomment next line to do SIP NAT pinging<br>
</div>                        ## setbflag(FLB_NATSIPPING);<br>
<div class="">                }<br>
                if (!save("location"))<br>
                        sl_reply_error();<br>
<br>
</div>#!ifdef WITH_MSILO<br>
                # Ensure we aren't unregistering<br>
                # Right now, CSipSimple doesn't send an Allow header with an<br>
un-REGISTER,<br>
                # so Kamailio skips to checking the Contact header for<br>
expires, and appears<br>
                # to ignore the fact that an Expires: 0 header is present.<br>
                if($hdr(Expires) != 0)<br>
                        m_dump();<br>
#!endif<br>
<br>
#!ifdef WITH_ASTERISK<br>
                route(REGFWD);<br>
#!endif<br>
<br>
                exit;<br>
        }<br>
}<br>
<br>
<br>
#######################<br>
route[LOCATION] {<br>
<br>
#!ifdef WITH_SPEEDDIAL<br>
        # search for short dialing - 2-digit extension<br>
        if($rU=~"^[0-9][0-9]$")<br>
                if(sd_lookup("speed_dial"))<br>
                        route(SIPOUT);<br>
#!endif<br>
<div class=""><br>
#!ifdef WITH_ALIASDB<br>
        # search in DB-based aliases<br>
</div>        if(alias_db_lookup("dbaliases"))<br>
                route(SIPOUT);<br>
#!endif<br>
<br>
#!ifdef WITH_ASTERISK<br>
        if(is_method("INVITE") && (!route(FROMASTERISK))) {<br>
                # if new call from out there - send to Asterisk<br>
                # - non-INVITE request are routed directly by Kamailio<br>
                # - traffic from Asterisk is routed also directy by Kamailio<br>
                route(TOASTERISK);<br>
                exit;<br>
        }<br>
#!endif<br>
<br>
        $avp(oexten) = $rU;<br>
        if (!lookup("location")) {<br>
<br>
#!ifdef WITH_MSILO<br>
                if(is_method("MESSAGE") && src_ip!=myself) {<br>
                        # Ensure we have a valid account for which to store<br>
MESSAGEs<br>
<br>
#!ifdef WITH_ASTERISK<br>
                        if(is_subscriber("$ru", "ps_auths", "1")) {<br>
#!else<br>
                        if(is_subscriber("$ru", "subscriber", "1")) {<br>
#!endif<br>
<br>
                                if(m_store("$ru")) {<br>
                                        xlog("L_INFO", "MSILO: MESSAGE from<br>
$fu stored for offline user $ru\n");<br>
                                        send_reply("202", "Accepted");<br>
                                } else {<br>
                                        xlog("L_ERR", "MSILO: unable to store<br>
MESSAGE from $fu for offline user $ru\n");<br>
                                        send_reply("503", "Service<br>
Unavailable");<br>
                                }<br>
                        } else {<br>
                                xlog("L_ERR", "MSILO: MESSAGE from $fu not<br>
stored for non-existent user $ru\n");<br>
                                send_reply("404", "Not Found");<br>
                        }<br>
                        exit;<br>
                }<br>
#!endif<br>
<br>
                $var(rc) = $rc;<br>
                route(TOVOICEMAIL);<br>
                t_newtran();<br>
                switch ($var(rc)) {<br>
                        case -1:<br>
                        case -3:<br>
                                send_reply("404", "Not Found");<br>
                                exit;<br>
                        case -2:<br>
<div class="">                                send_reply("405", "Method Not Allowed");<br>
                                exit;<br>
                }<br>
        }<br>
<br>
        # when routing via usrloc, log the missed calls also<br>
        if (is_method("INVITE"))<br>
        {<br>
                setflag(FLT_ACCMISSED);<br>
        }<br>
}<br>
<br>
<br>
</div>#######################<br>
route[AUTH] {<br>
#!ifdef WITH_MSILO<br>
        # do not authenticate ourselves when dumping messages<br>
        if(is_method("MESSAGE") && src_ip==myself)<br>
        {<br>
                return;<br>
        }<br>
#!endif<br>
<br>
        # if caller is not local subscriber, then check if it calls<br>
<div class="">        # a local destination, otherwise deny, not an open relay here<br>
</div>        if (from_uri!=myself && uri!=myself)<br>
<div class="">        {<br>
                sl_send_reply("403","Not relaying");<br>
                exit;<br>
        }<br>
<br>
</div>#!ifdef WITH_AUTH<br>
<br>
#!ifdef WITH_ASTERISK<br>
        # do not auth traffic from Asterisk - trusted!<br>
        if(route(FROMASTERISK))<br>
                return;<br>
#!endif<br>
<br>
#!ifdef WITH_IPAUTH<br>
        if((!is_method("REGISTER")) && allow_source_address())<br>
<div class="">        {<br>
                # source IP allowed<br>
                return;<br>
        }<br>
#!endif<br>
<br>
</div>        if (is_method("REGISTER") || from_uri==myself)<br>
        {<br>
                # authenticate requests<br>
#!ifdef WITH_ASTERISK<br>
                if (!auth_check("$fd", "ps_auths", "1")) {<br>
#!else<br>
                if (!auth_check("$fd", "subscriber", "1")) {<br>
#!endif<br>
                        auth_challenge("$fd", "0");<br>
                        exit;<br>
                }<br>
                # user authenticated - remove auth header<br>
                if(!is_method("REGISTER|PUBLISH"))<br>
                        consume_credentials();<br>
        }<br>
#!endif<br>
        return;<br>
}<br>
<br>
<br>
#######################<br>
failure_route[MANAGE_FAILURE] {<br>
        route(NATMANAGE);<br>
<br>
        if (t_is_canceled()) {<br>
                exit;<br>
        }<br>
<br>
#!ifdef WITH_BLOCK3XX<br>
        # block call redirect based on 3xx replies.<br>
<div class="">        if (t_check_status("3[0-9][0-9]")) {<br>
</div><div class="">                t_reply("404","Not found");<br>
</div>                exit;<br>
        }<br>
#!endif<br>
<br>
#!ifdef WITH_MSILO<br>
        # Manage MSILO transmission failures<br>
        if(is_method("MESSAGE") && src_ip!=myself) {<br>
<br>
                # Ensure we have a valid account for which to store MESSAGEs<br>
#!ifdef WITH_ASTERISK<br>
                if(is_subscriber("$ou", "ps_auths", "1")) {<br>
#!else<br>
                if(is_subscriber("$ou", "subscriber", "1")) {<br>
#!endif<br>
<br>
                        if (m_store("$ou")) {<br>
                                xlog("L_INFO", "MSILO: MESSAGE from $fu stored<br>
for unreachable user $ou\n");<br>
                                send_reply("202", "Accepted");<br>
                        } else {<br>
                                xlog("L_ERR", "MSILO: unable to store MESSAGE<br>
from $fu for unreachable user $ou\n");<br>
                                send_reply("503", "Service Unavailable");<br>
                        }<br>
                }<br>
                exit;<br>
        }<br>
#!endif<br>
<br>
#!ifdef WITH_VOICEMAIL<br>
        # serial forking<br>
        # - route to voicemail on busy or no answer (timeout)<br>
        if (t_check_status("486|408")) {<br>
                $du = $null;<br>
                route(TOVOICEMAIL);<br>
                exit;<br>
        }<br>
#!endif<br>
}<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
Anthony - <a href="http://messinet.com" target="_blank">http://messinet.com</a> - <a href="http://messinet.com/~amessina/gallery
8F89" target="_blank">http://messinet.com/~amessina/gallery<br>
8F89</a> 5E72 8DF0 BCF0 10BE 9967 92DC 35DC B001 4A4E<br>
</font></span><br>_______________________________________________<br>
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
<a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
<br></blockquote></div><br></div>