[asterisk-commits] may: branch may/ooh323_ipv6 r292666 - /team/may/ooh323_ipv6/addons/ooh323c/src/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Oct 21 16:45:48 CDT 2010


Author: may
Date: Thu Oct 21 16:45:44 2010
New Revision: 292666

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=292666
Log:
changes in OLC functions

Modified:
    team/may/ooh323_ipv6/addons/ooh323c/src/ooh245.c

Modified: team/may/ooh323_ipv6/addons/ooh323c/src/ooh245.c
URL: http://svnview.digium.com/svn/asterisk/team/may/ooh323_ipv6/addons/ooh323c/src/ooh245.c?view=diff&rev=292666&r1=292665&r2=292666
==============================================================================
--- team/may/ooh323_ipv6/addons/ooh323c/src/ooh245.c (original)
+++ team/may/ooh323_ipv6/addons/ooh323c/src/ooh245.c Thu Oct 21 16:45:44 2010
@@ -1559,7 +1559,8 @@
    H245H2250LogicalChannelAckParameters *h2250lcap=NULL;
    OOCTXT *pctxt;
    H245UnicastAddress *unicastAddrs, *unicastAddrs1;
-   H245UnicastAddress_iPAddress *iPAddress, *iPAddress1;
+   H245UnicastAddress_iPAddress *iPAddress = NULL, *iPAddress1 = NULL;
+   H245UnicastAddress_iP6Address *iP6Address = NULL, *iP6Address1 = NULL;
    ooLogicalChannel *pLogicalChannel = NULL;
    H245H2250LogicalChannelParameters *h2250lcp=NULL;
    H245OpenLogicalChannel_forwardLogicalChannelParameters *flcp =
@@ -1637,11 +1638,20 @@
 
    unicastAddrs = h2250lcap->mediaChannel.u.unicastAddress;
    memset(unicastAddrs, 0, sizeof(H245UnicastAddress));
-   unicastAddrs->t = T_H245UnicastAddress_iPAddress;
-   unicastAddrs->u.iPAddress = (H245UnicastAddress_iPAddress*)
+
+   if (gH323ep.v6Mode) {
+   	unicastAddrs->t = T_H245UnicastAddress_iP6Address;
+   	unicastAddrs->u.iP6Address = (H245UnicastAddress_iP6Address*)
+               memAlloc(pctxt, sizeof(H245UnicastAddress_iP6Address));
+   	iP6Address = unicastAddrs->u.iP6Address;
+   	memset(iP6Address, 0, sizeof(H245UnicastAddress_iP6Address));
+   } else {
+   	unicastAddrs->t = T_H245UnicastAddress_iPAddress;
+   	unicastAddrs->u.iPAddress = (H245UnicastAddress_iPAddress*)
                memAlloc(pctxt, sizeof(H245UnicastAddress_iPAddress));
-   iPAddress = unicastAddrs->u.iPAddress;
-   memset(iPAddress, 0, sizeof(H245UnicastAddress_iPAddress));
+   	iPAddress = unicastAddrs->u.iPAddress;
+   	memset(iPAddress, 0, sizeof(H245UnicastAddress_iPAddress));
+   }
 
    pLogicalChannel = ooAddNewLogicalChannel(call, 
                         olc->forwardLogicalChannelNumber, h2250lcap->sessionID,
@@ -1652,10 +1662,16 @@
                   "(%s, %s)\n", call->callType, call->callToken);
       return OO_FAILED;
    }
-   ooSocketConvertIpToNwAddr(call->localIP, iPAddress->network.data);
-
-   iPAddress->network.numocts = 4;
-   iPAddress->tsapIdentifier = pLogicalChannel->localRtpPort;
+
+   if (gH323ep.v6Mode) {
+	inet_pton(AF_INET6, call->localIP, iP6Address->network.data);
+   	iP6Address->network.numocts = 16;
+   	iP6Address->tsapIdentifier = pLogicalChannel->localRtpPort;
+   } else {
+	inet_pton(AF_INET, call->localIP, iPAddress->network.data);
+   	iPAddress->network.numocts = 4;
+   	iPAddress->tsapIdentifier = pLogicalChannel->localRtpPort;
+   }
 
    /* media contrcol channel */
    h2250lcap->mediaControlChannel.t = 
@@ -1664,17 +1680,28 @@
                          ASN1MALLOC(pctxt, sizeof(H245UnicastAddress));
 
    unicastAddrs1 = h2250lcap->mediaControlChannel.u.unicastAddress;
+
    memset(unicastAddrs1, 0, sizeof(H245UnicastAddress));
-   unicastAddrs1->t = T_H245UnicastAddress_iPAddress;
-   unicastAddrs1->u.iPAddress = (H245UnicastAddress_iPAddress*)
-               memAlloc(pctxt, sizeof(H245UnicastAddress_iPAddress));
-   iPAddress1 = unicastAddrs1->u.iPAddress;
-   memset(iPAddress1, 0, sizeof(H245UnicastAddress_iPAddress));
-
-   ooSocketConvertIpToNwAddr(call->localIP, iPAddress1->network.data);
-
-   iPAddress1->network.numocts = 4;
-   iPAddress1->tsapIdentifier = pLogicalChannel->localRtcpPort;
+   if (gH323ep.v6Mode) {
+   	unicastAddrs1->t = T_H245UnicastAddress_iP6Address;
+   	unicastAddrs1->u.iP6Address = (H245UnicastAddress_iP6Address*)
+               memAlloc(pctxt, sizeof(H245UnicastAddress_iP6Address));
+   	iP6Address1 = unicastAddrs1->u.iP6Address;
+   	memset(iP6Address1, 0, sizeof(H245UnicastAddress_iP6Address));
+	inet_pton(AF_INET6, call->localIP, iP6Address1->network.data);
+   	iP6Address1->network.numocts = 16;
+   	iP6Address1->tsapIdentifier = pLogicalChannel->localRtcpPort;
+   } else {
+   	unicastAddrs1->t = T_H245UnicastAddress_iPAddress;
+   	unicastAddrs1->u.iPAddress = (H245UnicastAddress_iPAddress*)
+               	memAlloc(pctxt, sizeof(H245UnicastAddress_iPAddress));
+   	iPAddress1 = unicastAddrs1->u.iPAddress;
+   	memset(iPAddress1, 0, sizeof(H245UnicastAddress_iPAddress));
+
+	inet_pton(AF_INET, call->localIP, iPAddress1->network.data);
+   	iPAddress1->network.numocts = 4;
+   	iPAddress1->tsapIdentifier = pLogicalChannel->localRtcpPort;
+   }
 
    OOTRACEDBGA3("Built OpenLogicalChannelAck (%s, %s)\n", call->callType, 
                  call->callToken);
@@ -1765,14 +1792,16 @@
 int ooOnReceivedOpenLogicalChannelAck(OOH323CallData *call,
                                       H245OpenLogicalChannelAck *olcAck)
 {
-   char remoteip[20];
+   char remoteip[2+8*4+7];
    regmatch_t pmatch[1];
    ooLogicalChannel *pLogicalChannel;
    H245H2250LogicalChannelAckParameters *h2250lcap;
    H245UnicastAddress *unicastAddr;
-   H245UnicastAddress_iPAddress *iPAddress;
+   H245UnicastAddress_iPAddress *iPAddress = NULL;
+   H245UnicastAddress_iP6Address *iP6Address = NULL;
    H245UnicastAddress *unicastAddr1;
    H245UnicastAddress_iPAddress *iPAddress1 = NULL;
+   H245UnicastAddress_iP6Address *iP6Address1 = NULL;
 
    if(!((olcAck->m.forwardMultiplexAckParametersPresent == 1) &&
         (olcAck->forwardMultiplexAckParameters.t == 
@@ -1802,19 +1831,28 @@
    }
    
    unicastAddr = h2250lcap->mediaChannel.u.unicastAddress;
-   if(unicastAddr->t != T_H245UnicastAddress_iPAddress)
-   {
-      OOTRACEERR3("Error: Processing OpenLogicalChannelAck - media channel "
+   if (gH323ep.v6Mode) {
+   	if(unicastAddr->t != T_H245UnicastAddress_iP6Address)
+   	{
+      	OOTRACEERR3("Error: Processing OpenLogicalChannelAck - media channel "
+                  "address type is not IP6 (%s, %s)\n", call->callType, 
+                   call->callToken);
+      	return OO_FAILED;
+   	}
+   	iP6Address = unicastAddr->u.iP6Address;
+	inet_ntop(AF_INET6, iP6Address->network.data, remoteip, sizeof(remoteip));
+   
+   } else {
+   	if(unicastAddr->t != T_H245UnicastAddress_iPAddress)
+   	{
+      	OOTRACEERR3("Error: Processing OpenLogicalChannelAck - media channel "
                   "address type is not IP (%s, %s)\n", call->callType, 
                    call->callToken);
-      return OO_FAILED;
-   }
-   iPAddress = unicastAddr->u.iPAddress;
-   
-   sprintf(remoteip,"%d.%d.%d.%d", iPAddress->network.data[0],
-                                  iPAddress->network.data[1], 
-                                  iPAddress->network.data[2], 
-                                  iPAddress->network.data[3]);
+      	return OO_FAILED;
+   	}
+   	iPAddress = unicastAddr->u.iPAddress;
+	inet_ntop(AF_INET, iPAddress->network.data, remoteip, sizeof(remoteip));
+   }
    
    /* Extract media control channel address */
    if(h2250lcap->m.mediaControlChannelPresent == 1) {
@@ -1828,14 +1866,23 @@
    	}
    
    	unicastAddr1 = h2250lcap->mediaControlChannel.u.unicastAddress;
-   	if(unicastAddr1->t != T_H245UnicastAddress_iPAddress) {
-      		OOTRACEERR3("Error: Processing OpenLogicalChannelAck - media control "
-                  "channel address type is not IP (%s, %s)\n", call->callType, 
-                   call->callToken);
-      	return OO_FAILED;
-   	}
-
-   	iPAddress1 = unicastAddr1->u.iPAddress;
+	if (gH323ep.v6Mode) {
+   		if(unicastAddr1->t != T_H245UnicastAddress_iP6Address) {
+      			OOTRACEERR3("Error: Processing OpenLogicalChannelAck - media control "
+                  	"channel address type is not IP6 (%s, %s)\n", call->callType, 
+                   	call->callToken);
+      		return OO_FAILED;
+   		}
+   		iP6Address1 = unicastAddr1->u.iP6Address;
+	} else {
+   		if(unicastAddr1->t != T_H245UnicastAddress_iPAddress) {
+      			OOTRACEERR3("Error: Processing OpenLogicalChannelAck - media control "
+                  	"channel address type is not IP (%s, %s)\n", call->callType, 
+                   	call->callToken);
+      		return OO_FAILED;
+   		}
+   		iPAddress1 = unicastAddr1->u.iPAddress;
+	}
    } else {
       OOTRACEDBGA3("Warning: Processing OpenLogicalChannelAck - Missing media "
                 "control channel (%s, %s)\n", call->callType, call->callToken);
@@ -1861,7 +1908,7 @@
 
    /* Populate ports &ip  for channel */
 
-   if (call->rtpMaskStr[0]) {
+   if (call->rtpMaskStr[0] && !gH323ep.v6Mode) {
      if (regexec(&call->rtpMask->regex, remoteip, 1, pmatch, 0)) {
 		OOTRACEERR5("ERROR:H245 Address is not matched with filter %s/%s"
 			"(%s, %s)\n", remoteip, call->rtpMaskStr, call->callType, call->callToken);
@@ -1870,10 +1917,15 @@
    }
 
    strcpy(pLogicalChannel->remoteIP, remoteip);   
-   pLogicalChannel->remoteMediaPort = iPAddress->tsapIdentifier;
-   if (iPAddress1)
-   	pLogicalChannel->remoteMediaControlPort = iPAddress1->tsapIdentifier;
-
+   if (gH323ep.v6Mode) {
+   	pLogicalChannel->remoteMediaPort = iP6Address->tsapIdentifier;
+   	if (iP6Address1)
+   		pLogicalChannel->remoteMediaControlPort = iP6Address1->tsapIdentifier;
+   } else {
+   	pLogicalChannel->remoteMediaPort = iPAddress->tsapIdentifier;
+   	if (iPAddress1)
+   		pLogicalChannel->remoteMediaControlPort = iPAddress1->tsapIdentifier;
+   }
    if(pLogicalChannel->chanCap->startTransmitChannel)
    {
       pLogicalChannel->chanCap->startTransmitChannel(call, pLogicalChannel);
@@ -3596,6 +3648,7 @@
    H245H2250LogicalChannelParameters *h2250lcp = NULL;
    H245UnicastAddress *unicastAddrs = NULL;
    H245UnicastAddress_iPAddress *iPAddress = NULL;
+   H245UnicastAddress_iP6Address *iP6Address = NULL;
    unsigned session_id=0;
    ooLogicalChannel *pLogicalChannel = NULL;
    
@@ -3739,16 +3792,27 @@
 
    unicastAddrs = h2250lcp->mediaControlChannel.u.unicastAddress;
    memset(unicastAddrs, 0, sizeof(H245UnicastAddress));
-   unicastAddrs->t = T_H245UnicastAddress_iPAddress;
-   unicastAddrs->u.iPAddress = (H245UnicastAddress_iPAddress*)
+   if (gH323ep.v6Mode) {
+   	unicastAddrs->t = T_H245UnicastAddress_iP6Address;
+   	unicastAddrs->u.iP6Address = (H245UnicastAddress_iP6Address*)
+               ASN1MALLOC(pctxt, sizeof(H245UnicastAddress_iP6Address));
+   	iP6Address = unicastAddrs->u.iP6Address;
+   	memset(iP6Address, 0, sizeof(H245UnicastAddress_iP6Address));
+
+	inet_pton(AF_INET6, pLogicalChannel->localIP, iP6Address->network.data);
+   	iP6Address->network.numocts = 16;
+   	iPAddress->tsapIdentifier = pLogicalChannel->localRtcpPort;
+   } else {
+   	unicastAddrs->t = T_H245UnicastAddress_iPAddress;
+   	unicastAddrs->u.iPAddress = (H245UnicastAddress_iPAddress*)
                ASN1MALLOC(pctxt, sizeof(H245UnicastAddress_iPAddress));
-   iPAddress = unicastAddrs->u.iPAddress;
-   memset(iPAddress, 0, sizeof(H245UnicastAddress_iPAddress));
-
-   ooSocketConvertIpToNwAddr(pLogicalChannel->localIP,iPAddress->network.data);
-
-   iPAddress->network.numocts = 4;
-   iPAddress->tsapIdentifier = pLogicalChannel->localRtcpPort;
+   	iPAddress = unicastAddrs->u.iPAddress;
+   	memset(iPAddress, 0, sizeof(H245UnicastAddress_iPAddress));
+
+	inet_pton(AF_INET, pLogicalChannel->localIP, iPAddress->network.data);
+   	iPAddress->network.numocts = 4;
+   	iPAddress->tsapIdentifier = pLogicalChannel->localRtcpPort;
+   }
    pLogicalChannel->state = OO_LOGICALCHAN_PROPOSED; 
    OOTRACEDBGA4("Built OpenLogicalChannel-%s (%s, %s)\n", 
                  ooGetCapTypeText(epCap->cap), call->callType, 
@@ -3781,6 +3845,7 @@
    H245H2250LogicalChannelParameters *pH2250lcp1=NULL, *pH2250lcp2=NULL;
    H245UnicastAddress *pUnicastAddrs=NULL, *pUniAddrs=NULL;
    H245UnicastAddress_iPAddress *pIpAddrs=NULL, *pUniIpAddrs=NULL;
+   H245UnicastAddress_iP6Address *pIp6Addrs=NULL, *pUniIp6Addrs=NULL;
    unsigned session_id = 0;
    ooLogicalChannel *pLogicalChannel = NULL;
    int outgoing=FALSE;
@@ -3863,17 +3928,29 @@
                                                    sizeof(H245UnicastAddress));
          memset(pUniAddrs, 0, sizeof(H245UnicastAddress));
          pH2250lcp1->mediaChannel.u.unicastAddress =  pUniAddrs;
-         pUniAddrs->t = T_H245UnicastAddress_iPAddress;
-         pUniIpAddrs = (H245UnicastAddress_iPAddress*) ASN1MALLOC(pctxt, 
+	 if (gH323ep.v6Mode) {
+         	pUniAddrs->t = T_H245UnicastAddress_iP6Address;
+         	pUniIp6Addrs = (H245UnicastAddress_iP6Address*) ASN1MALLOC(pctxt, 
+                                         sizeof(H245UnicastAddress_iP6Address));
+         	memset(pUniIp6Addrs, 0, sizeof(H245UnicastAddress_iP6Address));
+         	pUniAddrs->u.iP6Address = pUniIp6Addrs;
+     
+		inet_pton(AF_INET6, pLogicalChannel->localIP, pUniIp6Addrs->network.data);
+
+         	pUniIp6Addrs->network.numocts = 16;
+         	pUniIp6Addrs->tsapIdentifier = pLogicalChannel->localRtpPort;
+	 } else {
+         	pUniAddrs->t = T_H245UnicastAddress_iPAddress;
+         	pUniIpAddrs = (H245UnicastAddress_iPAddress*) ASN1MALLOC(pctxt, 
                                          sizeof(H245UnicastAddress_iPAddress));
-         memset(pUniIpAddrs, 0, sizeof(H245UnicastAddress_iPAddress));
-         pUniAddrs->u.iPAddress = pUniIpAddrs;
+         	memset(pUniIpAddrs, 0, sizeof(H245UnicastAddress_iPAddress));
+         	pUniAddrs->u.iPAddress = pUniIpAddrs;
      
-         ooSocketConvertIpToNwAddr(pLogicalChannel->localIP, 
-                                                pUniIpAddrs->network.data);
-
-         pUniIpAddrs->network.numocts = 4;
-         pUniIpAddrs->tsapIdentifier = pLogicalChannel->localRtpPort;
+		inet_pton(AF_INET, pLogicalChannel->localIP, pUniIpAddrs->network.data);
+
+         	pUniIpAddrs->network.numocts = 4;
+         	pUniIpAddrs->tsapIdentifier = pLogicalChannel->localRtpPort;
+	 }
       }
       pH2250lcp1->m.mediaControlChannelPresent = 1;
       pH2250lcp1->mediaControlChannel.t = 
@@ -3882,17 +3959,30 @@
                                                    sizeof(H245UnicastAddress));
       memset(pUnicastAddrs, 0, sizeof(H245UnicastAddress));
       pH2250lcp1->mediaControlChannel.u.unicastAddress =  pUnicastAddrs;
-      pUnicastAddrs->t = T_H245UnicastAddress_iPAddress;
-      pIpAddrs = (H245UnicastAddress_iPAddress*) ASN1MALLOC(pctxt, 
+      if (gH323ep.v6Mode) {
+         	pUnicastAddrs->t = T_H245UnicastAddress_iP6Address;
+         	pIp6Addrs = (H245UnicastAddress_iP6Address*) ASN1MALLOC(pctxt, 
+                                         sizeof(H245UnicastAddress_iP6Address));
+         	memset(pIp6Addrs, 0, sizeof(H245UnicastAddress_iP6Address));
+         	pUnicastAddrs->u.iP6Address = pIp6Addrs;
+     
+		inet_pton(AF_INET6, pLogicalChannel->localIP, pIp6Addrs->network.data);
+
+         	pIp6Addrs->network.numocts = 16;
+         	pIp6Addrs->tsapIdentifier = pLogicalChannel->localRtcpPort;
+	 } else {
+         	pUnicastAddrs->t = T_H245UnicastAddress_iPAddress;
+         	pIpAddrs = (H245UnicastAddress_iPAddress*) ASN1MALLOC(pctxt, 
                                          sizeof(H245UnicastAddress_iPAddress));
-      memset(pIpAddrs, 0, sizeof(H245UnicastAddress_iPAddress));
-      pUnicastAddrs->u.iPAddress = pIpAddrs;
+         	memset(pIpAddrs, 0, sizeof(H245UnicastAddress_iPAddress));
+         	pUnicastAddrs->u.iPAddress = pIpAddrs;
      
-       ooSocketConvertIpToNwAddr(pLogicalChannel->localIP, 
-                                                      pIpAddrs->network.data);
-
-      pIpAddrs->network.numocts = 4;
-      pIpAddrs->tsapIdentifier = pLogicalChannel->localRtcpPort;
+		inet_pton(AF_INET, pLogicalChannel->localIP, pIpAddrs->network.data);
+
+         	pIpAddrs->network.numocts = 4;
+         	pIpAddrs->tsapIdentifier = pLogicalChannel->localRtcpPort;
+	}
+
       if(!outgoing)
       {
          if(epCap->startReceiveChannel)
@@ -3955,18 +4045,33 @@
                                                   sizeof(H245UnicastAddress));
          memset(pUnicastAddrs, 0, sizeof(H245UnicastAddress));
          pH2250lcp2->mediaChannel.u.unicastAddress =  pUnicastAddrs;
+
+	 /* May 20101022 */
       
-         pUnicastAddrs->t = T_H245UnicastAddress_iPAddress;
-         pIpAddrs = (H245UnicastAddress_iPAddress*) memAlloc(pctxt, 
+      	 if (gH323ep.v6Mode) {
+         	pUnicastAddrs->t = T_H245UnicastAddress_iP6Address;
+         	pIp6Addrs = (H245UnicastAddress_iP6Address*) ASN1MALLOC(pctxt, 
+                                         sizeof(H245UnicastAddress_iP6Address));
+         	memset(pIp6Addrs, 0, sizeof(H245UnicastAddress_iP6Address));
+         	pUnicastAddrs->u.iP6Address = pIp6Addrs;
+     
+		inet_pton(AF_INET6, pLogicalChannel->localIP, pIp6Addrs->network.data);
+
+         	pIp6Addrs->network.numocts = 16;
+         	pIp6Addrs->tsapIdentifier = pLogicalChannel->localRtpPort;
+	 } else {
+         	pUnicastAddrs->t = T_H245UnicastAddress_iPAddress;
+         	pIpAddrs = (H245UnicastAddress_iPAddress*) ASN1MALLOC(pctxt, 
                                          sizeof(H245UnicastAddress_iPAddress));
-         memset(pIpAddrs, 0, sizeof(H245UnicastAddress_iPAddress));
-         pUnicastAddrs->u.iPAddress = pIpAddrs;      
-
-         ooSocketConvertIpToNwAddr(pLogicalChannel->localIP, 
-                                                       pIpAddrs->network.data);
-
-         pIpAddrs->network.numocts = 4;
-         pIpAddrs->tsapIdentifier = pLogicalChannel->localRtpPort;
+         	memset(pIpAddrs, 0, sizeof(H245UnicastAddress_iPAddress));
+         	pUnicastAddrs->u.iPAddress = pIpAddrs;
+     
+		inet_pton(AF_INET, pLogicalChannel->localIP, pIpAddrs->network.data);
+
+         	pIpAddrs->network.numocts = 4;
+         	pIpAddrs->tsapIdentifier = pLogicalChannel->localRtpPort;
+	}
+
       }
       pH2250lcp2->m.mediaControlChannelPresent = 1;
       pH2250lcp2->mediaControlChannel.t = 
@@ -3976,17 +4081,32 @@
       memset(pUniAddrs, 0, sizeof(H245UnicastAddress));
       pH2250lcp2->mediaControlChannel.u.unicastAddress =  pUniAddrs;
 
+      /* May 20101023 */
       
-      pUniAddrs->t = T_H245UnicastAddress_iPAddress;
-      pUniIpAddrs = (H245UnicastAddress_iPAddress*) ASN1MALLOC(pctxt, sizeof(H245UnicastAddress_iPAddress));
-      memset(pUniIpAddrs, 0, sizeof(H245UnicastAddress_iPAddress));
-      pUniAddrs->u.iPAddress = pUniIpAddrs; 
-
-      ooSocketConvertIpToNwAddr(pLogicalChannel->localIP, 
-                                                    pUniIpAddrs->network.data);
-      pUniIpAddrs->network.numocts = 4;
-      pUniIpAddrs->tsapIdentifier = pLogicalChannel->localRtcpPort;
-          
+	 if (gH323ep.v6Mode) {
+         	pUniAddrs->t = T_H245UnicastAddress_iP6Address;
+         	pUniIp6Addrs = (H245UnicastAddress_iP6Address*) ASN1MALLOC(pctxt, 
+                                         sizeof(H245UnicastAddress_iP6Address));
+         	memset(pUniIp6Addrs, 0, sizeof(H245UnicastAddress_iP6Address));
+         	pUniAddrs->u.iP6Address = pUniIp6Addrs;
+     
+		inet_pton(AF_INET6, pLogicalChannel->localIP, pUniIp6Addrs->network.data);
+
+         	pUniIp6Addrs->network.numocts = 16;
+         	pUniIp6Addrs->tsapIdentifier = pLogicalChannel->localRtcpPort;
+	 } else {
+         	pUniAddrs->t = T_H245UnicastAddress_iPAddress;
+         	pUniIpAddrs = (H245UnicastAddress_iPAddress*) ASN1MALLOC(pctxt, 
+                                         sizeof(H245UnicastAddress_iPAddress));
+         	memset(pUniIpAddrs, 0, sizeof(H245UnicastAddress_iPAddress));
+         	pUniAddrs->u.iPAddress = pUniIpAddrs;
+     
+		inet_pton(AF_INET, pLogicalChannel->localIP, pUniIpAddrs->network.data);
+
+         	pUniIpAddrs->network.numocts = 4;
+         	pUniIpAddrs->tsapIdentifier = pLogicalChannel->localRtcpPort;
+	 }
+
       /*
          In case of fast start, the local endpoint need to be ready to
          receive all the media types proposed in the fast connect, before
@@ -4184,6 +4304,7 @@
 {
    H245UnicastAddress *unicastAddress = NULL;
    H245UnicastAddress_iPAddress *ipAddress = NULL;
+   H245UnicastAddress_iP6Address *ip6Address = NULL;
    regmatch_t pmatch[1];
 
    if(h245Address->t != T_H245TransportAddress_unicastAddress)
@@ -4194,7 +4315,17 @@
    } 
       
    unicastAddress = h245Address->u.unicastAddress;
-   if(unicastAddress->t != T_H245UnicastAddress_iPAddress)
+   if (gH323ep.v6Mode) {
+	if (unicastAddress->t != T_H245UnicastAddress_iP6Address) {
+      		OOTRACEERR3("ERROR:H245 Address type is not IP6"
+                   "(%s, %s)\n", call->callType, call->callToken);
+      		return OO_FAILED;
+	}
+	ip6Address = unicastAddress->u.iP6Address;
+	*port = ip6Address->tsapIdentifier;
+	inet_ntop(AF_INET6, ip6Address->network.data, ip, INET6_ADDRSTRLEN);
+
+   } else { if(unicastAddress->t != T_H245UnicastAddress_iPAddress)
    {
       OOTRACEERR3("ERROR:H245 Address type is not IP"
                    "(%s, %s)\n", call->callType, call->callToken);
@@ -4203,11 +4334,7 @@
    ipAddress = unicastAddress->u.iPAddress;
 
    *port = ipAddress->tsapIdentifier;
-
-   sprintf(ip, "%d.%d.%d.%d", ipAddress->network.data[0], 
-                              ipAddress->network.data[1],
-                              ipAddress->network.data[2],
-                              ipAddress->network.data[3]);
+   inet_ntop(AF_INET,  ipAddress->network.data, ip, INET_ADDRSTRLEN);
    if (call->rtpMaskStr[0]) {
      if (regexec(&call->rtpMask->regex, ip, 1, pmatch, 0)) {
 		OOTRACEERR5("ERROR:H245 Address is not matched with filter %s/%s"
@@ -4215,7 +4342,7 @@
 	 return OO_FAILED;
 	}
    }
-
+   }
    return OO_OK;
 }
 
@@ -4230,6 +4357,7 @@
    H245H2250LogicalChannelParameters *pH2250lcp1=NULL, *pH2250lcp2=NULL;
    H245UnicastAddress *pUnicastAddrs=NULL, *pUniAddrs=NULL;
    H245UnicastAddress_iPAddress *pIpAddrs=NULL, *pUniIpAddrs=NULL;
+   H245UnicastAddress_iP6Address *pIp6Addrs=NULL, *pUniIp6Addrs=NULL;
    unsigned session_id = 0;
    ooLogicalChannel *pLogicalChannel = NULL;
    
@@ -4275,53 +4403,82 @@
 
       pH2250lcp1->m.mediaChannelPresent = 1;
       pH2250lcp1->mediaChannel.t = T_H245TransportAddress_unicastAddress;
-      pUniAddrs = (H245UnicastAddress*) memAlloc(pctxt, 
+      pUniAddrs = (H245UnicastAddress*) memAllocZ(pctxt, 
                                                    sizeof(H245UnicastAddress));
-      pUniIpAddrs = (H245UnicastAddress_iPAddress*) memAlloc(pctxt, 
+      pH2250lcp1->mediaChannel.u.unicastAddress =  pUniAddrs;
+      if (gH323ep.v6Mode) {
+      	pUniIp6Addrs = (H245UnicastAddress_iP6Address*) memAllocZ(pctxt, 
+                                         sizeof(H245UnicastAddress_iP6Address));
+      	if(!pUniAddrs || !pUniIpAddrs) {
+         	OOTRACEERR3("Error:Memory - ooPrepareFastStartResponseOLC - pUniAddrs"
+                     "/pUniIpAddrs (%s, %s)\n", call->callType, 
+                     call->callToken);
+         return OO_FAILED;
+      	}
+
+      	pUniAddrs->t = T_H245UnicastAddress_iP6Address;
+      	pUniAddrs->u.iP6Address = pUniIp6Addrs;
+     	inet_pton(AF_INET6, pLogicalChannel->localIP, pUniIp6Addrs->network.data);
+
+      	pUniIp6Addrs->network.numocts = 16;
+      	pUniIp6Addrs->tsapIdentifier = pLogicalChannel->localRtpPort;
+
+      } else {
+      	pUniIpAddrs = (H245UnicastAddress_iPAddress*) memAllocZ(pctxt, 
                                          sizeof(H245UnicastAddress_iPAddress));
-      if(!pUniAddrs || !pUniIpAddrs)
-      {
+      	if(!pUniAddrs || !pUniIpAddrs) {
          OOTRACEERR3("Error:Memory - ooPrepareFastStartResponseOLC - pUniAddrs"
                      "/pUniIpAddrs (%s, %s)\n", call->callType, 
                      call->callToken);
          return OO_FAILED;
-      }
-
-      pH2250lcp1->mediaChannel.u.unicastAddress =  pUniAddrs;
-      pUniAddrs->t = T_H245UnicastAddress_iPAddress;
-      pUniAddrs->u.iPAddress = pUniIpAddrs;
+      	}
+
+      	pUniAddrs->t = T_H245UnicastAddress_iPAddress;
+      	pUniAddrs->u.iPAddress = pUniIpAddrs;
+	inet_pton(AF_INET, pLogicalChannel->localIP, pUniIpAddrs->network.data);
      
-      ooSocketConvertIpToNwAddr(pLogicalChannel->localIP, 
-                                                    pUniIpAddrs->network.data);
-
-      pUniIpAddrs->network.numocts = 4;
-      pUniIpAddrs->tsapIdentifier = pLogicalChannel->localRtpPort;
+      	pUniIpAddrs->network.numocts = 4;
+      	pUniIpAddrs->tsapIdentifier = pLogicalChannel->localRtpPort;
+      }
+
 
       pH2250lcp1->m.mediaControlChannelPresent = 1;
       pH2250lcp1->mediaControlChannel.t = 
                                  T_H245TransportAddress_unicastAddress;
-      pUnicastAddrs = (H245UnicastAddress*) memAlloc(pctxt, 
+      pUnicastAddrs = (H245UnicastAddress*) memAllocZ(pctxt, 
                                                    sizeof(H245UnicastAddress));
-      pIpAddrs = (H245UnicastAddress_iPAddress*) memAlloc(pctxt, 
-                                         sizeof(H245UnicastAddress_iPAddress));
-      if(!pUnicastAddrs || !pIpAddrs)
-      {
+      pH2250lcp1->mediaControlChannel.u.unicastAddress =  pUnicastAddrs;
+
+      if (gH323ep.v6Mode) {
+      	pIp6Addrs = (H245UnicastAddress_iP6Address*) memAllocZ(pctxt, 
+                                         sizeof(H245UnicastAddress_iP6Address));
+      	if(!pUnicastAddrs || !pIp6Addrs) {
          OOTRACEERR3("Error:Memory - ooPrepareFastStartResponseOLC - "
                      "pUnicastAddrs/pIpAddrs (%s, %s)\n", call->callType, 
                      call->callToken);
          return OO_FAILED;
-      }
-      memset(pUnicastAddrs, 0, sizeof(H245UnicastAddress));
-      pH2250lcp1->mediaControlChannel.u.unicastAddress =  pUnicastAddrs;
-      pUnicastAddrs->t = T_H245UnicastAddress_iPAddress;
-      
-      pUnicastAddrs->u.iPAddress = pIpAddrs;
-     
-      ooSocketConvertIpToNwAddr(pLogicalChannel->localIP, 
-                                                       pIpAddrs->network.data);
-
-      pIpAddrs->network.numocts = 4;
-      pIpAddrs->tsapIdentifier = pLogicalChannel->localRtcpPort;
+      	}
+      	pUnicastAddrs->t = T_H245UnicastAddress_iP6Address;
+      	pUnicastAddrs->u.iP6Address = pIp6Addrs;
+      	inet_pton(AF_INET6, pLogicalChannel->localIP, pIp6Addrs->network.data);
+      	pIp6Addrs->network.numocts = 16;
+      	pIp6Addrs->tsapIdentifier = pLogicalChannel->localRtcpPort;
+      } else {
+
+      	pIpAddrs = (H245UnicastAddress_iPAddress*) memAllocZ(pctxt, 
+                                         sizeof(H245UnicastAddress_iPAddress));
+      	if(!pUnicastAddrs || !pIpAddrs) {
+         	OOTRACEERR3("Error:Memory - ooPrepareFastStartResponseOLC - "
+                     "pUnicastAddrs/pIpAddrs (%s, %s)\n", call->callType, 
+                     call->callToken);
+         	return OO_FAILED;
+      	}
+      	pUnicastAddrs->t = T_H245UnicastAddress_iPAddress;
+      	pUnicastAddrs->u.iPAddress = pIpAddrs;
+      	inet_pton(AF_INET, pLogicalChannel->localIP, pIpAddrs->network.data);
+      	pIpAddrs->network.numocts = 4;
+      	pIpAddrs->tsapIdentifier = pLogicalChannel->localRtcpPort;
+      }
    }
 
    if(reverse)
@@ -4340,26 +4497,42 @@
                                  T_H245TransportAddress_unicastAddress;
       pUniAddrs = (H245UnicastAddress*) memAlloc(pctxt, 
                                                    sizeof(H245UnicastAddress));
-      pUniIpAddrs = (H245UnicastAddress_iPAddress*) memAlloc(pctxt, 
-                                         sizeof(H245UnicastAddress_iPAddress));
-      if(!pUniAddrs || !pUniIpAddrs)
-      {
-         OOTRACEERR3("Error:Memory - ooPrepareFastStartResponseOLC - "
+      pH2250lcp2->mediaControlChannel.u.unicastAddress =  pUniAddrs;
+
+      if (gH323ep.v6Mode) {
+      	pUniIp6Addrs = (H245UnicastAddress_iP6Address*) memAlloc(pctxt, 
+                                         sizeof(H245UnicastAddress_iP6Address));
+      	if(!pUniAddrs || !pUniIp6Addrs) {
+         	OOTRACEERR3("Error:Memory - ooPrepareFastStartResponseOLC - "
                     "pUniAddrs/pUniIpAddrs (%s, %s)\n", call->callType, 
                      call->callToken);
          return OO_FAILED;
-      }
-
-      pH2250lcp2->mediaControlChannel.u.unicastAddress =  pUniAddrs;
+      	}
+
       
-      pUniAddrs->t = T_H245UnicastAddress_iPAddress;
-
-      pUniAddrs->u.iPAddress = pUniIpAddrs; 
-
-      ooSocketConvertIpToNwAddr(pLogicalChannel->localIP, 
-                                                    pUniIpAddrs->network.data);
-      pUniIpAddrs->network.numocts = 4;
-      pUniIpAddrs->tsapIdentifier = pLogicalChannel->localRtcpPort;
+      	pUniAddrs->t = T_H245UnicastAddress_iP6Address;
+      	pUniAddrs->u.iP6Address = pUniIp6Addrs; 
+	inet_pton(AF_INET6, pLogicalChannel->localIP, pUniIp6Addrs->network.data);
+	pUniIp6Addrs->network.numocts = 16;
+      	pUniIp6Addrs->tsapIdentifier = pLogicalChannel->localRtcpPort;
+      } else {
+      	pUniIpAddrs = (H245UnicastAddress_iPAddress*) memAlloc(pctxt, 
+                                         sizeof(H245UnicastAddress_iPAddress));
+      	if(!pUniAddrs || !pUniIpAddrs) {
+         	OOTRACEERR3("Error:Memory - ooPrepareFastStartResponseOLC - "
+                    "pUniAddrs/pUniIpAddrs (%s, %s)\n", call->callType, 
+                     call->callToken);
+         return OO_FAILED;
+      	}
+
+      	pH2250lcp2->mediaControlChannel.u.unicastAddress =  pUniAddrs;
+      
+      	pUniAddrs->t = T_H245UnicastAddress_iPAddress;
+      	pUniAddrs->u.iPAddress = pUniIpAddrs; 
+	inet_pton(AF_INET, pLogicalChannel->localIP, pUniIpAddrs->network.data);
+	pUniIpAddrs->network.numocts = 4;
+      	pUniIpAddrs->tsapIdentifier = pLogicalChannel->localRtcpPort;
+      }
           
    }
 




More information about the asterisk-commits mailing list