multiple_listeners.patch 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. diff --git a/pjproject/pjsip/src/pjsip/sip_transport.c b/pjproject_new/pjsip/src/pjsip/sip_transport.c
  2. index 4b2cc1a..22e3603 100644
  3. --- a/pjsip/src/pjsip/sip_transport.c
  4. +++ b/pjsip/src/pjsip/sip_transport.c
  5. @@ -1248,22 +1248,22 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_register_tpfactory( pjsip_tpmgr *mgr,
  6. pj_lock_acquire(mgr->lock);
  7. - /* Check that no factory with the same type has been registered. */
  8. + /* Check that no factory with the same type and bound address has been registered. */
  9. status = PJ_SUCCESS;
  10. for (p=mgr->factory_list.next; p!=&mgr->factory_list; p=p->next) {
  11. - if (p->type == tpf->type) {
  12. - status = PJSIP_ETYPEEXISTS;
  13. - break;
  14. - }
  15. - if (p == tpf) {
  16. - status = PJ_EEXISTS;
  17. - break;
  18. - }
  19. + if (p->type == tpf->type && !pj_sockaddr_cmp(&tpf->local_addr, &p->local_addr)) {
  20. + status = PJSIP_ETYPEEXISTS;
  21. + break;
  22. + }
  23. + if (p == tpf) {
  24. + status = PJ_EEXISTS;
  25. + break;
  26. + }
  27. }
  28. if (status != PJ_SUCCESS) {
  29. - pj_lock_release(mgr->lock);
  30. - return status;
  31. + pj_lock_release(mgr->lock);
  32. + return status;
  33. }
  34. pj_list_insert_before(&mgr->factory_list, tpf);
  35. @@ -2047,13 +2047,11 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,
  36. pj_memcpy(&key.rem_addr, remote, addr_len);
  37. transport = (pjsip_transport*)
  38. - pj_hash_get(mgr->table, &key, key_len, NULL);
  39. -
  40. + pj_hash_get(mgr->table, &key, key_len, NULL);
  41. + unsigned flag = pjsip_transport_get_flag_from_type(type);
  42. if (transport == NULL) {
  43. - unsigned flag = pjsip_transport_get_flag_from_type(type);
  44. const pj_sockaddr *remote_addr = (const pj_sockaddr*)remote;
  45. -
  46. /* Ignore address for loop transports. */
  47. if (type == PJSIP_TRANSPORT_LOOP ||
  48. type == PJSIP_TRANSPORT_LOOP_DGRAM)
  49. @@ -2135,6 +2135,11 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,
  50. }
  51. } else {
  52. + /* Make sure we don't use another factory than the one given if secure flag is set */
  53. + if (flag & PJSIP_TRANSPORT_SECURE) {
  54. + TRACE_((THIS_FILE, "Can't create new TLS transport with no provided suitable TLS listener."));
  55. + return PJSIP_ETPNOTSUITABLE;
  56. + }
  57. /* Find factory with type matches the destination type */
  58. factory = mgr->factory_list.next;