1
0
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:
2023-06-23 23:31:50 +02:00
parent 49ebdc82a7
commit 8c476968e9
5 changed files with 6 additions and 3 deletions

View File

@@ -13,7 +13,7 @@ if (args[1] == "a") then
if (itf.ethernet) then if (itf.ethernet) then
print(string.format("\tMAC : %s MTU : %d", itf.ethernet:addr(), itf.ethernet:mtu())) print(string.format("\tMAC : %s MTU : %d", itf.ethernet:addr(), itf.ethernet:mtu()))
end 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()))) print(string.format("\tIP : %s Mask : %s", ipv4.address.tostring(itf.ip:addr()), ipv4.address.tostring(itf.ip:mask())))
end end
end end

View File

@@ -4,6 +4,7 @@ local bit32 = require("bit32")
local ipv4Adress = {} local ipv4Adress = {}
function ipv4Adress.fromString(val) function ipv4Adress.fromString(val)
checkArg(1, val, 'string')
local a, b, c, d = val:match("^(%d+)%.(%d+)%.(%d+)%.(%d+)$") 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 if (not a or not b or not c or not d) then error("Not a IPv4", 2) end
a = assert(tonumber(a)) a = assert(tonumber(a))
@@ -18,6 +19,7 @@ function ipv4Adress.fromString(val)
end end
function ipv4Adress.tostring(val) function ipv4Adress.tostring(val)
checkArg(1, val, 'number')
local a = bit32.extract(val, 24, 8) local a = bit32.extract(val, 24, 8)
local b = bit32.extract(val, 16, 8) local b = bit32.extract(val, 16, 8)
local c = bit32.extract(val, 8, 8) local c = bit32.extract(val, 8, 8)
@@ -29,6 +31,7 @@ end
---@param cidr string ---@param cidr string
---@return number address, number mask ---@return number address, number mask
function ipv4Adress.fromCIDR(cidr) function ipv4Adress.fromCIDR(cidr)
checkArg(1, cidr, 'string')
local address, mask = cidr:match("^(%d+%.%d+%.%d+%.%d+)/(%d+)$") local address, mask = cidr:match("^(%d+%.%d+%.%d+%.%d+)/(%d+)$")
mask = assert(tonumber(mask)) mask = assert(tonumber(mask))
return ipv4Adress.fromString(address), ipv4Adress.maskLenToMask(mask) return ipv4Adress.fromString(address), ipv4Adress.maskLenToMask(mask)

View File

@@ -255,7 +255,7 @@
["osinetwork"] = { ["osinetwork"] = {
["manifestVersion"] = "1.0", ["manifestVersion"] = "1.0",
["package"] = "osinetwork", ["package"] = "osinetwork",
["version"] = "2.3.1", ["version"] = "2.3.2",
["name"] = "OSI Network stack", ["name"] = "OSI Network stack",
["repo"] = "tree/master/network", ["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", ["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.

View File

@@ -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", 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", authors = "AR2000AR",
repo = "tree/master/network", repo = "tree/master/network",
version = "2.3.1" version = "2.3.2"
}, },
["dns_common"] = { ["dns_common"] = {
files = { files = {