summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorPatrick Grimm <patrick@lunatiki.de>2019-02-03 13:32:03 +0100
committerJo-Philipp Wich <jo@mein.io>2019-10-21 17:37:34 +0200
commit498b1fe65f144e142a009670c9861b5ff85ce4e6 (patch)
tree474cf9ba7f85b36f15b013ab28c953fa8c929870
parent36b052f8cc4ee142ad5126b5e4781ae1d7b38317 (diff)
luci-lib-luaneightbl: drop package - all functions ar also in luci-lib-ip
Signed-off-by: Patrick Grimm <patrick@lunatiki.de>
-rw-r--r--applications/luci-app-olsr/Makefile2
-rw-r--r--applications/luci-app-olsr/luasrc/controller/olsr.lua1
-rw-r--r--libs/luci-lib-luaneightbl/Makefile14
-rw-r--r--libs/luci-lib-luaneightbl/src/Makefile17
-rw-r--r--libs/luci-lib-luaneightbl/src/neightbl.c122
5 files changed, 1 insertions, 155 deletions
diff --git a/applications/luci-app-olsr/Makefile b/applications/luci-app-olsr/Makefile
index 93815a55e..6ce1ac255 100644
--- a/applications/luci-app-olsr/Makefile
+++ b/applications/luci-app-olsr/Makefile
@@ -7,7 +7,7 @@
include $(TOPDIR)/rules.mk
LUCI_TITLE:=OLSR configuration and status module
-LUCI_DEPENDS:=+olsrd +olsrd-mod-jsoninfo +luci-lib-luaneightbl +luci-lib-json
+LUCI_DEPENDS:=+olsrd +olsrd-mod-jsoninfo +luci-lib-json
include ../../luci.mk
diff --git a/applications/luci-app-olsr/luasrc/controller/olsr.lua b/applications/luci-app-olsr/luasrc/controller/olsr.lua
index 75463d405..22d9a01f1 100644
--- a/applications/luci-app-olsr/luasrc/controller/olsr.lua
+++ b/applications/luci-app-olsr/luasrc/controller/olsr.lua
@@ -130,7 +130,6 @@ function action_neigh(json)
local devices = ntm:get_wifidevs()
local sys = require "luci.sys"
local assoclist = {}
- --local neightbl = require "neightbl"
local ntm = require "luci.model.network"
local ipc = require "luci.ip"
local nxo = require "nixio"
diff --git a/libs/luci-lib-luaneightbl/Makefile b/libs/luci-lib-luaneightbl/Makefile
deleted file mode 100644
index f0185b86a..000000000
--- a/libs/luci-lib-luaneightbl/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-# Copyright (C) 2008-2014 The LuCI Team <luci@lists.subsignal.org>
-#
-# This is free software, licensed under the Apache License, Version 2.0 .
-#
-
-include $(TOPDIR)/rules.mk
-
-LUCI_TITLE:=neightbl - Lua lib for IPv6 neighbors
-LUCI_DEPENDS:=+liblua
-
-include ../../luci.mk
-
-# call BuildPackage - OpenWrt buildroot signature
diff --git a/libs/luci-lib-luaneightbl/src/Makefile b/libs/luci-lib-luaneightbl/src/Makefile
deleted file mode 100644
index f856d2fa2..000000000
--- a/libs/luci-lib-luaneightbl/src/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-NEIGHTBL_CFLAGS = -std=gnu99
-NEIGHTBL_LDFLAGS = -llua -lm
-NEIGHTBL_OBJ = neightbl.o
-NEIGHTBL_LIB = neightbl.so
-
-%.o: %.c
- $(CC) $(CPPFLAGS) $(CFLAGS) $(LUA_CFLAGS) $(NEIGHTBL_CFLAGS) $(FPIC) -c -o $@ $<
-
-compile: $(NEIGHTBL_OBJ)
- $(CC) $(LDFLAGS) -shared -o $(NEIGHTBL_LIB) $(NEIGHTBL_OBJ) $(NEIGHTBL_LDFLAGS)
-
-install: compile
- mkdir -p $(DESTDIR)/usr/lib/lua
- cp $(NEIGHTBL_LIB) $(DESTDIR)/usr/lib/lua/$(NEIGHTBL_LIB)
-
-clean:
- rm -f *.o *.so
diff --git a/libs/luci-lib-luaneightbl/src/neightbl.c b/libs/luci-lib-luaneightbl/src/neightbl.c
deleted file mode 100644
index 987ec5e32..000000000
--- a/libs/luci-lib-luaneightbl/src/neightbl.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
-License:
-Copyright 2013 Steven Barth <steven@midlink.org>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-#include <stdlib.h>
-#include <stdbool.h>
-#include <lua.h>
-#include <lualib.h>
-#include <lauxlib.h>
-#include <linux/rtnetlink.h>
-#include <sys/socket.h>
-#include <errno.h>
-#include <unistd.h>
-#include <string.h>
-#include <net/if.h>
-#include <arpa/inet.h>
-#include <netinet/ether.h>
-
-char *ether_ntoa_l (const struct ether_addr *addr, char *buf)
-{
- sprintf (buf, "%02x:%02x:%02x:%02x:%02x:%02x",
- addr->ether_addr_octet[0], addr->ether_addr_octet[1],
- addr->ether_addr_octet[2], addr->ether_addr_octet[3],
- addr->ether_addr_octet[4], addr->ether_addr_octet[5]);
- return buf;
-}
-
-static int neightbl_get(lua_State *L) {
- int sock = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE);
- struct sockaddr_nl kernel = {AF_NETLINK, 0, 0, 0};
- if (connect(sock, (struct sockaddr*)&kernel, sizeof(kernel)))
- goto error;
-
- const char *ifname = luaL_checkstring(L, 1);
- int ifindex = if_nametoindex(ifname);
- if (ifindex <= 0)
- goto error;
-
- struct {
- struct nlmsghdr hdr;
- struct ndmsg ndm;
- } req = {
- {sizeof(req), RTM_GETNEIGH, NLM_F_REQUEST | NLM_F_DUMP, 1, 0},
- {AF_INET6, 0, 0, ifindex, 0, 0, 0},
- };
-
- if (send(sock, &req, sizeof(req), 0) != sizeof(req))
- goto error;
-
- lua_newtable(L);
-
- char buf[8192];
- struct nlmsghdr *nh = (struct nlmsghdr*)buf;
- do {
- ssize_t len = recv(sock, buf, sizeof(buf), 0);
- if (len < 0) {
- lua_pop(L, 1);
- goto error;
- }
-
-
- for (;NLMSG_OK(nh, (size_t)len) && nh->nlmsg_type == RTM_NEWNEIGH;
- nh = NLMSG_NEXT(nh, len)) {
- struct ndmsg *ndm = NLMSG_DATA(nh);
- if (NLMSG_PAYLOAD(nh, 0) < sizeof(*ndm) || ndm->ndm_ifindex != ifindex)
- continue;
-
- ssize_t alen = NLMSG_PAYLOAD(nh, sizeof(*ndm));
- char buf[INET6_ADDRSTRLEN] = {0}, *mac = NULL, str_buf[ETH_ALEN];
- for (struct rtattr *rta = (struct rtattr*)&ndm[1]; RTA_OK(rta, alen);
- rta = RTA_NEXT(rta, alen)) {
- if (rta->rta_type == NDA_DST && RTA_PAYLOAD(rta) >= sizeof(struct in6_addr))
- inet_ntop(AF_INET6, RTA_DATA(rta), buf, sizeof(buf));
- else if (rta->rta_type == NDA_LLADDR && RTA_PAYLOAD(rta) >= 6)
- mac = ether_ntoa_l(RTA_DATA(rta),str_buf);
- }
-
- if (mac)
- lua_pushstring(L, mac);
- else
- lua_pushboolean(L, false);
-
- lua_setfield(L, -2, buf);
- }
- } while (nh->nlmsg_type == RTM_NEWNEIGH);
-
- close(sock);
- return 1;
-
-error:
- close(sock);
- lua_pushnil(L);
- lua_pushinteger(L, errno);
- lua_pushstring(L, strerror(errno));
- return 3;
-}
-
-
-static const luaL_reg R[] = {
- {"get", neightbl_get},
- {NULL, NULL}
-};
-
-
-int luaopen_neightbl(lua_State *l)
-{
- luaL_register(l, "neightbl", R);
- return 1;
-}