multiple tcp factories

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

 



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
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20150512/2331807a/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