mirror of
https://github.com/AR2000AR/openComputers_codes.git
synced 2025-09-07 22:21:14 +02:00
[osinetwork] misc fixes
This commit is contained in:
@@ -13,7 +13,7 @@ if (args[1] == "a") then
|
||||
if (itf.ethernet) then
|
||||
print(string.format("\tMAC : %s MTU : %d", itf.ethernet:addr(), itf.ethernet:mtu()))
|
||||
end
|
||||
if (itf.ip) then
|
||||
if (itf.ip and itf.ip:addr()) then
|
||||
print(string.format("\tIP : %s Mask : %s", ipv4.address.tostring(itf.ip:addr()), ipv4.address.tostring(itf.ip:mask())))
|
||||
end
|
||||
end
|
||||
|
@@ -4,6 +4,7 @@ local bit32 = require("bit32")
|
||||
local ipv4Adress = {}
|
||||
|
||||
function ipv4Adress.fromString(val)
|
||||
checkArg(1, val, 'string')
|
||||
local a, b, c, d = val:match("^(%d+)%.(%d+)%.(%d+)%.(%d+)$")
|
||||
if (not a or not b or not c or not d) then error("Not a IPv4", 2) end
|
||||
a = assert(tonumber(a))
|
||||
@@ -18,6 +19,7 @@ function ipv4Adress.fromString(val)
|
||||
end
|
||||
|
||||
function ipv4Adress.tostring(val)
|
||||
checkArg(1, val, 'number')
|
||||
local a = bit32.extract(val, 24, 8)
|
||||
local b = bit32.extract(val, 16, 8)
|
||||
local c = bit32.extract(val, 8, 8)
|
||||
@@ -29,6 +31,7 @@ end
|
||||
---@param cidr string
|
||||
---@return number address, number mask
|
||||
function ipv4Adress.fromCIDR(cidr)
|
||||
checkArg(1, cidr, 'string')
|
||||
local address, mask = cidr:match("^(%d+%.%d+%.%d+%.%d+)/(%d+)$")
|
||||
mask = assert(tonumber(mask))
|
||||
return ipv4Adress.fromString(address), ipv4Adress.maskLenToMask(mask)
|
||||
|
@@ -255,7 +255,7 @@
|
||||
["osinetwork"] = {
|
||||
["manifestVersion"] = "1.0",
|
||||
["package"] = "osinetwork",
|
||||
["version"] = "2.3.1",
|
||||
["version"] = "2.3.2",
|
||||
["name"] = "OSI Network stack",
|
||||
["repo"] = "tree/master/network",
|
||||
["description"] = "A close to official rfc emulation of the OSI layers for OpenOS. Include Ethernet, ARP, ICMP, UDP. Also provide a luasocket libe librairy",
|
||||
|
Binary file not shown.
@@ -277,7 +277,7 @@
|
||||
note = "Are provided : ping, ifup, ifdown, arp, nc, netstat. Any one of theses tools may be moved to a separate package at any time",
|
||||
authors = "AR2000AR",
|
||||
repo = "tree/master/network",
|
||||
version = "2.3.1"
|
||||
version = "2.3.2"
|
||||
},
|
||||
["dns_common"] = {
|
||||
files = {
|
||||
|
Reference in New Issue
Block a user