Fixed URI parser limitation (protocol is now optional).

Fixed possible bug when resolved to non-IPv4 address.


git-svn-id: http://voip.null.ro/svn/yate@208 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2005-01-17 00:42:27 +00:00
parent a9db4dc64c
commit 0f7fcc188d
2 changed files with 16 additions and 3 deletions

View File

@ -84,11 +84,12 @@ void URI::parse() const
DDebug("URI",DebugAll,"new value='%s' [%p]",c_str(),this);
}
// proto:[user[:passwd]@]hostname[:port][/path][?param=value[&param=value...]]
// proto:[user@]hostname[:port][/path][;params][?params][&params]
r = "^\\([[:alpha:]]\\+\\):\\([[:alnum:]._-]\\+@\\)\\?\\([[:alnum:]._-]\\+\\)\\(:[0-9]\\+\\)\\?";
// [proto:][user[:passwd]@]hostname[:port][/path][?param=value[&param=value...]]
// [proto:][user@]hostname[:port][/path][;params][?params][&params]
r = "^\\([[:alpha:]]\\+:\\)\\?\\([[:alnum:]._-]\\+@\\)\\?\\([[:alnum:]._-]\\+\\)\\(:[0-9]\\+\\)\\?";
if (tmp.matches(r)) {
m_proto = tmp.matchString(1).toLower();
m_proto = m_proto.substr(0,m_proto.length()-1);
m_user = tmp.matchString(2);
m_user = m_user.substr(0,m_user.length()-1);
m_host = tmp.matchString(3).toLower();

View File

@ -331,6 +331,8 @@ bool YateUDPParty::setParty(const URI& uri)
{
if (m_partyPort && m_party && s_cfg.getBoolValue("general","ignorevia"))
return true;
if (uri.getHost().null())
return false;
int port = uri.getPort();
if (port <= 0)
port = 5060;
@ -342,6 +344,11 @@ bool YateUDPParty::setParty(const URI& uri)
err,uri.getHost().safe(),this);
return false;
}
if (he.h_addrtype != AF_INET) {
Debug("YateUDPParty",DebugWarn,"Address family %d not supported yet [%p]",
he.h_addrtype,this);
return false;
}
m_sin.sin_family = he.h_addrtype;
m_sin.sin_addr.s_addr = *((u_int32_t*)he.h_addr_list[0]);
m_sin.sin_port = htons((short)port);
@ -404,6 +411,11 @@ bool YateSIPEndPoint::buildParty(SIPMessage* message, const char* host, int port
Debug(DebugWarn,"Error %d resolving name '%s'",err,host);
return false;
}
if (he.h_addrtype != AF_INET) {
Debug("YateUDPParty",DebugWarn,"Address family %d not supported yet [%p]",
he.h_addrtype,this);
return false;
}
struct sockaddr_in sin;
sin.sin_family = he.h_addrtype;
sin.sin_addr.s_addr = *((u_int32_t*)he.h_addr_list[0]);