mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-02 03:48:02 +00:00
IPv6 support for chan_ooh323
IPv6 support for ooh323, bindaddr, peers and users ip can be IPv4 or IPv6 addr correction for multi-homed mode (0.0.0.0 or :: bindaddr) can work in dual 6/4 mode with :: bindaddr gatekeeper mode isn't supported in v6 mode while (issue #18278) Reported by: may213 Patches: ipv6-ooh323.patch uploaded by may213 (license 454) Review: https://reviewboard.asterisk.org/r/1004/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@313482 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -226,7 +226,7 @@ int ooHandleFastStart(OOH323CallData *call, H225Facility_UUIE *facility)
|
||||
if(ret != OO_OK)
|
||||
{
|
||||
OOTRACEERR3("Error: Unknown H245 address type in received "
|
||||
"CallProceeding message (%s, %s)", call->callType,
|
||||
"Facility message (%s, %s)", call->callType,
|
||||
call->callToken);
|
||||
/* Mark call for clearing */
|
||||
if(call->callState < OO_CALL_CLEAR)
|
||||
@@ -368,8 +368,10 @@ int ooOnReceivedSetup(OOH323CallData *call, Q931Message *q931Msg)
|
||||
H245OpenLogicalChannel* olc;
|
||||
ASN1OCTET msgbuf[MAXMSGLEN];
|
||||
H225TransportAddress_ipAddress_ip *ip = NULL;
|
||||
H225TransportAddress_ip6Address_ip *ip6 = NULL;
|
||||
Q931InformationElement* pDisplayIE=NULL;
|
||||
OOAliases *pAlias=NULL;
|
||||
char remoteIP[2+8*4+7];
|
||||
|
||||
call->callReference = q931Msg->callReference;
|
||||
|
||||
@@ -507,18 +509,26 @@ int ooOnReceivedSetup(OOH323CallData *call, Q931Message *q931Msg)
|
||||
"setup (%s, %s)\n", call->callType, call->callToken);
|
||||
}
|
||||
else{
|
||||
|
||||
if(setup->sourceCallSignalAddress.t != T_H225TransportAddress_ipAddress)
|
||||
{
|
||||
OOTRACEERR3("ERROR: Source call signalling address type not ip "
|
||||
if(setup->sourceCallSignalAddress.t == T_H225TransportAddress_ip6Address) {
|
||||
ip6 = &setup->sourceCallSignalAddress.u.ip6Address->ip;
|
||||
inet_ntop(AF_INET6, ip6->data, remoteIP, INET6_ADDRSTRLEN);
|
||||
call->remotePort = setup->sourceCallSignalAddress.u.ip6Address->port;
|
||||
} else if(setup->sourceCallSignalAddress.t == T_H225TransportAddress_ipAddress) {
|
||||
ip = &setup->sourceCallSignalAddress.u.ipAddress->ip;
|
||||
sprintf(remoteIP, "%d.%d.%d.%d", ip->data[0], ip->data[1],
|
||||
ip->data[2], ip->data[3]);
|
||||
call->remotePort = setup->sourceCallSignalAddress.u.ipAddress->port;
|
||||
} else {
|
||||
OOTRACEERR3("ERROR: Source call signalling address type not ip4 nor ip6 "
|
||||
"(%s, %s)\n", call->callType, call->callToken);
|
||||
return OO_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
ip = &setup->sourceCallSignalAddress.u.ipAddress->ip;
|
||||
sprintf(call->remoteIP, "%d.%d.%d.%d", ip->data[0], ip->data[1],
|
||||
ip->data[2], ip->data[3]);
|
||||
call->remotePort = setup->sourceCallSignalAddress.u.ipAddress->port;
|
||||
if (strncmp(remoteIP, call->remoteIP, strlen(remoteIP))) {
|
||||
OOTRACEERR5("ERROR: Security denial remote sig IP isn't a socket ip, %s not %s "
|
||||
"(%s, %s)\n", remoteIP, call->remoteIP, call->callType,
|
||||
call->callToken);
|
||||
}
|
||||
|
||||
/* check for fast start */
|
||||
@@ -1814,6 +1824,7 @@ int ooOnReceivedFacility(OOH323CallData *call, Q931Message * pQ931Msg)
|
||||
H225Facility_UUIE * facility = NULL;
|
||||
int ret;
|
||||
H225TransportAddress_ipAddress_ip *ip = NULL;
|
||||
H225TransportAddress_ip6Address_ip *ip6 = NULL;
|
||||
OOTRACEDBGC3("Received Facility Message.(%s, %s)\n", call->callType,
|
||||
call->callToken);
|
||||
|
||||
@@ -1899,6 +1910,21 @@ int ooOnReceivedFacility(OOH323CallData *call, Q931Message * pQ931Msg)
|
||||
call->pCallFwdData->aliases = NULL;
|
||||
if(facility->m.alternativeAddressPresent)
|
||||
{
|
||||
if (call->versionIP == 6) {
|
||||
if(facility->alternativeAddress.t !=
|
||||
T_H225TransportAddress_ip6Address)
|
||||
{
|
||||
OOTRACEERR3("ERROR: Source call signalling address type not ip6 "
|
||||
"(%s, %s)\n", call->callType, call->callToken);
|
||||
|
||||
return OO_FAILED;
|
||||
}
|
||||
|
||||
ip6 = &facility->alternativeAddress.u.ip6Address->ip;
|
||||
inet_ntop(AF_INET6, ip6->data, call->pCallFwdData->ip, INET6_ADDRSTRLEN);
|
||||
call->pCallFwdData->port =
|
||||
facility->alternativeAddress.u.ip6Address->port;
|
||||
} else {
|
||||
if(facility->alternativeAddress.t !=
|
||||
T_H225TransportAddress_ipAddress)
|
||||
{
|
||||
@@ -1913,6 +1939,7 @@ int ooOnReceivedFacility(OOH323CallData *call, Q931Message * pQ931Msg)
|
||||
ip->data[1], ip->data[2], ip->data[3]);
|
||||
call->pCallFwdData->port =
|
||||
facility->alternativeAddress.u.ipAddress->port;
|
||||
}
|
||||
}
|
||||
|
||||
if(facility->m.alternativeAliasAddressPresent)
|
||||
@@ -1969,6 +1996,7 @@ int ooHandleStartH245FacilityMessage
|
||||
(OOH323CallData *call, H225Facility_UUIE *facility)
|
||||
{
|
||||
H225TransportAddress_ipAddress *ipAddress = NULL;
|
||||
H225TransportAddress_ip6Address *ip6Address = NULL;
|
||||
int ret;
|
||||
|
||||
/* Extract H245 address */
|
||||
@@ -1978,25 +2006,43 @@ int ooHandleStartH245FacilityMessage
|
||||
"address (%s, %s)\n", call->callType, call->callToken);
|
||||
return OO_FAILED;
|
||||
}
|
||||
if(facility->h245Address.t != T_H225TransportAddress_ipAddress)
|
||||
{
|
||||
if (call->versionIP == 6) {
|
||||
if(facility->h245Address.t != T_H225TransportAddress_ip6Address)
|
||||
{
|
||||
OOTRACEERR3("ERROR:Unknown H245 address type in received startH245 "
|
||||
"facility message (%s, %s)\n", call->callType, call->callToken);
|
||||
return OO_FAILED;
|
||||
}
|
||||
ipAddress = facility->h245Address.u.ipAddress;
|
||||
if(!ipAddress)
|
||||
{
|
||||
}
|
||||
ip6Address = facility->h245Address.u.ip6Address;
|
||||
if(!ip6Address)
|
||||
{
|
||||
OOTRACEERR3("ERROR:Invalid startH245 facility message. No H245 ip6 "
|
||||
"address found. (%s, %s)\n", call->callType, call->callToken);
|
||||
return OO_FAILED;
|
||||
}
|
||||
inet_ntop(AF_INET6, ip6Address->ip.data, call->remoteIP, INET6_ADDRSTRLEN);
|
||||
call->remoteH245Port = ip6Address->port;
|
||||
} else {
|
||||
if(facility->h245Address.t != T_H225TransportAddress_ipAddress)
|
||||
{
|
||||
OOTRACEERR3("ERROR:Unknown H245 address type in received startH245 "
|
||||
"facility message (%s, %s)\n", call->callType, call->callToken);
|
||||
return OO_FAILED;
|
||||
}
|
||||
ipAddress = facility->h245Address.u.ipAddress;
|
||||
if(!ipAddress)
|
||||
{
|
||||
OOTRACEERR3("ERROR:Invalid startH245 facility message. No H245 ip "
|
||||
"address found. (%s, %s)\n", call->callType, call->callToken);
|
||||
return OO_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(call->remoteIP, "%d.%d.%d.%d", ipAddress->ip.data[0],
|
||||
sprintf(call->remoteIP, "%d.%d.%d.%d", ipAddress->ip.data[0],
|
||||
ipAddress->ip.data[1],
|
||||
ipAddress->ip.data[2],
|
||||
ipAddress->ip.data[3]);
|
||||
call->remoteH245Port = ipAddress->port;
|
||||
call->remoteH245Port = ipAddress->port;
|
||||
}
|
||||
|
||||
/* disable tunneling for this call */
|
||||
OO_CLRFLAG (call->flags, OO_M_TUNNELING);
|
||||
@@ -2178,15 +2224,16 @@ int ooH323RetrieveAliases
|
||||
newAlias->value[strlen(pAliasAddress->u.url_ID)*sizeof(char)]='\0';
|
||||
break;
|
||||
case T_H225AliasAddress_transportID:
|
||||
newAlias->type = T_H225AliasAddress_transportID;
|
||||
pTransportAddrss = pAliasAddress->u.transportID;
|
||||
if(pTransportAddrss->t != T_H225TransportAddress_ipAddress)
|
||||
{
|
||||
OOTRACEERR3("Error:Alias transportID not an IP address"
|
||||
"(%s, %s)\n", call->callType, call->callToken);
|
||||
memFreePtr(call->pctxt, newAlias);
|
||||
break;
|
||||
}
|
||||
newAlias->type = T_H225AliasAddress_transportID;
|
||||
pTransportAddrss = pAliasAddress->u.transportID;
|
||||
if(pTransportAddrss->t == T_H225TransportAddress_ip6Address) {
|
||||
/* hopefully ip:port value can't exceed more than 30
|
||||
characters */
|
||||
newAlias->value = (char*)memAlloc(call->pctxt,
|
||||
INET6_ADDRSTRLEN*sizeof(char)*2);
|
||||
inet_ntop(AF_INET6, pTransportAddrss->u.ip6Address->ip.data, newAlias->value, INET6_ADDRSTRLEN);
|
||||
sprintf(newAlias->value+strlen(newAlias->value), ":%d", pTransportAddrss->u.ip6Address->port);
|
||||
} else if(pTransportAddrss->t == T_H225TransportAddress_ipAddress) {
|
||||
/* hopefully ip:port value can't exceed more than 30
|
||||
characters */
|
||||
newAlias->value = (char*)memAlloc(call->pctxt,
|
||||
@@ -2197,7 +2244,12 @@ int ooH323RetrieveAliases
|
||||
pTransportAddrss->u.ipAddress->ip.data[2],
|
||||
pTransportAddrss->u.ipAddress->ip.data[3],
|
||||
pTransportAddrss->u.ipAddress->port);
|
||||
break;
|
||||
} else {
|
||||
OOTRACEERR3("Error:Alias transportID not an IP4 nor IP6 address"
|
||||
"(%s, %s)\n", call->callType, call->callToken);
|
||||
memFreePtr(call->pctxt, newAlias);
|
||||
}
|
||||
break;
|
||||
case T_H225AliasAddress_email_ID:
|
||||
newAlias->type = T_H225AliasAddress_email_ID;
|
||||
newAlias->value = (char*)memAlloc(call->pctxt,
|
||||
@@ -2471,22 +2523,29 @@ OOAliases* ooH323AddAliasToList
|
||||
case T_H225AliasAddress_transportID:
|
||||
newAlias->type = T_H225AliasAddress_transportID;
|
||||
pTransportAddrss = pAliasAddress->u.transportID;
|
||||
if(pTransportAddrss->t != T_H225TransportAddress_ipAddress)
|
||||
{
|
||||
OOTRACEERR1("Error:Alias transportID not an IP address\n");
|
||||
memFreePtr(pctxt, newAlias);
|
||||
return NULL;
|
||||
}
|
||||
/* hopefully ip:port value can't exceed more than 30
|
||||
if(pTransportAddrss->t == T_H225TransportAddress_ip6Address) {
|
||||
/* hopefully ip:port value can't exceed more than 30
|
||||
characters */
|
||||
newAlias->value = (char*)memAlloc(pctxt,
|
||||
newAlias->value = (char*)memAlloc(pctxt,
|
||||
INET6_ADDRSTRLEN*sizeof(char)*2);
|
||||
inet_ntop(AF_INET6, pTransportAddrss->u.ip6Address->ip.data, newAlias->value, INET6_ADDRSTRLEN);
|
||||
sprintf(newAlias->value+strlen(newAlias->value), ":%d", pTransportAddrss->u.ip6Address->port);
|
||||
} else if(pTransportAddrss->t == T_H225TransportAddress_ipAddress) {
|
||||
/* hopefully ip:port value can't exceed more than 30
|
||||
characters */
|
||||
newAlias->value = (char*)memAlloc(pctxt,
|
||||
30*sizeof(char));
|
||||
sprintf(newAlias->value, "%d.%d.%d.%d:%d",
|
||||
sprintf(newAlias->value, "%d.%d.%d.%d:%d",
|
||||
pTransportAddrss->u.ipAddress->ip.data[0],
|
||||
pTransportAddrss->u.ipAddress->ip.data[1],
|
||||
pTransportAddrss->u.ipAddress->ip.data[2],
|
||||
pTransportAddrss->u.ipAddress->ip.data[3],
|
||||
pTransportAddrss->u.ipAddress->port);
|
||||
} else {
|
||||
OOTRACEERR1("Error:Alias transportID not an IP4 nor IP6 address\n");
|
||||
memFreePtr(pctxt, newAlias);
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
case T_H225AliasAddress_email_ID:
|
||||
newAlias->type = T_H225AliasAddress_email_ID;
|
||||
@@ -2509,6 +2568,17 @@ OOAliases* ooH323AddAliasToList
|
||||
int ooH323GetIpPortFromH225TransportAddress(struct OOH323CallData *call,
|
||||
H225TransportAddress *h225Address, char *ip, int *port)
|
||||
{
|
||||
if (call->versionIP == 6) {
|
||||
if(h225Address->t != T_H225TransportAddress_ip6Address)
|
||||
{
|
||||
OOTRACEERR3("Error: Unknown H225 address type. (%s, %s)", call->callType,
|
||||
call->callToken);
|
||||
return OO_FAILED;
|
||||
}
|
||||
inet_ntop(AF_INET6, h225Address->u.ip6Address->ip.data, ip, INET6_ADDRSTRLEN);
|
||||
*port = h225Address->u.ip6Address->port;
|
||||
return OO_OK;
|
||||
}
|
||||
if(h225Address->t != T_H225TransportAddress_ipAddress)
|
||||
{
|
||||
OOTRACEERR3("Error: Unknown H225 address type. (%s, %s)", call->callType,
|
||||
|
||||
Reference in New Issue
Block a user