full Lua implementation of inet_ntop