News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Storage of IPv6 Address on the stack???

Started by jimeeg, October 10, 2006, 07:52:53 PM

Previous topic - Next topic

jimeeg

i am not sure where to put this question so if this is the wrong place please let me know.

i am trying to research how the IPv6 address is stored into memory.  the IPv4 address is easy, because we can load it directly into an register such as eax and push it onto the stack.  works great, but how are the IPv6 stuffed on there?

i am guessing that it takes 4 pushes onto the stack and somehow that is all popped back off into the AF_INET6 structure, but HOW????  does anyone have a disassembled copy of that code? 

a sample of the ipv4 code is:

mov ebp-4Ch, eax  ;store ip address from eax into ebp
push 10h
lea eax, [ebp-50h] ;load address up
push eax

anyone have an idea or a good place to look - my searches are failing me.

Tedd

ip4 = 4 bytes (one 32-bit register; one push)
ip6 = 6 bytes (one a half 32-bit registers; or two pushes -- giving 8 bytes, but two aren't directly used)

If you were to pop an ip6 address into a structure then you would do it in two pops, one for each four bytes of the structure (unless the struct really is 6 bytes, then you have to pop the 'halfer' to a register and store the lower 16-bits.)


Anyway, start here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/ipv6_support_2.asp
No snowflake in an avalanche feels responsible.

japheth


Hi,

> ip6 = 6 bytes (one a half 32-bit registers; or two pushes -- giving 8 bytes, but two aren't directly used)

but size of in6_addr is indeed 16, not 6.

sinsi

Surely an IPv6 address is 128 bits? Where does "6 bytes" come from? :confusion:
Light travels faster than sound, that's why some people seem bright until you hear them.

jimeeg

IPv6 is 128 ... this means that we have FOUR ipv4 addresses to push for each IPv6.

Tedd - thanks for the link, but i was hoping someone had the actual disassembled/assembly code for doing this not the C code and explaination of operators.  I will keep digging, and hopefully someone else has had some experience with this even though it is extremely new.


Tedd

Sorry, it is 128-bits :dazzled:
Everyone ignore me today ::)
No snowflake in an avalanche feels responsible.

jimeeg


japheth

> anyone have any clues?

You shouldn't wonder why you don't get that many responses because your question is not totally clear and your ipv4 example has errors and lacks comments. But I will try a simple translation to ipv6, regardless if it is useful or not:



    .data
v6addr db 16 dup (?)
    .code
    mov eax, dword ptr [v6addr+0]
    mov ebx, dword ptr [v6addr+4]
    mov ecx, dword ptr [v6addr+8]
    mov edx, dword ptr [v6addr+12]
    mov [ebp-4Ch], eax  ;store ip address from eax into ebp
    mov [ebp-48h], ebx
    mov [ebp-44h], ecx
    mov [ebp-40h], edx
    push 10h             ;whatever this parameter means
    lea eax, [ebp-50h] ;load address up
    push eax


the question is what is in [ebp-50h] -  the first dword -, but this may have been just a typo?


jimeeg

That was what i was looking for!  it is similar to what i had in mind.

Sorry, if my question was not clear.  Now i just need to incorporate something similar as that into hexcode for my research.  Thanks for backing me up.