Using IPv6 Addresses

Discussion to talk about software related topics only.
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: Using IPv6 Addresses

Post by pbreed »

Remember the IPV6 stack and the IPV4 stack are really seperate things....

First the IPv4 stack is basically unmodified.
and it's configuration is different than the IPV6 stack.
Whatever you were doing to configure the IPv4 stuff before keep doing, don't change anything...
You should be able to cast an IPADDR to IPADDR4 anyplace a IPADDR4 is needed.
Given that it better be an embedded ipv4 and not an actual ipv6.


As for IPV6 configuration, IPV6 addresses work somewhat differently...
In 90% of the cases DHCP is probably unnecessary as the router based autoconfig just works.
IPV6 does not really have a seperate netmask.
The prefix length is communicated with the address prefix.

To start with all interfaces have a Link local address fe80::XXXXXXXX
Where XXXX is device specific and derived from the Mac address....

If there is an IPV6 router on the segment, the system will auto discover the routers and get prefixes from each of them...
So say I had 3 IPv6 routers on my network each handing out prefixes...

Router 1 1111:
Router 2 2222:
Router 3 3333:

No the Netburner will end up with 4 IPV6 addresses..>

1111:XXXXXXXX
2222:XXXXXXXX
3333:XXXXXXXX
FE80::XXXXXXXX

This requires ZERO programmer intervention....
These routers will also hand out DNS entries....

So 99% of the time you have to do nothing for IPV6 configuration, it just works.
Leave it alone and don't mess with it....


You can run the utility...
nburn\pctools\find\python\find6.py
To list all the IPV6 netburner available on your network...
This works by sending a IPv6 Multicast out to the netburner Multicast channel and every Netburner running IPV6 responds...
SeeCwriter
Posts: 605
Joined: Mon May 12, 2008 10:55 am

Re: Using IPv6 Addresses

Post by SeeCwriter »

Thank you. That was helpful.

What happens to the IPv6 configuration on a power-cycle? Normally, in our equipment the network configuration parameters are stored in nonvolatile memory so they can be restored on power-up. If the IPv6 parameters are being configured unbeknownst to the firmware are we supposed to always rely on a router to reconfigure the unit every time it boots up? Which I think would mean the equipment could never be used on a network without a router if IPv6 was being used.
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: Using IPv6 Addresses

Post by pbreed »

The FE80:: subnet always exists.
It will autoconfigure with nothing else on the network.

IF there is an IPv6 router on the net it will hand out other prefixes.

You can also set static addresses if you want...

#include <ipv6\ipv6_interface.h>

IPv6Interface * pIp6IF= IPv6Interface::GetFirst_IP6_Interface();
if(pIp6IF)
{
pIp6IF->AddStaticAddress(const IPADDR6 & ip, int PrefixLen)
}
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: Using IPv6 Addresses

Post by pbreed »

fc00::
to
fdff::

are the IPV6 equivalent of 10.x.x.x and 192.168.x.x addresses.
They don't route, but are legal on the local subnet.
AS for prefix length just use 64.
SeeCwriter
Posts: 605
Joined: Mon May 12, 2008 10:55 am

Re: Using IPv6 Addresses

Post by SeeCwriter »

If I understand correctly, since the module can have an IPv4 static address and an IPv6 static address at the same time, I can't just use a single IPADDR ip variable for storing static addresses. I need one for each stack. Seems like I also need a set (ip, netmask, gateway, dns) for each stack.
This is really messing with my structure of unit parameters that get restored on power-up.
SeeCwriter
Posts: 605
Joined: Mon May 12, 2008 10:55 am

Re: Using IPv6 Addresses

Post by SeeCwriter »

Why doesn't the function below detect an IPv4 address, and why does the program crash? I'm using v2.9.2 of the tools, and dual-stack is enabled.

Code: Select all

void SetIP( char *buf, int link )
{
   int len;
   char buf1[66];
   IPADDR new_ip;
   InterfaceBlock *ib;
   IPv6Interface *pIPv6If = IPv6Interface::GetFirst_IP6_Interface();
   
   new_ip.SetFromAscii(buf);
   iprintf("StaticIP: ");
   new_ip.print();
   puts("");
   // Output from above:  "StaticIP: 10.250.5.240"
   
   if ( new_ip.IsEmbeddedIPV4() )
   {
      puts("IPv4 detected");
      ib = GetInterFaceBlock( CONFIG_IF_ID_ETHERNET );
      ip6_address = new_ip;
      if ( !SS->use_dhcp ) 
         ib->netIP = ip6_address.Extract4(); // immediately active.
   }
   else
   {
      puts("IPv6 detected");
      pIPv6If->RemoveStaticAddress( ip6_address ); 
      ip6_address = new_ip;
      pIPv6If->AddStaticAddress( ip6_address, 64 );

   }
   // Output from above: "IPv6 detected"
   
   len = ip6_address.sprintf( buf1, 64);
   iprintf( "buf1 = %s, len = %d\r\n", buf1, len );
   OSTimeDly( TICKS_PER_SECOND );
   // Output from above:" buf1 = ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff, Len = 39"
   
   // Then the program crashes with most resisters set to 0xffffffff, including the Faulted PC register.
}   
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: Using IPv6 Addresses

Post by pbreed »

First question why are you trying to set a static IPV6 address at all?
If there is no router autoconfig will work.
If there is a router you should be using the address that it assigns.

While the capability to set an IPV6 static address exists, its really bad form and should probably NEVER be used.
On boot IT WILL NOT HAVE ANY STATIC IPV6 address unless you specifically add one (and I really think you should not do so)
As for your code snipit
ip6_address is not declared in your code sample, don't know where its declared and where it comes from.
Why are you trying to remove a static address that was never set?
SeeCwriter
Posts: 605
Joined: Mon May 12, 2008 10:55 am

Re: Using IPv6 Addresses

Post by SeeCwriter »

ip6_address is a global variable declared as IPADDR. It's set on boot-up by reading stored parameters from nonvolatile memory. During power-up initialization it would be passed to the AddStaticAddress function.

So the proper way to initialize the IPv6 stack on boot-up is to do nothing? That an IPv6 router will always be required to do anything beyond using the link-local address?
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: Using IPv6 Addresses

Post by pbreed »

Yes, do nothing.
There is absolutely nothing wrong with using the linklocal address....

My question is why would one choose to EVER use an IPV6 address unless there is an IPV6 router on the local network?
imho Any place that enforces an IPV6 only policy will have a router on their network.

To start with all the ipv6 packets are slightly larger, the outbound routing is more complicated and thus things like TCP etc are slightly slower.

Now if you want to use IPv6 for "customer requires it reasons" then you can go ahead and setup the IPv6 static address, just don't call the remove address before you call the set static address... but I'd be really surprised to find a customer that wants to set up a IPV6 system with static addresses.
(I've not seen one example of this yet)

Now I also strongly suspect that something is wrong with your flash configuration (IE using userparams without a checksum) and the all ff's address is actually blank unprogramed flash.
SeeCwriter
Posts: 605
Joined: Mon May 12, 2008 10:55 am

Re: Using IPv6 Addresses

Post by SeeCwriter »

Our current customers rarely use DHCP when using IPv4. They assign specific addresses to each piece of equipment so their Monitor & Control system software can detect when a piece is missing. I know there are better ways to do this, but our customers are paranoid, and getting them to change their program is worse than pulling teeth. I don't know if they expect IPv6 to operate the same way, but since most of them are more illiterate than I on network configurations I wouldn't be surprised.

What flash configuration are you referring too? I use an EEPROM for nonvolatile storage, not the module's flash memory.
If you look at the function I posted earlier, you will see where new_ip is set to an IPv4 address from an ASCII string ("10.250.5.240"). And I send it to a serial terminal for display, so it appears correct. Then I test new_ip to see if it's an IPv4 address or not. That function, IsEmbeddedIPV4(), returns false. Why? Did I not set it right?

Moving on, since it returns false, the program flow goes to the else portion, which assumes its an IPv6 address. In the else portion global variable ip6_address is set to new_ip. So ip6_address should be 10.250.5.240. But the printout is all ff's and then the program crashes. Or does removing a static address that was never added cause the eventual crash? The comments for the remove function say that the address is removed "if" it is found. If the address had never been added in the first place, I would think the function would return without doing anything.
Post Reply