Changeset 5518 for pjproject/trunk/pjsip/src/pjsua2/endpoint.cpp
- Timestamp:
- Jan 11, 2017 1:41:31 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua2/endpoint.cpp
r5501 r5518 45 45 /////////////////////////////////////////////////////////////////////////////// 46 46 47 TlsInfo::TlsInfo() 48 { 49 pj_bzero(this, sizeof(TlsInfo)); 50 } 51 52 bool TlsInfo::isEmpty() const 53 { 54 TlsInfo dummy; 55 56 pj_bzero(&dummy, sizeof(dummy)); 57 return ((pj_memcmp(this, &dummy, sizeof(dummy)) == 0)? true: false); 58 } 59 60 void TlsInfo::fromPj(const pjsip_tls_state_info &info) 61 { 62 #if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK != 0 63 pj_ssl_sock_info *ssock_info = info.ssl_sock_info; 64 char straddr[PJ_INET6_ADDRSTRLEN+10]; 65 const char *verif_msgs[32]; 66 unsigned verif_msg_cnt; 67 68 established = PJ2BOOL(ssock_info->established); 69 protocol = ssock_info->proto; 70 cipher = ssock_info->cipher; 71 cipherName = pj_ssl_cipher_name(ssock_info->cipher); 72 pj_sockaddr_print(&ssock_info->local_addr, straddr, sizeof(straddr), 3); 73 localAddr = straddr; 74 pj_sockaddr_print(&ssock_info->remote_addr, straddr, sizeof(straddr),3); 75 remoteAddr = straddr; 76 verifyStatus = ssock_info->verify_status; 77 if (ssock_info->local_cert_info) 78 localCertInfo.fromPj(*ssock_info->local_cert_info); 79 if (ssock_info->remote_cert_info) 80 remoteCertInfo.fromPj(*ssock_info->remote_cert_info); 81 82 /* Dump server TLS certificate verification result */ 83 verif_msg_cnt = PJ_ARRAY_SIZE(verif_msgs); 84 pj_ssl_cert_get_verify_status_strings(ssock_info->verify_status, 85 verif_msgs, &verif_msg_cnt); 86 for (unsigned i = 0; i < verif_msg_cnt; ++i) { 87 verifyMsgs.push_back(verif_msgs[i]); 88 } 89 #endif 90 } 91 92 bool SslCertInfo::isEmpty() const 93 { 94 SslCertInfo dummy; 95 96 pj_bzero(&dummy, sizeof(dummy)); 97 return ((pj_memcmp(this, &dummy, sizeof(dummy)) == 0)? true: false); 98 } 99 100 void SslCertInfo::fromPj(const pj_ssl_cert_info &info) 101 { 102 version = info.version; 103 pj_memcpy(serialNo, info.serial_no, sizeof(info.serial_no)); 104 subjectCn = pj2Str(info.subject.cn); 105 subjectInfo = pj2Str(info.subject.info); 106 issuerCn = pj2Str(info.issuer.cn); 107 issuerInfo = pj2Str(info.issuer.info); 108 validityStart.fromPj(info.validity.start); 109 validityEnd.fromPj(info.validity.end); 110 validityGmt = PJ2BOOL(info.validity.gmt); 111 raw = pj2Str(info.raw); 112 113 for (unsigned i = 0; i < info.subj_alt_name.cnt; i++) { 114 SslCertName cname; 115 cname.type = info.subj_alt_name.entry[i].type; 116 cname.name = pj2Str(info.subj_alt_name.entry[i].name); 117 subjectAltName.push_back(cname); 118 } 119 } 120 121 /////////////////////////////////////////////////////////////////////////////// 122 47 123 UaConfig::UaConfig() 48 124 : mainThreadOnly(false) … … 559 635 560 636 prm.hnd = (TransportHandle)tp; 637 prm.type = tp->type_name; 561 638 prm.state = state; 562 639 prm.lastError = info ? info->status : PJ_SUCCESS; 640 pj_bzero(&prm.tlsInfo, sizeof(TlsInfo)); 641 642 #if defined(PJSIP_HAS_TLS_TRANSPORT) && PJSIP_HAS_TLS_TRANSPORT!=0 643 if (!pj_ansi_stricmp(tp->type_name, "tls") && info->ext_info && 644 (state == PJSIP_TP_STATE_CONNECTED || 645 ((pjsip_tls_state_info*)info->ext_info)-> 646 ssl_sock_info->verify_status != PJ_SUCCESS)) 647 { 648 prm.tlsInfo.fromPj(*((pjsip_tls_state_info*)info->ext_info)); 649 } 650 #endif 563 651 564 652 ep.onTransportState(prm); … … 1695 1783 } 1696 1784 1785 void Endpoint::transportShutdown(TransportHandle tp) throw(Error) 1786 { 1787 PJSUA2_CHECK_EXPR( pjsip_transport_shutdown((pjsip_transport *)tp) ); 1788 } 1789 1697 1790 /////////////////////////////////////////////////////////////////////////////// 1698 1791 /*
Note: See TracChangeset
for help on using the changeset viewer.