Embedded IPv4 Addr in IPv6

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

Embedded IPv4 Addr in IPv6

Post by SeeCwriter »

As I read RFC 2373 about embedding an IPv4 address in an IPv6 address, it says that the IPv4 address is assigned to the low-order bits (0-31). But looking at the IPADDR6 structure, it assumes the IPv4 address is in the high-order bits (95-127). Is this because of big-endian/little-endian issues?
User avatar
dciliske
Posts: 623
Joined: Mon Feb 06, 2012 9:37 am
Location: San Diego, CA
Contact:

Re: Embedded IPv4 Addr in IPv6

Post by dciliske »

I'm just going to go with: yes.

An IPv6 address is by definition a 128-bit long bit sequence; the IPADDR6 structure is a 128-bit long array of 32-bit values. Since we can only access the 128-bits in 32-bit chunks, we have to slide the window until the correct chunk appears underneath our index. Thus, to get to the "low" order bits for the embedded IPv4 address, you need to slide the window to a higher address.
Dan Ciliske
Project Engineer
Netburner, Inc
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: Embedded IPv4 Addr in IPv6

Post by pbreed »

Take a look here:
https://www.iana.org/assignments/iana-i ... stry.xhtml

We map all IPV4 addresses to the space labeled IPv4-mapped Address
In RFC 4291 see 2.5.5.2
Delleem
Posts: 1
Joined: Mon Sep 30, 2019 2:20 am

Re: Embedded IPv4 Addr in IPv6

Post by Delleem »

What's the reason for mapping all IPV4 addresses like that, Pbreed?
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: Embedded IPv4 Addr in IPv6

Post by pbreed »

So all of the network function calls, send, connect, sendto, receive etc.. can have the same exact interface.
IE IPV4 and IPV6 are treated EXACTLY the same by your code.
You don't have to do ANYTHING different.


Under the hood things are different, but for the user/programmer the interface is identical.
Same for UDP both Send and Receive
Same for listen/accept a TCP connection then query its address...

If you want to convert text to an IP address it works for both a V4 and V6 address...
If you want to printout an address onto a webpage, or console, it works the same....

IE
IPADDR ipa;
ipa=GetAddressFromSomewhere();

printf("%I",ipa);
Will print out a V4 address if its V4 and a V6 if its V6...

(%I is a netburner extension to our printf , spprintf,fdprintf snprintf etc.. that prints IP addresses)
Post Reply