[OpenSIPS-Users] opensips 3.2 with b2bua.

johan johan at democon.be
Fri Jun 18 09:06:25 EST 2021


Hi,

it seems to me that I don't grasp b2bua.

The purpose of this script is very simple :

- handle registration

- on receiving an invite then put the 2 entities in contact with each
other.


For some reason, b2bua can't route the reply.


Log:

Jun 18 04:55:20 debian10opensips31 /data/opensips/sbin/opensips[3041]:
route[0] INVITE sip:1000 at 192.168.68.115;transport=UDP
SIP/2.0#015#012Via: SIP/2.0/UDP
192.168.68.104:44072;branch=z9hG4bK-524287-1---519c17eab6690bb8;rport#015#012Max-Forwards:
70#015#012Contact:
<sip:1001 at 192.168.68.104:44072;transport=UDP>#015#012To:
<sip:1000 at 192.168.68.115>#015#012From:
<sip:1001 at 192.168.68.115;transport=UDP>;tag=8e780c78#015#012Call-ID:
ywvufmDkg195whyiReyxBw..#015#012CSeq: 1 INVITE#015#012Allow: INVITE,
ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO,
SUBSCRIBE#015#012Content-Type: application/sdp#015#012User-Agent: Zoiper
rv2.10.12.3-mod#015#012Allow-Events: presence, kpml,
talk#015#012Content-Length: 185#015#012#015#012v=0#015#012o=Zoiper
1624006519564 1 IN IP4 192.168.68.104#015#012s=Z#015#012c=IN IP4
192.168.68.104#015#012t=0 0#015#012m=audio 44128 RTP/AVP 0 101
8#015#012a=rtpmap:101 telephone-event/8000#015#012a=fmtp:101
0-16#015#012a=sendrecv#015
Jun 18 04:55:20 debian10opensips31 /data/opensips/sbin/opensips[3041]:
INFO:b2b_logic:b2bl_add_client: adding entity
[0x7f8e0f112f88]->[B2B.274.5538153.1624006520] to tuple
[0x7f8e0f10cd48]->[274.0]
Jun 18 04:55:20 debian10opensips31 /data/opensips/sbin/opensips[3041]:
route[0] INVITE sip:1000 at 192.168.68.115 SIP/2.0#015#012Via: SIP/2.0/UDP
192.168.68.115:5060;branch=z9hG4bKba3f.67a6a393.0#015#012To:
sip:1000 at 192.168.68.109:38419#015#012From:
<sip:1001 at 192.168.68.115;transport=UDP>;tag=29b4ae0b3643070a47d5f40529fb2fbd-cdb7#015#012CSeq:
2 INVITE#015#012Call-ID: B2B.274.5538153.1624006520#015#012Max-Forwards:
70#015#012Content-Length: 185#015#012User-Agent: OpenSIPS (3.2.0-beta
(x86_64/linux))#015#012Content-Type: application/sdp#015#012Allow:
INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO,
SUBSCRIBE#015#012Contact:
<sip:192.168.68.115>#015#012#015#012v=0#015#012o=Zoiper 1624006519564 1
IN IP4 192.168.68.104#015#012s=Z#015#012c=IN IP4
192.168.68.104#015#012t=0 0#015#012m=audio 44128 RTP/AVP 0 101
8#015#012a=rtpmap:101 telephone-event/8000#015#012a=fmtp:101
0-16#015#012a=sendrecv#015
Jun 18 04:55:20 debian10opensips31 /data/opensips/sbin/opensips[3041]:
INFO:b2b_logic:b2bl_add_client: adding entity
[0x7f8e0f119368]->[B2B.274.5538153.1624006520] to tuple
[0x7f8e0f1131c8]->[274.1]
Jun 18 04:55:21 debian10opensips31 /data/opensips/sbin/opensips[3040]:
callid=B2B.274.5538153.1624006520: route[b2b_reply]: incoming reply mb
[SIP/2.0 180 Ringing#015#012Via: SIP/2.0/UDP
192.168.68.115:5060;branch=z9hG4bKca3f.1c958c27.0#015#012Contact:
<sip:1000 at 192.168.68.109:38419>#015#012To:
<sip:1000 at 192.168.68.109:38419>;tag=1095d332#015#012From:
<sip:1001 at 192.168.68.115;transport=UDP>;tag=29b4ae0b3643070a47d5f40529fb2fbd-cdb7#015#012Call-ID:
B2B.274.5538153.1624006520#015#012CSeq: 3 INVITE#015#012Allow: INVITE,
ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO,
SUBSCRIBE#015#012User-Agent: Z 5.3.8 rv2.9.30-mod#015#012Allow-Events:
presence, kpml, talk#015#012Content-Length: 0#015#012#015#012]
Jun 18 04:55:23 debian10opensips31 /data/opensips/sbin/opensips[3041]:
INFO:b2b_logic:b2b_add_dlginfo: Dialog pair:
[B2B.274.5538153.1624006520] - [B2B.274.5538153.1624006520]
Jun 18 04:55:23 debian10opensips31 /data/opensips/sbin/opensips[3041]:
callid=B2B.274.5538153.1624006520: route[b2b_reply]: incoming reply mb
[SIP/2.0 200 OK#015#012Via: SIP/2.0/UDP
192.168.68.115:5060;branch=z9hG4bKca3f.1c958c27.0#015#012Contact:
<sip:1000 at 192.168.68.109:38419>#015#012To:
<sip:1000 at 192.168.68.109:38419>;tag=1095d332#015#012From:
<sip:1001 at 192.168.68.115;transport=UDP>;tag=29b4ae0b3643070a47d5f40529fb2fbd-cdb7#015#012Call-ID:
B2B.274.5538153.1624006520#015#012CSeq: 3 INVITE#015#012Allow: INVITE,
ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO,
SUBSCRIBE#015#012Content-Type: application/sdp#015#012User-Agent: Z
5.3.8 rv2.9.30-mod#015#012Allow-Events: presence, kpml,
talk#015#012Content-Length: 165#015#012#015#012v=0#015#012o=Z 0 1 IN IP4
192.168.68.109#015#012s=Z#015#012c=IN IP4 192.168.68.109#015#012t=0
0#015#012m=audio 8000 RTP/AVP 8 101#015#012a=rtpmap:101
telephone-event/8000#015#012a=fmtp:101 0-16#015#012a=sendrecv#015#012]

johan at debian10opensips31:~$


Script below:

####### Global Parameters #########

/* uncomment the following lines to enable debugging */
#debug_mode=yes

log_level=3
log_stderror=no
log_facility=LOG_LOCAL0

udp_workers=4

/* uncomment the next line to enable the auto temporary blacklisting of
   not available destinations (default disabled) */
#disable_dns_blacklist=no

/* uncomment the next line to enable IPv6 lookup after IPv4 dns
   lookup failures (default disabled) */
#dns_try_ipv6=yes

socket=udp:*:5060

####### Modules Section ########
#set module path
mpath="/data/opensips/lib64/opensips/modules/"

#### SIGNALING module
loadmodule "signaling.so"

#### StateLess module
loadmodule "sl.so"

#### Transaction Module
loadmodule "tm.so"
modparam("tm", "fr_timeout", 5)
modparam("tm", "fr_inv_timeout", 30)
modparam("tm", "restart_fr_on_each_reply", 0)
modparam("tm", "onreply_avp_mode", 1)


#### MAX ForWarD module
loadmodule "maxfwd.so"

#### SIP MSG OPerationS module
loadmodule "sipmsgops.so"

#### FIFO Management Interface
loadmodule "mi_fifo.so"
modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
modparam("mi_fifo", "fifo_mode", 0666)

#### USeR LOCation module
loadmodule "usrloc.so"
modparam("usrloc", "nat_bflag", "NAT")
modparam("usrloc", "working_mode_preset", "single-instance-no-db")

#### REGISTRAR module
loadmodule "registrar.so"
modparam("registrar", "tcp_persistent_flag", "TCP_PERSISTENT")

loadmodule "proto_udp.so"

loadmodule "mi_datagram.so"
loadmodule "event_datagram.so"
modparam("mi_datagram", "socket_name", "udp:127.0.0.1:8080")
loadmodule "b2b_entities.so"
loadmodule "b2b_logic.so"
modparam("b2b_logic", "script_req_route", "b2b_logic_request")
modparam("b2b_logic", "script_reply_route", "b2b_reply")

#### cfgutils
loadmodule "cfgutils.so"
#### textops
loadmodule "textops.so"
#### nathelper
loadmodule "nathelper.so"
#### rr
loadmodule "rr.so"
####### Routing Logic ########

# main request routing logic

route
{
    xlog("route[0] $mb");
    if (!mf_process_maxfwd_header(10))
    {
        send_reply(483,"Too Many Hops");
        exit;
    }

    # preloaded route checking
    if (loose_route())
    {
        xlog("LOOSE ROUTING $mb");
        route(relay);
    }

   
    # requests for my domain   
    if (is_method("PUBLISH|SUBSCRIBE"))
    {
        send_reply(503, "Service Unavailable");
        exit;
    }

    if (is_method("REGISTER"))
    {          
        if (!save("location"))
            sl_reply_error();
        exit;
    }
    if ($rU==NULL)
    {
        # request with no Username in RURI
        send_reply(484,"Address Incomplete");
        exit;
    }

    lookup("location","m");

    if (is_method("INVITE") && !has_totag()) {
       
        # create the server entity
        b2b_server_new("caller",$fu);
        # create the initial client entity, to connect the caller with
the callee
        b2b_client_new("callee", $tu);
        # initialize B2B session for the "refer" scenario
        b2b_init_request("refer");
    }
}


route[b2b_logic_request]
{
    xlog("callid=$ci: route b2b logic request: received message $mb");

    if ($rm != "REFER") {
        # for requests other than REFER, no special actions needs to be
done,
        # just pass the request to the peer

        b2b_pass_request();
        exit;
    }

    # end dialog with the referrer
    b2b_send_reply(202, "Accepted");
    b2b_end_dlg_leg();

    # create the client entity corresponding to
    # the user specified in the 'Refer-To' header
    b2b_client_new("referee", $hdr(Refer-To));

    # bridge the referrer's peer with the referee
    b2b_bridge("peer", "referee");
}

route[b2b_reply]
{
    xlog("callid=$ci: route[b2b_reply]: incoming reply mb [$mb]\n");     
}

route[relay] {
    # send it out now; use stateful forwarding as it works reliably
    # even for UDP2TCP
    xlog("callid=$ci: route[relay]: incoming message mb [$mb]\n");
    if (!t_relay()) {
        sl_reply_error();
    };
    exit;
}

Can somebody please give a hint on what I am doing wrong ?


wkr,






More information about the Users mailing list