Changeset 3106 for pjproject/trunk/pjsip/src/pjsip/sip_transport.c
- Timestamp:
- Feb 24, 2010 5:43:34 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip/sip_transport.c
r3077 r3106 90 90 void (*on_rx_msg)(pjsip_endpoint*, pj_status_t, pjsip_rx_data*); 91 91 pj_status_t (*on_tx_msg)(pjsip_endpoint*, pjsip_tx_data*); 92 pjsip_tp_state_callback *tp_state_cb; 93 void *tp_state_user_data; 92 94 }; 93 95 … … 865 867 * Register to hash table (see Trac ticket #42). 866 868 */ 867 key_len = sizeof(tp->key.type) + tp->addr_len;869 key_len = sizeof(tp->key.type) + sizeof(tp->key.hname) + tp->addr_len; 868 870 pj_lock_acquire(mgr->lock); 869 871 … … 915 917 * Unregister from hash table (see Trac ticket #42). 916 918 */ 917 key_len = sizeof(tp->key.type) + tp->addr_len;919 key_len = sizeof(tp->key.type) + sizeof(tp->key.hname) + tp->addr_len; 918 920 hval = 0; 919 921 entry = pj_hash_get(mgr->table, &tp->key, key_len, &hval); … … 1503 1505 pjsip_transport **tp) 1504 1506 { 1507 return pjsip_tpmgr_acquire_transport2(mgr, type, remote, addr_len, sel, 1508 NULL, tp); 1509 } 1510 1511 /* 1512 * pjsip_tpmgr_acquire_transport2() 1513 * 1514 * Get transport suitable to communicate to remote. Create a new one 1515 * if necessary. 1516 */ 1517 PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr, 1518 pjsip_transport_type_e type, 1519 const pj_sockaddr_t *remote, 1520 int addr_len, 1521 const pjsip_tpselector *sel, 1522 pjsip_tx_data *tdata, 1523 pjsip_transport **tp) 1524 { 1505 1525 pjsip_tpfactory *factory; 1506 1526 pj_status_t status; … … 1572 1592 pjsip_transport *transport; 1573 1593 1594 /* 1595 * Find factory that can create such transport. 1596 */ 1597 factory = mgr->factory_list.next; 1598 while (factory != &mgr->factory_list) { 1599 if (factory->type == type) 1600 break; 1601 factory = factory->next; 1602 } 1603 if (factory == &mgr->factory_list) 1604 factory = NULL; 1605 1574 1606 pj_bzero(&key, sizeof(key)); 1575 key_len = sizeof(key.type) + addr_len;1607 key_len = sizeof(key.type) + sizeof(key.hname) + addr_len; 1576 1608 1577 1609 /* First try to get exact destination. */ 1578 1610 key.type = type; 1579 1611 pj_memcpy(&key.rem_addr, remote, addr_len); 1612 if (factory && factory->create_transport2 && 1613 tdata && tdata->dest_info.name.slen) 1614 { 1615 /* Only include hostname hash in the key when the factory support 1616 * create_transport2() and tdata is supplied. 1617 */ 1618 key.hname = pj_hash_calc_tolower(0, 1619 (char*)tdata->dest_info.name.ptr, 1620 &tdata->dest_info.name); 1621 } 1580 1622 1581 1623 transport = (pjsip_transport*) 1582 1624 pj_hash_get(mgr->table, &key, key_len, NULL); 1625 1583 1626 if (transport == NULL) { 1584 1627 unsigned flag = pjsip_transport_get_flag_from_type(type); 1585 1628 const pj_sockaddr *remote_addr = (const pj_sockaddr*)remote; 1629 1586 1630 1587 1631 /* Ignore address for loop transports. */ … … 1592 1636 1593 1637 pj_bzero(addr, addr_len); 1594 key_len = sizeof(key.type) + addr_len;1638 key_len = sizeof(key.type) + sizeof(key.hname) + addr_len; 1595 1639 transport = (pjsip_transport*) 1596 1640 pj_hash_get(mgr->table, &key, key_len, NULL); … … 1605 1649 addr->addr.sa_family = remote_addr->addr.sa_family; 1606 1650 1607 key_len = sizeof(key.type) + addr_len;1651 key_len = sizeof(key.type) + sizeof(key.hname) + addr_len; 1608 1652 transport = (pjsip_transport*) 1609 1653 pj_hash_get(mgr->table, &key, key_len, NULL); … … 1625 1669 /* 1626 1670 * Transport not found! 1627 * Find factory that can create such transport.1628 1671 */ 1629 factory = mgr->factory_list.next; 1630 while (factory != &mgr->factory_list) { 1631 if (factory->type == type) 1632 break; 1633 factory = factory->next; 1634 } 1635 1636 if (factory == &mgr->factory_list) { 1672 if (NULL == factory) { 1637 1673 /* No factory can create the transport! */ 1638 1674 pj_lock_release(mgr->lock); … … 1640 1676 return PJSIP_EUNSUPTRANSPORT; 1641 1677 } 1642 1643 1678 } 1644 1679 … … 1647 1682 1648 1683 /* Request factory to create transport. */ 1649 status = factory->create_transport(factory, mgr, mgr->endpt, 1650 (const pj_sockaddr*) remote, addr_len, 1651 tp); 1684 if (factory->create_transport2) { 1685 status = factory->create_transport2(factory, mgr, mgr->endpt, 1686 (const pj_sockaddr*) remote, 1687 addr_len, tdata, tp); 1688 } else { 1689 status = factory->create_transport(factory, mgr, mgr->endpt, 1690 (const pj_sockaddr*) remote, 1691 addr_len, tp); 1692 } 1652 1693 if (status == PJ_SUCCESS) { 1653 1694 PJ_ASSERT_ON_FAIL(tp!=NULL, … … 1712 1753 } 1713 1754 1755 PJ_DEF(pj_status_t) pjsip_tpmgr_set_status_cb(pjsip_tpmgr *mgr, 1756 pjsip_tp_state_callback *cb) 1757 { 1758 PJ_ASSERT_RETURN(mgr, PJ_EINVAL); 1759 1760 mgr->tp_state_cb = cb; 1761 1762 return PJ_SUCCESS; 1763 } 1764 1765 PJ_DEF(pjsip_tp_state_callback*) pjsip_tpmgr_get_status_cb( 1766 const pjsip_tpmgr *mgr) 1767 { 1768 PJ_ASSERT_RETURN(mgr, NULL); 1769 1770 return mgr->tp_state_cb; 1771 }
Note: See TracChangeset
for help on using the changeset viewer.