/// Apply the mangalgorithm to the specified URI. The user part of the URI is /// always mangled. The domain is mangled separately, and is only mangled if /// mangelwurzel's change_domain flag is set, or if the function's /// force_mangle_domain flag is set (we use this flag to make sure we always /// mangle the domains for Routes and Record-Routes). We don't mangle /// anything else (e.g. port number, SIP parameters). void MangelwurzelTsx::mangle_uri(pjsip_uri* uri, pj_pool_t* pool, bool force_mangle_domain) { if (PJSIP_URI_SCHEME_IS_SIP(uri)) { pjsip_sip_uri* sip_uri = (pjsip_sip_uri*)uri; std::string user = PJUtils::pj_str_to_string(&sip_uri->user); mangle_string(user); sip_uri->user = pj_strdup3(pool, user.c_str()); if ((force_mangle_domain) || (_config.change_domain)) { std::string host = PJUtils::pj_str_to_string(&sip_uri->host); mangle_string(host); sip_uri->host = pj_strdup3(pool, host.c_str()); } } else if (PJSIP_URI_SCHEME_IS_TEL(uri)) { pjsip_tel_uri* tel_uri = (pjsip_tel_uri*)uri; std::string number = PJUtils::pj_str_to_string(&tel_uri->number); mangle_string(number); tel_uri->number = pj_strdup3(pool, number.c_str()); } }
/// Apply the mangalgorithm to the From tag, To tag (if present) and call ID of /// req. void MangelwurzelTsx::mangle_dialog_identifiers(pjsip_msg* req, pj_pool_t* pool) { pjsip_from_hdr* from_hdr = PJSIP_MSG_FROM_HDR(req); if (from_hdr != NULL) { std::string from_tag = PJUtils::pj_str_to_string(&from_hdr->tag); mangle_string(from_tag); TRC_DEBUG("From tag mangled to %s", from_tag.c_str()); from_hdr->tag = pj_strdup3(pool, from_tag.c_str()); } pjsip_to_hdr* to_hdr = PJSIP_MSG_TO_HDR(req); if (to_hdr != NULL) { std::string to_tag = PJUtils::pj_str_to_string(&to_hdr->tag); mangle_string(to_tag); TRC_DEBUG("To tag mangled to %s", to_tag.c_str()); to_hdr->tag = pj_strdup3(pool, to_tag.c_str()); } pjsip_cid_hdr* cid_hdr = (pjsip_cid_hdr*)pjsip_msg_find_hdr(req, PJSIP_H_CALL_ID, NULL); if (cid_hdr != NULL) { std::string call_id = PJUtils::pj_str_to_string(&cid_hdr->id); mangle_string(call_id); TRC_DEBUG("Call ID manged to %s", call_id.c_str()); cid_hdr->id = pj_strdup3(pool, call_id.c_str()); // Report a SAS marker for the new call ID so that the two dialogs can be // correlated in SAS. TRC_DEBUG("Logging SAS Call-ID marker, Call-ID %.*s", cid_hdr->id.slen, cid_hdr->id.ptr); SAS::Marker cid_marker(trail(), MARKER_ID_SIP_CALL_ID, 1u); cid_marker.add_var_param(cid_hdr->id.slen, cid_hdr->id.ptr); SAS::report_marker(cid_marker, SAS::Marker::Scope::Trace); } }
bool FieldVisitor::ProcessTemplate(std::string in_name , clang::CXXRecordDecl * crd ) { // Save container namespaces and classes. fdes->getNamespacesAndClasses(crd->getDeclContext()) ; size_t pos ; // Check to see if we've processed this template before // If not we need to create attributes for this template if ( processed_templates.find(in_name) == processed_templates.end() ) { std::string mangled_name = mangle_string(in_name) ; // save off the mangled name of this template to be used if another variable is the same template type processed_templates[in_name] = fdes->getContainerClass() + "_" + fdes->getName() + "_" + mangled_name ; // Traverse the template declaration CXXRecordVisitor template_spec_cvis(ci , cs, hsd , pa, false, false, true) ; template_spec_cvis.get_class_data()->setMangledTypeName(processed_templates[in_name]) ; template_spec_cvis.TraverseCXXRecordDecl(crd) ; // Set the actual type name and file name. Print the attributes for this template type template_spec_cvis.get_class_data()->setName(in_name) ; template_spec_cvis.get_class_data()->setFileName(fdes->getFileName()) ; pa.printClass(template_spec_cvis.get_class_data()) ; if ( debug_level >= 4 ) { std::cout << "Added template class from FieldVisitor ProcessTemplate " ; std::cout << in_name << std::endl ; std::cout << *fdes << std::endl ; } } fdes->setMangledTypeName(processed_templates[in_name]) ; fdes->setEnumString("TRICK_STRUCTURED") ; fdes->setRecord(true) ; // processing the template will process the type, return false to stop processing return false ; }