Skip to content

Commit e2f7443

Browse files
committed
oonf-olsrd2: reinstate and update to OONF master
Reverts the olsrd2 portion of the oonf-* removal in 58070aa. The two issues that motivated removal are fixed in current OONF master: - GCC 14 -Wint-conversion in os_system_linux.c: master uses designated initializers for struct msghdr. The fix existed on develop and landed on master in the 2025-12 develop->master merge. - CMake 4.x: root CMakeLists.txt now sets cmake_minimum_required 3.10. Bumps the source pin from the stale 2022-08-25 commit to master b2164126 (2025-12-04), bumps PKG_RELEASE, and drops 100-enable-lan-import-plugin.patch, which upstream has absorbed (lan_import is now in src/olsrv2/CMakeLists.txt). Verified: clean build and hash verification with the OpenWrt x86-64 gcc-14.3.0_musl SDK. Signed-off-by: Matthias Tarasiewicz <mt@riat.at>
1 parent 6ea029d commit e2f7443

9 files changed

Lines changed: 403 additions & 0 deletions

File tree

oonf-init-scripts/Makefile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
3+
include $(TOPDIR)/rules.mk
4+
5+
PKG_NAME:=oonf-init-scripts
6+
PKG_VERSION:=0.9.1
7+
PKG_RELEASE:=1
8+
9+
PKG_MAINTAINER:=Matthias Tarasiewicz <mt@riat.at>
10+
PKG_LICENSE:=GPL-2.0-only
11+
12+
include $(INCLUDE_DIR)/package.mk
13+
14+
define Package/oonf-init-scripts
15+
SECTION:=net
16+
CATEGORY:=Network
17+
SUBMENU:=OLSR.org network framework
18+
TITLE:=Common OONF startup scripts
19+
URL:=https://www.olsr.org/
20+
DEPENDS:=+jshn +ubus +uci
21+
endef
22+
23+
define Package/oonf-init-scripts/description
24+
Shared shell helpers sourced by the OONF init scripts.
25+
endef
26+
27+
define Build/Compile
28+
endef
29+
30+
define Package/oonf-init-scripts/install
31+
$(INSTALL_DIR) $(1)/lib/functions
32+
$(INSTALL_DATA) ./files/oonf_init.sh $(1)/lib/functions/oonf_init.sh
33+
$(INSTALL_DATA) ./files/oonf_hotplug.sh $(1)/lib/functions/oonf_hotplug.sh
34+
endef
35+
36+
$(eval $(call BuildPackage,oonf-init-scripts))
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
case "${ACTION}" in
4+
ifup)
5+
. /etc/rc.common /etc/init.d/${DAEMON} enabled && {
6+
logger -t "${DAEMON}[hotplug]" -p daemon.info 'reloading configuration'
7+
. /etc/rc.common /etc/init.d/${DAEMON} reload
8+
}
9+
;;
10+
esac
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#!/bin/sh
2+
3+
. /usr/share/libubox/jshn.sh
4+
5+
oonf_log()
6+
{
7+
logger -s -t ${DAEMON} -p daemon.info "${1}"
8+
}
9+
10+
oonf_get_layer3_device()
11+
{
12+
local interface="${1}" # e.g. 'mywifi'
13+
local status dev proto
14+
local query="{ \"interface\" : \"${interface}\" }"
15+
16+
status="$( ubus -S call network.interface status "${query}" )" && {
17+
json_load "${status}"
18+
json_get_var 'dev' l3_device
19+
json_get_var 'proto' proto
20+
case "${proto}" in
21+
pppoe)
22+
# TODO: otherwise it segfaults
23+
oonf_log "refusing to add '$interface', because of proto '${proto}'"
24+
;;
25+
*)
26+
echo "${dev}" # e.g. 'wlan0-1'
27+
;;
28+
esac
29+
}
30+
}
31+
32+
oonf_add_devices_to_configuration()
33+
{
34+
local i=0
35+
local device_name= section= interface= single_interface=
36+
local ignore_list=
37+
38+
# make a copy of configuration and
39+
# add a 'name' (physical name) for all
40+
# 'interface-names' (e.g. mywifi)
41+
42+
# /var is in ramdisc/tmpfs
43+
uci export ${DAEMON} >"/var/run/${DAEMON}_dev"
44+
45+
while section="$( uci -q -c /etc/config get "${DAEMON}.@[${i}]" )"; do {
46+
interface="$( uci -q -c /etc/config get "${DAEMON}.@[${i}].ifname" )" || {
47+
i=$(( i + 1 ))
48+
continue
49+
}
50+
51+
case "$( uci -q get "${DAEMON}.@[${i}].ignore" )" in
52+
1|on|true|enabled|yes)
53+
oonf_log "ignoring section '${section}'"
54+
ignore_list="${i} ${ignore_list}"
55+
i=$(( i + 1 ))
56+
continue
57+
;;
58+
esac
59+
60+
for single_interface in ${interface}; do {
61+
device_name="$( oonf_get_layer3_device "${single_interface}" )"
62+
63+
if [ ! -z "${device_name}" ]
64+
then
65+
# add option 'name' for 'ifname' (e.g. 'mywifi')
66+
uci -q -c /var/run add_list "${DAEMON}_dev.@[${i}].name=${device_name}"
67+
fi
68+
} done
69+
i=$(( $i + 1 ))
70+
} done
71+
72+
for j in ${ignore_list}; do
73+
uci -q -c /var/run delete "${DAEMON}_dev.@[${j}]"
74+
done
75+
76+
uci -q -c /var/run commit "${DAEMON}_dev"
77+
78+
oonf_log "wrote '/var/run/${DAEMON}_dev'"
79+
}
80+
81+
82+
oonf_reread_config()
83+
{
84+
local pid
85+
local pidfile="/var/run/${DAEMON}.pid"
86+
87+
if [ -e "${pidfile}" ]; then
88+
read pid <"${pidfile}"
89+
elif pidfile="$( uci -q get "${DAEMON}.@global[0].pidfile" )"; then
90+
read pid <"${pidfile}"
91+
fi
92+
93+
# if empty, ask kernel
94+
pid="${pid:-$( pidof ${DAEMON} )}"
95+
96+
[ -n "${pid}" ] && kill -SIGHUP ${pid}
97+
}
98+
99+
start()
100+
{
101+
oonf_add_devices_to_configuration
102+
103+
# produce coredumps
104+
ulimit -c unlimited
105+
106+
service_start /usr/sbin/${DAEMON} --set global.fork=true --load uci:///var/run/${DAEMON}_dev
107+
}
108+
109+
stop()
110+
{
111+
service_stop /usr/sbin/${DAEMON}
112+
}
113+
114+
reload()
115+
{
116+
oonf_add_devices_to_configuration
117+
oonf_reread_config
118+
}
119+
120+
running()
121+
{
122+
# check if we have a pidfile and then check if that pid still exists.
123+
# since we don't use -e this has to be explicitly returned. exit would stop the process.
124+
local pidfile="/var/run/${DAEMON}.pid"
125+
test -e "${pidfile}" && test -e "/proc/$(cat "${pidfile}")" && return 0
126+
return 1
127+
}
128+
129+
status()
130+
{
131+
if running; then
132+
echo "running"
133+
else
134+
echo "stopped"
135+
fi
136+
}

oonf-olsrd2/Config.in

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# OONF Olsrd2 configuration
2+
menu "Optional Plugins"
3+
depends on PACKAGE_oonf-olsrd2
4+
5+
config OONF_NHDP_AUTOLL4
6+
bool "Auto_LL4 plugin enabled"
7+
help
8+
The auto_ll4 plugin automatically generates linklocal IPv4 addresses on interfaces that do not contain IPv4 addresses.
9+
default n
10+
11+
config OONF_OLSRV2_LAN_IMPORT
12+
bool "Lan_import plugin enabled"
13+
help
14+
The lan_import plugin can read routing tables and automatically export them as locally attached networks in olsrd2.
15+
default y
16+
17+
config OONF_OLSRV2_ROUTE_MODIFIER
18+
bool "route_modifier plugin enabled"
19+
help
20+
The route_modifier plugin allows you to overwrite aspects of routes (like table/protocol) for certain destinations.
21+
default y
22+
23+
config OONF_GENERIC_DLEP_ROUTER
24+
bool "dlep_router plugin enabled"
25+
help
26+
The dlep_router plugin can receive linklayer metadata over the DLEP protocol.
27+
default n
28+
29+
config OONF_GENERIC_REMOTECONTROL
30+
bool "remotecontrol plugin enabled"
31+
help
32+
The remotecontrol plugin allows you to control configuration and logging over the telnet plugin. Be careful not to open this functionality over the network without securing it.
33+
default y
34+
35+
config OONF_GENERIC_HTTP
36+
bool "http plugin enabled"
37+
help
38+
The HTTP plugin allows HTTP access to all telnet commands.
39+
default n
40+
41+
config OONF_OLSRV2_MPR
42+
bool "MPR plugin enabled"
43+
help
44+
The MPR plugin reduce the routing graph to limit the overhead of the OLSRv2 protocol
45+
default y
46+
47+
config OONF_OLSRV2_LAN
48+
bool "New config option for Locally attached entries"
49+
help
50+
Adds the 'lan' section to the config to configure LANs without setting multiple settings in a single key/value pair
51+
default y
52+
53+
config OONF_OLSRV2_OLD_LAN
54+
bool "Legacy option for Locally attached entries"
55+
help
56+
Adds the olsr 'lan' config key in the olsrv2 section
57+
default n
58+
59+
endmenu

oonf-olsrd2/Makefile

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
3+
include $(TOPDIR)/rules.mk
4+
5+
PKG_NAME:=oonf-olsrd2
6+
PKG_RELEASE:=1
7+
8+
PKG_MAINTAINER:=Matthias Tarasiewicz <mt@riat.at>
9+
PKG_LICENSE:=BSD-3-Clause
10+
11+
PKG_SOURCE_PROTO:=git
12+
PKG_SOURCE_URL:=https://github.com/OLSR/OONF.git
13+
PKG_SOURCE_DATE:=2025-12-04
14+
PKG_SOURCE_VERSION:=b2164126e12340f19ea33070e1e11eb469a051e5
15+
PKG_MIRROR_HASH:=75f54d0d45f40bd64eba191ac5986d320210c887e101ff5498e9cfdb7febf033
16+
17+
include $(INCLUDE_DIR)/package.mk
18+
include $(INCLUDE_DIR)/cmake.mk
19+
20+
21+
# ref https://stackoverflow.com/a/10571900/3990041
22+
SPACE:= $(subst ,, )
23+
CMAKE_OPTIONAL_PLUGINS:= $(subst $(SPACE),;,$(strip \
24+
$(if $(filter y,$(CONFIG_OONF_NHDP_AUTOLL4)),auto_ll4,) \
25+
$(if $(filter y,$(CONFIG_OONF_OLSRV2_LAN_IMPORT)),lan_import,) \
26+
$(if $(filter y,$(CONFIG_OONF_OLSRV2_ROUTE_MODIFIER)),route_modifier,) \
27+
$(if $(filter y,$(CONFIG_OONF_GENERIC_DLEP_ROUTER)),dlep,) \
28+
$(if $(filter y,$(CONFIG_OONF_GENERIC_REMOTECONTROL)),remotecontrol,) \
29+
$(if $(filter y,$(CONFIG_OONF_OLSRV2_MPR)),mpr,) \
30+
$(if $(filter y,$(CONFIG_OONF_GENERIC_HTTP)),http,) \
31+
$(if $(filter y,$(CONFIG_OONF_OLSRV2_LAN)),olsrv2_lan,) \
32+
$(if $(filter y,$(CONFIG_OONF_OLSRV2_OLD_LAN)),olsrv2_old_lan,) \
33+
))
34+
35+
BUILD_TYPE:= $(if $(filter y,$(CONFIG_DEBUG)),Debug,Release)
36+
37+
CMAKE_OPTIONS+=-D CMAKE_BUILD_TYPE:String=$(BUILD_TYPE) \
38+
-D OONF_NO_WERROR:Bool=true \
39+
-D OONF_LOGGING_LEVEL:String=debug \
40+
-D OONF_NO_TESTING:Bool=true \
41+
-D UCI:Bool=true \
42+
-D OONF_APP_DEFAULT_CFG_HANDLER:String=uci \
43+
-D OONF_STATIC_PLUGINS:String="class;callback;clock;duplicate_set;layer2;packet_socket;rfc5444;socket;stream_socket;telnet;timer;viewer;os_clock;os_fd;os_interface;os_routing;os_system;nhdp;olsrv2;ff_dat_metric;neighbor_probing;nl80211_listener;link_config;layer2info;systeminfo;cfg_uciloader;cfg_compact;nhdpinfo;olsrv2info;netjsoninfo;${CMAKE_OPTIONAL_PLUGINS}" \
44+
-D OONF_LIB_GIT:String=$(PKG_SOURCE_VERSION) \
45+
-D VERSION_SUB_TAG:String=$(PKG_SOURCE_DATE) \
46+
-D INSTALL_LIB_DIR:Path=lib/oonf \
47+
-D INSTALL_INCLUDE_DIR:Path=include/oonf \
48+
-D INSTALL_CMAKE_DIR:Path=lib/oonf \
49+
-D CMAKE_PREFIX_PATH=$(STAGING_DIR)/usr \
50+
-D CMAKE_GENERATOR=Ninja
51+
52+
define Package/oonf-olsrd2
53+
SECTION:=net
54+
CATEGORY:=Network
55+
SUBMENU:=OLSR.org network framework
56+
TITLE:=OLSRv2 routing agent (olsrd2)
57+
URL:=https://www.olsr.org/
58+
DEPENDS:=+librt +libnl-tiny +libuci +oonf-init-scripts
59+
MENU:=1
60+
endef
61+
62+
define Package/oonf-olsrd2/config
63+
source "$(SOURCE)/Config.in"
64+
endef
65+
66+
Build/Compile=$(call Build/Compile/Default,olsrd2_static)
67+
68+
Build/Install=
69+
70+
define Build/Install
71+
$(INSTALL_BIN) -D $(PKG_BUILD_DIR)/$(MAKE_PATH)/olsrd2_static $(PKG_INSTALL_DIR)/usr/sbin/olsrd2;
72+
endef
73+
74+
TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include -I${STAGING_DIR}/usr/include/libnl-tiny
75+
76+
define Package/oonf-olsrd2/install
77+
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/init.d $(1)/etc/hotplug.d/iface $(1)/etc/config
78+
$(INSTALL_BIN) $(PKG_BUILD_DIR)/olsrd2_static $(1)/usr/sbin/olsrd2
79+
$(INSTALL_BIN) ./files/olsrd2.init $(1)/etc/init.d/olsrd2
80+
$(INSTALL_DATA) ./files/olsrd2.hotplug $(1)/etc/hotplug.d/iface/50-olsrd2
81+
$(INSTALL_CONF) ./files/olsrd2.uci $(1)/etc/config/olsrd2
82+
endef
83+
84+
define Package/oonf-olsrd2/conffiles
85+
/etc/config/olsrd2
86+
endef
87+
88+
$(eval $(call BuildPackage,oonf-olsrd2))

oonf-olsrd2/files/olsrd2.hotplug

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
DAEMON='olsrd2'
4+
5+
. /lib/functions/oonf_hotplug.sh

oonf-olsrd2/files/olsrd2.init

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh /etc/rc.common
2+
3+
START=82
4+
DAEMON='olsrd2'
5+
6+
[ -n "$IPKG_INSTROOT" ] || {
7+
. /lib/functions/oonf_init.sh
8+
9+
extra_command "running" "Check if service is running"
10+
extra_command "status" "Service status"
11+
}

oonf-olsrd2/files/olsrd2.uci

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
config global
2+
option 'failfast' 'no'
3+
option 'pidfile' '/var/run/olsrd2.pid'
4+
option 'lockfile' '/var/lock/olsrd2'
5+
6+
config log
7+
option 'syslog' 'true'
8+
option 'stderr' 'true'
9+
# option 'file' '/var/log/olsrd2.log'
10+
# option 'info' 'all'
11+
# option 'debug' 'all'
12+
13+
config telnet
14+
# option 'port' '2009'
15+
16+
config olsrv2
17+
# list 'lan' '::/0'
18+
# list 'lan' '0.0.0.0/0'
19+
20+
config interface
21+
option 'ifname' 'loopback'
22+
23+
config interface
24+
list 'ifname' 'WIFI'
25+
list 'ifname' 'wlanadhoc'
26+
list 'ifname' 'wlanadhocRADIO1'
27+
28+
config interface
29+
list 'ifname' 'wan'
30+
option 'ignore' '1'
31+
# option 'rx_bitrate' '100M'
32+
# option 'tx_bitrate' '100M'
33+
# option 'signal' '-20'
34+
35+
config interface
36+
list 'ifname' 'lan'
37+
option 'ignore' '1'
38+
# option 'rx_bitrate' '1G'
39+
# option 'tx_bitrate' '1G'
40+
# option 'signal' '-10'

0 commit comments

Comments
 (0)