c++ - converting a byte array into a in_addr or in6_addr and endianness -


i'm concerned endianness when comes problem. maybe overthinking have worry about.

the input code packet looks like:

i've received network packet contains bytes. if know index in byte array (and have valid data) of in_addr is, safe like:

uint8_t* addrptr = packet[ip_idx]; struct in_addr addr; memcpy((void*) addr, addrptr, sizeof(in_addr)); 

is safe regardless of endianness?

what in6_addr 16 bytes?

thanks.

struct in_addr supposed in network byte order, iirc. assuming packet delivered in network byte order, you're go.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -