multiple tcp factories

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Harald,

You are right, it should not work. I dug and found that we no longer use TCP because, when we try to restart our program, the socket is not closed and we can?t restart it immediately. TCP is only on test machines and I think that there is only one TCP peer configured.

Sorry
Bernard

De : pjsip [mailto:pjsip-bounces at lists.pjsip.org] De la part de Harald Radke
Envoy? : mardi 12 mai 2015 10:38
? : pjsip at lists.pjsip.org
Objet : Re: [pjsip] multiple tcp factories

Hi Bernard,
Thx for your quick reply

hm, I wonder why your TCP start works, since when the second TCP transport is started, the tp_mgr should refuse to add it, since
another TCP factory is already registered, and in consequence the listerner would be destroyed.
(I kinda "created" my own version of transport_tcp.c where basically the _start() function does all the stuff EXCEPT for registering at the transport manager...ugly but works)

The rest is pretty much what I did  (-:

Problem is, that this way with every new request you send a new tcp transport and thus connection is created, so if you have a larger number of calls with frequent requests (like INFO or OPTIONS) I think one could get into trouble conerning TCP connections.
( when aquiring a transport, the manager will blindly use a passed tcp listener to create a new transport no matter what...)

My approach was then to maintain a hashtable within  each of the tcp factories/listeners and do a "local" lookup in the create_transport callback of the listener...but this is also kinda ugly because now transports are maintained in two tables.

Also I am not sure if I miss some transport lookup within PJSIP where no selector is set

Regards,

Harry


Gesendet: Dienstag, 12. Mai 2015 um 10:16 Uhr
Von: "POQUILLON, Bernard" <bpoquillon at prosodie.com<mailto:bpoquillon at prosodie.com>>
An: "pjsip list" <pjsip at lists.pjsip.org<mailto:pjsip at lists.pjsip.org>>
Betreff: Re: [pjsip] multiple tcp factories
Hi Harald,

I am currently using many interfaces with PJSIP. For that, I have a table describing the type (UDP, TCP?), the address and the port for each peer. Each peer has also a transport selector.
The initialization is like:
for (i = 0; i < tab_size; ++i) {
        pj_sockaddr_init(AF, &addr, NULL,  (pj_uint16_t)tab[i].local_port);
        addr.ipv4.sin_addr.s_addr = tab[i].local_addr;
        switch(tab[i].type) {
        case UDP :
               status = pjsip_udp_transport_start(g_endpt, &addr.ipv4,
                                NULL, 1, &tp_select.u.transport);
                        tp_select.type = PJSIP_TPSELECTOR_TRANSPORT;
                        break;
        case TCP :
               status = pjsip_tcp_transport_start(g_endpt, &addr.ipv4,
                       1, &tp_select.u.listener);
               tp_select.type = PJSIP_TPSELECTOR_LISTENER;
               break;
        default:
               status = PJ_EAFNOTSUP;
               break;
        }

        if (status != PJ_SUCCESS) {
               APP_PERROR("Unable to start transport");
               return -1;
        }

        tab[i].tp_select = malloc(sizeof(tp_select));
        if (socks->tab[i].tp_select == NULL) {
                log_afffat("%s:%d malloc failed", __FILE__, __LINE__);
                return -1;
        }
        memcpy(tab[i].tp_select, &tp_select, sizeof(tp_select));
}

When a call arrives, the used peer can be retrieved from rdata which contains the address (rdata->pkt_info.src_name), the port (rdata->pkt_info.src_port) and the type (rdata->tp_info.transport->type_name).
For an outbound call, you determine the peer you want to use.
Then you can use pjsip_dlg_set_transport(dlg, tab[peer_to_use].tp_select); to set the transport for the call.

Hope it helps.
Bernard

De : pjsip [mailto:pjsip-bounces at lists.pjsip.org] De la part de Harald Radke
Envoy? : mardi 12 mai 2015 09:44
? : pjsip at lists.pjsip.org<mailto:pjsip at lists.pjsip.org>
Objet : [pjsip] multiple tcp factories

Hi list:

still on the topic on how to implement the use of multiple TCP transport factories in order to be able to listen on and use specific network interfaces for certain calls.

Eth1:
192.168.0.1

Eth2:
192.168.0.2

the SIP user should listen on both addresses on the same port for incoming calls, and establish certain calls using a certain interface (configurable)

I started to do the transport (factory) handling on myown, separatly from the transport(manager) susbsystem, but it is getting quite a lot of work and I am always afraid to miss something...

Any chance to get something like that in PJSIP in the near future?

If not, what do you think would be the better approach for me:

- modify the PJSIP code
or
- write a parallel subsytem

Thx and regards,

Harry
_______________________________________________ Visit our blog: http://blog.pjsip.org pjsip mailing list pjsip at lists.pjsip.org<mailto:pjsip at lists.pjsip.org> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20150512/986c329e/attachment.html>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux