X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=documentation%2Fapi%2Fmodules%2Fluci.ip.cidr.html;h=5a2b06ec67f377340daf06ed0b82e18fc7580d94;hp=ce8c567952c230c469d2f3a85513e66593391d1e;hb=4f412a76c262acf099678fe97c058f295c749608;hpb=315a54b89cd9953199bf46a04c153070aae8f408 diff --git a/documentation/api/modules/luci.ip.cidr.html b/documentation/api/modules/luci.ip.cidr.html index ce8c56795..5a2b06ec6 100644 --- a/documentation/api/modules/luci.ip.cidr.html +++ b/documentation/api/modules/luci.ip.cidr.html @@ -260,6 +260,30 @@ Checks whether the CIDR instance is an IPv6 mapped IPv4 address + cidr:ismac () + + +Checks whether the CIDR instance is an ethernet MAC address range + + + + + cidr:ismaclocal () + + +Checks whether the CIDR instance is a locally administered (LAA) MAC address + + + + + cidr:ismacmcast () + + +Checks whether the CIDR instance is a multicast MAC address + + + + cidr:lower (addr) @@ -323,6 +347,20 @@ Derive mapped IPv4 address of CIDR instance. + cidr:tomac () + + +Derive MAC address of IPv6 link local CIDR instance. + + + + cidr:tolinklocal () + + +Derive IPv6 link local address from MAC address CIDR instance. + + + cidr:contains (addr) @@ -405,6 +443,10 @@ Checks whether the CIDR instance is an IPv4 address range cidr:is6 +
  • + cidr:ismac + + @@ -499,6 +541,10 @@ Checks whether the CIDR instance is an IPv6 address range cidr:is4 +
  • + cidr:ismac + + @@ -566,13 +612,108 @@ end +
    cidr:ismac ()
    +
    + + +Checks whether the CIDR instance is an ethernet MAC address range + + + + + + + + +

    Return value:

    +true if the CIDR is a MAC address range, else false + + + +

    See also:

    + + +
    + + + + +
    cidr:ismaclocal ()
    +
    + + +Checks whether the CIDR instance is a locally administered (LAA) MAC address + + + + + + +

    Usage:

    +
    local mac = luci.ip.new("02:C0:FF:EE:00:01") 
    +if mac:ismaclocal() then 
    +  print("Is an LAA MAC address") 
    +end
    + + + +

    Return value:

    +true if the MAC address sets the locally administered bit. + + + +
    + + + + +
    cidr:ismacmcast ()
    +
    + + +Checks whether the CIDR instance is a multicast MAC address + + + + + + +

    Usage:

    +
    local mac = luci.ip.new("01:00:5E:7F:00:10") 
    +if addr:ismacmcast() then 
    +  print("Is a multicast MAC address") 
    +end
    + + + +

    Return value:

    +true if the MAC address sets the multicast bit. + + + +
    + + + +
    cidr:lower (addr)
    Checks whether this CIDR instance is lower than the given argument. The comparisation follows these rules: - @@ -837,7 +985,7 @@ CIDR instance representing the network address Derive host address of CIDR instance. This function essentially constructs a copy of this CIDR with the prefix size -set to 32 for IPv4 and 128 for IPv6. +set to 32 for IPv4, 128 for IPv6 or 48 for MAC addresses. @@ -877,8 +1025,8 @@ prefix size can be overridden by the optional mask parameter.
  • mask: Either a number containing the number of bits (0..32 - for IPv4, 0..128 for IPv6) or a string containing a valid - netmask (optional) + for IPv4, 0..128 for IPv6 or 0..48 for MAC addresses) or a string + containing a valid netmask (optional)
  • @@ -913,8 +1061,8 @@ Derive broadcast address of CIDR instance. Constructs a CIDR instance representing the broadcast address of this instance. The used prefix size can be overridden by the optional mask parameter. -This function has no effect on IPv6 instances, it will return nothing in this -case. +This function has no effect on IPv6 or MAC address instances, it will return +nothing in this case. @@ -922,9 +1070,8 @@ case. @@ -960,8 +1107,8 @@ Derive mapped IPv4 address of CIDR instance. Constructs a CIDR instance representing the IPv4 address of the IPv6 mapped IPv4 address in this instance. -This function has no effect on IPv4 instances or IPv6 instances which are not a -mapped address, it will return nothing in this case. +This function has no effect on IPv4 instances, MAC address instances or IPv6 +instances which are not a mapped address, it will return nothing in this case. @@ -985,6 +1132,74 @@ Return a new CIDR instance representing the IPv4 address if this +
    cidr:tomac ()
    +
    + + +Derive MAC address of IPv6 link local CIDR instance. + +Constructs a CIDR instance representing the MAC address contained in the IPv6 +link local address of this instance. + +This function has no effect on IPv4 instances, MAC address instances or IPv6 +instances which are not a link local address, it will return nothing in this +case. + + + + + + +

    Usage:

    +
    local addr = luci.ip.new("fe80::6666:b3ff:fe47:e1b9") 
    +print(addr:tomac()) -- "64:66:B3:47:E1:B9"
    + + + +

    Return value:

    +Return a new CIDR instance representing the MAC address if this + instance is an IPv6 link local address, else return nothing. + + + +
    + + + + +
    cidr:tolinklocal ()
    +
    + + +Derive IPv6 link local address from MAC address CIDR instance. + +Constructs a CIDR instance representing the IPv6 link local address of the +MAC address represented by this instance. + +This function has no effect on IPv4 instances or IPv6 instances, it will return +nothing in this case. + + + + + + +

    Usage:

    +
    local mac = luci.ip.new("64:66:B3:47:E1:B9") 
    +print(mac:tolinklocal()) -- "fe80::6666:b3ff:fe47:e1b9"
    + + + +

    Return value:

    +Return a new CIDR instance representing the IPv6 link local address. + + + +
    + + + +
    cidr:contains (addr)
    @@ -1014,7 +1229,11 @@ print(range:contains("10.0.0.0/8")) -- false local range6 = luci.ip.new("fe80::/10") print(range6:contains("fe80::221:63f:fe75:aa17/64")) -- true -print(range6:contains("fd9b:6b3:c5:0:221:63f:fe75:aa17/64")) -- false +print(range6:contains("fd9b:6b3:c5:0:221:63f:fe75:aa17/64")) -- false + +local intel_macs = luci.ip.MAC("C0:B6:F9:00:00:00/24") +print(intel_macs:contains("C0:B6:F9:A3:C:11")) -- true +print(intel_macs:contains("64:66:B3:47:E1:B9")) -- false @@ -1059,30 +1278,40 @@ address space, the result is set to the highest possible address.

    Usage:

    local addr = luci.ip.new("192.168.1.1/24") 
    -print(addr:add(250))         -- "192.168.1.251/24" 
    -print(addr:add("0.0.99.0"))  -- "192.168.100.1/24" 
    +print(addr:add(250))           -- "192.168.1.251/24" 
    +print(addr:add("0.0.99.0"))    -- "192.168.100.1/24" 
      
    -addr:add(256, true)          -- true 
    -print(addr)                  -- "192.168.2.1/24 
    +addr:add(256, true)            -- true 
    +print(addr)                    -- "192.168.2.1/24 
      
    -addr:add("255.0.0.0", true)  -- false (overflow) 
    -print(addr)                  -- "255.255.255.255/24 
    +addr:add("255.0.0.0", true)    -- false (overflow) 
    +print(addr)                    -- "255.255.255.255/24 
      
     local addr6 = luci.ip.new("fe80::221:63f:fe75:aa17/64") 
    -print(addr6:add(256))        -- "fe80::221:63f:fe75:ab17/64" 
    -print(addr6:add("::ffff:0")) -- "fe80::221:640:fe74:aa17/64" 
    +print(addr6:add(256))          -- "fe80::221:63f:fe75:ab17/64" 
    +print(addr6:add("::ffff:0"))   -- "fe80::221:640:fe74:aa17/64" 
    + 
    +addr6:add(256, true)           -- true 
    +print(addr6)                   -- "fe80::221:63f:fe75:ab17/64 
    + 
    +addr6:add("ffff::", true)      -- false (overflow) 
    +print(addr6)                   -- "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/64" 
    + 
    +local mac = luci.ip.new("00:14:22:01:23:45") 
    +print(mac:add(256))            -- "00:14:22:01:24:45" 
    +print(mac:add("0:0:0:0:FF:0")  -- "00:14:22:02:22:45" 
      
    -addr:add(256, true)          -- true 
    -print(addr)                  -- "fe80::221:63f:fe75:ab17/64 
    +mac:add(256, true)             -- true 
    +print(mac)                     -- "00:14:22:01:24:45" 
      
    -addr:add("ffff::", true)     -- false (overflow) 
    -print(addr)                  -- "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/64"
    +mac:add("FF:FF:0:0:0:0", true) -- false (overflow) +print(mac) -- "FF:FF:FF:FF:FF:FF"

    Return value: