本文整理汇总了C++中Url::getHostAddress方法的典型用法代码示例。如果您正苦于以下问题:C++ Url::getHostAddress方法的具体用法?C++ Url::getHostAddress怎么用?C++ Url::getHostAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Url
的用法示例。
在下文中一共展示了Url::getHostAddress方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPreferredContactUri
UtlBoolean SipLine::getPreferredContactUri(Url& preferredContactUri) const
{
UtlString host ;
preferredContactUri = mPreferredContactUri ;
preferredContactUri.getHostAddress(host) ;
return (host.length() > 0) ;
}
示例2: execute
int AuthCommand::execute(int argc, char* argv[])
{
int commandStatus = CommandProcessor::COMMAND_FAILED;
Url identity;
UtlString user;
UtlString realm;
UtlString password;
switch ( argc )
{
case 2:
// Delete Identity
identity = argv[1];
printf( "Deleting identity '%s'\n", argv[1] );
mLineMgr.deleteLine( identity );
break;
case 3: // <identity-url> <password>
case 5: // <identity-url> <user> <realm> <password>
{
// Add Identity
identity = argv[1];
if ( 3 == argc )
{
identity.getHostAddress( realm );
identity.getUserId( user );
user.append("@");
user.append(realm);
password = argv[2];
}
else
{
user = argv[2];
realm = argv[3];
password = argv[4];
}
SipLine line( identity // user entered url
,identity // identity url
,user // user
,TRUE // visible
,SipLine::LINE_STATE_PROVISIONED
,TRUE // auto enable
,FALSE // use call handling
);
mLineMgr.addLine( line );
UtlString cred_input;
UtlString cred_digest;
cred_input.append( user );
cred_input.append( ":" );
cred_input.append( realm );
cred_input.append( ":" );
cred_input.append( password );
NetMd5Codec::encode( cred_input.data(), cred_digest );
printf("Adding identity '%s': user='%s' realm='%s' password='%s'\n"
" H(A1)='%s'\n"
,identity.toString().data(), user.data(), realm.data()
,password.data(), cred_digest.data()
);
commandStatus = ( mLineMgr.addCredentialForLine( identity, realm, user, cred_digest
,HTTP_DIGEST_AUTHENTICATION
)
)
? CommandProcessor::COMMAND_SUCCESS
: CommandProcessor::COMMAND_FAILED
;
}
break;
default:
fprintf( stderr, "%s: Invalid number of arguments\n", argv[0] );
fprintf( stderr, "%s%s", argv[0], UsageMsg );
break;
}
return(commandStatus);
}
示例3: contactUri
bool
SipRedirectorAliasDB::resolveAlias(
const SipMessage& message,
UtlString& requestString,
Url& requestUri
)
{
bool isDomainAlias = false;
bool isUserAlias = false;
UtlString domain;
UtlString hostAlias;
UtlString userAlias;
requestUri.getHostAddress(domain);
UtlBoolean isMyHostAlias = mpSipUserAgent->isMyHostAlias(requestUri);
if (mpSipUserAgent && domain != _localDomain && isMyHostAlias)
{
isDomainAlias = true;
hostAlias = domain;
}
UtlString requestIdentity;
requestUri.getIdentity(requestIdentity);
EntityDB::Aliases aliases;
bool isUserIdentity = false;
EntityDB* entityDb = SipRegistrar::getInstance(NULL)->getEntityDB();
entityDb->getAliasContacts(requestUri, aliases, isUserIdentity);
int numAliasContacts = aliases.size();
EntityDB::Aliases::iterator iter = aliases.begin();
if (numAliasContacts == 1 && iter != aliases.end())
{
// If disableForwarding and the relation value is "userforward",
// do not record this contact.
if (isUserIdentity && iter->relation != ALIASDB_RELATION_USERFORWARD && iter->relation != "callgroup")
{
UtlString contact = iter->contact.c_str();
Url contactUri(contact);
isUserAlias = true;
contactUri.getUserId(userAlias);
}
}
if (isUserAlias)
{
requestUri.setUserId(userAlias.data());
requestUri.getUri(requestString);
}
if (isDomainAlias)
{
requestUri.setHostAddress(hostAlias);
requestUri.getUri(requestString);
}
if (isUserAlias || isDomainAlias)
{
OS_LOG_NOTICE(FAC_SIP, "SipRedirectorAliasDB::lookUp normalized request-uri to " << requestString.data());
}
return isUserAlias || isDomainAlias;
}
示例4: parseRouteMatchContainer
OsStatus ForwardRules::parseRouteMatchContainer(const Url& requestUri,
const SipMessage& request,
UtlString& routeToString,
UtlString& mappingType,
bool& authRequired,
TiXmlNode* routesNode,
TiXmlNode* previousRouteMatchNode)
{
UtlString testHost;
requestUri.getHostAddress(testHost);
int testPort = requestUri.getHostPort();
if(testPort == SIP_PORT)
{
testPort = PORT_NONE;
}
UtlBoolean routeMatchFound = false;
OsStatus methodMatchFound = OS_FAILED;
TiXmlElement* routesElement = routesNode->ToElement();
TiXmlNode* routeMatchNode = previousRouteMatchNode;
// Iterate through routes container children looking for
// route tags
while ( (routeMatchNode = routesElement->IterateChildren(routeMatchNode))
&& methodMatchFound != OS_SUCCESS)
{
// Skip non-elements
if(routeMatchNode && routeMatchNode->Type() != TiXmlNode::ELEMENT)
{
continue;
}
// Skip non-route elements
TiXmlElement* routeMatchElement = routeMatchNode->ToElement();
UtlString tagValue = routeMatchElement->Value();
if(tagValue.compareTo(XML_TAG_ROUTEMATCH) != 0 )
{
continue;
}
mappingType.remove(0);
routeToString.remove(0);
const char* mappingTypePtr =
routeMatchElement->Attribute(XML_ATT_MAPPINGTYPE);
//get the mapping Type attribute
mappingType.append(mappingTypePtr ? mappingTypePtr : "");
// Iterate through the route container's children looking
// for routeFrom, routeIPv4subnet, or routeDnsWildcard elements
TiXmlNode* routeFromPatternNode = NULL;
for( routeFromPatternNode = routeMatchElement->FirstChildElement();
routeFromPatternNode;
routeFromPatternNode = routeFromPatternNode->NextSiblingElement() )
{
// Skip elements that aren't of the "domainMatches" family
enum {ret_from, ret_ip, ret_dns} routeElementType ;
const char *name = routeFromPatternNode->Value() ;
if (strcmp(name, XML_TAG_ROUTEFROM) == 0)
{
routeElementType = ret_from;
}
else if (strcmp(name, XML_TAG_ROUTEIPV4SUBNET) == 0)
{
routeElementType = ret_ip;
}
else if (strcmp(name, XML_TAG_ROUTEDNSWILDCARD) == 0)
{
routeElementType = ret_dns;
}
else
{
continue ;
}
//found "domainMatches" pattern tag
TiXmlElement* routeFromPatternElement = routeFromPatternNode->ToElement();
//get the text value from it
TiXmlNode* routeFromPatternText = routeFromPatternElement->FirstChild();
if(routeFromPatternText && routeFromPatternText->Type() == TiXmlNode::TEXT)
{
TiXmlText* Xmlpattern = routeFromPatternText->ToText();
if (Xmlpattern)
{
UtlString pattern = Xmlpattern->Value();
switch(routeElementType)
{
case ret_from: // a routeFrom element matches host and port
{
Url xmlUrl(pattern.data());
UtlString xmlHost;
xmlUrl.getHostAddress(xmlHost);
int xmlPort = xmlUrl.getHostPort();
// See if the host and port of the routeFrom elelment
// match that of the URI
//.........这里部分代码省略.........
示例5: contactUri
RedirectPlugin::LookUpStatus
SipRedirectorAliasDB::lookUp(
const SipMessage& message,
UtlString& requestString,
Url& requestUri,
const UtlString& method,
ContactList& contactList,
RequestSeqNo requestSeqNo,
int redirectorNo,
SipRedirectorPrivateStorage*& privateStorage,
ErrorDescriptor& errorDescriptor)
{
// If url param sipx-userforward = false, do not redirect to user-forward
// aliases.
UtlString userforwardParam;
requestUri.getUrlParameter("sipx-userforward", userforwardParam);
bool disableForwarding =
userforwardParam.compareTo("false", UtlString::ignoreCase) == 0;
if (disableForwarding)
{
Os::Logger::instance().log(FAC_SIP, PRI_DEBUG, "%s::lookUp user forwarding disabled by parameter",
mLogName.data());
}
bool isDomainAlias = false;
UtlString domain;
UtlString hostAlias;
requestUri.getHostAddress(domain);
UtlBoolean isMyHostAlias = mpSipUserAgent->isMyHostAlias(requestUri);
if (mpSipUserAgent && domain != _localDomain && isMyHostAlias)
{
isDomainAlias = true;
hostAlias = domain;
requestUri.setHostAddress(_localDomain);
}
UtlString requestIdentity;
requestUri.getIdentity(requestIdentity);
OS_LOG_DEBUG(FAC_SIP, mLogName.data() << "::lookUp identity: " << requestIdentity.data()
<< " domain: " << domain.data()
<< " local-domain: " << _localDomain.data()
<< " isHostAlias: " << isMyHostAlias);
//ResultSet aliases;
//AliasDB::getInstance()->getContacts(requestUri, aliases);
//int numAliasContacts = aliases.getSize();
EntityDB::Aliases aliases;
bool isUserIdentity = false;
EntityDB* entityDb = SipRegistrar::getInstance(NULL)->getEntityDB();
entityDb->getAliasContacts(requestUri, aliases, isUserIdentity);
int numAliasContacts = aliases.size();
if (numAliasContacts > 0)
{
Os::Logger::instance().log(FAC_SIP, PRI_DEBUG, "%s::lookUp "
"got %d AliasDB contacts", mLogName.data(),
numAliasContacts);
// Check if the request identity is a real user/extension
UtlString realm;
UtlString authType;
SipXauthIdentity authIdentity;
authIdentity.setIdentity(requestIdentity);
for (EntityDB::Aliases::iterator iter = aliases.begin(); iter != aliases.end(); iter++)
{
// If disableForwarding and the relation value is "userforward",
// do not record this contact.
if (!(disableForwarding && iter->relation == ALIASDB_RELATION_USERFORWARD))
{
UtlString contact = iter->contact.c_str();
Url contactUri(contact);
// if the request identity is a real user
if (isUserIdentity)
{
// Encode AuthIdentity into the URI
authIdentity.encodeUri(contactUri, message);
}
contactUri.setUrlParameter(SIP_SIPX_CALL_DEST_FIELD, "AL");
if (numAliasContacts == 1 && isDomainAlias && isUserIdentity)
{
UtlString userId;
contactUri.getUserId(userId);
requestUri.setUserId(userId.data());
requestUri.getUri(requestString);
OS_LOG_NOTICE(FAC_SIP, "SipRedirectorAliasDB::lookUp normalized request-uri to " << requestString.data());
}
else
{
//.........这里部分代码省略.........