Using IPv6 Addresses

Discussion to talk about software related topics only.
Post Reply
SeeCwriter
Posts: 430
Joined: Mon May 12, 2008 10:55 am

Using IPv6 Addresses

Post by SeeCwriter » Wed Dec 18, 2019 7:23 am

I converted one of my applications to use IPADDR for IP addresses ( was using IPADDR4), and I expected to see IPv6 addresses on the wire. But I don't. I only see IPv4 addresses.

Code: Select all

IPADDR BroadcastIP;
WORD BroadcastPort;
IPADDR ip6_multicast;

void InitMulticast()
{
   if ( !ip6_multicast.IsMultiCast() )
       ip6_multicast = IPADDR::AsciiToIp6( "224.0.100.100" );
   if ( use_multicast )
   {
       BroadcastIP = ip6_multicast;
       BroadcastPort = MULTICAST_PORT;
   }
   else
   {
       BroadcastIP.SetFromIP4( IPADDR4::GlobalBroadCast() );
       BroadcastPort = BROADCAST_PORT;
   }
}

void UdpSend( char *buf, int len, IPADDR &ip_addr, WORD port )
{
    IPADDR ip = ( ip_addr.IsNull() ) ? BroadcastIP : ip_addr;
    
    UDPPacket pkt;
    pkt.SetSourcePort(port);
    pkt.SetDestinationPort(port);
    pkt.AddData((PBYTE)buf, (WORD) len);
    pkt.Send(ip);
}
The above code works, switching between sending multicast packets and broadcast packets. But I thought the multicast packets would use IPv6 formatted IP addresses. But it just uses IPv4 packets. What has to happen for IPv6 packets to be used?

Post Reply