ome::common::xml::dom::Document createDocument(const boost::filesystem::path& file, const ome::common::xml::dom::ParseParameters& params) { ome::xml::OMEEntityResolver& resolver = get_resolver(); return ome::common::xml::dom::createDocument(file, resolver, params); }
ome::common::xml::dom::Document createDocument(std::istream& stream, const ome::common::xml::dom::ParseParameters& params, const std::string& id) { ome::xml::OMEEntityResolver& resolver = get_resolver(); return ome::common::xml::dom::createDocument(stream, resolver, params, id); }
std::string DNSEnumService::lookup_uri_from_user(const std::string& user, SAS::TrailId trail) const { if (user.empty()) { TRC_INFO("No dial string supplied, so don't do ENUM lookup"); return std::string(); } // Log starting ENUM processing. SAS::Event event(trail, SASEvent::ENUM_START, 0); event.add_var_param(user); SAS::report_event(event); // Determine the Application Unique String (AUS) from the user. This is // used to form the first key, and also as the input into the regular // expressions. std::string aus = user_to_aus(user); std::string string = aus; // Get the resolver to use. This comes from thread-local data. DNSResolver* resolver = get_resolver(); // Spin round until we've finished (successfully or otherwise) or we've done // the maximum number of queries. bool complete = false; bool failed = false; bool server_failed = false; int dns_queries = 0; while ((!complete) && (!failed) && (dns_queries < MAX_DNS_QUERIES)) { // Translate the key into a domain and issue a query for it. std::string domain = key_to_domain(string); struct ares_naptr_reply* naptr_reply = NULL; int status = resolver->perform_naptr_query(domain, naptr_reply, trail); if (status == ARES_SUCCESS) { // Parse the reply into a sorted list of rules. std::vector<Rule> rules; parse_naptr_reply(naptr_reply, rules); // Now spin through the rules, looking for the first match. std::vector<DNSEnumService::Rule>::const_iterator rule; for (rule = rules.begin(); rule != rules.end(); ++rule) { if (rule->matches(string)) { // We found a match, so apply the regular expression to the AUS (not // the previous string - this is what ENUM mandates). If this was a // terminal rule, we now have a SIP URI and we're finished. // Otherwise, the output of the regular expression is used as the // next key. try { string = rule->replace(aus, trail); complete = rule->is_terminal(); } catch(...) // LCOV_EXCL_START Only throws if expression too complex or similar hard-to-hit conditions { TRC_ERROR("Failed to translate number with regex"); failed = true; // LCOV_EXCL_STOP } break; } } // If we didn't find a match (and so hit the end of the list), consider // this a failure. failed = failed || (rule == rules.end()); } else if (status == ARES_ENOTFOUND) { // Our DNS query failed, so give up, but this is not an ENUM server issue - // we just tried to look up an unknown name. failed = true; } else { // Our DNS query failed. Give up, and track an ENUM server failure. failed = true; server_failed = true; } // Free off the NAPTR reply if we have one. if (naptr_reply != NULL) { resolver->free_naptr_reply(naptr_reply); naptr_reply = NULL; } dns_queries++; } // Log that we've finished processing (and whether it was successful or not). if (complete) { TRC_DEBUG("Enum lookup completes: %s", string.c_str()); SAS::Event event(trail, SASEvent::ENUM_COMPLETE, 0); event.add_var_param(user); event.add_var_param(string); SAS::report_event(event); } else { TRC_WARNING("Enum lookup did not complete for user %s", user.c_str()); SAS::Event event(trail, SASEvent::ENUM_INCOMPLETE, 0); event.add_var_param(user); SAS::report_event(event); // On failure, we must return an empty (rather than incomplete) string. string = std::string(""); } // Report state of last communication attempt (which may potentially set/clear // an associated alarm). if (_comm_monitor) { if (server_failed) { _comm_monitor->inform_failure(); } else { _comm_monitor->inform_success(); } } return string; }
bool OptiTrackNatNetClient::connect() { if (command_socket) delete command_socket; command_socket = NULL; if (data_socket) delete data_socket; data_socket = NULL; boost::system::error_code ec; { sout << "Resolving " << serverName.getValue() << sendl; udp::resolver::query query(udp::v4(), serverName.getValue(), "0"); udp::resolver::iterator result = get_resolver().resolve(query, ec); if (ec) { serr << ec.category().name() << " ERROR while resolving " << serverName.getValue() << " : " << ec.message() << sendl; return false; } server_endpoint = *result; server_endpoint.port(PORT_COMMAND); sout << "Resolved " << serverName.getValue() << " to " << server_endpoint << sendl; } udp::endpoint client_endpoint(udp::v4(), PORT_DATA); if (!clientName.getValue().empty()) { sout << "Resolving " << clientName.getValue() << sendl; udp::resolver::query query(udp::v4(), clientName.getValue(), "0"); udp::resolver::iterator result = get_resolver().resolve(query, ec); if (ec) { serr << ec.category().name() << " ERROR while resolving " << clientName.getValue() << " : " << ec.message() << sendl; return false; } client_endpoint = *result; client_endpoint.port(PORT_DATA); sout << "Resolved " << clientName.getValue() << " to " << client_endpoint << sendl; } sout << "Opening data socket on " << client_endpoint << sendl; data_socket = new udp::socket(get_io_service()); if (data_socket->open(udp::v4(), ec)) { serr << ec.category().name() << " ERROR while opening data socket : " << ec.message() << sendl; return false; } data_socket->set_option(udp::socket::reuse_address(true)); if (data_socket->bind(client_endpoint, ec)) { serr << ec.category().name() << " ERROR while binding data socket : " << ec.message() << sendl; return false; } // Join the multicast group. if (!clientName.getValue().empty()) data_socket->set_option(boost::asio::ip::multicast::join_group(boost::asio::ip::address::from_string(MULTICAST_ADDRESS).to_v4(), client_endpoint.address().to_v4())); else data_socket->set_option(boost::asio::ip::multicast::join_group(boost::asio::ip::address::from_string(MULTICAST_ADDRESS))); sout << "Data socket ready" << sendl; start_data_receive(); sout << "Opening command socket" << sendl; command_socket = new udp::socket(get_io_service()); if (command_socket->open(udp::v4(), ec)) { serr << ec.category().name() << " ERROR while opening command socket : " << ec.message() << sendl; return false; } if (!clientName.getValue().empty()) { client_endpoint.port(0); if (command_socket->bind(client_endpoint, ec)) { serr << ec.category().name() << " ERROR while binding command socket : " << ec.message() << sendl; return false; } } sout << "Command socket ready" << sendl; start_command_receive(); //boost::shared_pointer<sPacket> helloMsg = new sPacket; //helloMsg.iMessage = NAT_PING; //helloMsg.nDataBytes = 0; sout << "Sending hello message..." << sendl; boost::array<unsigned short, 2> helloMsg; helloMsg[0] = NAT_PING; helloMsg[1] = 0; command_socket->send_to(boost::asio::buffer(helloMsg), server_endpoint); return true; }