Hey Klaus,
                Yes invites work fine from asterisk to UA

So should I record route() all the OPTIONS also?

        remove_hf("Route");
        if (is_method("INVITE|SUBSCRIBE|OPTIONS")){
                xlog("L_INFO","mylog: Recording Route. Method: [$rm].\n");
                record_route();
                }

Thanks Ian

Message: 2
Date: Fri, 28 Jun 2013 10:19:18 +0200
From: Klaus Darilion <klaus.mailinglists@pernau.at>
To: sr-users@lists.sip-router.org
Subject: Re: [SR-Users] Asterisk Gateway OPTIONS relay
Message-ID: <51CD4706.7080600@pernau.at>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Does the routing of INVITE from Asterisk to the UA work? If yes, just
make sure that you route the OPTIONS from Asterisk identical to the INVITE.

regards
Klaus

On 27.06.2013 15:28, Ian French wrote:
> Hey list,
>             I've been trying the relay OPTIONS messages from an asterisk
> server through kamailio to clients so to preserve the qualify feature in
> asterisk. So
>
>
> ASTERISK -----OPTIONS----> KAMAILIO ------------> UA
>
> UA ----OK-----> KAMAILIO ---OK-----> ASTERISK
>
> But I'm seeing floods of OPTIONS messages between asterisk and kamailio
> now. So much so that kamailio seems to deadlock introducing 10 -20
> second delays in processing messages
>
> firstly I've enabled the options.so but this is just enable remote
> monitoring of the application and in my FROMASTERISK route
>
> #!ifdef WITH_ASTERISK
> # Test if coming from Asterisk
> route[FROMASTERISK] {
> #       if($si==$sel(cfg_get.asterisk.
bindip)
> #                       && $sp==$sel(cfg_get.asterisk.bindport))
>
> if ((method==OPTIONS) && (uri=~"sip:.*[@]+.*")) {
>                  xlog("L_INFO","Options Reply from $ru to $fu\r\n");
>                  return 1;
> }
>
>          if(ds_is_from_list("2")){
>          $sht(forw=>$ft)=$si;
>                  xlog("L_INFO","INVITE: INVITE Passed From [$fu]
> Asterisk Cluster To [$rm:$au].\n");
>                  return 1;
> }
>             return -1;
> }
>
> I've included a debug below, stating *RFC3261 transaction matching
> failed. *Can anyone help or advise on how I should solve this
>
> Thanks in advance
> Ian
>
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/msg_parser.c:630]: SIP Request:
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/msg_parser.c:632]:  method:  <OPTIONS>
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/msg_parser.c:634]:  uri:     <sip:XXXXXXXX@P.P.P.P:5060>
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/msg_parser.c:636]:  version: <SIP/2.0>
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/parse_via.c:1287]: Found param type 232, <branch> =
> <z9hG4bK50c02ae3>; state=6
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/parse_via.c:1287]: Found param type 235, <rport> = <n/a>; state=17
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/parse_via.c:2300]: end of header reached, state=5
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/msg_parser.c:515]: parse_headers: Via found, flags=2
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/msg_parser.c:517]: parse_headers: this is the first via
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core> [receive.c:145]:
> After parse_msg...
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core> [receive.c:186]:
> preparing to run routing scripts...
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core> [socket_info.c:501]:
> grep_sock_info - checking if host==us: 10==10 &&  [P.P.P.P] == [P.P.P.P]
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core> [socket_info.c:504]:
> grep_sock_info - checking if port 5060 matches port 5060
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core> [socket_info.c:501]:
> grep_sock_info - checking if host==us: 10==10 &&  [A.A.A.A] == [P.P.P.P]
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core> [forward.c:446]:
> check_self: host != me
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/parse_to.c:174]: DEBUG: add_param: tag=as2c63e7cc
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/parse_to.c:803]: end of header reached, state=29
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/parse_to.c:803]: end of header reached, state=10
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/msg_parser.c:187]: DEBUG: get_hdr_field: <To> [32];
> uri=[sip:XXXXXXXX@P.P.P.P:5060]
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/msg_parser.c:167]: get_hdr_field: cseq <CSeq>: <102> <OPTIONS>
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: maxfwd [mf_funcs.c:85]:
> value = 70
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/msg_parser.c:201]: DEBUG: get_hdr_body : content_length=0
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/msg_parser.c:103]: found end of header
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: geoip [geoip_pv.c:395]:
> attempt to match: A.A.A.A
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: geoip [geoip_pv.c:401]:
> geoip PV updated for: A.A.A.A
> KamP /usr/local/sbin/kamailio[19288]: INFO: <script>: SIP message from
> unprohibited source IE (ip: A.A.A.A) - Packet accepted
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [msg_translator.c:204]: check_via_address(A.A.A.A, A.A.A.A, 0)
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: siputils [checks.c:73]: no
> totag
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: tm [t_lookup.c:1081]:
> DEBUG: t_check_msg: msg id=294 global id=293 T start=0xffffffffffffffff
> *KamP /usr/local/sbin/kamailio[19288]: DEBUG: tm [t_lookup.c:528]:
> t_lookup_request: start searching: hash=44040, isACK=0*
> **RFC3261 transaction matching failed*KamP
> /usr/local/sbin/kamailio[19288]: DEBUG: tm [t_lookup.c:485]: DEBUG:
> RFC3261 transaction matching failed
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: tm [t_lookup.c:711]: DEBUG:
> t_lookup_request: no transaction found*
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: tm [t_lookup.c:1150]:
> DEBUG: t_check_msg: msg id=294 global id=294 T end=(nil)
> KamP /usr/local/sbin/kamailio[19288]: INFO: <script>: SIP Dialog From
> Asterisk Gatways A.A.A.A- No Authentication
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core> [socket_info.c:501]:
> grep_sock_info - checking if host==us: 10==10 &&  [P.P.P.P] == [P.P.P.P]
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core> [socket_info.c:504]:
> grep_sock_info - checking if port 5060 matches port 5060
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: siputils [checks.c:73]: no
> totag
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: rr [record.c:519]:
> rr_param_buf=<;nat=yes>
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: tm [t_lookup.c:1379]:
> DEBUG: t_newtran: msg id=294 , global msg id=294 , T on entrance=(nil)
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: tm [t_lookup.c:528]:
> t_lookup_request: start searching: hash=44040, isACK=0
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: tm [t_lookup.c:485]: DEBUG:
> RFC3261 transaction matching failed
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: tm [t_lookup.c:711]: DEBUG:
> t_lookup_request: no transaction found
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: tm [t_hooks.c:374]: DBG:
> trans=0x2b8a8f4f0ed8, callback type 1, id 0 entered
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [msg_translator.c:204]: check_via_address(A.A.A.A, A.A.A.A, 0)
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: tm [t_funcs.c:388]: SER:
> new transaction fwd'ed
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core> [usr_avp.c:646]:
> DEBUG:destroy_avp_list: destroying list (nil)
> KamP last message repeated 5 times




Message: 2
Date: Fri, 28 Jun 2013 10:19:18 +0200
From: Klaus Darilion <klaus.mailinglists@pernau.at>
To: sr-users@lists.sip-router.org
Subject: Re: [SR-Users] Asterisk Gateway OPTIONS relay
Message-ID: <51CD4706.7080600@pernau.at>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Does the routing of INVITE from Asterisk to the UA work? If yes, just
make sure that you route the OPTIONS from Asterisk identical to the INVITE.

regards
Klaus

On 27.06.2013 15:28, Ian French wrote:
> Hey list,
>             I've been trying the relay OPTIONS messages from an asterisk
> server through kamailio to clients so to preserve the qualify feature in
> asterisk. So
>
>
> ASTERISK -----OPTIONS----> KAMAILIO ------------> UA
>
> UA ----OK-----> KAMAILIO ---OK-----> ASTERISK
>
> But I'm seeing floods of OPTIONS messages between asterisk and kamailio
> now. So much so that kamailio seems to deadlock introducing 10 -20
> second delays in processing messages
>
> firstly I've enabled the options.so but this is just enable remote
> monitoring of the application and in my FROMASTERISK route
>
> #!ifdef WITH_ASTERISK
> # Test if coming from Asterisk
> route[FROMASTERISK] {
> #       if($si==$sel(cfg_get.asterisk.bindip)
> #                       && $sp==$sel(cfg_get.asterisk.bindport))
>
> if ((method==OPTIONS) && (uri=~"sip:.*[@]+.*")) {
>                  xlog("L_INFO","Options Reply from $ru to $fu\r\n");
>                  return 1;
> }
>
>          if(ds_is_from_list("2")){
>          $sht(forw=>$ft)=$si;
>                  xlog("L_INFO","INVITE: INVITE Passed From [$fu]
> Asterisk Cluster To [$rm:$au].\n");
>                  return 1;
> }
>             return -1;
> }
>
> I've included a debug below, stating *RFC3261 transaction matching
> failed. *Can anyone help or advise on how I should solve this
>
> Thanks in advance
> Ian
>
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/msg_parser.c:630]: SIP Request:
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/msg_parser.c:632]:  method:  <OPTIONS>
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/msg_parser.c:634]:  uri:     <sip:XXXXXXXX@P.P.P.P:5060>
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/msg_parser.c:636]:  version: <SIP/2.0>
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/parse_via.c:1287]: Found param type 232, <branch> =
> <z9hG4bK50c02ae3>; state=6
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/parse_via.c:1287]: Found param type 235, <rport> = <n/a>; state=17
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/parse_via.c:2300]: end of header reached, state=5
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/msg_parser.c:515]: parse_headers: Via found, flags=2
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/msg_parser.c:517]: parse_headers: this is the first via
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core> [receive.c:145]:
> After parse_msg...
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core> [receive.c:186]:
> preparing to run routing scripts...
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core> [socket_info.c:501]:
> grep_sock_info - checking if host==us: 10==10 &&  [P.P.P.P] == [P.P.P.P]
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core> [socket_info.c:504]:
> grep_sock_info - checking if port 5060 matches port 5060
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core> [socket_info.c:501]:
> grep_sock_info - checking if host==us: 10==10 &&  [A.A.A.A] == [P.P.P.P]
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core> [forward.c:446]:
> check_self: host != me
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/parse_to.c:174]: DEBUG: add_param: tag=as2c63e7cc
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/parse_to.c:803]: end of header reached, state=29
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/parse_to.c:803]: end of header reached, state=10
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/msg_parser.c:187]: DEBUG: get_hdr_field: <To> [32];
> uri=[sip:XXXXXXXX@P.P.P.P:5060]
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/msg_parser.c:167]: get_hdr_field: cseq <CSeq>: <102> <OPTIONS>
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: maxfwd [mf_funcs.c:85]:
> value = 70
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/msg_parser.c:201]: DEBUG: get_hdr_body : content_length=0
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [parser/msg_parser.c:103]: found end of header
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: geoip [geoip_pv.c:395]:
> attempt to match: A.A.A.A
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: geoip [geoip_pv.c:401]:
> geoip PV updated for: A.A.A.A
> KamP /usr/local/sbin/kamailio[19288]: INFO: <script>: SIP message from
> unprohibited source IE (ip: A.A.A.A) - Packet accepted
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [msg_translator.c:204]: check_via_address(A.A.A.A, A.A.A.A, 0)
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: siputils [checks.c:73]: no
> totag
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: tm [t_lookup.c:1081]:
> DEBUG: t_check_msg: msg id=294 global id=293 T start=0xffffffffffffffff
> *KamP /usr/local/sbin/kamailio[19288]: DEBUG: tm [t_lookup.c:528]:
> t_lookup_request: start searching: hash=44040, isACK=0*
> **RFC3261 transaction matching failed*KamP
> /usr/local/sbin/kamailio[19288]: DEBUG: tm [t_lookup.c:485]: DEBUG:
> RFC3261 transaction matching failed
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: tm [t_lookup.c:711]: DEBUG:
> t_lookup_request: no transaction found*
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: tm [t_lookup.c:1150]:
> DEBUG: t_check_msg: msg id=294 global id=294 T end=(nil)
> KamP /usr/local/sbin/kamailio[19288]: INFO: <script>: SIP Dialog From
> Asterisk Gatways A.A.A.A- No Authentication
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core> [socket_info.c:501]:
> grep_sock_info - checking if host==us: 10==10 &&  [P.P.P.P] == [P.P.P.P]
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core> [socket_info.c:504]:
> grep_sock_info - checking if port 5060 matches port 5060
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: siputils [checks.c:73]: no
> totag
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: rr [record.c:519]:
> rr_param_buf=<;nat=yes>
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: tm [t_lookup.c:1379]:
> DEBUG: t_newtran: msg id=294 , global msg id=294 , T on entrance=(nil)
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: tm [t_lookup.c:528]:
> t_lookup_request: start searching: hash=44040, isACK=0
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: tm [t_lookup.c:485]: DEBUG:
> RFC3261 transaction matching failed
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: tm [t_lookup.c:711]: DEBUG:
> t_lookup_request: no transaction found
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: tm [t_hooks.c:374]: DBG:
> trans=0x2b8a8f4f0ed8, callback type 1, id 0 entered
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core>
> [msg_translator.c:204]: check_via_address(A.A.A.A, A.A.A.A, 0)
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: tm [t_funcs.c:388]: SER:
> new transaction fwd'ed
> KamP /usr/local/sbin/kamailio[19288]: DEBUG: <core> [usr_avp.c:646]:
> DEBUG:destroy_avp_list: destroying list (nil)
> KamP last message repeated 5 times
>
>
>
>
> _______________________________________________