问题描述
使用下面的模块,我可以长 IPv4 地址。我如何为 IPv6 做同样的事情?
function ip2long(ip)
local inp = ffi.new("struct in_addr[1]")
if C.inet_aton(ip,inp) ~= 0 then
return tonumber(C.ntohl(inp[0].s_addr))
end
return nil
end
function long2ip(long)
if type(long) ~= "number" then
return nil
end
local addr = ffi.new("struct in_addr")
addr.s_addr = C.htonl(long)
return ffi.string(C.inet_ntoa(addr))
end
https://github.com/agentzh/lua-php-utils/blob/master/php/utils.lua
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)