Commit graph

20 commits

Author SHA1 Message Date
Jo-Philipp Wich
ac7b37ef01 luci-lib-ip: fix creating address instances from integers
Ensure that the proper byte order is used when creating IPv4/IPv6/MAC
instances from integer values on big endian systems.

Fixes: #6678
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2023-11-07 22:59:08 +01:00
Santiago Piccinini
62505bdd2d luci-lib-ip: fix tolinklocal invalid ipv6 result
Force zeroing uninitialized memory.

Signed-off-by: Santiago Piccinini <spiccinini@altermundi.net>
2020-09-06 18:15:29 -03:00
Jo-Philipp Wich
c2eeb09bd9 luci-lib-ip: explicitly clear scope when allocating new userdata
Fixes: #3609
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-02-08 11:03:56 +01:00
Jo-Philipp Wich
5cbbfaba3e luci-lib-ip: explicitly initialize address scope value
Explicitly initialize the address scope value to zero in parse_cidr() and
L_setaddr() to avoid stray scope identifiers getting added when formatting
the address object as string.

Fixes: 1d2b4c777 ("luci-lib-ip: support scoped IPv6 addresses")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-01-23 12:33:49 +01:00
Jo-Philipp Wich
f7a7f89e0c luci-lib-ip: support scoped IPv6 addresses
Ref: https://github.com/openwrt/luci/issues/3380
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-12-09 17:31:51 +01:00
Jo-Philipp Wich
d73553e530 luci-lib-ip: support specifying source address in route()
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-08-06 15:19:50 +02:00
yangfl
401382a459 treewide: Fix typos in comments
Signed-off-by: David Yang <mmyangfl@gmail.com>
2018-10-10 15:00:07 +08:00
Jo-Philipp Wich
4f412a76c2 luci-lib-ip: add MAC address calculation support
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-03-12 16:02:55 +01:00
Jo-Philipp Wich
daeb2016d6 luci-lib-ip: fix documentation issue
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-09-01 16:49:19 +02:00
Jo-Philipp Wich
7ca5222f4b luci-lib-ip: add api documentation
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-28 22:31:14 +01:00
Jo-Philipp Wich
e6e74b712f luci-lib-ip: add functions to deal with IPv6 mapped IPv6
* Add luci.ip.cidr.is6mapped4() to test whether an IPv6 CIDR is a mapped IPv4 one
 * Add luci.ip.cidr.mapped4() to derive IPv4 from mapped CIDR
 * Remove mapped IPv4 workaround from constructor as it breaks genuine addrs like ::ffff:0

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-28 14:21:04 +01:00
Jo-Philipp Wich
65f0135491 luci-lib-ip: multiple fixes
* Fix broken neighbor filtering by address range due to uninitialized memory
 * Fix wrong sizeof in _cidr_add_sub when adding/substracing IPv6 addresses
 * Properly convert numeric values to IPv6 addresses

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-28 13:23:24 +01:00
Jo-Philipp Wich
8c8c69fa5d luci-lib-ip: accept 2nd netmask argument in new(), IPv4() and IPv6()
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-26 10:47:39 +01:00
Jo-Philipp Wich
0d32e69f16 luci-lib-ip: fix segfault in link() on systems with ip6gre support
If an ip6gre interface is queried, the resulting link local address string
of 47 byte overflowed the buffer of 32 bytes used to hold the translated
address.

Increase the address string buffer to 48 byte and check the address length
prior to writing it into the buffer to avoid future problems with longs
link local addresses.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-25 21:39:17 +01:00
Jo-Philipp Wich
eb1ef783f6 luci-lib-ip: fix netlink receiving in link()
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-24 14:25:53 +01:00
Jo-Philipp Wich
671566d701 luci-lib-ip: add link() method to get basic iface info
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-23 13:00:51 +01:00
Jo-Philipp Wich
4ab9f972c4 luci-lib-ip: always return table for dump, even if empty
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-22 23:59:11 +01:00
Jo-Philipp Wich
e85698638f luci-lib-ip: support filtering neighbors by mac or dest addr
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-22 23:43:56 +01:00
Jo-Philipp Wich
e9bfa5fe79 luci-lib-ip: fix routes() for non-callback invocations
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-22 15:25:41 +01:00
Jo-Philipp Wich
0ff02e3a13 libs: add luci-lib-ip
Add new luci.ip library which is an api compatible C reimplementation
of ip.lua. It also supports dumping the system routing table and neighbour
entry database via netlink.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-22 15:01:50 +01:00