Compare commits

..

66 commits

Author SHA1 Message Date
Bastian Bittorf
ee12b0330f
Merge pull request #307 from HRogge/for-14.07
OONF 0.14.1-1
2017-12-13 12:41:49 +01:00
Henning Rogge
00ba1ea5fe Update OONF to 0.14.1-1 2017-06-13 11:00:08 +02:00
Henning Rogge
09735e0a16 Add v0.14.0 OONF 2017-06-06 16:48:18 +02:00
Bastian Bittorf
fb0203bc53 Merge pull request #236 from HRogge/for-14.07
Update to OONF version 0.13.0
2016-10-21 13:00:37 +02:00
Henning Rogge
11a23c28a3 Update to OONF version 0.13.0 2016-10-21 12:51:19 +02:00
Bastian Bittorf
aab1355501 Merge pull request #228 from HRogge/for-14.07
Update to OONF 0.12.4
2016-09-09 20:16:58 +02:00
Henning Rogge
fec97ee9af Update to OONF 0.12.4 2016-09-04 14:22:09 +02:00
Bastian Bittorf
43cf77fb15 Merge pull request #223 from HRogge/for-14.07
Update to OONF 0.12.3
2016-08-18 13:44:27 +02:00
Henning Rogge
77d934e4ea Update to OONF 0.12.3 2016-08-17 17:21:58 +02:00
Bastian Bittorf
48f8992987 Merge pull request #219 from HRogge/for-14.07
Update to OONF 0.12.2 + coverity fix
2016-08-09 13:15:17 +02:00
Henning Rogge
f9a9197d62 Update to OONF 0.12.2 + coverity fix 2016-08-01 11:58:35 +02:00
Bastian Bittorf
73c3b55495 Merge pull request #200 from HRogge/for-14.07
OONF v0.12.1
2016-06-20 11:57:06 +02:00
Henning Rogge
d962f7d397 OONF release 0.12.1 2016-06-07 11:20:52 +02:00
Henning Rogge
35dd7fdf5c Update to OONF 0.12.0 2016-05-31 09:02:51 +02:00
Bastian Bittorf
8558fac0c2 Merge pull request #189 from HRogge/for-14.07
For 14.07
2016-05-25 10:15:13 +02:00
Henning Rogge
2831cf1392 Update OONF to v0.11.7 2016-05-13 15:06:00 +02:00
Henning Rogge
77c76f9823 Update OONF to 0.11.6 2016-05-13 10:50:40 +02:00
Henning Rogge
2caae51450 Add remotecontrol plugin to selectable Olsrd2 plugins 2016-05-05 14:21:44 +01:00
Henning Rogge
a3f6a24f2e Add optional packages to OONF olsrd2 2016-05-05 14:00:01 +01:00
Bastian Bittorf
fddd88b1d3 Merge pull request #180 from HRogge/for-14.07
Update to OONF v0.11.4
2016-04-25 11:15:20 +02:00
Henning Rogge
465b4784bc Update to OONF v0.11.4 2016-04-25 08:23:31 +02:00
Bastian Bittorf
8fb50df995 Merge pull request #174 from HRogge/for-14.07
Update to OONF 0.11.3
2016-04-23 17:28:07 +02:00
Henning Rogge
777fcc18a4 Update to OONF 0.11.3 2016-04-19 12:31:19 +02:00
Bastian Bittorf
e2e9be7bd3 Merge pull request #164 from HRogge/for-14.07
Update to version 0.11.2
2016-03-19 16:40:16 +01:00
Henning Rogge
99f2c955b3 Update to version 0.11.2 2016-03-17 14:16:25 +01:00
Bastian Bittorf
4b0a4bd80b Merge pull request #161 from HRogge/for-14.07
Update to OONF 0.11.1
2016-03-13 16:23:58 +01:00
Henning Rogge
f6523a6ae9 Update to OONF 0.11.1 2016-03-12 00:47:32 +01:00
Bastian Bittorf
16e4720534 Merge pull request #153 from HRogge/for-14.07
For 14.07
2016-03-04 15:55:58 +01:00
Henning Rogge
5e24cbc069 Forgot to change to switch from os_socket to os_fd for OONF 2016-02-29 19:04:46 +01:00
Henning Rogge
7f970ae58d OONF version 0.11.0 2016-02-28 21:32:15 +01:00
Bastian Bittorf
2e704cd29e Merge pull request #138 from HRogge/for-14.07
update to v0.9.2
2015-09-09 01:40:19 +02:00
Henning Rogge
678ca49420 update to v0.9.2 2015-09-08 18:26:36 +02:00
Bastian Bittorf
0656bdac9b Merge pull request #127 from HRogge/for-14.07
OONF Init script fix for the case that /var/etc does not exist
2015-08-13 14:53:39 +02:00
Henning Rogge
3144a9028c Move OONF temporary config to /var/run 2015-08-12 16:59:30 +02:00
Henning Rogge
530e8c47db Merge remote-tracking branch 'openwrt/for-14.07' into for-14.07 2015-08-10 14:10:22 +02:00
Henning Rogge
0d7353bc70 OONF Init script fix for the case that /var/etc does not exist 2015-08-10 13:53:13 +02:00
Bastian Bittorf
7b166ede6e Merge pull request #124 from HRogge/for-14.07
Unified Openwrt startup scripts for OONF
2015-08-06 22:45:33 +02:00
Henning Rogge
a84e564f85 Unified Openwrt startup scripts for OONF 2015-08-06 22:31:56 +02:00
Bastian Bittorf
c8f5a485a7 Merge pull request #118 from HRogge/for-14.07
OONF v0.9.1 for barrier breaker
2015-08-05 16:21:31 +02:00
Henning Rogge
0db0048832 OONF v0.9.1 for barrier breaker 2015-08-05 13:14:44 +02:00
Bastian Bittorf
932b4ec738 Merge pull request #109 from westbywest/for-14.07
[olsrd] adapt init script for 0.6.8 (PingCmd option)
2015-07-03 19:59:51 +02:00
André Gaul
87d52fc40d [olsrd] adapt init script for 0.6.8 (PingCmd option)
olsrd 0.6.8 accepts a PingCmd parameter as of
http://olsr.org/git/?p=olsrd.git;a=commitdiff;h=0a26c52af3941eb9060b193cae5552f8d13fd28e.
The PingCmd is a string of the form "ping -c 1 -q %s" where %s is
replaced with an IP. This commit allows for '%' characters in an olsrd
option.
2015-07-01 17:30:48 -05:00
Bastian Bittorf
00e5c81841 olsrd: for14.07: 0.9.0.1 -> 0.9.0.2 (bugfix-release) 2015-07-01 21:34:13 +02:00
Bastian Bittorf
4a5132cc66 olsrd: Makefile version typo: 0.9.1 -> 0.9.0.1 2015-06-19 13:20:36 +02:00
Bastian Bittorf
212640f11d olsrd: 14.07-branch: bump to new version 0.9.1 (bugfixes)
We did a bug-fix release of olsrd v1.
It fixes a route-recalculation issue and at least one crash.

Everyone using olsrd v1 is strongly urged to upgrade, especially people
using Smart-Gateway.

The shortlog is appended.

0.9.0.1 -------------------------------------------------------------------

Ferry Huberts (3):
      neighbors: signal link changes when deleting a neighbor
      jsoninfo: do not output smart-gateway info when not enabled.
      txtinfo: do not output smart-gateway info when not enabled.

Henning Rogge (2):
      Update version after release of v0.9.0
      Release v0.9.0.1
2015-06-18 20:11:01 +02:00
Axel Neumann
c8aa5cd271 bmx6: bump to latest (auto tunOutTimeout) version 2015-06-16 15:21:36 +02:00
Bastian Bittorf
e0de429982 olsrd: bump to new release 0.9.0
see: https://lists.olsr.org/pipermail/olsr-dev/2015-June/007598.html

"Everyone using olsrd v1 is strongly urged to upgrade, especially people
using Smart-Gateway.

In this release the Multi-Smart-Gateway additions are declared stable.

Also, Smart-Gateway timeouts are now implemented, which is a major fix
to the Smart-Gateway system. These timeouts were missing ever since its
first implementation." (Ferry Huberts)
2015-06-12 21:34:01 +02:00
Axel Neumann
8e44826ef4 bmx6: bump to latest (--tunnel and --redistTable fixing) version 2015-06-05 10:50:31 +02:00
Pau
5d4ad63897 Merge pull request #68 from rogerpueyo/for-14.07
bmx6: update repository revision (bugfix)
2014-12-17 16:22:20 +01:00
Roger Pueyo Centelles
f6aa55e00a bmx6: update repository revision (bugfix) 2014-12-12 12:22:32 +01:00
Steven Barth
c08fe48bcd hnetd: stability and bug fixes 2014-09-26 09:34:15 +02:00
Casper Meijn
1a999ad02b babeld: create the directory for the config file before writing to it 2014-09-08 14:51:08 +02:00
Baptiste Jonglez
47f74d0041 babeld: Specify edge cases 2014-09-03 15:12:21 +02:00
Baptiste Jonglez
d26e5eb197 babeld: Backward compatibility with old config files
This allows to use the old syntax "config interface foo" for specifying an
interface.  The new syntax ("option ifname foo") takes precedence.

Also, old option names for the "general" section are translated
accordingly.  Exceptions are:

- 'hello_interval' and 'wired_hello_interval', which are now interface-specific;
- 'conf_file', since /etc/babeld.conf is now always used;

which are simply ignored.

Beware, the syntax for the 'diversity' option is not backward compatible.
2014-09-03 15:01:44 +02:00
Baptiste Jonglez
e30f3394d3 babeld: Update configuration file for new syntax 2014-09-03 15:01:44 +02:00
Baptiste Jonglez
8ff7cde48f babeld: Support default interface configuration
When a "section interface" does not have a "option ifname", all its
options are used as default interface options.
2014-09-03 15:01:44 +02:00
Baptiste Jonglez
06158b911e babeld: Take interface name from "option ifname"
Previously, we were using the name of the section as the interface name,
but this has several drawbacks:

- no "-" or other special characters are allowed in a section name,
  preventing some physical interface names to be specified this way
  (e.g. "tun-topeka" would not work)
- it is harder to support default interface options (no interface name)

This change is not backward compatible, but a later commit will fix that.
2014-09-03 15:01:44 +02:00
Baptiste Jonglez
a7a090d12e babeld: Handle ignore options 2014-09-03 15:01:44 +02:00
Baptiste Jonglez
bfbcaf87e6 babeld: Print an error when startup fails 2014-09-03 15:01:44 +02:00
Baptiste Jonglez
20004f09cb babeld: Generate a configuration file instead of passing cmdline arguments
This is the first step toward fixing issue #33.

This still lacks some features:

- no support for "ignore" options
- no backward compatibility for option names
- no support for default interface options
2014-09-03 15:01:44 +02:00
Baptiste Jonglez
6218a5ac03 babeld: Update to 1.5.1 2014-09-03 15:01:44 +02:00
Steven Barth
9a64273132 nat46: add map-t meta-package
Signed-off-by: Steven Barth <steven@midlink.org>
2014-09-02 13:57:19 +02:00
Steven Barth
1774c10dba hnetd: fix mdns-support
Signed-off-by: Steven Barth <steven@midlink.org>
2014-09-02 10:19:00 +02:00
Steven Barth
11ed2e8613 babels: update repository URL 2014-08-10 14:18:24 +02:00
Steven Barth
9d3c311fdd hnetd: fix ipv4 uplink detection 2014-07-31 17:41:23 +02:00
Steven Barth
d7616fd1f3 miniupnpd: fix integer conversion in NAT-PMP, update description
Signed-off-by: Steven Barth <steven@midlink.org>
2014-07-30 15:51:05 +02:00
265 changed files with 9860 additions and 9639 deletions

View file

@ -1,16 +0,0 @@
Please make sure that the issue subject starts with `<package-name>: `
Also make sure that the package is maintained in this repository and not in OpenWrt-base, OpenWrt-packages or OpenWrt-LuCI.
Issues related to releases below 18.06 and forks are not supported or maintained and will be closed.
# Issue template (remove lines from top till here)
Maintainer: @\<github-user> (find it by checking history of the package Makefile)
Environment: (put here arch, model, OpenWrt version)
Description:
```
Formating code blocks by wrapping them with pairs of ```
```

View file

@ -1,5 +0,0 @@
Maintainer: me / @\<github-user> (find it by checking history of the package Makefile)
Compile tested: (put here arch, model, OpenWrt version)
Run tested: (put here arch, model, OpenWrt version, tests done)
Description:

View file

@ -1,6 +0,0 @@
ARG ARCH=x86-64
FROM openwrt/rootfs:$ARCH
ADD entrypoint.sh /entrypoint.sh
CMD ["/entrypoint.sh"]

View file

@ -1,91 +0,0 @@
name: Check autorelease deprecation
on:
pull_request_target:
types: [opened, synchronize, converted_to_draft, ready_for_review, edited]
jobs:
build:
name: Check autorelease deprecation
runs-on: ubuntu-latest
strategy:
fail-fast: false
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Determine branch name
run: |
BRANCH="${GITHUB_BASE_REF#refs/heads/}"
echo "Building for $BRANCH"
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
- name: Determine changed packages
run: |
RET=0
# only detect packages with changes
PKG_ROOTS=$(find . -name Makefile | \
grep -v ".*/src/Makefile" | \
sed -e 's@./\(.*\)/Makefile@\1/@')
CHANGES=$(git diff --diff-filter=d --name-only origin/$BRANCH...)
for ROOT in $PKG_ROOTS; do
for CHANGE in $CHANGES; do
if [[ "$CHANGE" == "$ROOT"* ]]; then
if grep -q '$(AUTORELEASE)' "$ROOT/Makefile"; then
CONTAINS_AUTORELEASE+="$ROOT"
fi
break
fi
done
done
if [ -n "$CONTAINS_AUTORELEASE" ]; then
RET=1
cat > "$GITHUB_WORKSPACE/pr_comment.md" << EOF
Please do no longer set *PKG_RELEASE* to *AUTORELEASE* as the
feature is deprecated. Please use an integer instead. Below is a
list of affected packages including correct *PKG_RELEASE*:
EOF
fi
for ROOT in $CONTAINS_AUTORELEASE; do
echo -n " - ${ROOT}Makefile: PKG_RELEASE:=" >> "$GITHUB_WORKSPACE/pr_comment.md"
last_bump="$(git log --pretty=format:'%h %s' "$ROOT" |
grep --max-count=1 -e ': [uU]pdate to ' -e ': [bB]ump to ' |
cut -f 1 -d ' ')"
if [ -n "$last_bump" ]; then
echo -n $(($(git rev-list --count "$last_bump..HEAD" "$ROOT") + 2)) >> "$GITHUB_WORKSPACE/pr_comment.md"
else
echo -n $(($(git rev-list --count HEAD "$ROOT") + 2)) >> "$GITHUB_WORKSPACE/pr_comment.md"
fi
echo >> "$GITHUB_WORKSPACE/pr_comment.md"
done
exit $RET
- name: Find Comment
uses: peter-evans/find-comment@v2
if: ${{ failure() }}
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v2
if: ${{ failure() }}
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body-file: 'pr_comment.md'
edit-mode: replace

View file

@ -1,26 +0,0 @@
#!/bin/sh
color_out() {
printf "\e[0;$1m$PKG_NAME: %s\e[0;0m\n" "$2"
}
success() {
color_out 32 "$1"
}
info() {
color_out 36 "$1"
}
err() {
color_out 31 "$1"
}
warn() {
color_out 33 "$1"
}
err_die() {
err "$1"
exit 1
}

View file

@ -1,62 +0,0 @@
#!/bin/sh
# not enabling `errtrace` and `pipefail` since those are bash specific
set -o errexit # failing commands causes script to fail
set -o nounset # undefined variables causes script to fail
echo "src/gz packages_ci file:///ci" >> /etc/opkg/distfeeds.conf
FINGERPRINT="$(usign -F -p /ci/packages_ci.pub)"
cp /ci/packages_ci.pub "/etc/opkg/keys/$FINGERPRINT"
mkdir -p /var/lock/
opkg update
[ -n "${CI_HELPER:=''}" ] || CI_HELPER="/ci/.github/workflows/ci_helpers.sh"
for PKG in /ci/*.ipk; do
tar -xzOf "$PKG" ./control.tar.gz | tar xzf - ./control
# package name including variant
PKG_NAME=$(sed -ne 's#^Package: \(.*\)$#\1#p' ./control)
# package version without release
PKG_VERSION=$(sed -ne 's#^Version: \(.*\)-[0-9]*$#\1#p' ./control)
# package source contianing test.sh script
PKG_SOURCE=$(sed -ne 's#^Source: .*/\(.*\)$#\1#p' ./control)
echo "Testing package $PKG_NAME in version $PKG_VERSION from $PKG_SOURCE"
export PKG_NAME PKG_VERSION CI_HELPER
PRE_TEST_SCRIPT=$(find /ci/ -name "$PKG_SOURCE" -type d)/pre-test.sh
if [ -f "$PRE_TEST_SCRIPT" ]; then
echo "Use package specific pre-test.sh"
if sh "$PRE_TEST_SCRIPT" "$PKG_NAME" "$PKG_VERSION"; then
echo "Pre-test successful"
else
echo "Pre-test failed"
exit 1
fi
else
echo "No pre-test.sh script available"
fi
opkg install "$PKG"
TEST_SCRIPT=$(find /ci/ -name "$PKG_SOURCE" -type d)/test.sh
if [ -f "$TEST_SCRIPT" ]; then
echo "Use package specific test.sh"
if sh "$TEST_SCRIPT" "$PKG_NAME" "$PKG_VERSION"; then
echo "Test succesful"
else
echo "Test failed"
exit 1
fi
else
echo "No test.sh script available"
fi
opkg remove "$PKG_NAME" --force-removal-of-dependent-packages --force-remove --autoremove || true
done

View file

@ -1,63 +0,0 @@
name: Test Formalities
on:
pull_request:
jobs:
build:
name: Test Formalities
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Determine branch name
run: |
BRANCH="${GITHUB_BASE_REF#refs/heads/}"
echo "Building for $BRANCH"
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
- name: Test formalities
run: |
source .github/workflows/ci_helpers.sh
RET=0
for commit in $(git rev-list HEAD ^origin/$BRANCH); do
info "=== Checking commit '$commit'"
if git show --format='%P' -s $commit | grep -qF ' '; then
err "Pull request should not include merge commits"
RET=1
fi
author="$(git show -s --format=%aN $commit)"
if echo $author | grep -q '\S\+\s\+\S\+'; then
success "Author name ($author) seems ok"
else
err "Author name ($author) need to be your real name 'firstname lastname'"
RET=1
fi
subject="$(git show -s --format=%s $commit)"
if echo "$subject" | grep -q -e '^[0-9A-Za-z,+/_-]\+: ' -e '^Revert '; then
success "Commit subject line seems ok ($subject)"
else
err "Commit subject line MUST start with '<package name>: ' ($subject)"
RET=1
fi
body="$(git show -s --format=%b $commit)"
sob="$(git show -s --format='Signed-off-by: %aN <%aE>' $commit)"
if echo "$body" | grep -qF "$sob"; then
success "Signed-off-by match author"
else
err "Signed-off-by is missing or doesn't match author (should be '$sob')"
RET=1
fi
done
exit $RET

View file

@ -1,157 +0,0 @@
name: Test Build
on:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
build:
name: Test ${{ matrix.arch }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- arch: aarch64_generic
target: armsr-armv8
runtime_test: true
- arch: arm_cortex-a15_neon-vfpv4
target: armsr-armv7
runtime_test: true
- arch: arm_cortex-a9_vfpv3-d16
target: mvebu-cortexa9
runtime_test: false
- arch: i386_pentium-mmx
target: x86-geode
runtime_test: true
- arch: mips_24kc
target: ath79-generic
runtime_test: true
- arch: powerpc_464fp
target: apm821xx-nand
runtime_test: false
- arch: powerpc_8548
target: mpc85xx-p1010
runtime_test: false
- arch: riscv64_riscv64
target: sifiveu-generic
runtime_test: false
- arch: x86_64
target: x86-64
runtime_test: true
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Determine branch name
run: |
BRANCH="${GITHUB_BASE_REF#refs/heads/}"
echo "Building for $BRANCH"
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
- name: Determine changed packages
run: |
# only detect packages with changes
PKG_ROOTS=$(find . -name Makefile | \
grep -v ".*/src/Makefile" | \
sed -e 's@./\(.*\)/Makefile@\1/@')
CHANGES=$(git diff --diff-filter=d --name-only origin/$BRANCH)
for ROOT in $PKG_ROOTS; do
for CHANGE in $CHANGES; do
if [[ "$CHANGE" == "$ROOT"* ]]; then
PACKAGES+=$(echo "$ROOT" | sed -e 's@\(.*\)/@\1 @')
break
fi
done
done
# fallback to test packages if nothing explicitly changes this is
# should run if other mechanics in packages.git changed
PACKAGES="${PACKAGES:-bird2 cjdns olsrd}"
echo "Building $PACKAGES"
echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV
- name: Generate build keys
run: |
sudo apt-get update
sudo apt-get install -y signify-openbsd
signify-openbsd -G -n -c 'DO NOT USE - OpenWrt packages feed CI' -p packages_ci.pub -s packages_ci.sec
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "KEY_BUILD<<$EOF" >> $GITHUB_ENV
cat packages_ci.sec >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
- name: Build
uses: openwrt/gh-action-sdk@v5
env:
ARCH: ${{ matrix.arch }}-${{ env.BRANCH }}
FEEDNAME: packages_ci
INDEX: 1
KEY_BUILD: ${{ env.KEY_BUILD }}
- name: Move created packages to project dir
run: cp bin/packages/${{ matrix.arch }}/packages_ci/* . || true
- name: Store packages
uses: actions/upload-artifact@v3
with:
name: ${{env.ARCHIVE_NAME}}-packages
path: |
Packages
Packages.*
*.ipk
PKG-INFO
- name: Store logs
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.arch}}-logs
path: logs/
- name: Remove logs
run: sudo rm -rf logs/ || true
- name: Check if any packages were built
run: |
if [ -n "$(find . -maxdepth 1 -type f -name '*.ipk' -print -quit)" ]; then
echo "Found *.ipk files"
HAVE_IPKS=true
else
echo "No *.ipk files found"
HAVE_IPKS=false
fi
echo "HAVE_IPKS=$HAVE_IPKS" >> $GITHUB_ENV
- name: Register QEMU
if: ${{ matrix.runtime_test && fromJSON(env.HAVE_IPKS) }}
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static binfmt-support
sudo update-binfmts --import
- name: Build Docker container
if: ${{ matrix.runtime_test && fromJSON(env.HAVE_IPKS) }}
run: |
docker build -t test-container --build-arg ARCH .github/workflows/
env:
ARCH: ${{ matrix.arch }}-${{ env.BRANCH }}
- name: Test via Docker container
if: ${{ matrix.runtime_test && fromJSON(env.HAVE_IPKS) }}
run: |
docker run --rm -v $GITHUB_WORKSPACE:/ci test-container

View file

@ -8,18 +8,17 @@
# use alphabetical order when updating the list.
Axel "axn" Neumann <neumann@cgws.de>
Baptiste Jonglez <openwrt-pkg@bitsofnetworks.org>
Bastian Bittorf <bb@npl.de>
Bastian Bittorf <bittorf@bluebottle.com>
Corinna "Elektra" Aichele <onelektra@gmx.net>
Gabriel Kerneis <gabriel@kerneis.info>
Gui Iribarren <gui@altermundi.net>
Jo-Philipp Wich <jo@mein.io>
Jo-Philipp Wich <jow@openwrt.org>
Luka Perkov <luka@openwrt.org>
Marek Lindner <mareklindner@neomailbox.ch>
Moritz Warning <moritzwarning@web.de>
Nicolás Echániz <nicoechaniz@altermundi.net>
Pau Escrich <pau@dabax.net>
Saverio Proto <zioproto@gmail.com>
Simon Wunderlich <sw@simonwunderlich.de>
Steven Barth <steven@midlink.org>
Simon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>
Steven Barth <cyrus@openwrt.org>
Vasilis "acinonyx" Tsiligiannis <acinonyx@openwrt.gr>

18
README Normal file
View file

@ -0,0 +1,18 @@
This is an OpenWrt package feed containing community maintained routing packages.
To use these packages, add the following line to the feeds.conf
in the OpenWrt buildroot:
src-git routing git://github.com/openwrt-routing/packages.git
Update the feed:
./scripts/feeds update routing
Activate the package:
./scripts/feeds install -a -p routing
The routing packages should now appear in menuconfig.

View file

@ -1,21 +0,0 @@
# OpenWrt Routing Feed
## Description
This OpenWrt package feed contains community maintained routing packages.
## Usage
This repository is intended to be layered on-top of an OpenWrt buildroot.
If you do not have an OpenWrt buildroot installed, see the documentation at:
[OpenWrt Buildroot Installation][1] on the OpenWrt support site.
This feed is enabled by default. To install all its package definitions, run:
```
./scripts/feeds update routing
./scripts/feeds install -a -p routing
```
[1]: https://openwrt.org/docs/guide-developer/build-system/install-buildsystem

View file

@ -1,4 +1,4 @@
#
#
# Copyright (C) 2007-2011 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
@ -9,15 +9,12 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=ahcpd
PKG_VERSION:=0.53
PKG_RELEASE:=3
PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://www.irif.fr/~jch/software/files/
PKG_HASH:=a4622e817d2b2a9b878653f085585bd57f3838cc546cca6028d3b73ffcac0d52
PKG_SOURCE_URL:=http://www.pps.univ-paris-diderot.fr/~jch/software/files/
PKG_MD5SUM:=a1a610bf20965aa522cd766bf3d5829a
PKG_MAINTAINER:=Gabriel Kerneis <gabriel@kerneis.info>
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENCE
include $(INCLUDE_DIR)/package.mk
@ -25,8 +22,9 @@ define Package/ahcpd
SECTION:=net
CATEGORY:=Network
TITLE:=Ad-Hoc Configuration Protocol daemon
URL:=https://www.irif.fr/~jch/software/ahcp/
DEPENDS:=@IPV6 +ip +librt
URL:=http://www.pps.univ-paris-diderot.fr/~jch/software/ahcp/
MAINTAINER:=Gabriel Kerneis <gabriel@kerneis.info>
DEPENDS:=+kmod-ipv6 +ip +librt
endef
define Package/ahcpd/description

View file

@ -1,55 +1,51 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
#
# The latest alfred git hash in PKG_REV can be obtained from http://git.open-mesh.org/alfred.git
#
PKG_NAME:=alfred
PKG_VERSION:=2024.0
PKG_RELEASE:=1
PKG_VERSION:=2014.3.0
PKG_RELEASE:=0
PKG_MD5SUM:=b8ab5677ed73d817b02b0e4fae10357a
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
PKG_HASH:=d029a43638ab16771e5f71e134bc843d1713d74041c65bcda18a31d18f5531bd
PKG_MAINTAINER:=Simon Wunderlich <sw@simonwunderlich.de>
PKG_LICENSE:=GPL-2.0-only MIT
PKG_LICENSE_FILES:=LICENSES/preferred/GPL-2.0 LICENSES/preferred/MIT
PKG_BUILD_PARALLEL:=1
PKG_BUILD_FLAGS:=gc-sections lto
PKG_CONFIG_DEPENDS += \
CONFIG_ALFRED_NEEDS_lua \
CONFIG_ALFRED_NEEDS_libgps \
CONFIG_PACKAGE_ALFRED_VIS \
CONFIG_PACKAGE_ALFRED_BATHOSTS \
CONFIG_PACKAGE_ALFRED_GPSD
PKG_SOURCE_URL:=http://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
init-y := alfred
define Package/alfred
URL:=http://www.open-mesh.org/
SECTION:=net
CATEGORY:=Network
TITLE:=A.L.F.R.E.D. - Almighty Lightweight Fact Remote Exchange Daemon
URL:=https://www.open-mesh.org/
DEPENDS:= +libc @IPV6 +libnl-tiny +librt \
+ALFRED_NEEDS_lua:lua \
+ALFRED_NEEDS_libgps:libgps
DEPENDS:= +libc +IPV6:kmod-ipv6 +librt \
+ALFRED_NEEDS_lua:lua \
+ALFRED_NEEDS_libgps:libgps
endef
define Package/alfred/description
alfred is a user space daemon for distributing arbitrary local information
over the mesh/network in a decentralized fashion. This data can be anything
which appears to be useful - originally designed to replace the batman-adv
visualization (vis), you may distribute hostnames, phone books, administration
information, DNS information, the local weather forecast ...
alfred is a user space daemon for distributing arbitrary local information over
the mesh/network in a decentralized fashion. This data can be anything which
appears to be useful - originally designed to replace the batman-adv
visualization (vis), you may distribute hostnames, phone books, administration
information, DNS information, the local weather forecast ...
alfred runs as daemon in the background of the system. A user may insert
information by using the alfred binary on the command line, or use special
programs to communicate with alfred (done via unix sockets). alfred then takes
care of distributing the local information to other alfred servers on other
nodes. This is done via IPv6 link-local multicast, and does not require any
configuration. A user can request data from alfred, and will receive the
information available from all alfred servers in the network.
alfred runs as daemon in the background of the system. A user may insert
information by using the alfred binary on the command line, or use special
programs to communicate with alfred (done via unix sockets). alfred then takes
care of distributing the local information to other alfred servers on other
nodes. This is done via IPv6 link-local multicast, and does not require any
configuration. A user can request data from alfred, and will receive the
information available from all alfred servers in the network.
endef
define Package/alfred/conffiles
@ -60,19 +56,24 @@ define Package/alfred/config
source "$(SOURCE)/Config.in"
endef
MAKE_FLAGS += \
MAKE_ALFRED_FLAGS=\
CONFIG_ALFRED_VIS=$(if $(CONFIG_PACKAGE_ALFRED_VIS),y,n) \
CONFIG_ALFRED_GPSD=$(if $(CONFIG_PACKAGE_ALFRED_GPSD),y,n) \
CONFIG_ALFRED_CAPABILITIES=n \
LIBNL_NAME="libnl-tiny" \
LIBNL_GENL_NAME="libnl-tiny" \
REVISION="$(PKG_VERSION)-openwrt-$(PKG_RELEASE)"
CONFIG_ALFRED_GPSD=$(if $(CONFIG_PACKAGE_ALFRED_GPSD),y,n)
TARGET_CFLAGS += -ffunction-sections -fdata-sections -flto
TARGET_LDFLAGS += -Wl,--gc-sections -fuse-linker-plugin
define Build/Compile
CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS)" \
$(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS) $(MAKE_ALFRED_FLAGS) all
endef
define Package/alfred/install
$(INSTALL_DIR) $(1)/usr/sbin
cp -fpR $(PKG_BUILD_DIR)/alfred $(1)/usr/sbin/
[ "x$(CONFIG_PACKAGE_ALFRED_VIS)" == "xy" ] && cp -fpR $(PKG_BUILD_DIR)/vis/batadv-vis $(1)/usr/sbin/ ; true
[ "x$(CONFIG_PACKAGE_ALFRED_GPSD)" == "xy" ] && cp -fpR $(PKG_BUILD_DIR)/gpsd/alfred-gpsd $(1)/usr/sbin/ ; true
[ "x$(CONFIG_PACKAGE_ALFRED_GPSD)" == "xy" ] && cp -fpR $(PKG_BUILD_DIR)/vis/alfred-gpsd $(1)/usr/sbin/ ; true
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/alfred.init $(1)/etc/init.d/alfred
$(INSTALL_DIR) $(1)/etc/config

View file

@ -1,5 +1,5 @@
config 'alfred' 'alfred'
list interface 'br-lan'
option interface 'br-lan'
option mode 'master'
option batmanif 'bat0'
option start_vis '1'

View file

@ -1,41 +1,39 @@
#!/bin/sh /etc/rc.common
#
# Copyright (C) 2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
START=99
USE_PROCD=1
STOP=99
alfred_args=""
vis_args=""
facters_dir="/etc/alfred"
pid_file_alfred="/var/run/alfred.pid"
pid_file_vis="/var/run/batadv-vis.pid"
enable=0
vis_enable=0
batmanif=""
SERVICE_DAEMONIZE=1
SERVICE_WRITE_PID=1
append_interface()
alfred_start()
{
append "interfaces" "$1" ","
}
alfred_start() {
local args=""
local section="$1"
local disabled interface mode
local interfaces
# check if section is disabled
config_get_bool disabled "$section" disabled 0
[ $disabled = 0 ] || return 1
args="-f"
args=""
config_list_foreach "$section" "interface" append_interface
if [ -z "$interfaces" ]; then
config_get interface "$section" interface
append_interface "$interface"
fi
append args "-i $interfaces"
config_get interface "$section" interface
append args "-i $interface"
config_get mode "$section" mode
[ "$mode" = "master" ] && append args "-m"
@ -46,52 +44,66 @@ alfred_start() {
append alfred_args "$args"
enable=1
config_get_bool start_vis "$section" start_vis 0
if [ "$start_vis" = 1 ] && [ -x /usr/sbin/batadv-vis ]; then
vis_enable=1
append vis_args "-i $batmanif -s"
fi
config_get_bool start_vis "$section" start_vis 0
if [ "$start_vis" = 1 ] && [ -x /usr/sbin/batadv-vis ]; then
vis_enable=1
append vis_args "-i $batmanif -s"
fi
config_get_bool run_facters "$section" run_facters 0
return 0
}
start_service() {
start()
{
config_load "alfred"
config_foreach alfred_start alfred
[ "$enable" = "0" ] && return 0
if [ "$enable" = "0" ]; then
exit 0
fi
procd_open_instance "alfred"
procd_set_param command /usr/sbin/alfred
procd_append_param command ${alfred_args}
procd_close_instance
mesh_dir="/sys/class/net/$batmanif/mesh/"
if ! [ -d "$mesh_dir" ] ; then
timeout=30
echo "${initscript}: waiting $timeout secs for $batmanif interface..."
for i in $(seq $timeout); do
sleep 1
[ -d "$mesh_dir" ] && break
if [ $i == $timeout ] ; then
echo "${initscript}: $batmanif not detected, alfred not starting."
exit 1
fi
done
fi
[ "$vis_enable" = "1" ] && {
procd_open_instance "batadv-vis"
procd_set_param command /usr/sbin/batadv-vis
procd_append_param command ${vis_args}
procd_close_instance
}
echo "${initscript}: starting alfred"
SERVICE_PID_FILE="$pid_file_alfred"
service_start /usr/sbin/alfred ${alfred_args}
[ "$run_facters" = "1" ] && {
if [ "$vis_enable" = "1" ]; then
echo "${initscript}: starting batadv-vis"
SERVICE_PID_FILE="$pid_file_vis"
service_start /usr/sbin/batadv-vis ${vis_args}
fi
if [ "$run_facters" = "1" ]; then
( for file in $facters_dir/* ; do [ -x $file ] && $file ; done )
if ! ( grep -q "for file in $facters_dir/\* ; do " /etc/crontabs/root 2>/dev/null ) ; then
echo "*/5 * * * * ( for file in $facters_dir/* ; do [ -x \$file ] && \$file ; done )" >> /etc/crontabs/root
/etc/init.d/cron enable
/etc/init.d/cron restart
fi
}
fi
}
service_triggers() {
procd_add_reload_trigger "alfred"
}
stop_service() {
[ -e /etc/crontabs/root ] && {
sed "\|for file in $facters_dir/\* ; do |d" -i /etc/crontabs/root
/etc/init.d/cron restart
}
stop()
{
SERVICE_PID_FILE="$pid_file_alfred"
service_stop /usr/sbin/alfred
SERVICE_PID_FILE="$pid_file_vis"
[ -x /usr/sbin/batadv-vis ] && service_stop /usr/sbin/batadv-vis
sed "\|for file in $facters_dir/\* ; do |d" -i /etc/crontabs/root
/etc/init.d/cron restart
}

View file

@ -87,24 +87,19 @@ end
local function receive_bat_hosts()
-- read raw chunks from alfred, convert them to a nested table and call write_bat_hosts
-- "alfred -r" can fail in slave nodes (returns empty stdout), so:
-- check output is not null before writing /tmp/bat-hosts, and retry 3 times before giving up.
for n = 1, 3 do
local fd = io.popen("alfred -r " .. type_id)
--[[ this command returns something like
{ "54:e6:fc:b9:cb:37", "00:11:22:33:44:55 ham_wlan0\x0a00:22:33:22:33:22 ham_eth0\x0a" },
{ "90:f6:52:bb:ec:57", "00:22:33:22:33:23 spam\x0a" },
]]--
local fd = io.popen("alfred -r " .. type_id)
--[[ this command returns something like
{ "54:e6:fc:b9:cb:37", "00:11:22:33:44:55 ham_wlan0\x0a00:22:33:22:33:22 ham_eth0\x0a" },
{ "90:f6:52:bb:ec:57", "00:22:33:22:33:23 spam\x0a" },
]]--
if fd then
local output = fd:read("*a")
fd:close()
if output and output ~= "" then
assert(loadstring("rows = {" .. output .. "}"))()
write_bat_hosts(rows)
break
end
if fd then
local output = fd:read("*a")
if output then
assert(loadstring("rows = {" .. output .. "}"))()
write_bat_hosts(rows)
end
fd:close()
end
end

View file

@ -1,41 +0,0 @@
# Copyright (C) 2012-2014 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
include $(TOPDIR)/rules.mk
PKG_NAME:=babel-pinger
PKG_VERSION:=0.1
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.pps.univ-paris-diderot.fr/~jch/software/files/
PKG_HASH:=c411430bb102f08d3d68d2fb5010b5da0149908b671ac0fb12abd8c8ee6380c5
include $(INCLUDE_DIR)/package.mk
define Package/babel-pinger
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
TITLE:=Babel-pinger
URL:=http://www.pps.univ-paris-diderot.fr/~jch/software/babel/
MAINTAINER:=Gabriel Kerneis <gabriel@kerneis.info>
DEPENDS:=+librt
endef
define Package/babel-pinger/description
Babel-pinger is a hack to export a default route into Babel for people
using DHCP to configure their routers rather than speaking to their
upstream provider with a proper routing protocol.
endef
MAKE_FLAGS+= \
CFLAGS="$(TARGET_CFLAGS)" \
define Package/babel-pinger/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/babel-pinger $(1)/usr/sbin/
endef
$(eval $(call BuildPackage,babel-pinger))

View file

@ -1,23 +1,19 @@
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Copyright (C) 2007-2021 OpenWrt.org
# Copyright (C) 2007-2009 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=babeld
PKG_VERSION:=1.13.1
PKG_VERSION:=1.5.1
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://www.irif.fr/~jch/software/files/
PKG_HASH:=15f24d26da0ccfc073abcdef0309f281e4684f2aa71126f826572c4c845e8dd9
PKG_MAINTAINER:=Gabriel Kerneis <gabriel@kerneis.info>, \
Baptiste Jonglez <openwrt-pkg@bitsofnetworks.org>, \
Nick Hainke <vincent@systemli.org>
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENCE
PKG_SOURCE_URL:=http://www.pps.univ-paris-diderot.fr/~jch/software/files/
PKG_MD5SUM:=20e3284d5ad291d7ba2ad91d5b47de10
include $(INCLUDE_DIR)/package.mk
@ -25,17 +21,20 @@ define Package/babeld
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
TITLE:=A loop-avoiding distance-vector routing protocol
URL:=https://www.irif.fr/~jch/software/babel/
DEPENDS:=@IPV6 +libubus +libubox
TITLE:=A loop-free distance-vector routing protocol
URL:=http://www.pps.univ-paris-diderot.fr/~jch/software/babel/
MAINTAINER:=Gabriel Kerneis <gabriel@kerneis.info>
DEPENDS:=+kmod-ipv6 +librt
endef
define Package/babeld/description
Babel is a loop-avoiding distance-vector routing protocol for IPv6 and IPv4
with fast convergence properties. It is based on the ideas in DSDV, AODV and
Cisco's EIGRP, but is designed to work well not only in wired networks but
also in wireless mesh networks, and has been extended with support for
overlay networks. Babel is an IETF standard protocol (RFC 8966).
Babel is a loop-avoiding distance-vector routing protocol roughly based
on DSDV and AODV, but with provisions for link cost estimation and
redistribution of routes from other routing protocols.
While it is optimised for wireless mesh networks, Babel will also work
efficiently on wired networks. It will generate between 1.2 and 2.4 times
the amount of routing traffic that RIPng would generate, while
never counting to infinity.
endef
define Package/babeld/conffiles
@ -45,8 +44,6 @@ endef
MAKE_FLAGS+= \
CFLAGS="$(TARGET_CFLAGS)" \
LDLIBS="" \
LDLIBS+="-lubus -lubox"
define Package/babeld/install
$(INSTALL_DIR) $(1)/usr/sbin

View file

@ -1,12 +1,10 @@
package babeld
# Detailed documentation: https://openwrt.org/docs/guide-user/services/babeld
# Babeld reads options from the following files (the last one takes precedence
# if an option is defined in several places):
# - the file defined by the option conf_file (default: /etc/babeld.conf),
# - *.conf files in the directory defined by conf_dir (default: /tmp/babel.d/),
# - this UCI configuration file.
# Configuration set in this file ends up in /var/etc/babeld.conf.
# Babeld is told to use both /etc/babeld.conf and /var/etc/babeld.conf, so
# you can use one or the other, or even both at the same time. If an
# option is defined in both files, the version in /var/etc/babeld.conf
# takes precedence.
# See "man babeld" for all available options ("Global options").
# Important: remember to use '_' instead of '-' in option names.
@ -15,16 +13,10 @@ config general
# option 'debug' '1'
# option 'local_port' '33123'
# option 'log_file' '/var/log/babeld.log'
## Enable ipv6-subtrees by default since OpenWrt should ship with a
## recent enough kernel for it to work.
option 'ipv6_subtrees' 'true'
## This seems somewhat buggy on BB. If you need only one
## import-table statement, "option import_table 42" should work.
# list 'import_table' '42'
# list 'import_table' '100'
## Alternative configuration file and directory.
## See comment at the top of this file for more details.
# option 'conf_file' '/etc/babeld.conf'
# option 'conf_dir' '/tmp/babel.d/'
# option 'ubus_bindings' 'false'
config interface
## Remove this line to enable babeld on this interface
@ -42,10 +34,7 @@ config interface
option 'ignore' 'true'
## Physical interface name
option 'ifname' 'tun-example'
## Specify the type of interface: tunnels use the RTT-based metric.
option 'type' 'tunnel'
## Other options that can be overriden.
# option 'max_rtt_penalty' '96'
# option 'max_rtt_penalty' '90'
# A config interface without "option ifname" will set default options
# for all interfaces. Interface-specific configuration always overrides
@ -55,49 +44,26 @@ config interface
# option 'update_interval' '30'
# A filter consists of a type ('in', 'out', 'redistribute' or 'install'),
# a set of selectors ('ip', 'eq', etc.) and a set of actions to perform
# ('allow', 'deny', 'metric xxx', 'src-prefix xxx', 'table xxx', 'pref-src xxx').
# See babeld man page ("Filtering rules") for more details.
# Below is a sample filter that redistributes the default route if its
# protocol number is "boot", e.g. when it is installed by dhcp (see
# /etc/iproute2/rt_protos). This filter is disabled thanks to the 'ignore'
# setting.
# A filter consists of a type ('in', 'out' or 'redistribute'), an action
# ('allow', 'deny' or 'metric xxx') and a set of selectors ('ip', 'eq',
# etc.). See babeld man page ("Filtering rules") for more details.
# Here is a sample filter wich redistributes the default route if its
# protocol number is "boot", e.g. when it installed by dhcp. It is
# disabled by default.
config filter
option 'ignore' 'true'
# Type of filter
# Type
option 'type' 'redistribute'
# Selectors: ip, eq, le, ge, src_ip, src_eq, src_le, src_ge, neigh, id,
# proto, local, if.
# Selectors: ip, eq, le, ge, neigh, id, proto, local, if
option 'ip' '0.0.0.0/0'
option 'eq' '0'
option 'proto' '3'
# Action, which can be any of: allow, deny, metric <NUMBER>, src-prefix <PREFIX>,
# table <ID>, pref-src <IP>.
# The action defaults to "allow" if not specified. Here, we specify a higher
# redistribution metric than the default (0).
# Action
option 'action' 'metric 128'
# Another example filter: don't redistribute local addresses in a certain IP prefix.
# By default, babeld redistributes *all* local addresses.
# Notice that the 'local' selector is a boolean.
config filter
option 'ignore' 'true'
option 'type' 'redistribute'
# Only apply to routes/addresses within this prefix.
option 'ip' '198.51.100.0/24'
# Notice that the 'local' selector is a boolean.
option 'local' 'true'
# Don't redistribute.
option 'action' 'deny'
# Example install filter, to change or filter routes before they are inserted
# into the kernel.
config filter
option 'ignore' 'true'
option 'type' 'install'
# Optional: only apply to routes within 2001:db8:cafe::/48
option 'ip' '2001:db8:cafe::/48'
# We specify the kernel routing table and the preferred source address to use for these routes.
# "Allow" is implicit.
option 'action' 'table 200 pref-src 2001:db8:ba:be1::42'
# No action means "allow"

View file

@ -1,20 +1,23 @@
#!/bin/sh /etc/rc.common
. $IPKG_INSTROOT/lib/functions/network.sh
. /lib/functions/network.sh
USE_PROCD=1
START=70
pidfile='/var/run/babeld.pid'
CONFIGFILE='/var/etc/babeld.conf'
OTHERCONFIGFILE="/etc/babeld.conf"
OTHERCONFIGDIR="/tmp/babeld.d/"
EXTRA_COMMANDS="status"
EXTRA_HELP=" status Dump Babel's table to the log file."
# Options to ignore for the global section (old options that are translated
# for backward compatibility with old configuration files)
ignored_options="carrier_sense assume_wireless no_split_horizon random_router_id multicast_address port hello_interval wired_hello_interval smoothing_half_time duplication_priority local_server conf_file"
# Append a line to the configuration file
cfg_append() {
local value="$1"
echo "$value" >> "$CONFIGFILE"
echo "$value" >> $CONFIGFILE
}
cfg_append_option() {
@ -57,6 +60,56 @@ append_parm() {
append buffer "$switch $_loctmp"
}
# Provides backward compatibility for old option names in the global section.
translate_option() {
local section="$1"
local old_option="$2"
local new_option="$3"
local _value
config_get _value "$section" "$old_option"
[ -z "$_value" ] && return
cfg_append "${new_option//_/-} $_value"
}
translate_bool() {
local section="$1"
local old_option="$2"
local new_option="$3"
local _bool
local _value
config_get_bool _bool "$section" "$old_option" 0
[ "$_bool" -eq 0 ] && return
cfg_append "${new_option//_/-} true"
}
# Adds a new interface section for setting default interface options.
add_default_option() {
local option="$1"
local value="$2"
cfg_append "default ${option//_/-} $value"
}
# Global 'hello_interval' and 'wired_hello_interval' options are ignored,
# because they have no direct equivalent: you should use
# interface-specific settings.
parse_old_global_options() {
local section="$1"
translate_bool "$section" 'carrier_sense' 'link_detect'
translate_bool "$section" 'random_router_id' 'random_id'
translate_option "$section" 'multicast_address' 'protocol_group'
translate_option "$section" 'port' 'protocol_port'
translate_option "$section" 'local_server' 'local_port'
translate_option "$section" 'smoothing_half_time' 'smoothing_half_life'
translate_option "$section" 'duplication_priority' 'allow_duplicates'
# These two global options are turned into default interface options.
local _bool
config_get_bool _bool "$section" 'assume_wireless' 0
[ "$_bool" -eq 1 ] && add_default_option "wired" "false"
config_get_bool _bool "$section" 'no_split_horizon' 0
[ "$_bool" -eq 1 ] && add_default_option "split_horizon" "false"
}
babel_filter() {
local cfg="$1"
local _loctmp
@ -74,10 +127,6 @@ babel_filter() {
append_parm "$cfg" 'eq' 'eq'
append_parm "$cfg" 'le' 'le'
append_parm "$cfg" 'ge' 'ge'
append_parm "$cfg" 'src_ip' 'src-ip'
append_parm "$cfg" 'src_eq' 'src-eq'
append_parm "$cfg" 'src_le' 'src-le'
append_parm "$cfg" 'src_ge' 'src-ge'
append_parm "$cfg" 'neigh' 'neigh'
append_parm "$cfg" 'id' 'id'
append_parm "$cfg" 'proto' 'proto'
@ -103,18 +152,17 @@ babel_config_cb() {
option_cb() {
local option="$1"
local value="$2"
# Ignore options that are not supposed to be given to babeld
[ "$option" = "conf_file" ] && return
[ "$option" = "conf_dir" ] && return
# Skip lists. They will be taken care of by list_cb
test "${option#*_ITEM}" != "$option" && return
test "${option#*_LENGTH}" != "$option" && return
# Ignore old options
list_contains ignored_options "$option" && return
cfg_append "${option//_/-} $value"
}
;;
"interface")
local _ifname
config_get _ifname "$section" 'ifname'
# Backward compatibility: try to use the section name
# if no "option ifname" was used.
[ -z "$_ifname" -a "${section:0:3}" != "cfg" ] && _ifname="$section"
# Try to resolve the logical interface name
unset interface
network_get_device interface "$_ifname" || interface="$_ifname"
@ -149,58 +197,43 @@ babel_config_cb() {
esac
}
# Support for conf_file and conf_dir
babel_configpaths() {
local cfg="$1"
local conf_file
config_get conf_file "$cfg" "conf_file"
[ -n "$conf_file" ] && OTHERCONFIGFILE="$conf_file"
local conf_dir
config_get conf_dir "$cfg" "conf_dir"
[ -n "$conf_dir" ] && OTHERCONFIGDIR="$conf_dir"
}
start_service() {
start() {
mkdir -p /var/lib
mkdir -p /var/etc
# First load the whole config file, without callbacks, so that we are
# aware of all "ignore" options in the second pass. This also allows
# to load the configuration paths (conf_file and conf_dir).
config_load babeld
# Configure alternative configuration file and directory
config_foreach babel_configpaths "general"
# Start by emptying the generated config file
>"$CONFIGFILE"
# Import dynamic config files
mkdir -p "$OTHERCONFIGDIR"
for f in "$OTHERCONFIGDIR"/*.conf; do
[ -f "$f" ] && cat "$f" >> "$CONFIGFILE"
done
# First load the whole config file, without callbacks, so that we are
# aware of all "ignore" options in the second pass.
config_load babeld
# Parse general and interface sections thanks to the "config_cb()"
# callback. This allows to loop over all options without having to
# know their name in advance.
config_cb() { babel_config_cb "$@"; }
config_load babeld
# Backward compatibility
config_foreach parse_old_global_options general
# Parse filters separately, since we know which options we expect
config_foreach babel_filter filter
procd_open_instance
# Using multiple config files is supported since babeld 1.5.1
procd_set_param command /usr/sbin/babeld -I "" -c "$OTHERCONFIGFILE" -c "$CONFIGFILE"
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param file "$OTHERCONFIGFILE" "$OTHERCONFIGDIR"/*.conf "$CONFIGFILE"
procd_set_param respawn
procd_close_instance
/usr/sbin/babeld -D -I "$pidfile" -c "$OTHERCONFIGFILE" -c "$CONFIGFILE"
# Wait for the pidfile to appear
for i in 1 2
do
[ -f "$pidfile" ] || sleep 1
done
[ -f "$pidfile" ] || (echo "Failed to start babeld"; exit 42)
}
service_triggers() {
procd_add_reload_trigger babeld
stop() {
[ -f "$pidfile" ] && kill $(cat $pidfile)
# avoid race-condition on restart: wait for
# babeld to die for real.
[ -f "$pidfile" ] && sleep 1
[ -f "$pidfile" ] && sleep 1
[ -f "$pidfile" ] && sleep 1
[ -f "$pidfile" ] && exit 42
}
status() {
kill -USR1 $(pgrep -P 1 babeld)
[ -f "$pidfile" ] && kill -USR1 $(cat $pidfile)
}

View file

@ -1,132 +0,0 @@
--- a/babeld.c
+++ b/babeld.c
@@ -54,6 +54,8 @@ THE SOFTWARE.
#include "local.h"
#include "version.h"
+#include "ubus.h"
+
struct timeval now;
unsigned char myid[8];
@@ -505,6 +507,9 @@ main(int argc, char **argv)
}
}
+ if(ubus_bindings)
+ babeld_add_ubus();
+
init_signals();
rc = resize_receive_buffer(1500);
if(rc < 0)
@@ -597,6 +602,8 @@ main(int argc, char **argv)
FD_SET(local_sockets[i].fd, &readfds);
maxfd = MAX(maxfd, local_sockets[i].fd);
}
+ if(ubus_bindings)
+ maxfd = babeld_ubus_add_read_sock(&readfds, maxfd);
rc = select(maxfd + 1, &readfds, NULL, NULL, &tv);
if(rc < 0) {
if(errno != EINTR) {
@@ -665,6 +672,9 @@ main(int argc, char **argv)
i++;
}
+ if(ubus_bindings)
+ babeld_ubus_receive(&readfds);
+
if(reopening) {
kernel_dump_time = now.tv_sec;
check_neighbours_timeout = now;
--- a/generate-version.sh
+++ b/generate-version.sh
@@ -10,4 +10,4 @@ else
version="unknown"
fi
-echo "#define BABELD_VERSION \"$version\""
+echo "#define BABELD_VERSION \"$version-ubus-mod\""
--- a/configuration.c
+++ b/configuration.c
@@ -42,6 +42,8 @@ THE SOFTWARE.
#include "hmac.h"
#include "configuration.h"
+#include "ubus.h"
+
static struct filter *input_filters = NULL;
static struct filter *output_filters = NULL;
static struct filter *redistribute_filters = NULL;
@@ -1024,7 +1026,8 @@ parse_option(int c, gnc_t gnc, void *clo
strcmp(token, "daemonise") == 0 ||
strcmp(token, "skip-kernel-setup") == 0 ||
strcmp(token, "ipv6-subtrees") == 0 ||
- strcmp(token, "reflect-kernel-metric") == 0) {
+ strcmp(token, "reflect-kernel-metric") == 0 ||
+ strcmp(token, "ubus-bindings") == 0) {
int b;
c = getbool(c, &b, gnc, closure);
if(c < -1)
@@ -1042,6 +1045,8 @@ parse_option(int c, gnc_t gnc, void *clo
has_ipv6_subtrees = b;
else if(strcmp(token, "reflect-kernel-metric") == 0)
reflect_kernel_metric = b;
+ else if(strcmp(token, "ubus-bindings") == 0)
+ ubus_bindings = b;
else
abort();
} else if(strcmp(token, "protocol-group") == 0) {
--- a/local.c
+++ b/local.c
@@ -42,6 +42,8 @@ THE SOFTWARE.
#include "local.h"
#include "version.h"
+#include "ubus.h"
+
int local_server_socket = -1;
struct local_socket local_sockets[MAX_LOCAL_SOCKETS];
int num_local_sockets = 0;
@@ -191,6 +193,8 @@ local_notify_neighbour(struct neighbour
if(local_sockets[i].monitor)
local_notify_neighbour_1(&local_sockets[i], neigh, kind);
}
+ if(ubus_bindings)
+ ubus_notify_neighbour(neigh, kind);
}
static void
@@ -228,6 +232,8 @@ local_notify_xroute(struct xroute *xrout
if(local_sockets[i].monitor)
local_notify_xroute_1(&local_sockets[i], xroute, kind);
}
+ if(ubus_bindings)
+ ubus_notify_xroute(xroute, kind);
}
static void
@@ -273,6 +279,8 @@ local_notify_route(struct babel_route *r
if(local_sockets[i].monitor)
local_notify_route_1(&local_sockets[i], route, kind);
}
+ if(ubus_bindings)
+ ubus_notify_route(route, kind);
}
static void
--- a/Makefile
+++ b/Makefile
@@ -11,11 +11,11 @@ LDLIBS = -lrt
SRCS = babeld.c net.c kernel.c util.c interface.c source.c neighbour.c \
route.c xroute.c message.c resend.c configuration.c local.c \
- hmac.c rfc6234/sha224-256.c BLAKE2/ref/blake2s-ref.c
+ hmac.c ubus.c rfc6234/sha224-256.c BLAKE2/ref/blake2s-ref.c
OBJS = babeld.o net.o kernel.o util.o interface.o source.o neighbour.o \
route.o xroute.o message.o resend.o configuration.o local.o \
- hmac.o rfc6234/sha224-256.o BLAKE2/ref/blake2s-ref.o
+ hmac.o ubus.o rfc6234/sha224-256.o BLAKE2/ref/blake2s-ref.o
babeld: $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o babeld $(OBJS) $(LDLIBS)

View file

@ -1,535 +0,0 @@
#include <stdint.h>
#include <stdlib.h>
#include <sys/select.h>
#include <libubox/blob.h>
#include <libubox/blobmsg.h>
#include <libubox/list.h>
#include <libubus.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include "babeld.h"
#include "configuration.h"
#include "interface.h"
#include "kernel.h"
#include "local.h"
#include "message.h"
#include "neighbour.h"
#include "net.h"
#include "resend.h"
#include "route.h"
#include "source.h"
#include "util.h"
#include "version.h"
#include "xroute.h"
#include "ubus.h"
// Definition of header variable whether to enable ubus bindings.
int ubus_bindings = 0;
// Shared state maintained throughout calls to handle ubus messages.
static struct ubus_context *shared_ctx;
// List of exported routes (to be used with ubox's list helpers).
struct xroute_list_entry {
struct list_head list;
struct xroute *xroute;
};
// List of received routes (to be used with ubox's list helpers).
struct route_list_entry {
struct list_head list;
struct babel_route *route;
};
// List of neighbours (to be used with ubox's list helpers).
struct neighbour_list_entry {
struct list_head list;
struct neighbour *neighbour;
};
// Definition of interface function enums (to be used with ubox's blobmsg
// helpers).
enum { INTERFACE_IFNAME, __INTERFACE_MAX };
// Definition of interface parsing (to be used with ubox's blobmsg helpers).
static const struct blobmsg_policy interface_policy[__INTERFACE_MAX] = {
[INTERFACE_IFNAME] = {"ifname", BLOBMSG_TYPE_STRING},
};
// Definition of filter function enums (to be used with ubox's blobmsg
// helpers).
enum { FILTER_IFNAME, FILTER_TYPE, FILTER_METRIC, __FILTER_MAX };
// Definition of filter parsing (to be used with ubox's blobmsg helpers).
static const struct blobmsg_policy filter_policy[__FILTER_MAX] = {
[FILTER_IFNAME] = {"ifname", BLOBMSG_TYPE_STRING},
[FILTER_TYPE] = {"type", BLOBMSG_TYPE_INT32},
[FILTER_METRIC] = {"metric", BLOBMSG_TYPE_INT32},
};
// Adds a filter (ubus equivalent to "filter"-function).
static int babeld_ubus_add_filter(struct ubus_context *ctx_local,
struct ubus_object *obj,
struct ubus_request_data *req,
const char *method, struct blob_attr *msg) {
struct blob_attr *tb[__FILTER_MAX];
struct blob_buf b = {0};
struct filter *filter = NULL;
char *ifname;
int metric, type;
blobmsg_parse(filter_policy, __FILTER_MAX, tb, blob_data(msg), blob_len(msg));
if (!tb[FILTER_IFNAME])
return UBUS_STATUS_INVALID_ARGUMENT;
if (!tb[FILTER_TYPE])
return UBUS_STATUS_INVALID_ARGUMENT;
type = blobmsg_get_u32(tb[FILTER_TYPE]);
if (tb[FILTER_METRIC])
metric = blobmsg_get_u32(tb[FILTER_METRIC]);
filter = calloc(1, sizeof(struct filter));
if (filter == NULL)
return UBUS_STATUS_UNKNOWN_ERROR;
filter->af = AF_INET6;
filter->proto = 0;
filter->plen_le = 128;
filter->src_plen_le = 128;
filter->action.add_metric = metric;
ifname = blobmsg_get_string(tb[FILTER_IFNAME]);
filter->ifname = strdup(ifname);
filter->ifindex = if_nametoindex(filter->ifname);
add_filter(filter, type);
return UBUS_STATUS_OK;
}
// Adds an inteface (ubus equivalent to "interface"-function).
static int babeld_ubus_add_interface(struct ubus_context *ctx_local,
struct ubus_object *obj,
struct ubus_request_data *req,
const char *method,
struct blob_attr *msg) {
struct blob_attr *tb[__INTERFACE_MAX];
struct blob_buf b = {0};
struct interface *ifp = NULL;
char *ifname;
blobmsg_parse(interface_policy, __INTERFACE_MAX, tb, blob_data(msg),
blob_len(msg));
if (!tb[INTERFACE_IFNAME])
return UBUS_STATUS_INVALID_ARGUMENT;
ifname = blobmsg_get_string(tb[INTERFACE_IFNAME]);
ifp = add_interface(ifname, NULL);
if (ifp == NULL)
return UBUS_STATUS_UNKNOWN_ERROR;
return UBUS_STATUS_OK;
}
// Sends a babel info message on ubus socket.
static int babeld_ubus_babeld_info(struct ubus_context *ctx_local,
struct ubus_object *obj,
struct ubus_request_data *req,
const char *method, struct blob_attr *msg) {
struct blob_buf b = {0};
void *prefix;
char host[64];
int ret;
blob_buf_init(&b, 0);
blobmsg_add_string(&b, "babeld-version", BABELD_VERSION);
blobmsg_add_string(&b, "my-id", format_eui64(myid));
if (!gethostname(host, sizeof(host)))
blobmsg_add_string(&b, "host", host);
ret = ubus_send_reply(ctx_local, req, b.head);
if (ret)
fprintf(stderr, "Failed to send reply: %s\n", ubus_strerror(ret));
blob_buf_free(&b);
return ret;
}
// Appends an exported route message entry to the buffer.
static void babeld_add_xroute_buf(struct xroute *xroute, struct blob_buf *b) {
void *prefix;
prefix = blobmsg_open_table(b, format_prefix(xroute->prefix, xroute->plen));
blobmsg_add_string(b, "src-prefix",
format_prefix(xroute->src_prefix, xroute->src_plen));
blobmsg_add_u32(b, "metric", xroute->metric);
blobmsg_close_table(b, prefix);
}
// Sends an exported routes message on ubus socket, splitting apart IPv4 and
// IPv6 routes.
static int babeld_ubus_get_xroutes(struct ubus_context *ctx_local,
struct ubus_object *obj,
struct ubus_request_data *req,
const char *method, struct blob_attr *msg) {
struct blob_buf b = {0};
struct xroute_stream *xroutes;
struct xroute_list_entry *cur, *tmp;
void *ipv4, *ipv6;
int ret;
LIST_HEAD(xroute_ipv4_list);
LIST_HEAD(xroute_ipv6_list);
blob_buf_init(&b, 0);
xroutes = xroute_stream();
if (xroutes) {
while (1) {
struct xroute *xroute = xroute_stream_next(xroutes);
if (xroute == NULL)
break;
struct xroute_list_entry *xr =
calloc(1, sizeof(struct xroute_list_entry));
xr->xroute = xroute;
if (v4mapped(xroute->prefix)) {
list_add(&xr->list, &xroute_ipv4_list);
} else {
list_add(&xr->list, &xroute_ipv6_list);
}
}
xroute_stream_done(xroutes);
}
ipv4 = blobmsg_open_table(&b, "IPv4");
list_for_each_entry_safe(cur, tmp, &xroute_ipv4_list, list) {
babeld_add_xroute_buf(cur->xroute, &b);
list_del(&cur->list);
free(cur);
}
blobmsg_close_table(&b, ipv4);
ipv6 = blobmsg_open_table(&b, "IPv6");
list_for_each_entry_safe(cur, tmp, &xroute_ipv6_list, list) {
babeld_add_xroute_buf(cur->xroute, &b);
list_del(&cur->list);
free(cur);
}
blobmsg_close_table(&b, ipv6);
ret = ubus_send_reply(ctx_local, req, b.head);
if (ret)
fprintf(stderr, "Failed to send reply: %s\n", ubus_strerror(ret));
blob_buf_free(&b);
return ret;
}
// Appends an route message entry to the buffer.
static void babeld_add_route_buf(struct babel_route *route,
struct blob_buf *b) {
void *prefix;
prefix = blobmsg_open_table(
b, format_prefix(route->src->prefix, route->src->plen));
blobmsg_add_string(
b, "src-prefix",
format_prefix(route->src->src_prefix, route->src->src_plen));
blobmsg_add_u32(b, "route_metric", route_metric(route));
blobmsg_add_u32(b, "route_smoothed_metric", route_smoothed_metric(route));
blobmsg_add_u32(b, "refmetric", route->refmetric);
blobmsg_add_string(b, "id", format_eui64(route->src->id));
blobmsg_add_u32(b, "seqno", (uint32_t)route->seqno);
blobmsg_add_u32(b, "age", (int)(now.tv_sec - route->time));
blobmsg_add_string(b, "via", format_address(route->neigh->address));
if (memcmp(route->nexthop, route->neigh->address, 16) != 0)
blobmsg_add_string(b, "nexthop", format_address(route->nexthop));
blobmsg_add_u8(b, "installed", route->installed);
blobmsg_add_u8(b, "feasible", route_feasible(route));
blobmsg_close_table(b, prefix);
}
// Sends received routes message on ubus socket, splitting apart IPv4 and IPv6
// routes.
static int babeld_ubus_get_routes(struct ubus_context *ctx_local,
struct ubus_object *obj,
struct ubus_request_data *req,
const char *method, struct blob_attr *msg) {
struct blob_buf b = {0};
struct route_stream *routes;
struct route_list_entry *cur, *tmp;
void *prefix, *ipv4, *ipv6;
int ret;
LIST_HEAD(route_ipv4_list);
LIST_HEAD(route_ipv6_list);
blob_buf_init(&b, 0);
routes = route_stream(0);
if (routes) {
while (1) {
struct babel_route *route = route_stream_next(routes);
if (route == NULL)
break;
struct route_list_entry *r = calloc(1, sizeof(struct route_list_entry));
r->route = route;
if (v4mapped(route->src->prefix)) {
list_add(&r->list, &route_ipv4_list);
} else {
list_add(&r->list, &route_ipv6_list);
}
}
route_stream_done(routes);
}
ipv4 = blobmsg_open_table(&b, "IPv4");
list_for_each_entry_safe(cur, tmp, &route_ipv4_list, list) {
babeld_add_route_buf(cur->route, &b);
list_del(&cur->list);
free(cur);
}
blobmsg_close_table(&b, ipv4);
ipv6 = blobmsg_open_table(&b, "IPv6");
list_for_each_entry_safe(cur, tmp, &route_ipv6_list, list) {
babeld_add_route_buf(cur->route, &b);
list_del(&cur->list);
free(cur);
}
blobmsg_close_table(&b, ipv6);
ret = ubus_send_reply(ctx_local, req, b.head);
if (ret)
fprintf(stderr, "Failed to send reply: %s\n", ubus_strerror(ret));
blob_buf_free(&b);
return ret;
}
// Appends an neighbour entry to the buffer.
static void babeld_add_neighbour_buf(struct neighbour *neigh,
struct blob_buf *b) {
void *neighbour;
neighbour = blobmsg_open_table(b, format_address(neigh->address));
blobmsg_add_string(b, "dev", neigh->ifp->name);
blobmsg_add_u32(b, "hello-reach", neigh->hello.reach);
blobmsg_add_u32(b, "uhello-reach", neigh->uhello.reach);
blobmsg_add_u32(b, "rxcost", neighbour_rxcost(neigh));
blobmsg_add_u32(b, "txcost", neigh->txcost);
blobmsg_add_string(b, "rtt", format_thousands(neigh->rtt));
blobmsg_add_u8(b, "if_up", if_up(neigh->ifp));
blobmsg_close_table(b, neighbour);
}
// Sends neighbours message on ubus socket, splitting apart IPv4 and IPv6
// neighbours.
static int babeld_ubus_get_neighbours(struct ubus_context *ctx_local,
struct ubus_object *obj,
struct ubus_request_data *req,
const char *method,
struct blob_attr *msg) {
struct blob_buf b = {0};
struct neighbour *neigh;
struct neighbour_list_entry *cur, *tmp;
void *ipv4, *ipv6;
int ret;
LIST_HEAD(neighbour_ipv4_list);
LIST_HEAD(neighbour_ipv6_list);
blob_buf_init(&b, 0);
FOR_ALL_NEIGHBOURS(neigh) {
struct neighbour_list_entry *n =
calloc(1, sizeof(struct neighbour_list_entry));
n->neighbour = neigh;
if (v4mapped(neigh->address)) {
list_add(&n->list, &neighbour_ipv4_list);
} else {
list_add(&n->list, &neighbour_ipv6_list);
}
}
ipv4 = blobmsg_open_table(&b, "IPv4");
list_for_each_entry_safe(cur, tmp, &neighbour_ipv4_list, list) {
babeld_add_neighbour_buf(cur->neighbour, &b);
list_del(&cur->list);
free(cur);
}
blobmsg_close_table(&b, ipv4);
ipv6 = blobmsg_open_table(&b, "IPv6");
list_for_each_entry_safe(cur, tmp, &neighbour_ipv6_list, list) {
babeld_add_neighbour_buf(cur->neighbour, &b);
list_del(&cur->list);
free(cur);
}
blobmsg_close_table(&b, ipv6);
ret = ubus_send_reply(ctx_local, req, b.head);
if (ret)
fprintf(stderr, "Failed to send reply: %s\n", ubus_strerror(ret));
blob_buf_free(&b);
return ret;
}
// List of functions we expose via the ubus bus.
static const struct ubus_method babeld_methods[] = {
UBUS_METHOD("add_interface", babeld_ubus_add_interface, interface_policy),
UBUS_METHOD("add_filter", babeld_ubus_add_filter, filter_policy),
UBUS_METHOD_NOARG("get_info", babeld_ubus_babeld_info),
UBUS_METHOD_NOARG("get_xroutes", babeld_ubus_get_xroutes),
UBUS_METHOD_NOARG("get_routes", babeld_ubus_get_routes),
UBUS_METHOD_NOARG("get_neighbours", babeld_ubus_get_neighbours),
};
// Definition of the ubus object type.
static struct ubus_object_type babeld_object_type =
UBUS_OBJECT_TYPE("babeld", babeld_methods);
// Object we announce via the ubus bus.
static struct ubus_object babeld_object = {
.name = "babeld",
.type = &babeld_object_type,
.methods = babeld_methods,
.n_methods = ARRAY_SIZE(babeld_methods),
};
// Registers handlers for babel methods in the global ubus context.
static bool ubus_init_object() {
int ret;
ret = ubus_add_object(shared_ctx, &babeld_object);
if (ret) {
fprintf(stderr, "Failed to add object: %s\n", ubus_strerror(ret));
return false;
}
return true;
}
// Initializes the global ubus context, connecting to the bus to be able to
// receive and send messages.
static bool babeld_ubus_init(void) {
if (shared_ctx)
return true;
shared_ctx = ubus_connect(NULL);
if (!shared_ctx)
return false;
return true;
}
void ubus_notify_route(struct babel_route *route, int kind) {
struct blob_buf b = {0};
char method[50]; // possible methods are route.change, route.add, route.flush
if (!babeld_object.has_subscribers)
return;
if (!route)
return;
if (!shared_ctx)
return;
blob_buf_init(&b, 0);
babeld_add_route_buf(route, &b);
snprintf(method, sizeof(method), "route.%s", local_kind(kind));
ubus_notify(shared_ctx, &babeld_object, method, b.head, -1);
blob_buf_free(&b);
}
void ubus_notify_xroute(struct xroute *xroute, int kind) {
struct blob_buf b = {0};
char method[50]; // possible methods are xroute.change, xroute.add,
// xroute.flush
if (!babeld_object.has_subscribers)
return;
if (!xroute)
return;
if (!shared_ctx)
return;
blob_buf_init(&b, 0);
babeld_add_xroute_buf(xroute, &b);
snprintf(method, sizeof(method), "xroute.%s", local_kind(kind));
ubus_notify(shared_ctx, &babeld_object, method, b.head, -1);
blob_buf_free(&b);
}
void ubus_notify_neighbour(struct neighbour *neigh, int kind) {
struct blob_buf b = {0};
char method[50]; // possible methods are neigh.change, neigh.add, neigh.flush
if (!babeld_object.has_subscribers)
return;
if (!neigh)
return;
if (!shared_ctx)
return;
blob_buf_init(&b, 0);
babeld_add_neighbour_buf(neigh, &b);
snprintf(method, sizeof(method), "neigh.%s", local_kind(kind));
ubus_notify(shared_ctx, &babeld_object, method, b.head, -1);
blob_buf_free(&b);
}
void babeld_ubus_receive(fd_set *readfds) {
if (!shared_ctx)
return;
if (FD_ISSET(shared_ctx->sock.fd, readfds))
ubus_handle_event(shared_ctx);
}
int babeld_ubus_add_read_sock(fd_set *readfds, int maxfd) {
if (!shared_ctx)
return maxfd;
FD_SET(shared_ctx->sock.fd, readfds);
return MAX(maxfd, shared_ctx->sock.fd);
}
bool babeld_add_ubus() {
if (!babeld_ubus_init()) {
fprintf(stderr, "Failed to initialize ubus!\n");
return false;
}
if (!ubus_init_object()) {
fprintf(stderr, "Failed to add objects to ubus!\n");
return false;
}
return true;
}

View file

@ -1,99 +0,0 @@
/*
IPC integration of babeld with OpenWrt.
The ubus interface offers following functions:
- add_filter '{"ifname":"eth0", "type":0, "metric":5000}'
type:
0: FILTER_TYPE_INPUT
1: FILTER_TYPE_OUTPUT
2: FILTER_TYPE_REDISTRIBUTE
3: FILTER_TYPE_INSTALL
- add_interface '{"ifname":"eth0"}'
- get_info
- get_neighbours
- get_xroutes
- get_routes
All output is divided into IPv4 and IPv6.
Ubus notifications are sent if we receive updates for
- xroutes
- routes
- neighbours
The format is:
- {route,xroute,neighbour}.add: Object was added
- {route,xroute,neighbour}.change: Object was changed
- {route,xroute,neighbour}.flush: Object was flushed
*/
#include <stdbool.h>
#include <sys/select.h>
struct babel_route;
struct neighbour;
struct xroute;
// Whether to enable ubus bindings (boolean option).
extern int ubus_bindings;
/**
* Initialize ubus interface.
*
* Connect to the ubus daemon and expose the ubus functions.
*
* @return if initializing ubus was successful
*/
bool babeld_add_ubus();
/**
* Add ubus socket to given filedescriptor set.
*
* We need to check repeatedly if the ubus socket has something to read.
* The functions allows to add the ubus socket to the normal while(1)-loop of
* babeld.
*
* @param readfs: the filedescriptor set
* @param maxfd: the current maximum file descriptor
* @return the maximum file descriptor
*/
int babeld_ubus_add_read_sock(fd_set *readfds, int maxfd);
/**
* Check and process ubus socket.
*
* If the ubus-socket signals that data is available, the ubus_handle_event is
* called.
*/
void babeld_ubus_receive(fd_set *readfds);
/***
* Notify the ubus bus that a new xroute is received.
*
* If a new xroute is received or changed, we will notify subscribers.
*
* @param xroute: xroute that experienced some change
* @param kind: kind that describes if we have a flush, add or change
*/
void ubus_notify_xroute(struct xroute *xroute, int kind);
/***
* Notify the ubus bus that a new route is received.
*
* If a new route is received or changed, we will notify subscribers.
*
* @param route: route that experienced some change
* @param kind: kind that describes if we have a flush, add or change
*/
void ubus_notify_route(struct babel_route *route, int kind);
/***
* Notify the ubus bus that a new neighbour is received.
*
* If a new neighbour is received or changed, we will notify subscribers.
*
* @param neigh: neighbour that experienced some change
* @param kind: kind that describes if we have a flush, add or change
*/
void ubus_notify_neighbour(struct neighbour *neigh, int kind);

68
babels/Makefile Normal file
View file

@ -0,0 +1,68 @@
#
# Copyright (C) 2007-2009 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=babels
PKG_SOURCE_VERSION:=bc5d60e58e7ebd1694cef23d798df08b3b8f216f
PKG_VERSION:=2014-07-04-$(PKG_SOURCE_VERSION)
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/boutier/babeld.git
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
define Package/babels
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
TITLE:=A loop-free distance-vector routing protocol (source-specific)
URL:=http://www.pps.univ-paris-diderot.fr/~jch/software/babel/
MAINTAINER:=Steven Barth <cyrus@openwrt.org>
DEPENDS:=+kmod-ipv6
endef
define Package/babels/description
Babel is a loop-avoiding distance-vector routing protocol roughly based
on DSDV and AODV, but with provisions for link cost estimation and
redistribution of routes from other routing protocols.
While it is optimised for wireless mesh networks, Babel will also work
efficiently on wired networks. It will generate between 1.2 and 2.4 times
the amount of routing traffic that RIPng would generate, while
never counting to infinity.
This is experimental source routing branch, and should be only used if you
know what you are doing.
endef
define Package/babels/conffiles
/etc/babeld.conf
/etc/config/babeld
endef
MAKE_FLAGS+= \
CFLAGS="$(TARGET_CFLAGS) -DIPV6_SUBTREES" \
LDLIBS="" \
define Package/babels/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/babeld $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/etc
$(INSTALL_CONF) ./files/babeld.conf $(1)/etc/
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/babeld.config $(1)/etc/config/babeld
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/babeld.init $(1)/etc/init.d/babeld
endef
define Build/Compile
echo "#define BABEL_VERSION \"$(PKG_SOURCE_SUBDIR)\"" > $(PKG_BUILD_DIR)/version.h
$(call Build/Compile/Default)
endef
$(eval $(call BuildPackage,babels))

38
babels/files/babeld.conf Normal file
View file

@ -0,0 +1,38 @@
# babel config file
#
# This config file simply documents sample entries.
# "redistribute" means: redistribute routes from other routing protocols
# into babel. "local" means addresses assigned to local interfaces.
#
# You do not need to edit this file: you can use /etc/config/babeld
# instead (sections "interface" and "filter"). Both files can be used
# simultaneously (the rules of this file are executed first).
# the default rules are:
#
## redistribute local
## redistribute deny
#
# this says, redistribute local addresses but no other routes
# redistribute IPv4 default route into babel
## redistribute local ip 0.0.0.0/0 le 0 metric 128
# same but for IPv6
## redistribute local ip ::/0 le 0 metric 128
# don't redistribute all local addresses, only selected ones
# after the first line, the "deny" rules kicks in. After the "deny"
# no redistribute local rules are going to match
## redistribute local ip 192.160.4.0/24
## redistribute local deny
# Babel refuses to redistribute routes with a protocol number of "boot";
# this is standard practice, and means that you cannot easily
# redistribute the default route installed by dhcp. It is however
# possible to redistribute such route by explicitly specifying "proto 3"
# on the redistribute line.
## redistribute ip 0.0.0.0/0 le 0 proto 3 metric 128

View file

@ -0,0 +1,72 @@
package babeld
config general
# option 'multicast_address' 'ff02:0:0:0:0:0:1:6'
# option 'port' '6696'
# option 'state_file' '/var/lib/babel-state'
# option 'hello_interval' '4'
# option 'wired_hello_interval' '20'
# option 'diversity' '0,128'
# option 'smoothing_half_time' '4'
# option 'kernel_priority' '0'
# Do not use this option unless you know what you are doing, as it can
# cause persistent route flapping.
## option 'duplication_priority' '0'
# option 'carrier_sense' 'false'
# option 'assume_wireless' 'false'
# option 'no_split_horizon' 'false'
# option 'debug' '0'
# Listen for connections from a front-end, e.g. on port 33123.
## option 'local_server' '33123'
# option 'random_router_id' 'false'
# Keep unfeasible routes
## option 'keep_unfeasible' 'false'
# Use the given kernel routing table for routes inserted by babeld.
## option 'export_table' '0'
# Export routes from the given kernel routing tables.
## list 'import_table' '0'
## list 'import_table' '42'
# The configuration file is not necessary since you can do everything
# from this file.
# option 'conf_file' '/etc/babeld.conf'
# option 'log_file' '/var/log/babeld.log'
# You can use aliases (like lan, wlan) or real names (like eth0.0).
# If you use an alias, it must be already defined when babeld starts.
# Otherwise, the name is taken literally and the interface can be
# brought up later (useful for tunnels for instance).
config interface wlan
# Remove this line to enable babeld on this interface
option 'ignore' 'true'
# option 'wired' 'auto'
# option 'link_quality' 'auto'
# option 'split_horizon' 'auto'
# The default is 96 for wired interfaces, and 256 for wireless ones
## option 'rxcost' '256'
# The default is specified with the -h and -H command-line flags.
## option 'hello_interval' '4'
# This can be set to a fairly large value, unless significant
# packet loss is expected. The default is four times the hello
# interval.
## option 'update_interval' '16'
config interface lan
option 'ignore' 'true'
# A filter consists in a type ('in', 'out' or 'redistribute'), an action
# ('allow', 'deny' or 'metric xxx') and a set of selectors ('ip', 'eq',
# etc.). See /etc/babeld.conf for more details.
# Here is a sample filter wich redistributes the default route if its
# protocol number is "boot", e.g. when it installed by dhcp. It is
# disabled by default.
config filter
option 'ignore' 'true'
# Type
option 'type' 'redistribute'
# Selectors: ip, eq, le, ge, neigh, id, proto, local, if
option 'ip' '0.0.0.0/0'
option 'le' '0'
option 'proto' '3'
# Action
option 'action' 'metric 128'

154
babels/files/babeld.init Executable file
View file

@ -0,0 +1,154 @@
#!/bin/sh /etc/rc.common
START=70
pidfile='/var/run/babeld.pid'
EXTRA_COMMANDS="status"
EXTRA_HELP=" status Dump Babel's table to the log file."
listen_ifname() {
local ifname=$(uci_get_state network "$1" ifname "$1")
local switch="$2"
append args "$switch $ifname"
append interfaces "$ifname"
}
append_ifname() {
local section="$1"
local option="$2"
local switch="$3"
local _name
config_get _name "$section" "$option"
[ -z "$_name" ] && return 0
local ifname=$(uci_get_state network "$_name" ifname "$_name")
append args "$switch $ifname"
}
append_bool() {
local section="$1"
local option="$2"
local value="$3"
local _loctmp
config_get_bool _loctmp "$section" "$option" 0
[ "$_loctmp" -gt 0 ] && append args "$value"
}
append_switch() {
local value="$1"
local switch="$2"
append args "$switch $value"
}
append_parm() {
local section="$1"
local option="$2"
local switch="$3"
local _loctmp
config_get _loctmp "$section" "$option"
[ -z "$_loctmp" ] && return 0
append args "$switch $_loctmp"
}
babel_filter() {
local cfg="$1"
local _loctmp
local _ignored
config_get_bool _ignored "$cfg" 'ignore' 0
[ "$_ignored" -eq 1 ] && return 0
append args "-C '"
append_parm "$cfg" 'type' ''
append_bool "$cfg" 'local' 'local'
append_parm "$cfg" 'ip' 'ip'
append_parm "$cfg" 'eq' 'eq'
append_parm "$cfg" 'le' 'le'
append_parm "$cfg" 'ge' 'ge'
append_parm "$cfg" 'src_ip' 'src-ip'
append_parm "$cfg" 'src_eq' 'src-eq'
append_parm "$cfg" 'src_le' 'src-le'
append_parm "$cfg" 'src_ge' 'src-ge'
append_parm "$cfg" 'neigh' 'neigh'
append_parm "$cfg" 'id' 'id'
append_parm "$cfg" 'proto' 'proto'
append_ifname "$cfg" 'if' 'if'
append_parm "$cfg" 'action' ''
append args ' ' "'"
}
babel_addif() {
local cfg="$1"
local _ignored
config_get_bool _ignored "$cfg" 'ignore' 0
[ "$_ignored" -eq 1 ] && return 0
listen_ifname "$cfg" "-C 'interface"
append_parm "$cfg" 'wired' 'wired'
append_parm "$cfg" 'link_quality' 'link-quality'
append_parm "$cfg" 'split_horizon' 'split-horizon'
append_parm "$cfg" 'rxcost' 'rxcost'
append_parm "$cfg" 'hello_interval' 'hello-interval'
append_parm "$cfg" 'update_interval' 'update-interval'
append args ' ' "'"
}
babel_config() {
local cfg="$1"
append_bool "$cfg" 'carrier_sense' '-l'
append_bool "$cfg" 'assume_wireless' '-w'
append_bool "$cfg" 'no_split_horizon' '-s'
append_bool "$cfg" 'keep_unfeasible' '-u'
append_bool "$cfg" 'random_router_id' '-r'
append_parm "$cfg" 'multicast_address' '-m'
append_parm "$cfg" 'port' '-p'
append_parm "$cfg" 'state_file' '-S'
append_parm "$cfg" 'hello_interval' '-h'
append_parm "$cfg" 'wired_hello_interval' '-H'
append_parm "$cfg" 'diversity' '-z'
append_parm "$cfg" 'smoothing_half_time' '-M'
append_parm "$cfg" 'kernel_priority' '-k'
append_parm "$cfg" 'duplication_priority' '-A'
append_parm "$cfg" 'debug' '-d'
append_parm "$cfg" 'local_server' '-g'
append_parm "$cfg" 'export_table' '-t'
config_list_foreach "$cfg" 'import_table' append_switch '-T'
append_parm "$cfg" 'conf_file' '-c'
append_parm "$cfg" 'log_file' '-L'
}
start() {
mkdir -p /var/lib
config_load babeld
unset args
unset interfaces
config_foreach babel_config general
config_foreach babel_addif interface
config_foreach babel_filter filter
[ -z "$interfaces" ] && return 0
eval "/usr/sbin/babeld -D -I $pidfile $args $interfaces"
}
stop() {
[ -f "$pidfile" ] && kill $(cat $pidfile)
# avoid race-condition on restart: wait for
# babeld to die for real.
[ -f "$pidfile" ] && sleep 1
[ -f "$pidfile" ] && sleep 1
[ -f "$pidfile" ] && sleep 1
[ -f "$pidfile" ] && exit 42
}
status() {
[ -f "$pidfile" ] && kill -USR1 $(cat $pidfile)
}

View file

@ -0,0 +1,103 @@
From 3fdbb1f797ee9fe9260af92f5d7ea760684cd271 Mon Sep 17 00:00:00 2001
From: Steven Barth <steven@midlink.org>
Date: Tue, 18 Feb 2014 13:18:32 +0100
Subject: [PATCH] Allow routes with source ::/128 for SAS on Linux
Linux uses the source-address :: (unspecified) to lookup routes in the
routing table for connections that are not bound to a specific source
address (e.g. ping6 2001:db8::1). If all default routes are
source-restricted a command like above will result in a "Permission
denied" error and no packets are being sent. Adding a default route with
source ::/128 avoids this issue.
This patch excludes ::/128 from the "martian_prefix" check for source
prefixes and thus allows such auxiliary routes to be distributed.
Signed-off-by: Steven Barth <cyrus@openwrt.org>
---
kernel_netlink.c | 4 ++--
route.c | 4 ++--
util.c | 4 ++--
util.h | 2 +-
xroute.c | 2 +-
5 files changed, 8 insertions(+), 8 deletions(-)
--- a/kernel_netlink.c
+++ b/kernel_netlink.c
@@ -1242,8 +1242,8 @@ filter_kernel_routes(struct nlmsghdr *nh
if(rc < 0)
return 0;
- if(martian_prefix(current_route->prefix, current_route->plen) ||
- martian_prefix(current_route->src_prefix, current_route->src_plen))
+ if(martian_prefix(current_route->prefix, current_route->plen, 0) ||
+ martian_prefix(current_route->src_prefix, current_route->src_plen, 1))
return 0;
/* Ignore default unreachable routes; no idea where they come from. */
@@ -1944,7 +1944,7 @@ filter_kernel_rules(struct nlmsghdr *nh,
kdebugf("filter_rules: from %s prio %d table %d\n",
format_prefix(src, src_plen), priority, table);
- if(martian_prefix(src, src_plen) || !has_priority)
+ if(martian_prefix(src, src_plen, 1) || !has_priority)
return 0;
i = priority - src_table_prio;
--- a/route.c
+++ b/route.c
@@ -901,12 +901,12 @@ update_route(const unsigned char *id,
if(memcmp(id, myid, 8) == 0)
return NULL;
- if(martian_prefix(prefix, plen)) {
+ if(martian_prefix(prefix, plen, 0)) {
fprintf(stderr, "Rejecting martian route to %s through %s.\n",
format_prefix(prefix, plen), format_address(nexthop));
return NULL;
}
- if(src_plen != 0 && martian_prefix(src_prefix, src_plen)) {
+ if(src_plen != 0 && martian_prefix(src_prefix, src_plen, 1)) {
fprintf(stderr, "Rejecting martian route to %s from %s through %s.\n",
format_prefix(prefix, plen),
format_prefix(src_prefix, src_plen), format_eui64(id));
--- a/util.c
+++ b/util.c
@@ -437,13 +437,13 @@ wait_for_fd(int direction, int fd, int m
}
int
-martian_prefix(const unsigned char *prefix, int plen)
+martian_prefix(const unsigned char *prefix, int plen, int is_source)
{
return
(plen >= 8 && prefix[0] == 0xFF) ||
(plen >= 10 && prefix[0] == 0xFE && (prefix[1] & 0xC0) == 0x80) ||
(plen >= 128 && memcmp(prefix, zeroes, 15) == 0 &&
- (prefix[15] == 0 || prefix[15] == 1)) ||
+ ((prefix[15] == 0 && !is_source) || prefix[15] == 1)) ||
(plen >= 96 && v4mapped(prefix) &&
((plen >= 104 && (prefix[12] == 127 || prefix[12] == 0)) ||
(plen >= 100 && (prefix[12] & 0xE0) == 0xE0)));
--- a/util.h
+++ b/util.h
@@ -106,7 +106,7 @@ int parse_net(const char *net, unsigned
int *af_r);
int parse_eui64(const char *eui, unsigned char *eui_r);
int wait_for_fd(int direction, int fd, int msecs);
-int martian_prefix(const unsigned char *prefix, int plen) ATTRIBUTE ((pure));
+int martian_prefix(const unsigned char *prefix, int plen, int is_source) ATTRIBUTE ((pure));
int linklocal(const unsigned char *address) ATTRIBUTE ((pure));
int v4mapped(const unsigned char *address) ATTRIBUTE ((pure));
void v4tov6(unsigned char *dst, const unsigned char *src);
--- a/xroute.c
+++ b/xroute.c
@@ -266,7 +266,7 @@ check_xroutes(int send_updates)
/* Add any new routes */
for(i = 0; i < numroutes; i++) {
- if(martian_prefix(routes[i].prefix, routes[i].plen))
+ if(martian_prefix(routes[i].prefix, routes[i].plen, 0))
continue;
metric = redistribute_filter(routes[i].prefix, routes[i].plen,
routes[i].src_prefix, routes[i].src_plen,

View file

@ -1,248 +1,79 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2014 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=batctl
PKG_VERSION:=2024.0
PKG_VERSION:=2014.2.0
PKG_RELEASE:=1
PKG_MD5SUM:=c196cf95b7324d9123b701a56b06b31d
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
PKG_HASH:=76853e87201af63c411db152fd0c625a729a9733115897d1331604e2c5a67c7d
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_URL:=http://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
PKG_MAINTAINER:=Simon Wunderlich <sw@simonwunderlich.de>
PKG_LICENSE:=GPL-2.0-only ISC MIT
PKG_LICENSE_FILES:=LICENSES/preferred/GPL-2.0 LICENSES/preferred/MIT LICENSES/deprecated/ISC
PKG_BUILD_PARALLEL:=1
PKG_BUILD_FLAGS:=gc-sections lto
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/$(PKG_NAME)-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
define Package/batctl/Default
define Package/batctl
URL:=http://www.open-mesh.org/
SECTION:=net
CATEGORY:=Network
URL:=https://www.open-mesh.org/
DEPENDS:=+libnl-tiny +libc +librt
PROVIDES:=batctl
DEPENDS:=+kmod-batman-adv +libnl-tiny +libc
TITLE:=B.A.T.M.A.N. Advanced user space configuration tool batctl
MAINTAINER:=Marek Lindner <mareklindner@neomailbox.ch>
endef
define Package/batctl/description
batctl is a more intuitive managment utility for B.A.T.M.A.N.-Advanced.
It is an easier method for configuring batman-adv and provides some
additional tools for debugging as well. This package builds
version $(PKG_VERSION) of the user space utility.
batctl is a more intuitive managment utility for B.A.T.M.A.N.-Advanced.
It is an easier method for configuring batman-adv and provides some
additional tools for debugging as well. This package builds
version $(PKG_VERSION) of the user space utility.
endef
define Package/batctl-tiny
$(call Package/batctl/Default)
TITLE:=B.A.T.M.A.N. Advanced user space configuration tool (Minimal)
VARIANT:=tiny
ALTERNATIVES:=100:/usr/sbin/batctl:/usr/libexec/batctl-tiny
# The linker can identify unused sections of a binary when each symbol is stored
# in a separate section. This mostly removes unused linker sections and reduces
# the size by ~3% on mipsel.
TARGET_CFLAGS += -ffunction-sections -fdata-sections
TARGET_LDFLAGS += -Wl,--gc-sections
# Link-time optimization allows to move parts of the optimization from the single
# source file to the global source view. This is done by emitting the GIMPLE
# representation in each object file and analyzing it again during the link step.
TARGET_CFLAGS += -flto
TARGET_LDFLAGS += -fuse-linker-plugin
MAKE_BATCTL_ENV += \
CPPFLAGS="$(TARGET_CPPFLAGS)" \
CFLAGS="$(TARGET_CFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS)" \
LIBNL_NAME="libnl-tiny"
MAKE_BATCTL_ARGS += \
REVISION="$(PKG_BATCTL_SHORTREV)" \
CC="$(TARGET_CC)" \
DESTDIR="$(PKG_INSTALL_DIR)" \
batctl install
define Build/Compile
$(MAKE_BATCTL_ENV) $(MAKE) -C "$(PKG_BUILD_DIR)" $(MAKE_BATCTL_ARGS)
endef
define Package/batctl-tiny/description
$(Package/batctl/description)
Only configuration relevant subcommands are enabled.
define Build/Clean
rm -rf $(BUILD_DIR)/$(PKG_NAME)/
endef
define Package/batctl-default
$(call Package/batctl/Default)
TITLE:=B.A.T.M.A.N. Advanced user space configuration tool (Default)
VARIANT:=default
ALTERNATIVES:=200:/usr/sbin/batctl:/usr/libexec/batctl-default
define Package/batctl/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/batctl $(1)/usr/sbin/
endef
define Package/batctl-default/description
$(Package/batctl/description)
Standard subcommands for configuration and online debugging are enabled.
endef
define Package/batctl-full
$(call Package/batctl/Default)
TITLE:=B.A.T.M.A.N. Advanced user space configuration tool (Full)
VARIANT:=full
ALTERNATIVES:=300:/usr/sbin/batctl:/usr/libexec/batctl-full
endef
define Package/batctl-full/description
$(Package/batctl/description)
Subcommands for configuration, online and offline debugging are enabled.
endef
MAKE_VARS += \
LIBNL_NAME="libnl-tiny" \
LIBNL_GENL_NAME="libnl-tiny"
MAKE_FLAGS += \
REVISION="$(PKG_VERSION)-openwrt-$(PKG_RELEASE)"
config-n := \
aggregation \
ap_isolation \
backbonetable \
bisect_iv \
bonding \
bla_backbone_json \
bla_claim_json \
bridge_loop_avoidance \
claimtable \
dat_cache \
dat_cache_json \
distributed_arp_table \
elp_interval \
event \
fragmentation \
gateways \
gateways_json \
gw_mode \
hardif_json \
hardifs_json \
hop_penalty \
interface \
isolation_mark \
loglevel \
mcast_flags \
mcast_flags_json \
mesh_json \
multicast_fanout \
multicast_forceflood \
multicast_mode \
neighbors \
neighbors_json \
network_coding \
orig_interval \
originators \
originators_json \
ping \
routing_algo \
statistics \
tcpdump \
throughput_override \
throughputmeter \
traceroute \
transglobal \
translate \
translocal \
transtable_global_json \
transtable_local_json \
vlan_json \
config-settings := \
aggregation \
ap_isolation \
bonding \
bridge_loop_avoidance \
distributed_arp_table \
elp_interval \
fragmentation \
gw_mode \
hop_penalty \
interface \
isolation_mark \
loglevel \
multicast_fanout \
multicast_forceflood \
multicast_mode \
network_coding \
orig_interval \
routing_algo \
throughput_override \
config-tables := \
backbonetable \
claimtable \
dat_cache \
gateways \
mcast_flags \
neighbors \
originators \
statistics \
transglobal \
translocal \
config-json := \
bla_backbone_json \
bla_claim_json \
dat_cache_json \
gateways_json \
hardif_json \
hardifs_json \
mcast_flags_json \
mesh_json \
neighbors_json \
originators_json \
transtable_global_json \
transtable_local_json \
vlan_json \
config-tools := \
event \
ping \
tcpdump \
throughputmeter \
traceroute \
translate \
config-extratools := \
bisect_iv \
ifeq ($(BUILD_VARIANT),tiny)
config-y := \
$(config-settings) \
endif
ifeq ($(BUILD_VARIANT),default)
config-y := \
$(config-settings) \
$(config-tables) \
$(config-json) \
$(config-tools) \
endif
ifeq ($(BUILD_VARIANT),full)
config-y := \
$(config-settings) \
$(config-tables) \
$(config-json) \
$(config-tools) \
$(config-extratools) \
endif
define ConfigVars
$(subst $(space),,$(foreach opt,$(config-$(1)),CONFIG_$(opt)=$(1)
))
endef
define batctl_config
$(call ConfigVars,n)$(call ConfigVars,y)
endef
$(eval $(call shexport,batctl_config))
MAKE_FLAGS += $$$$$(call shvar,batctl_config)
define Package/batctl-tiny/install
$(INSTALL_DIR) $(1)/usr/libexec
$(INSTALL_BIN) $(PKG_BUILD_DIR)/batctl $(1)/usr/libexec/batctl-tiny
endef
define Package/batctl-default/install
$(INSTALL_DIR) $(1)/usr/libexec
$(INSTALL_BIN) $(PKG_BUILD_DIR)/batctl $(1)/usr/libexec/batctl-default
endef
define Package/batctl-full/install
$(INSTALL_DIR) $(1)/usr/libexec
$(INSTALL_BIN) $(PKG_BUILD_DIR)/batctl $(1)/usr/libexec/batctl-full
endef
$(eval $(call BuildPackage,batctl-default))
$(eval $(call BuildPackage,batctl-tiny))
$(eval $(call BuildPackage,batctl-full))
$(eval $(call BuildPackage,batctl))

View file

@ -1,88 +1,26 @@
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2007-2019 B.A.T.M.A.N. contributors:
#
# Marek Lindner, Simon Wunderlich
#
# B.A.T.M.A.N meshing protocol
#
config KMOD_BATMAN_ADV_DEBUG_LOG
bool "enable verbose debug logging"
depends on PACKAGE_kmod-batman-adv
default n
config BATMAN_ADV_BATMAN_V
bool "B.A.T.M.A.N. V protocol"
config KMOD_BATMAN_ADV_BLA
bool "enable bridge loop avoidance"
depends on PACKAGE_kmod-batman-adv
default y
help
This option enables the B.A.T.M.A.N. V protocol, the successor
of the currently used B.A.T.M.A.N. IV protocol. The main
changes include splitting of the OGM protocol into a neighbor
discovery protocol (Echo Location Protocol, ELP) and a new OGM
Protocol OGMv2 for flooding protocol information through the
network, as well as a throughput based metric.
B.A.T.M.A.N. V is currently considered experimental and not
compatible to B.A.T.M.A.N. IV networks.
config BATMAN_ADV_BLA
bool "Bridge Loop Avoidance"
depends on PACKAGE_kmod-batman-adv
select PACKAGE_kmod-lib-crc16
default y
help
This option enables BLA (Bridge Loop Avoidance), a mechanism
to avoid Ethernet frames looping when mesh nodes are connected
to both the same LAN and the same mesh. If you will never use
more than one mesh node in the same LAN, you can safely remove
this feature and save some space.
config BATMAN_ADV_DAT
bool "Distributed ARP Table"
config KMOD_BATMAN_ADV_DAT
bool "enable distributed arp table"
depends on PACKAGE_kmod-batman-adv
default y
help
This option enables DAT (Distributed ARP Table), a DHT based
mechanism that increases ARP reliability on sparse wireless
mesh networks. If you think that your network does not need
this option you can safely remove it and save some space.
config BATMAN_ADV_NC
bool "Network Coding"
depends on PACKAGE_kmod-batman-adv
help
This option enables network coding, a mechanism that aims to
increase the overall network throughput by fusing multiple
packets in one transmission.
Note that interfaces controlled by batman-adv must be manually
configured to have promiscuous mode enabled in order to make
network coding work.
If you think that your network does not need this feature you
can safely disable it and save some space.
config BATMAN_ADV_MCAST
bool "Multicast optimisation"
config KMOD_BATMAN_ADV_MCAST
bool "enable multicast transmission optimization"
depends on PACKAGE_kmod-batman-adv
default y
help
This option enables the multicast optimisation which aims to
reduce the air overhead while improving the reliability of
multicast messages.
config BATMAN_ADV_DEBUG
bool "B.A.T.M.A.N. debugging"
config KMOD_BATMAN_ADV_NC
bool "enable network coding [requires promisc mode support]"
depends on PACKAGE_kmod-batman-adv
help
This is an option for use by developers; most people should
say N here. This enables compilation of support for
outputting debugging information to the debugfs log or tracing
buffer. The output is controlled via the batadv netdev specific
log_level setting.
default n
config BATMAN_ADV_TRACING
bool "B.A.T.M.A.N. tracing support"
depends on PACKAGE_kmod-batman-adv
select KERNEL_FTRACE
select KERNEL_ENABLE_DEFAULT_TRACERS
help
This is an option for use by developers; most people should
say N here. Select this option to gather traces like the debug
messages using the generic tracing infrastructure of the kernel.
BATMAN_ADV_DEBUG must also be selected to get trace events for
batadv_dbg.

View file

@ -1,101 +1,83 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2010 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id: Makefile 5624 2006-11-23 00:29:07Z nbd $
include $(TOPDIR)/rules.mk
PKG_NAME:=batman-adv
PKG_VERSION:=2024.0
PKG_RELEASE:=2
PKG_VERSION:=2014.2.0
PKG_RELEASE:=1
PKG_MD5SUM:=1243029b3a3e2f4fa721d1a59c2faaf5
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
PKG_HASH:=61110697b5799f646a2a82a4dcf97faed4bb12a7cc43bf4683d2c4de4f6b40e7
PKG_EXTMOD_SUBDIRS:=net/batman-adv
PKG_SOURCE_URL:=http://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
PKG_MAINTAINER:=Simon Wunderlich <sw@simonwunderlich.de>
PKG_LICENSE:=GPL-2.0-only MIT
PKG_LICENSE_FILES:=LICENSES/preferred/GPL-2.0 LICENSES/preferred/MIT
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/$(PKG_NAME)-$(PKG_VERSION)
PKG_BUILD_PARALLEL:=1
STAMP_CONFIGURED_DEPENDS := $(STAGING_DIR)/usr/include/mac80211-backport/backport/autoconf.h
PKG_CONFIG_DEPENDS += \
CONFIG_BATMAN_ADV_BATMAN_V \
CONFIG_BATMAN_ADV_BLA \
CONFIG_BATMAN_ADV_DAT \
CONFIG_BATMAN_ADV_NC \
CONFIG_BATMAN_ADV_MCAST \
CONFIG_BATMAN_ADV_DEBUG \
CONFIG_BATMAN_ADV_TRACING
include $(INCLUDE_DIR)/kernel.mk
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/kernel.mk
define KernelPackage/batman-adv
URL:=http://www.open-mesh.org/
MAINTAINER:=Marek Lindner <mareklindner@neomailbox.ch>
SUBMENU:=Network Support
DEPENDS:=+KMOD_BATMAN_ADV_BLA:kmod-lib-crc16 +kmod-crypto-core +kmod-crypto-crc32c +kmod-lib-crc32c
TITLE:=B.A.T.M.A.N. Adv
URL:=https://www.open-mesh.org/
DEPENDS:=+BATMAN_ADV_BLA:kmod-lib-crc16 +kmod-lib-crc32c +kmod-cfg80211 +batctl
FILES:=$(PKG_BUILD_DIR)/net/batman-adv/batman-adv.$(LINUX_KMOD_SUFFIX)
AUTOLOAD:=$(call AutoProbe,batman-adv)
FILES:=$(PKG_BUILD_DIR)/batman-adv.$(LINUX_KMOD_SUFFIX)
AUTOLOAD:=$(call AutoLoad,50,batman-adv)
endef
define KernelPackage/batman-adv/description
B.A.T.M.A.N. (better approach to mobile ad-hoc networking) is
a routing protocol for multi-hop ad-hoc mesh networks. The
networks may be wired or wireless. See
https://www.open-mesh.org/ for more information and user space
tools. This package builds version $(PKG_VERSION) of the kernel
module.
B.A.T.M.A.N. advanced is a kernel module which allows to
build layer 2 mesh networks. This package builds
version $(PKG_VERSION) of the kernel module.
endef
define KernelPackage/batman-adv/config
source "$(SOURCE)/Config.in"
endef
define Package/kmod-batman-adv/conffiles
/etc/config/batman-adv
MAKE_BATMAN_ADV_ARGS += \
CROSS_COMPILE="$(TARGET_CROSS)" \
KERNELPATH="$(LINUX_DIR)" \
ARCH="$(LINUX_KARCH)" \
PATH="$(TARGET_PATH)" \
SUBDIRS="$(PKG_BUILD_DIR)" \
PWD="$(PKG_BUILD_DIR)" \
LINUX_VERSION="$(LINUX_VERSION)" \
CONFIG_BATMAN_ADV_DEBUG=$(if $(CONFIG_KMOD_BATMAN_ADV_DEBUG_LOG),y,n) \
CONFIG_BATMAN_ADV_BLA=$(if $(CONFIG_KMOD_BATMAN_ADV_BLA),y,n) \
CONFIG_BATMAN_ADV_DAT=$(if $(CONFIG_KMOD_BATMAN_ADV_DAT),y,n) \
CONFIG_BATMAN_ADV_MCAST=$(if $(CONFIG_KMOD_BATMAN_ADV_MCAST),y,n) \
CONFIG_BATMAN_ADV_NC=$(if $(CONFIG_KMOD_BATMAN_ADV_NC),y,n) \
REVISION="" all
define Build/Prepare
$(call Build/Prepare/Default)
$(SED) '/#define _NET_BATMAN_ADV_MAIN_H_/a\#undef CONFIG_MODULE_STRIPPED' \
$(PKG_BUILD_DIR)/main.h
endef
PKG_EXTRA_KCONFIG:= \
CONFIG_BATMAN_ADV=m \
CONFIG_BATMAN_ADV_DEBUG=$(if $(CONFIG_BATMAN_ADV_DEBUG),y,n) \
CONFIG_BATMAN_ADV_BLA=$(if $(CONFIG_BATMAN_ADV_BLA),y,n) \
CONFIG_BATMAN_ADV_DAT=$(if $(CONFIG_BATMAN_ADV_DAT),y,n) \
CONFIG_BATMAN_ADV_MCAST=$(if $(CONFIG_BATMAN_ADV_MCAST),y,n) \
CONFIG_BATMAN_ADV_NC=$(if $(CONFIG_BATMAN_ADV_NC),y,n) \
CONFIG_BATMAN_ADV_BATMAN_V=$(if $(CONFIG_BATMAN_ADV_BATMAN_V),y,n) \
CONFIG_BATMAN_ADV_TRACING=$(if $(CONFIG_BATMAN_ADV_TRACING),y,n) \
PKG_EXTRA_CFLAGS:= \
$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(PKG_EXTRA_KCONFIG)))) \
$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(PKG_EXTRA_KCONFIG)))) \
NOSTDINC_FLAGS = \
$(KERNEL_NOSTDINC_FLAGS) \
-I$(PKG_BUILD_DIR)/net/batman-adv \
-I$(STAGING_DIR)/usr/include/mac80211-backport \
-I$(STAGING_DIR)/usr/include/mac80211-backport/uapi \
-I$(STAGING_DIR)/usr/include/mac80211 \
-I$(STAGING_DIR)/usr/include/mac80211/uapi \
-I$(PKG_BUILD_DIR)/include/ \
-include backport/autoconf.h \
-include backport/backport.h \
-include $(PKG_BUILD_DIR)/compat-hacks.h \
-DBATADV_SOURCE_VERSION=\\\"$(PKG_VERSION)-openwrt-$(PKG_RELEASE)\\\"
define Build/Compile
$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \
$(KERNEL_MAKE_FLAGS) \
M="$(PKG_BUILD_DIR)/net/batman-adv" \
$(PKG_EXTRA_KCONFIG) \
EXTRA_CFLAGS="$(PKG_EXTRA_CFLAGS)" \
NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \
modules
$(MAKE) -C "$(PKG_BUILD_DIR)" $(MAKE_BATMAN_ADV_ARGS)
endef
define Build/Clean
rm -rf $(BUILD_DIR)/$(PKG_NAME)/
endef
define KernelPackage/batman-adv/install
$(CP) ./files/. $(1)/
$(INSTALL_DIR) $(1)/etc/config $(1)/etc/hotplug.d/net $(1)/etc/hotplug.d/iface $(1)/lib/batman-adv $(1)/usr/sbin $(1)/lib/netifd/proto
$(INSTALL_DATA) ./files/etc/config/batman-adv $(1)/etc/config
$(INSTALL_DATA) ./files/lib/batman-adv/config.sh $(1)/lib/batman-adv
$(INSTALL_BIN) ./files/etc/hotplug.d/net/99-batman-adv $(1)/etc/hotplug.d/net
$(INSTALL_BIN) ./files/lib/netifd/proto/batadv.sh $(1)/lib/netifd/proto
$(INSTALL_BIN) ./files/lib/netifd/proto/batadv_vlan.sh $(1)/lib/netifd/proto
endef
$(eval $(call KernelPackage,batman-adv))

View file

@ -0,0 +1,22 @@
config 'mesh' 'bat0'
option 'aggregated_ogms'
option 'ap_isolation'
option 'bonding'
option 'fragmentation'
option 'gw_bandwidth'
option 'gw_mode'
option 'gw_sel_class'
option 'log_level'
option 'orig_interval'
option 'vis_mode'
option 'bridge_loop_avoidance'
option 'distributed_arp_table'
option 'multicast_mode'
option 'network_coding'
option 'hop_penalty'
option 'isolation_mark'
# yet another batX instance
# config 'mesh' 'bat5'
# option 'interfaces' 'second_mesh'

View file

@ -0,0 +1,12 @@
#!/bin/sh
. /lib/batman-adv/config.sh
bat_load_module
config_load batman-adv
case "$ACTION" in
add)
[ -d /sys/class/net/$INTERFACE/mesh/ ] && bat_config "$INTERFACE"
;;
esac

View file

@ -1,97 +0,0 @@
#!/bin/sh
# This UCI-Defaults script will split the batadv proto network interfaces
# in batadv_hardif and batadv proto. The configuration options from
# /etc/config/batman-adv will be moved to the latter.
. /lib/functions.sh
proto_batadv_to_batadv_hardif() {
local section="$1"
local proto
local mesh
local routing_algo
config_get proto "${section}" proto
config_get mesh "${section}" mesh
config_get routing_algo "${section}" routing_algo
if [ -z "$mesh" -o "${proto}" != "batadv" ]; then
continue
fi
uci set network."${section}".proto="batadv_hardif"
uci rename network."${section}".mesh="master"
uci delete network."${section}".routing_algo
# create new section or adjust existing one
uci set network."${mesh}"=interface
uci set network."${mesh}".proto=batadv
[ -n "${routing_algo}" ] && uci set network."${mesh}".routing_algo="${routing_algo}"
}
mv_batadv_config_section() {
local section="$1"
local aggregated_ogms
local ap_isolation
local bonding
local bridge_loop_avoidance
local distributed_arp_table
local fragmentation
local gw_bandwidth
local gw_mode
local gw_sel_class
local hop_penalty
local isolation_mark
local log_level
local multicast_mode
local network_coding
local orig_interval
config_get aggregated_ogms "${section}" aggregated_ogms
config_get ap_isolation "${section}" ap_isolation
config_get bonding "${section}" bonding
config_get bridge_loop_avoidance "${section}" bridge_loop_avoidance
config_get distributed_arp_table "${section}" distributed_arp_table
config_get fragmentation "${section}" fragmentation
config_get gw_bandwidth "${section}" gw_bandwidth
config_get gw_mode "${section}" gw_mode
config_get gw_sel_class "${section}" gw_sel_class
config_get hop_penalty "${section}" hop_penalty
config_get isolation_mark "${section}" isolation_mark
config_get log_level "${section}" log_level
config_get multicast_mode "${section}" multicast_mode
config_get network_coding "${section}" network_coding
config_get orig_interval "${section}" orig_interval
# update section in case it exists
[ -n "${aggregated_ogms}" ] && uci set network."${section}".aggregated_ogms="${aggregated_ogms}"
[ -n "${ap_isolation}" ] && uci set network."${section}".ap_isolation="${ap_isolation}"
[ -n "${bonding}" ] && uci set network."${section}".bonding="${bonding}"
[ -n "${bridge_loop_avoidance}" ] && uci set network."${section}".bridge_loop_avoidance="${bridge_loop_avoidance}"
[ -n "${distributed_arp_table}" ] && uci set network."${section}".distributed_arp_table="${distributed_arp_table}"
[ -n "${fragmentation}" ] && uci set network."${section}".fragmentation="${fragmentation}"
[ -n "${gw_bandwidth}" ] && uci set network."${section}".gw_bandwidth="${gw_bandwidth}"
[ -n "${gw_mode}" ] && uci set network."${section}".gw_mode="${gw_mode}"
[ -n "${gw_sel_class}" ] && uci set network."${section}".gw_sel_class="${gw_sel_class}"
[ -n "${hop_penalty}" ] && uci set network."${section}".hop_penalty="${hop_penalty}"
[ -n "${isolation_mark}" ] && uci set network."${section}".isolation_mark="${isolation_mark}"
[ -n "${log_level}" ] && uci set network."${section}".log_level="${log_level}"
[ -n "${multicast_mode}" ] && uci set network."${section}".multicast_mode="${multicast_mode}"
[ -n "${network_coding}" ] && uci set network."${section}".network_coding="${network_coding}"
[ -n "${orig_interval}" ] && uci set network."${section}".orig_interval="${orig_interval}"
}
if [ -f /etc/config/batman-adv ]; then
config_load network
config_foreach proto_batadv_to_batadv_hardif 'interface'
uci commit network
config_load batman-adv
config_foreach mv_batadv_config_section 'mesh'
uci commit network
rm -f /etc/config/batman-adv
fi
exit 0

View file

@ -0,0 +1,53 @@
#!/bin/sh
bat_load_module()
{
[ -d "/sys/module/batman_adv/" ] && return
. /lib/functions.sh
load_modules /etc/modules.d/*-crc16 /etc/modules.d/*-crypto* /etc/modules.d/*-lib-crc* /etc/modules.d/*-batman-adv*
}
bat_config()
{
local mesh="$1"
local aggregated_ogms ap_isolation bonding bridge_loop_avoidance distributed_arp_table fragmentation
local gw_bandwidth gw_mode gw_sel_class isolation_mark hop_penalty multicast_mode network_coding log_level
local orig_interval vis_mode
config_get aggregated_ogms "$mesh" aggregated_ogms
config_get ap_isolation "$mesh" ap_isolation
config_get bonding "$mesh" bonding
config_get bridge_loop_avoidance "$mesh" bridge_loop_avoidance
config_get distributed_arp_table "$mesh" distributed_arp_table
config_get fragmentation "$mesh" fragmentation
config_get gw_bandwidth "$mesh" gw_bandwidth
config_get gw_mode "$mesh" gw_mode
config_get gw_sel_class "$mesh" gw_sel_class
config_get hop_penalty "$mesh" hop_penalty
config_get isolation_mark "$mesh" isolation_mark
config_get multicast_mode "$mesh" multicast_mode
config_get network_coding "$mesh" network_coding
config_get log_level "$mesh" log_level
config_get orig_interval "$mesh" orig_interval
config_get vis_mode "$mesh" vis_mode
[ ! -f "/sys/class/net/$mesh/mesh/orig_interval" ] && echo "batman-adv mesh $mesh does not exist - check your interface configuration" && return 1
[ -n "$aggregate_ogms" ] && echo $aggregate_ogms > /sys/class/net/$mesh/mesh/aggregate_ogms
[ -n "$ap_isolation" ] && echo $ap_isolation > /sys/class/net/$mesh/mesh/ap_isolation
[ -n "$bonding" ] && echo $bonding > /sys/class/net/$mesh/mesh/bonding
[ -n "$bridge_loop_avoidance" ] && echo $bridge_loop_avoidance > /sys/class/net/$mesh/mesh/bridge_loop_avoidance 2>&-
[ -n "$distributed_arp_table" ] && echo $distributed_arp_table > /sys/class/net/$mesh/mesh/distributed_arp_table 2>&-
[ -n "$fragmentation" ] && echo $fragmentation > /sys/class/net/$mesh/mesh/fragmentation
[ -n "$gw_bandwidth" ] && echo $gw_bandwidth > /sys/class/net/$mesh/mesh/gw_bandwidth
[ -n "$gw_mode" ] && echo $gw_mode > /sys/class/net/$mesh/mesh/gw_mode
[ -n "$gw_sel_class" ] && echo $gw_sel_class > /sys/class/net/$mesh/mesh/gw_sel_class
[ -n "$hop_penalty" ] && echo $hop_penalty > /sys/class/net/$mesh/mesh/hop_penalty
[ -n "$isolation_mark" ] && echo $isolation_mark > /sys/class/net/$mesh/mesh/isolation_mark
[ -n "$multicast_mode" ] && echo $multicast_mode > /sys/class/net/$mesh/mesh/multicast_mode 2>&-
[ -n "$network_coding" ] && echo $network_coding > /sys/class/net/$mesh/mesh/network_coding 2>&-
[ -n "$log_level" ] && echo $log_level > /sys/class/net/$mesh/mesh/log_level 2>&-
[ -n "$orig_interval" ] && echo $orig_interval > /sys/class/net/$mesh/mesh/orig_interval
[ -n "$vis_mode" ] && echo $vis_mode > /sys/class/net/$mesh/mesh/vis_mode
}

113
batman-adv/files/lib/netifd/proto/batadv.sh Executable file → Normal file
View file

@ -1,123 +1,30 @@
#!/bin/sh
[ -n "$INCLUDE_ONLY" ] || {
. /lib/functions.sh
. ../netifd-proto.sh
init_proto "$@"
}
. /lib/functions.sh
. ../netifd-proto.sh
init_proto "$@"
proto_batadv_init_config() {
no_device=1
available=1
proto_config_add_boolean 'aggregated_ogms:bool'
proto_config_add_boolean 'ap_isolation:bool'
proto_config_add_boolean 'bonding:bool'
proto_config_add_boolean 'bridge_loop_avoidance:bool'
proto_config_add_boolean 'distributed_arp_table:bool'
proto_config_add_boolean 'fragmentation:bool'
proto_config_add_string 'gw_bandwidth'
proto_config_add_string 'gw_mode'
proto_config_add_int 'gw_sel_class'
proto_config_add_int 'hop_penalty'
proto_config_add_string 'isolation_mark'
proto_config_add_string 'log_level'
proto_config_add_int 'multicast_fanout'
proto_config_add_boolean 'multicast_mode:bool'
proto_config_add_boolean 'network_coding:bool'
proto_config_add_int 'orig_interval'
proto_config_add_string 'routing_algo'
proto_config_add_string "mesh"
}
proto_batadv_setup() {
local config="$1"
local iface="$config"
local iface="$2"
local aggregated_ogms
local ap_isolation
local bonding
local bridge_loop_avoidance
local distributed_arp_table
local fragmentation
local gw_bandwidth
local gw_mode
local gw_sel_class
local hop_penalty
local isolation_mark
local log_level
local multicast_fanout
local multicast_mode
local network_coding
local orig_interval
local routing_algo
json_get_vars aggregated_ogms
json_get_vars ap_isolation
json_get_vars bonding
json_get_vars bridge_loop_avoidance
json_get_vars distributed_arp_table
json_get_vars fragmentation
json_get_vars gw_bandwidth
json_get_vars gw_mode
json_get_vars gw_sel_class
json_get_vars hop_penalty
json_get_vars isolation_mark
json_get_vars log_level
json_get_vars multicast_fanout
json_get_vars multicast_mode
json_get_vars network_coding
json_get_vars orig_interval
json_get_vars routing_algo
set_default routing_algo 'BATMAN_IV'
batctl routing_algo "$routing_algo"
batctl meshif "$iface" interface create
[ -n "$aggregated_ogms" ] && batctl meshif "$iface" aggregation "$aggregated_ogms"
[ -n "$ap_isolation" ] && batctl meshif "$iface" ap_isolation "$ap_isolation"
[ -n "$bonding" ] && batctl meshif "$iface" bonding "$bonding"
[ -n "$bridge_loop_avoidance" ] && batctl meshif "$iface" bridge_loop_avoidance "$bridge_loop_avoidance" 2>&-
[ -n "$distributed_arp_table" ] && batctl meshif "$iface" distributed_arp_table "$distributed_arp_table" 2>&-
[ -n "$fragmentation" ] && batctl meshif "$iface" fragmentation "$fragmentation"
case "$gw_mode" in
server)
if [ -n "$gw_bandwidth" ]; then
batctl meshif "$iface" gw_mode "server" "$gw_bandwidth"
else
batctl meshif "$iface" gw_mode "server"
fi
;;
client)
if [ -n "$gw_sel_class" ]; then
batctl meshif "$iface" gw_mode "client" "$gw_sel_class"
else
batctl meshif "$iface" gw_mode "client"
fi
;;
*)
batctl meshif "$iface" gw_mode "off"
;;
esac
[ -n "$hop_penalty" ] && batctl meshif "$iface" hop_penalty "$hop_penalty"
[ -n "$isolation_mark" ] && batctl meshif "$iface" isolation_mark "$isolation_mark"
[ -n "$multicast_fanout" ] && batctl meshif "$iface" multicast_fanout "$multicast_fanout"
[ -n "$multicast_mode" ] && batctl meshif "$iface" multicast_mode "$multicast_mode" 2>&-
[ -n "$network_coding" ] && batctl meshif "$iface" network_coding "$network_coding" 2>&-
[ -n "$log_level" ] && batctl meshif "$iface" loglevel "$log_level" 2>&-
[ -n "$orig_interval" ] && batctl meshif "$iface" orig_interval "$orig_interval"
local mesh
json_get_vars mesh
echo "$mesh" > "/sys/class/net/$iface/batman_adv/mesh_iface"
proto_init_update "$iface" 1
proto_send_update "$config"
}
proto_batadv_teardown() {
local config="$1"
local iface="$config"
local iface="$2"
batctl meshif "$iface" interface destroy
echo "none" > "/sys/class/net/$iface/batman_adv/mesh_iface" || true
}
add_protocol batadv

View file

@ -1,53 +0,0 @@
#!/bin/sh
[ -n "$INCLUDE_ONLY" ] || {
. /lib/functions.sh
. ../netifd-proto.sh
init_proto "$@"
}
proto_batadv_hardif_init_config() {
proto_config_add_int 'elp_interval'
proto_config_add_int 'hop_penalty'
proto_config_add_string "master"
proto_config_add_string 'throughput_override'
}
proto_batadv_hardif_setup() {
local config="$1"
local iface="$2"
local elp_interval
local hop_penalty
local master
local throughput_override
json_get_vars elp_interval
json_get_vars hop_penalty
json_get_vars master
json_get_vars throughput_override
( proto_add_host_dependency "$config" '' "$master" )
batctl meshif "$master" interface -M add "$iface"
[ -n "$elp_interval" ] && batctl hardif "$iface" elp_interval "$elp_interval"
[ -n "$hop_penalty" ] && batctl hardif "$iface" hop_penalty "$hop_penalty"
[ -n "$throughput_override" ] && batctl hardif "$iface" throughput_override "$throughput_override"
proto_init_update "$iface" 1
proto_send_update "$config"
}
proto_batadv_hardif_teardown() {
local config="$1"
local iface="$2"
local master
json_get_vars master
batctl meshif "$master" interface -M del "$iface" || true
}
add_protocol batadv_hardif

12
batman-adv/files/lib/netifd/proto/batadv_vlan.sh Executable file → Normal file
View file

@ -5,25 +5,25 @@
init_proto "$@"
proto_batadv_vlan_init_config() {
proto_config_add_boolean 'ap_isolation:bool'
proto_config_add_string "ap_isolation"
}
proto_batadv_vlan_setup() {
local config="$1"
local iface="$2"
# VLAN specific variables
local device="${iface%.*}"
local vid="${iface#*.}"
# batadv_vlan options
local ap_isolation
json_get_vars ap_isolation
[ -n "$ap_isolation" ] && batctl vlan "$iface" ap_isolation "$ap_isolation"
echo "$ap_isolation" > "/sys/class/net/${device}/mesh/vlan${vid}/ap_isolation"
proto_init_update "$iface" 1
proto_send_update "$config"
}
proto_batadv_vlan_teardown() {
local cfg="$1"
}
add_protocol batadv_vlan

View file

@ -1,274 +0,0 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Fri, 6 May 2022 22:03:29 +0200
Subject: Revert "batman-adv: Migrate to linux/container_of.h"
The original patch requires Linux 5.16.0 or a mac80211 compat header with this
name. But the mac80211 package is currently not providing this header and
OpenWrt main is still using older Linux kernel versions for some targets.
This reverts commit 043ae5634bdfd4c4dd8b95a22890752495080bb5.
--- a/compat-include/linux/container_of.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* Copyright (C) B.A.T.M.A.N. contributors:
- *
- * Marek Lindner, Simon Wunderlich
- *
- * This file contains macros for maintaining compatibility with older versions
- * of the Linux kernel.
- */
-
-#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_CONTAINER_OF_H_
-#define _NET_BATMAN_ADV_COMPAT_LINUX_CONTAINER_OF_H_
-
-#include <linux/version.h>
-#if LINUX_VERSION_IS_GEQ(5, 16, 0)
-#include_next <linux/container_of.h>
-#else
-#include <linux/kernel.h>
-#endif
-
-#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_CONTAINER_OF_H_ */
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -13,13 +13,13 @@
#include <linux/bug.h>
#include <linux/byteorder/generic.h>
#include <linux/cache.h>
-#include <linux/container_of.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
#include <linux/gfp.h>
#include <linux/if_ether.h>
#include <linux/init.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/lockdep.h>
--- a/net/batman-adv/bat_v_elp.c
+++ b/net/batman-adv/bat_v_elp.c
@@ -10,13 +10,13 @@
#include <linux/atomic.h>
#include <linux/bitops.h>
#include <linux/byteorder/generic.h>
-#include <linux/container_of.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
#include <linux/ethtool.h>
#include <linux/gfp.h>
#include <linux/if_ether.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/minmax.h>
#include <linux/netdevice.h>
--- a/net/batman-adv/bat_v_ogm.c
+++ b/net/batman-adv/bat_v_ogm.c
@@ -9,12 +9,12 @@
#include <linux/atomic.h>
#include <linux/byteorder/generic.h>
-#include <linux/container_of.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
#include <linux/gfp.h>
#include <linux/if_ether.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/lockdep.h>
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -10,7 +10,6 @@
#include <linux/atomic.h>
#include <linux/byteorder/generic.h>
#include <linux/compiler.h>
-#include <linux/container_of.h>
#include <linux/crc16.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -11,7 +11,6 @@
#include <linux/atomic.h>
#include <linux/bitops.h>
#include <linux/byteorder/generic.h>
-#include <linux/container_of.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
#include <linux/gfp.h>
@@ -21,6 +20,7 @@
#include <linux/in.h>
#include <linux/ip.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/netlink.h>
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -9,7 +9,6 @@
#include <linux/atomic.h>
#include <linux/byteorder/generic.h>
-#include <linux/container_of.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
#include <linux/gfp.h>
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -10,12 +10,12 @@
#include <linux/atomic.h>
#include <linux/byteorder/generic.h>
#include <linux/compiler.h>
-#include <linux/container_of.h>
#include <linux/errno.h>
#include <linux/gfp.h>
#include <linux/if.h>
#include <linux/if_arp.h>
#include <linux/if_ether.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/limits.h>
#include <linux/list.h>
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -10,7 +10,6 @@
#include <linux/atomic.h>
#include <linux/build_bug.h>
#include <linux/byteorder/generic.h>
-#include <linux/container_of.h>
#include <linux/crc32c.h>
#include <linux/device.h>
#include <linux/errno.h>
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -11,7 +11,6 @@
#include <linux/bitops.h>
#include <linux/bug.h>
#include <linux/byteorder/generic.h>
-#include <linux/container_of.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
#include <linux/gfp.h>
--- a/net/batman-adv/network-coding.c
+++ b/net/batman-adv/network-coding.c
@@ -11,7 +11,6 @@
#include <linux/bitops.h>
#include <linux/byteorder/generic.h>
#include <linux/compiler.h>
-#include <linux/container_of.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
#include <linux/gfp.h>
@@ -20,6 +19,7 @@
#include <linux/init.h>
#include <linux/jhash.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/lockdep.h>
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -8,11 +8,11 @@
#include "main.h"
#include <linux/atomic.h>
-#include <linux/container_of.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
#include <linux/gfp.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/lockdep.h>
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -10,13 +10,13 @@
#include <linux/atomic.h>
#include <linux/bug.h>
#include <linux/byteorder/generic.h>
-#include <linux/container_of.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
#include <linux/gfp.h>
#include <linux/if.h>
#include <linux/if_ether.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/netdevice.h>
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -11,7 +11,6 @@
#include <linux/byteorder/generic.h>
#include <linux/cache.h>
#include <linux/compiler.h>
-#include <linux/container_of.h>
#include <linux/cpumask.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
@@ -20,6 +19,7 @@
#include <linux/if_ether.h>
#include <linux/if_vlan.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/lockdep.h>
--- a/net/batman-adv/tp_meter.c
+++ b/net/batman-adv/tp_meter.c
@@ -12,13 +12,13 @@
#include <linux/byteorder/generic.h>
#include <linux/cache.h>
#include <linux/compiler.h>
-#include <linux/container_of.h>
#include <linux/err.h>
#include <linux/etherdevice.h>
#include <linux/gfp.h>
#include <linux/if_ether.h>
#include <linux/init.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/kthread.h>
#include <linux/limits.h>
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -13,7 +13,6 @@
#include <linux/byteorder/generic.h>
#include <linux/cache.h>
#include <linux/compiler.h>
-#include <linux/container_of.h>
#include <linux/crc32c.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
@@ -22,6 +21,7 @@
#include <linux/init.h>
#include <linux/jhash.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/lockdep.h>
--- a/net/batman-adv/tvlv.c
+++ b/net/batman-adv/tvlv.c
@@ -7,10 +7,10 @@
#include "main.h"
#include <linux/byteorder/generic.h>
-#include <linux/container_of.h>
#include <linux/etherdevice.h>
#include <linux/gfp.h>
#include <linux/if_ether.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/lockdep.h>

View file

@ -1,19 +0,0 @@
From: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Date: Thu, 6 Apr 2023 18:05:50 -0500
Subject: fix batadv_is_cfg80211_netdev
Replace CONFIG_CFG80211 with CPTCFG_CFG80211, which is the correct
macro to use when building under backports.
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -308,8 +308,7 @@ static bool batadv_is_cfg80211_netdev(st
{
if (!net_device)
return false;
-
-#if IS_ENABLED(CONFIG_CFG80211)
+#if IS_ENABLED(CPTCFG_CFG80211)
/* cfg80211 drivers have to set ieee80211_ptr */
if (net_device->ieee80211_ptr)
return true;

View file

@ -1,97 +0,0 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Fri, 2 Feb 2024 22:49:00 +0100
Subject: Revert "batman-adv: Switch to linux/sprintf.h"
The original patch requires Linux 6.6.0 or a mac80211 compat header with this
name. But the mac80211 package is currently not providing this header and
OpenWrt main is still using older Linux kernel versions for some targets.
This reverts commit f0fb49c5ab70dfa064f0aa8d1c5d84f65e8cbc86.
--- a/compat-include/linux/sprintf.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* Copyright (C) B.A.T.M.A.N. contributors:
- *
- * Marek Lindner, Simon Wunderlich
- *
- * This file contains macros for maintaining compatibility with older versions
- * of the Linux kernel.
- */
-
-#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_SPRINTF_H_
-#define _NET_BATMAN_ADV_COMPAT_LINUX_SPRINTF_H_
-
-#include <linux/version.h>
-#if LINUX_VERSION_IS_GEQ(6, 6, 0)
-#include_next <linux/sprintf.h>
-#else
-#include <linux/kernel.h>
-#endif
-
-#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_SPRINTF_H_ */
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -19,6 +19,7 @@
#include <linux/if_vlan.h>
#include <linux/jhash.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/lockdep.h>
@@ -29,7 +30,6 @@
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
-#include <linux/sprintf.h>
#include <linux/stddef.h>
#include <linux/string.h>
#include <linux/workqueue.h>
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -17,6 +17,7 @@
#include <linux/in.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/lockdep.h>
@@ -27,7 +28,6 @@
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
-#include <linux/sprintf.h>
#include <linux/stddef.h>
#include <linux/udp.h>
#include <net/sock.h>
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -32,7 +32,6 @@
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
-#include <linux/sprintf.h>
#include <linux/stddef.h>
#include <linux/string.h>
#include <linux/workqueue.h>
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -24,6 +24,7 @@
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/lockdep.h>
#include <linux/netdevice.h>
@@ -34,7 +35,6 @@
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
-#include <linux/sprintf.h>
#include <linux/stddef.h>
#include <linux/string.h>
#include <linux/types.h>

View file

@ -1,69 +0,0 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Fri, 2 Feb 2024 22:49:48 +0100
Subject: Revert "batman-adv: Switch to linux/array_size.h"
The original patch requires Linux 6.7.0 or a mac80211 compat header with this
name. But the mac80211 package is currently not providing this header and
OpenWrt main is still using older Linux kernel versions for some targets.
This reverts commit f33d7f724675544a36b24c77f8d4b95d41252ae2.
--- a/compat-include/linux/array_size.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* Copyright (C) B.A.T.M.A.N. contributors:
- *
- * Marek Lindner, Simon Wunderlich
- *
- * This file contains macros for maintaining compatibility with older versions
- * of the Linux kernel.
- */
-
-#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_ARRAY_SIZE_H_
-#define _NET_BATMAN_ADV_COMPAT_LINUX_ARRAY_SIZE_H_
-
-#include <linux/version.h>
-#if LINUX_VERSION_IS_GEQ(6, 7, 0)
-#include_next <linux/array_size.h>
-#else
-#include <linux/kernel.h>
-#endif
-
-#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_ARRAY_SIZE_H_ */
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -6,7 +6,6 @@
#include "main.h"
-#include <linux/array_size.h>
#include <linux/atomic.h>
#include <linux/build_bug.h>
#include <linux/byteorder/generic.h>
@@ -20,6 +19,7 @@
#include <linux/init.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
+#include <linux/kernel.h>
#include <linux/kobject.h>
#include <linux/kref.h>
#include <linux/list.h>
--- a/net/batman-adv/netlink.c
+++ b/net/batman-adv/netlink.c
@@ -7,7 +7,6 @@
#include "netlink.h"
#include "main.h"
-#include <linux/array_size.h>
#include <linux/atomic.h>
#include <linux/bitops.h>
#include <linux/bug.h>
@@ -21,6 +20,7 @@
#include <linux/if_ether.h>
#include <linux/if_vlan.h>
#include <linux/init.h>
+#include <linux/kernel.h>
#include <linux/limits.h>
#include <linux/list.h>
#include <linux/minmax.h>

View file

@ -1,121 +0,0 @@
/* Please avoid adding hacks here - instead add it to mac80211/backports.git */
#undef CONFIG_MODULE_STRIPPED
#include <linux/version.h> /* LINUX_VERSION_CODE */
#include <linux/types.h>
#if LINUX_VERSION_IS_LESS(6, 0, 0)
#define __vstring(item, fmt, ap) __dynamic_array(char, item, 256)
#define __assign_vstr(dst, fmt, va) \
WARN_ON_ONCE(vsnprintf(__get_dynamic_array(dst), 256, fmt, *va) >= 256)
#endif /* LINUX_VERSION_IS_LESS(6, 0, 0) */
#if LINUX_VERSION_IS_LESS(6, 2, 0)
#include <linux/random.h>
#define genl_split_ops genl_ops
static inline u32 batadv_get_random_u32_below(u32 ep_ro)
{
return prandom_u32_max(ep_ro);
}
#define get_random_u32_below batadv_get_random_u32_below
#endif /* LINUX_VERSION_IS_LESS(6, 2, 0) */
#if LINUX_VERSION_IS_LESS(6, 4, 0) && \
!(LINUX_VERSION_IS_GEQ(5, 10, 205) && LINUX_VERSION_IS_LESS(5, 11, 0)) && \
!(LINUX_VERSION_IS_GEQ(5, 15, 144) && LINUX_VERSION_IS_LESS(5, 16, 0)) && \
!(LINUX_VERSION_IS_GEQ(6, 1, 69) && LINUX_VERSION_IS_LESS(6, 2, 0))
#include <linux/if_vlan.h>
/* Prefer this version in TX path, instead of
* skb_reset_mac_header() + vlan_eth_hdr()
*/
static inline struct vlan_ethhdr *skb_vlan_eth_hdr(const struct sk_buff *skb)
{
return (struct vlan_ethhdr *)skb->data;
}
#endif /* LINUX_VERSION_IS_LESS(6, 4, 0) */
/* <DECLARE_EWMA> */
#include <linux/version.h>
#include_next <linux/average.h>
#include <linux/bug.h>
#ifdef DECLARE_EWMA
#undef DECLARE_EWMA
#endif /* DECLARE_EWMA */
/*
* Exponentially weighted moving average (EWMA)
*
* This implements a fixed-precision EWMA algorithm, with both the
* precision and fall-off coefficient determined at compile-time
* and built into the generated helper funtions.
*
* The first argument to the macro is the name that will be used
* for the struct and helper functions.
*
* The second argument, the precision, expresses how many bits are
* used for the fractional part of the fixed-precision values.
*
* The third argument, the weight reciprocal, determines how the
* new values will be weighed vs. the old state, new values will
* get weight 1/weight_rcp and old values 1-1/weight_rcp. Note
* that this parameter must be a power of two for efficiency.
*/
#define DECLARE_EWMA(name, _precision, _weight_rcp) \
struct ewma_##name { \
unsigned long internal; \
}; \
static inline void ewma_##name##_init(struct ewma_##name *e) \
{ \
BUILD_BUG_ON(!__builtin_constant_p(_precision)); \
BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \
/* \
* Even if you want to feed it just 0/1 you should have \
* some bits for the non-fractional part... \
*/ \
BUILD_BUG_ON((_precision) > 30); \
BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \
e->internal = 0; \
} \
static inline unsigned long \
ewma_##name##_read(struct ewma_##name *e) \
{ \
BUILD_BUG_ON(!__builtin_constant_p(_precision)); \
BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \
BUILD_BUG_ON((_precision) > 30); \
BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \
return e->internal >> (_precision); \
} \
static inline void ewma_##name##_add(struct ewma_##name *e, \
unsigned long val) \
{ \
unsigned long internal = READ_ONCE(e->internal); \
unsigned long weight_rcp = ilog2(_weight_rcp); \
unsigned long precision = _precision; \
\
BUILD_BUG_ON(!__builtin_constant_p(_precision)); \
BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \
BUILD_BUG_ON((_precision) > 30); \
BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \
\
WRITE_ONCE(e->internal, internal ? \
(((internal << weight_rcp) - internal) + \
(val << precision)) >> weight_rcp : \
(val << precision)); \
}
/* </DECLARE_EWMA> */

View file

@ -6,29 +6,32 @@
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=batmand
PKG_REV:=1439
PKG_VERSION:=r$(PKG_REV)
PKG_RELEASE:=2
PKG_EXTRA_CFLAGS=-DDEBUG_MALLOC -DMEMORY_USAGE -DPROFILE_DATA -DREVISION_VERSION=\"\ rv$(PKG_REV)\"
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://git.open-mesh.org/batmand.git
PKG_REV:=b67a7087b51d7a5e90d27ac39116d1f57257c86e
PKG_VERSION:=1440
PKG_RELEASE:=1
PKG_LICENSE:=GPL-2.0
PKG_SOURCE_PROTO:=svn
PKG_SOURCE_VERSION:=$(PKG_REV)
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_SUBDIR:=$(if $(PKG_BRANCH),$(PKG_BRANCH),$(PKG_NAME))-$(PKG_VERSION)
PKG_SOURCE_URL:=http://downloads.open-mesh.org/svn/batman/trunk/
PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
PKG_MIRROR_HASH:=ceb8e0e399f79b1b663594fcf9642e1efc40e696a7604daf709c77da9b6ec52f
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SOURCE_SUBDIR)
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_SOURCE_SUBDIR)
PKG_BUILD_PARALLEL:=1
PKG_KMOD_BUILD_DIR:=$(PKG_BUILD_DIR)/batman/linux/modules
include $(INCLUDE_DIR)/package.mk
define Package/batmand/Default
URL:=http://www.open-mesh.org/
MAINTAINER:=Marek Lindner <lindner_marek@yahoo.de>
endef
define Package/batmand
URL:=https://www.open-mesh.org/
MAINTAINER:=Corinna "Elektra" Aichele <onelektra@gmx.net>
$(call Package/batmand/Default)
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
@ -40,16 +43,91 @@ define Package/batmand/description
B.A.T.M.A.N. layer 3 routing daemon
endef
MAKE_FLAGS += \
EXTRA_CFLAGS='-DDEBUG_MALLOC -DMEMORY_USAGE -DPROFILE_DATA -DREVISION_VERSION=\"\ rv$(PKG_REV)\" -D_GNU_SOURCE' \
define Package/vis
$(call Package/batmand/Default)
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
DEPENDS:=+libpthread
TITLE:=visualization server for B.A.T.M.A.N. layer 3
endef
define Package/vis/description
visualization server for B.A.T.M.A.N. layer 3
endef
define KernelPackage/batgat
$(call Package/batmand/Default)
SUBMENU:=Network Support
DEPENDS:=+batmand @BROKEN
TITLE:=B.A.T.M.A.N. gateway module
FILES:=$(PKG_KMOD_BUILD_DIR)/batgat.$(LINUX_KMOD_SUFFIX)
AUTOLOAD:=$(call AutoLoad,50,batgat)
endef
define KernelPackage/batgat/description
Kernel gateway module for B.A.T.M.A.N. for better tunnel performance
endef
MAKE_BATMAND_ARGS += \
EXTRA_CFLAGS='$(TARGET_CFLAGS) $(PKG_EXTRA_CFLAGS)' \
CCFLAGS="$(TARGET_CFLAGS)" \
OFLAGS="$(TARGET_CFLAGS)" \
REVISION="$(PKG_REV)" \
CC="$(TARGET_CC)" \
NODEBUG=1 \
UNAME="Linux" \
batmand
INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
STRIP="/bin/true" \
batmand install
MAKE_VIS_ARGS += \
EXTRA_CFLAGS='$(TARGET_CFLAGS) $(PKG_EXTRA_CFLAGS)' \
CCFLAGS="$(TARGET_CFLAGS)" \
OFLAGS="$(TARGET_CFLAGS)" \
REVISION="$(PKG_REV)" \
CC="$(TARGET_CC)" \
NODEBUG=1 \
UNAME="Linux" \
INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
STRIP="/bin/true" \
vis install
MAKE_BATGAT_ARGS += \
CROSS_COMPILE="$(TARGET_CROSS)" \
ARCH="$(LINUX_KARCH)" \
PATH="$(TARGET_PATH)" \
SUBDIRS="$(PKG_KMOD_BUILD_DIR)" \
LINUX_VERSION="$(LINUX_VERSION)" \
REVISION="$(PKG_REV)" modules
define Build/Configure
endef
ifneq ($(DEVELOPER)$(CONFIG_PACKAGE_batmand),)
BUILD_BATMAND := $(MAKE) -C $(PKG_BUILD_DIR)/batman $(MAKE_BATMAND_ARGS)
endif
ifneq ($(DEVELOPER)$(CONFIG_PACKAGE_vis),)
BUILD_VIS := $(MAKE) -C $(PKG_BUILD_DIR)/vis $(MAKE_VIS_ARGS)
endif
ifneq ($(DEVELOPER)$(CONFIG_PACKAGE_kmod-batgat),)
BUILD_BATGAT := $(MAKE) -C "$(LINUX_DIR)" $(MAKE_BATGAT_ARGS)
endif
define Build/Compile
$(BUILD_BATMAND)
$(BUILD_VIS)
cp $(PKG_KMOD_BUILD_DIR)/Makefile.kbuild $(PKG_KMOD_BUILD_DIR)/Makefile
$(BUILD_BATGAT)
endef
define Package/batmand/install
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/batmand $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/batmand $(1)/usr/sbin/
$(INSTALL_BIN) ./files/etc/init.d/batmand $(1)/etc/init.d
$(INSTALL_DATA) ./files/etc/config/batmand $(1)/etc/config
endef
@ -58,4 +136,17 @@ define Package/batmand/conffiles
/etc/config/batmand
endef
define Package/vis/install
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/vis $(1)/usr/sbin/
$(INSTALL_BIN) ./files/etc/init.d/vis $(1)/etc/init.d
$(INSTALL_DATA) ./files/etc/config/vis $(1)/etc/config
endef
define Package/vis/conffiles
/etc/config/vis
endef
$(eval $(call BuildPackage,batmand))
$(eval $(call BuildPackage,vis))
$(eval $(call KernelPackage,batgat))

View file

@ -1,11 +1,12 @@
config batmand general
option interface ath0
option hna
option gateway_class
option hna
option gateway_class
option originator_interval
option preferred_gateway
option preferred_gateway
option routing_class
option visualisation_srv
option policy_routing_script
option disable_client_nat
option disable_aggregation

View file

@ -1,44 +1,27 @@
#!/bin/sh /etc/rc.common
START=90
USE_PROCD=1
batmand_start() {
local config="$1"
local batman_args
local interface
local hnas
local gateway_class
local originator_interval
local preferred_gateway
local routing_class
local visualisation_srv
local local policy_routing_script
local disable_client_nat
local disable_aggregation
[ "$config" = "general" ] || return 1
config_get interface "$config" interface
start () {
interface=$(uci get batmand.general.interface)
if [ "$interface" = "" ]; then
echo $1 Error, you must specify at least a network interface
return 1
exit
fi
config_get hnas "$config" hna
config_get gateway_class "$config" gateway_class
config_get originator_interval "$config" originator_interval
config_get preferred_gateway "$config" preferred_gateway
config_get routing_class "$config" routing_class
config_get visualisation_srv "$config" visualisation_srv
config_get policy_routing_script "$config" policy_routing_script
config_get disable_client_nat "$config" disable_client_nat
config_get disable_aggregation "$config" disable_aggregation
hnas=$(uci get batmand.general.hna)
gateway_class=$(uci get batmand.general.gateway_class)
originator_interval=$(uci get batmand.general.originator_interval)
preferred_gateway=$(uci get batmand.general.preferred_gateway)
routing_class=$(uci get batmand.general.routing_class)
visualisation_srv=$(uci get batmand.general.visualisation_srv)
policy_routing_script=$(uci get batmand.general.policy_routing_script)
disable_client_nat=$(uci get batmand.general.disable_client_nat)
disable_aggregation=$(uci get batmand.general.disable_aggregation)
batman_args=""
for hna in $hnas; do
batman_args=${batman_args}'-a '$hna' '
done
for hna in $hnas
do
batman_args=${batman_args}'-a '$hna' '
done
if [ $gateway_class ]; then
batman_args=${batman_args}'-g '$gateway_class' '
@ -55,37 +38,29 @@ batmand_start() {
if [ $routing_class ]; then
batman_args=${batman_args}'-r '$routing_class' '
fi
if [ $visualisation_srv ]; then
batman_args=${batman_args}'-s '$visualisation_srv' '
fi
if [ $policy_routing_script ]; then
batman_args=${batman_args}'--policy-routing-script '$policy_routing_script' '
fi
if [ $disable_client_nat ]; then
batman_args=${batman_args}'--disable-client-nat '
fi
if [ $disable_aggregation ]; then
batman_args=${batman_args}'--disable-aggregation '
fi
procd_open_instance "${config}"
procd_set_param command /usr/sbin/batmand
procd_append_param command --no-detach
procd_append_param command ${batman_args}
procd_append_param command ${interface}
procd_set_param netdev ${interface}
procd_close_instance
batman_args=${batman_args}$interface
batmand $batman_args >/dev/null 2>&1
}
start_service() {
config_load "batmand"
config_foreach batmand_start batmand
stop () {
killall batmand
}
service_triggers() {
procd_add_reload_trigger "batmand"
}

View file

@ -0,0 +1,19 @@
#!/bin/sh /etc/rc.common
START=90
start () {
interface=$(uci get vis.general.interface)
if [ "$interface" = "" ]; then
echo $1 Error, you must specify at least a network interface
exit
fi
vis_args=$interface
vis $vis_args >/dev/null 2>&1
}
stop () {
killall vis
}

View file

@ -1,66 +0,0 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Sun, 1 Dec 2013 14:39:00 +0100
Subject: Allow one to disable forking to background in debug_mode 0
---
posix/init.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
--- a/posix/init.c
+++ b/posix/init.c
@@ -44,6 +44,7 @@
#define IOCSETDEV 1
int8_t stop;
+int no_detach = 0;
@@ -159,6 +160,7 @@ void apply_init_args( int argc, char *ar
{"purge-timeout", required_argument, 0, 'q'},
{"disable-aggregation", no_argument, 0, 'x'},
{"disable-client-nat", no_argument, 0, 'z'},
+ {"no-detach", no_argument, 0, 'D'},
{0, 0, 0, 0}
};
@@ -169,7 +171,7 @@ void apply_init_args( int argc, char *ar
if ( strstr( SOURCE_VERSION, "-" ) != NULL )
printf( "WARNING: You are using the unstable batman branch. If you are interested in *using* batman get the latest stable release !\n" );
- while ( ( optchar = getopt_long( argc, argv, "a:A:bcd:hHio:g:p:r:s:vV", long_options, &option_index ) ) != -1 ) {
+ while ( ( optchar = getopt_long( argc, argv, "a:A:bcd:hHio:g:p:r:s:vVD", long_options, &option_index ) ) != -1 ) {
switch ( optchar ) {
@@ -381,6 +383,11 @@ void apply_init_args( int argc, char *ar
found_args++;
break;
+ case 'D':
+ no_detach = 1;
+ found_args++;
+ break;
+
case 'h':
default:
usage();
@@ -539,12 +546,14 @@ void apply_init_args( int argc, char *ar
/* daemonize */
if (debug_level == 0) {
- if (my_daemon() < 0) {
+ if (!no_detach) {
+ if (my_daemon() < 0) {
- printf("Error - can't fork to background: %s\n", strerror(errno));
- restore_defaults();
- exit(EXIT_FAILURE);
+ printf("Error - can't fork to background: %s\n", strerror(errno));
+ restore_defaults();
+ exit(EXIT_FAILURE);
+ }
}
openlog("batmand", LOG_PID, LOG_DAEMON);

View file

@ -0,0 +1,47 @@
---
batman/linux/modules/gateway.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
--- batmand-r1439.orig/batman/linux/modules/gateway.c
+++ batmand-r1439/batman/linux/modules/gateway.c
@@ -29,6 +29,7 @@ static struct class *batman_class;
static int batgat_open(struct inode *inode, struct file *filp);
static int batgat_release(struct inode *inode, struct file *file);
static int batgat_ioctl( struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg );
+static long batgat_ioctl_unlocked(struct file *file, unsigned int cmd, unsigned long arg );
static void udp_data_ready(struct sock *sk, int len);
@@ -53,7 +54,11 @@ static int proc_clients_read(char *buf,
static struct file_operations fops = {
.open = batgat_open,
.release = batgat_release,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
+ .unlocked_ioctl = batgat_ioctl_unlocked,
+#else
.ioctl = batgat_ioctl,
+#endif
};
@@ -166,6 +171,20 @@ static int batgat_release(struct inode *
}
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
+#include <linux/smp_lock.h>
+static long batgat_ioctl_unlocked(struct file *file, unsigned int cmd, unsigned long arg )
+{
+ int ret;
+
+ lock_kernel();
+ ret = batgat_ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+#endif
+
static int batgat_ioctl( struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg )
{
uint8_t tmp_ip[4];

63
bcp38/Makefile Normal file
View file

@ -0,0 +1,63 @@
#
# Copyright (C) 2014 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
# Please note this is not an officially released version of bcp38
include $(TOPDIR)/rules.mk
PKG_NAME:=bcp38
PKG_VERSION:=4
PKG_RELEASE:=1
include $(INCLUDE_DIR)/package.mk
define Package/bcp38
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
TITLE:=BCP38 compliance
URL:=http://www.github.com/dtaht/bcp38
MAINTAINER:=Dave Taht <d+bcp38@taht.net>
DEPENDS:=+ipset
endef
define Package/bcp38/description
bcp38 implements rfc bcp 38 for home routers.
endef
define Package/bcp38/conffiles
/etc/config/bcp38
endef
define Build/Prepare
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/bcp38/install
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/bcp38.config $(1)/etc/config/bcp38
$(INSTALL_DIR) $(1)/usr/lib/bcp38
$(INSTALL_BIN) ./files/run.sh $(1)/usr/lib/bcp38/run.sh
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) ./files/bcp38.defaults $(1)/etc/uci-defaults/bcp38
endef
define Package/bcp38/postinst
#!/bin/sh
[ -x /etc/uci-defaults/bcp38 ] && /etc/uci-defaults/bcp38 || exit 0
endef
define Package/bcp38/postrm
#!/bin/sh
uci delete firewall.bcp38
uci commit
endef
$(eval $(call BuildPackage,bcp38))

22
bcp38/files/bcp38.config Normal file
View file

@ -0,0 +1,22 @@
config bcp38
option enabled 1
option interface 'ge00'
option detect_upstream 1
list match '127.0.0.0/8'
list match '0.0.0.0/8' # RFC 1700
list match '240.0.0.0/4' # RFC 5745
list match '192.0.2.0/24' # RFC 5737
list match '198.51.100.0/24' # RFC 5737
list match '203.0.113.0/24' # RFC 5737
list match '192.168.0.0/16' # RFC 1918
list match '10.0.0.0/8' # RFC 1918
list match '172.16.0.0/12' # RFC 1918
list match '169.254.0.0/16' # RFC 3927
# list nomatch '172.26.0.0/21' # Example of something not to match
# There is a dhcp trigger to do this for the netmask of a
# double natted connection needed
# I will argue that this level of indirection doesn't scale
# very well - see how to block china as an example
# http://www.okean.com/china.txt

View file

@ -0,0 +1,13 @@
#!/bin/sh
uci -q batch <<-EOT
delete firewall.bcp38
set firewall.bcp38=include
set firewall.bcp38.type=script
set firewall.bcp38.path=/usr/lib/bcp38/run.sh
set firewall.bcp38.family=IPv4
set firewall.bcp38.reload=1
commit firewall
EOT
exit 0

96
bcp38/files/run.sh Executable file
View file

@ -0,0 +1,96 @@
#!/bin/sh
STOP=$1
IPSET_NAME=bcp38-ipv4
IPTABLES_CHAIN=BCP38
. /lib/functions.sh
config_load bcp38
add_bcp38_rule()
{
local subnet="$1"
local action="$2"
if [ "$action" == "nomatch" ]; then
ipset add "$IPSET_NAME" "$subnet" nomatch
else
ipset add "$IPSET_NAME" "$subnet"
fi
}
detect_upstream()
{
local interface="$1"
subnets=$(ip route show dev "$interface" | grep 'scope link' | awk '{print $1}')
for subnet in $subnets; do
# ipset test doesn't work for subnets, so strip out the subnet part
# and test for that; add as exception if there's a match
addr=$(echo $subnet | sed 's|/[0-9]\+$||')
ipset test "$IPSET_NAME" $addr 2>/dev/null && add_bcp38_rule $subnet nomatch
done
}
run() {
local section="$1"
local enabled
local interface
local detect_upstream
config_get_bool enabled "$section" enabled 0
config_get interface "$section" interface
config_get detect_upstream "$section" detect_upstream
if [ "$enabled" -eq "1" -a -n "$interface" -a -z "$STOP" ] ; then
setup_ipset
setup_iptables "$interface"
config_list_foreach "$section" match add_bcp38_rule match
config_list_foreach "$section" nomatch add_bcp38_rule nomatch
[ "$detect_upstream" -eq "1" ] && detect_upstream "$interface"
fi
exit 0
}
setup_ipset()
{
ipset create "$IPSET_NAME" hash:net family ipv4
ipset flush "$IPSET_NAME"
}
setup_iptables()
{
local interface="$1"
iptables -N "$IPTABLES_CHAIN" 2>/dev/null
iptables -F "$IPTABLES_CHAIN" 2>/dev/null
iptables -I output_rule -j "$IPTABLES_CHAIN"
iptables -I input_rule -j "$IPTABLES_CHAIN"
iptables -I forwarding_rule -j "$IPTABLES_CHAIN"
# always accept DHCP traffic
iptables -A "$IPTABLES_CHAIN" -p udp --dport 67:68 --sport 67:68 -j RETURN
iptables -A "$IPTABLES_CHAIN" -o "$interface" -m set --match-set "$IPSET_NAME" dst -j REJECT --reject-with icmp-net-unreachable
iptables -A "$IPTABLES_CHAIN" -i "$interface" -m set --match-set "$IPSET_NAME" src -j DROP
}
destroy_ipset()
{
ipset flush "$IPSET_NAME" 2>/dev/null
ipset destroy "$IPSET_NAME" 2>/dev/null
}
destroy_iptables()
{
iptables -D output_rule -j "$IPTABLES_CHAIN" 2>/dev/null
iptables -D input_rule -j "$IPTABLES_CHAIN" 2>/dev/null
iptables -D forwarding_rule -j "$IPTABLES_CHAIN" 2>/dev/null
iptables -F "$IPTABLES_CHAIN" 2>/dev/null
iptables -X "$IPTABLES_CHAIN" 2>/dev/null
}
destroy_iptables
destroy_ipset
config_foreach run bcp38
exit 0

161
bird/Makefile Normal file
View file

@ -0,0 +1,161 @@
#
# Copyright (C) 2009-2014 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
include $(TOPDIR)/rules.mk
PKG_NAME:=bird
PKG_VERSION:=1.4.3
PKG_RELEASE:=1
PKG_SOURCE:=bird-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=ftp://bird.network.cz/pub/bird
PKG_MD5SUM:=eb7e00b9c1d102ddfcbc19d9cb168511
PKG_BUILD_DEPENDS:=libncurses libreadline
include $(INCLUDE_DIR)/package.mk
define Package/bird/Default
TITLE:=The BIRD Internet Routing Daemon
URL:=http://bird.network.cz/
DEPENDS:=+libpthread
endef
define Package/birdc/Default
TITLE:=The BIRD command-line client
URL:=http://bird.network.cz/
DEPENDS:= +libreadline +libncurses
endef
define Package/bird/Default/description1
BIRD is an internet routing daemon which manages TCP/IP routing tables
with support of modern routing protocols, easy to use configuration
interface and powerful route filtering language. It is lightweight and
efficient and therefore appropriate for small embedded routers.
endef
define Package/bird/Default/description2
In BGP, BIRD supports communities, multiprotocol extensions, MD5
authentication, 32bit AS numbers and could act as a route server or a
route reflector. BIRD also supports multiple RIBs, multiple kernel
routing tables and redistribution between the protocols with a powerful
configuration syntax.
endef
define Package/bird/Default/description3
This is a BIRD command-line client. It is used to send commands to BIRD,
commands can perform simple actions such as enabling/disabling of
protocols, telling BIRD to show various information, telling it to show
a routing table filtered by a filter, or asking BIRD to reconfigure.
Unless you can't afford dependency on ncurses and readline, you
should install BIRD command-line client together with BIRD.
endef
define Package/bird4
$(call Package/bird/Default)
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
TITLE+= (IPv4)
endef
define Package/birdc4
$(call Package/birdc/Default)
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
TITLE+= (IPv4)
DEPENDS+= +bird4
endef
define Package/bird6
$(call Package/bird/Default)
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
TITLE+= (IPv6)
endef
define Package/birdc6
$(call Package/birdc/Default)
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
TITLE+= (IPv6)
DEPENDS+= +bird6
endef
define Package/bird4/description
$(call Package/bird/Default/description1)
This is IPv4 version of BIRD, it supports OSPFv2, RIPv2 and BGP
protocols.
$(call Package/bird/Default/description2)
endef
define Package/birdc4/description
$(call Package/bird/Default/description1)
$(call Package/bird/Default/description3)
endef
define Package/bird6/description
$(call Package/bird/Default/description1)
This is IPv6 version of BIRD, it supports OSPFv3, RIPng and BGP
protocols.
$(call Package/bird/Default/description2)
endef
define Package/birdc6/description
$(call Package/bird/Default/description1)
$(call Package/bird/Default/description3)
endef
CONFIGURE_ARGS += --with-linux-headers="$(LINUX_DIR)"
define Build/Template
$(STAMP_BUILT)-$(2): $(STAMP_PREPARED)
$(call Build/Configure/Default,$(3))
$(call Build/Compile/Default,)
( cd $(PKG_BUILD_DIR); mv -f bird bird$(2); mv -f birdc birdc$(2) )
-$(MAKE) -C $(PKG_BUILD_DIR) clean
touch $$@
$(STAMP_BUILT): $(STAMP_BUILT)-$(2)
define Package/bird$(2)/install
$(INSTALL_DIR) $$(1)/usr/sbin
$(INSTALL_BIN) $$(PKG_BUILD_DIR)/bird$(2) $$(1)/usr/sbin/
$(INSTALL_DIR) $$(1)/etc
$(INSTALL_DATA) ./files/bird$(2).conf $$(1)/etc/
$(INSTALL_DIR) $$(1)/etc/init.d
$(INSTALL_BIN) ./files/bird$(2).init $$(1)/etc/init.d/bird$(2)
endef
define Package/bird$(2)/conffiles
/etc/bird$(2).conf
endef
define Package/birdc$(2)/install
$(INSTALL_DIR) $$(1)/usr/sbin
$(INSTALL_BIN) $$(PKG_BUILD_DIR)/birdc$(2) $$(1)/usr/sbin/
endef
endef
$(eval $(call Build/Template,bird4,4, --disable-ipv6))
$(eval $(call Build/Template,bird6,6, --enable-ipv6))
$(eval $(call BuildPackage,bird4))
$(eval $(call BuildPackage,birdc4))
$(eval $(call BuildPackage,bird6))
$(eval $(call BuildPackage,birdc6))

121
bird/files/bird4.conf Normal file
View file

@ -0,0 +1,121 @@
# THIS CONFIG FILE IS NOT A COMPLETE DOCUMENTATION
# PLEASE LOOK IN THE BIRD DOCUMENTATION FOR MORE INFO
# However, most of options used here are just for example
# and will be removed in real-life configs.
log syslog all;
# Override router ID
#router id 192.168.0.1;
# Turn on global debugging of all protocols
#debug protocols all;
# Define a route filter...
# filter test_filter {
# if net ~ 10.0.0.0/16 then accept;
# else reject;
# }
# The direct protocol automatically generates device routes to all network
# interfaces. Can exist in as many instances as you wish if you want to
# populate multiple routing tables with device routes. Because device routes
# are handled by Linux kernel, this protocol is usually not needed.
# protocol direct {
# interface "*"; # Restrict network interfaces it works with
# }
# This pseudo-protocol performs synchronization between BIRD's routing
# tables and the kernel. You can run multiple instances of the kernel
# protocol and synchronize different kernel tables with different BIRD tables.
protocol kernel {
# learn; # Learn all alien routes from the kernel
# persist; # Don't remove routes on bird shutdown
scan time 20; # Scan kernel routing table every 20 seconds
# import none; # Default is import all
# export all; # Default is export none
}
# This pseudo-protocol watches all interface up/down events.
protocol device {
scan time 10; # Scan interfaces every 10 seconds
}
# Static routes (again, there can be multiple instances, so that you
# can disable/enable various groups of static routes on the fly).
protocol static {
# export all; # Default is export none
# route 0.0.0.0/0 via 62.168.0.13;
# route 10.0.0.0/8 reject;
# route 192.168.0.0/16 reject;
}
#protocol rip {
# disabled;
# import all;
# export all;
# export filter test_filter;
# port 1520;
# period 7;
# infinity 16;
# garbage time 60;
# interface "*" { mode broadcast; };
# honor neighbor;
# honor always;
# honor never;
# authentication none;
#}
#protocol ospf {
# disabled;
# import all;
# export all;
# export where source = RTS_STATIC;
# area 0 {
# interface "eth*" {
# cost 10;
# hello 3;
# retransmit 2;
# wait 5;
# dead 20;
# type broadcast;
# authentication simple;
# password "pass";
# };
# };
#}
#protocol bgp {
# disabled;
# import all;
# export all;
# export where source = RTS_STATIC;
# local as 65000;
# neighbor 192.168.1.1 as 65001;
# multihop 20 via 192.168.2.1;
# hold time 240;
# startup hold time 240;
# connect retry time 120;
# keepalive time 80; # defaults to hold time / 3
# start delay time 5; # How long do we wait before initial connect
# error wait time 60, 300;# Minimum and maximum time we wait after an error (when consecutive
# # errors occur, we increase the delay exponentially ...
# error forget time 300; # ... until this timeout expires)
# disable after error; # Disable the protocol automatically when an error occurs
# next hop self; # Disable next hop processing and always advertise our local address as nexthop
# source address 62.168.0.14; # What local address we use for the TCP connection
# password "secret" # Password used for MD5 authentication
# rr client; # I am a route reflector and the neighor is my client
# rr cluster id 1.0.0.1 # Use this value for cluster id instead of my router id
# };
#}

26
bird/files/bird4.init Normal file
View file

@ -0,0 +1,26 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2010-2014 OpenWrt.org
BIRD="bird4"
START=99
STOP=10
SERVICE_DAEMONIZE=1
SERVICE_USE_PID=1
SERVICE_PID_FILE="/var/run/$BIRD.pid"
BIRD_BIN="/usr/sbin/$BIRD"
BIRD_CONF="/etc/$BIRD.conf"
start() {
service_start $BIRD_BIN -d -c $BIRD_CONF -P $SERVICE_PID_FILE
}
stop() {
service_stop $BIRD_BIN
}
reload() {
service_reload $BIRD_BIN
}

121
bird/files/bird6.conf Normal file
View file

@ -0,0 +1,121 @@
# THIS CONFIG FILE IS NOT A COMPLETE DOCUMENTATION
# PLEASE LOOK IN THE BIRD DOCUMENTATION FOR MORE INFO
# However, most of options used here are just for example
# and will be removed in real-life configs.
log syslog all;
# Override router ID
#router id 192.168.0.1;
# Turn on global debugging of all protocols
#debug protocols all;
# Define a route filter...
# filter test_filter {
# if net ~ 10.0.0.0/16 then accept;
# else reject;
# }
# The direct protocol automatically generates device routes to all network
# interfaces. Can exist in as many instances as you wish if you want to
# populate multiple routing tables with device routes. Because device routes
# are handled by Linux kernel, this protocol is usually not needed.
# protocol direct {
# interface "*"; # Restrict network interfaces it works with
# }
# This pseudo-protocol performs synchronization between BIRD's routing
# tables and the kernel. You can run multiple instances of the kernel
# protocol and synchronize different kernel tables with different BIRD tables.
protocol kernel {
# learn; # Learn all alien routes from the kernel
# persist; # Don't remove routes on bird shutdown
scan time 20; # Scan kernel routing table every 20 seconds
# import none; # Default is import all
# export all; # Default is export none
}
# This pseudo-protocol watches all interface up/down events.
protocol device {
scan time 10; # Scan interfaces every 10 seconds
}
# Static routes (again, there can be multiple instances, so that you
# can disable/enable various groups of static routes on the fly).
protocol static {
# export all; # Default is export none
# route 0.0.0.0/0 via 62.168.0.13;
# route 10.0.0.0/8 reject;
# route 192.168.0.0/16 reject;
}
#protocol rip {
# disabled;
# import all;
# export all;
# export filter test_filter;
# port 1520;
# period 7;
# infinity 16;
# garbage time 60;
# interface "*" { mode broadcast; };
# honor neighbor;
# honor always;
# honor never;
# authentication none;
#}
#protocol ospf {
# disabled;
# import all;
# export all;
# export where source = RTS_STATIC;
# area 0 {
# interface "eth*" {
# cost 10;
# hello 3;
# retransmit 2;
# wait 5;
# dead 20;
# type broadcast;
# authentication simple;
# password "pass";
# };
# };
#}
#protocol bgp {
# disabled;
# import all;
# export all;
# export where source = RTS_STATIC;
# local as 65000;
# neighbor 192.168.1.1 as 65001;
# multihop 20 via 192.168.2.1;
# hold time 240;
# startup hold time 240;
# connect retry time 120;
# keepalive time 80; # defaults to hold time / 3
# start delay time 5; # How long do we wait before initial connect
# error wait time 60, 300;# Minimum and maximum time we wait after an error (when consecutive
# # errors occur, we increase the delay exponentially ...
# error forget time 300; # ... until this timeout expires)
# disable after error; # Disable the protocol automatically when an error occurs
# next hop self; # Disable next hop processing and always advertise our local address as nexthop
# source address 62.168.0.14; # What local address we use for the TCP connection
# password "secret" # Password used for MD5 authentication
# rr client; # I am a route reflector and the neighor is my client
# rr cluster id 1.0.0.1 # Use this value for cluster id instead of my router id
# };
#}

26
bird/files/bird6.init Normal file
View file

@ -0,0 +1,26 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2010-2014 OpenWrt.org
BIRD="bird6"
START=99
STOP=10
SERVICE_DAEMONIZE=1
SERVICE_USE_PID=1
SERVICE_PID_FILE="/var/run/$BIRD.pid"
BIRD_BIN="/usr/sbin/$BIRD"
BIRD_CONF="/etc/$BIRD.conf"
start() {
service_start $BIRD_BIN -d -c $BIRD_CONF -P $SERVICE_PID_FILE
}
stop() {
service_stop $BIRD_BIN
}
reload() {
service_reload $BIRD_BIN
}

View file

@ -1,129 +0,0 @@
#
# Copyright (C) 2009-2017 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
include $(TOPDIR)/rules.mk
PKG_NAME:=bird2
PKG_VERSION:=2.14
PKG_RELEASE:=1
PKG_SOURCE:=bird-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=ftp://bird.network.cz/pub/bird
PKG_HASH:=b0b9f6f8566541b9be4af1f0cac675c5a3785601a55667a7ec3d7de29735a786
PKG_MAINTAINER:=Toke Høiland-Jørgensen <toke@toke.dk>
PKG_LICENSE:=GPL-2.0-or-later
PKG_BUILD_DEPENDS:=ncurses readline
PKG_BUILD_DIR:=$(BUILD_DIR)/bird-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
define Package/bird2/Default/description
BIRD is an internet routing daemon which manages TCP/IP routing tables
with support of modern routing protocols, easy to use configuration
interface and powerful route filtering language. It is lightweight and
efficient and therefore appropriate for small embedded routers.
endef
define Package/bird2
TITLE:=The BIRD Internet Routing Daemon (v2)
URL:=http://bird.network.cz/
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
DEPENDS:=+libpthread
CONFLICTS:=bird1-ipv4 bird1-ipv6 bird4 bird6
endef
define Package/bird2c
TITLE:=The BIRD command-line client (v2)
URL:=http://bird.network.cz/
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
DEPENDS:=+bird2 +libreadline +libncurses
CONFLICTS:=bird1c-ipv4 bird1c-ipv6 birdc4 birdc6
endef
define Package/bird2cl
TITLE:=The BIRD lightweight command-line client (v2)
URL:=http://bird.network.cz/
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
DEPENDS:=+bird2
CONFLICTS:=bird1cl-ipv4 bird1cl-ipv6 birdcl4 birdcl6
endef
define Package/bird2/description
$(call Package/bird2/Default/description)
BIRD supports OSPFv2, RIPv2, Babel and BGP protocols for IPv4 and
OSPFv3, RIPng, Babel and BGP protocols for IPv6.
In BGP, BIRD supports communities, multiprotocol extensions, MD5
authentication, 32bit AS numbers and could act as a route server or a
route reflector. BIRD also supports multiple RIBs, multiple kernel
routing tables and redistribution between the protocols with a powerful
configuration syntax.
This is the 2.0 branch of Bird which integrates support for IPv4 and IPv6
into a single branch, and also adds support for the Babel routing protocol.
endef
define Package/bird2c/description
$(call Package/bird2/Default/description)
This is a BIRD command-line client. It is used to send commands to BIRD,
commands can perform simple actions such as enabling/disabling of
protocols, telling BIRD to show various information, telling it to show
a routing table filtered by a filter, or asking BIRD to reconfigure.
Unless you can't afford dependency on ncurses and readline, you
should install BIRD command-line client together with BIRD.
endef
define Package/bird2cl/description
$(call Package/bird2/Default/description)
This is a BIRD lightweight command-line client. It is used to send commands
to BIRD, commands can perform simple actions such as enabling/disabling of
protocols, telling BIRD to show various information, telling it to show
a routing table filtered by a filter, or asking BIRD to reconfigure.
endef
CONFIGURE_ARGS += --disable-libssh
define Package/bird2/conffiles
/etc/bird.conf
/etc/bird4.conf
/etc/bird6.conf
endef
define Package/bird2/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bird $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/etc
$(INSTALL_DATA) ./files/bird.conf $(1)/etc/
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/bird.init $(1)/etc/init.d/bird
endef
define Package/bird2c/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/birdc $(1)/usr/sbin/
endef
define Package/bird2cl/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/birdcl $(1)/usr/sbin/
endef
$(eval $(call BuildPackage,bird2))
$(eval $(call BuildPackage,bird2c))
$(eval $(call BuildPackage,bird2cl))

View file

@ -1,332 +0,0 @@
/*
* This is an example configuration file for MB-BGP setting
*/
log syslog all;
# debug protocols all;
router id 192.168.1.1;
ipv4 table master4;
ipv6 table master6;
ipv4 table mcast4;
ipv6 table mcast6;
ipv4 table mtab4;
ipv6 table mtab6;
vpn4 table vpntab4;
vpn6 table vpntab6;
vpn4 table vpn4mc;
vpn6 table vpn6mc;
flow4 table flowtab4;
flow6 table flowtab6;
protocol device {
}
protocol kernel kernel4 {
ipv4 {
export all;
};
}
protocol kernel kernel6 {
ipv6 {
export all;
};
}
protocol static static4 {
ipv4;
route 10.10.0.0/24 via 192.168.1.2;
route 10.10.1.0/24 via 192.168.1.2 { bgp_large_community.add((10,20,30)); bgp_large_community.add((10,(20*3),10)); };
}
protocol static static6 {
ipv6;
route 2001:db8:10:10::/64 via 2001:db8:1:1::10;
route 2001:db8:10:11::/64 via 2001:db8:1:1::10;
route 2001:db8:1:1::/64 via fe80::ec9b:67ff:fe60:fd5d % ve1;
}
# VPNv4 routes with MPLS labels
protocol static statvpn4 {
vpn4;
route 10:10 10.20.0.0/24 via 192.168.1.2 mpls 210;
route 10:10 10.20.1.0/24 via 192.168.1.2 mpls 210;
route 10:20 10.20.0.0/24 via 192.168.1.2 mpls 220;
route 10:20 10.20.1.0/24 via 192.168.1.2 mpls 220;
}
protocol static statvpn6 {
vpn6;
route 10:10 2001:db8:20:10::/64 via 2001:db8:1:1::10 mpls 200/210;
route 10:10 2001:db8:20:11::/64 via 2001:db8:1:1::10 mpls 200/210;
route 10:20 2001:db8:20:10::/64 via 2001:db8:1:1::10 mpls 200/220;
route 10:20 2001:db8:20:11::/64 via 2001:db8:1:1::10 mpls 200/220;
}
# RFC 5575 flow specification
protocol static flowstat4 {
flow4;
route flow4 {
dst 10.0.0.0/8;
proto = 23;
dport > 24 && < 30 || 40..50,60..70,80;
sport > 24 && < 30 || = 40 || 50,60..70,80;
icmp type 80;
icmp code 90;
tcp flags 0x03/0x0f;
length 2048..65535;
dscp = 63;
fragment dont_fragment, is_fragment || !first_fragment;
};
route flow4 {
dst 11.0.0.0/8;
proto = 0x12;
sport > 0x5678 && < 0x9abc || 0xdef0 || 0x1234,0x5678,0x9abc..0xdef0;
dport = 50;
tcp flags 0x000/0xf00;
};
route flow4 {
dst 12.0.0.0/32;
tcp flags ! 0/0x999;
};
route flow4 {
dst 220.0.254.0/24;
tcp flags 0x99/0x999;
};
route flow4 {
dst 220.0.254.192/28;
tcp flags ! 0xfff/0xfff;
};
route flow4 {
dst 15.0.0.0/8;
tcp flags ! 0x999/0x999;
};
}
protocol static flowstat6 {
flow6;
route flow6 {
dst fec0:1122:3344:5566::1/128;
src 0000:0000:0000:0001:1234:5678:9800:0000/101 offset 63;
next header = 23;
sport 24..30, 42 || 50,60,70..80;
dport = 50;
tcp flags 0x03/0x0f, !0/0xff || 0x33/0x33;
fragment !is_fragment || !first_fragment;
label 0xaaaa/0xaaaa && 0x33/0x33;
};
route flow6 {
dst fec0:1122:3344:5566::1/128;
src ::1:1234:5678:9800:0/101 offset 63;
next header = 23;
dport = 50;
sport > 24 && < 30 || = 40 || = 50 || = 60 || >= 70 && <= 80;
tcp flags 0x3/0x3 && 0x0/0xc;
};
}
protocol pipe {
table master4;
peer table mcast4;
import none;
export where source = RTS_OSPF;
}
protocol pipe {
table master6;
peer table mcast6;
import none;
export where source = RTS_OSPF;
}
protocol ospf v2 ospf4 {
ipv4 {
import all;
# export where source = RTS_STATIC;
};
area 0 {
interface "ve0" { stub; };
interface "ve1" { hello 5; type ptp; };
interface "ve2" { hello 5; type bcast; ttl security; };
interface "ve3" { hello 5; type bcast; ttl security; };
};
}
protocol ospf v3 ospf6 {
ipv6 {
import all;
# export where source = RTS_STATIC;
};
area 0 {
interface "ve0" { stub; };
interface "ve1" { hello 5; type ptp; };
interface "ve2" { hello 5; type bcast; };
};
}
protocol bgp {
local 192.168.11.1 as 1000;
neighbor 192.168.11.2 as 2000;
# local 192.168.1.1 as 1000;
# neighbor 192.168.2.1 as 2000;
# multihop;
# rr client;
# strict bind;
# debug all;
# regular IPv4 unicast (1/1)
ipv4 {
# connects to master4 table by default
import all;
export where source ~ [ RTS_STATIC, RTS_BGP ];
};
# regular IPv6 unicast (2/1)
ipv6 {
# connects to master6 table by default
import all;
export where source ~ [ RTS_STATIC, RTS_BGP ];
# next hop address 2001:db8:1:1::1;
};
# IPv4 multicast topology (1/2)
ipv4 multicast {
# explicit IPv4 table
table mcast4;
import all;
export all;
};
# IPv6 multicast topology (2/2)
ipv6 multicast {
# explicit IPv6 table
table mcast6;
import all;
export all;
# next hop address 2001:db8:1:1::1;
};
# IPv4 with MPLS labels (1/4)
ipv4 mpls {
# explicit IPv4 table
table mtab4;
import all;
export all;
};
# IPv6 with MPLS labels (2/4)
ipv6 mpls {
# explicit IPv6 table
table mtab6;
import all;
export all;
# allows IPv4 next hops (6PE)
# extended next hop;
};
# VPNv4 with MPLS labels (1/128)
vpn4 mpls {
# connects to vpntab4 table by default
import all;
export all;
};
# VPNv6 with MPLS labels (2/128)
vpn6 mpls {
# connects to vpntab6 table by default
import all;
export all;
};
# VPNv4 multicast topology (1/129)
vpn4 multicast {
table vpn4mc;
import all;
export all;
};
# VPNv6 multicast topology (2/129)
vpn6 multicast {
table vpn6mc;
import all;
export all;
};
# IPv4 Flowspec (1/133)
flow4 {
# connects to flowtab4 table by default
import all;
export all;
};
# IPv6 Flowspec (2/133)
flow6 {
# connects to flowtab6 table by default
import all;
export all;
};
}
protocol bgp {
local 192.168.1.1 as 1000;
neighbor 192.168.3.1 as 1000;
multihop;
rr client;
ipv4 {
import all;
export where source ~ [ RTS_STATIC, RTS_BGP ];
};
ipv6 {
import all;
export where source ~ [ RTS_STATIC, RTS_BGP ];
next hop address 2001:db8:1:1::1;
};
}
protocol bgp {
local 2001:db8:1:1::1 as 1000;
neighbor 2001:db8:4:1::1 as 1000;
multihop;
rr client;
ipv4 {
import all;
export where source ~ [ RTS_STATIC, RTS_BGP ];
next hop address 192.168.4.1;
};
ipv6 {
import all;
export where source ~ [ RTS_STATIC, RTS_BGP ];
};
}

View file

@ -1,25 +0,0 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2010-2017 OpenWrt.org
USE_PROCD=1
START=70
STOP=10
BIRD_BIN="/usr/sbin/bird"
BIRD_CONF="/etc/bird.conf"
BIRD_PID_FILE="/var/run/bird.pid"
start_service() {
mkdir -p /var/run
procd_open_instance
procd_set_param command $BIRD_BIN -f -c $BIRD_CONF -P $BIRD_PID_FILE
procd_set_param file "$BIRD_CONF"
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param respawn
procd_close_instance
}
reload_service() {
procd_send_signal bird
}

View file

@ -1,11 +0,0 @@
--- a/proto/ospf/topology.h
+++ b/proto/ospf/topology.h
@@ -41,7 +41,7 @@ struct top_hash_entry
u8 mode; /* LSA generated during RT calculation (LSA_RTCALC or LSA_STALE)*/
u8 nhs_reuse; /* Whether nhs nodes can be reused during merging.
See a note in rt.c:add_cand() */
-};
+} PACKED;
/* Prevents ospf_hash_find() to ignore the entry, for p->lsrqh and p->lsrth */

155
bmx6/Makefile Normal file
View file

@ -0,0 +1,155 @@
# Copyright (C) 2011 Fundacio Privada per a la Xarxa Oberta, Lliure i Neutral guifi.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# The full GNU General Public License is included in this distribution in
# the file called "COPYING".
#
# Contibutors:
# Axel Neumann, Simó Albert i Beltran, Pau Escrich
#
include $(TOPDIR)/rules.mk
PKG_NAME:=bmx6
PKG_SOURCE_PROTO:=git
#PKG_SOURCE_URL:=git://bmx6.net/bmx6.git
PKG_SOURCE_URL:=git://github.com/axn/bmx6.git
PKG_REV:=8f26909e8808ed7fab0359afc15a3e44563fbd40
PKG_VERSION:=r2015061604
PKG_RELEASE:=4
PKG_SOURCE_VERSION:=$(PKG_REV)
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SOURCE_SUBDIR)
include $(INCLUDE_DIR)/package.mk
TARGET_CFLAGS += $(FPIC)
MAKE_ARGS += \
EXTRA_CFLAGS="$(TARGET_CFLAGS) -I. -I$(STAGING_DIR)/usr/include -DNO_DEBUG_ALL -DNO_DEBUG_DUMP" \
EXTRA_LDFLAGS="-L$(STAGING_DIR)/usr/lib " \
GIT_REV="$(PKG_REV)" \
CC="$(TARGET_CC)" \
INSTALL_DIR="$(PKG_INSTALL_DIR)" \
STRIP="/bin/false" \
build_all
define Package/bmx6/Default
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
TITLE:=BMX6 layer 3 routing daemon
URL:=http://bmx6.net/
MAINTAINER:=Axel Neumann <neumann@cgws.de>
DEPENDS:=+kmod-ip6-tunnel +kmod-iptunnel6 +kmod-tun
endef
define Package/bmx6/description
BMX6 layer 3 routing daemon supporting IPv4, IPv6, and IPv4 over IPv6
endef
define Package/bmx6
$(call Package/bmx6/Default)
MENU:=1
endef
define Package/bmx6-uci-config
$(call Package/bmx6/Default)
DEPENDS:=bmx6 +libuci
TITLE:=configuration plugin based on uci (recommended!)
endef
define Package/bmx6-json
$(call Package/bmx6/Default)
DEPENDS:=bmx6 +libjson
TITLE:=json plugin based on jsonc
endef
define Package/bmx6-sms
$(call Package/bmx6/Default)
DEPENDS:=bmx6
TITLE:=sms plugin
endef
#define Package/bmx6-quagga
# $(call Package/bmx6/Default)
# DEPENDS:=bmx6 +qmp-quagga @BROKEN
# TITLE:=bmx6 quagga plugin to redistribute/export routes (needs manet/bmx6 patched quagga 0.99.21)
#endef
define Package/bmx6-table
$(call Package/bmx6/Default)
DEPENDS:=bmx6
TITLE:=bmx6 table plugin to automatic announce routing-table routes via ip6ip tunnels
endef
define Build/Configure
mkdir -p $(PKG_INSTALL_DIR)
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_ARGS)
endef
define Package/bmx6/install
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bmx6 $(1)/usr/sbin/bmx6
endef
define Package/bmx6-uci-config/conffiles
/etc/config/bmx6
endef
define Package/bmx6-uci-config/install
$(INSTALL_DIR) $(1)/usr/lib $(1)/etc/config $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx6_uci_config/bmx6_config.so $(1)/usr/lib/bmx6_config.so
$(INSTALL_BIN) ./files/etc/init.d/bmx6 $(1)/etc/init.d/bmx6
$(INSTALL_DATA) ./files/etc/config/bmx6 $(1)/etc/config/bmx6
endef
define Package/bmx6-json/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx6_json/bmx6_json.so $(1)/usr/lib/bmx6_json.so
endef
define Package/bmx6-sms/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx6_sms/bmx6_sms.so $(1)/usr/lib/bmx6_sms.so
endef
define Package/bmx6-table/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx6_table/bmx6_table.so $(1)/usr/lib/bmx6_table.so
endef
#define Package/bmx6-quagga/install
# $(INSTALL_DIR) $(1)/usr/lib
# $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx6_quagga/bmx6_quagga.so $(1)/usr/lib/bmx6_quagga.so
#endef
$(eval $(call BuildPackage,bmx6))
$(eval $(call BuildPackage,bmx6-uci-config))
$(eval $(call BuildPackage,bmx6-json))
$(eval $(call BuildPackage,bmx6-sms))
#$(eval $(call BuildPackage,bmx6-quagga))
$(eval $(call BuildPackage,bmx6-table))

View file

@ -0,0 +1,82 @@
# for more information:
# http://bmx6.net/projects/bmx6/wiki
# options execute: bmx6 --help
config 'bmx6' 'general'
# option 'runtimeDir' '/var/run/bmx6'
# option 'tun4Address' '10.202.0.116/32'
# option 'tun4Address' '10.254.10.0/32'
# option 'tun6Address' '2012:0:0:1000::1/64'
#config 'ipVersion' 'ipVersion'
# option 'ipVersion' '6' # default is 4
# option 'throwRules' '0'
#config 'plugin'
# option 'plugin' 'bmx6_config.so'
#config 'plugin'
# option 'plugin' 'bmx6_json.so'
#config 'plugin'
# option 'plugin' 'bmx6_sms.so'
config 'dev' 'mesh_1'
option 'dev' 'eth0.12'
config 'dev' 'mesh_2'
option 'dev' 'ath0.12'
#config 'hna' 'my_global_prefix'
# option 'hna' '2012:0:0:74:0:0:0:0/64'
#config 'tunOut'
# option 'tunOut' 'ip6'
# option 'network' '2012::/16'
# option 'exportDistance' '0'
#config 'tunOut'
# option 'tunOut' 'ip4'
# option 'network' '10.254.0.0/16'
# option 'exportDistance' '0' # requires quagga plugin !
# option 'minPrefixLen' '27'
#config 'plugin'
# option 'plugin' 'bmx6_quagga.so'
#config 'redistribute'
# option 'redistribute' 'ospf6'
# option 'network' '10.0.0.0/8'
# option 'minPrefixLen' '10'
# option 'bandwidth' '10000000'
# option 'ospf6' '1'
# option 'aggregatePrefixLen' '16'
#config 'redistribute'
# option 'redistribute' 'bgp'
# option 'network' '0.0.0.0/0'
# option 'minPrefixLen' '0'
# option 'maxPrefixLen' '24'
# option 'bandwidth' '10000000'
# option 'bgp' '1'
# option 'aggregatePrefixLen' '8'

41
bmx6/files/etc/init.d/bmx6 Executable file
View file

@ -0,0 +1,41 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2011 Fundacio Privada per a la Xarxa Oberta, Lliure i Neutral guifi.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# The full GNU General Public License is included in this distribution in
# the file called "COPYING".
START=91
BIN=/usr/sbin/bmx6
CONF=/etc/config/bmx6
PID=/var/run/bmx6/pid
start() {
cd /root/
while pgrep -f mac80211.sh ; do sleep 1; done
ulimit -c 20000
$BIN -f $CONF -d0 > /dev/null &
}
stop() {
start-stop-daemon -p $PID -K
}
restart() {
stop; sleep 3; start
}

View file

@ -1,163 +0,0 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=bmx7
PKG_VERSION:=7.1.1
PKG_RELEASE:=5
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/bmx-routing/bmx7/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=5f88df1c95e5cb842a6016bb1604e3e7f6097c63c5c9916edc3c84e96d4f5f65
PKG_MAINTAINER:=Axel Neumann <neumann@cgws.de>
PKG_LICENSE:=GPL-2.0-or-later
PKG_LICENSE_FILES:=LICENSE
PKG_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/package.mk
TARGET_CFLAGS += $(FPIC)
MAKE_ARGS += EXTRA_CFLAGS="$(TARGET_CFLAGS) \
-I. \
-I$(STAGING_DIR)/usr/include \
-DCRYPTLIB=MBEDTLS_2_8_0 \
-DCORE_LIMIT=20000 \
-DTRAFFIC_DUMP \
-DNO_TRACE_FUNCTION_CALLS \
-DBMX7_LIB_IWINFO" \
EXTRA_LDFLAGS="$(TARGET_LDFLAGS) \
-L$(STAGING_DIR)/usr/lib -liwinfo" \
GIT_REV="$(PKG_REV)" \
CC="$(TARGET_CC)" \
INSTALL_DIR="$(PKG_INSTALL_DIR)" \
build_all
MAKE_PATH:=src
define Package/bmx7/Default
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
TITLE:=BMX7 layer 3 routing daemon
URL:=https://github.com/bmx-routing/bmx7
DEPENDS:=+zlib +libmbedtls +libiwinfo
endef
define Package/bmx7/description
BMX7 routing daemon supporting securely-entrusted IPv6 (and IPv4in6) routing
endef
define Package/bmx7
$(call Package/bmx7/Default)
MENU:=1
endef
define Package/bmx7-uci-config
$(call Package/bmx7/Default)
DEPENDS:=bmx7 +libuci
TITLE:=configuration plugin based on uci (recommended!)
endef
define Package/bmx7-iwinfo
$(call Package/bmx7/Default)
DEPENDS:=bmx7 +libiwinfo
TITLE:=link characteristics plugin via libiwinfo (recommended!)
endef
define Package/bmx7-topology
$(call Package/bmx7/Default)
DEPENDS:=bmx7
TITLE:=topology plugin
endef
define Package/bmx7-json
$(call Package/bmx7/Default)
DEPENDS:=bmx7 +libjson-c
TITLE:=json plugin based on json-c
endef
define Package/bmx7-sms
$(call Package/bmx7/Default)
DEPENDS:=bmx7
TITLE:=sms plugin
endef
define Package/bmx7-tun
$(call Package/bmx7/Default)
DEPENDS:=bmx7 +kmod-ip6-tunnel +kmod-iptunnel6 +kmod-tun
TITLE:=ipip-based tunnel plugin (recommended!)
endef
define Package/bmx7-table
$(call Package/bmx7/Default)
DEPENDS:=bmx7 +bmx7-tun
TITLE:=plugin to announce routes from tables via tunnels
endef
define Package/bmx7/install
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/bmx7 $(1)/usr/sbin/bmx7
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) $(MAKE_ARGS)
endef
define Package/bmx7-uci-config/conffiles
/etc/config/bmx7
/etc/bmx7
endef
define Package/bmx7-uci-config/install
$(INSTALL_DIR) $(1)/usr/lib $(1)/etc/config $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/lib/bmx7_uci_config/bmx7_config.so \
$(1)/usr/lib/bmx7_config.so
$(INSTALL_BIN) ./files/etc/init.d/bmx7 $(1)/etc/init.d/bmx7
$(INSTALL_DATA) ./files/etc/config/bmx7 $(1)/etc/config/bmx7
endef
define Package/bmx7-iwinfo/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/lib/bmx7_iwinfo/bmx7_iwinfo.so \
$(1)/usr/lib/bmx7_iwinfo.so
endef
define Package/bmx7-topology/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/lib/bmx7_topology/bmx7_topology.so \
$(1)/usr/lib/bmx7_topology.so
endef
define Package/bmx7-json/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/lib/bmx7_json/bmx7_json.so \
$(1)/usr/lib/bmx7_json.so
endef
define Package/bmx7-sms/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/lib/bmx7_sms/bmx7_sms.so \
$(1)/usr/lib/bmx7_sms.so
endef
define Package/bmx7-tun/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/lib/bmx7_tun/bmx7_tun.so \
$(1)/usr/lib/bmx7_tun.so
endef
define Package/bmx7-table/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/lib/bmx7_table/bmx7_table.so \
$(1)/usr/lib/bmx7_table.so
endef
$(eval $(call BuildPackage,bmx7))
$(eval $(call BuildPackage,bmx7-uci-config))
$(eval $(call BuildPackage,bmx7-iwinfo))
$(eval $(call BuildPackage,bmx7-topology))
$(eval $(call BuildPackage,bmx7-json))
$(eval $(call BuildPackage,bmx7-sms))
$(eval $(call BuildPackage,bmx7-table))
$(eval $(call BuildPackage,bmx7-tun))

View file

@ -1,47 +0,0 @@
# for more information:
# https://github.com/bmx-routing/bmx7/
# options execute: bmx7 --help
config 'bmx7' 'general'
# option 'runtimeDir' '/var/run/bmx7'
# option 'trustedNodesDir' '/etc/bmx7/trustedNodes'
#config 'plugin'
# option 'plugin' 'bmx7_config.so'
#config 'plugin'
# option 'plugin' 'bmx7_json.so'
#config 'plugin'
# option 'plugin' 'bmx7_sms.so'
#config 'plugin'
# option 'plugin' 'bmx7_iwinfo.so'
config 'dev' 'mesh_1'
option 'dev' 'br-lan'
config 'dev' 'mesh_2'
option 'dev' 'wlan0'
#config 'plugin'
# option 'plugin' 'bmx7_tun.so'
#config 'plugin'
# option 'plugin' 'bmx7_table.so'
#config 'tunDev' default
# option 'tunDev' 'default'
# option 'tun6Address' '2012:0:0:6666::1/64'
# option 'tun4Address' '10.66.66.1/24'
#config 'tunOut'
# option 'tunOut' 'ip6'
# option 'network' '2012::/16'
# option 'exportDistance' '0'
#config 'tunOut'
# option 'tunOut' 'ip4'
# option 'network' '10.0.0.0/9'
# option 'minPrefixLen' '27'

View file

@ -1,28 +0,0 @@
#!/bin/sh /etc/rc.common
START=91
USE_PROCD=1
BIN=/usr/sbin/bmx7
CONF=/etc/config/bmx7
start_service() {
cd /root/ || return
while pgrep -f mac80211.sh ; do sleep 1; done
procd_open_instance "bmx7"
procd_set_param command "$BIN"
procd_append_param command -f "$CONF" -d0
procd_set_param limits core=20000
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param respawn
procd_close_instance
}
reload_service() {
"$BIN" -c configReload
}
service_triggers() {
procd_add_reload_trigger "bmx7"
}

View file

@ -1,11 +0,0 @@
--- a/src/bmx.h
+++ b/src/bmx.h
@@ -290,7 +290,7 @@ enum ADGSN {
#define SUCCESS 0
#define FAILURE -1
-const void* FAILURE_PTR;
+extern const void* FAILURE_PTR;
#define MAX_SELECT_TIMEOUT_MS 1100 /* MUST be smaller than (1000/2) to fit into max tv_usec */

View file

@ -1,38 +0,0 @@
--- a/src/schedule.c
+++ b/src/schedule.c
@@ -375,7 +375,9 @@ loop4Event:
continue;
}
+#ifdef SIOCGSTAMP
ioctl(pb.i.iif->rx_mcast_sock, SIOCGSTAMP, &(pb.i.tv_stamp));
+#endif
rx_packet(&pb);
@@ -401,7 +403,9 @@ loop4Event:
continue;
}
+#ifdef SIOCGSTAMP
ioctl(pb.i.iif->rx_fullbrc_sock, SIOCGSTAMP, &(pb.i.tv_stamp));
+#endif
rx_packet(&pb);
@@ -451,10 +455,15 @@ loop4Event:
}
}
#endif
+#ifdef SIOCGSTAMP
if (tv_stamp == NULL)
ioctl(pb.i.iif->unicast_sock, SIOCGSTAMP, &(pb.i.tv_stamp));
else
timercpy(&(pb.i.tv_stamp), tv_stamp);
+#else
+ if (tv_stamp)
+ timercpy(&(pb.i.tv_stamp), tv_stamp);
+#endif
rx_packet(&pb);

View file

@ -1,146 +0,0 @@
#
# Copyright (C) 2014,2015 Hyperboria.net
#
# You may redistribute this program and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=cjdns
PKG_VERSION:=v21.1
PKG_RELEASE:=5
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/cjdelisle/cjdns/tar.gz/$(PKG_NAME)-$(PKG_VERSION)?
PKG_HASH:=a6158ce7847159aa44e86f74ccc7b6ded6910a230ed8f3830db53cda5838f0b0
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_NAME)-$(PKG_VERSION)
PKG_MAINTAINER:=William Fleurant <meshnet@protonmail.com>
PKG_LICENSE:=GPL-3.0-or-later
PKG_LICENSE_FILES:=LICENSE
include $(INCLUDE_DIR)/package.mk
define Package/cjdns
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
TITLE:=Encrypted near-zero-conf mesh routing protocol
URL:=https://github.com/cjdelisle/cjdns
DEPENDS:=@!arc @IPV6 +kmod-tun +libnl-tiny +libpthread +librt \
+libuci-lua +lua-bencode +dkjson +luasocket +lua-sha2
endef
define Package/cjdns/description
Cjdns implements an encrypted IPv6 network using public-key cryptography \
for address allocation and a distributed hash table for routing. \
This provides near-zero-configuration networking, and prevents many \
of the security and scalability issues that plague existing networks.
endef
define Package/cjdns-tests
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
TITLE:=cjdns test cases
URL:=https://github.com/cjdelisle/cjdns
DEPENDS:=+libpthread +librt @!arc
endef
define Package/cjdns-test/description
Builds cjdns test cases binary test_testcjdroute_c
endef
define Build/Configure
endef
PKG_DO_VARS:=CJDNS_RELEASE_VERSION=$(PKG_SOURCE_VERSION)
ifneq ($(CONFIG_KERNEL_SECCOMP_FILTER),y)
PKG_DO_VARS+= Seccomp_NO=1
endif
ifneq ($(CONFIG_USE_UCLIBC),)
PKG_DO_VARS+= UCLIBC=1
endif
define Build/Compile
$(INSTALL_DIR) $(PKG_BUILD_DIR)/tmp
(cd $(PKG_BUILD_DIR) && \
CROSS="true" \
CC="$(TARGET_CC_NOCACHE)" \
AR="$(TARGET_AR)" \
RANLIB="$(TARGET_RANLIB)" \
CFLAGS="$(TARGET_CFLAGS) -U_FORTIFY_SOURCE -Wno-error=array-bounds -Wno-error=stringop-overflow -Wno-error=stringop-overread" \
LDFLAGS="$(TARGET_LDFLAGS)" \
SYSTEM="linux" \
TARGET_ARCH="$(CONFIG_ARCH)" \
SSP_SUPPORT="$(CONFIG_SSP_SUPPORT)" \
GYP_ADDITIONAL_ARGS="-f make-linux" \
CJDNS_BUILD_TMPDIR="$(PKG_BUILD_DIR)/tmp" \
$(PKG_DO_VARS) \
exec ./do)
endef
define Package/cjdns/install
$(INSTALL_DIR) \
$(1)/usr/sbin \
$(1)/usr/bin \
$(1)/etc/config \
$(1)/etc/init.d \
$(1)/etc/uci-defaults \
$(1)/usr/lib/lua/cjdns
$(INSTALL_BIN) \
./files/cjdrouteconf \
$(1)/usr/bin
$(INSTALL_BIN) \
$(PKG_BUILD_DIR)/cjdroute \
$(1)/usr/sbin
$(INSTALL_BIN) \
$(PKG_BUILD_DIR)/publictoip6 \
$(1)/usr/bin
$(INSTALL_BIN) \
./files/cjdns.init \
$(1)/etc/init.d/cjdns
$(INSTALL_BIN) \
./files/cjdns.defaults \
$(1)/etc/uci-defaults/cjdns
$(CP) \
./lua/cjdns/* \
$(1)/usr/lib/lua/cjdns
endef
define Package/cjdns/postinst
#!/bin/sh
if [ -z $${IPKG_INSTROOT} ] ; then
( . /etc/uci-defaults/cjdns ) && rm -f /etc/uci-defaults/cjdns
/etc/init.d/cjdns enabled || /etc/init.d/cjdns enable
exit 0
fi
endef
define Package/cjdns-tests/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) \
$(PKG_BUILD_DIR)/build_linux/test_testcjdroute_c \
$(1)/usr/bin
endef
$(eval $(call BuildPackage,cjdns))
$(eval $(call BuildPackage,cjdns-tests))

View file

@ -1,120 +0,0 @@
#!/bin/sh
# if there is an existing config, our work is already done
uci get cjdns.cjdns.ipv6 >/dev/null 2>&1
if [ $? -ne 0 ]; then
# register commit handler
uci -q batch <<-EOF >/dev/null
delete ucitrack.@cjdns[-1]
add ucitrack cjdns
set ucitrack.@cjdns[-1].init=cjdns
commit ucitrack
EOF
# generate configuration
touch /etc/config/cjdns
cjdroute --genconf | cjdroute --cleanconf | cjdrouteconf set
# make sure config is present (might fail for any reason)
uci get cjdns.cjdns.ipv6 >/dev/null 2>&1
if [ $? -ne 0 ]; then
exit 1
fi
# enable auto-peering on ethernet interface lan, if existing
ifname=$(uci -q get network.lan.device || \
([ "$(uci -q get network.lan.type)" == "bridge" ] && echo br-lan) || \
uci -q get network.lan.ifname)
if [ -n "$ifname" ]; then
uci -q batch <<-EOF >/dev/null
add cjdns eth_interface
set cjdns.@eth_interface[-1].beacon=2
set cjdns.@eth_interface[-1].bind=$ifname
EOF
fi
# set the tun interface name
uci set cjdns.cjdns.tun_device=tuncjdns
# create the network interface
uci -q batch <<-EOF >/dev/null
set network.cjdns=interface
set network.cjdns.device=tuncjdns
set network.cjdns.proto=none
EOF
# firewall rules by @dangowrt -- thanks <3
# create the firewall zone
uci -q batch <<-EOF >/dev/null
add firewall zone
set firewall.@zone[-1].name=cjdns
add_list firewall.@zone[-1].network=cjdns
set firewall.@zone[-1].input=REJECT
set firewall.@zone[-1].output=ACCEPT
set firewall.@zone[-1].forward=REJECT
set firewall.@zone[-1].conntrack=1
set firewall.@zone[-1].family=ipv6
EOF
# allow ICMP from cjdns zone, e.g. ping6
uci -q batch <<-EOF >/dev/null
add firewall rule
set firewall.@rule[-1].name='Allow-ICMPv6-cjdns'
set firewall.@rule[-1].src=cjdns
set firewall.@rule[-1].proto=icmp
add_list firewall.@rule[-1].icmp_type=echo-request
add_list firewall.@rule[-1].icmp_type=echo-reply
add_list firewall.@rule[-1].icmp_type=destination-unreachable
add_list firewall.@rule[-1].icmp_type=packet-too-big
add_list firewall.@rule[-1].icmp_type=time-exceeded
add_list firewall.@rule[-1].icmp_type=bad-header
add_list firewall.@rule[-1].icmp_type=unknown-header-type
set firewall.@rule[-1].limit='1000/sec'
set firewall.@rule[-1].family=ipv6
set firewall.@rule[-1].target=ACCEPT
EOF
# allow SSH from cjdns zone, needs to be explicitly enabled
uci -q batch <<-EOF >/dev/null
add firewall rule
set firewall.@rule[-1].enabled=0
set firewall.@rule[-1].name='Allow-SSH-cjdns'
set firewall.@rule[-1].src=cjdns
set firewall.@rule[-1].proto=tcp
set firewall.@rule[-1].dest_port=22
set firewall.@rule[-1].target=ACCEPT
EOF
# allow LuCI access from cjdns zone, needs to be explicitly enabled
uci -q batch <<-EOF >/dev/null
add firewall rule
set firewall.@rule[-1].enabled=0
set firewall.@rule[-1].name='Allow-HTTP-cjdns'
set firewall.@rule[-1].src=cjdns
set firewall.@rule[-1].proto=tcp
set firewall.@rule[-1].dest_port=80
set firewall.@rule[-1].target=ACCEPT
EOF
# allow UDP peering from wan zone, if it exists
uci show network.wan >/dev/null 2>&1
if [ $? -eq 0 ]; then
peeringPort=`uci get cjdns.@udp_interface[0].port`
uci -q batch <<-EOF >/dev/null
add firewall rule
set firewall.@rule[-1].name='Allow-cjdns-wan'
set firewall.@rule[-1].src=wan
set firewall.@rule[-1].proto=udp
set firewall.@rule[-1].dest_port=$peeringPort
set firewall.@rule[-1].target=ACCEPT
EOF
fi
uci commit cjdns
uci commit firewall
uci commit network
fi
exit 0

View file

@ -1,32 +0,0 @@
#!/bin/sh /etc/rc.common
START=90
STOP=85
USE_PROCD=1
start_service()
{
[ -f /etc/uci-defaults/cjdns ] && ( . /etc/uci-defaults/cjdns )
procd_open_instance
procd_set_param respawn
procd_set_param command /bin/ash -c "cjdrouteconf get | tee /tmp/etc/cjdroute.conf | cjdroute --nobg | logger -t cjdns"
procd_close_instance
}
stop_service()
{
killall cjdroute
}
reload_service()
{
# cat /tmp/etc/cjdroute.conf | cjdrouteconf reload
restart
}
service_triggers()
{
procd_add_reload_trigger cjdns
}

View file

@ -1,30 +0,0 @@
#!/usr/bin/env lua
dkjson = require("dkjson")
cjdns = require("cjdns")
require("cjdns/uci")
function help()
print("JSON interface to /etc/config/cjdns\n\nExamples: \
cjdrouteconf get > /tmp/etc/cjdroute.conf \
cat /tmp/etc/cjdroute.conf | cjdrouteconf set \
uci changes \
cjdrouteconf get | cjdroute")
end
if arg[1] == "get" then
local json = dkjson.encode(cjdns.uci.get(), { indent = true })
print(json)
elseif arg[1] == "set" then
local json = io.stdin:read("*a")
local obj, pos, err = dkjson.decode(json, 1, nil)
if obj then
cjdns.uci.set(obj)
else
print("dkjson: " .. err .. " (try cjdroute --cleanconf)")
os.exit(1)
end
else
help()
end

View file

@ -1,105 +0,0 @@
-- Cjdns admin module for Lua
-- Written by Philip Horger
common = require 'cjdns/common'
AdminInterface = {}
AdminInterface.__index = AdminInterface
common.AdminInterface = AdminInterface
function AdminInterface.new(properties)
properties = properties or {}
properties.host = properties.host or "127.0.0.1"
properties.port = properties.port or 11234
properties.password = properties.password or nil
properties.config = properties.config or common.ConfigFile.new("/etc/cjdroute.conf", false)
properties.timeout = properties.timeout or 2
properties.udp = common.UDPInterface.new(properties)
return setmetatable(properties, AdminInterface)
end
function AdminInterface:send(object)
local bencoded, err = bencode.encode(object)
if err then
return nil, err
end
local sock_obj = assert(socket.udp())
sock_obj:settimeout(self.timeout)
local _, err = sock_obj:sendto(bencoded, self.host, self.port)
if err then
return nil, err
end
return sock_obj
end
function AdminInterface:recv(sock_obj)
local retrieved, err = sock_obj:receive()
if not retrieved then
return nil, "ai:recv > " .. err
end
local bencoded, err = bencode.decode(retrieved)
if bencoded then
return bencoded
else
return nil, "ai:recv > " .. err
end
end
function AdminInterface:call(request)
local sock_obj, err = self:send(request)
if err then
return nil, "ai:call > " .. err
end
return self:recv(sock_obj)
end
function AdminInterface:getCookie()
local cookie_response, err = self:call({ q = "cookie" })
if not cookie_response then
return nil, "ai:getCookie > " .. err
end
return cookie_response.cookie
end
function AdminInterface:auth(request)
local funcname = request.q
local args = {}
for k, v in pairs(request) do
args[k] = v
end
-- Step 1: Get cookie
local cookie, err = self:getCookie()
if err then
return nil, err
end
-- Step 2: Calculate hash1 (password + cookie)
local plaintext1 = self.password .. cookie
local hash1 = sha2.sha256hex(plaintext1)
-- Step 3: Calculate hash2 (intermediate stage request)
local request = {
q = "auth",
aq = funcname,
args = args,
hash = hash1,
cookie = cookie
}
local plaintext2, err = bencode.encode(request)
if err then
return nil, err
end
local hash2 = sha2.sha256hex(plaintext2)
-- Step 4: Update hash in request, then ship it out
request.hash = hash2
return self:call(request)
end

View file

@ -1,7 +0,0 @@
-- Cjdns admin module for Lua
-- Written by Philip Horger
-- This table is preserved over multiple imports, and collects
-- submodules import-by-import via init.lua.
return {}

View file

@ -1,12 +0,0 @@
-- Cjdns admin module for Lua
-- Written by Philip Horger
bencode = require "bencode" -- https://bitbucket.org/wilhelmy/lua-bencode/
dkjson = require "dkjson" -- http://dkolf.de/src/dkjson-lua.fsl/home
socket = require "socket" -- http://w3.impa.br/~diego/software/luasocket/
sha2 = require "sha2" -- https://code.google.com/p/sha2/
require "cjdns/admin"
require "cjdns/udp"
return require "cjdns/common"

View file

@ -1,294 +0,0 @@
common = require("cjdns/common")
uci = require("uci")
UCI = {}
common.uci = UCI
--- Return the configuration defaults as a table suitable for JSON output
--
-- Mostly taken from cjdroute --genconf
-- @return table with configuration defaults
function UCI.defaults()
return {
security = {
{ setuser = "nobody", keepNetAdmin = 1 },
{ chroot = "/var/run/" },
{ nofiles = 0 },
{ noforks = 1 },
{ seccomp = 0 },
{ setupComplete = 1 }
},
router = {
supernodes = {},
ipTunnel = { outgoingConnections = {}, allowedConnections = {} },
interface = { type = "TUNInterface" }
},
interfaces = { UDPInterface = {}, ETHInterface = {} },
authorizedPasswords = {},
logging = { logTo = "stdout" }
}
end
--- Return the cjdns configuration as a table suitable for JSON output
--
-- Iterates over cjdns, eth_interface, udp_interface, eth_peer, udp_peer,
-- and password sections. Doesn't include IPTunnel related options yet.
-- @return table with cjdns configuration
function UCI.get()
local obj = UCI.defaults()
local cursor = uci.cursor()
local config = cursor:get_all("cjdns", "cjdns")
if not config then return obj end
obj.ipv6 = config.ipv6
obj.publicKey = config.public_key
obj.privateKey = config.private_key
obj.admin = {
bind = config.admin_address .. ":" .. config.admin_port,
password = config.admin_password }
if config.tun_device and string.len(config.tun_device) > 0 then
obj.router.interface.tunDevice = config.tun_device
end
cursor:foreach("cjdns", "supernodes", function(supernodes)
table.insert(obj.router.supernodes, supernodes.public_key)
end)
for i,section in pairs(obj.security) do
if type(section.seccomp) == "number" then
obj.security[i].seccomp = tonumber(config.seccomp)
end
end
cursor:foreach("cjdns", "iptunnel_outgoing", function(outgoing)
table.insert(obj.router.ipTunnel.outgoingConnections, outgoing.public_key)
end)
cursor:foreach("cjdns", "iptunnel_allowed", function(allowed)
entry = { publicKey = allowed.public_key }
if allowed.ipv4 then
entry["ip4Address"] = allowed.ipv4
end
if allowed.ipv6 then
entry["ip6Address"] = allowed.ipv6
end
table.insert(obj.router.ipTunnel.allowedConnections, entry)
end)
cursor:foreach("cjdns", "eth_interface", function(eth_interface)
table.insert(obj.interfaces.ETHInterface, {
bind = eth_interface.bind,
beacon = tonumber(eth_interface.beacon),
connectTo = {}
})
end)
cursor:foreach("cjdns", "udp_interface", function(udp_interface)
table.insert(obj.interfaces.UDPInterface, {
bind = udp_interface.address .. ":" .. udp_interface.port,
connectTo = {}
})
end)
cursor:foreach("cjdns", "eth_peer", function(eth_peer)
if not eth_peer.address == "" then
local i = tonumber(eth_peer.interface)
obj.interfaces.ETHInterface[i].connectTo[eth_peer.address] = {
publicKey = eth_peer.public_key,
password = eth_peer.password
}
end
end)
cursor:foreach("cjdns", "udp_peer", function(udp_peer)
local bind = udp_peer.address .. ":" .. udp_peer.port
local i = tonumber(udp_peer.interface)
obj.interfaces.UDPInterface[i].connectTo[bind] = {
user = udp_peer.user,
publicKey = udp_peer.public_key,
password = udp_peer.password
}
end)
cursor:foreach("cjdns", "password", function(password)
table.insert(obj.authorizedPasswords, {
password = password.password,
user = password.user,
contact = password.contact
})
end)
return obj
end
--- Parse and save updated configuration from JSON input
--
-- Transforms general settings, ETHInterface, UDPInterface, connectTo, and
-- authorizedPasswords fields into UCI sections, and replaces the UCI config's
-- contents with them.
-- @param table JSON input
-- @return Boolean whether saving succeeded
function UCI.set(obj)
local cursor = uci.cursor()
for i, section in pairs(cursor:get_all("cjdns")) do
cursor:delete("cjdns", section[".name"])
end
local admin_address, admin_port = string.match(obj.admin.bind, "^(.*):(.*)$")
UCI.cursor_section(cursor, "cjdns", "cjdns", "cjdns", {
ipv6 = obj.ipv6,
public_key = obj.publicKey,
private_key = obj.privateKey,
admin_password = obj.admin.password,
admin_address = admin_address,
admin_port = admin_port
})
if obj.router.interface.tunDevice then
UCI.cursor_section(cursor, "cjdns", "cjdns", "cjdns", {
tun_device = tostring(obj.router.interface.tunDevice)
})
end
if obj.security then
for i,section in pairs(obj.security) do
for key,value in pairs(section) do
if key == "seccomp" then
UCI.cursor_section(cursor, "cjdns", "cjdns", "cjdns", {
seccomp = tonumber(value)
})
end
end
end
end
if obj.router.ipTunnel.outgoingConnections then
for i,public_key in pairs(obj.router.ipTunnel.outgoingConnections) do
UCI.cursor_section(cursor, "cjdns", "iptunnel_outgoing", nil, {
public_key = public_key
})
end
end
if obj.router.ipTunnel.allowedConnections then
for i,allowed in pairs(obj.router.ipTunnel.allowedConnections) do
entry = { public_key = allowed.publicKey }
if allowed.ip4Address then
entry["ipv4"] = allowed.ip4Address
end
if allowed.ip6Address then
entry["ipv6"] = allowed.ip6Address
end
UCI.cursor_section(cursor, "cjdns", "iptunnel_allowed", nil, entry)
end
end
if obj.interfaces.ETHInterface then
for i,interface in pairs(obj.interfaces.ETHInterface) do
UCI.cursor_section(cursor, "cjdns", "eth_interface", nil, {
bind = interface.bind,
beacon = tostring(interface.beacon)
})
if interface.connectTo then
for peer_address,peer in pairs(interface.connectTo) do
UCI.cursor_section(cursor, "cjdns", "eth_peer", nil, {
interface = i,
address = peer_address,
public_key = peer.publicKey,
password = peer.password
})
end
end
end
end
if obj.interfaces.UDPInterface then
for i,interface in pairs(obj.interfaces.UDPInterface) do
local address, port = string.match(interface.bind, "^(.*):(.*)$")
UCI.cursor_section(cursor, "cjdns", "udp_interface", nil, {
address = address,
port = port
})
if interface.connectTo then
for peer_bind,peer in pairs(interface.connectTo) do
local peer_address, peer_port = string.match(peer_bind, "^(.*):(.*)$")
UCI.cursor_section(cursor, "cjdns", "udp_peer", nil, {
interface = i,
address = peer_address,
port = peer_port,
user = peer.user,
public_key = peer.publicKey,
password = peer.password
})
end
end
end
end
if obj.authorizedPasswords then
for i,password in pairs(obj.authorizedPasswords) do
local user = password.user
if not user or string.len(user) == 0 then
user = "user-" .. UCI.random_string(6)
end
UCI.cursor_section(cursor, "cjdns", "password", nil, {
password = password.password,
user = user,
contact = password.contact
})
end
end
return cursor:save("cjdns")
end
--- Simple backport of Cursor:section from luci.model.uci
--
-- Backport reason: we don't wanna depend on LuCI.
-- @param Cursor the UCI cursor to operate on
-- @param string name of the config
-- @param string type of the section
-- @param string name of the section (optional)
-- @param table config values
function UCI.cursor_section(cursor, config, type, section, values)
if section then
cursor:set(config, section, type)
else
section = cursor:add("cjdns", type)
end
for k,v in pairs(values) do
cursor:set(config, section, k, v)
end
end
function UCI.makeInterface()
local cursor = uci.cursor()
local config = cursor:get_all("cjdns", "cjdns")
if not config then return nil end
return common.AdminInterface.new({
host = config.admin_address,
port = config.admin_port,
password = config.admin_password,
config = UCI.get(),
timeout = 2
})
end
function UCI.random_string(length)
-- tr -cd 'A-Za-z0-9' < /dev/urandom
local urandom = io.popen("tr -cd 'A-Za-z0-9' 2> /dev/null < /dev/urandom", "r")
local string = urandom:read(length)
urandom:close()
return string
end

View file

@ -1,102 +0,0 @@
-- Cjdns admin module for Lua
-- Written by Philip Horger
common = require 'cjdns/common'
UDPInterface = {}
UDPInterface.__index = UDPInterface
common.UDPInterface = UDPInterface
function UDPInterface.new(ai, config, ptype)
properties = {
ai = ai,
config = config or ai.config,
ptype = ptype or "ai"
}
return setmetatable(properties, UDPInterface)
end
function UDPInterface:call(name, args)
local func = self[name .. "_" .. self.ptype]
return func(self, unpack(args))
end
function UDPInterface:newBind(...)
return self:call("newBind", arg)
end
function UDPInterface:beginConnection(...)
return self:call("beginConnection", arg)
end
function UDPInterface:newBind_ai(address)
local response, err = self.ai:auth({
q = "UDPInterface_new",
bindAddress = address
})
if not response then
return nil, err
elseif response.error ~= "none" then
return nil, response.error
elseif response.interfaceNumber then
return response.interfaceNumber
else
return nil, "bad response format"
end
end
function UDPInterface:newBind_config(address)
local udpif = self.config.contents.interfaces.UDPInterface
local new_interface = {
bind = address,
connectTo = {}
}
table.insert(udpif, new_interface)
return (#udpif - 1), new_interface
end
function UDPInterface:newBind_perm(...)
return
self:newBind_config(unpack(arg)),
self:newBind_ai(unpack(arg))
end
function UDPInterface:beginConnection_ai(pubkey, addr, password, interface)
local request = {
q = "UDPInterface_beginConnection",
publicKey = pubkey,
address = addr,
password = password
}
if interface then
request.interfaceNumber = interface
end
local response, err = self.ai:auth(request)
if not response then
return nil, err
elseif response.error == "none" then
-- Unfortunately, no real success indicator either.
return "No error"
else
return nil, response.error
end
end
function UDPInterface:beginConnection_config(pubkey, addr, password, interface)
local udpif = self.config.contents.interfaces.UDPInterface
local connections = udpif[(interface or 0) + 1].connectTo
local this_conn = {
password = password,
publicKey = pubkey
}
connections[addr] = this_conn
return this_conn -- allows adding metadata fields afterwards
end
function UDPInterface:beginConnection_perm(...)
return
self:beginConnection_config(unpack(arg)),
self:beginConnection_ai(unpack(arg))
end

View file

@ -1,13 +0,0 @@
--- a/node_build/builder.js
+++ b/node_build/builder.js
@@ -277,8 +277,8 @@ const execJs = function (js, ctx, file,
js = '"use strict";' + qs.join("'");
const to = setTimeout(function () {
- throw new Error("Inline JS did not return after 120 seconds [" + js + "]");
- }, 120000);
+ throw new Error("Inline JS did not return after 5 minutes [" + js + "]");
+ }, 300000);
nThen(function (waitFor) {

View file

@ -1,11 +0,0 @@
--- a/node_build/FindPython.js
+++ b/node_build/FindPython.js
@@ -23,7 +23,7 @@ var Fs = require('fs');
// de-prioritize because the testing script accepts ANY python3 version
// (as of this writing, we don't know what python3 versions actually work)
// whereas we know that python2.7 is the only working python2 version.
-var PYTHONS = ["python3.7", "python3", "python2.7", "python2", "python"];
+var PYTHONS = ["python2", "python2.7", "python3.7", "python3.8", "python3.9", "python3"]
var SCRIPT = [
'import sys',

View file

@ -1,23 +0,0 @@
--- a/net/SwitchPinger_admin.c
+++ b/net/SwitchPinger_admin.c
@@ -78,8 +78,10 @@ static void adminPing(Dict* args, void*
uint32_t timeout = (timeoutPtr) ? *timeoutPtr : DEFAULT_TIMEOUT;
uint64_t path;
String* err = NULL;
+ String* pathNotParsable = String_CONST("path was not parsable.");
+ String* noOpenSlots = String_CONST("no open slots to store ping, try later.");
if (pathStr->len != 19 || AddrTools_parsePath(&path, (uint8_t*) pathStr->bytes)) {
- err = String_CONST("path was not parsable.");
+ err = pathNotParsable;
} else {
struct SwitchPinger_Ping* ping = SwitchPinger_newPing(path,
data,
@@ -89,7 +91,7 @@ static void adminPing(Dict* args, void*
context->switchPinger);
if (keyPing && *keyPing) { ping->type = SwitchPinger_Type_KEYPING; }
if (!ping) {
- err = String_CONST("no open slots to store ping, try later.");
+ err = noOpenSlots;
} else {
ping->onResponseContext = Allocator_clone(ping->pingAlloc, (&(struct Ping) {
.context = context,

View file

@ -1,15 +0,0 @@
--- a/node_build/dependencies/libuv/build/gyp/pylib/gyp/common.py
+++ b/node_build/dependencies/libuv/build/gyp/pylib/gyp/common.py
@@ -4,7 +4,11 @@
from __future__ import with_statement
-import collections
+try:
+ # Python 3.10
+ from six.moves import collections_abc as collections
+except ImportError:
+ import collections
import errno
import filecmp
import os.path

View file

@ -1,5 +1,5 @@
#
# Copyright (C) 2012-2014 OpenWrt.org
# Copyright (C) 2012-2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
@ -7,19 +7,16 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=hnetd
PKG_SOURCE_DATE:=2018-12-21
PKG_SOURCE_VERSION:=c43766610ed30194b048bc070a3c433aec731c40
PKG_SOURCE_VERSION:=0c1d55d03983c726aaad010738236c2da64ca7df
PKG_VERSION:=2014-09-26-$(PKG_SOURCE_VERSION)
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/sbyx/hnetd
PKG_MIRROR_HASH:=a41baa2e3d7930cc88073b0b3f6e1fa6a4abd9fd663f2577cfde1564fa07f8f2
PKG_SOURCE_URL:=git://github.com/sbyx/hnetd.git
PKG_MAINTAINER:=Steven Barth <cyrus@openwrt.org>
PKG_LICENSE:=GPL-2.0-only
PKG_LICENSE_FILES:=LICENSE
PKG_BUILD_PARALLEL:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
@ -30,61 +27,25 @@ CMAKE_OPTIONS += -DL_LEVEL=7
# OpenWRT target
CMAKE_OPTIONS += -DBACKEND=openwrt
ifeq ($(BUILD_VARIANT),openssl)
CMAKE_OPTIONS += -DDTLS_OPENSSL=1
endif
define Package/hnetd/Default
define Package/hnetd
SECTION:=net
CATEGORY:=Network
TITLE:=HNCP Homenet daemon - $(2)
TITLE:=HNCP Homenet daemon
URL:=https://github.com/sbyx/hnetd
DEPENDS:=+odhcpd +odhcp6c +netifd $(3)
DEPENDS+=@IPV6
VARIANT:=$1
DEPENDS:=+odhcpd +odhcp6c +netifd
DEPENDS+=+@IPV6
endef
Package/hnetd-nossl=$(call Package/hnetd/Default,nossl,no authentication)
Package/hnetd-openssl=$(call Package/hnetd/Default,openssl,authentication via OpenSSL,+libopenssl)
define Package/hnet-full
SECTION:=net
CATEGORY:=Network
TITLE:=HNCP Homenet metapackage
URL:=https://github.com/sbyx/hnetd
DEPENDS:=+hnetd-nossl +luci-app-hnet +ip
DEPENDS:=+hnetd +luci-app-hnet
# Routing
DEPENDS+=+babeld
DEPENDS+=+babels
# Service discovery
DEPENDS+=+ohybridproxy +zonestitcher
# Distributed PCP support
DEPENDS+=+miniupnpd +minimalist-pcproxy
endef
define Package/hnet-full-secure
SECTION:=net
CATEGORY:=Network
TITLE:=HNCP Homenet metapackage (w/ SSL)
URL:=https://github.com/sbyx/hnetd
DEPENDS:=+hnetd-openssl +luci-app-hnet +ip
# Routing
DEPENDS+=+babeld
# Service discovery
DEPENDS+=+ohybridproxy +zonestitcher
# Distributed PCP support
DEPENDS+=+miniupnpd +minimalist-pcproxy
endef
define Package/hnet-full-l2tp
SECTION:=net
CATEGORY:=Network
TITLE:=HNCP Homenet metapackage (w/ L2TP)
URL:=https://github.com/sbyx/hnetd
DEPENDS:=+hnetd-nossl +luci-app-hnet +ip-full +kmod-l2tp-eth
# Routing
DEPENDS+=+babeld
# Service discovery
DEPENDS+=+ohybridproxy +zonestitcher
DEPENDS+=+ohybridproxy
# Distributed PCP support
DEPENDS+=+miniupnpd +minimalist-pcproxy
endef
@ -94,52 +55,37 @@ define Package/luci-app-hnet
CATEGORY:=LuCI
SUBMENU:=3. Applications
TITLE:=HNCP Homenet configuration and visualization
# DEPENDS:=+hnetd
# TBD - how to express dependency on 'some' hnetd?
DEPENDS:=+hnetd
endef
define Package/hnetd-$(BUILD_VARIANT)/description
define Package/hnetd/description
This package provides a daemon which implementats distributed prefix assignment
and service discovery for a home network consisting of multiple routers
connected to multiple service providers. It provides a netifd protocol "hnet"
for use in /etc/config/network.
endef
define Package/hnetd-$(BUILD_VARIANT)/install
define Package/hnetd/install
$(INSTALL_DIR) $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/hnetd $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/lib/netifd/proto
$(INSTALL_BIN) $(PKG_BUILD_DIR)/openwrt/hnet.sh $(1)/lib/netifd/proto
ln -s hnetd $(1)/usr/sbin/hnet-ifresolve
ln -s hnetd $(1)/usr/sbin/hnet-trust
ln -s hnetd $(1)/usr/sbin/hnet-dump
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/hnetd.init $(1)/etc/init.d/hnetd
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/hnet.config $(1)/etc/config/hnet
$(INSTALL_BIN) $(PKG_BUILD_DIR)/generic/ohp.script $(1)/usr/sbin/hnetd-ohp-script
$(INSTALL_BIN) $(PKG_BUILD_DIR)/generic/ddz.script $(1)/usr/sbin/hnetd-ddz-script
$(INSTALL_BIN) $(PKG_BUILD_DIR)/generic/pcp.script $(1)/usr/sbin/hnetd-pcp-script
$(INSTALL_BIN) ./files/ohp-script $(1)/usr/sbin/hnetd-ohp-script
$(INSTALL_BIN) ./files/pcp-script $(1)/usr/sbin/hnetd-pcp-script
$(INSTALL_BIN) $(PKG_BUILD_DIR)/generic/hnetd-routing $(1)/usr/sbin/hnetd-routing
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) ./files/hnetd.defaults $(1)/etc/uci-defaults/x-hnetd.defaults
$(INSTALL_BIN) $(PKG_BUILD_DIR)/generic/multicast.script $(1)/usr/sbin/hnet-multicast
$(INSTALL_BIN) $(PKG_BUILD_DIR)/openwrt/autowifi.script $(1)/usr/sbin/autowifi
endef
define Package/hnet-full/install
true
endef
define Package/hnet-full-secure/install
true
endef
define Package/hnet-full-l2tp/install
$(INSTALL_DIR) $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/generic/tunnel.script $(1)/usr/sbin/hnetd-tunnel
endef
define Package/luci-app-hnet/install
$(INSTALL_DIR) $(1)/usr/lib/lua/luci
$(INSTALL_DIR) $(1)/www
@ -147,7 +93,7 @@ define Package/luci-app-hnet/install
$(CP) -R $(PKG_BUILD_DIR)/openwrt/luci/htdocs/* $(1)/www/
endef
define Package/hnetd-$(BUILD_VARIANT)/postinst
define Package/hnetd/postinst
#!/bin/sh
[ -n "$${IPKG_INSTROOT}" ] || {
(. /etc/uci-defaults/x-hnetd.defaults) && rm -f /etc/uci-defaults/x-hnetd.defaults
@ -155,11 +101,9 @@ define Package/hnetd-$(BUILD_VARIANT)/postinst
/etc/init.d/hnetd enable
/etc/init.d/hnetd start
}
exit 0
endef
$(eval $(call BuildPackage,hnetd-nossl))
$(eval $(call BuildPackage,hnetd-openssl))
$(eval $(call BuildPackage,hnetd))
$(eval $(call BuildPackage,hnet-full))
$(eval $(call BuildPackage,hnet-full-secure))
$(eval $(call BuildPackage,hnet-full-l2tp))
$(eval $(call BuildPackage,luci-app-hnet))

View file

@ -1,29 +1,8 @@
config security security
# Simplest security mode:
# option password foo
# Trust consensus and CA-based share these options:
# option certificate_file /etc/hnetd-cert.pem
# option private_key_file /etc/hnetd-key.pem
# Then to enable trust consensus:
# option trust_store /etc/hnetd-trust.dat
# Or CA-based authentication:
# option trust_certificate_file /etc/ca-cert.pem
config pa pa
# option ip4prefix 10.0.0.0/8
# option ip4mode ifuplink
# option ulaprefix fd12:3456:789A::/48
# option ulamode off
option persistent_store /etc/hnet-pa.store
# option persistent_store /etc/hnet-pa.store
config sd sd
# option router_name openwrt
# option domain_name home.
# Wifi allows for very basic wifi autoconfiguration
# Warning: This feature is unstable
config wifi wifi
# option enable 0
# option ssid ssidtest
# option password test

View file

@ -1,12 +1,6 @@
#!/bin/sh
# Why we tune dnsmasq?
# localservice=0 => other hnetd instances can query for local names
# boguspriv=0 => allow reverse resolution of RFC1918 w/o local hosts entries
uci batch <<EOF
set dhcp.odhcpd.maindhcp=1
set dhcp.@dnsmasq[0].localservice=0
set dhcp.@dnsmasq[0].boguspriv=0
commit dhcp
EOF

View file

@ -12,12 +12,8 @@ DNSMASQ_DIR=/tmp/dnsmasq.d
DNSMASQ_SCRIPT=/etc/init.d/dnsmasq
OHP_SCRIPT=/usr/sbin/hnetd-ohp-script
OHP_BINARY=/usr/sbin/ohybridproxy
DDZ_SCRIPT=/usr/sbin/hnetd-ddz-script
DDZ_BINARY=/usr/sbin/zonestitcher
PCP_SCRIPT=/usr/sbin/hnetd-pcp-script
PCP_BINARY=/usr/sbin/minimalist-pcproxy
MULTICAST_SCRIPT=/usr/sbin/hnet-multicast
WIFI_SCRIPT=/usr/sbin/autowifi
start_service() {
. /lib/functions.sh
@ -40,27 +36,6 @@ start_service() {
then
procd_append_param command -n "$HOSTNAME"
fi
if [ -f $DDZ_BINARY ]
then
procd_append_param command -z $DDZ_SCRIPT
fi
fi
# Enable multicast if present and installed
if [ -f "$MULTICAST_SCRIPT" ]
then
$MULTICAST_SCRIPT status && procd_append_param command -M "$MULTICAST_SCRIPT"
fi
config_get enableval wifi enable
if [ -f "$WIFI_SCRIPT" -a "$enableval" = "1" ]; then
wifiopt=$WIFI_SCRIPT
config_get ssidval wifi ssid
config_get passval wifi password
if [ -n "$ssidval" -a -n "$passval" ]; then
wifiopt=${wifiopt},${ssidval}:${passval}
fi
procd_append_param command -w "$wifiopt"
fi
# Enable PCP, if it's present
@ -76,52 +51,21 @@ start_service() {
# Routing script
procd_append_param command -r /usr/sbin/hnetd-routing
[ -x /usr/sbin/hnetd-tunnel ] && \
procd_append_param command -t /usr/sbin/hnetd-tunnel
# Prefix assignment (pa)
config_get val pa ip4prefix
[ -n "$val" ] && procd_append_param command --ip4prefix $val
config_get val pa ip4mode
[ -n "$val" ] && procd_append_param command --ip4mode $val
config_get val pa ulaprefix
[ -n "$val" ] && procd_append_param command --ulaprefix $val
config_get val pa ulamode
[ -n "$val" ] && procd_append_param command --ulamode $val
# Service discovery (sd)
config_get val sd router_name
[ -n "$val" ] && procd_append_param command -n $val
config_get val sd domain_name
[ -n "$val" ] && procd_append_param command -m $val
# Security (needs security-enabled build)
config_get val security password
[ -n "$val" ] && procd_append_param command --password $val
config_get val security certificate_file
[ -n "$val" ] && procd_append_param command --certificate $val
config_get val security private_key_file
[ -n "$val" ] && procd_append_param command --privatekey $val
config_get val security trust_store
[ -n "$val" ] && procd_append_param command --trust $val
config_get val security trust_certificate_file
[ -n "$val" ] && procd_append_param command --verify-path $val
# For more verbose logging, uncomment this:
#procd_append_param command --loglevel 7
procd_set_param respawn
procd_close_instance
}
service_triggers() {
procd_add_reload_trigger "hnet"
}

48
hnetd/files/ohp-script Normal file
View file

@ -0,0 +1,48 @@
#!/bin/sh
#-*-sh-*-
#
# $Id: ohp-script $
#
# Author: Markus Stenberg <mstenber@cisco.com>
#
# Copyright (c) 2014 cisco Systems, Inc.
#
# Created: Fri Jan 17 11:46:30 2014 mstenber
# Last modified: Mon Feb 3 14:39:15 2014 mstenber
# Edit time: 15 min
#
# This is minimalist init.d-like start/stop script for
# ohybridproxy. However, as ohybridproxy receives it's configuration
# via command line, the 'start' command is also equivalent to
# 'restart', and has bunch of extra arguments..
OHP=ohybridproxy
start() {
$OHP $* &
}
stop() {
killall -9 $OHP
}
CMD=$1
# For debugging purposes
LOGNAME=`basename $0`
echo "$*" | logger -t "$LOGNAME"
case $CMD in
start)
shift
stop
start $*
;;
stop)
stop
;;
*)
echo "Only start [config]/stop supported"
exit 1
;;
esac

46
hnetd/files/pcp-script Normal file
View file

@ -0,0 +1,46 @@
#!/bin/sh
#-*-sh-*-
#
# $Id: pcp-script $
#
# Author: Markus Stenberg <mstenber@cisco.com>
#
# Copyright (c) 2014 cisco Systems, Inc.
#
# Created: Fri Jan 17 11:46:30 2014 mstenber
# Last modified: Fri May 30 13:27:57 2014 mstenber
# Edit time: 16 min
#
# Copied from ohp-script.. Same idea. Just prod minimalist-pcproxy as
# needed, hoping the miniupnpd is taken care of by the system.
PCP=minimalist-pcproxy
start() {
$PCP $* &
}
stop() {
killall -9 $PCP
}
CMD=$1
# For debugging purposes
LOGNAME=`basename $0`
echo "$*" | logger -t "$LOGNAME"
case $CMD in
start)
shift
stop
start $*
;;
stop)
stop
;;
*)
echo "Only start [config]/stop supported"
exit 1
;;
esac

View file

@ -1,43 +0,0 @@
--- a/src/dtls.c
+++ b/src/dtls.c
@@ -698,8 +698,10 @@ dtls dtls_create(uint16_t port)
if (!_ssl_initialized)
{
_ssl_initialized = true;
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
SSL_load_error_strings();
SSL_library_init();
+#endif
}
if (!d)
goto fail;
@@ -711,9 +713,9 @@ dtls dtls_create(uint16_t port)
goto fail;
#ifdef USE_ONE_CONTEXT
- SSL_CTX *ctx = SSL_CTX_new(DTLSv1_method());
+ SSL_CTX *ctx = SSL_CTX_new(DTLS_method());
#else
- SSL_CTX *ctx = SSL_CTX_new(DTLSv1_server_method());
+ SSL_CTX *ctx = SSL_CTX_new(DTLS_server_method());
#endif /* USE_ONE_CONTEXT */
if (!ctx)
{
@@ -1002,6 +1004,7 @@ _client_psk(SSL *ssl,
bool dtls_set_psk(dtls d, const char *psk, size_t psk_len)
{
+#ifndef OPENSSL_NO_PSK
free(d->psk);
d->psk = malloc(psk_len);
if (!d->psk)
@@ -1011,6 +1014,9 @@ bool dtls_set_psk(dtls d, const char *ps
SSL_CTX_set_psk_client_callback(d->ssl_client_ctx, _client_psk);
SSL_CTX_set_psk_server_callback(d->ssl_server_ctx, _server_psk);
return true;
+#else
+ return false;
+#endif
}
bool dtls_cert_to_pem_buf(dtls_cert cert, char *buf, int buf_len)

View file

@ -1,10 +0,0 @@
--- a/src/hnetd.h
+++ b/src/hnetd.h
@@ -39,6 +39,7 @@
#endif /* __APPLE__ */
+#undef __unused
#include <stddef.h>
#include <stdint.h>
#include <time.h>

56
luci-app-bcp38/Makefile Normal file
View file

@ -0,0 +1,56 @@
#
# Copyright (C) 2010 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-bcp38
PKG_VERSION:=2
PKG_RELEASE:=1
LUCI_DIR:=/usr/lib/lua/luci
include $(INCLUDE_DIR)/package.mk
define Package/luci-app-bcp38
SECTION:=luci
CATEGORY:=LuCI
TITLE:=BCP38 LuCI interface
MAINTAINER:=Toke Høiland-Jørgensen <toke@toke.dk>
PKGARCH:=all
DEPENDS:= lua luci-base +bcp38
SUBMENU:=3. Applications
endef
define Package/luci-app-bcp38/description
Control BCP38 subnet blocking
endef
define Build/Compile
endef
define Build/Configure
endef
define Package/luci-app-bcp38/install
$(INSTALL_DIR) $(1)$(LUCI_DIR)/controller $(1)$(LUCI_DIR)/model/cbi
$(INSTALL_DATA) ./files/bcp38-controller.lua $(1)$(LUCI_DIR)/controller/bcp38.lua
$(INSTALL_DATA) ./files/bcp38-cbi.lua $(1)$(LUCI_DIR)/model/cbi/bcp38.lua
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) ./files/uci-defaults-bcp38 $(1)/etc/uci-defaults/luci-bcp38
endef
define Package/luci-app-bcp38/postinst
#!/bin/sh
[ -x /etc/uci-defaults/luci-bcp38 ] && /etc/uci-defaults/luci-bcp38 || exit 0
endef
define Package/luci-app-bcp38/postrm
#!/bin/sh
uci delete ucitrack.@bcp38[0]
uci commit
endef
$(eval $(call BuildPackage,luci-app-bcp38))

View file

@ -0,0 +1,58 @@
--[[
LuCI - Lua Configuration Interface
Copyright 2014 Toke Høiland-Jørgensen <toke@toke.dk>
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
$Id$
]]--
local wa = require "luci.tools.webadmin"
local net = require "luci.model.network".init()
local ifaces = net:get_interfaces()
m = Map("bcp38", translate("BCP38"),
translate("This function blocks packets with private address destinations " ..
"from going out onto the internet as per " ..
"<a href=\"http://tools.ietf.org/html/bcp38\">BCP 38</a>."))
s = m:section(TypedSection, "bcp38", translate("BCP38 config"))
s.anonymous = true
-- BASIC
e = s:option(Flag, "enabled", translate("Enable"))
e.rmempty = false
a = s:option(Flag, "detect_upstream", translate("Auto-detect upstream IP"),
translate("Attempt to automatically detect if the upstream IP " ..
"will be blocked by the configuration, and add an exception if it will. " ..
"If this does not work correctly, you can add exceptions manually below."))
a.rmempty = false
n = s:option(ListValue, "interface", translate("Interface name"), translate("Interface to apply the blocking to " ..
"(should be the upstream WAN interface)."))
for _, iface in ipairs(ifaces) do
if iface:is_up() then
n:value(iface:name())
end
end
n.rmempty = false
ma = s:option(DynamicList, "match",
translate("Blocked IP ranges"))
ma.datatype = "ip4addr"
nm = s:option(DynamicList, "nomatch",
translate("Allowed IP ranges"), translate("Takes precedence over blocked ranges. "..
"Use to whitelist your upstream network if you're behind a double NAT " ..
"and the auto-detection doesn't work."))
nm.datatype = "ip4addr"
return m

View file

@ -0,0 +1,7 @@
module("luci.controller.bcp38", package.seeall)
function index()
entry({"admin", "network", "firewall", "bcp38"},
cbi("bcp38"),
_("BCP38"), 50).dependent = false
end

View file

@ -0,0 +1,11 @@
#!/bin/sh
uci -q batch <<-EOF >/dev/null
delete ucitrack.@bcp38[-1]
add ucitrack bcp38
add_list ucitrack.@bcp38[0].affects=firewall
commit ucitrack
EOF
rm -f /tmp/luci-indexcache
exit 0

339
luci-app-bmx6/COPYING Normal file
View file

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

61
luci-app-bmx6/Makefile Normal file
View file

@ -0,0 +1,61 @@
# Copyright (C) 2011 Pau Escrich <pau@dabax.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# The full GNU General Public License is included in this distribution in
# the file called "COPYING".
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-bmx6
PKG_RELEASE:=2
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/luci-app-bmx6
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=3. Applications
TITLE:= bmx6 configuration, status and visualization module
DEPENDS:=+luci-lib-json +luci-mod-admin-core +luci-lib-httpclient +bmx6
MAINTAINER:= Pau Escrich <p4u@dabax.net>
endef
define Package/luci-app-bmx6/description
bmx6 web module for LuCi web interface
endef
define Package/luci-app-bmx6/conffiles
/etc/config/luci-bmx6
endef
define Build/Prepare
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/luci-app-bmx6/install
$(CP) ./files/* $(1)/
chmod 755 $(1)/www/cgi-bin/bmx6-info
endef
$(eval $(call BuildPackage,luci-app-bmx6))

View file

@ -0,0 +1,7 @@
config 'bmx6' 'luci'
option ignore '0'
option place 'admin network BMX6'
#option place 'qmp Mesh'
option position '3'
#option json 'http://127.0.0.1/cgi-bin/bmx6-info?'
option json 'exec:/www/cgi-bin/bmx6-info -s'

View file

@ -0,0 +1,329 @@
--[[
Copyright (C) 2011 Pau Escrich <pau@dabax.net>
Contributors Jo-Philipp Wich <xm@subsignal.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
--]]
local bmx6json = require("luci.model.bmx6json")
module("luci.controller.bmx6", package.seeall)
function index()
local place = {}
local ucim = require "luci.model.uci"
local uci = ucim.cursor()
-- checking if ignore is on
if uci:get("luci-bmx6","luci","ignore") == "1" then
return nil
end
-- getting value from uci database
local uci_place = uci:get("luci-bmx6","luci","place")
-- default values
if uci_place == nil then
place = {"bmx6"}
else
local util = require "luci.util"
place = util.split(uci_place," ")
end
-- getting position of menu
local uci_position = uci:get("luci-bmx6","luci","position")
---------------------------
-- Starting with the pages
---------------------------
--- status (default)
entry(place,call("action_nodes_j"),place[#place],tonumber(uci_position))
table.insert(place,"Status")
entry(place,call("action_status_j"),"Status",0)
table.remove(place)
-- not visible
table.insert(place,"nodes_nojs")
entry(place, call("action_nodes"), nil)
table.remove(place)
--- nodes
table.insert(place,"Nodes")
entry(place,call("action_nodes_j"),"Nodes",1)
table.remove(place)
--- links
table.insert(place,"Links")
entry(place,call("action_links"),"Links",2).leaf = true
table.remove(place)
-- Tunnels
table.insert(place,"Tunnels")
entry(place,call("action_tunnels_j"), "Tunnels", 3).leaf = true
table.remove(place)
-- Gateways (deprecated)
--table.insert(place,"Gateways")
--entry(place,call("action_gateways_j"),"Gateways").leaf = true
--table.remove(place)
--- Chat
table.insert(place,"Chat")
entry(place,call("action_chat"),"Chat",5)
table.remove(place)
--- Graph
table.insert(place,"Graph")
entry(place, template("bmx6/graph"), "Graph",4)
table.remove(place)
--- Topology (hidden)
table.insert(place,"topology")
entry(place, call("action_topology"), nil)
table.remove(place)
--- configuration (CBI)
table.insert(place,"Configuration")
entry(place, cbi("bmx6/main"), "Configuration",6).dependent=false
table.insert(place,"General")
entry(place, cbi("bmx6/main"), "General",1)
table.remove(place)
table.insert(place,"Advanced")
entry(place, cbi("bmx6/advanced"), "Advanced",5)
table.remove(place)
table.insert(place,"Interfaces")
entry(place, cbi("bmx6/interfaces"), "Interfaces",2)
table.remove(place)
table.insert(place,"Tunnels")
entry(place, cbi("bmx6/tunnels"), "Tunnels",3)
table.remove(place)
table.insert(place,"Plugins")
entry(place, cbi("bmx6/plugins"), "Plugins",6)
table.remove(place)
table.insert(place,"HNAv6")
entry(place, cbi("bmx6/hna"), "HNAv6",4)
table.remove(place)
table.remove(place)
end
function action_status()
local status = bmx6json.get("status").status or nil
local interfaces = bmx6json.get("interfaces").interfaces or nil
if status == nil or interfaces == nil then
luci.template.render("bmx6/error", {txt="Cannot fetch data from bmx6 json"})
else
luci.template.render("bmx6/status", {status=status,interfaces=interfaces})
end
end
function action_status_j()
luci.template.render("bmx6/status_j", {})
end
function action_nodes()
local orig_list = bmx6json.get("originators").originators or nil
if orig_list == nil then
luci.template.render("bmx6/error", {txt="Cannot fetch data from bmx6 json"})
return nil
end
local originators = {}
local desc = nil
local orig = nil
local name = ""
local ipv4 = ""
for _,o in ipairs(orig_list) do
orig = bmx6json.get("originators/"..o.name) or {}
desc = bmx6json.get("descriptions/"..o.name) or {}
if string.find(o.name,'.') then
name = luci.util.split(o.name,'.')[1]
else
name = o.name
end
table.insert(originators,{name=name,orig=orig,desc=desc})
end
luci.template.render("bmx6/nodes", {originators=originators})
end
function action_nodes_j()
local http = require "luci.http"
local link_non_js = "/cgi-bin/luci" .. http.getenv("PATH_INFO") .. '/nodes_nojs'
luci.template.render("bmx6/nodes_j", {link_non_js=link_non_js})
end
function action_gateways_j()
luci.template.render("bmx6/gateways_j", {})
end
function action_tunnels_j()
luci.template.render("bmx6/tunnels_j", {})
end
function action_links(host)
local links = bmx6json.get("links", host)
local devlinks = {}
local _,l
if links ~= nil then
links = links.links
for _,l in ipairs(links) do
devlinks[l.viaDev] = {}
end
for _,l in ipairs(links) do
l.name = luci.util.split(l.name,'.')[1]
table.insert(devlinks[l.viaDev],l)
end
end
luci.template.render("bmx6/links", {links=devlinks})
end
function action_topology()
local originators = bmx6json.get("originators/all")
local o,i,l,i2
local first = true
local topology = '[ '
local cache = '/tmp/bmx6-topology.json'
local offset = 60
local cachefd = io.open(cache,r)
local update = false
if cachefd ~= nil then
local lastupdate = tonumber(cachefd:read("*line")) or 0
if os.time() >= lastupdate + offset then
update = true
else
topology = cachefd:read("*all")
end
cachefd:close()
end
if cachefd == nil or update then
for i,o in ipairs(originators) do
local links = bmx6json.get("links",o.primaryIp)
if links then
if first then
first = false
else
topology = topology .. ', '
end
topology = topology .. '{ "name": "%s", "links": [' %o.name
local first2 = true
for i2,l in ipairs(links.links) do
if first2 then
first2 = false
else
topology = topology .. ', '
end
name = l.name or l.llocalIp or "unknown"
topology = topology .. '{ "name": "%s", "rxRate": %s, "txRate": %s }'
%{ name, l.rxRate, l.txRate }
end
topology = topology .. ']}'
end
end
topology = topology .. ' ]'
-- Upgrading the content of the cache file
cachefd = io.open(cache,'w+')
cachefd:write(os.time()..'\n')
cachefd:write(topology)
cachefd:close()
end
luci.http.prepare_content("application/json")
luci.http.write(topology)
end
function action_chat()
local sms_dir = "/var/run/bmx6/sms"
local rcvd_dir = sms_dir .. "/rcvdSms"
local send_file = sms_dir .. "/sendSms/chat"
local sms_list = bmx6json.get("rcvdSms")
local sender = ""
local sms_file = ""
local chat = {}
local to_send = nil
local sent = ""
local fd = nil
if luci.sys.call("test -d " .. sms_dir) ~= 0 then
luci.template.render("bmx6/error", {txt="sms plugin disabled or some problem with directory " .. sms_dir})
return nil
end
sms_list = luci.util.split(luci.util.exec("ls "..rcvd_dir.."/*:chat"))
for _,sms_path in ipairs(sms_list) do
if #sms_path > #rcvd_dir then
sms_file = luci.util.split(sms_path,'/')
sms_file = sms_file[#sms_file]
sender = luci.util.split(sms_file,':')[1]
-- Trying to clean the name
if string.find(sender,".") ~= nil then
sender = luci.util.split(sender,".")[1]
end
fd = io.open(sms_path,"r")
chat[sender] = fd:read()
fd:close()
end
end
to_send = luci.http.formvalue("toSend")
if to_send ~= nil and #to_send > 1 then
fd = io.open(send_file,"w")
fd:write(to_send)
fd:close()
sent = to_send
else
sent = luci.util.exec("cat "..send_file)
end
luci.template.render("bmx6/chat", {chat=chat,sent=sent})
end

Some files were not shown because too many files have changed in this diff Show more