Using dual stack mode

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

Using dual stack mode

Post by SeeCwriter »

I've install v2.8.0 and am trying to get my MOD54415 application to compile. I left the installation set to dual stack mode.
As I understand it, I can declare all my IP objects as IPADDR whether they are for IPv4 or IPv6.

The structure InterfaceBlock declares all the IP objects as IPADDR4. Which I think is causing the following compiler error for code below.

"error: no match for 'operator=' (operand types are 'IPADDR4 and 'IPADDR' {aka IPADDR6})

Code: Select all

void ChangeRuntimeIPSettings( InterfaceBlock *ib_, IPADDR IpAddr, IPADDR IpMask, IPADDR IpGate, IPADDR IpDNS )
{
	#ifdef foo
	iprintf("Old Settings:\r\n");
	iprintf("   IP:    "); ShowIP(ib->netIP); 		iprintf("\r\n");
	iprintf("   Mask:  "); ShowIP(ib->netIpMask); iprintf("\r\n");
	iprintf("   Gway:  "); ShowIP(ib->netIpGate); iprintf("\r\n");
	iprintf("   DNS:   "); ShowIP(ib->netDNS); 		iprintf("\r\n");
	iprintf("-------------------------------\r\n");
	#endif

	ib_->netIP			= IpAddr;
	ib_->netIpMask	= IpMask;
	ib_->netIpGate	= IpGate;
	ib_->netDNS			= IpDNS;

	#ifdef foo
	iprintf("New Settings:\r\n");
	iprintf("   IP:    "); ShowIP(ib->netIP); 		iprintf("\r\n");
	iprintf("   Mask:  "); ShowIP(ib->netIpMask); iprintf("\r\n");
	iprintf("   Gway:  "); ShowIP(ib->netIpGate); iprintf("\r\n");
	iprintf("   DNS:   "); ShowIP(ib->netDNS); 		iprintf("\r\n");
	iprintf("-------------------------------\r\n");
	#endif
}
How do I correct this?
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: Using dual stack mode

Post by pbreed »

To set an IPADDR4 from IPADDR use the

IPADDR ip;
IPADDR4 ip4;


if(ip.IsEmbeddedIPV4())
{
ip4=ip.Extract4();
}
else
{//Fail...
}
SeeCwriter
Posts: 606
Joined: Mon May 12, 2008 10:55 am

Re: Using dual stack mode

Post by SeeCwriter »

But the InterfaceBlock structure only takes IPv4. What if the unit is connected to an IPv6 network, how do we set a new IP address in Static IP mode?
User avatar
dciliske
Posts: 623
Joined: Mon Feb 06, 2012 9:37 am
Location: San Diego, CA
Contact:

Re: Using dual stack mode

Post by dciliske »

This seems to be common question...

Currently, to add a static address you'll need to use

Code: Select all

IPv6Interface::AddStaticAddress(const IPADDR6 & ip, int PrefixLen)
PrefixLen is used for link determination. It should match the network segment's value. PrefixLen should be 64 unless you know what your doing.

Use it like this:

Code: Select all

IPv6Interface *pintf = IPv6Interface::GetFirst_IP6_Interface();
pintf->AddStaticAddress(<insert address variable here>, 64);
All this said, I'll be adding to the next release the functions:

Code: Select all

void AddStaticIPv6Address(const IPADDR6 &ip, int ifnum = -1);
bool RemoveStaticIPv6Address(const IPADDR6 &ip, int ifnum = -1);
Dan Ciliske
Project Engineer
Netburner, Inc
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: Using dual stack mode

Post by pbreed »

The interface block stuff is for IPV4 addresses, if you want a static IPV6 address you need to use the
functions Dan showed....

One should not usually set IPV6 static addresses.......
Autoconfig, or if necessary DHCP.....

The Loacal addresses should work even with no IPV6 router or DHCP on the link...
SeeCwriter
Posts: 606
Joined: Mon May 12, 2008 10:55 am

Re: Using dual stack mode

Post by SeeCwriter »

I know next to nothing about IPv6 other than the IP address being expanded to 128 bits. Just enough to be
dangerous.

Using your example, is the following correct? Also, I couldn't find a netmask setting. Doesn't IPv6 use one?

Code: Select all

if( ip.IsEmbeddedIPV4() )
{
  ib_->netIP      = IpAddr.Extract4();
  ib_->netIpMask = IpMask.Extract4();
  ib_->netIpGate = IpGate.Extract4();
  ib_->netDNS    = IpDNS.Extract4();
}
else
{
  IPv6Interface *pintf = IPv6Interface::GetFirst_IP6_Interface();
  pintf->AddStaticAddress( IpAddr, 64 );
  pintf->AddDefaultGateway( IpGate, 64 );
  pintf->AddStaticDNS( IpDNS, 64 );

}
User avatar
TomNB
Posts: 538
Joined: Tue May 10, 2016 8:22 am

Re: Using dual stack mode

Post by TomNB »

Understanding the differences between v4 and v6 is going to be a very common question for everyone. It will take some background reading, but we are attempting to put together a document to help people get started. Attached is the first iteration of a document we would like to get feedback on and improve to the point that describes the right midset for v6. Initially I also thought that it was just a bigger address space, but there is significantly more to it than that. For example, routers provide configuration and address information in v6. In v4 only DHCP did that.

One way to look at this that might help you is that in v4 you normally have 1 primary address. There is also multi-home, but in general, one primary address. The ChangeIP example was created to demonstrate how to change that primary address between DHCP and static.

In v6 there will always be multiple primary addresses. The document goes into this. The most common configuration is not to use DHCPv6 at all - it is something called auto configuration and address information is provided by the routers on the network. Our ShowAddresses() example program will display all of a device's addresses and where they came from. Note that you need to have a v6 enabled network and v6 enabled router for things to work properly.

So ChangeIP is not necessary for v6. I would limit it to v4 in your application. v6 will take care of configuring itself with multiple primary addresses, and routing will determine which is the proper one to use. For example, you will have a link local address with prefix fe80:xxxx. Then you will have one or more router addresses, and possibly a DHCPv6 assigned address if a server exists AND the routers are configured correctly (a common mis config problem). There is no need to explicitly start the DHCPv6 client like you do in v4. If the Router Advertisement (RA) is telling devices that they should generate a DHCPv6 request, then the NetBurner will take care of that.

Hope this serves as a brief introduction. I've only been using is for about six months. If anyone sees an inconsistency please let me know :)

Tom
Attachments
IPv6 Address Configuration.pdf
(345.77 KiB) Downloaded 243 times
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: Using dual stack mode

Post by pbreed »

The net mask is part of the 64 you are passing in....
I really think we should strongly discourage static IPV6 addresses....
SeeCwriter
Posts: 606
Joined: Mon May 12, 2008 10:55 am

Re: Using dual stack mode

Post by SeeCwriter »

Thank you for the document. I will read it and offer comments. I've also ordered some books that cover IPv6.

Not having read the document, this may be a dumb question, but why not Static addresses for IPv6? Most of our end-users don't connect our equipment to a server/router of any flavor. There is typically just a switch that all the pieces connect to and they communicate with one another using static IP addresses over UDP. Don't all the IP addresses need to be compatible for the network, or has that gone away with IPv6?
SeeCwriter
Posts: 606
Joined: Mon May 12, 2008 10:55 am

Re: Using dual stack mode

Post by SeeCwriter »

I should add that, individual pieces of our equipment are often placed in remote locations and they also use Static IP because the user-needs to know the IP address of the unit so he can communicate with it. So even if no DHCPv6 is used, and the equipment relied on the router to assign it an address, how would the end-user know what it was?

Before installation, the user typically connects the equipment to a PC, after the PC has been set to a compatible static IP address, and sets the IP address of the unit as needed. He can do that because we set a default static IP when it ships so the user can communicate with it. With Auto-Config or DHCPv6, how would the user determine what the IP address is using only a PC?

I attached a markup of your document.
Attachments
Intro_IPv6_Addr_Markup.pdf
(147.41 KiB) Downloaded 216 times
Post Reply