There is a libuv function for that: uv_interface_addresses()