1, Given a 32-bit integer value, how to exactly determine if it is private IPv4 address.
2, Given a 128-bit integer value, how to exactly determine if it is private IPv6 address.
Consider the byte order of the IP address on different platforms, it is error-prone to write such a common little function every time. So I think there should be a library function for this, is there?
This will get you started. I didn't bother including the "link local" address range, but that's an exercise left for you to complete by modifying the code below.
IPV6 is slightly different. And your question is slightly malformed since most systems don't have a native 128-bit type. IPv6 addresses are usually contained as an array of 16 bytes embedded in a sockaddr_in6 struct.
Everything you need to know to finish this example is at this link here.