Hello! I have a problem and would like to know if any of you could
give me an answer. I am using C on a linux plataform, and I need to
compare 2 addreses to see which one is "bigger".
Using IPv4 I use the following code:
if(ntohl(max.s_addr) < ntohl(min.s_addr))
//swap both addresses
And I`m trying to do this with IPv6
if (max6.s6_addr32[0] < min6.s6_addr32[0] ||
(max6.s6_addr32[0] == min6.s6_addr32[0] &&
(max6.s6_addr32[1] < min6.s6_addr32[1] ||
(max6.s6_addr32[1] == min6.s6_addr32[1] &&
(max6.s6_addr32[2] < min6.s6_addr32[2] ||
(max6.s6_addr32[2] == min6.s6_addr32[3] &&
(max6.s6_addr32[3] < min6.s6_addr32[3])
))))))
//swap both addresses
But i think this is quite long. Do you know about some function that I
can use to make this simpler?
thanks in advance
Carlos Martinez