├── .github ├── FUNDING.yml └── workflows │ ├── build.yml │ ├── coverity.yml │ └── release.yml ├── .gitignore ├── ChangeLog.md ├── LICENSE ├── Makefile.am ├── README.md ├── autogen.sh ├── configure.ac ├── debian ├── .gitignore ├── changelog ├── compat ├── control ├── copyright ├── dirs ├── init.d ├── pimctl.install ├── pimdd.docs ├── pimdd.examples ├── pimdd.install ├── pimdd.lintian-overrides ├── rules └── source │ ├── format │ └── lintian-overrides ├── doc ├── ANNOUNCEMENT ├── BUGS.TODO ├── DEVELOPMENT.NOTES ├── IPC.md ├── LICENSE.mrouted ├── LICENSE.pimd ├── Makefile ├── README ├── RELEASE.NOTES ├── TESTING ├── draft-ietf-idmr-pim-dm-spec-05.txt └── pimd-dense.html ├── include ├── Makefile.am ├── freebsd │ └── netinet │ │ ├── in.h │ │ ├── ip_mroute.h │ │ ├── ip_var.h │ │ ├── pim.h │ │ └── pim_var.h ├── linux │ └── netinet │ │ ├── in-glibc-2.0.h │ │ ├── in-glibc-2.1.h │ │ ├── in-my.h │ │ ├── ip_mroute.h │ │ └── mroute.h ├── netbsd │ └── netinet │ │ ├── in.h │ │ ├── ip_mroute.h │ │ ├── pim.h │ │ └── pim_var.h ├── netinet │ ├── pim.h │ └── pim_var.h ├── sunos-cc │ ├── netinet │ │ ├── igmp.h │ │ └── ip_mroute.h │ └── sys │ │ └── sockio.h └── sunos-gcc │ ├── netinet │ ├── igmp.h │ ├── in.h │ ├── ip_mroute.h │ ├── pim.h │ └── pim_var.h │ └── sys │ └── sockio.h ├── lib ├── .gitignore ├── strlcat.c ├── strlcpy.c └── tempfile.c ├── man ├── Makefile.am ├── pimctl.8 ├── pimdd.8 └── pimdd.conf.5 ├── pimdd.conf ├── pimdd.service.in ├── src ├── .gitignore ├── Makefile.am ├── callout.c ├── cfparse.y ├── config.c ├── debug.c ├── debug.h ├── defs.h ├── dvmrp.h ├── dvmrp_proto.c ├── igmp.c ├── igmp_proto.c ├── igmpv2.h ├── igmpv3.h ├── inet.c ├── ipc.c ├── kern.c ├── main.c ├── mrt.c ├── mrt.h ├── netlink.c ├── pathnames.h ├── pim.c ├── pim_proto.c ├── pimctl.c ├── pimdd.h ├── queue.h ├── route.c ├── routesock.c ├── rsrr.c ├── rsrr.h ├── rsrr_var.h ├── timer.c ├── trace.c ├── trace.h ├── vif.c └── vif.h └── test ├── .gitignore ├── Makefile.am ├── lib.sh ├── mping.c ├── pod.sh ├── shared.sh ├── single.sh ├── test-setup.pdf └── three.sh /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [troglobit] 4 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Bob the Builder 2 | 3 | # Run on all branches, including all pull requests, except the 'dev' 4 | # branch since that's where we run Coverity Scan (limited tokens/day) 5 | on: 6 | push: 7 | branches: 8 | - '**' 9 | - '!dev' 10 | pull_request: 11 | branches: 12 | - '**' 13 | 14 | jobs: 15 | build: 16 | # Verify we can build on latest Ubuntu with both gcc and clang 17 | name: ${{ matrix.compiler }} 18 | runs-on: ubuntu-latest 19 | strategy: 20 | matrix: 21 | compiler: [gcc, clang] 22 | fail-fast: false 23 | env: 24 | MAKEFLAGS: -j3 25 | CC: ${{ matrix.compiler }} 26 | steps: 27 | - name: Install dependencies 28 | run: | 29 | sudo apt-get -y update 30 | sudo apt-get -y install pkg-config libsystemd-dev bird2 ethtool keepalived tshark tree 31 | - uses: actions/checkout@v4 32 | - name: Configure 33 | # Build in a sub-directory so we can safely set a+w on all 34 | # directories. Needed for `make check` since it runs with 35 | # root dropped and wants to write .trs and .log files. 36 | run: | 37 | set -x 38 | ./autogen.sh 39 | ./configure --prefix= --enable-rsrr --enable-test 40 | make dist && archive=$(ls *.tar.gz) 41 | if [ -n "$archive" -a -f "$archive" ]; then 42 | tar xf "$archive" 43 | dir=$(echo "$archive" |rev |cut -f3- -d. |rev) 44 | cd "$dir" 45 | fi 46 | mkdir -p .build/dir 47 | cd .build/dir 48 | ../../configure --prefix= --enable-rsrr --enable-test 49 | chmod -R a+w . 50 | - name: Build 51 | run: | 52 | make V=1 53 | - name: Install 54 | run: | 55 | DESTDIR=~/tmp make install-strip 56 | tree ~/tmp 57 | ldd ~/tmp/sbin/pimdd 58 | size ~/tmp/sbin/pimdd 59 | ldd ~/tmp/sbin/pimctl 60 | size ~/tmp/sbin/pimctl 61 | sudo ~/tmp/sbin/pimdd -p ~/tmp/foo.pid -u ~/tmp/foo.sock 62 | sleep 1 63 | ~/tmp/sbin/pimdd -h 64 | sudo ~/tmp/sbin/pimctl -u ~/tmp/foo.sock -h 65 | sudo ~/tmp/sbin/pimctl -u ~/tmp/foo.sock 66 | sudo ~/tmp/sbin/pimctl -u ~/tmp/foo.sock kill 67 | - name: Test 68 | run: | 69 | make check || (cat test/test-suite.log; false) 70 | - name: Upload Test Results 71 | uses: actions/upload-artifact@v4 72 | with: 73 | name: pimd-dense-test-${{ matrix.compiler }} 74 | path: test/* 75 | -------------------------------------------------------------------------------- /.github/workflows/coverity.yml: -------------------------------------------------------------------------------- 1 | name: Coverity Scan 2 | 3 | on: 4 | push: 5 | branches: 6 | - 'dev' 7 | 8 | env: 9 | PROJECT_NAME: pimd-dense 10 | CONTACT_EMAIL: troglobit@gmail.com 11 | COVERITY_NAME: troglobit-pimd-dense 12 | COVERITY_PROJ: troglobit%2Fpimd-dense 13 | 14 | jobs: 15 | coverity: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: actions/checkout@v4 19 | - name: Fetch latest Coverity Scan MD5 20 | id: var 21 | env: 22 | TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} 23 | run: | 24 | wget -q https://scan.coverity.com/download/cxx/linux64 \ 25 | --post-data "token=$TOKEN&project=${COVERITY_PROJ}&md5=1" \ 26 | -O coverity-latest.tar.gz.md5 27 | echo "md5=$(cat coverity-latest.tar.gz.md5)" | tee -a $GITHUB_OUTPUT 28 | - uses: actions/cache@v3 29 | id: cache 30 | with: 31 | path: coverity-latest.tar.gz 32 | key: ${{ runner.os }}-coverity-${{ steps.var.outputs.md5 }} 33 | restore-keys: | 34 | ${{ runner.os }}-coverity-${{ steps.var.outputs.md5 }} 35 | ${{ runner.os }}-coverity- 36 | ${{ runner.os }}-coverity 37 | - name: Download Coverity Scan 38 | env: 39 | TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} 40 | run: | 41 | if [ ! -f coverity-latest.tar.gz ]; then 42 | wget -q https://scan.coverity.com/download/cxx/linux64 \ 43 | --post-data "token=$TOKEN&project=${COVERITY_PROJ}" \ 44 | -O coverity-latest.tar.gz 45 | else 46 | echo "Latest Coverity Scan available from cache :-)" 47 | md5sum coverity-latest.tar.gz 48 | fi 49 | mkdir coverity 50 | tar xzf coverity-latest.tar.gz --strip 1 -C coverity 51 | - name: Install dependencies 52 | run: | 53 | sudo apt-get -y update 54 | sudo apt-get -y install pkg-config libsystemd-dev 55 | - name: Configure 56 | run: | 57 | ./autogen.sh 58 | ./configure --prefix= --enable-rsrr 59 | - name: Build 60 | run: | 61 | export PATH=`pwd`/coverity/bin:$PATH 62 | cov-build --dir cov-int make 63 | - name: Submit results to Coverity Scan 64 | env: 65 | TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} 66 | run: | 67 | tar czvf ${PROJECT_NAME}.tgz cov-int 68 | curl \ 69 | --form project=${COVERITY_NAME} \ 70 | --form token=$TOKEN \ 71 | --form email=${CONTACT_EMAIL} \ 72 | --form file=@${PROJECT_NAME}.tgz \ 73 | --form version=trunk \ 74 | --form description="${PROJECT_NAME} $(git rev-parse HEAD)" \ 75 | https://scan.coverity.com/builds?project=${COVERITY_PROJ} 76 | - name: Upload build.log 77 | uses: actions/upload-artifact@v4 78 | with: 79 | name: coverity-build.log 80 | path: cov-int/build-log.txt 81 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release General 2 | 3 | on: 4 | push: 5 | tags: 6 | - '[0-9]+.[0-9]+.[0-9]+' 7 | 8 | jobs: 9 | release: 10 | name: Build and upload release tarball 11 | if: startsWith(github.ref, 'refs/tags/') 12 | runs-on: ubuntu-latest 13 | env: 14 | MAKEFLAGS: -j3 15 | steps: 16 | - uses: actions/checkout@v4 17 | - name: Installing dependencies ... 18 | run: | 19 | sudo apt-get -y update 20 | sudo apt-get -y install pkg-config libsystemd-dev 21 | - name: Setting release variables ... 22 | id: build 23 | run: | 24 | ver=${GITHUB_REF#refs/tags/} 25 | echo "ver=${ver}" >> $GITHUB_OUTPUT 26 | if echo $ver | grep -qE '^[0-9]+\.[0-9]+(\.[0-9]+)?(-alpha|-beta|-rc)[0-9]*$'; then 27 | echo "pre=true" >> $GITHUB_OUTPUT 28 | else 29 | echo "pre=false" >> $GITHUB_OUTPUT 30 | fi 31 | if echo $ver | grep -qE '^[0-9.]+\.[0-9.]+(\.[0-9]+)?$'; then 32 | echo "latest=true" >> $GITHUB_OUTPUT 33 | else 34 | echo "latest=false" >> $GITHUB_OUTPUT 35 | fi 36 | - name: Creating Makefiles ... 37 | run: | 38 | ./autogen.sh 39 | ./configure --prefix= --enable-rsrr 40 | - name: Build release ... 41 | run: | 42 | make release || (cat test/test-suite.log; false) 43 | ls -lF ../ 44 | mkdir -p artifacts/ 45 | mv ../*.tar.* artifacts/ 46 | - name: Extract ChangeLog entry ... 47 | run: | 48 | awk '/-----*/{if (x == 1) exit; x=1;next}x' ChangeLog.md \ 49 | |head -n -1 > release.md 50 | cat release.md 51 | - uses: ncipollo/release-action@v1 52 | with: 53 | name: pimd-dense v${{ github.ref_name }} 54 | prerelease: ${{ steps.build.outputs.pre }} 55 | makeLatest: ${{ steps.build.outputs.latest }} 56 | bodyFile: "release.md" 57 | artifacts: "artifacts/*" 58 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | aclocal.m4 3 | autom4te.cache 4 | aux/ 5 | compile 6 | config.h* 7 | config.log 8 | config.status 9 | configure 10 | depcomp 11 | install-sh 12 | missing 13 | stamp-h1 14 | GPATH 15 | GRTAGS 16 | GTAGS 17 | ID 18 | Makefile 19 | Makefile.in 20 | pimdd.service 21 | -------------------------------------------------------------------------------- /ChangeLog.md: -------------------------------------------------------------------------------- 1 | ChangeLog 2 | ========= 3 | 4 | All notable changes to the project are documented in this file. 5 | 6 | 7 | [v2.1.1][] - 2024-01-05 8 | ----------------------- 9 | 10 | ### Changes 11 | - Ignore IGMP proxy queries (source IP 0.0.0.0), they must never win 12 | a querier election. 13 | 14 | ### Fixes 15 | - Fix #4: wrong type for `getopt()` return value 16 | - Fix #5: bug in igmpv2/igmpv3 option parser 17 | 18 | 19 | [v2.1.0][] - 2021-09-12 20 | ----------------------- 21 | 22 | ### Changes 23 | - Sync changes wrt preference/distance in pimdd.conf with pimd sources 24 | - Import `cfparse.y` from mrouted to replace homegrown .conf parser 25 | - Support for `default-route-distance` and `default-route-metric` 26 | - Support for `assert-timeout` 27 | - Import kernel interface probing from mrouted 28 | - Fixes issues with discovering IP addresses on Linux/FreeBSD 29 | - Allows for multinetting, using `altnet` directive from pimd 30 | - Align command line options with pimd 31 | - Rename options to match 32 | - Add `-n` and `-s` command line options 33 | - Add `-l LEVEL` to adjust log level 34 | - Add `-i IDENT` to assume another identity for .conf/.pid and syslog 35 | - Add `-u FILE` to override pimdd/pimctl IPC socket file 36 | - Add `-p FILE` to override pimdd PID file 37 | - Add `-w SEC` startup delay before interface probe 38 | - Rip out unfinished SNMP support 39 | - Add support for IGMPv3, querier and accepting membership reports 40 | - Add support for `no phyint` to start with all interfaces disabled 41 | - Add support for selecting `phyint` by name 42 | - Add support for `pimctl`, from pimd. The tool can be shared with 43 | pimd and used interchangeably between the two daemons 44 | - Add support for PIM Generation ID (genid) in PIM Hello 45 | - Add IP Router Alert option to IGMP and PIM messages, as per RFC2113 46 | - Inform PIM neighbors when we go down/reconfigure, PIM Hello holdtime=0 47 | - Trigger PIM Assert reelection when PIM neighbor goes down 48 | - Add support for querying RPF metric from Linux kernel 49 | - Drop periodic dump of vifs + mrt in log/stderr, we have `pimctl` now 50 | - Check for root privileges *after* checking command line args 51 | - Use configure'd paths for .conf, .pid, and .dump file 52 | - Update license files, stripping "contact Kurt .." and similar, also 53 | update pimd and mrouted license changes, thank you OpenBSD! 54 | - Cleanup, drop old pre-C89 `__P()` macro 55 | - Import safe string API functions from OpenBSD 56 | - Drop PIM-SM and DVMRP specific debug messages/levels, unused 57 | - Add systemd unit file, enabled automatically at configure time 58 | - Add man pages for pimd, pimctl, and pimd.conf in sections 8 and 5 59 | - Support for building .deb packages for Debian and Ubuntu based systemd 60 | 61 | ### Fixes 62 | - Fix PIM Assert handling, with new `assert-timeout` .conf option 63 | - Fix `k_del_vif()`, does not work properly in Linux 64 | - Fix `k_req_incoming()` on FreeBSD 65 | - Fix 100% CPU usage, refactor linked list handling to use `queue.h` 66 | - Fix IGMP querier election bug, lost querier "flag" on interface when 67 | PIM DR election was lost. Thar draft spec PimDM is built around says 68 | largest IP wins DR election, but smallest wins IGMP, follow IGMP RFC 69 | - Only stop active/enabled VIFs, prevent bogus error messages 70 | - Fix unset DSCP value in PIM messages, Internet Control (DS6) 71 | - Fix RSRR (optional) build errors 72 | - Fix various memory leaks identified by Valgrind 73 | - Fix various scary bug identified by Coverity Scan 74 | 75 | 76 | [v0.2.1.0-beta1][] - 2020-05-16 77 | ------------------------------- 78 | 79 | ### Changes 80 | - Converted to GNU Configure & Build system 81 | - Use netlink on Linux, `SIOCGETRPF` doesn't exist 82 | - Cleanup `#ifdef` hell in `accept_igmp()`, unreadable mess due to 83 | how various UNIX flavors handle `SOCK_RAW` and `IP_HDRINCL` 84 | - Use modern signal API, which all UNIX dialects support 85 | - Cleanup, rename reserved function name `log()` to `logit()` 86 | - Relocate source files to `src/` subdirectory 87 | - Use `strerror()` instead of old `sys_errlist[]` & C:o 88 | - Import patches from FreeBSD ports collection: 89 | - https://www.freshports.org/net/pimdd/ 90 | - https://svnweb.freebsd.org/ports/head/net/pimdd/ 91 | 92 | ### Fixes 93 | - Always copy `IFNAMSIZ` bytes interface name to kernel 94 | - Fix missing break statement for SIGALARM in signal handler 95 | - Fix `linux` vs `__linux__` ifdefs and drop a few SYSV ifdefs 96 | - Fix signed vs unsigned comparisons across the tree 97 | - Fix bit shift with negative value, fix imported from pimd, stems from 98 | FreeBSD PR https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=202959 99 | 100 | 101 | [v0.2.1.0-alpha21][] - 1998-12-30 102 | --------------------------------- 103 | 104 | Synch'ed with latest releave pimd (sparse) from USC: 105 | - XXX Timer changes in defs.h compatible with entry/prune timeout changes? 106 | 107 | ### Changes 108 | - (Almost) all timers manipulation now use macros 109 | - pim.h and pim_var.h are in separate common directory 110 | - added BSDI definition to pim_var.h (thanks to Hitoshi Adaeda) 111 | - Now compiles under Linux (haven't check whether the PIMv2 kernel 112 | support in linux-2.1.103 works) 113 | - allpimrouters deleted from igmp.c (already defined in pim.c) 114 | - igmpmsg defined for IRIX 115 | - Linux patches to pim.c and defs.h, contributed by Jonathan Day 116 | . Notes from Jonathan: 117 | 118 | > I'd like to report some bugs in the current version of PimD-Dense, 119 | > which cause compilation to fail under Linux. In `defs.h`, external 120 | > variables that have already been defined are being re-defined, causing 121 | > the compilation to fail. In `pim.c`, there is a typing error - 122 | > `if->ip_len` is referred to, as opposed to `ip->ip_len`. I've 123 | > included the changes I've been using to fix these bugs. 124 | 125 | ### Fixes 126 | - Fixed entry timer initialization in `route.c:process_cache_miss()` 127 | - BUG FIX: fix TIMEOUT definitions in difs.h (bug report by Nidhi Bhaskar) 128 | (originally, if timer value less than 5 seconds, it won't become 0) 129 | - Fixed delay time for LAN prune scheduling to 4 seconds to comply with 130 | spec, which says that prunes should be delayed for time strictly 131 | greater than the maximum join delay of 3 seconds. 132 | - Fixed Prune timeout behavior: 133 | - Prune timeout now triggers graft 134 | - If prune and entry timeout simultaneously, the prune is timed out 135 | first, triggering an entry timer refresh. 136 | - Fixed Assert sending so that asserts sent from upstream routers 137 | without routes to the source send pref and metric of 0x7fffffff. 138 | 139 | 140 | June 19, 1998 141 | ------------- 142 | 143 | Modifications to comply with the latest PIM-DM spec revision: 144 | - Graft retransmission period is now 3 seconds 145 | - Random Join/Prune delay is 3 seconds 146 | 147 | Some still unresolved issues: 148 | - Upstream Address field in Graft and Graft-Ack 149 | 150 | 151 | v0.2.1.0-alpha15 - May 29, 1998 152 | ------------------------------- 153 | 154 | Synched in fixes from Pavlin's pimd-2.1.0-alpha15: 155 | 156 | - Bug fixes related to NetBSD, thanks to Heiko W.Rupp 157 | - `MRT_PIM` completely replaced by `MRT_ASSERT` 158 | 159 | 160 | v0.2.1.0-alpha11 - May 29, 1998 161 | ------------------------------- 162 | 163 | This is the first release of the the PIM Dense-Mode version of pimd. 164 | 165 | For now, I have simply prepended "0." onto the version number for Pavlin 166 | Ivanov Radoslavov's Sparse-Mode pimd, from which this code was derived. 167 | A new 1.0.x-alpha version number will be assigned upon the initial 168 | public release of this code. 169 | 170 | 171 | [UNRELEASED]: https://github.com/troglobit/pimd-dense/compare/2.1.1...HEAD 172 | [v2.1.1]: https://github.com/troglobit/pimd-dense/compare/2.1.0...2.1.1 173 | [v2.1.0]: https://github.com/troglobit/pimd-dense/compare/0.2.1.0-beta1...2.1.0 174 | [v0.2.1.0-beta1]: https://github.com/troglobit/pimd-dense/compare/0.2.1.0-alpha21...0.2.1.0-beta1 175 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 1998 by the University of Oregon. 2 | All rights reserved. 3 | 4 | Permission to use, copy, modify, and distribute this software and its 5 | documentation in source and binary forms for lawful purposes and without 6 | fee is hereby granted, provided that the above copyright notice appear 7 | in all copies and that both the copyright notice and this permission 8 | notice appear in supporting documentation, and that any documentation, 9 | advertising materials, and other materials related to such distribution 10 | and use acknowledge that the software was developed by the University of 11 | Oregon. The name of the University of Oregon may not be used to endorse 12 | or promote products derived from this software without specific prior 13 | written permission. 14 | 15 | THE UNIVERSITY OF OREGON DOES NOT MAKE ANY REPRESENTATIONS ABOUT THE 16 | SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. THIS SOFTWARE IS PROVIDED 17 | "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 18 | WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT. 20 | 21 | IN NO EVENT SHALL UO, OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY 22 | SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, WHETHER IN CONTRACT, 23 | TORT, OR OTHER FORM OF ACTION, ARISING OUT OF OR IN CONNECTION WITH, 24 | THE USE OR PERFORMANCE OF THIS SOFTWARE. 25 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | doc_DATA = README.md ChangeLog.md LICENSE doc/LICENSE.pimd doc/LICENSE.mrouted pimdd.conf 2 | EXTRA_DIST = README.md ChangeLog.md LICENSE doc/LICENSE.pimd doc/LICENSE.mrouted pimdd.conf 3 | DISTCLEANFILES = *~ GPATH GRTAGS GTAGS ID *.gdb *.elf core core.* 4 | SUBDIRS = src include man 5 | 6 | if ENABLE_TEST 7 | SUBDIRS += test 8 | endif 9 | 10 | if SYSTEMD 11 | systemd_DATA = pimdd.service 12 | endif 13 | 14 | ## Generate .deb package 15 | package: 16 | @debuild -uc -us -B --lintian-opts --profile debian -i -I 17 | 18 | ## Check if tagged in git 19 | release-hook: 20 | @if [ ! `git tag -l $(PACKAGE_VERSION) | grep $(PACKAGE_VERSION)` ]; then \ 21 | echo; \ 22 | printf "\e[1m\e[41mCannot find release tag $(PACKAGE_VERSION)\e[0m\n"; \ 23 | printf "\e[1m\e[5mDo release anyway?\e[0m "; read yorn; \ 24 | if [ "$$yorn" != "y" -a "$$yorn" != "Y" ]; then \ 25 | printf "OK, aborting release.\n"; \ 26 | exit 1; \ 27 | fi; \ 28 | echo; \ 29 | else \ 30 | echo; \ 31 | printf "\e[1m\e[42mFound GIT release tag $(PACKAGE_VERSION)\e[0m\n"; \ 32 | printf "\e[1m\e[44m>>Remember to push tags!\e[0m\n"; \ 33 | echo; \ 34 | fi 35 | 36 | ## Target to run when building a release 37 | release: release-hook distcheck 38 | @for file in $(DIST_ARCHIVES); do \ 39 | md5sum $$file > ../$$file.md5; \ 40 | sha256sum $$file > ../$$file.sha256; \ 41 | done 42 | @mv $(DIST_ARCHIVES) ../ 43 | @echo 44 | @echo "Resulting release files =======================================================================" 45 | @for file in $(DIST_ARCHIVES); do \ 46 | printf "%-30s Distribution tarball\n" $$file; \ 47 | printf "%-30s " $$file.md5; cat ../$$file.md5 | cut -f1 -d' '; \ 48 | printf "%-30s " $$file.sha256; cat ../$$file.sha256 | cut -f1 -d' '; \ 49 | done 50 | 51 | DISTCHECK_CONFIGURE_FLAGS = --with-systemd=$$dc_install_base/$(systemd) 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PIM-DM Multicast Routing for UNIX 2 | ================================= 3 | [![Badge][]][License] [![CIstat][]][GitHub] [![Cstat][]][Scan] 4 | 5 | Introduction 6 | ------------ 7 | 8 | pimdd is the dense-mode cousin to [pimd][], the reference implementation 9 | for [PIM-DM draft 5][draft]. Later revised in [RFC3973][], which pimdd 10 | does not (yet) fully support. 11 | 12 | PIM-DM is similar to DVRMP ([mrouted][]), they are both flood-and-prune 13 | multicast routing protocols, but unlike DVMRP, PIM implementations rely 14 | on the underlying unicast routes to be established already. 15 | 16 | This GitHub project is an attempt at reviving pimdd. The latest code on 17 | the master branch has been infused with fresh DNA strands from the 18 | [pimd][] project, including a netlink back-end to read the unicast 19 | routing table, and full IGMPv3 support (ASM). 20 | 21 | > **HELP NEEDED:** The project needs more volunteers to test and update 22 | > `pimdd` to RFC3973. 23 | 24 | 25 | Running pimdd 26 | ------------- 27 | 28 | If you have more than one router, you need to have unicast routing set 29 | up already between all subnets. Usually an IGP like OSPF or even RIP 30 | is used for this. Then start pimdd as root, it backgrounds itself as 31 | a proper UNIX daemon: 32 | 33 | pimdd 34 | 35 | Use the `pimctl` control tool (shared with pimd) to query status. The 36 | project also ships a systemd unit file that allows for customization of 37 | command line arguments using an environment file: `/etc/default/pimdd`. 38 | 39 | See the manual pages for details on command line options, config file 40 | settings, and the `pimctl` control tool: 41 | 42 | - https://man.troglobit.com/man8/pimdd.8.html 43 | - https://man.troglobit.com/man8/pimctl.8.html 44 | - https://man.troglobit.com/man5/pimdd.conf.5.html 45 | 46 | To help out with development, or tracking down bugs, it is recommended 47 | to run pimdd in debug mode. Since there are many debug messages, you 48 | can specify only a subset of the messages to be printed out: 49 | 50 | ``` 51 | Usage: pimdd [-hnpqrsv] [-d SYS[,SYS]] [-f FILE] [-l LVL] [-w SEC] 52 | 53 | -d SYS Enable debug of subsystem(s) 54 | -f FILE Configuration file, default: /etc/pimdd.conf 55 | -h This help text 56 | -i NAME Identity for config + PID file, and syslog, default: pimdd 57 | -l LVL Set log level: none, err, notice (default), info, debug 58 | -n Run in foreground, do not detach from calling terminal 59 | -p FILE Override PID file, default is based on identity, -i 60 | -s Use syslog, default unless running in foreground, -n 61 | -u FILE Override UNIX domain socket, default based on identity, -i 62 | -v Show program version 63 | -w SEC Initial startup delay before probing interfaces 64 | 65 | Available subystems for debug: 66 | all, igmp, groups, igmp_proto, igmp_timers, igmp_members, interfaces, 67 | kernel, mfc, neighbors, pkt, rsrr, pim, asserts, bsr, detail, graft, hello, 68 | registers, routes, pim_routes, jp, pim_timers, rpf, timers, timeout, trace 69 | ``` 70 | 71 | If you want to see all messages, use `pimdd -d all`. When debugging 72 | `pimdd`, it is recommended to run in foreground as well. 73 | 74 | 75 | Build & Install 76 | --------------- 77 | 78 | When building from a released tarball, the configure script is bundled 79 | and you do not need to do anything special (see below for building from 80 | GIT). The Makefile supports de facto standard settings and environment 81 | variables such as `--prefix=PATH` and `DESTDIR=` for the install 82 | process. E.g., to install pimd to `/usr` instead of the default 83 | `/usr/local`, but redirect install to a package directory in `/tmp`: 84 | 85 | ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var 86 | make 87 | make DESTDIR=/tmp/pimd-dense-1.0.0 install-strip 88 | 89 | 90 | Building from GIT 91 | ----------------- 92 | 93 | If you want to contribute, or simply just try out the latest but 94 | unreleased features, then you need to know a few things about the 95 | [GNU build system][build]: 96 | 97 | - `configure.ac` and a per-directory `Makefile.am` are key files 98 | - `configure` and `Makefile.in` are generated from `autogen.sh` 99 | - `Makefile` is generated by `configure` script 100 | 101 | To build from GIT you first need to clone the repository and run the 102 | `autogen.sh` script. This requires `automake` and `autoconf` to be 103 | installed on your system. 104 | 105 | git clone https://github.com/troglobit/pimd-dense.git 106 | cd pimd-dense/ 107 | ./autogen.sh 108 | ./configure && make 109 | 110 | GIT sources are a moving target and are not recommended for production 111 | systems, unless you know what you are doing! 112 | 113 | 114 | Origin & References 115 | ------------------- 116 | 117 | This code is old and was sort of dead and forgotten. The only project 118 | that kept it running was FreeBSD in their ports collection. As such it 119 | was included in the BSD Router Project. 120 | 121 | pimdd was written by Kurt Windisch when he was at University of Oregon. 122 | It is based on the PIM sparse-mode daemon, pimd, which in turn is based 123 | on the DVMRP daemon mrouted. 124 | 125 | pimdd is covered by [LICENSE](LICENSE), Copyright 1998 the University of 126 | Oregon. 127 | 128 | pimd is covered by [LICENSE.pimd](doc/LICENSE.pimd), Copyright 1998-2001 129 | University of Southern California. 130 | 131 | mrouted is covered by [LICENSE.mrouted](doc/LICENSE.mrouted), Copyright 132 | 2002 The Board of Trustees of Leland Stanford Junior University 133 | 134 | [mrouted]: https://github.com/troglobit/mrouted 135 | [pimd]: https://github.com/troglobit/pimd 136 | [draft]: https://github.com/troglobit/pimd-dense/blob/master/doc/draft-ietf-idmr-pim-dm-spec-05.txt 137 | [RFC3973]: https://tools.ietf.org/html/rfc3973 138 | [License]: https://en.wikipedia.org/wiki/BSD_licenses 139 | [Badge]: https://img.shields.io/badge/License-BSD%203--Clause-blue.svg 140 | [GitHub]: https://github.com/troglobit/pimd-dense/actions/workflows/build.yml/ 141 | [CIstat]: https://github.com/troglobit/pimd-dense/actions/workflows/build.yml/badge.svg 142 | [build]: https://autotools.io/ 143 | [Scan]: https://scan.coverity.com/projects/troglobit-pimd-dense 144 | [Cstat]: https://scan.coverity.com/projects/21569/badge.svg 145 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | autoreconf -W portability -visfm 4 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | AC_PREREQ(2.61) 2 | AC_INIT([pimdd], [2.1.1], [https://github.com/troglobit/pimd-dense/issues], 3 | [pimd-dense], [https://github.com/troglobit/pimd-dense/]) 4 | AC_CONFIG_AUX_DIR(aux) 5 | AM_INIT_AUTOMAKE([1.11 foreign]) 6 | AM_SILENT_RULES([yes]) 7 | 8 | AC_CONFIG_SRCDIR([src/main.c]) 9 | AC_CONFIG_HEADERS([config.h]) 10 | AC_CONFIG_FILES([Makefile include/Makefile man/Makefile src/Makefile test/Makefile pimdd.service]) 11 | 12 | # Check for standard programs, headers, and functions 13 | AC_PROG_CC 14 | AC_PROG_INSTALL 15 | AC_PROG_YACC 16 | 17 | # Check build host, differnt for each operating system 18 | AC_CANONICAL_HOST 19 | 20 | case $host_os in 21 | dragonfly*) 22 | CPPFLAGS="-I../include/dragonfly" 23 | ;; 24 | netbsd*) 25 | CPPFLAGS="$CPPFLAGS -D_OPENBSD_SOURCE" 26 | ;; 27 | solaris2.5) 28 | CPPFLAGS="-DSYSV -DSunOS=55 -I../include/sunos-gcc" 29 | LIBS="-lsocket -lnsl" 30 | ;; 31 | solaris2.6|solaris2.7|solaris2.8|solaris2.9|solaris2.10|solaris2.11) 32 | CPPFLAGS="-DSYSV -DSunOS=56 -I../include/sunos-gcc" 33 | LIBS="-lsocket -lnsl" 34 | ;; 35 | linux*) 36 | # -D_GNU_SOURCE Use GNU extensions, where possible (GLIBC) 37 | # -D_BSD_SOURCE Use functions derived from 4.3 BSD Unix rather than POSIX.1 38 | # In GLIBC >= v2.20 this is replaced with -D_DEFAULT_SOURCE, 39 | # but to build on older GLIBC systems we now need both ... 40 | CPPFLAGS="-D_BSD_SOURCE -D_DEFAULT_SOURCE -D_GNU_SOURCE" 41 | ;; 42 | *) 43 | ;; 44 | esac 45 | 46 | # Required to check for libsystemd-dev 47 | PKG_PROG_PKG_CONFIG 48 | 49 | AC_CHECK_HEADERS([fcntl.h netinet/pim.h net/if_dl.h sys/time.h sys/ioctl.h linux/netlink.h termios.h]) 50 | AC_CHECK_HEADERS([net/if.h], [], [], [ 51 | #include 52 | #ifdef STDC_HEADERS 53 | # include 54 | # include 55 | #else 56 | # ifdef HAVE_STDLIB_H 57 | # include 58 | # endif 59 | #endif 60 | #ifdef HAVE_SYS_SOCKET_H 61 | # include 62 | #endif]) 63 | 64 | # Check for usually missing API's, which we can replace 65 | AC_REPLACE_FUNCS([strlcpy strlcat tempfile]) 66 | AC_CONFIG_LIBOBJ_DIR([lib]) 67 | 68 | AC_ARG_ENABLE(rsrr, 69 | AS_HELP_STRING([--enable-rsrr], [Routing Support for Resource Reservation 70 | currently used by RSVP (EXPERIMENTAL). For details, see 71 | http://tools.ietf.org/html/draft-ietf-rsvp-routing-02]),, 72 | enable_rsrr=no) 73 | 74 | AC_ARG_ENABLE(test, 75 | [AS_HELP_STRING([--enable-test], [enable tests, requries unshare, tshark, etc.])], 76 | [enable_test="$enableval"], 77 | [enable_test="no"]) 78 | 79 | AC_ARG_WITH([systemd], 80 | [AS_HELP_STRING([--with-systemd=DIR], [Directory for systemd service files])],, 81 | [with_systemd=auto]) 82 | 83 | # Create config.h from selected features and fallback defaults 84 | AS_IF([test "x$enable_rsrr" = "xyes"], [ 85 | AC_DEFINE(RSRR, 1, [Routing Support for Resource Reservation.])]) 86 | 87 | AS_IF([test "x$with_systemd" = "xyes" -o "x$with_systemd" = "xauto"], [ 88 | def_systemd=$($PKG_CONFIG --variable=systemdsystemunitdir systemd) 89 | AS_IF([test "x$def_systemd" = "x"], 90 | [AS_IF([test "x$with_systemd" = "xyes"], 91 | [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])]) 92 | with_systemd=no], [with_systemd="$def_systemd"])] 93 | ) 94 | AS_IF([test "x$with_systemd" != "xno"], 95 | [AC_SUBST([systemddir], [$with_systemd])]) 96 | 97 | AM_CONDITIONAL(BSD, [test "x$ac_cv_header_net_if_dl_h" = "xyes"]) 98 | AM_CONDITIONAL(LINUX, [test "x$ac_cv_header_linux_netlink_h" = "xyes"]) 99 | AM_CONDITIONAL(RSRR, [test "x$enable_rsrr" = "xyes"]) 100 | AM_CONDITIONAL(SYSTEMD, [test "x$with_systemd" != "xno"]) 101 | AM_CONDITIONAL(ENABLE_TEST, [test "x$enable_test" != "xno"]) 102 | 103 | # Expand $sbindir early, into $SBINDIR, for systemd unit file 104 | # NOTE: This does *not* take prefix/exec_prefix override at "make 105 | # install" into account, unfortunately. 106 | test "x$prefix" = xNONE && prefix=$ac_default_prefix 107 | test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' 108 | DOCDIR=`eval echo $docdir` 109 | DOCDIR=`eval echo $DOCDIR` 110 | AC_SUBST(DOCDIR) 111 | SYSCONFDIR=`eval echo $sysconfdir` 112 | SYSCONFDIR=`eval echo $SYSCONFDIR` 113 | AC_SUBST(SYSCONFDIR) 114 | SBINDIR=`eval echo $sbindir` 115 | SBINDIR=`eval echo $SBINDIR` 116 | AC_SUBST(SBINDIR) 117 | 118 | # Workaround for as-of-yet unreleased runstatedir support, planned for 119 | # autoconf 2.70, which some major distros have backported. 120 | AS_IF([test -z "$runstatedir"], runstatedir="$localstatedir/run") 121 | AC_SUBST(runstatedir) 122 | 123 | # Generate all files 124 | AC_OUTPUT 125 | 126 | cat < Fri, 05 Jan 2024 21:36:14 +0200 8 | 9 | pimd-dense (2.1.0) stable; urgency=low 10 | 11 | * Initial release. 12 | 13 | -- Joachim Wiberg Sun, 12 Sep 2021 13:36:06 +0200 14 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: pimd-dense 2 | Section: net 3 | Priority: optional 4 | Maintainer: Joachim Wiberg 5 | Build-Depends: debhelper (>= 10), bison | byacc | btyacc, pkg-config, systemd 6 | Standards-Version: 4.3.0 7 | Homepage: https://github.com/troglobit/pimd-dense 8 | Vcs-Browser: https://github.com/troglobit/pimd-dense 9 | Vcs-Git: https://github.com/troglobit/pimd-dense.git 10 | 11 | Package: pimdd 12 | Architecture: any 13 | Depends: ${shlibs:Depends}, ${misc:Depends}, lsb-base (>= 3.0-6) 14 | Description: PIM-DM for UNIX 15 | pimdd is the dense-mode cousin to pimd, the reference implementation of 16 | PIM-DM draft 5, later revised in RFC3973. 17 | . 18 | PIM-DM is similar to DVRMP (mrouted), they are both flood-and-prune 19 | multicast routing protocols, but unlike DVMRP, PIM implementations rely 20 | on the underlying unicast routes to be established already. E.g., with 21 | OSPF, RIP, or statically configured routes. 22 | 23 | Package: pimctl 24 | Architecture: any 25 | Depends: ${shlibs:Depends}, ${misc:Depends} 26 | Description: Shared control tool for pimd, pimdd, and pim6sd 27 | pimctl can be used to query status, debug, restart, and kill a running 28 | pimd, pimdd, and pim6sd. 29 | . 30 | The tool is shared between the different projects, this one is bundled 31 | with pimd-dense, but any one of them can be used since they first query 32 | available commands from the running daemon. 33 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: pimd-dense 3 | Upstream-Contact: troglobit@gmail.com 4 | Source: https://github.com/troglobit/pimd-dense 5 | 6 | Files: * 7 | Copyright: 1998-2001 University of Southern California/Information Sciences Institute 8 | Comment: pimd-dense is built on top of an older version of pimd (sparse), 9 | so the default/fallback license for all files are the same as pimd. 10 | In many cases the previous Oregon license has been reverted back to 11 | the USC since most of the code from pimd has been grafted onto pimdd 12 | by Joachim Wiberg during the reconstruction effort. The wonderful 13 | mix with the mrouted code base makes it hard to see the difference, 14 | but most of the configuration, main, and DVMRP specific code is all 15 | that remains of the mrouted code base. The pimd-dense specifics 16 | are centered around the PIM source files. 17 | License: PIMD 18 | 19 | Files: src/callout.c src/cfparse.y src/dvmrp* src/inet.c src/kern.c src/trace.* src/vif.* 20 | Copyright: 2002 The Board of Trustees of the Leland Stanford Junior University 21 | Comment: mrouted was made fully open source by Standford in March 2003 thanks 22 | to the effort by the OpenBSD project. For the full story, see the 23 | commit log for the LICENSE file in the OpenBSD CVS repository: 24 | http://www.openbsd.org/cgi-bin/cvsweb/src/usr.sbin/mrouted/LICENSE 25 | License: MROUTED 26 | 27 | Files: src/defs.h src/main.c src/mrt.* src/pimdd.h src/pim_proto.c src/route.c src/timer.c 28 | Copyright: 1998 University of Oregon 29 | License: PIMDD 30 | 31 | Files: src/pimctl* src/ipc.c 32 | Copyright: 2018-2020 Joachim Wiberg 33 | License: BSD-3-clause 34 | 35 | Files: src/netlink.c 36 | Copyright: Fred Griffoul 37 | License: public-domain 38 | 39 | Files: lib/strlcpy.c 40 | Copyright: 1998, 2015 Todd C. Miller 41 | License: ISC 42 | 43 | Files: lib/strlcat.c 44 | Copyright: 1998, 2015 Todd C. Miller 45 | License: ISC 46 | 47 | Files: lib/tempfile.c 48 | Copyright: 2015-2020 Joachim Wiberg 49 | License: ISC 50 | 51 | Files: debian/* 52 | Comment: pimdd was packaged by Joachim Wiberg on 53 | Sun, 12 Sep 2021 13:46:19 +0200 based on the mrouted package. 54 | Copyright: 2021 Joachim Wiberg 55 | License: ISC 56 | 57 | License: MROUTED 58 | Permission is hereby granted to STANFORD's rights, free of charge, to any 59 | person obtaining a copy of this Software and associated documentation files 60 | ( "MROUTED"), to deal in MROUTED without restriction, including without 61 | limitation the rights to use, copy, modify, merge, publish, distribute, 62 | sublicense, and/or sell copies of MROUTED , and to permit persons to whom 63 | MROUTED is furnished to do so, subject to the following conditions: 64 | 1) The above copyright notice and this permission notice shall be 65 | included in all copies or substantial portions of the MROUTED . 66 | 2) Neither the STANFORD name nor the names of its contributors may be 67 | used in any promotional advertising or other promotional materials to be 68 | disseminated to the public or any portion thereof nor to use the name of 69 | any STANFORD faculty member, employee, or student, or any trademark, 70 | service mark, trade name, or symbol of STANFORD or Stanford Hospitals and 71 | Clinics, nor any that is associated with any of them, without STANFORD's 72 | prior written consent. Any use of STANFORD's name shall be limited to 73 | statements of fact and shall not imply endorsement of any products or 74 | services. 75 | 3) MROUTED IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 76 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 77 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 78 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 79 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 80 | FROM, OUT OF OR IN CONNECTION WITH MROUTED OR THE USE OR OTHER DEALINGS IN 81 | THE MROUTED. 82 | Comment: The license is 3-clause BSD style license, but is not word-for-word 83 | compatible. Non-printable, or 8-bit, characters have been replaced. 84 | 85 | License: PIMD 86 | Redistribution and use in source and binary forms, with or without 87 | modification, are permitted provided that the following conditions are met: 88 | . 89 | 1. Redistributions of source code must retain the above copyright notice, 90 | this list of conditions and the following disclaimer. 91 | 2. Redistributions in binary form must reproduce the above copyright notice, 92 | this list of conditions and the following disclaimer in the documentation 93 | and/or other materials provided with the distribution. 94 | 3. Neither the name of the copyright holders nor the names of its 95 | contributors may be used to endorse or promote products derived from this 96 | software without specific prior written permission. 97 | . 98 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 99 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 100 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 101 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 102 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 103 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 104 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 105 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 106 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 107 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 108 | POSSIBILITY OF SUCH DAMAGE. 109 | 110 | License: PIMDD 111 | Permission to use, copy, modify, and distribute this software and its 112 | documentation in source and binary forms for lawful purposes and without 113 | fee is hereby granted, provided that the above copyright notice appear 114 | in all copies and that both the copyright notice and this permission 115 | notice appear in supporting documentation, and that any documentation, 116 | advertising materials, and other materials related to such distribution 117 | and use acknowledge that the software was developed by the University of 118 | Oregon. The name of the University of Oregon may not be used to endorse 119 | or promote products derived from this software without specific prior 120 | written permission. 121 | . 122 | THE UNIVERSITY OF OREGON DOES NOT MAKE ANY REPRESENTATIONS ABOUT THE 123 | SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. THIS SOFTWARE IS PROVIDED 124 | "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 125 | WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 126 | FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT. 127 | . 128 | IN NO EVENT SHALL UO, OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY 129 | SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, WHETHER IN CONTRACT, 130 | TORT, OR OTHER FORM OF ACTION, ARISING OUT OF OR IN CONNECTION WITH, 131 | THE USE OR PERFORMANCE OF THIS SOFTWARE. 132 | -------------------------------------------------------------------------------- /debian/dirs: -------------------------------------------------------------------------------- 1 | usr/sbin 2 | etc 3 | -------------------------------------------------------------------------------- /debian/init.d: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ### BEGIN INIT INFO 3 | # Provides: pimdd 4 | # Required-Start: $remote_fs $syslog $network 5 | # Required-Stop: $remote_fs $syslog $network 6 | # Default-Start: 2 3 4 5 7 | # Default-Stop: 0 1 6 8 | # Short-Description: PIM-DM 9 | # Description: PIM Dense Mode multicast routing daemon 10 | ### END INIT INFO 11 | . /lib/lsb/init-functions 12 | 13 | PATH=/bin:/usr/bin:/sbin:/usr/sbin 14 | DESC="PIM dense mode multicast routing daemon" 15 | NAME=pimdd 16 | 17 | DAEMON=/usr/sbin/pimdd 18 | PIDFILE=/var/run/pimdd.pid 19 | SCRIPTNAME=/etc/init.d/$NAME 20 | 21 | # Exit if the package is not installed 22 | [ -x "$DAEMON" ] || exit 0 23 | 24 | # Read configuration variable file if it is present 25 | [ -r /etc/default/$NAME ] && . /etc/default/$NAME 26 | 27 | # Define LSB log_* functions. 28 | . /lib/lsb/init-functions 29 | 30 | do_start() 31 | { 32 | start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- $PIMDD_OPTIONS 33 | } 34 | 35 | do_signal() 36 | { 37 | start-stop-daemon --stop --quiet --signal $1 $2 --pidfile $PIDFILE --exec $DAEMON 38 | } 39 | 40 | do_stop() 41 | { 42 | do_signal TERM --oknodo 43 | } 44 | 45 | do_reload() 46 | { 47 | do_signal HUP 48 | } 49 | 50 | case "$1" in 51 | start) 52 | log_daemon_msg "Starting $DESC" "$NAME" 53 | do_start 54 | case "$?" in 55 | 0) log_end_msg 0 ;; 56 | 1) log_progress_msg "already started" 57 | log_end_msg 0 ;; 58 | *) log_end_msg 1 ;; 59 | esac 60 | ;; 61 | 62 | stop) 63 | log_daemon_msg "Stopping $DESC" "$NAME" 64 | do_stop 65 | case "$?" in 66 | 0) log_end_msg 0 ;; 67 | 1) log_progress_msg "already stopped" 68 | log_end_msg 0 ;; 69 | *) log_end_msg 1 ;; 70 | esac 71 | ;; 72 | 73 | reload) 74 | log_daemon_msg "Reloading $DESC" "$NAME" 75 | do_reload 76 | case "$?" in 77 | 0) log_end_msg 0 ;; 78 | 1) log_progress_msg "not running" 79 | log_end_msg 1 ;; 80 | *) log_end_msg 1 ;; 81 | esac 82 | ;; 83 | 84 | restart|force-reload) 85 | $0 stop 86 | $0 start 87 | ;; 88 | 89 | try-restart) 90 | $0 status >/dev/null 2>&1 && $0 restart 91 | ;; 92 | 93 | status) 94 | status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $? 95 | ;; 96 | 97 | *) 98 | echo "Usage: $SCRIPTNAME {start|stop|reload|restart|force-reload|try-restart|status}" >&2 99 | exit 3 100 | ;; 101 | esac 102 | 103 | : 104 | -------------------------------------------------------------------------------- /debian/pimctl.install: -------------------------------------------------------------------------------- 1 | usr/sbin/pimctl 2 | usr/share/man/man8/pimctl.8 3 | -------------------------------------------------------------------------------- /debian/pimdd.docs: -------------------------------------------------------------------------------- 1 | README.md 2 | -------------------------------------------------------------------------------- /debian/pimdd.examples: -------------------------------------------------------------------------------- 1 | pimdd.conf 2 | -------------------------------------------------------------------------------- /debian/pimdd.install: -------------------------------------------------------------------------------- 1 | lib/systemd/system/pimdd.service 2 | usr/sbin/pimdd 3 | usr/share/man/man8/pimdd.8 4 | usr/share/man/man5/pimdd.conf.5 5 | -------------------------------------------------------------------------------- /debian/pimdd.lintian-overrides: -------------------------------------------------------------------------------- 1 | pimdd: spelling-error-in-binary usr/sbin/pimdd iif if 2 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # Uncomment this to turn on verbose mode. 3 | #export DH_VERBOSE=1 4 | 5 | # See dpkg-buildflags(1) manpage 6 | export DEB_BUILD_MAINT_OPTIONS = hardening=+all 7 | 8 | %: 9 | dh $@ --with autoreconf,systemd 10 | 11 | override_dh_installchangelogs: 12 | dh_installchangelogs ChangeLog.md 13 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) -------------------------------------------------------------------------------- /debian/source/lintian-overrides: -------------------------------------------------------------------------------- 1 | pimdd source: empty-debian-diff 2 | pimdd source: native-package-with-dash-version 3 | -------------------------------------------------------------------------------- /doc/ANNOUNCEMENT: -------------------------------------------------------------------------------- 1 | The first public version of pimd-dense is now available 2 | Pimd-dense is a lightweight, stand-alone PIM-Dense Mode 3 | implementation that may be freely distributed or deployed. 4 | Pimd-Dense implements the full PIM-DM specification with a few 5 | noted exceptions (See the release notes). 6 | 7 | PimD-Dense is currently ALPHA-version software that still 8 | requires extensive testing. If you choose to use it, send any 9 | comments or bug reports to kurtw@antc.uoregon.edu. 10 | 11 | PimD-Dense should compile and run on most UNIX varieties, including 12 | FreeBSD, BSDI, NetBSD, SunOS, IRIX, Solaris 2.5, Solaris 2.6, and Linux 13 | (however it has not yet been tested on all these). 14 | 15 | The software and information may be obtained from the website of 16 | the University of Oregon's Advanced Network Technology Center (ANTC). 17 | 18 | For more information: 19 | http://www.antc.uoregon.edu/PIMDM/pimd-dense.html 20 | 21 | For anonymous FTP: 22 | ftp://ns.uoregon.edu/pub/src/pimd-dense.tar.gz 23 | 24 | ----------------------------------------------------------------------- 25 | Kurt Windisch kurtw@antc.uoregon.edu 26 | Network Engineer/Research Asst. (TEL) 541-346-1698 27 | Advanced Network Technology Center (ANTC) (FAX) 541-346-4397 28 | University of Oregon http://www.cs.uoregon.edu/~kurtw/ 29 | PGP figerprint: 33 2A 7E 38 24 36 03 11 DB BF 22 DA C4 28 CC 23 30 | 31 | -------------------------------------------------------------------------------- /doc/BUGS.TODO: -------------------------------------------------------------------------------- 1 | $Id: BUGS.TODO,v 1.8 1998/12/31 19:28:39 kurtw Exp $ 2 | 3 | THIS LIST IS FAR AWAY FROM BEING COMPLETE, so these are the few things 4 | that came up at the right moment to be written down. 5 | 6 | ------- 7 | JOACHIM 8 | 9 | Before release: 10 | * [DONE] Use yacc-based parser from pim6sd project 11 | * [DONE] Startup query handling fomr pim6sd project 12 | * [DONE] Handle IGMP querier timeout, not handled atm. 13 | * [DONE] Send PIM Hello holdtime=0 on shutdown/reconf 14 | * [DONE] When receiving holdtime=0, trigger Assert relection 15 | * [DONE] Fix "pim status" output, what's relevant? 16 | * [DONE] Add "mrt" and "mfc" concepts to pimctl/ipc commands 17 | * [DONE] Add ident, -i NAME, support from pimd 18 | * [DONE] Add custom IPC socket file, -u FILE, from SMCRoute 19 | * Add basic automatic test, use framework from SMCRoute 20 | * [DONE] Test in non-trivial (POD?) setup with CORE 21 | * [DONE] Split man page in two -> pimdd.conf.5 22 | * [DONE] Add ChangeLog.md 23 | * Add RPF support for FreeBSD, import routing socket support from pimd 24 | 25 | Bonus, or later release: 26 | * Issue #2: Support for (prune) state refresh 27 | * Investigate migrating to linked lists from BSD queue.h 28 | 29 | ------- 30 | KURT: 31 | 32 | * FIXED ? DR does not go to highest IP when new neighbor appears!!! 33 | 34 | * Sync with changes in the lastest Sparse-Mode pimd release 35 | Pimd-dense is now synched up to alpha21. 36 | 37 | * The mrtentry preference/metrics should be used to indicate the 38 | distance/metric for the upstream assert winner for comparison with 39 | assert messages received from upstream. When lacking upstream 40 | distance/metric info (before assert or after assert times out), 41 | should the mrtentry pref/metric be set to 0/0 (or some other 42 | arbitrary values) or to the distance/metric of the source for the 43 | local router (which should always be greater than those 44 | received from asserts)??? I think the current scheme is okay: 45 | set to 0/0 when allocating mrtentry and source distance/metric when 46 | creating route before assert or when timing out assert. 47 | 48 | ------- 49 | * Use NetBSD's definition for IPADDR (netinet/in.h): 50 | #ifdef _KERNEL 51 | #define __IPADDR(x) ((u_int32_t) htonl((u_int32_t)(x))) 52 | #else 53 | #define __IPADDR(x) ((u_int32_t)(x)) 54 | #endif 55 | 56 | * Check whether the kernel code sends CACHE_MISS and WRONG_IIF for 57 | the LAN-scoped addresses 58 | 59 | * If a new interface is configured, include it automatically 60 | 61 | * Don't create routing entries for local link scoped groups 62 | 63 | * Implement adm. scoped filters 64 | 65 | * Do more precise error check for the received PIM messages. In most cases, 66 | the whole message must be parsed completely before starting processing it. 67 | 68 | * Clean up the debugging messages. 69 | 70 | * Use Patricia tree to search the routing table 71 | (There is a nice paper in Sigcomm '97 about fast routing tables 72 | implementation, so need to check it as well) 73 | 74 | * Change all countdown timers to events timeout (callout.c) 75 | (The current implementation is very unefficient if the routing table becomes 76 | very large) 77 | 78 | * Fix the code allowing interface UP/DOWN without restarting pimd. 79 | 80 | * Test the RSRR (RSVP support) code 81 | 82 | * Send Initial_Reply RSRR message if the interfaces detected by pimd change 83 | -------------------------------------------------------------------------------- /doc/DEVELOPMENT.NOTES: -------------------------------------------------------------------------------- 1 | Dense-mode TODO: 2 | ----------------- 3 | - Go through Pavlin's notes in BUGS.TODO and resolve 4 | 5 | TESTING/BUGS 6 | ------------ 7 | 8 | 9 | NOTES 10 | ----- 11 | -------------------------------------------------------------------------------- /doc/IPC.md: -------------------------------------------------------------------------------- 1 | pimctl ipc interface 2 | ==================== 3 | 4 | pimdd share pimctl with pimd. The front-end itself is fairly simple and 5 | independent of either PIM daemon. 6 | 7 | The default socket file is /var/run/pimctl.sock if multiple PIM daemons 8 | are used at the same time (possible on Linux), the user have to set the 9 | socket path for both daemons and client. 10 | 11 | The API is designed around sending string commands to the daemon over 12 | the socket. Each command from pimctl results in a, possibly multi-line, 13 | string response from the daemon. 14 | 15 | commands 16 | -------- 17 | 18 | - `usage`: multi-line command + description 19 | 20 | The command starts at column 0, description follows on the 21 | next line and is always indented with white space (TAB) 22 | 23 | - `version`: version of daemon, e.g. "pimd v2.3.2" 24 | 25 | -------------------------------------------------------------------------------- /doc/LICENSE.mrouted: -------------------------------------------------------------------------------- 1 | Copyright © 2002 The Board of Trustees of the Leland Stanford Junior University 2 | 3 | Permission is hereby granted to STANFORD's rights, free of charge, to any 4 | person obtaining a copy of this Software and associated documentation files 5 | ("MROUTED"), to deal in MROUTED without restriction, including without 6 | limitation the rights to use, copy, modify, merge, publish, distribute, 7 | sublicense, and/or sell copies of MROUTED, and to permit persons to whom 8 | MROUTED is furnished to do so, subject to the following conditions: 9 | 10 | 1) The above copyright notice and this permission notice shall be included 11 | in all copies or substantial portions of the MROUTED. 12 | 13 | 2) Neither the STANFORD name nor the names of its contributors may be used 14 | in any promotional advertising or other promotional materials to be 15 | disseminated to the public or any portion thereof nor to use the name of 16 | any STANFORD faculty member, employee, or student, or any trademark, 17 | service mark, trade name, or symbol of STANFORD or Stanford Hospitals 18 | and Clinics, nor any that is associated with any of them, without 19 | STANFORD's prior written consent. Any use of STANFORD's name shall be 20 | limited to statements of fact and shall not imply endorsement of any 21 | products or services. 22 | 23 | 3) MROUTED IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 27 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 28 | ARISING FROM, OUT OF OR IN CONNECTION WITH MROUTED OR THE USE OR OTHER 29 | DEALINGS IN THE MROUTED. 30 | -------------------------------------------------------------------------------- /doc/LICENSE.pimd: -------------------------------------------------------------------------------- 1 | Copyright (C) 1998-2001 University of Southern California/Information Sciences Institute 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 3. Neither the name of the copyright holders nor the names of its 13 | contributors may be used to endorse or promote products derived from this 14 | software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 20 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the Daemon part of PIM-SMv2.0, 3 | # Protocol Independent Multicast, Sparse-Mode version 2.0 4 | # 5 | # 6 | # Questions concerning this software should be directed to 7 | # Kurt Windisch (kurtw@antc.uoregon.edu) 8 | # 9 | # $Id: Makefile,v 1.10 1998/12/22 21:50:16 kurtw Exp $ 10 | # 11 | # XXX: SEARCH FOR "CONFIGCONFIGCONFIG" (without the quotas) for the lines 12 | # that might need configuration 13 | 14 | PROG_NAME=pimdd 15 | 16 | #CONFIGCONFIGCONFIG 17 | # 18 | # flags: 19 | # -DSAVE_MEMORY: saves 4 bytes per unconfigured interface 20 | # per routing entry. If set, configuring such interface 21 | # will restart the daemon and will flush the routing 22 | # table. 23 | # 24 | MISCDEFS= # -DSAVE_MEMORY 25 | 26 | # 27 | # Version control stuff. Nothing should be changed 28 | # 29 | VERSION = `cat VERSION` 30 | CVS_VERSION = `cat VERSION | sed 'y/./_/' | sed 'y/-/_/'` 31 | CVS_LAST_VERSION=`cat CVS_LAST_VERSION` 32 | PROG_VERSION = ${PROG_NAME}-${VERSION} 33 | PROG_CVS_VERSION = ${PROG_NAME}_${CVS_VERSION} 34 | PROG_CVS_LAST_VERSION = ${PROG_NAME}_${CVS_LAST_VERSION} 35 | 36 | #CONFIGCONFIGCONFIG 37 | # Uncomment the following line if you want to use RSRR (Routing 38 | # Support for Resource Reservations), currently used by RSVP. 39 | RSRRDEF= -DRSRR 40 | 41 | CC?= gcc 42 | MCAST_INCLUDE= -Iinclude 43 | LDFLAGS?= 44 | 45 | #CONFIGCONFIGCONFIG 46 | PURIFY= purify -cache-dir=/tmp -collector=/import/pkgs/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3_U1/2.7.2.2/ld 47 | 48 | #CONFIGCONFIGCONFIG 49 | ### Compilation flags for different platforms. Uncomment only one of them 50 | ## FreeBSD 51 | #CFLAGS+= ${MCAST_INCLUDE} ${RSRRDEF} ${MISCDEFS} -DFreeBSD -DPIM -Dlog=logit ${CPPFLAGS} 52 | 53 | ## NetBSD -DNetBSD is done by OS 54 | #CFLAGS= -Wall -g -Iinclude/netbsd ${MCAST_INCLUDE} ${RSRRDEF} ${MISCDEFS} -DPIM 55 | 56 | ## BSDI 57 | #CFLAGS= -g ${MCAST_INCLUDE} ${RSRRDEF} ${MISCDEFS} -DBSDI -DPIM 58 | 59 | ## SunOS, OSF1, gcc 60 | #CFLAGS= -Wall -g -Iinclude/sunos-gcc ${MCAST_INCLUDE} ${RSRRDEF} ${MISCDEFS} -DSunOS=43 -DPIM 61 | ## SunOS, OSF1, cc 62 | #CFLAGS= -g -Iinclude/sunos-cc ${MCAST_INCLUDE} ${RSRRDEF} ${MISCDEFS} -DSunOS=43 -DPIM 63 | 64 | ## IRIX 65 | #CFLAGS= -Wall -g ${MCAST_INCLUDE} ${RSRRDEF} ${MISCDEFS} -D_BSD_SIGNALS -DIRIX -DPIM 66 | 67 | ## Solaris 2.5, gcc 68 | #CFLAGS= -Wall -g ${MCAST_INCLUDE} ${RSRRDEF} ${MISCDEFS} -DSYSV -DSunOS=55 -DPIM 69 | ## Solaris 2.5, cc 70 | #CFLAGS= -g ${MCAST_INCLUDE} ${RSRRDEF} ${MISCDEFS} -DSYSV -DSunOS=55 -DPIM 71 | ## Solaris 2.6 72 | #CFLAGS= -g ${MCAST_INCLUDE} ${RSRRDEF} ${MISCDEFS} -DSYSV -DSunOS=56 -DPIM 73 | ## Solaris 2.x 74 | #LIB2= -L/usr/ucblib -lucb -L/usr/lib -lsocket -lnsl 75 | 76 | ## Linux 77 | CFLAGS= -Iinclude -Iinclude/linux ${RSRRDEF} ${MISCDEFS} -D__BSD_SOURCE -DRAW_INPUT_IS_RAW -DRAW_OUTPUT_IS_RAW -DIOCTL_OK_ON_RAW_SOCKET -DPIM -Dlog=logit 78 | 79 | 80 | LIBS= ${LIB2} 81 | LINTFLAGS= ${MCAST_INCLUDE} ${CFLAGS} 82 | 83 | IGMP_SRCS= igmp.c igmp_proto.c trace.c 84 | IGMP_OBJS= igmp.o igmp_proto.o trace.o 85 | ROUTER_SRCS= inet.c kern.c main.c config.c debug.c routesock.c \ 86 | vers.c callout.c 87 | ROUTER_OBJS= inet.o kern.o main.o config.o debug.o routesock.o \ 88 | vers.o callout.o 89 | PIM_SRCS= route.c vif.c timer.c mrt.c pim.c pim_proto.c 90 | PIM_OBJS= route.o vif.o timer.o mrt.o pim.o pim_proto.o 91 | DVMRP_SRCS= dvmrp_proto.c 92 | DVMRP_OBJS= dvmrp_proto.o 93 | RSRR_SRCS= rsrr.c 94 | RSRR_OBJS= rsrr.o 95 | RSRR_HDRS= rsrr.h rsrr_var.h 96 | HDRS= debug.h defs.h dvmrp.h igmpv2.h mrt.h pathnames.h pimdd.h \ 97 | trace.h vif.h ${RSRR_HDRS} 98 | SRCS= ${IGMP_SRCS} ${ROUTER_SRCS} ${PIM_SRCS} ${DVMRP_SRCS} \ 99 | ${RSRR_SRCS} 100 | OBJS= ${IGMP_OBJS} ${ROUTER_OBJS} ${PIM_OBJS} ${DVMRP_OBJS} \ 101 | ${RSRR_OBJS} 102 | DISTFILES= README CHANGES ${SRCS} ${HDRS} VERSION LICENSE \ 103 | LICENSE.mrouted Makefile pimdd.conf BUGS.TODO include 104 | 105 | all: ${PROG_NAME} 106 | 107 | ${PROG_NAME}: ${IGMP_OBJS} ${ROUTER_OBJS} ${PIM_OBJS} ${DVMRP_OBJS} \ 108 | ${RSRR_OBJS} ${CMULIBS} 109 | rm -f $@ 110 | ${CC} ${LDFLAGS} -o $@ ${CFLAGS} ${IGMP_OBJS} ${ROUTER_OBJS} \ 111 | ${PIM_OBJS} ${DVMRP_OBJS} ${RSRR_OBJS} ${LIBS} 112 | 113 | purify: ${OBJS} 114 | ${PURIFY} ${CC} ${LDFLAGS} -o ${PROG_NAME} ${CFLAGS} \ 115 | ${IGMP_OBJS} ${ROUTER_OBJS} ${PIM_OBJS} ${DVMRP_OBJS} ${RSRR_OBJS} \ 116 | ${LIBS} 117 | 118 | 119 | vers.c: VERSION 120 | rm -f $@ 121 | sed -e 's/.*/char todaysversion[]="&";/' < VERSION > vers.c 122 | 123 | release: cvs-commit cvs-tag last-dist 124 | 125 | re-release: cvs-commit cvs-retag last-dist 126 | 127 | cvs-commit: 128 | cvs commit -m "make cvs-commit VERSION=${PROG_VERSION}" 129 | 130 | cvs-tag: 131 | cvs tag ${PROG_CVS_VERSION} 132 | `cat VERSION | sed 'y/./_/' | sed 'y/-/_/' > CVS_LAST_VERSION` 133 | 134 | cvs-retag: 135 | cvs tag -F ${PROG_CVS_VERSION} 136 | `cat VERSION | sed 'y/./_/' | sed 'y/-/_/' > CVS_LAST_VERSION` 137 | 138 | last-dist: 139 | - mv ${PROG_NAME} _${PROG_NAME}.SAVE_ 140 | - rm -rf ${PROG_VERSION} 141 | - rm -rf ${PROG_VERSION}.tar.gz 142 | - rm -rf ${PROG_VERSION}.tar.gz.formail 143 | cvs export -r ${PROG_CVS_LAST_VERSION} ${PROG_NAME} 144 | mv ${PROG_NAME} ${PROG_VERSION} 145 | tar cvf - ${PROG_VERSION} | gzip > ${PROG_VERSION}.tar.gz 146 | uuencode ${PROG_VERSION}.tar.gz ${PROG_VERSION}.tar.gz > ${PROG_VERSION}.tar.gz.formail 147 | rm -rf ${PROG_VERSION} 148 | - mv _${PROG_NAME}.SAVE_ ${PROG_NAME} 149 | 150 | curr-dist: 151 | - mv ${PROG_NAME} _${PROG_NAME}.SAVE_ 152 | cvs commit -m "make curr-dist VERSION=${PROG_VERSION}" 153 | - rm -rf ${PROG_NAME}-current 154 | - rm -rf ${PROG_NAME}-current.tar.gz 155 | - rm -rf ${PROG_NAME}-current.tar.gz.formail 156 | cvs checkout ${PROG_NAME} 157 | mv ${PROG_NAME} ${PROG_NAME}-current 158 | tar cvf - ${PROG_NAME}-current | gzip > ${PROG_NAME}-current.tar.gz 159 | uuencode ${PROG_NAME}-current.tar.gz ${PROG_NAME}-current.tar.gz > ${PROG_NAME}-current.tar.gz.formail 160 | rm -rf ${PROG_NAME}-current 161 | - mv _${PROG_NAME}.SAVE_ ${PROG_NAME} 162 | 163 | curr-diff: 164 | cvs commit -m "make curr-diff VERSION=${PROG_VERSION}" 165 | cvs rdiff -kk -u -r ${PROG_CVS_LAST_VERSION} ${PROG_NAME} > ${PROG_NAME}-current.diff 166 | 167 | 168 | install: ${PROG_NAME} 169 | install -d /usr/local/bin 170 | install -m 0755 -f /usr/local/bin ${PROG_NAME} 171 | - mv /etc/pimdd.conf /etc/pimdd.conf.old 172 | cp pimdd.conf /etc 173 | echo "Don't forget to check/edit /etc/pimdd.conf!!!" 174 | 175 | clean: FRC 176 | rm -f ${OBJS} core ${PROG_NAME} tags TAGS 177 | 178 | depend: FRC 179 | mkdep ${CFLAGS} ${SRCS} 180 | 181 | lint: FRC 182 | lint ${LINTFLAGS} ${SRCS} 183 | 184 | tags: ${IGMP_SRCS} ${ROUTER_SRCS} 185 | ctags ${IGMP_SRCS} ${ROUTER_SRCS} 186 | 187 | cflow: FRC 188 | cflow ${MCAST_INCLUDE} ${IGMP_SRCS} ${ROUTER_SRCS} > cflow.out 189 | 190 | cflow2: FRC 191 | cflow -ix ${MCAST_INCLUDE} ${IGMP_SRCS} ${ROUTER_SRCS} > cflow2.out 192 | 193 | rcflow: FRC 194 | cflow -r ${MCAST_INCLUDE} ${IGMP_SRCS} ${ROUTER_SRCS} > rcflow.out 195 | 196 | rcflow2: FRC 197 | cflow -r -ix ${MCAST_INCLUDE} ${IGMP_SRCS} ${ROUTER_SRCS} > rcflow2.out 198 | 199 | TAGS: FRC 200 | etags ${SRCS} 201 | 202 | FRC: 203 | 204 | 205 | 206 | # DO NOT DELETE THIS LINE -- mkdep uses it. 207 | -------------------------------------------------------------------------------- /doc/README: -------------------------------------------------------------------------------- 1 | $Id: README,v 1.4 1998/12/31 19:28:39 kurtw Exp $ 2 | 3 | WARNING! WARNING! WARNING! 4 | THIS RELEASE IS VERY ALPHA, SO PLEASE DO NOT REDISTRIBUTE AND 5 | DO NOT TRY IT OUTSIDE OF YOUR TESTBED. 6 | 7 | This is README for pimd, the PIM multicast daemon. 8 | PIM-DM version: 2 9 | Check http://www.antc.uoregon.edu/ for lastest version. 10 | 11 | SUPPORTED PLATFORMS: FreeBSD-2.2.1, SunOS-4.1.3, Solaris-2.5.1 and 2.6, 12 | SGI, BSDI 3.0/3.1 13 | 14 | AVAILABLE PIM kernel patches: FreeBSD-2.2.1, FreeBSD-2.2.2, FreeBSD-2.2,5, 15 | SunOS-4.1.3, SGI, BSDI-3.0, BSDI-3.1 16 | 17 | 18 | FAST START (read "fast explanation" :)) 19 | 20 | 1. Apply the PIM kernel patches, recompile, reboot. 21 | These contain necessary bug fixes to the ipmroute kernel code as well 22 | as stuff needed only for PIM-SM. 23 | 24 | 2. Copy pimdd.conf to /etc and edit as appropriate. Disable the interfaces 25 | you don't need. Note that you need at least 2 physical interfaces enabled. 26 | 27 | 3. Edit Makefile by uncommenting the line(s) corresponding to your platform. 28 | 29 | 4. Recompile pimdd (you need to have the 'include' files patches applied) 30 | 31 | 5. Run pimdd as a root. It is highly recommended to run it in debug mode. 32 | Because there are many debug messages, you can specify only a subset of 33 | the messages to be printed out: 34 | 35 | usage: pimdd [-hv] [-f configfile] [-d debug_level[,debug_level]] 36 | 37 | Valid debug levels: dvmrp_prunes, dvmrp_mrt, dvmrp_neighbors, 38 | dvmrp_timers, igmp_proto, igmp_timers, igmp_members, trace, 39 | timeout, pkt, interfaces, kernel, cache, rsrr, pim_hello, 40 | pim_register, pim_join_prune, pim_graft, pim_bootstrap, 41 | pim_asserts, pim_routes, pim_timers, pim_rpf 42 | 43 | If you want to see all messages, use `pimd -d all` 44 | 45 | 6. There are plenty of bugs, some of them known (check BUGS.TODO), 46 | some of them unknown, so your bug reports are mroe than welcome. 47 | 48 | Kurt Windisch 49 | kurtw@antc.uoregon.edu 50 | 51 | ACKNOWLEDGEMENTS: 52 | 53 | * This pimd code was mostly written by Pavlin Ivanov Radoslavov 54 | (pavlin@catarina.usc.edu) and Ahmed Helmy (ahelmy@catarina.usc.edu), 55 | before being heavily modified by myself. 56 | 57 | * The PIM kernel modifications and pimd itself were originally written by 58 | Ahmed Helmy (ahelmy@catarina.usc.edu) as a summer intern in SGI. 59 | 60 | * The "up to the March '97 I-D spec" + RSVP support pimd version was done 61 | during Pavlin's summer'97 intern in Sun Microsystems under Michael Speer's 62 | supervision. 63 | 64 | * BSDI 3.0/3.1 support + various improvements and bug reports 65 | by Hitoshi Asaeda (asaeda@yamato.ibm.co.jp). 66 | 67 | * Bug reports and SGI tests by Nidhi Bhaskar (nidhi@cho-oyu.engr.sgi.com). 68 | 69 | * Bug reports and SunOS tests by Isabelle Girard (girardi@rc.bel.alcatel.be) 70 | and Dirk Ooms (oomsd@rc.bel.alcatel.be) 71 | 72 | * NetBSD-1.3 compilation support (both for pimd and the kernel mods) and 73 | bug reports by Heiko W.Rupp 74 | 75 | * Thanks to the FreeBSD team and particularly to the 76 | freebsd-hackers mailing list participants for the help 77 | with the real-time debugging of the FreeBSD kernel. 78 | 79 | -------------------------------------------------------------------------------- /doc/RELEASE.NOTES: -------------------------------------------------------------------------------- 1 | Second Pre-release December 31, 1998 (Happy New Year) 2 | 3 | * Fixed a variety of bugs and updated the implementation to comply 4 | with some sublte points and revisions of the PIM-DM specification. 5 | 6 | * Also synch'ed with the latest pimd from Pavlin and added patches 7 | for Linux, which were contributed by Jonathan Day . 8 | Thanks Jonathan. 9 | 10 | 11 | First Pre-release June 5, 1997 12 | 13 | * Pimd-dense requires kernel patches to the current ip_mroute kernel 14 | in order to operate correctly. This is due to bugs in the ipmroute 15 | kernel code currently being distributed (at least for FreeBSD). 16 | I've tested pimdd with both Rusty's GateD patches (to be depricated) 17 | and Pavlin's combined patches, which are available at: 18 | ftp://catarina.usc.edu/pub/pim/pimd/experimental/one-pimd-gated-kernel 19 | It should also work with any of the other recent patch kits that Pavlin 20 | has produced for use with Sparse-mode pimd. 21 | 22 | * Since pimd cannot reliably get distance and metric info from the kernel 23 | a configuration option is provided to specify a distance with which to 24 | advertise sources when sending PIM-Assert messages. The phyint command 25 | in pimd.conf allows you to specify a default distance for each interface. 26 | If no distance is specified, it defaults to 101, which is high enough that 27 | default distance advertised by either Cisco or Gated routers (both having 28 | better information on unicast routes) will win over pimd distances. 29 | Directly connected sources will always be asserted with a distance of 0. 30 | 31 | * Because unicast routes are obtained from the kernel, only the preferred 32 | route is available. pimd cannot determine, or handle, the existence of 33 | equal-cost-multipaths, and thus does not implement the addressing of 34 | joins and prunes to 0.0.0.0. 35 | 36 | * RSRR support is currently rough and completely untested. 37 | 38 | -------------------------------------------------------------------------------- /doc/TESTING: -------------------------------------------------------------------------------- 1 | 2 | Neighbor establishment passes manual 3 | Neighbor addition w/ state (potential flood) passes manual 4 | Neighbor timeout passes manual 5 | Neighbor timeout w/ state (potential prune) passes manual 6 | Cache miss-create S,G state passes manual 7 | Packet forwarding on flood (fwd to nbr) passes manual 8 | Packet forwarding on flood (fwd to host) passes manual 9 | MRT entry refresh on data passes manual 10 | MRT entry timeout passes manual 11 | IGMP group membership caching w/o state passes manual 12 | IGMP group membership report w/ state passes manual 13 | IGMP group membership leave w/ state passes manual 14 | passes manual 15 | passes manual 16 | passes manual 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /doc/pimd-dense.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | PIM-Dense Routing Daemon Software 4 | 5 | 6 |
7 |

Protocol Independent Multicast - Dense Mode (PIM-DM)

8 |

Routing Daemon Software

9 | 10 | Kurt Windisch
11 | Advanced Network Technology Center
12 | kurtw@antc.uoregon.edu
13 |

14 | 15 | Pimd-dense is a lightweight, stand-alone PIM-Dense Mode 16 | implementation that may be freely deployed or distributed. Pimd-Dense 17 | implements the full 18 | PIM-DM specification with a few exceptions 19 | noted in the Release Notes. 20 |

21 | 22 | The code from Pimd-dense is heavily based on the PIM-Sparse Mode daemon 23 | implementation by Puneet Sharma and Charley Liu (USC), Ahmed Helmy (SGI/USC), 24 | and Pavlin Ivanov Radoslavov (USC). For more info on PimD-Sparse, see the 25 | PIM Home Page at USC

26 | 27 | Use of PimD-Dense for multicast routing requires a separate facility for 28 | unicast routing such as (1) static routes via the UNIX route command, 29 | (2) RIP routes via the standard UNIX routed routing daemon, or 30 | (3) other dynamic unicast routing protocols such as those provided by the 31 | GateD multiprotocol routing daemon.

32 | 33 |


34 |

The Software

35 | 36 | PimD-Dense is currently ALPHA-version software that yet requires 37 | extensive testing. If you choose to use it, information about any 38 | bugs or problems sent to 39 | kurtw@antc.uoregon.edu would be 40 | greatly appreciated and will be investigated ASAP.

41 | 42 | PimD-Dense should compile and run on most UNIX varieties, including 43 | FreeBSD, BSDI, NetBSD, SunOS, IRIX, Solaris 2.5, Solaris 2.6, and Linux 44 | (however it has not yet been tested on all these).

45 | 46 | Many current version of the IP MRouting kernel code requires patches 47 | to correct certain bugs in order to work correctly with PimD-Dense. 48 | Before using PimD-Dense, you should apply one of the current 49 | patches available for PimD-Sparse from USC's 50 | 51 | PIM FTP site. Several are available.

52 | 53 |

63 | 64 |
65 |

Testing

66 | In the future, a suite of test scripts will be included that will test 67 | the basic functionality of this, or other, PIM-DM implemenations. 68 | This test suite will use George (Rusty) Eddy's 69 | PKT toolkit. 70 | 71 |
72 |

PIM Links

73 | 82 | 83 | 84 |
85 |
Kurt Windisch
86 | 87 | 88 | Last modified: Thu Dec 31 11:23:53 PST 1998 89 | 90 | 91 | -------------------------------------------------------------------------------- /include/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = linux/netinet/in-my.h linux/netinet/ip_mroute.h \ 2 | linux/netinet/in-glibc-2.0.h linux/netinet/in-glibc-2.1.h \ 3 | linux/netinet/mroute.h 4 | EXTRA_DIST += freebsd/netinet/in.h freebsd/netinet/ip_mroute.h 5 | EXTRA_DIST += netbsd/netinet/in.h netbsd/netinet/ip_mroute.h 6 | EXTRA_DIST += netinet/pim.h netinet/pim_var.h 7 | -------------------------------------------------------------------------------- /include/freebsd/netinet/pim.h: -------------------------------------------------------------------------------- 1 | /* $Id: pim.h,v 1.2 1998/06/01 22:27:16 kurtw Exp $ */ 2 | 3 | #ifndef _NETINET_PIM_H_ 4 | #define _NETINET_PIM_H_ 5 | 6 | /* 7 | * Protocol Independent Multicast (PIM) definitions. 8 | * 9 | * Written by Ahmed Helmy, USC/SGI, July 1996 10 | * Modified by George Edmond Eddy (Rusty), ISI, February 1998 11 | * Modified by Pavlin Ivanov Radoslavov, USC/ISI, May 1998 12 | */ 13 | 14 | /* 15 | * PIM packet format. 16 | */ 17 | #define PIM_VERSION 2 18 | struct pim { 19 | #if BYTE_ORDER == LITTLE_ENDIAN 20 | u_char pim_type:4, /* type of PIM message */ 21 | pim_vers:4; /* PIM version */ 22 | #else /* BYTE_ORDER == BIG_ENDIAN */ 23 | u_char pim_vers:4, /* PIM version */ 24 | pim_type:4; /* type of PIM message */ 25 | #endif /* BYTE_ORDER */ 26 | u_char reserved; /* Reserved */ 27 | u_short pim_cksum; /* IP-style checksum */ 28 | }; 29 | 30 | #define PIM_MINLEN 8 /* The header min. length is 8 */ 31 | #define PIM_REG_MINLEN (PIM_MINLEN+20) /* Register message + inner IPheader */ 32 | 33 | /* 34 | * Message types 35 | */ 36 | #define PIM_REGISTER 0x01 /* PIM Register type is 1 */ 37 | #define PIM_NULL_REGISTER 0x40000000 /* second bit in reg_head is the Null-bit */ 38 | 39 | #endif /* _NETINET_PIM_H_ */ 40 | -------------------------------------------------------------------------------- /include/freebsd/netinet/pim_var.h: -------------------------------------------------------------------------------- 1 | /* $Id: pim_var.h,v 1.1 1998/07/06 23:44:57 kurtw Exp $ */ 2 | 3 | #ifndef _NETINET_PIM_VAR_H_ 4 | #define _NETINET_PIM_VAR_H_ 5 | 6 | /* 7 | * Protocol Independent Multicast (PIM), 8 | * implementation-specific definitions. 9 | * 10 | * Written by George Edmond Eddy (Rusty), ISI, February 1998 11 | * Modified by Pavlin Ivanov Radoslavov, USC/ISI, May 1998 12 | */ 13 | 14 | struct pimstat { 15 | u_int pim_rcv_total; /* total PIM messages received */ 16 | u_int pim_rcv_tooshort; /* received with too few bytes */ 17 | u_int pim_rcv_badsum; /* received with bad checksum */ 18 | u_int pim_rcv_badversion; /* received bad PIM version */ 19 | u_int pim_rcv_registers; /* received registers */ 20 | u_int pim_rcv_badregisters; /* received invalid registers */ 21 | u_int pim_snd_registers; /* sent registers */ 22 | }; 23 | 24 | #if (defined(KERNEL)) || (defined(_KERNEL)) 25 | extern struct pimstat pimstat; 26 | 27 | #ifdef NetBSD 28 | void pim_input (struct mbuf *, ...); 29 | #else 30 | void pim_input (struct mbuf *, int); 31 | #endif 32 | #endif /* KERNEL */ 33 | 34 | /* 35 | * Names for PIM sysctl objects 36 | */ 37 | #if (defined(__FreeBSD__)) || (defined(NetBSD)) 38 | #define PIMCTL_STATS 1 /* statistics (read-only) */ 39 | #define PIMCTL_MAXID 2 40 | 41 | #define PIMCTL_NAMES { \ 42 | { 0, 0 }, \ 43 | { "stats", CTLTYPE_STRUCT }, \ 44 | } 45 | #endif /* FreeBSD || NetBSD */ 46 | 47 | #endif /* _NETINET_PIM_VAR_H_ */ 48 | -------------------------------------------------------------------------------- /include/linux/netinet/in-my.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Dummy header file to include the appropriate in.h for Linux 3 | * The situation is pretty messy, and no guarantee it will work. 4 | * Use your skills and imagination at your own risk :) 5 | * 6 | * Thanks to Jonathan Day for the problem report and the solution 7 | * 8 | */ 9 | /* 10 | * Questions concerning this software should be directed to 11 | * Pavlin Ivanov Radoslavov (pavlin@catarina.usc.edu) 12 | * 13 | * $Id: in.h,v 1.8 2000/03/08 09:12:45 pavlin Exp $ 14 | */ 15 | 16 | #include 17 | 18 | #if (defined(__GLIBC__) && (defined(__GLIBC_MINOR__))) 19 | # if (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0) 20 | # include "in-glibc-2.0.h" 21 | # elif (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 1) 22 | # include "in-glibc-2.1.h" 23 | # else 24 | # include 25 | # include 26 | # endif /* __GLIBC__ */ 27 | #else 28 | # include 29 | # include 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /include/linux/netinet/ip_mroute.h: -------------------------------------------------------------------------------- 1 | #include "mroute.h" 2 | 3 | -------------------------------------------------------------------------------- /include/linux/netinet/mroute.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_MROUTE_H 2 | #define __LINUX_MROUTE_H 3 | 4 | #include 5 | #include 6 | 7 | 8 | /* 9 | * Based on the MROUTING 3.5 defines primarily to keep 10 | * source compatibility with BSD. 11 | * 12 | * See the mrouted code for the original history. 13 | * 14 | * Protocol Independent Multicast (PIM) data structures included 15 | * Carlos Picoto (cap@di.fc.ul.pt) 16 | * 17 | */ 18 | 19 | #define MRT_BASE 200 20 | #define MRT_INIT (MRT_BASE) /* Activate the kernel mroute code */ 21 | #define MRT_DONE (MRT_BASE+1) /* Shutdown the kernel mroute */ 22 | #define MRT_ADD_VIF (MRT_BASE+2) /* Add a virtual interface */ 23 | #define MRT_DEL_VIF (MRT_BASE+3) /* Delete a virtual interface */ 24 | #define MRT_ADD_MFC (MRT_BASE+4) /* Add a multicast forwarding entry */ 25 | #define MRT_DEL_MFC (MRT_BASE+5) /* Delete a multicast forwarding entry */ 26 | #define MRT_VERSION (MRT_BASE+6) /* Get the kernel multicast version */ 27 | #define MRT_ASSERT (MRT_BASE+7) /* Activate PIM assert mode */ 28 | #define MRT_PIM (MRT_BASE+8) /* enable PIM code */ 29 | 30 | #define SIOCGETVIFCNT SIOCPROTOPRIVATE /* IP protocol privates */ 31 | #define SIOCGETSGCNT (SIOCPROTOPRIVATE+1) 32 | #define SIOCGETRPF (SIOCPROTOPRIVATE+2) 33 | 34 | #ifdef CUSTOM_MAX_VIFS 35 | #define MAXVIFS CUSTOM_MAX_VIFS /* MUST match kernel MAXVIFS! */ 36 | #else 37 | #define MAXVIFS 32 38 | #endif 39 | typedef unsigned long vifbitmap_t; /* User mode code depends on this lot */ 40 | typedef unsigned short vifi_t; 41 | #define ALL_VIFS ((vifi_t)(-1)) 42 | 43 | /* 44 | * Same idea as select 45 | */ 46 | 47 | #define VIFM_SET(n,m) ((m)|=(1<<(n))) 48 | #define VIFM_CLR(n,m) ((m)&=~(1<<(n))) 49 | #define VIFM_ISSET(n,m) ((m)&(1<<(n))) 50 | #define VIFM_CLRALL(m) ((m)=0) 51 | #define VIFM_COPY(mfrom,mto) ((mto)=(mfrom)) 52 | #define VIFM_SAME(m1,m2) ((m1)==(m2)) 53 | 54 | /* 55 | * Passed by mrouted for an MRT_ADD_VIF - again we use the 56 | * mrouted 3.6 structures for compatibility 57 | */ 58 | 59 | struct vifctl { 60 | vifi_t vifc_vifi; /* Index of VIF */ 61 | unsigned char vifc_flags; /* VIFF_ flags */ 62 | unsigned char vifc_threshold; /* ttl limit */ 63 | unsigned int vifc_rate_limit; /* Rate limiter values (NI) */ 64 | struct in_addr vifc_lcl_addr; /* Our address */ 65 | struct in_addr vifc_rmt_addr; /* IPIP tunnel addr */ 66 | }; 67 | 68 | #define VIFF_TUNNEL 0x1 /* IPIP tunnel */ 69 | #define VIFF_SRCRT 0x2 /* NI */ 70 | #define VIFF_REGISTER 0x4 /* register vif */ 71 | 72 | /* 73 | * Cache manipulation structures for mrouted and PIMd 74 | */ 75 | 76 | struct mfcctl 77 | { 78 | struct in_addr mfcc_origin; /* Origin of mcast */ 79 | struct in_addr mfcc_mcastgrp; /* Group in question */ 80 | vifi_t mfcc_parent; /* Where it arrived */ 81 | unsigned char mfcc_ttls[MAXVIFS]; /* Where it is going */ 82 | unsigned int mfcc_pkt_cnt; /* pkt count for src-grp */ 83 | unsigned int mfcc_byte_cnt; 84 | unsigned int mfcc_wrong_if; 85 | int mfcc_expire; 86 | }; 87 | 88 | /* 89 | * Group count retrieval for mrouted 90 | */ 91 | 92 | struct sioc_sg_req 93 | { 94 | struct in_addr src; 95 | struct in_addr grp; 96 | unsigned long pktcnt; 97 | unsigned long bytecnt; 98 | unsigned long wrong_if; 99 | }; 100 | 101 | /* 102 | * To get vif packet counts 103 | */ 104 | 105 | struct sioc_vif_req 106 | { 107 | vifi_t vifi; /* Which iface */ 108 | unsigned long icount; /* In packets */ 109 | unsigned long ocount; /* Out packets */ 110 | unsigned long ibytes; /* In bytes */ 111 | unsigned long obytes; /* Out bytes */ 112 | }; 113 | 114 | /* 115 | * This is the format the mroute daemon expects to see IGMP control 116 | * data. Magically happens to be like an IP packet as per the original 117 | */ 118 | 119 | struct igmpmsg 120 | { 121 | uint32_t unused1,unused2; 122 | unsigned char im_msgtype; /* What is this */ 123 | unsigned char im_mbz; /* Must be zero */ 124 | unsigned char im_vif; /* Interface (this ought to be a vifi_t!) */ 125 | unsigned char unused3; 126 | struct in_addr im_src,im_dst; 127 | }; 128 | 129 | /* 130 | * That's all usermode folks 131 | */ 132 | 133 | 134 | 135 | #define MFC_ASSERT_THRESH (3*HZ) /* Maximal freq. of asserts */ 136 | 137 | /* 138 | * Pseudo messages used by mrouted 139 | */ 140 | 141 | #define IGMPMSG_NOCACHE 1 /* Kern cache fill request to mrouted */ 142 | #define IGMPMSG_WRONGVIF 2 /* For PIM assert processing (unused) */ 143 | #define IGMPMSG_WHOLEPKT 3 /* For PIM Register processing */ 144 | 145 | 146 | #endif 147 | -------------------------------------------------------------------------------- /include/netbsd/netinet/ip_mroute.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: ip_mroute.h,v 1.12 1996/09/09 17:14:05 mycroft Exp $ */ 2 | 3 | /* 4 | * Definitions for IP multicast forwarding. 5 | * 6 | * Written by David Waitzman, BBN Labs, August 1988. 7 | * Modified by Steve Deering, Stanford, February 1989. 8 | * Modified by Ajit Thyagarajan, PARC, August 1993. 9 | * Modified by Ajit Thyagarajan, PARC, August 1994. 10 | * 11 | * MROUTING Revision: 1.2 12 | */ 13 | 14 | #include 15 | 16 | /* 17 | * Multicast Routing set/getsockopt commands. 18 | */ 19 | #define MRT_INIT 100 /* initialize forwarder */ 20 | #define MRT_DONE 101 /* shut down forwarder */ 21 | #define MRT_ADD_VIF 102 /* create virtual interface */ 22 | #define MRT_DEL_VIF 103 /* delete virtual interface */ 23 | #define MRT_ADD_MFC 104 /* insert forwarding cache entry */ 24 | #define MRT_DEL_MFC 105 /* delete forwarding cache entry */ 25 | #define MRT_VERSION 106 /* get kernel version number */ 26 | #define MRT_ASSERT 107 /* enable assert (wrong iif) processing */ 27 | 28 | 29 | /* 30 | * Types and macros for handling bitmaps with one bit per virtual interface. 31 | */ 32 | #define MAXVIFS 32 33 | typedef u_int32_t vifbitmap_t; 34 | typedef u_int16_t vifi_t; /* type of a vif index */ 35 | 36 | #define VIFM_SET(n, m) ((m) |= (1 << (n))) 37 | #define VIFM_CLR(n, m) ((m) &= ~(1 << (n))) 38 | #define VIFM_ISSET(n, m) ((m) & (1 << (n))) 39 | #define VIFM_SETALL(m) ((m) = 0xffffffff) 40 | #define VIFM_CLRALL(m) ((m) = 0x00000000) 41 | #define VIFM_COPY(mfrom, mto) ((mto) = (mfrom)) 42 | #define VIFM_SAME(m1, m2) ((m1) == (m2)) 43 | 44 | #define VIFF_TUNNEL 0x1 /* vif represents a tunnel end-point */ 45 | #define VIFF_SRCRT 0x2 /* tunnel uses IP src routing */ 46 | #define VIFF_REGISTER 0x4 /* vif used for register en/decap */ 47 | 48 | /* 49 | * Argument structure for MRT_ADD_VIF. 50 | * (MRT_DEL_VIF takes a single vifi_t argument.) 51 | */ 52 | struct vifctl { 53 | vifi_t vifc_vifi; /* the index of the vif to be added */ 54 | u_int8_t vifc_flags; /* VIFF_ flags defined below */ 55 | u_int8_t vifc_threshold; /* min ttl required to forward on vif */ 56 | u_int32_t vifc_rate_limit; /* max rate */ 57 | struct in_addr vifc_lcl_addr;/* local interface address */ 58 | struct in_addr vifc_rmt_addr;/* remote address (tunnels only) */ 59 | }; 60 | 61 | /* 62 | * Argument structure for MRT_ADD_MFC and MRT_DEL_MFC. 63 | * (mfcc_tos to be added at a future point) 64 | */ 65 | struct mfcctl { 66 | struct in_addr mfcc_origin; /* ip origin of mcasts */ 67 | struct in_addr mfcc_mcastgrp; /* multicast group associated */ 68 | vifi_t mfcc_parent; /* incoming vif */ 69 | u_int8_t mfcc_ttls[MAXVIFS]; /* forwarding ttls on vifs */ 70 | }; 71 | 72 | /* 73 | * Argument structure used by mrouted to get src-grp pkt counts. 74 | */ 75 | struct sioc_sg_req { 76 | struct in_addr src; 77 | struct in_addr grp; 78 | u_long pktcnt; 79 | u_long bytecnt; 80 | u_long wrong_if; 81 | }; 82 | 83 | /* 84 | * Argument structure used by mrouted to get vif pkt counts. 85 | */ 86 | struct sioc_vif_req { 87 | vifi_t vifi; /* vif number */ 88 | u_long icount; /* input packet count on vif */ 89 | u_long ocount; /* output packet count on vif */ 90 | u_long ibytes; /* input byte count on vif */ 91 | u_long obytes; /* output byte count on vif */ 92 | }; 93 | 94 | 95 | /* 96 | * The kernel's multicast routing statistics. 97 | */ 98 | struct mrtstat { 99 | u_long mrts_mfc_lookups; /* # forw. cache hash table hits */ 100 | u_long mrts_mfc_misses; /* # forw. cache hash table misses */ 101 | u_long mrts_upcalls; /* # calls to mrouted */ 102 | u_long mrts_no_route; /* no route for packet's origin */ 103 | u_long mrts_bad_tunnel; /* malformed tunnel options */ 104 | u_long mrts_cant_tunnel; /* no room for tunnel options */ 105 | u_long mrts_wrong_if; /* arrived on wrong interface */ 106 | u_long mrts_upq_ovflw; /* upcall Q overflow */ 107 | u_long mrts_cache_cleanups; /* # entries with no upcalls */ 108 | u_long mrts_drop_sel; /* pkts dropped selectively */ 109 | u_long mrts_q_overflow; /* pkts dropped - Q overflow */ 110 | u_long mrts_pkt2large; /* pkts dropped - size > BKT SIZE */ 111 | u_long mrts_upq_sockfull; /* upcalls dropped - socket full */ 112 | }; 113 | 114 | 115 | #ifdef _KERNEL 116 | 117 | /* 118 | * The kernel's virtual-interface structure. 119 | */ 120 | struct vif { 121 | struct mbuf *tbf_q, **tbf_t; /* packet queue */ 122 | struct timeval tbf_last_pkt_t; /* arr. time of last pkt */ 123 | u_int32_t tbf_n_tok; /* no of tokens in bucket */ 124 | u_int32_t tbf_q_len; /* length of queue at this vif */ 125 | u_int32_t tbf_max_q_len; /* max. queue length */ 126 | 127 | u_int8_t v_flags; /* VIFF_ flags defined above */ 128 | u_int8_t v_threshold; /* min ttl required to forward on vif */ 129 | u_int32_t v_rate_limit; /* max rate */ 130 | struct in_addr v_lcl_addr; /* local interface address */ 131 | struct in_addr v_rmt_addr; /* remote address (tunnels only) */ 132 | struct ifnet *v_ifp; /* pointer to interface */ 133 | u_long v_pkt_in; /* # pkts in on interface */ 134 | u_long v_pkt_out; /* # pkts out on interface */ 135 | u_long v_bytes_in; /* # bytes in on interface */ 136 | u_long v_bytes_out; /* # bytes out on interface */ 137 | struct route v_route; /* cached route if this is a tunnel */ 138 | #ifdef RSVP_ISI 139 | int v_rsvp_on; /* # RSVP listening on this vif */ 140 | struct socket *v_rsvpd; /* # RSVPD daemon */ 141 | #endif /* RSVP_ISI */ 142 | }; 143 | 144 | /* 145 | * The kernel's multicast forwarding cache entry structure. 146 | * (A field for the type of service (mfc_tos) is to be added 147 | * at a future point.) 148 | */ 149 | struct mfc { 150 | LIST_ENTRY(mfc) mfc_hash; 151 | struct in_addr mfc_origin; /* ip origin of mcasts */ 152 | struct in_addr mfc_mcastgrp; /* multicast group associated */ 153 | vifi_t mfc_parent; /* incoming vif */ 154 | u_int8_t mfc_ttls[MAXVIFS]; /* forwarding ttls on vifs */ 155 | u_long mfc_pkt_cnt; /* pkt count for src-grp */ 156 | u_long mfc_byte_cnt; /* byte count for src-grp */ 157 | u_long mfc_wrong_if; /* wrong if for src-grp */ 158 | int mfc_expire; /* time to clean entry up */ 159 | struct timeval mfc_last_assert; /* last time I sent an assert */ 160 | struct rtdetq *mfc_stall; /* pkts waiting for route */ 161 | }; 162 | 163 | /* 164 | * Structure used to communicate from kernel to multicast router. 165 | * (Note the convenient similarity to an IP packet.) 166 | */ 167 | struct igmpmsg { 168 | u_int32_t unused1; 169 | u_int32_t unused2; 170 | u_int8_t im_msgtype; /* what type of message */ 171 | #define IGMPMSG_NOCACHE 1 172 | #define IGMPMSG_WRONGVIF 2 173 | #define IGMPMSG_WHOLEPKT 3 /* send the whole packet */ 174 | u_int8_t im_mbz; /* must be zero */ 175 | u_int8_t im_vif; /* vif rec'd on */ 176 | u_int8_t unused3; 177 | struct in_addr im_src, im_dst; 178 | }; 179 | 180 | /* 181 | * Argument structure used for pkt info. while upcall is made. 182 | */ 183 | struct rtdetq { 184 | struct mbuf *m; /* a copy of the packet */ 185 | struct ifnet *ifp; /* interface pkt came in on */ 186 | #ifdef UPCALL_TIMING 187 | struct timeval t; /* timestamp */ 188 | #endif /* UPCALL_TIMING */ 189 | struct rtdetq *next; 190 | }; 191 | 192 | #define MFCTBLSIZ 256 193 | #define MAX_UPQ 4 /* max. no of pkts in upcall Q */ 194 | 195 | /* 196 | * Token bucket filter code 197 | */ 198 | #define MAX_BKT_SIZE 10000 /* 10K bytes size */ 199 | #define MAXQSIZE 10 /* max. no of pkts in token queue */ 200 | 201 | 202 | int ip_mrouter_set (struct socket *, int, struct mbuf **); 203 | int ip_mrouter_get (struct socket *, int, struct mbuf **); 204 | int mrt_ioctl (struct socket *, u_long, caddr_t); 205 | int ip_mrouter_done (void); 206 | void reset_vif (struct vif *); 207 | #ifdef RSVP_ISI 208 | int ip_mforward (struct mbuf *, struct ifnet *, struct ip_moptions *); 209 | int legal_vif_num (int); 210 | int ip_rsvp_vif_init (struct socket *, struct mbuf *); 211 | int ip_rsvp_vif_done (struct socket *, struct mbuf *); 212 | void ip_rsvp_force_done (struct socket *); 213 | void rsvp_input (struct mbuf *, struct ifnet *); 214 | #else 215 | int ip_mforward (struct mbuf *, struct ifnet *); 216 | #endif 217 | void ipip_input (struct mbuf *, ...); 218 | 219 | #endif /* _KERNEL */ 220 | -------------------------------------------------------------------------------- /include/netbsd/netinet/pim.h: -------------------------------------------------------------------------------- 1 | /* $Id: pim.h,v 1.1 1998/06/01 22:35:32 kurtw Exp $ */ 2 | 3 | #ifndef _NETINET_PIM_H_ 4 | #define _NETINET_PIM_H_ 5 | 6 | /* 7 | * Protocol Independent Multicast (PIM) definitions. 8 | * 9 | * Written by Ahmed Helmy, USC/SGI, July 1996 10 | * Modified by George Edmond Eddy (Rusty), ISI, February 1998 11 | * Modified by Pavlin Ivanov Radoslavov, USC/ISI, May 1998 12 | */ 13 | 14 | /* 15 | * PIM packet format. 16 | */ 17 | #define PIM_VERSION 2 18 | struct pim { 19 | #if BYTE_ORDER == LITTLE_ENDIAN 20 | u_char pim_type:4, /* type of PIM message */ 21 | pim_vers:4; /* PIM version */ 22 | #else /* BYTE_ORDER == BIG_ENDIAN */ 23 | u_char pim_vers:4, /* PIM version */ 24 | pim_type:4; /* type of PIM message */ 25 | #endif /* BYTE_ORDER */ 26 | u_char reserved; /* Reserved */ 27 | u_short pim_cksum; /* IP-style checksum */ 28 | }; 29 | 30 | #define PIM_MINLEN 8 /* The header min. length is 8 */ 31 | #define PIM_REG_MINLEN (PIM_MINLEN+20) /* Register message + inner IPheader */ 32 | 33 | /* 34 | * Message types 35 | */ 36 | #define PIM_REGISTER 0x01 /* PIM Register type is 1 */ 37 | #define PIM_NULL_REGISTER 0x40000000 /* second bit in reg_head is the Null-bit */ 38 | 39 | #endif /* _NETINET_PIM_H_ */ 40 | -------------------------------------------------------------------------------- /include/netbsd/netinet/pim_var.h: -------------------------------------------------------------------------------- 1 | /* $Id: pim_var.h,v 1.1 1998/06/01 22:35:32 kurtw Exp $ */ 2 | 3 | #ifndef _NETINET_PIM_VAR_H_ 4 | #define _NETINET_PIM_VAR_H_ 5 | 6 | /* 7 | * Protocol Independent Multicast (PIM), 8 | * implementation-specific definitions. 9 | * 10 | * Written by George Edmond Eddy (Rusty), ISI, February 1998 11 | * Modified by Pavlin Ivanov Radoslavov, USC/ISI, May 1998 12 | */ 13 | 14 | struct pimstat { 15 | u_int pim_rcv_total; /* total PIM messages received */ 16 | u_int pim_rcv_tooshort; /* received with too few bytes */ 17 | u_int pim_rcv_badsum; /* received with bad checksum */ 18 | u_int pim_rcv_badversion; /* received bad PIM version */ 19 | u_int pim_rcv_registers; /* received registers */ 20 | u_int pim_rcv_badregisters; /* received invalid registers */ 21 | u_int pim_snd_registers; /* sent registers */ 22 | }; 23 | 24 | #if (defined(KERNEL)) || (defined(_KERNEL)) 25 | extern struct pimstat pimstat; 26 | 27 | #ifdef NetBSD 28 | void pim_input (struct mbuf *, ...); 29 | #else 30 | void pim_input (struct mbuf *, int); 31 | #endif 32 | #endif /* KERNEL */ 33 | 34 | /* 35 | * Names for PIM sysctl objects 36 | */ 37 | #if (defined(__FreeBSD__)) || (defined(NetBSD)) 38 | #define PIMCTL_STATS 1 /* statistics (read-only) */ 39 | #define PIMCTL_MAXID 2 40 | 41 | #define PIMCTL_NAMES { \ 42 | { 0, 0 }, \ 43 | { "stats", CTLTYPE_STRUCT }, \ 44 | } 45 | #endif /* FreeBSD || NetBSD */ 46 | 47 | #endif /* _NETINET_PIM_VAR_H_ */ 48 | -------------------------------------------------------------------------------- /include/netinet/pim.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2000 3 | * University of Southern California/Information Sciences Institute. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. Neither the name of the project nor the names of its contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef _NETINET_PIM_H_ 32 | #define _NETINET_PIM_H_ 33 | 34 | /* 35 | * Protocol Independent Multicast (PIM) definitions. 36 | * RFC 2362, June 1998. 37 | * 38 | * Written by Ahmed Helmy, USC/SGI, July 1996. 39 | * Modified by George Edmond Eddy (Rusty), ISI, February 1998. 40 | * Modified by Pavlin Radoslavov, USC/ISI, May 1998, October 2000. 41 | */ 42 | 43 | 44 | #ifndef _PIM_VT 45 | #ifndef BYTE_ORDER 46 | # error BYTE_ORDER is not defined! 47 | #endif 48 | #if (BYTE_ORDER != BIG_ENDIAN) && (BYTE_ORDER != LITTLE_ENDIAN) 49 | # error BYTE_ORDER must be defined to either BIG_ENDIAN or LITTLE_ENDIAN 50 | #endif 51 | #endif /* ! _PIM_VT */ 52 | 53 | /* 54 | * PIM packet header 55 | */ 56 | struct pim { 57 | #ifdef _PIM_VT 58 | uint8_t pim_vt; /* PIM version and message type */ 59 | #else /* ! _PIM_VT */ 60 | #if BYTE_ORDER == BIG_ENDIAN 61 | u_int pim_vers:4, /* PIM protocol version */ 62 | pim_type:4; /* PIM message type */ 63 | #endif 64 | #if BYTE_ORDER == LITTLE_ENDIAN 65 | u_int pim_type:4, /* PIM message type */ 66 | pim_vers:4; /* PIM protocol version */ 67 | #endif 68 | #endif /* ! _PIM_VT */ 69 | uint8_t pim_reserved; /* Reserved */ 70 | uint16_t pim_cksum; /* IP-style checksum */ 71 | }; 72 | /* KAME-related name backward compatibility */ 73 | #define pim_ver pim_vers 74 | #define pim_rsv pim_reserved 75 | 76 | #ifdef _PIM_VT 77 | #define PIM_MAKE_VT(v, t) (0xff & (((v) << 4) | (0x0f & (t)))) 78 | #define PIM_VT_V(x) (((x) >> 4) & 0x0f) 79 | #define PIM_VT_T(x) ((x) & 0x0f) 80 | #endif /* _PIM_VT */ 81 | 82 | #define PIM_VERSION 2 83 | #define PIM_MINLEN 8 /* PIM message min. length */ 84 | #define PIM_REG_MINLEN (PIM_MINLEN+20) /* PIM Register hdr + inner IPv4 hdr */ 85 | #define PIM6_REG_MINLEN (PIM_MINLEN+40) /* PIM Register hdr + inner IPv6 hdr */ 86 | 87 | /* 88 | * PIM message types 89 | */ 90 | #define PIM_HELLO 0x0 /* PIM-SM and PIM-DM */ 91 | #define PIM_REGISTER 0x1 /* PIM-SM only */ 92 | #define PIM_REGISTER_STOP 0x2 /* PIM-SM only */ 93 | #define PIM_JOIN_PRUNE 0x3 /* PIM-SM and PIM-DM */ 94 | #define PIM_BOOTSTRAP 0x4 /* PIM-SM only */ 95 | #define PIM_ASSERT 0x5 /* PIM-SM and PIM-DM */ 96 | #define PIM_GRAFT 0x6 /* PIM-DM only */ 97 | #define PIM_GRAFT_ACK 0x7 /* PIM-DM only */ 98 | #define PIM_CAND_RP_ADV 0x8 /* PIM-SM only */ 99 | #define PIM_ALL_DF_ELECTION 0xa /* Bidir-PIM-SM only */ 100 | 101 | /* 102 | * PIM-Register message flags 103 | */ 104 | #define PIM_BORDER_REGISTER 0x80000000U /* The Border bit (host-order) */ 105 | #define PIM_NULL_REGISTER 0x40000000U /* The Null-Register bit (host-order)*/ 106 | 107 | /* 108 | * All-PIM-Routers IPv4 and IPv6 multicast addresses 109 | */ 110 | #define INADDR_ALLPIM_ROUTERS_GROUP (uint32_t)0xe000000dU /* 224.0.0.13 */ 111 | #define IN6ADDR_LINKLOCAL_ALLPIM_ROUTERS "ff02::d" 112 | #define IN6ADDR_LINKLOCAL_ALLPIM_ROUTERS_INIT \ 113 | {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 114 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d }}} 115 | 116 | #endif /* _NETINET_PIM_H_ */ 117 | -------------------------------------------------------------------------------- /include/netinet/pim_var.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1998-2001 3 | * University of Southern California/Information Sciences Institute. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. Neither the name of the project nor the names of its contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef _NETINET_PIM_VAR_H_ 32 | #define _NETINET_PIM_VAR_H_ 33 | 34 | /* 35 | * Protocol Independent Multicast (PIM), 36 | * kernel variables and implementation-specific definitions. 37 | * 38 | * Written by George Edmond Eddy (Rusty), ISI, February 1998. 39 | * Modified by Pavlin Radoslavov, USC/ISI, May 1998, Aug 1999, October 2000. 40 | * Modified by Hitoshi Asaeda, WIDE, August 1998. 41 | */ 42 | 43 | /* 44 | * PIM statistics kept in the kernel 45 | */ 46 | struct pimstat { 47 | u_quad_t pims_rcv_total_msgs; /* total PIM messages received */ 48 | u_quad_t pims_rcv_total_bytes; /* total PIM bytes received */ 49 | u_quad_t pims_rcv_tooshort; /* rcvd with too few bytes */ 50 | u_quad_t pims_rcv_badsum; /* rcvd with bad checksum */ 51 | u_quad_t pims_rcv_badversion; /* rcvd bad PIM version */ 52 | u_quad_t pims_rcv_registers_msgs; /* rcvd regs. msgs (data only) */ 53 | u_quad_t pims_rcv_registers_bytes; /* rcvd regs. bytes (data only) */ 54 | u_quad_t pims_rcv_registers_wrongiif; /* rcvd regs. on wrong iif */ 55 | u_quad_t pims_rcv_badregisters; /* rcvd invalid registers */ 56 | u_quad_t pims_snd_registers_msgs; /* sent regs. msgs (data only) */ 57 | u_quad_t pims_snd_registers_bytes; /* sent regs. bytes (data only) */ 58 | }; 59 | 60 | #if (defined(KERNEL)) || (defined(_KERNEL)) 61 | extern struct pimstat pimstat; 62 | 63 | #if defined(NetBSD) || defined(__OpenBSD__) 64 | void pim_input(struct mbuf *, ...); 65 | #elif (defined(__FreeBSD__) && (__FreeBSD_version >= 400000)) || defined(__FreeBSD_kernel__) 66 | void pim_input(struct mbuf *, int, int); 67 | #else 68 | void pim_input(struct mbuf *, int); 69 | #endif /* ! (NetBSD || OpenBSD) */ 70 | #endif /* KERNEL */ 71 | 72 | /* 73 | * Names for PIM sysctl objects 74 | */ 75 | #if (defined(__FreeBSD__)) || (defined(NetBSD)) || defined(__OpenBSD__) || (defined(__bsdi__)) 76 | #define PIMCTL_STATS 1 /* statistics (read-only) */ 77 | #define PIMCTL_MAXID 2 78 | 79 | #define PIMCTL_NAMES { \ 80 | { 0, 0 }, \ 81 | { "stats", CTLTYPE_STRUCT }, \ 82 | } 83 | #endif /* FreeBSD || NetBSD || OpenBSD || bsdi */ 84 | 85 | #if (defined(__FreeBSD__) && (__FreeBSD_version >= 400000)) || defined(__FreeBSD_kernel__) 86 | #if ((defined(KERNEL)) || (defined(_KERNEL))) 87 | #if defined(SYSCTL_DECL) 88 | SYSCTL_DECL(_net_inet_pim); 89 | #endif /* SYSCTL_DECL */ 90 | #endif /* KERNEL */ 91 | #endif /* FreeBSD >= 4.0 */ 92 | 93 | #if (defined(NetBSD) || defined(__OpenBSD__) || defined(__bsdi__)) 94 | #define PIMCTL_VARS { \ 95 | 0, \ 96 | 0, \ 97 | } 98 | int pim_sysctl(int *, u_int, void *, size_t *, void *, size_t); 99 | #endif /* NetBSD || OpenBSD || bsdi */ 100 | 101 | #endif /* _NETINET_PIM_VAR_H_ */ 102 | 103 | -------------------------------------------------------------------------------- /include/sunos-cc/netinet/igmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Internet Group Management Protocol (IGMP) definitions. 3 | * 4 | * Written by Steve Deering, Stanford, May 1988. 5 | * 6 | * MULTICAST $Revision: 1.3 $ 7 | */ 8 | 9 | /* 10 | * IGMP packet format. 11 | */ 12 | struct igmp { 13 | u_char igmp_type; /* version & type of IGMP message */ 14 | u_char igmp_code; /* code for routing sub-msgs */ 15 | u_short igmp_cksum; /* IP-style checksum */ 16 | struct in_addr igmp_group; /* group address being reported */ 17 | }; /* (zero for queries) */ 18 | 19 | #define IGMP_MINLEN 8 20 | 21 | /* 22 | * Message types, including version number. 23 | */ 24 | #define IGMP_HOST_MEMBERSHIP_QUERY 0x11 /* Host membership query */ 25 | #define IGMP_HOST_MEMBERSHIP_REPORT 0x12 /* Old membership report */ 26 | #define IGMP_DVMRP 0x13 /* DVMRP routing message */ 27 | #define IGMP_PIM 0x14 /* PIM routing message */ 28 | 29 | #define IGMP_HOST_NEW_MEMBERSHIP_REPORT 0x16 /* New membership report */ 30 | 31 | #define IGMP_HOST_LEAVE_MESSAGE 0x17 /* Leave-group message */ 32 | 33 | #define IGMP_MTRACE_RESP 0x1e /* traceroute resp. (to sender) */ 34 | #define IGMP_MTRACE 0x1f /* mcast traceroute messages */ 35 | 36 | #define IGMP_MAX_HOST_REPORT_DELAY 10 /* max delay for response to */ 37 | /* query (in seconds) */ 38 | 39 | 40 | #define IGMP_TIMER_SCALE 10 /* denotes that the igmp->timer filed */ 41 | /* specifies time in 10th of seconds */ 42 | 43 | /* 44 | * States for the IGMPv2 state table 45 | */ 46 | #define IGMP_DELAYING_MEMBER 1 47 | #define IGMP_IDLE_MEMBER 2 48 | #define IGMP_LAZY_MEMBER 3 49 | #define IGMP_SLEEPING_MEMBER 4 50 | #define IGMP_AWAKENING_MEMBER 5 51 | 52 | /* 53 | * We must remember whether the querier is an old or a new router. 54 | */ 55 | #define IGMP_OLD_ROUTER 0 56 | #define IGMP_NEW_ROUTER 1 57 | 58 | /* 59 | * Revert to new router if we haven't heard from an old router in 60 | * this amount of time. 61 | */ 62 | #define IGMP_AGE_THRESHOLD 540 63 | -------------------------------------------------------------------------------- /include/sunos-cc/sys/sockio.h: -------------------------------------------------------------------------------- 1 | /* @(#)sockio.h 1.7 88/12/06 SMI; from UCB ioctl.h 7.1 6/4/86 */ 2 | 3 | /* 4 | * Copyright (c) 1982, 1986 Regents of the University of California. 5 | * All rights reserved. The Berkeley software License Agreement 6 | * specifies the terms and conditions for redistribution. 7 | */ 8 | 9 | /* 10 | * General socket ioctl definitions. 11 | */ 12 | 13 | #ifndef _sys_sockio_h 14 | #define _sys_sockio_h 15 | 16 | #include 17 | 18 | /* socket i/o controls */ 19 | #define SIOCSHIWAT _IOW(s, 0, int) /* set high watermark */ 20 | #define SIOCGHIWAT _IOR(s, 1, int) /* get high watermark */ 21 | #define SIOCSLOWAT _IOW(s, 2, int) /* set low watermark */ 22 | #define SIOCGLOWAT _IOR(s, 3, int) /* get low watermark */ 23 | #define SIOCATMARK _IOR(s, 7, int) /* at oob mark? */ 24 | #define SIOCSPGRP _IOW(s, 8, int) /* set process group */ 25 | #define SIOCGPGRP _IOR(s, 9, int) /* get process group */ 26 | 27 | #define SIOCADDRT _IOW(r, 10, struct rtentry) /* add route */ 28 | #define SIOCDELRT _IOW(r, 11, struct rtentry) /* delete route */ 29 | #define SIOCSETRTINFO _IOWR(r, 12, struct fullrtentry) /* change aux info */ 30 | #define SIOCGETRTINFO _IOWR(r, 13, struct fullrtentry) /* read aux info */ 31 | #define SIOCGETVIFCNT _IOWR(r, 20, struct sioc_vif_req)/* get vif pkt cnt */ 32 | #define SIOCGETSGCNT _IOWR(r, 21, struct sioc_sg_req) /* get s,g pkt cnt */ 33 | /* AH 96/9/23 added GETRPF for PIM support */ 34 | #define SIOCGETRPF _IOWR(r, 22, struct rpfctl) /* get rpf info */ 35 | #ifdef RSVP_ISI 36 | #define SIOCGETVIFINF _IOWR(r, 15, struct vif_conf) /* read m/c vifs */ 37 | #endif RSVP_ISI 38 | 39 | #define SIOCSIFADDR _IOW(i, 12, struct ifreq) /* set ifnet address */ 40 | #define SIOCGIFADDR _IOWR(i,13, struct ifreq) /* get ifnet address */ 41 | #define SIOCSIFDSTADDR _IOW(i, 14, struct ifreq) /* set p-p address */ 42 | #define SIOCGIFDSTADDR _IOWR(i,15, struct ifreq) /* get p-p address */ 43 | #define SIOCSIFFLAGS _IOW(i, 16, struct ifreq) /* set ifnet flags */ 44 | #define SIOCGIFFLAGS _IOWR(i,17, struct ifreq) /* get ifnet flags */ 45 | #define SIOCSIFMEM _IOW(i, 18, struct ifreq) /* set interface mem */ 46 | #define SIOCGIFMEM _IOWR(i,19, struct ifreq) /* get interface mem */ 47 | #define SIOCGIFCONF _IOWR(i,20, struct ifconf) /* get ifnet list */ 48 | #define SIOCSIFMTU _IOW(i, 21, struct ifreq) /* set if_mtu */ 49 | #define SIOCGIFMTU _IOWR(i,22, struct ifreq) /* get if_mtu */ 50 | 51 | /* from 4.3BSD */ 52 | #define SIOCGIFBRDADDR _IOWR(i,23, struct ifreq) /* get broadcast addr */ 53 | #define SIOCSIFBRDADDR _IOW(i,24, struct ifreq) /* set broadcast addr */ 54 | #define SIOCGIFNETMASK _IOWR(i,25, struct ifreq) /* get net addr mask */ 55 | #define SIOCSIFNETMASK _IOW(i,26, struct ifreq) /* set net addr mask */ 56 | #define SIOCGIFMETRIC _IOWR(i,27, struct ifreq) /* get IF metric */ 57 | #define SIOCSIFMETRIC _IOW(i,28, struct ifreq) /* set IF metric */ 58 | 59 | #define SIOCSARP _IOW(i, 30, struct arpreq) /* set arp entry */ 60 | #define SIOCGARP _IOWR(i,31, struct arpreq) /* get arp entry */ 61 | #define SIOCDARP _IOW(i, 32, struct arpreq) /* delete arp entry */ 62 | #define SIOCUPPER _IOW(i, 40, struct ifreq) /* attach upper layer */ 63 | #define SIOCLOWER _IOW(i, 41, struct ifreq) /* attach lower layer */ 64 | #define SIOCSETSYNC _IOW(i, 44, struct ifreq) /* set syncmode */ 65 | #define SIOCGETSYNC _IOWR(i, 45, struct ifreq) /* get syncmode */ 66 | #define SIOCSSDSTATS _IOWR(i, 46, struct ifreq) /* sync data stats */ 67 | #define SIOCSSESTATS _IOWR(i, 47, struct ifreq) /* sync error stats */ 68 | 69 | #define SIOCSPROMISC _IOW(i, 48, int) /* request promisc mode 70 | on/off */ 71 | #define SIOCADDMULTI _IOW(i, 49, struct ifreq) /* set m/c address */ 72 | #define SIOCDELMULTI _IOW(i, 50, struct ifreq) /* clr m/c address */ 73 | 74 | /* FDDI controls */ 75 | #define SIOCFDRESET _IOW(i, 51, struct ifreq) /* Reset FDDI */ 76 | #define SIOCFDSLEEP _IOW(i, 52, struct ifreq) /* Sleep until next dnld req */ 77 | #define SIOCSTRTFMWAR _IOW(i, 53, struct ifreq) /* Start FW at an addr */ 78 | #define SIOCLDNSTRTFW _IOW(i, 54, struct ifreq) /* Load the shared memory */ 79 | #define SIOCGETFDSTAT _IOW(i, 55, struct ifreq) /* Get FDDI stats */ 80 | #define SIOCFDNMIINT _IOW(i, 56, struct ifreq) /* NMI to fddi */ 81 | #define SIOCFDEXUSER _IOW(i, 57, struct ifreq) /* Exec in user mode */ 82 | #define SIOCFDGNETMAP _IOW(i, 58, struct ifreq) /* Get a netmap entry */ 83 | #define SIOCFDGIOCTL _IOW(i, 59, struct ifreq) /* Generic ioctl for fddi */ 84 | 85 | /* protocol i/o controls */ 86 | #define SIOCSNIT _IOW(p, 0, struct nit_ioc) /* set nit modes */ 87 | #define SIOCGNIT _IOWR(p, 1, struct nit_ioc) /* get nit modes */ 88 | 89 | #endif /*!_sys_sockio_h*/ 90 | -------------------------------------------------------------------------------- /include/sunos-gcc/netinet/igmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Internet Group Management Protocol (IGMP) definitions. 3 | * 4 | * Written by Steve Deering, Stanford, May 1988. 5 | * 6 | * MULTICAST $Revision: 1.1 $ 7 | */ 8 | 9 | /* 10 | * IGMP packet format. 11 | */ 12 | struct igmp { 13 | u_char igmp_type; /* version & type of IGMP message */ 14 | u_char igmp_code; /* code for routing sub-msgs */ 15 | u_short igmp_cksum; /* IP-style checksum */ 16 | struct in_addr igmp_group; /* group address being reported */ 17 | }; /* (zero for queries) */ 18 | 19 | #define IGMP_MINLEN 8 20 | 21 | /* 22 | * Message types, including version number. 23 | */ 24 | #define IGMP_HOST_MEMBERSHIP_QUERY 0x11 /* Host membership query */ 25 | #define IGMP_HOST_MEMBERSHIP_REPORT 0x12 /* Old membership report */ 26 | #define IGMP_DVMRP 0x13 /* DVMRP routing message */ 27 | #define IGMP_PIM 0x14 /* PIM routing message */ 28 | 29 | #define IGMP_HOST_NEW_MEMBERSHIP_REPORT 0x16 /* New membership report */ 30 | 31 | #define IGMP_HOST_LEAVE_MESSAGE 0x17 /* Leave-group message */ 32 | 33 | #define IGMP_MTRACE_RESP 0x1e /* traceroute resp. (to sender) */ 34 | #define IGMP_MTRACE 0x1f /* mcast traceroute messages */ 35 | 36 | #define IGMP_MAX_HOST_REPORT_DELAY 10 /* max delay for response to */ 37 | /* query (in seconds) */ 38 | 39 | 40 | #define IGMP_TIMER_SCALE 10 /* denotes that the igmp->timer filed */ 41 | /* specifies time in 10th of seconds */ 42 | 43 | /* 44 | * States for the IGMPv2 state table 45 | */ 46 | #define IGMP_DELAYING_MEMBER 1 47 | #define IGMP_IDLE_MEMBER 2 48 | #define IGMP_LAZY_MEMBER 3 49 | #define IGMP_SLEEPING_MEMBER 4 50 | #define IGMP_AWAKENING_MEMBER 5 51 | 52 | /* 53 | * We must remember whether the querier is an old or a new router. 54 | */ 55 | #define IGMP_OLD_ROUTER 0 56 | #define IGMP_NEW_ROUTER 1 57 | 58 | /* 59 | * Revert to new router if we haven't heard from an old router in 60 | * this amount of time. 61 | */ 62 | #define IGMP_AGE_THRESHOLD 540 63 | -------------------------------------------------------------------------------- /include/sunos-gcc/netinet/in.h: -------------------------------------------------------------------------------- 1 | /* @(#)in.h 1.19 90/07/27 SMI; from UCB 7.5 2/22/88 */ 2 | 3 | /* 4 | * Copyright (c) 1982, 1986 Regents of the University of California. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms are permitted 8 | * provided that this notice is preserved and that due credit is given 9 | * to the University of California at Berkeley. The name of the University 10 | * may not be used to endorse or promote products derived from this 11 | * software without specific prior written permission. This software 12 | * is provided ``as is'' without express or implied warranty. 13 | */ 14 | 15 | /* 16 | * Constants and structures defined by the internet system, 17 | * Per RFC 790, September 1981. 18 | */ 19 | 20 | #ifndef _netinet_in_h 21 | #define _netinet_in_h 22 | 23 | /* 24 | * Protocols 25 | */ 26 | #define IPPROTO_IP 0 /* dummy for IP */ 27 | #define IPPROTO_ICMP 1 /* control message protocol */ 28 | #define IPPROTO_IGMP 2 /* group control protocol */ 29 | #define IPPROTO_GGP 3 /* gateway^2 (deprecated) */ 30 | #define IPPROTO_IPIP 4 /* IP inside IP */ 31 | #define IPPROTO_TCP 6 /* tcp */ 32 | #define IPPROTO_EGP 8 /* exterior gateway protocol */ 33 | #define IPPROTO_PUP 12 /* pup */ 34 | #define IPPROTO_UDP 17 /* user datagram protocol */ 35 | #define IPPROTO_IDP 22 /* xns idp */ 36 | #define IPPROTO_HELLO 63 /* "hello" routing protocol */ 37 | #define IPPROTO_ND 77 /* UNOFFICIAL net disk proto */ 38 | #define IPPROTO_RSVP 46 /* resource reservation proto*/ 39 | #define IPPROTO_PIM 103 /* Protocol Independent Mcast*/ 40 | #define IPPROTO_RAW 255 /* raw IP packet */ 41 | #define IPPROTO_MAX 256 42 | 43 | /* 44 | * Port/socket numbers: network standard functions 45 | */ 46 | #define IPPORT_ECHO 7 47 | #define IPPORT_DISCARD 9 48 | #define IPPORT_SYSTAT 11 49 | #define IPPORT_DAYTIME 13 50 | #define IPPORT_NETSTAT 15 51 | #define IPPORT_FTP 21 52 | #define IPPORT_TELNET 23 53 | #define IPPORT_SMTP 25 54 | #define IPPORT_TIMESERVER 37 55 | #define IPPORT_NAMESERVER 42 56 | #define IPPORT_WHOIS 43 57 | #define IPPORT_MTP 57 58 | 59 | /* 60 | * Port/socket numbers: host specific functions 61 | */ 62 | #define IPPORT_TFTP 69 63 | #define IPPORT_RJE 77 64 | #define IPPORT_FINGER 79 65 | #define IPPORT_TTYLINK 87 66 | #define IPPORT_SUPDUP 95 67 | 68 | /* 69 | * UNIX TCP sockets 70 | */ 71 | #define IPPORT_EXECSERVER 512 72 | #define IPPORT_LOGINSERVER 513 73 | #define IPPORT_CMDSERVER 514 74 | #define IPPORT_EFSSERVER 520 75 | 76 | /* 77 | * UNIX UDP sockets 78 | */ 79 | #define IPPORT_BIFFUDP 512 80 | #define IPPORT_WHOSERVER 513 81 | #define IPPORT_ROUTESERVER 520 /* 520+1 also used */ 82 | 83 | /* 84 | * Ports < IPPORT_RESERVED are reserved for 85 | * privileged processes (e.g. root). 86 | * Ports > IPPORT_USERRESERVED are reserved 87 | * for servers, not necessarily privileged. 88 | */ 89 | #define IPPORT_RESERVED 1024 90 | #define IPPORT_USERRESERVED 5000 91 | 92 | /* 93 | * Link numbers 94 | */ 95 | #define IMPLINK_IP 155 96 | #define IMPLINK_LOWEXPER 156 97 | #define IMPLINK_HIGHEXPER 158 98 | 99 | /* 100 | * Internet address 101 | * This definition contains obsolete fields for compatibility 102 | * with SunOS 3.x and 4.2bsd. The presence of subnets renders 103 | * divisions into fixed fields misleading at best. New code 104 | * should use only the s_addr field. 105 | */ 106 | struct in_addr { 107 | union { 108 | struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b; 109 | struct { u_short s_w1,s_w2; } S_un_w; 110 | u_long S_addr; 111 | } S_un; 112 | #define s_addr S_un.S_addr /* should be used for all code */ 113 | #define s_host S_un.S_un_b.s_b2 /* OBSOLETE: host on imp */ 114 | #define s_net S_un.S_un_b.s_b1 /* OBSOLETE: network */ 115 | #define s_imp S_un.S_un_w.s_w2 /* OBSOLETE: imp */ 116 | #define s_impno S_un.S_un_b.s_b4 /* OBSOLETE: imp # */ 117 | #define s_lh S_un.S_un_b.s_b3 /* OBSOLETE: logical host */ 118 | }; 119 | 120 | /* 121 | * Definitions of bits in internet address integers. 122 | * On subnets, the decomposition of addresses to host and net parts 123 | * is done according to subnet mask, not the masks here. 124 | */ 125 | #define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0) 126 | #define IN_CLASSA_NET 0xff000000 127 | #define IN_CLASSA_NSHIFT 24 128 | #define IN_CLASSA_HOST 0x00ffffff 129 | #define IN_CLASSA_MAX 128 130 | 131 | #define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000) 132 | #define IN_CLASSB_NET 0xffff0000 133 | #define IN_CLASSB_NSHIFT 16 134 | #define IN_CLASSB_HOST 0x0000ffff 135 | #define IN_CLASSB_MAX 65536 136 | 137 | #define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000) 138 | #define IN_CLASSC_NET 0xffffff00 139 | #define IN_CLASSC_NSHIFT 8 140 | #define IN_CLASSC_HOST 0x000000ff 141 | 142 | #define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000) 143 | #define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */ 144 | #define IN_CLASSD_NSHIFT 28 /* net and host fields, but */ 145 | #define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */ 146 | #define IN_MULTICAST(i) IN_CLASSD(i) 147 | 148 | #define IN_EXPERIMENTAL(i) (((long)(i) & 0xe0000000) == 0xe0000000) 149 | #define IN_BADCLASS(i) (((long)(i) & 0xf0000000) == 0xf0000000) 150 | 151 | #define INADDR_ANY (u_long)0x00000000 152 | #define INADDR_LOOPBACK (u_long)0x7F000001 153 | #define INADDR_BROADCAST (u_long)0xffffffff /* must be masked */ 154 | 155 | #define INADDR_UNSPEC_GROUP (u_long)0xe0000000 /* 224.0.0.0 */ 156 | #define INADDR_ALLHOSTS_GROUP (u_long)0xe0000001 /* 224.0.0.1 */ 157 | #define INADDR_MAX_LOCAL_GROUP (u_long)0xe00000ff /* 224.0.0.255 */ 158 | 159 | #define IN_LOOPBACKNET 127 /* official! */ 160 | 161 | /* 162 | * Define a macro to stuff the loopback address into an Internet address 163 | */ 164 | #define IN_SET_LOOPBACK_ADDR(a) {(a)->sin_addr.s_addr = htonl(INADDR_LOOPBACK); \ 165 | (a)->sin_family = AF_INET;} 166 | 167 | /* 168 | * Socket address, internet style. 169 | */ 170 | struct sockaddr_in { 171 | short sin_family; 172 | u_short sin_port; 173 | struct in_addr sin_addr; 174 | char sin_zero[8]; 175 | }; 176 | 177 | /* 178 | * Options for use with [gs]etsockopt at the IP level. 179 | */ 180 | #define IP_OPTIONS 1 /* set/get IP per-packet options */ 181 | #define IP_MULTICAST_IF 2 /* set/get IP multicast interface */ 182 | #define IP_MULTICAST_TTL 3 /* set/get IP multicast timetolive */ 183 | #define IP_MULTICAST_LOOP 4 /* set/get IP multicast loopback */ 184 | #define IP_ADD_MEMBERSHIP 5 /* add an IP group membership */ 185 | #define IP_DROP_MEMBERSHIP 6 /* drop an IP group membership */ 186 | #define IP_MULTICAST_VIF 7 /* set/get IP mcast vir. interface */ 187 | #define IP_RSVP_ON 8 /* set rsvp var. in kernel */ 188 | #define IP_RSVP_OFF 9 /* unset rsvp var in kernel */ 189 | #define IP_RSVP_VIF_ON 10 /* set rsvp per-vif socket */ 190 | #define IP_RSVP_VIF_OFF 11 /* unset rsvp per-vif socket */ 191 | 192 | #define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */ 193 | #define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */ 194 | #define IP_MAX_MEMBERSHIPS 20 /* per socket; must fit in one mbuf */ 195 | 196 | /* 197 | * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. 198 | */ 199 | struct ip_mreq { 200 | struct in_addr imr_multiaddr; /* IP multicast address of group */ 201 | struct in_addr imr_interface; /* local IP address of interface */ 202 | }; 203 | 204 | #if !defined(__vax__) && !defined(ntohl) && !defined(__i386__) 205 | /* 206 | * Macros for number representation conversion. 207 | */ 208 | #define ntohl(x) (x) 209 | #define ntohs(x) (x) 210 | #define htonl(x) (x) 211 | #define htons(x) (x) 212 | #endif 213 | 214 | #if !defined(ntohl) && (defined(__vax__) || defined(__i386__)) 215 | u_short ntohs(), htons(); 216 | u_long ntohl(), htonl(); 217 | #endif 218 | 219 | #ifdef KERNEL 220 | extern struct domain inetdomain; 221 | extern struct protosw inetsw[]; 222 | struct in_addr in_makeaddr(); 223 | u_long in_netof(), in_lnaof(); 224 | #endif 225 | 226 | #endif /*!_netinet_in_h*/ 227 | -------------------------------------------------------------------------------- /include/sunos-gcc/netinet/pim.h: -------------------------------------------------------------------------------- 1 | /* $Id: pim.h,v 1.1 1998/06/01 22:29:43 kurtw Exp $ */ 2 | 3 | #ifndef _NETINET_PIM_H_ 4 | #define _NETINET_PIM_H_ 5 | 6 | /* 7 | * Protocol Independent Multicast (PIM) definitions. 8 | * 9 | * Written by Ahmed Helmy, USC/SGI, July 1996 10 | * Modified by George Edmond Eddy (Rusty), ISI, February 1998 11 | * Modified by Pavlin Ivanov Radoslavov, USC/ISI, May 1998 12 | */ 13 | 14 | /* 15 | * PIM packet format. 16 | */ 17 | #define PIM_VERSION 2 18 | struct pim { 19 | #if BYTE_ORDER == LITTLE_ENDIAN 20 | u_char pim_type:4, /* type of PIM message */ 21 | pim_vers:4; /* PIM version */ 22 | #else /* BYTE_ORDER == BIG_ENDIAN */ 23 | u_char pim_vers:4, /* PIM version */ 24 | pim_type:4; /* type of PIM message */ 25 | #endif /* BYTE_ORDER */ 26 | u_char reserved; /* Reserved */ 27 | u_short pim_cksum; /* IP-style checksum */ 28 | }; 29 | 30 | #define PIM_MINLEN 8 /* The header min. length is 8 */ 31 | #define PIM_REG_MINLEN (PIM_MINLEN+20) /* Register message + inner IPheader */ 32 | 33 | /* 34 | * Message types 35 | */ 36 | #define PIM_REGISTER 0x01 /* PIM Register type is 1 */ 37 | #define PIM_NULL_REGISTER 0x40000000 /* second bit in reg_head is the Null-bit */ 38 | 39 | #endif /* _NETINET_PIM_H_ */ 40 | -------------------------------------------------------------------------------- /include/sunos-gcc/netinet/pim_var.h: -------------------------------------------------------------------------------- 1 | /* $Id: pim_var.h,v 1.1 1998/06/01 22:29:43 kurtw Exp $ */ 2 | 3 | #ifndef _NETINET_PIM_VAR_H_ 4 | #define _NETINET_PIM_VAR_H_ 5 | 6 | /* 7 | * Protocol Independent Multicast (PIM), 8 | * implementation-specific definitions. 9 | * 10 | * Written by George Edmond Eddy (Rusty), ISI, February 1998 11 | * Modified by Pavlin Ivanov Radoslavov, USC/ISI, May 1998 12 | */ 13 | 14 | struct pimstat { 15 | u_int pim_rcv_total; /* total PIM messages received */ 16 | u_int pim_rcv_tooshort; /* received with too few bytes */ 17 | u_int pim_rcv_badsum; /* received with bad checksum */ 18 | u_int pim_rcv_badversion; /* received bad PIM version */ 19 | u_int pim_rcv_registers; /* received registers */ 20 | u_int pim_rcv_badregisters; /* received invalid registers */ 21 | u_int pim_snd_registers; /* sent registers */ 22 | }; 23 | 24 | #if (defined(KERNEL)) || (defined(_KERNEL)) 25 | extern struct pimstat pimstat; 26 | 27 | #ifdef NetBSD 28 | void pim_input (struct mbuf *, ...); 29 | #else 30 | void pim_input (struct mbuf *, int); 31 | #endif 32 | #endif /* KERNEL */ 33 | 34 | /* 35 | * Names for PIM sysctl objects 36 | */ 37 | #if (defined(__FreeBSD__)) || (defined(NetBSD)) 38 | #define PIMCTL_STATS 1 /* statistics (read-only) */ 39 | #define PIMCTL_MAXID 2 40 | 41 | #define PIMCTL_NAMES { \ 42 | { 0, 0 }, \ 43 | { "stats", CTLTYPE_STRUCT }, \ 44 | } 45 | #endif /* FreeBSD || NetBSD */ 46 | 47 | #endif /* _NETINET_PIM_VAR_H_ */ 48 | -------------------------------------------------------------------------------- /include/sunos-gcc/sys/sockio.h: -------------------------------------------------------------------------------- 1 | /* @(#)sockio.h 1.7 88/12/06 SMI; from UCB ioctl.h 7.1 6/4/86 */ 2 | 3 | /* 4 | * Copyright (c) 1982, 1986 Regents of the University of California. 5 | * All rights reserved. The Berkeley software License Agreement 6 | * specifies the terms and conditions for redistribution. 7 | */ 8 | 9 | /* 10 | * General socket ioctl definitions. 11 | */ 12 | 13 | #ifndef _sys_sockio_h 14 | #define _sys_sockio_h 15 | 16 | #include 17 | 18 | /* socket i/o controls */ 19 | #define SIOCSHIWAT _IOW('s', 0, int) /* set high watermark */ 20 | #define SIOCGHIWAT _IOR('s', 1, int) /* get high watermark */ 21 | #define SIOCSLOWAT _IOW('s', 2, int) /* set low watermark */ 22 | #define SIOCGLOWAT _IOR('s', 3, int) /* get low watermark */ 23 | #define SIOCATMARK _IOR('s', 7, int) /* at oob mark? */ 24 | #define SIOCSPGRP _IOW('s', 8, int) /* set process group */ 25 | #define SIOCGPGRP _IOR('s', 9, int) /* get process group */ 26 | 27 | #define SIOCADDRT _IOW('r', 10, struct rtentry) /* add route */ 28 | #define SIOCDELRT _IOW('r', 11, struct rtentry) /* delete route */ 29 | #define SIOCGETVIFCNT _IOWR('r', 20, struct sioc_vif_req)/* get vif pkt cnt */ 30 | #define SIOCGETSGCNT _IOWR('r', 21, struct sioc_sg_req) /* get s,g pkt cnt */ 31 | /* AH 96/9/23 added GETRPF for PIM support */ 32 | #define SIOCGETRPF _IOWR('r', 22, struct rpfctl) /* get rpf info */ 33 | #ifdef RSVP_ISI 34 | #define SIOCGETVIFINF _IOWR('r', 15, struct vif_conf) /* read m/c vifs */ 35 | #endif RSVP_ISI 36 | 37 | #define SIOCSIFADDR _IOW('i', 12, struct ifreq) /* set ifnet address */ 38 | #define SIOCGIFADDR _IOWR('i',13, struct ifreq) /* get ifnet address */ 39 | #define SIOCSIFDSTADDR _IOW('i', 14, struct ifreq) /* set p-p address */ 40 | #define SIOCGIFDSTADDR _IOWR('i',15, struct ifreq) /* get p-p address */ 41 | #define SIOCSIFFLAGS _IOW('i', 16, struct ifreq) /* set ifnet flags */ 42 | #define SIOCGIFFLAGS _IOWR('i',17, struct ifreq) /* get ifnet flags */ 43 | #define SIOCSIFMEM _IOW('i', 18, struct ifreq) /* set interface mem */ 44 | #define SIOCGIFMEM _IOWR('i',19, struct ifreq) /* get interface mem */ 45 | #define SIOCGIFCONF _IOWR('i',20, struct ifconf) /* get ifnet list */ 46 | #define SIOCSIFMTU _IOW('i', 21, struct ifreq) /* set if_mtu */ 47 | #define SIOCGIFMTU _IOWR('i',22, struct ifreq) /* get if_mtu */ 48 | 49 | /* from 4.3BSD */ 50 | #define SIOCGIFBRDADDR _IOWR('i',23, struct ifreq) /* get broadcast addr */ 51 | #define SIOCSIFBRDADDR _IOW('i',24, struct ifreq) /* set broadcast addr */ 52 | #define SIOCGIFNETMASK _IOWR('i',25, struct ifreq) /* get net addr mask */ 53 | #define SIOCSIFNETMASK _IOW('i',26, struct ifreq) /* set net addr mask */ 54 | #define SIOCGIFMETRIC _IOWR('i',27, struct ifreq) /* get IF metric */ 55 | #define SIOCSIFMETRIC _IOW('i',28, struct ifreq) /* set IF metric */ 56 | 57 | #define SIOCSARP _IOW('i', 30, struct arpreq) /* set arp entry */ 58 | #define SIOCGARP _IOWR('i',31, struct arpreq) /* get arp entry */ 59 | #define SIOCDARP _IOW('i', 32, struct arpreq) /* delete arp entry */ 60 | #define SIOCUPPER _IOW('i', 40, struct ifreq) /* attach upper layer */ 61 | #define SIOCLOWER _IOW('i', 41, struct ifreq) /* attach lower layer */ 62 | #define SIOCSETSYNC _IOW('i', 44, struct ifreq) /* set syncmode */ 63 | #define SIOCGETSYNC _IOWR('i', 45, struct ifreq) /* get syncmode */ 64 | #define SIOCSSDSTATS _IOWR('i', 46, struct ifreq) /* sync data stats */ 65 | #define SIOCSSESTATS _IOWR('i', 47, struct ifreq) /* sync error stats */ 66 | 67 | #define SIOCSPROMISC _IOW('i', 48, int) /* request promisc mode 68 | on/off */ 69 | #define SIOCADDMULTI _IOW('i', 49, struct ifreq) /* set m/c address */ 70 | #define SIOCDELMULTI _IOW('i', 50, struct ifreq) /* clr m/c address */ 71 | 72 | /* FDDI controls */ 73 | #define SIOCFDRESET _IOW('i', 51, struct ifreq) /* Reset FDDI */ 74 | #define SIOCFDSLEEP _IOW('i', 52, struct ifreq) /* Sleep until next dnld req */ 75 | #define SIOCSTRTFMWAR _IOW('i', 53, struct ifreq) /* Start FW at an addr */ 76 | #define SIOCLDNSTRTFW _IOW('i', 54, struct ifreq) /* Load the shared memory */ 77 | #define SIOCGETFDSTAT _IOW('i', 55, struct ifreq) /* Get FDDI stats */ 78 | #define SIOCFDNMIINT _IOW('i', 56, struct ifreq) /* NMI to fddi */ 79 | #define SIOCFDEXUSER _IOW('i', 57, struct ifreq) /* Exec in user mode */ 80 | #define SIOCFDGNETMAP _IOW('i', 58, struct ifreq) /* Get a netmap entry */ 81 | #define SIOCFDGIOCTL _IOW('i', 59, struct ifreq) /* Generic ioctl for fddi */ 82 | 83 | /* protocol i/o controls */ 84 | #define SIOCSNIT _IOW('p', 0, struct nit_ioc) /* set nit modes */ 85 | #define SIOCGNIT _IOWR('p', 1, struct nit_ioc) /* get nit modes */ 86 | 87 | #endif /*!_sys_sockio_h*/ 88 | -------------------------------------------------------------------------------- /lib/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | .deps/ 3 | .dirstamp 4 | -------------------------------------------------------------------------------- /lib/strlcat.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: strlcat.c,v 1.15 2015/03/02 21:41:08 millert Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1998, 2015 Todd C. Miller 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #include 20 | #include 21 | 22 | /* 23 | * Appends src to string dst of size dsize (unlike strncat, dsize is the 24 | * full size of dst, not space left). At most dsize-1 characters 25 | * will be copied. Always NUL terminates (unless dsize <= strlen(dst)). 26 | * Returns strlen(src) + MIN(dsize, strlen(initial dst)). 27 | * If retval >= dsize, truncation occurred. 28 | */ 29 | size_t 30 | strlcat(char *dst, const char *src, size_t dsize) 31 | { 32 | const char *odst = dst; 33 | const char *osrc = src; 34 | size_t n = dsize; 35 | size_t dlen; 36 | 37 | /* Find the end of dst and adjust bytes left but don't go past end. */ 38 | while (n-- != 0 && *dst != '\0') 39 | dst++; 40 | dlen = dst - odst; 41 | n = dsize - dlen; 42 | 43 | if (n-- == 0) 44 | return(dlen + strlen(src)); 45 | while (*src != '\0') { 46 | if (n != 0) { 47 | *dst++ = *src; 48 | n--; 49 | } 50 | src++; 51 | } 52 | *dst = '\0'; 53 | 54 | return(dlen + (src - osrc)); /* count does not include NUL */ 55 | } 56 | -------------------------------------------------------------------------------- /lib/strlcpy.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: strlcpy.c,v 1.12 2015/01/15 03:54:12 millert Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1998, 2015 Todd C. Miller 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #include 20 | #include 21 | 22 | /* 23 | * Copy string src to buffer dst of size dsize. At most dsize-1 24 | * chars will be copied. Always NUL terminates (unless dsize == 0). 25 | * Returns strlen(src); if retval >= dsize, truncation occurred. 26 | */ 27 | size_t 28 | strlcpy(char *dst, const char *src, size_t dsize) 29 | { 30 | const char *osrc = src; 31 | size_t nleft = dsize; 32 | 33 | /* Copy as many bytes as will fit. */ 34 | if (nleft != 0) { 35 | while (--nleft != 0) { 36 | if ((*dst++ = *src++) == '\0') 37 | break; 38 | } 39 | } 40 | 41 | /* Not enough room in dst, add NUL and traverse rest of src. */ 42 | if (nleft == 0) { 43 | if (dsize != 0) 44 | *dst = '\0'; /* NUL-terminate dst */ 45 | while (*src++) 46 | ; 47 | } 48 | 49 | return(src - osrc - 1); /* count does not include NUL */ 50 | } 51 | -------------------------------------------------------------------------------- /lib/tempfile.c: -------------------------------------------------------------------------------- 1 | /* A secure tmpfile() replacement. 2 | * 3 | * Copyright (c) 2015-2020 Joachim Wiberg 4 | * 5 | * Permission to use, copy, modify, and/or distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | */ 17 | 18 | #include 19 | #include /* O_TMPFILE requires -D_GNU_SOURCE */ 20 | #include /* fdopen() */ 21 | #include /* umask() */ 22 | 23 | /** 24 | * tempfile - A secure tmpfile() replacement 25 | * 26 | * This is the secure replacement for tmpfile() that does not exist in 27 | * GLIBC. The function uses the Linux specific %O_TMPFILE and %O_EXCL 28 | * for security. When the %FILE is fclose()'ed the file contents is 29 | * lost. The file is hidden in the %_PATH_TMP directory on the system. 30 | * 31 | * This function requires Linux 3.11, or later, due to %O_TMPFILE. 32 | * 33 | * Returns: 34 | * An open %FILE pointer, or %NULL on error. 35 | */ 36 | FILE *tempfile(void) 37 | { 38 | #ifdef O_TMPFILE /* Only on Linux, with fairly recent (G)LIBC */ 39 | mode_t oldmask; 40 | int fd; 41 | 42 | oldmask = umask(0077); 43 | fd = open(_PATH_TMP, O_TMPFILE | O_RDWR | O_EXCL | O_CLOEXEC, S_IRUSR | S_IWUSR); 44 | umask(oldmask); 45 | if (-1 == fd) 46 | return NULL; 47 | 48 | return fdopen(fd, "w+"); 49 | #else 50 | return tmpfile(); /* Fallback on older GLIBC/Linux and actual UNIX systems */ 51 | #endif 52 | } 53 | 54 | /** 55 | * Local Variables: 56 | * indent-tabs-mode: t 57 | * c-file-style: "linux" 58 | * End: 59 | */ 60 | -------------------------------------------------------------------------------- /man/Makefile.am: -------------------------------------------------------------------------------- 1 | dist_man5_MANS = pimdd.conf.5 2 | dist_man8_MANS = pimdd.8 pimctl.8 3 | -------------------------------------------------------------------------------- /man/pimctl.8: -------------------------------------------------------------------------------- 1 | .Dd Sep 12, 2021 2 | .Dt PIMCTL 8 SMM 3 | .Os 4 | .Sh NAME 5 | .Nm pimctl 6 | .Nd Control tool for 7 | .Xr pimdd 8 8 | .Sh SYNOPSIS 9 | .Nm pimctl 10 | .Op Fl mpthv 11 | .Op Fl i Ar NAME 12 | .Op Fl u Ar FILE 13 | .Op COMMAND 14 | .Nm 15 | .Ar help | kill | restart | status | version 16 | .Pp 17 | .Nm 18 | .Ar debug Op ? | none | SYSTEM Op ,SYSTEM 19 | .Nm 20 | .Ar log Op ? | none | LEVEL 21 | .Pp 22 | .Nm 23 | .Ar show igmp 24 | .Pp 25 | .Nm 26 | .Ar show interface 27 | .Nm 28 | .Ar show neighbor 29 | .Nm 30 | .Ar show mrt Op detail 31 | .Nm 32 | .Ar show rp 33 | .Nm 34 | .Ar show crp 35 | .Nm 36 | .Ar show compat Op detail 37 | .Nm 38 | .Ar show pim Op detail 39 | .Sh DESCRIPTION 40 | .Nm 41 | is the friendly control tool for 42 | .Xr pimd 8 , 43 | .Xr pimdd 8 , 44 | and 45 | .Xr pim6sd 8 . 46 | It can be used to query status, debug, restart, and kill a running PIM 47 | daemon. Commands can be abbreviated to the minimum unambiguous prefix; 48 | for example, 49 | .Cm s in 50 | for 51 | .Cm show interface . 52 | .Sh OPTIONS 53 | This program follows the usual UNIX command line syntax, with long 54 | options starting with two dashes (`-'). The options are as follows: 55 | .Bl -tag -width Ds 56 | .It Fl h, -help 57 | Show usage instructions and exit. 58 | .It Fl i, -ident Ar NAME 59 | Connect to named PIM daemon instance. Since the same 60 | .Nm 61 | is capable supporting all the PIM daemon's it comes with heuristics to 62 | aid the user, i.e., if only one of the supported daemon's is running 63 | this option is not required. 64 | .It Fl m, -monitor 65 | Run 66 | .Op Ar COMMAND 67 | every two seconds, for limited systems that do not have 68 | .Xr watch 1 , 69 | which is highly recommended with 70 | .Nm . 71 | .It Fl p, -plain 72 | Use plain table headings, no ANSI ctrl characters. When using 73 | .Xr watch 1 , 74 | use 75 | .Cm watch Fl c 76 | option instead, it handles ANSI escape sequences. 77 | .It Fl t, -no-heading 78 | Skip table headings altogether. Useful for scripting 79 | .Nm . 80 | .It Fl u, -ipc Ar FILE 81 | Override UNIX domain socket filename, the default is based on the 82 | identity, 83 | .Fl i Ar NAME . 84 | On most systems this is 85 | .Pa /var/run/pimdd.sock . 86 | .El 87 | .Sh COMMANDS 88 | The 89 | .Nm 90 | tool from this project can be used with any of the other PIM daemons, 91 | so the available commands vary. When a PIM daemon is running the 92 | .Nm 93 | tool querys it over IPC for available commands. The 94 | .Nm pimd 95 | daemon comes with the following commands: 96 | .Bl -tag -width Ds 97 | .It Nm Ar help 98 | Show usage instructions and exit. 99 | .It Nm Ar kill 100 | Kill running daemon, like sending SIGTERM to the PIM daemon. 101 | .It Nm Ar restart 102 | Restart daemon and reload 103 | .Pa /etc/pimdd.conf , 104 | like sending SIGHUP to the PIM daemon. 105 | .It Nm Ar status 106 | Show PIM daemon status. 107 | .It Nm Ar debug Op ? | none | SYSTEM Op ,SYSTEM 108 | Control subystem debugging at runtime. Multiple subsystems can be 109 | enabled, separate with comma. E.g. 110 | .Bd -unfilled -offset indent 111 | pimctl debug igmp,pim 112 | .Ed 113 | .Pp 114 | The command returns a list of enabled subsystems. Without any debug 115 | argument, the command lists the currently enabled subsystems. To list 116 | all available subsystems, use 117 | .Bd -unfilled -offset indent 118 | pimctl debug ? 119 | .Ed 120 | .Pp 121 | To disable all subsystems, use 122 | .Bd -unfilled -offset indent 123 | pimctl debug none 124 | .Ed 125 | .Pp 126 | Subsystems: 127 | .Pp 128 | .Bl -tag -width pim_routes -compact -offset indent 129 | .It Cm all 130 | Enable all subsystems (may trigger log rate limiter) 131 | .It Cm asserts 132 | PIM assert messages 133 | .It Cm bsr 134 | PIM bootstrap router messages 135 | .It Cm crp 136 | PIM Candidate Rendez-Vous Point messages 137 | .It Cm detail 138 | Detailed PIM debug messages 139 | .It Cm igmp 140 | Debug IGMP messages 141 | .It Cm interfaces 142 | Show interface (VIF) debug messages 143 | .It Cm jp 144 | PIM join-prune messages 145 | .It Cm kernel 146 | Kernel debug messages 147 | .It Cm mfc 148 | Debug messages for the multicast forwarding cache (kernel) 149 | .It Cm mrt 150 | PIM routing messages 151 | .It Cm neighbors 152 | Debug hello messages to/from neighbors 153 | .It Cm packets 154 | Debug inbound/outbout packets 155 | .It Cm pim 156 | All PIM messages 157 | .It Cm prunes 158 | Pruning operations, or pruned routes 159 | .It Cm registers 160 | PIM register tunnel debug messages 161 | .It Cm rpf 162 | PIM revers-path forwarding debug messages 163 | .It Cm rsrr 164 | Debug RSRR messages 165 | .It Cm timers 166 | Debug timers 167 | .It Cm traceroute 168 | Multicast traceroute information 169 | .El 170 | .It Nm Ar log Op ? | none | LEVEL 171 | Control, query, or disable the log level of the PIM daemon: 172 | .Pp 173 | .Bl -tag -width WARNING -compact -offset indent 174 | .It Cm none 175 | Disable all logging 176 | .It Cm error 177 | Error conditions 178 | .It Cm warning 179 | Warning conditions 180 | .It Cm notice 181 | Normal but significant condition (Default) 182 | .It Cm info 183 | Informational 184 | .It Cm debug 185 | Debug-level messages 186 | .El 187 | .It Nm Ar show igmp 188 | Show IGMP interface status and group memberships. 189 | .It Nm Ar show interfaces 190 | Show PIM interface table 191 | .It Nm Ar show neighbor 192 | Show PIM neighbor table 193 | .It Nm Ar show mrt 194 | Show PIM multicast routing table. To see the actual multicast 195 | forwarding cache (mfc), see your operating system specific command. The 196 | MROUTING stack (used in most UNIX systems today) never developed socket 197 | options to query the routing table, so every operating system has its 198 | own method. On Linux this is 199 | .Bd -unfilled -offset indent 200 | ip mroute show 201 | .Ed 202 | .Pp 203 | on BSD systems it is usually something like 204 | .Bd -unfilled -offset indent 205 | netstat -g 206 | .Ed 207 | .Pp 208 | and on SVR4 systems like Illumos it is 209 | .Bd -unfilled -offset indent 210 | netstat -M 211 | .Ed 212 | .It Nm Ar show rp 213 | Show PIM Rendezvous-Point (RP) set 214 | .It Nm Ar show crp 215 | Show PIM Candidate Rendezvous-Point (CRP) set. 216 | .It Nm Ar show compat 217 | Show PIM status, compat mode. Previously available by sending SIGUSR1 218 | to the daemon to get output in 219 | .Pa /var/run/pimdd/pimdd.dump . 220 | These methods are no longer available, only this compat command remains. 221 | .It Nm Ar show pim Op detail 222 | Modern variant of the 223 | .Cm show compat 224 | command. 225 | .El 226 | .Sh FILES 227 | .Bl -tag -width /var/run/pimdd.sock -compact 228 | .It Pa /var/run/pimdd.sock 229 | .Ux Ns -domain 230 | socket used for communication with 231 | .Xr pimd 8 232 | .El 233 | .Pp 234 | Note, the basename used changes when running with a different identity, 235 | .Fl i Ar NAME , 236 | or when another PIM daemon from the same family is found. 237 | .Sh SEE ALSO 238 | .Xr pimd 8 , 239 | .Xr pimdd 8 , 240 | .Xr pim6sd 8 , 241 | .Xr /usr/share/doc/pimdd/ 242 | .Sh AUTHORS 243 | .Nm pimdd 244 | was made by Kurt Windisch while at University of Oregon. It is entirely 245 | based on 246 | .Nm pimd , 247 | which was originally written by Ahmed Helmy, George Edmond "Rusty" Eddy, 248 | and Pavlin Ivanov Radoslavov. 249 | .Pp 250 | This manual page is written by by Joachim Wiberg for the 251 | .Lk https://github.com/troglobit/pimd-dense GitHub 252 | .Nm 253 | project. 254 | -------------------------------------------------------------------------------- /man/pimdd.conf.5: -------------------------------------------------------------------------------- 1 | .\" Hey, EMACS: -*- nroff -*- 2 | .\" First parameter, NAME, should be all caps 3 | .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection 4 | .\" other parameters are allowed: see man(7), man(1) 5 | .Dd Aug 28, 2021 6 | .Dt PIMDD.CONF 5 7 | .Os 8 | .Sh NAME 9 | .Nm pimdd.conf 10 | .Nd pimdd configuration file 11 | .Sh SYNOPSIS 12 | .Nm /etc/pimdd.conf 13 | .Sh DESCRIPTION 14 | In many cases you do not need to configure 15 | .Nm pimdd . 16 | It configures itself automatically to forward multicast on all 17 | multicast-capable interfaces, i.e., interfaces that have the 18 | .Cm IFF_MULTICAST 19 | flag set. It locates other PIM-DM capable routers directly reachable 20 | via those interfaces. 21 | .Pp 22 | .Nm pimdd 23 | will not start with less than two enabled virtual interfaces (VIFs). A 24 | VIF is either a physical multicast-capable interface or a tunnel. To 25 | override the default settings, for example to disable some interfaces 26 | from being used, configuration commands may be placed in 27 | .Pa /etc/pimdd.conf . 28 | .Pp 29 | The file format is relatively free-form: whitespace (including newlines) 30 | is not significant. However, the order of some statements are 31 | important, more on this below. 32 | .Pp 33 | By default, 34 | .Nm pimdd 35 | runs on all multicast capable interfaces. The 36 | .Cm phyint 37 | setting can be used to control this behavior. 38 | .Pp 39 | .Bl -tag -offset indent -width 1n 40 | .It Cm assert-timeout Ao Ar 5-210 Ac 41 | .It Cm default-route-distance Ao Ar 1-255 Ac 42 | .It Cm default-route-metric Ao Ar 1-1024 Ac 43 | .It Cm no phyint 44 | .It Cm phyint Ao Ar address | Ar ifname Ac Oo Cm enable | disable Oc Oo Cm igmpv2 | igmpv3 Oc Oo Cm distance Ao Ar 1-255 Ac Oc Oo Cm metric Ao Ar 1-1024 Ac Oc 45 | .El 46 | .Pp 47 | The PIM assert mechanism arbitrates the forwarder of multicast when 48 | there are more than one router with the same (S,G) pair for a given 49 | destination LAN. The winner of an assert is the router with either 50 | the best (unicast) protocol distance (called metric preference in 51 | the RFC), or the best metric if the distance is the same, or, as a 52 | tiebreaker, the highest IP address. The loser of an asser election 53 | prunes its outbound interface from forwarding and starts an assert 54 | timer, in case the active forwarder is lost. The 55 | .Cm assert-timeout 56 | can be used to tune the PIM assert timer to a value between 5 to 210 57 | seconds, default: 180 sec. 58 | .Pp 59 | The 60 | .Cm default-route-distance 61 | option has nothing to do with the system default route, it is rather the 62 | default value for the unicast routing protocol's administrative 63 | distance. It is used in PIM Assert elections to determine upstream 64 | routers. Currently 65 | .Nm 66 | cannot obtain the admin distance and metric from the unicast routing 67 | protocols, so a default routing protocol distance (the RFC confusingly 68 | refers to this as 69 | .Em metric prefererence ) 70 | may be configured. In a PIM Assert election, the router advertising the 71 | lowest assert preference will be selected as the forwarder and upstream 72 | router for the LAN. Setting 101 should be sufficiently high so that 73 | asserts from Cisco or other routers preferred over 74 | .Nm . 75 | .Pp 76 | It is recommended that distances be set such that metrics are never 77 | consulted. However, default routing metrics may also be set using the 78 | .Cm default-route-metric 79 | option. (Again, this has nothing to do with the system default route.) 80 | This item sets the cost for sending data through this router. You want 81 | only PIM-DM data to go to this daemon; so once again, a high value is 82 | recommended to prevent accidental usage. The preferred default value is 83 | 1024. Both defaults can be overridden per phyint, so learned routes, or 84 | PIM Asserts use the phyint's values. 85 | .Pp 86 | Please also note that PIM Assert elections are not the same as the DR 87 | election. The PIM Assert election determines the active multicast 88 | forwarder, whereas the DR election determines the active PIM router. 89 | .Pp 90 | The 91 | .Nm phyint 92 | setting refers to a physical interface and must come after the 93 | .Cm default-route-metric 94 | and 95 | .Cm default-route-distance 96 | settings in the configuration file. Select the interface by its IP 97 | .Ar address 98 | or name. If you just want to activate this interface with default 99 | values, you don't need to put anything else on the line. However, there 100 | are some additional settings: 101 | .Pp 102 | .Bl -bullet -offset indent -width 1n -compact 103 | .It 104 | .Cm enable : 105 | Enable an interface for PIM. Used after the 106 | .Cm no phyint 107 | directive. 108 | .It 109 | .Cm disable : 110 | Do not use this interface in 111 | .Nm . 112 | .It 113 | .Cm igmpv2 | igmpv3 : 114 | Force interface in specific IGMP version. Default: 115 | .Cm igmpv3 . 116 | .It 117 | .Cm distance Ao Ar 1-255 Ac : 118 | Use this to override the 119 | .Nm default-route-distance 120 | (101) on this 121 | .Nm phyint 122 | in PIM Assert elections. 123 | .It 124 | .Cm metric Ao Ar 1-1024 Ac : 125 | The cost of sending data through this interface. Defaults to 126 | .Nm default-route-metric 127 | (1024) if not assigned. 128 | .El 129 | .Pp 130 | Add one 131 | .Nm phyint 132 | line per interface on this router. Otherwise 133 | .Nm 134 | will run on all interfaces using default settings. 135 | .Sh FILES 136 | .Bl -tag -width /etc/pimdd.conf -compact 137 | .It Pa /etc/pimdd.conf 138 | Main configuration file. 139 | .El 140 | .Sh SEE ALSO 141 | .Xr pimdd 8 , 142 | .Xr pimctl 8 143 | .Sh AUTHORS 144 | This manual page was written by 145 | .An Joachim Wiberg Aq mailto:troglobit@gmail.com . 146 | -------------------------------------------------------------------------------- /pimdd.conf: -------------------------------------------------------------------------------- 1 | # This is the configuration file for "pimd-dense", an IP multicast 2 | # router. pimdd looks for it in "/etc/pimdd.conf". 3 | # 4 | # Command formats: 5 | # 6 | # assert-timeout <5-210> 7 | # default-route-distance <1-255> 8 | # default-route-metric <1-1024> 9 | # no phyint 10 | # phyint [disable|enable] | [distance <1-255>] [metric <1-1024>] 11 | # 12 | # By default PIM will be activated on all interfaces. Use `no phyint` 13 | # to disable all interfaces by default and then `enable` each phyint, or 14 | # selectively disable each interfaces where PIM should not run. 15 | # 16 | # Route preferences are used in PIM Assert elections to determine the 17 | # upstream routers. Currently pimdd can only obtain unicaast routing 18 | # metrics, and only on Linux kernels. So at least the protocol distance 19 | # must be configured. In an assert election, the router advertising the 20 | # lowest assert preference will be selected as the (S,G)-forwarder and 21 | # upstream router for the LAN. 101 should be sufficiently high so that 22 | # asserts from Cisco or GateD routers are prefered over pimd-dense. 23 | # These default route preferences are what each phyint is initialized 24 | # with unless an explicit distance/metric is given. 25 | 26 | #assert-timeout 180 27 | #default-route-distance 101 28 | #default-route-metric 1024 29 | 30 | #phyint 128.125.51.11 disable 31 | #phyint 128.223.91.129 distance 101 32 | #phyint 128.223.163.129 disable 33 | 34 | #no phyint 35 | #phyint 192.168.1.113 enable 36 | #phyint 192.168.123.1 enable 37 | 38 | #no phyint 39 | #phyint wlp3s0 enable 40 | #phyint lxcbr0 enable 41 | -------------------------------------------------------------------------------- /pimdd.service.in: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=PIM-DM multicast routing daemon 3 | Documentation=man:pimdd 4 | Documentation=man:pimctl 5 | Documentation=man:pimdd.conf 6 | # ConditionPathExists=@SYSCONFDIR@/pimdd.conf 7 | After=network-online.target 8 | Requires=network-online.target 9 | 10 | [Service] 11 | Type=simple 12 | EnvironmentFile=-@SYSCONFDIR@/default/pimd 13 | ExecStart=@SBINDIR@/pimdd -ns $PIMDD_OPTS 14 | 15 | [Install] 16 | WantedBy=multi-user.target 17 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | .deps/ 3 | pimdd 4 | pimctl 5 | cfparse.c 6 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | # For replacement functions in lib/ 2 | AUTOMAKE_OPTIONS = subdir-objects 3 | 4 | AM_CPPFLAGS = -I$(top_srcdir)/include 5 | AM_CPPFLAGS += -DSYSCONFDIR=\"@sysconfdir@\" -DRUNSTATEDIR=\"@runstatedir@\" 6 | 7 | sbin_PROGRAMS = pimdd pimctl 8 | pimdd_SOURCES = callout.c cfparse.y config.c debug.c debug.h defs.h dvmrp.h \ 9 | dvmrp_proto.c igmpv2.h igmpv3.h igmp.c igmp_proto.c inet.c \ 10 | ipc.c kern.c main.c mrt.c mrt.h pathnames.h pimdd.h pim.c \ 11 | pim_proto.c queue.h route.c timer.c trace.c trace.h vif.c vif.h 12 | pimdd_CFLAGS = -W -Wall -Wextra -Wno-unused 13 | pimdd_LDADD = $(LIBS) $(LIBOBJS) 14 | 15 | if LINUX 16 | AM_CPPFLAGS += -DRAW_OUTPUT_IS_RAW -DIOCTL_OK_ON_RAW_SOCKET 17 | pimdd_SOURCES += netlink.c 18 | endif 19 | 20 | if BSD 21 | pimdd_SOURCES += routesock.c 22 | endif 23 | 24 | if RSRR 25 | AM_CPPFLAGS += -DPIM 26 | pimdd_SOURCES += rsrr.c rsrr_var.h rsrr.h 27 | endif 28 | 29 | pimctl_SOURCES = pimctl.c queue.h 30 | pimctl_CFLAGS = -W -Wall -Wextra -Wno-unused 31 | pimctl_LDADD = $(LIBS) $(LIBOBJS) 32 | -------------------------------------------------------------------------------- /src/callout.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The mrouted program is covered by the license in the accompanying file 3 | * named "LICENSE.mrouted". Use of the mrouted program represents acceptance 4 | * of the terms and conditions listed in that file. 5 | * 6 | * The mrouted program is COPYRIGHT 1989 by The Board of Trustees of 7 | * Leland Stanford Junior University. 8 | * 9 | * 10 | * callout.c,v 3.8.4.5 1997/05/16 20:18:25 fenner Exp 11 | */ 12 | 13 | #include "defs.h" 14 | 15 | /* the code below implements a callout queue */ 16 | static int id = 0; 17 | static struct timeout_q *Q = 0; /* pointer to the beginning of timeout queue */ 18 | 19 | struct timeout_q { 20 | struct timeout_q *next; /* next event */ 21 | int id; 22 | cfunc_t func; /* function to call */ 23 | void *data; /* func's data */ 24 | int time; /* time offset to next event*/ 25 | }; 26 | 27 | #ifdef CALLOUT_DEBUG 28 | static void print_Q (void); 29 | #else 30 | #define print_Q() 31 | #endif 32 | 33 | void 34 | callout_init() 35 | { 36 | Q = NULL; 37 | } 38 | 39 | void 40 | free_all_callouts() 41 | { 42 | struct timeout_q *p; 43 | 44 | while (Q) { 45 | p = Q; 46 | Q = Q->next; 47 | free(p); 48 | } 49 | } 50 | 51 | 52 | /* 53 | * elapsed_time seconds have passed; perform all the events that should 54 | * happen. 55 | */ 56 | void 57 | age_callout_queue(elapsed_time) 58 | int elapsed_time; 59 | { 60 | struct timeout_q *ptr, *expQ; 61 | 62 | #ifdef CALLOUT_DEBUG 63 | IF_DEBUG(DEBUG_TIMEOUT) 64 | logit(LOG_DEBUG, 0, "aging queue (elapsed time %d):", elapsed_time); 65 | print_Q(); 66 | #endif 67 | 68 | expQ = Q; 69 | ptr = NULL; 70 | 71 | while (Q) { 72 | if (Q->time > elapsed_time) { 73 | Q->time -= elapsed_time; 74 | if (ptr) { 75 | ptr->next = NULL; 76 | break; 77 | } 78 | return; 79 | } 80 | 81 | elapsed_time -= Q->time; 82 | ptr = Q; 83 | Q = Q->next; 84 | } 85 | 86 | /* handle queue of expired timers */ 87 | while (expQ) { 88 | ptr = expQ; 89 | if (ptr->func) 90 | ptr->func(ptr->data); 91 | expQ = expQ->next; 92 | free(ptr); 93 | } 94 | } 95 | 96 | /* 97 | * Return in how many seconds age_callout_queue() would like to be called. 98 | * Return -1 if there are no events pending. 99 | */ 100 | int 101 | timer_nextTimer() 102 | { 103 | if (Q) { 104 | if (Q->time < 0) { 105 | logit(LOG_WARNING, 0, "timer_nextTimer top of queue says %d", Q->time); 106 | return 0; 107 | } 108 | 109 | return Q->time; 110 | } 111 | 112 | return -1; 113 | } 114 | 115 | /* 116 | * sets the timer 117 | */ 118 | int 119 | timer_setTimer(delay, action, data) 120 | int delay; /* number of units for timeout */ 121 | cfunc_t action; /* function to be called on timeout */ 122 | void *data; /* what to call the timeout function with */ 123 | { 124 | struct timeout_q *ptr, *node, *prev; 125 | 126 | #ifdef CALLOUT_DEBUG 127 | IF_DEBUG(DEBUG_TIMEOUT) 128 | logit(LOG_DEBUG, 0, "setting timer:"); 129 | print_Q(); 130 | #endif 131 | 132 | /* create a node */ 133 | node = calloc(1, sizeof(struct timeout_q)); 134 | if (!node) { 135 | logit(LOG_WARNING, 0, "Failed allocating memory in timer_settimer()\n"); 136 | return -1; 137 | } 138 | 139 | node->func = action; 140 | node->data = data; 141 | node->time = delay; 142 | node->next = 0; 143 | node->id = ++id; 144 | 145 | prev = ptr = Q; 146 | 147 | /* insert node in the queue */ 148 | 149 | /* if the queue is empty, insert the node and return */ 150 | if (!Q) 151 | Q = node; 152 | else { 153 | /* chase the pointer looking for the right place */ 154 | while (ptr) { 155 | 156 | if (delay < ptr->time) { 157 | /* right place */ 158 | 159 | node->next = ptr; 160 | if (ptr == Q) 161 | Q = node; 162 | else 163 | prev->next = node; 164 | ptr->time -= node->time; 165 | return node->id; 166 | } 167 | 168 | /* keep moving */ 169 | delay -= ptr->time; 170 | node->time = delay; 171 | prev = ptr; 172 | ptr = ptr->next; 173 | } 174 | 175 | prev->next = node; 176 | } 177 | 178 | return node->id; 179 | } 180 | 181 | /* returns the time until the timer is scheduled */ 182 | int 183 | timer_leftTimer(timer_id) 184 | int timer_id; 185 | { 186 | struct timeout_q *ptr; 187 | int left = 0; 188 | 189 | if (!timer_id) 190 | return -1; 191 | 192 | for (ptr = Q; ptr; ptr = ptr->next) { 193 | left += ptr->time; 194 | if (ptr->id == timer_id) 195 | return left; 196 | } 197 | return -1; 198 | } 199 | 200 | /* clears the associated timer */ 201 | void 202 | timer_clearTimer(timer_id) 203 | int timer_id; 204 | { 205 | struct timeout_q *ptr, *prev; 206 | 207 | if (!timer_id) 208 | return; 209 | 210 | prev = ptr = Q; 211 | 212 | /* 213 | * find the right node, delete it. the subsequent node's time 214 | * gets bumped up 215 | */ 216 | 217 | while (ptr) { 218 | if (ptr->id == timer_id) { 219 | /* got the right node */ 220 | 221 | /* unlink it from the queue */ 222 | if (ptr == Q) 223 | Q = Q->next; 224 | else 225 | prev->next = ptr->next; 226 | 227 | /* increment next node if any */ 228 | if (ptr->next != 0) 229 | (ptr->next)->time += ptr->time; 230 | 231 | if (ptr->data) 232 | free(ptr->data); 233 | free(ptr); 234 | return; 235 | } 236 | prev = ptr; 237 | ptr = ptr->next; 238 | } 239 | } 240 | 241 | #ifdef CALLOUT_DEBUG 242 | /* 243 | * debugging utility 244 | */ 245 | static void 246 | print_Q() 247 | { 248 | struct timeout_q *ptr; 249 | 250 | IF_DEBUG(DEBUG_TIMEOUT) 251 | for (ptr = Q; ptr; ptr = ptr->next) 252 | logit(LOG_DEBUG, 0, "(%d,%d) ", ptr->id, ptr->time); 253 | } 254 | #endif /* CALLOUT_DEBUG */ 255 | -------------------------------------------------------------------------------- /src/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1998 by the University of Southern California. 3 | * All rights reserved. 4 | * 5 | * Permission to use, copy, modify, and distribute this software and 6 | * its documentation in source and binary forms for lawful 7 | * purposes and without fee is hereby granted, provided 8 | * that the above copyright notice appear in all copies and that both 9 | * the copyright notice and this permission notice appear in supporting 10 | * documentation, and that any documentation, advertising materials, 11 | * and other materials related to such distribution and use acknowledge 12 | * that the software was developed by the University of Southern 13 | * California and/or Information Sciences Institute. 14 | * The name of the University of Southern California may not 15 | * be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THE UNIVERSITY OF SOUTHERN CALIFORNIA DOES NOT MAKE ANY REPRESENTATIONS 19 | * ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. THIS SOFTWARE IS 20 | * PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND 23 | * NON-INFRINGEMENT. 24 | * 25 | * IN NO EVENT SHALL USC, OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY 26 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, WHETHER IN CONTRACT, 27 | * TORT, OR OTHER FORM OF ACTION, ARISING OUT OF OR IN CONNECTION WITH, 28 | * THE USE OR PERFORMANCE OF THIS SOFTWARE. 29 | * 30 | * Other copyrights might apply to parts of this software and are so 31 | * noted when applicable. 32 | */ 33 | /* 34 | * Questions concerning this software should be directed to 35 | * Pavlin Ivanov Radoslavov (pavlin@catarina.usc.edu) 36 | * 37 | * $Id: debug.h,v 1.4 1998/05/29 21:58:22 kurtw Exp $ 38 | */ 39 | /* 40 | * Part of this program has been derived from mrouted. 41 | * The mrouted program is covered by the license in the accompanying file 42 | * named "LICENSE.mrouted". 43 | * 44 | * The mrouted program is COPYRIGHT 1989 by The Board of Trustees of 45 | * Leland Stanford Junior University. 46 | * 47 | */ 48 | 49 | extern unsigned long debug; 50 | extern int log_nmsgs; 51 | #define IF_DEBUG(l) if (debug && debug & (l)) 52 | 53 | #define LOG_MAX_MSGS 20 /* if > 20/minute then shut up for a while */ 54 | #define LOG_SHUT_UP 600 /* shut up for 10 minutes */ 55 | 56 | 57 | /* Debug values definition */ 58 | /* DVMRP reserved for future use */ 59 | #define DEBUG_DVMRP_PRUNE 0x00000001 60 | #define DEBUG_DVMRP_ROUTE 0x00000002 61 | #define DEBUG_DVMRP_PEER 0x00000004 62 | #define DEBUG_DVMRP_TIMER 0x00000008 63 | #define DEBUG_DVMRP_DETAIL 0x01000000 64 | #define DEBUG_DVMRP ( DEBUG_DVMRP_PRUNE | DEBUG_DVMRP_ROUTE | \ 65 | DEBUG_DVMRP_PEER ) 66 | 67 | /* IGMP related */ 68 | #define DEBUG_IGMP_PROTO 0x00000010 69 | #define DEBUG_IGMP_TIMER 0x00000020 70 | #define DEBUG_IGMP_MEMBER 0x00000040 71 | #define DEBUG_MEMBER DEBUG_IGMP_MEMBER 72 | #define DEBUG_IGMP ( DEBUG_IGMP_PROTO | DEBUG_IGMP_TIMER | \ 73 | DEBUG_IGMP_MEMBER ) 74 | 75 | /* Misc */ 76 | #define DEBUG_TRACE 0x00000080 77 | #define DEBUG_TIMEOUT 0x00000100 78 | #define DEBUG_PKT 0x00000200 79 | 80 | 81 | /* Kernel related */ 82 | #define DEBUG_IF 0x00000400 83 | #define DEBUG_KERN 0x00000800 84 | #define DEBUG_MFC 0x00001000 85 | #define DEBUG_RSRR 0x00002000 86 | 87 | /* PIM related */ 88 | #define DEBUG_PIM_GRAFT 0x02000000 89 | #define DEBUG_PIM_HELLO 0x00004000 90 | #define DEBUG_PIM_REGISTER 0x00008000 91 | #define DEBUG_PIM_JOIN_PRUNE 0x00010000 92 | #define DEBUG_PIM_BOOTSTRAP 0x00020000 93 | #define DEBUG_PIM_ASSERT 0x00040000 94 | #define DEBUG_PIM_CAND_RP 0x00080000 95 | #define DEBUG_PIM_MRT 0x00100000 96 | #define DEBUG_PIM_TIMER 0x00200000 97 | #define DEBUG_PIM_RPF 0x00400000 98 | #define DEBUG_RPF DEBUG_PIM_RPF 99 | #define DEBUG_PIM_DETAIL 0x00800000 100 | #define DEBUG_PIM ( DEBUG_PIM_HELLO | DEBUG_PIM_REGISTER | \ 101 | DEBUG_PIM_JOIN_PRUNE | DEBUG_PIM_BOOTSTRAP | \ 102 | DEBUG_PIM_ASSERT | DEBUG_PIM_CAND_RP | \ 103 | DEBUG_PIM_MRT | DEBUG_PIM_TIMER | \ 104 | DEBUG_PIM_RPF | DEBUG_PIM_GRAFT ) 105 | 106 | #define DEBUG_MRT ( DEBUG_DVMRP_ROUTE | DEBUG_PIM_MRT ) 107 | #define DEBUG_NEIGHBORS ( DEBUG_DVMRP_PEER | DEBUG_PIM_HELLO ) 108 | #define DEBUG_TIMER ( DEBUG_IGMP_TIMER | DEBUG_DVMRP_TIMER | \ 109 | DEBUG_PIM_TIMER ) 110 | #define DEBUG_ASSERT ( DEBUG_PIM_ASSERT ) 111 | #define DEBUG_PARSE_FAIL 0x80000000 112 | #define DEBUG_ALL 0xffffffff 113 | 114 | extern void dump_vifs (FILE *fp, int detail); 115 | extern void dump_pim_mrt (FILE *fp, int detail); 116 | 117 | extern int debug_list (int mask, char *buf, size_t len); 118 | extern int debug_parse (char *arg); 119 | 120 | extern int log_str2lvl (char *level); 121 | extern const char *log_lvl2str (int val); 122 | extern int log_list (char *buf, size_t len); 123 | -------------------------------------------------------------------------------- /src/dvmrp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The mrouted program is covered by the license in the accompanying file 3 | * named "LICENSE.mrouted". Use of the mrouted program represents acceptance of 4 | * the terms and conditions listed in that file. 5 | * 6 | * The mrouted program is COPYRIGHT 1989 by The Board of Trustees of 7 | * Leland Stanford Junior University. 8 | * 9 | * 10 | * dvmrp.h,v 3.8.4.3 1997/03/14 00:28:47 fenner Exp 11 | */ 12 | 13 | /* 14 | * A DVMRP message consists of an IP header + an IGMP header + (for some types) 15 | * zero or more bytes of data. 16 | * 17 | * For REPORT messages, the data is route information; the route information 18 | * consists of one or more lists of the following form: 19 | * 20 | * (mask, (origin, metric), (origin, metric), ...) 21 | * 22 | * where: 23 | * 24 | * "mask" is the subnet mask for all the origins in the list. 25 | * It is always THREE bytes long, containing the low-order 26 | * three bytes of the mask (the high-order byte is always 27 | * 0xff and therefore need not be transmitted). 28 | * 29 | * "origin" is the number of a subnet from which multicast datagrams 30 | * may originate. It is from one to four bytes long, 31 | * depending on the value of "mask": 32 | * if all bytes of the mask are zero 33 | * the subnet number is one byte long 34 | * else if the low-order two bytes of the mask are zero 35 | * the subnet number is two bytes long 36 | * else if the lowest-order byte of the mask is zero 37 | * the subnet number is three bytes long, 38 | * else 39 | * the subnet number is four bytes long. 40 | * 41 | * "metric" is a one-byte value consisting of two subfields: 42 | * - the high-order bit is a flag which, when set, indicates 43 | * the last (origin, metric) pair of a list. 44 | * - the low-order seven bits contain the routing metric for 45 | * the corresponding origin, relative to the sender of the 46 | * DVMRP report. The metric may have the value of UNREACHABLE 47 | * added to it as a "split horizon" indication (so called 48 | * "poisoned reverse"). 49 | * 50 | * Within a list, the origin subnet numbers must be in ascending order, and 51 | * the lists themselves are in order of increasing mask value. A message may 52 | * not exceed 576 bytes, the default maximum IP reassembly size, including 53 | * the IP and IGMP headers; the route information may be split across more 54 | * than one message if necessary, by terminating a list in one message and 55 | * starting a new list in the next message (repeating the same mask value, 56 | * if necessary). 57 | * 58 | * For NEIGHBORS messages, the data is neighboring-router information 59 | * consisting of one or more lists of the following form: 60 | * 61 | * (local-addr, metric, threshold, ncount, neighbor, neighbor, ...) 62 | * 63 | * where: 64 | * 65 | * "local-addr" is the sending router's address as seen by the neighbors 66 | * in this list; it is always four bytes long. 67 | * "metric" is a one-byte unsigned value, the TTL `cost' of forwarding 68 | * packets to any of the neighbors on this list. 69 | * "threshold" is a one-byte unsigned value, a lower bound on the TTL a 70 | * packet must have to be forwarded to any of the neighbors on 71 | * this list. 72 | * "ncount" is the number of neighbors in this list. 73 | * "neighbor" is the address of a neighboring router, four bytes long. 74 | * 75 | * As with REPORT messages, NEIGHBORS messages should not exceed 576 bytes, 76 | * including the IP and IGMP headers; split longer messages by terminating the 77 | * list in one and continuing in another, repeating the local-addr, etc., if 78 | * necessary. 79 | * 80 | * For NEIGHBORS2 messages, the data is identical to NEIGHBORS except 81 | * there is a flags byte before the neighbor count: 82 | * 83 | * (local-addr, metric, threshold, flags, ncount, neighbor, neighbor, ...) 84 | */ 85 | 86 | /* 87 | * DVMRP message types (carried in the "code" field of an IGMP header) 88 | */ 89 | #define DVMRP_PROBE 1 /* for finding neighbors */ 90 | #define DVMRP_REPORT 2 /* for reporting some or all routes */ 91 | #define DVMRP_ASK_NEIGHBORS 3 /* sent by mapper, asking for a list */ 92 | /* of this router's neighbors. */ 93 | #define DVMRP_NEIGHBORS 4 /* response to such a request */ 94 | #define DVMRP_ASK_NEIGHBORS2 5 /* as above, want new format reply */ 95 | #define DVMRP_NEIGHBORS2 6 96 | #define DVMRP_PRUNE 7 /* prune message */ 97 | #define DVMRP_GRAFT 8 /* graft message */ 98 | #define DVMRP_GRAFT_ACK 9 /* graft acknowledgement */ 99 | #define DVMRP_INFO_REQUEST 10 /* information request */ 100 | #define DVMRP_INFO_REPLY 11 /* information reply */ 101 | 102 | /* 103 | * 'flags' byte values in DVMRP_NEIGHBORS2 reply. 104 | */ 105 | #define DVMRP_NF_TUNNEL 0x01 /* neighbors reached via tunnel */ 106 | #define DVMRP_NF_SRCRT 0x02 /* tunnel uses IP source routing */ 107 | #define DVMRP_NF_PIM 0x04 /* neighbor is a PIM neighbor */ 108 | #define DVMRP_NF_DOWN 0x10 /* kernel state of interface */ 109 | #define DVMRP_NF_DISABLED 0x20 /* administratively disabled */ 110 | #define DVMRP_NF_QUERIER 0x40 /* I am the subnet's querier */ 111 | #define DVMRP_NF_LEAF 0x80 /* Neighbor reports that it is a leaf */ 112 | 113 | /* 114 | * Request/reply types for info queries/replies 115 | */ 116 | #define DVMRP_INFO_VERSION 1 /* version string */ 117 | #define DVMRP_INFO_NEIGHBORS 2 /* neighbors2 data */ 118 | 119 | /* 120 | * Limit on length of route data 121 | */ 122 | /* TODO: now in defs.h 123 | #define MAX_IP_PACKET_LEN 576 124 | #define MIN_IP_HEADER_LEN 20 125 | #define MAX_IP_HEADER_LEN 60 126 | */ 127 | #define MAX_DVMRP_DATA_LEN \ 128 | ( MAX_IP_PACKET_LEN - MAX_IP_HEADER_LEN - IGMP_MINLEN ) 129 | 130 | /* 131 | * Various protocol constants (all times in seconds) 132 | */ 133 | /* address for multicast DVMRP msgs */ 134 | #define INADDR_DVMRP_GROUP (u_int32)0xe0000004 /* 224.0.0.4 */ 135 | 136 | #define DVMRP_ROUTE_MAX_REPORT_DELAY 5 /* max delay for reporting changes */ 137 | /* (This is the timer interrupt */ 138 | /* interval; all times must be */ 139 | /* multiples of this value.) */ 140 | 141 | #define DVMRP_ROUTE_REPORT_INTERVAL 60 /* periodic route report interval */ 142 | #define DVMRP_ROUTE_SWITCH_TIME 140 /* time to switch to equivalent gw */ 143 | #define DVMRP_ROUTE_EXPIRE_TIME 200 /* time to mark route invalid */ 144 | #define DVMRP_ROUTE_DISCARD_TIME 340 /* time to garbage collect route */ 145 | #define DVMRP_LEAF_CONFIRMATION_TIME 200 /* time to consider subnet a leaf */ 146 | #define DVMRP_NEIGHBOR_PROBE_INTERVAL 10 /* periodic neighbor probe interval */ 147 | #define DVMRP_NEIGHBOR_EXPIRE_TIME 30 /* time to consider neighbor gone */ 148 | #define DVMRP_OLD_NEIGHBOR_EXPIRE_TIME 140 /* time to consider neighbor gone */ 149 | #define DVMRP_UNREACHABLE 32 /* "infinity" metric, must be <= 64 */ 150 | 151 | /* TODO: remove the DVMRP prefix and merge it with the PIM code? */ 152 | #define DVMRP_MAX_RATE_LIMIT 100000 /* max rate limit */ 153 | #define DVMRP_DEFAULT_PHY_RATE_LIMIT 0 /* default phyint rate limit */ 154 | #define DVMRP_DEFAULT_TUN_RATE_LIMIT 500 /* default tunnel rate limit */ 155 | 156 | #define DVMRP_DEFAULT_CACHE_LIFETIME 300 /* kernel route entry discard time */ 157 | #define DVMRP_MIN_CACHE_LIFETIME 60 /* minimum allowed cache lifetime */ 158 | #define DVMRP_AVERAGE_PRUNE_LIFETIME 7200 /* average lifetime of prunes sent */ 159 | #define DVMRP_MIN_PRUNE_LIFETIME 120 /* minimum allowed prune lifetime */ 160 | #define DVMRP_GRAFT_TIMEOUT_VAL 5 /* retransmission time for grafts */ 161 | #define DVMRP_PRUNE_REXMIT_VAL 3 /* initial time for prune rexmission*/ 162 | 163 | #define DVMRP_OLD_AGE_THRESHOLD 2 /* # of query intervals to remember */ 164 | /* presence of IGMPv1 member */ 165 | /* XXX NOTE that this technically */ 166 | /* violates IGMPv2 draft as the */ 167 | /* timer is 5 seconds too short */ 168 | -------------------------------------------------------------------------------- /src/dvmrp_proto.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1998 by the University of Southern California. 3 | * All rights reserved. 4 | * 5 | * Permission to use, copy, modify, and distribute this software and 6 | * its documentation in source and binary forms for lawful 7 | * purposes and without fee is hereby granted, provided 8 | * that the above copyright notice appear in all copies and that both 9 | * the copyright notice and this permission notice appear in supporting 10 | * documentation, and that any documentation, advertising materials, 11 | * and other materials related to such distribution and use acknowledge 12 | * that the software was developed by the University of Southern 13 | * California and/or Information Sciences Institute. 14 | * The name of the University of Southern California may not 15 | * be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THE UNIVERSITY OF SOUTHERN CALIFORNIA DOES NOT MAKE ANY REPRESENTATIONS 19 | * ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. THIS SOFTWARE IS 20 | * PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND 23 | * NON-INFRINGEMENT. 24 | * 25 | * IN NO EVENT SHALL USC, OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY 26 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, WHETHER IN CONTRACT, 27 | * TORT, OR OTHER FORM OF ACTION, ARISING OUT OF OR IN CONNECTION WITH, 28 | * THE USE OR PERFORMANCE OF THIS SOFTWARE. 29 | * 30 | * Other copyrights might apply to parts of this software and are so 31 | * noted when applicable. 32 | */ 33 | /* 34 | * Questions concerning this software should be directed to 35 | * Pavlin Ivanov Radoslavov (pavlin@catarina.usc.edu) 36 | * 37 | * $Id: dvmrp_proto.c,v 1.1.1.1 1998/05/11 17:39:34 kurtw Exp $ 38 | */ 39 | 40 | #include "defs.h" 41 | 42 | 43 | /* TODO */ 44 | /* 45 | * Process an incoming neighbor probe message. 46 | */ 47 | void 48 | dvmrp_accept_probe(src, dst, p, datalen, level) 49 | u_int32 src; 50 | u_int32 dst; 51 | char *p; 52 | int datalen; 53 | u_int32 level; 54 | { 55 | return; 56 | } 57 | 58 | 59 | /* TODO */ 60 | /* 61 | * Process an incoming route report message. 62 | */ 63 | void 64 | dvmrp_accept_report(src, dst, p, datalen, level) 65 | u_int32 src; 66 | u_int32 dst; 67 | char *p; 68 | int datalen; 69 | u_int32 level; 70 | { 71 | return; 72 | } 73 | 74 | 75 | /* TODO */ 76 | void 77 | dvmrp_accept_info_request(src, dst, p, datalen) 78 | u_int32 src; 79 | u_int32 dst; 80 | u_char *p; 81 | int datalen; 82 | { 83 | return; 84 | } 85 | 86 | 87 | /* 88 | * Process an incoming info reply message. 89 | */ 90 | void 91 | dvmrp_accept_info_reply(src, dst, p, datalen) 92 | u_int32 src; 93 | u_int32 dst; 94 | u_char *p; 95 | int datalen; 96 | { 97 | IF_DEBUG(DEBUG_PKT) 98 | logit(LOG_DEBUG, 0, "ignoring spurious DVMRP info reply from %s to %s", 99 | inet_fmt(src, s1), inet_fmt(dst, s2)); 100 | } 101 | 102 | 103 | /* 104 | * Process an incoming neighbor-list message. 105 | */ 106 | void 107 | dvmrp_accept_neighbors(src, dst, p, datalen, level) 108 | u_int32 src; 109 | u_int32 dst; 110 | u_char *p; 111 | int datalen; 112 | u_int32 level; 113 | { 114 | logit(LOG_INFO, 0, "ignoring spurious DVMRP neighbor list from %s to %s", 115 | inet_fmt(src, s1), inet_fmt(dst, s2)); 116 | } 117 | 118 | 119 | /* 120 | * Process an incoming neighbor-list message. 121 | */ 122 | void 123 | dvmrp_accept_neighbors2(src, dst, p, datalen, level) 124 | u_int32 src; 125 | u_int32 dst; 126 | u_char *p; 127 | int datalen; 128 | u_int32 level; 129 | { 130 | IF_DEBUG(DEBUG_PKT) 131 | logit(LOG_DEBUG, 0, 132 | "ignoring spurious DVMRP neighbor list2 from %s to %s", 133 | inet_fmt(src, s1), inet_fmt(dst, s2)); 134 | } 135 | 136 | 137 | /* TODO */ 138 | /* 139 | * Takes the prune message received and then strips it to 140 | * determine the (src, grp) pair to be pruned. 141 | * 142 | * Adds the router to the (src, grp) entry then. 143 | * 144 | * Determines if further packets have to be sent down that vif 145 | * 146 | * Determines if a corresponding prune message has to be generated 147 | */ 148 | void 149 | dvmrp_accept_prune(src, dst, p, datalen) 150 | u_int32 src; 151 | u_int32 dst; 152 | char *p; 153 | int datalen; 154 | { 155 | return; 156 | } 157 | 158 | 159 | /* TODO */ 160 | /* determine the multicast group and src 161 | * 162 | * if it does, then determine if a prune was sent 163 | * upstream. 164 | * if prune sent upstream, send graft upstream and send 165 | * ack downstream. 166 | * 167 | * if no prune sent upstream, change the forwarding bit 168 | * for this interface and send ack downstream. 169 | * 170 | * if no entry exists for this group send ack downstream. 171 | */ 172 | void 173 | dvmrp_accept_graft(src, dst, p, datalen) 174 | u_int32 src; 175 | u_int32 dst; 176 | char *p; 177 | int datalen; 178 | { 179 | return; 180 | } 181 | 182 | 183 | /* TODO */ 184 | /* 185 | * find out which group is involved first of all 186 | * then determine if a graft was sent. 187 | * if no graft sent, ignore the message 188 | * if graft was sent and the ack is from the right 189 | * source, remove the graft timer so that we don't 190 | * have send a graft again 191 | */ 192 | void 193 | dvmrp_accept_g_ack(src, dst, p, datalen) 194 | u_int32 src; 195 | u_int32 dst; 196 | char *p; 197 | int datalen; 198 | { 199 | return; 200 | } 201 | -------------------------------------------------------------------------------- /src/igmpv2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The mrouted program is covered by the license in the accompanying file 3 | * named "LICENSE". Use of the mrouted program represents acceptance of 4 | * the terms and conditions listed in that file. 5 | * 6 | * The mrouted program is COPYRIGHT 1989 by The Board of Trustees of 7 | * Leland Stanford Junior University. 8 | * 9 | * 10 | * igmpv2.h,v 3.8 1997/05/01 23:10:31 fenner Exp 11 | */ 12 | 13 | /* 14 | * Constants for IGMP Version 2. Several of these, especially the 15 | * robustness variable, should be variables and not constants. 16 | */ 17 | #define IGMP_ROBUSTNESS_VARIABLE 2 18 | #define IGMP_QUERY_INTERVAL 125 19 | #define IGMP_QUERY_RESPONSE_INTERVAL 10 20 | #define IGMP_GROUP_MEMBERSHIP_INTERVAL (IGMP_ROBUSTNESS_VARIABLE * \ 21 | IGMP_QUERY_INTERVAL + \ 22 | IGMP_QUERY_RESPONSE_INTERVAL) 23 | #define IGMP_OTHER_QUERIER_PRESENT_INTERVAL (IGMP_ROBUSTNESS_VARIABLE * \ 24 | IGMP_QUERY_INTERVAL + \ 25 | IGMP_QUERY_RESPONSE_INTERVAL / 2) 26 | #define IGMP_STARTUP_QUERY_INTERVAL 30 27 | #define IGMP_STARTUP_QUERY_COUNT IGMP_ROBUSTNESS_VARIABLE 28 | #define IGMP_LAST_MEMBER_QUERY_INTERVAL 1 29 | #define IGMP_LAST_MEMBER_QUERY_COUNT IGMP_ROBUSTNESS_VARIABLE 30 | -------------------------------------------------------------------------------- /src/igmpv3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1998-2001 3 | * University of Southern California/Information Sciences Institute. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. Neither the name of the project nor the names of its contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef PIMD_IGMPV3_H_ 32 | #define PIMD_IGMPV3_H_ 33 | 34 | /* 35 | * IGMPv3 report modes. 36 | */ 37 | #ifndef IGMP_MODE_IS_INCLUDE 38 | #define IGMP_DO_NOTHING 0 /* don't send a record */ 39 | #define IGMP_MODE_IS_INCLUDE 1 /* MODE_IN */ 40 | #define IGMP_MODE_IS_EXCLUDE 2 /* MODE_EX */ 41 | #define IGMP_CHANGE_TO_INCLUDE_MODE 3 /* TO_IN */ 42 | #define IGMP_CHANGE_TO_EXCLUDE_MODE 4 /* TO_EX */ 43 | #define IGMP_ALLOW_NEW_SOURCES 5 /* ALLOW_NEW */ 44 | #define IGMP_BLOCK_OLD_SOURCES 6 /* BLOCK_OLD */ 45 | #endif 46 | 47 | struct igmpv3_query { 48 | uint8_t type; 49 | uint8_t code; 50 | uint16_t csum; 51 | uint32_t group; 52 | #if defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN) 53 | uint8_t qrv:3, 54 | suppress:1, 55 | resv:4; 56 | #else 57 | uint8_t resv:4, 58 | suppress:1, 59 | qrv:3; 60 | #endif 61 | uint8_t qqic; 62 | uint16_t nsrcs; 63 | uint32_t srcs[0]; 64 | }; 65 | 66 | struct igmpv3_grec { 67 | uint8_t grec_type; 68 | uint8_t grec_auxwords; 69 | uint16_t grec_nsrcs; 70 | uint32_t grec_mca; 71 | uint32_t grec_src[0]; 72 | }; 73 | 74 | #define IGMP_GRPREC_HDRLEN 8 75 | #define IGMP_V3_GROUP_RECORD_MIN_SIZE 8 76 | 77 | struct igmpv3_report { 78 | uint8_t type; 79 | uint8_t resv1; 80 | uint16_t csum; 81 | uint16_t resv2; 82 | uint16_t ngrec; 83 | struct igmpv3_grec grec[0]; 84 | }; 85 | 86 | #ifndef IGMP_V3_REPORT_MINLEN 87 | #define IGMP_V3_REPORT_MINLEN 8 88 | #define IGMP_V3_REPORT_MAXRECS 65535 89 | #endif 90 | 91 | #endif /* PIMD_IGMPV3_H_ */ 92 | 93 | /** 94 | * Local Variables: 95 | * indent-tabs-mode: t 96 | * c-file-style: "ellemtel" 97 | * c-basic-offset: 4 98 | * End: 99 | */ 100 | -------------------------------------------------------------------------------- /src/inet.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The mrouted program is covered by the license in the accompanying file 3 | * named "LICENSE.mrouted". Use of the mrouted program represents acceptance of 4 | * the terms and conditions listed in that file. 5 | * 6 | * The mrouted program is COPYRIGHT 1989 by The Board of Trustees of 7 | * Leland Stanford Junior University. 8 | * 9 | * 10 | * inet.c,v 3.8.4.1 1997/01/29 19:49:33 fenner Exp 11 | */ 12 | #define C(x) ((x) & 0xff) 13 | 14 | #include "defs.h" 15 | 16 | 17 | /* 18 | * Exported variables. 19 | */ 20 | char s1[19]; /* buffers to hold the string representations */ 21 | char s2[19]; /* of IP addresses, to be passed to inet_fmt() */ 22 | char s3[19]; 23 | char s4[19]; 24 | 25 | 26 | /* 27 | * Verify that a given IP address is credible as a host address. 28 | * (Without a mask, cannot detect addresses of the form {subnet,0} or 29 | * {subnet,-1}.) 30 | */ 31 | int 32 | inet_valid_host(naddr) 33 | u_int32 naddr; 34 | { 35 | u_int32 addr; 36 | 37 | addr = ntohl(naddr); 38 | 39 | return (!(IN_MULTICAST(addr) || 40 | IN_BADCLASS (addr) || 41 | (addr & 0xff000000) == 0)); 42 | } 43 | 44 | /* 45 | * Verify that a given netmask is plausible; 46 | * make sure that it is a series of 1's followed by 47 | * a series of 0's with no discontiguous 1's. 48 | */ 49 | int 50 | inet_valid_mask(mask) 51 | u_int32 mask; 52 | { 53 | if (~(((mask & -mask) - 1) | mask) != 0) { 54 | /* Mask is not contiguous */ 55 | return FALSE; 56 | } 57 | 58 | return TRUE; 59 | } 60 | 61 | /* 62 | * Verify that a given subnet number and mask pair are credible. 63 | * 64 | * With CIDR, almost any subnet and mask are credible. mrouted still 65 | * can't handle aggregated class A's, so we still check that, but 66 | * otherwise the only requirements are that the subnet address is 67 | * within the [ABC] range and that the host bits of the subnet 68 | * are all 0. 69 | */ 70 | int 71 | inet_valid_subnet(nsubnet, nmask) 72 | u_int32 nsubnet, nmask; 73 | { 74 | u_int32 subnet, mask; 75 | 76 | subnet = ntohl(nsubnet); 77 | mask = ntohl(nmask); 78 | 79 | if ((subnet & mask) != subnet) 80 | return FALSE; 81 | 82 | if (subnet == 0) 83 | return (mask == 0); 84 | 85 | if (IN_CLASSA(subnet)) { 86 | if (mask < 0xff000000 || 87 | (subnet & 0xff000000) == 0x7f000000 || 88 | (subnet & 0xff000000) == 0x00000000) return FALSE; 89 | } 90 | else if (IN_CLASSD(subnet) || IN_BADCLASS(subnet)) { 91 | /* Above Class C address space */ 92 | return FALSE; 93 | } 94 | if (subnet & ~mask) { 95 | /* Host bits are set in the subnet */ 96 | return FALSE; 97 | } 98 | if (!inet_valid_mask(mask)) { 99 | /* Netmask is not contiguous */ 100 | return FALSE; 101 | } 102 | 103 | return TRUE; 104 | } 105 | 106 | 107 | /* 108 | * Convert an IP address in u_int32 (network) format into a printable string. 109 | */ 110 | char * 111 | inet_fmt(addr, s) 112 | u_int32 addr; 113 | char *s; 114 | { 115 | u_char *a; 116 | 117 | a = (u_char *)&addr; 118 | sprintf(s, "%u.%u.%u.%u", a[0], a[1], a[2], a[3]); 119 | return (s); 120 | } 121 | 122 | 123 | /* 124 | * Convert an IP subnet number in u_int32 (network) format into a printable 125 | * string including the netmask as a number of bits. 126 | */ 127 | #ifdef NOSUCHDEF /* replaced by netname() */ 128 | char * 129 | inet_fmts(addr, mask, s) 130 | u_int32 addr, mask; 131 | char *s; 132 | { 133 | u_char *a, *m; 134 | int bits; 135 | 136 | if ((addr == 0) && (mask == 0)) { 137 | sprintf(s, "default"); 138 | return (s); 139 | } 140 | a = (u_char *)&addr; 141 | m = (u_char *)&mask; 142 | bits = 33 - ffs(ntohl(mask)); 143 | 144 | if (m[3] != 0) sprintf(s, "%u.%u.%u.%u/%d", a[0], a[1], a[2], a[3], 145 | bits); 146 | else if (m[2] != 0) sprintf(s, "%u.%u.%u/%d", a[0], a[1], a[2], bits); 147 | else if (m[1] != 0) sprintf(s, "%u.%u/%d", a[0], a[1], bits); 148 | else sprintf(s, "%u/%d", a[0], bits); 149 | 150 | return (s); 151 | } 152 | #endif /* NOSUCHDEF */ 153 | 154 | /* 155 | * Convert the printable string representation of an IP address into the 156 | * u_int32 (network) format. Return 0xffffffff on error. (To detect the 157 | * legal address with that value, you must explicitly compare the string 158 | * with "255.255.255.255".) 159 | * The return value is in network order. 160 | */ 161 | u_int32 162 | inet_parse(s, n) 163 | char *s; 164 | int n; 165 | { 166 | u_int32 a = 0; 167 | u_int a0 = 0, a1 = 0, a2 = 0, a3 = 0; 168 | int i; 169 | char c; 170 | 171 | i = sscanf(s, "%u.%u.%u.%u%c", &a0, &a1, &a2, &a3, &c); 172 | if (i < n || i > 4 || a0 > 255 || a1 > 255 || a2 > 255 || a3 > 255) 173 | return (0xffffffff); 174 | 175 | ((u_char *)&a)[0] = a0; 176 | ((u_char *)&a)[1] = a1; 177 | ((u_char *)&a)[2] = a2; 178 | ((u_char *)&a)[3] = a3; 179 | 180 | return (a); 181 | } 182 | 183 | 184 | /* 185 | * inet_cksum extracted from: 186 | * P I N G . C 187 | * 188 | * Author - 189 | * Mike Muuss 190 | * U. S. Army Ballistic Research Laboratory 191 | * December, 1983 192 | * Modified at Uc Berkeley 193 | * 194 | * (ping.c) Status - 195 | * Public Domain. Distribution Unlimited. 196 | * 197 | * I N _ C K S U M 198 | * 199 | * Checksum routine for Internet Protocol family headers (C Version) 200 | * 201 | */ 202 | int 203 | inet_cksum(addr, len) 204 | u_int16 *addr; 205 | u_int len; 206 | { 207 | int nleft = (int)len; 208 | u_int16 *w = addr; 209 | u_int16 answer = 0; 210 | int sum = 0; 211 | 212 | /* 213 | * Our algorithm is simple, using a 32 bit accumulator (sum), 214 | * we add sequential 16 bit words to it, and at the end, fold 215 | * back all the carry bits from the top 16 bits into the lower 216 | * 16 bits. 217 | */ 218 | while (nleft > 1) { 219 | sum += *w++; 220 | nleft -= 2; 221 | } 222 | 223 | /* mop up an odd byte, if necessary */ 224 | if (nleft == 1) { 225 | *(u_char *) (&answer) = *(u_char *)w ; 226 | sum += answer; 227 | } 228 | 229 | /* 230 | * add back carry outs from top 16 bits to low 16 bits 231 | */ 232 | sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */ 233 | sum += (sum >> 16); /* add carry */ 234 | answer = ~sum; /* truncate to 16 bits */ 235 | return (answer); 236 | } 237 | 238 | /* 239 | * Called by following netname() to create a mask specified network address. 240 | */ 241 | void 242 | trimdomain(cp) 243 | char *cp; 244 | { 245 | static char domain[MAXHOSTNAMELEN + 1]; 246 | static int first = 1; 247 | char *s; 248 | 249 | if (first) { 250 | first = 0; 251 | if (gethostname(domain, MAXHOSTNAMELEN) == 0 && (s = strchr(domain, '.'))) 252 | strlcpy(domain, s + 1, sizeof(domain)); 253 | else 254 | domain[0] = 0; 255 | } 256 | 257 | if (domain[0]) { 258 | while ((cp = strchr(cp, '.'))) { 259 | if (!strcasecmp(cp + 1, domain)) { 260 | *cp = 0; /* hit it */ 261 | break; 262 | } else { 263 | cp++; 264 | } 265 | } 266 | } 267 | } 268 | 269 | static u_long 270 | forgemask(a) 271 | u_long a; 272 | { 273 | u_long m; 274 | 275 | if (IN_CLASSA(a)) 276 | m = IN_CLASSA_NET; 277 | else if (IN_CLASSB(a)) 278 | m = IN_CLASSB_NET; 279 | else 280 | m = IN_CLASSC_NET; 281 | return (m); 282 | } 283 | 284 | static void 285 | domask(dst, addr, mask) 286 | char *dst; 287 | u_long addr, mask; 288 | { 289 | int b, i; 290 | 291 | if (!mask || (forgemask(addr) == mask)) { 292 | *dst = '\0'; 293 | return; 294 | } 295 | i = 0; 296 | for (b = 0; b < 32; b++) 297 | if (mask & (1 << b)) { 298 | int bb; 299 | 300 | i = b; 301 | for (bb = b+1; bb < 32; bb++) 302 | if (!(mask & (1 << bb))) { 303 | i = -1; /* noncontig */ 304 | break; 305 | } 306 | break; 307 | } 308 | if (i == -1) 309 | sprintf(dst, "&0x%lx", mask); 310 | else 311 | sprintf(dst, "/%d", 32 - i); 312 | } 313 | 314 | /* 315 | * Return the name of the network whose address is given. 316 | * The address is assumed to be that of a net or subnet, not a host. 317 | */ 318 | char * 319 | netname(addr, mask) 320 | u_int32 addr, mask; 321 | { 322 | static char line[MAXHOSTNAMELEN + 4]; 323 | u_int32 omask; 324 | u_int32 i; 325 | 326 | i = ntohl(addr); 327 | omask = mask = ntohl(mask); 328 | if ((i & 0xffffff) == 0) 329 | sprintf(line, "%u", C(i >> 24)); 330 | else if ((i & 0xffff) == 0) 331 | sprintf(line, "%u.%u", C(i >> 24) , C(i >> 16)); 332 | else if ((i & 0xff) == 0) 333 | sprintf(line, "%u.%u.%u", C(i >> 24), C(i >> 16), C(i >> 8)); 334 | else 335 | sprintf(line, "%u.%u.%u.%u", C(i >> 24), 336 | C(i >> 16), C(i >> 8), C(i)); 337 | domask(line+strlen(line), i, omask); 338 | return (line); 339 | } 340 | -------------------------------------------------------------------------------- /src/netlink.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Fred Griffoul sent me this file to use 3 | * when compiling pimd under Linux. 4 | * 5 | * There was no copyright message or author name, so I assume he was the 6 | * author, and deserves the copyright/credit for it: 7 | * 8 | * COPYRIGHT/AUTHORSHIP by Fred Griffoul 9 | * (until proven otherwise). 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include "defs.h" 20 | 21 | #include 22 | 23 | int routing_socket = -1; 24 | static uint32_t pid; /* pid_t, but /usr/include/linux/netlink.h says __u32 ... */ 25 | static uint32_t seq; 26 | 27 | static int getmsg(struct rtmsg *rtm, int msglen, struct rpfctl *rpf); 28 | 29 | static int addattr32(struct nlmsghdr *n, size_t maxlen, int type, uint32_t data) 30 | { 31 | int len = RTA_LENGTH(4); 32 | struct rtattr *rta; 33 | 34 | if (NLMSG_ALIGN(n->nlmsg_len) + len > maxlen) 35 | return -1; 36 | 37 | rta = (struct rtattr *)(((char *)n) + NLMSG_ALIGN(n->nlmsg_len)); 38 | rta->rta_type = type; 39 | rta->rta_len = len; 40 | memcpy(RTA_DATA(rta), &data, 4); 41 | n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + len; 42 | 43 | return 0; 44 | } 45 | 46 | static int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len) 47 | { 48 | while (RTA_OK(rta, len)) { 49 | if (rta->rta_type <= max) 50 | tb[rta->rta_type] = rta; 51 | rta = RTA_NEXT(rta, len); 52 | } 53 | 54 | if (len) 55 | logit(LOG_WARNING, 0, "netlink: Deficit in rtattr %d", len); 56 | 57 | return 0; 58 | } 59 | 60 | /* open and initialize the routing socket */ 61 | int init_routesock(void) 62 | { 63 | socklen_t addr_len; 64 | struct sockaddr_nl local; 65 | 66 | routing_socket = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE); 67 | if (routing_socket < 0) { 68 | logit(LOG_ERR, errno, "Failed creating netlink socket"); 69 | return -1; 70 | } 71 | 72 | memset(&local, 0, sizeof(local)); 73 | local.nl_family = AF_NETLINK; 74 | local.nl_groups = 0; 75 | if (bind(routing_socket, (struct sockaddr *)&local, sizeof(local)) < 0) { 76 | logit(LOG_ERR, errno, "Failed binding to netlink socket"); 77 | return -1; 78 | } 79 | 80 | addr_len = sizeof(local); 81 | if (getsockname(routing_socket, (struct sockaddr *)&local, &addr_len) < 0) { 82 | logit(LOG_ERR, errno, "Failed netlink getsockname"); 83 | return -1; 84 | } 85 | 86 | if (addr_len != sizeof(local)) { 87 | logit(LOG_ERR, 0, "Invalid netlink addr len."); 88 | return -1; 89 | } 90 | 91 | if (local.nl_family != AF_NETLINK) { 92 | logit(LOG_ERR, 0, "Invalid netlink addr family."); 93 | return -1; 94 | } 95 | 96 | pid = local.nl_pid; 97 | seq = 1; 98 | 99 | return 0; 100 | } 101 | 102 | void routesock_clean(void) 103 | { 104 | if (routing_socket > 0) 105 | close(routing_socket); 106 | routing_socket = 0; 107 | } 108 | 109 | /* get the rpf neighbor info */ 110 | int k_req_incoming(uint32_t source, struct rpfctl *rpf) 111 | { 112 | int l, rlen; 113 | char buf[512]; 114 | struct nlmsghdr *n = (struct nlmsghdr *)buf; 115 | struct rtmsg *r = NLMSG_DATA(n); 116 | struct sockaddr_nl addr; 117 | 118 | rpf->source.s_addr = source; 119 | rpf->iif = NO_VIF; /* Initialize, will be changed in kernel */ 120 | rpf->rpfneighbor.s_addr = INADDR_ANY; /* Initialize */ 121 | 122 | n->nlmsg_type = RTM_GETROUTE; 123 | n->nlmsg_flags = NLM_F_REQUEST; 124 | n->nlmsg_len = NLMSG_LENGTH(sizeof(*r)); 125 | n->nlmsg_pid = pid; 126 | n->nlmsg_seq = ++seq; 127 | 128 | memset(r, 0, sizeof(*r)); 129 | r->rtm_family = AF_INET; 130 | #ifdef RTM_F_FIB_MATCH /* Introduced in Linux 4.13 */ 131 | r->rtm_flags = RTM_F_FIB_MATCH; /* FIB lookup with route metric */ 132 | #endif 133 | r->rtm_dst_len = 32; 134 | addattr32(n, sizeof(buf), RTA_DST, rpf->source.s_addr); 135 | #ifdef CONFIG_RTNL_OLD_IFINFO 136 | r->rtm_optlen = n->nlmsg_len - NLMSG_LENGTH(sizeof(*r)); 137 | #endif 138 | addr.nl_family = AF_NETLINK; 139 | addr.nl_groups = 0; 140 | addr.nl_pid = 0; 141 | 142 | IF_DEBUG(DEBUG_RPF) 143 | logit(LOG_DEBUG, 0, "k_req_incoming(): ask path to %s", inet_fmt(rpf->source.s_addr, s1)); 144 | 145 | do { 146 | socklen_t alen = sizeof(addr); 147 | 148 | rlen = sendto(routing_socket, buf, n->nlmsg_len, 0, (struct sockaddr *)&addr, alen); 149 | if (rlen < 0) { 150 | if (errno == EINTR) 151 | continue; /* Received signal, retry syscall. */ 152 | 153 | logit(LOG_WARNING, errno, "Error writing to netlink socket"); 154 | return FALSE; 155 | } 156 | } while (rlen < 0); 157 | 158 | do { 159 | socklen_t alen = sizeof(addr); 160 | 161 | l = recvfrom(routing_socket, buf, sizeof(buf), 0, (struct sockaddr *)&addr, &alen); 162 | if (l < 0) { 163 | if (errno == EINTR) 164 | continue; /* Received signal, retry syscall. */ 165 | 166 | logit(LOG_WARNING, errno, "Error reading from routing socket"); 167 | return FALSE; 168 | } 169 | } while (n->nlmsg_seq != seq || n->nlmsg_pid != pid); 170 | 171 | if (n->nlmsg_type != RTM_NEWROUTE) { 172 | errno = -(*(int*)NLMSG_DATA(n)); 173 | 174 | if (n->nlmsg_type != NLMSG_ERROR) 175 | logit(LOG_WARNING, 0, "Wrong netlink answer type: %d", n->nlmsg_type); 176 | else 177 | logit(LOG_WARNING, errno, "Failed getting route for %s", inet_fmt(rpf->source.s_addr, s1)); 178 | 179 | return FALSE; 180 | } 181 | 182 | return getmsg(NLMSG_DATA(n), l - sizeof(*n), rpf); 183 | } 184 | 185 | static int getmsg(struct rtmsg *rtm, int msglen, struct rpfctl *rpf) 186 | { 187 | int ifindex; 188 | vifi_t vifi; 189 | struct uvif *v; 190 | struct rtattr *rta[RTA_MAX + 1]; 191 | 192 | if (!rpf) { 193 | logit(LOG_WARNING, 0, "Missing rpf pointer to netlink.c:getmsg()!"); 194 | return FALSE; 195 | } 196 | 197 | rpf->iif = NO_VIF; 198 | rpf->rpfneighbor.s_addr = INADDR_ANY; 199 | 200 | if (rtm->rtm_type == RTN_LOCAL) { 201 | IF_DEBUG(DEBUG_RPF) 202 | logit(LOG_DEBUG, 0, "netlink: local address"); 203 | 204 | if ((rpf->iif = local_address(rpf->source.s_addr)) != MAXVIFS) { 205 | rpf->rpfneighbor.s_addr = rpf->source.s_addr; 206 | 207 | return TRUE; 208 | } 209 | 210 | return FALSE; 211 | } 212 | 213 | if (rtm->rtm_type != RTN_UNICAST) { 214 | IF_DEBUG(DEBUG_RPF) 215 | logit(LOG_DEBUG, 0, "netlink: route type is %d", rtm->rtm_type); 216 | return FALSE; 217 | } 218 | 219 | memset(rta, 0, sizeof(rta)); 220 | parse_rtattr(rta, RTA_MAX, RTM_RTA(rtm), msglen - sizeof(*rtm)); 221 | 222 | if (!rta[RTA_OIF]) { 223 | logit(LOG_WARNING, 0, "Missing outbound interface in netlink reply"); 224 | return FALSE; 225 | } 226 | 227 | /* Get ifindex of outbound interface */ 228 | ifindex = *(int *)RTA_DATA(rta[RTA_OIF]); 229 | 230 | for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) { 231 | if (v->uv_ifindex == ifindex) 232 | break; 233 | } 234 | 235 | if (vifi >= numvifs) 236 | return FALSE; 237 | 238 | /* Found inbound interface in vifi */ 239 | rpf->iif = vifi; 240 | 241 | /* Default to use phyint metric from .conf file */ 242 | rpf->metric = -1; 243 | 244 | IF_DEBUG(DEBUG_RPF) 245 | logit(LOG_DEBUG, 0, "netlink: vif %d, ifindex=%d", vifi, ifindex); 246 | 247 | if (rta[RTA_GATEWAY]) { 248 | uint32_t gw = *(uint32_t *)RTA_DATA(rta[RTA_GATEWAY]); 249 | 250 | IF_DEBUG(DEBUG_RPF) 251 | logit(LOG_DEBUG, 0, "netlink: gateway is %s", inet_fmt(gw, s1)); 252 | 253 | rpf->rpfneighbor.s_addr = gw; 254 | } else { 255 | rpf->rpfneighbor.s_addr = rpf->source.s_addr; 256 | } 257 | 258 | if (rta[RTA_PRIORITY]) { 259 | int metric = *(int *)RTA_DATA(rta[RTA_PRIORITY]); 260 | 261 | IF_DEBUG(DEBUG_RPF) 262 | logit(LOG_DEBUG, 0, "netlink: metric %d", metric); 263 | 264 | rpf->metric = metric; 265 | } 266 | 267 | return TRUE; 268 | } 269 | 270 | /** 271 | * Local Variables: 272 | * c-file-style: "cc-mode" 273 | * End: 274 | */ 275 | -------------------------------------------------------------------------------- /src/pathnames.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1998 by the University of Southern California. 3 | * All rights reserved. 4 | * 5 | * Permission to use, copy, modify, and distribute this software and 6 | * its documentation in source and binary forms for lawful 7 | * purposes and without fee is hereby granted, provided 8 | * that the above copyright notice appear in all copies and that both 9 | * the copyright notice and this permission notice appear in supporting 10 | * documentation, and that any documentation, advertising materials, 11 | * and other materials related to such distribution and use acknowledge 12 | * that the software was developed by the University of Southern 13 | * California and/or Information Sciences Institute. 14 | * The name of the University of Southern California may not 15 | * be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THE UNIVERSITY OF SOUTHERN CALIFORNIA DOES NOT MAKE ANY REPRESENTATIONS 19 | * ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. THIS SOFTWARE IS 20 | * PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND 23 | * NON-INFRINGEMENT. 24 | * 25 | * IN NO EVENT SHALL USC, OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY 26 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, WHETHER IN CONTRACT, 27 | * TORT, OR OTHER FORM OF ACTION, ARISING OUT OF OR IN CONNECTION WITH, 28 | * THE USE OR PERFORMANCE OF THIS SOFTWARE. 29 | * 30 | * Other copyrights might apply to parts of this software and are so 31 | * noted when applicable. 32 | */ 33 | /* 34 | * Part of this program has been derived from mrouted. 35 | * The mrouted program is covered by the license in the accompanying file 36 | * named "LICENSE.mrouted". 37 | * 38 | * The mrouted program is COPYRIGHT 1989 by The Board of Trustees of 39 | * Leland Stanford Junior University. 40 | * 41 | */ 42 | #ifndef PIMD_PATHNAMES_H_ 43 | #define PIMD_PATHNAMES_H_ 44 | 45 | #define _PATH_PIMD_CONF SYSCONFDIR "/%s.conf" 46 | #define _PATH_PIMD_RUNDIR RUNSTATEDIR 47 | #define _PATH_PIMD_PID RUNSTATEDIR "/%s.pid" 48 | #define _PATH_PIMD_SOCK RUNSTATEDIR "/%s.sock" 49 | 50 | #endif /* PIMD_PATHNAMES_H_ */ 51 | -------------------------------------------------------------------------------- /src/rsrr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993, 1998-2001. 3 | * The University of Southern California/Information Sciences Institute. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. Neither the name of the project nor the names of its contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGE. 29 | */ 30 | 31 | #define RSRR_SERV_PATH "/tmp/.rsrr_svr" 32 | /* Note this needs to be 14 chars for 4.3 BSD compatibility */ 33 | #define RSRR_CLI_PATH "/tmp/.rsrr_cli" 34 | 35 | #define RSRR_MAX_LEN 2048 36 | #define RSRR_HEADER_LEN (sizeof(struct rsrr_header)) 37 | #define RSRR_RQ_LEN (RSRR_HEADER_LEN + sizeof(struct rsrr_rq)) 38 | #define RSRR_RR_LEN (RSRR_HEADER_LEN + sizeof(struct rsrr_rr)) 39 | #define RSRR_VIF_LEN (sizeof(struct rsrr_vif)) 40 | 41 | /* Current maximum number of vifs. */ 42 | #define RSRR_MAX_VIFS 32 43 | 44 | /* Maximum acceptable version */ 45 | #define RSRR_MAX_VERSION 1 46 | 47 | /* RSRR message types */ 48 | #define RSRR_ALL_TYPES 0 49 | #define RSRR_INITIAL_QUERY 1 50 | #define RSRR_INITIAL_REPLY 2 51 | #define RSRR_ROUTE_QUERY 3 52 | #define RSRR_ROUTE_REPLY 4 53 | 54 | 55 | /* Each definition represents the position of the bit from right to left. */ 56 | /* All not defined bits are zeroes */ 57 | 58 | /* RSRR Initial Reply (Vif) Status bits 59 | * 60 | * 0 = disabled bit, set if the vif is administratively disabled. 61 | */ 62 | #define RSRR_DISABLED_BIT 0 63 | 64 | /* RSRR Route Query/Reply flag bits 65 | * 66 | * 0 = Route Change Notification bit, set if the reservation protocol 67 | * wishes to receive notification of a route change for the 68 | * source-destination pair listed in the query. Notification is in the 69 | * form of an unsolicitied Route Reply. 70 | * 1 = Error bit, set if routing doesn't have a routing entry for 71 | * the source-destination pair. 72 | * (TODO: XXX: currently not used by rsvpd?) 73 | * (2,3) = Shared tree (Reply only) 74 | * = 01 if the listed sender is using a shared tree, but some other 75 | * senders for the same destination use sender (source-specific) 76 | * trees. 77 | * = 10 if all senders for the destination use shared tree. 78 | * = 00 otherwise 79 | */ 80 | #define RSRR_NOTIFICATION_BIT 0 81 | #define RSRR_ERROR_BIT 1 82 | #define RSRR_THIS_SENDER_SHARED_TREE 2 83 | #define RSRR_ALL_SENDERS_SHARED_TREE 3 84 | #define RSRR_SET_ALL_SENDERS_SHARED_TREE(X) \ 85 | BIT_SET((X), RSRR_ALL_SENDERS_SHARED_TREE); \ 86 | BIT_CLR((X), RSRR_THIS_SENDER_SHARED_TREE); 87 | #define RSRR_THIS_SENDER_SHARED_TREE_SOME_OTHER_NOT(X) \ 88 | BIT_SET((X), RSRR_THIS_SENDER_SHARED_TREE); \ 89 | BIT_CLR((X), RSRR_ALL_SENDERS_SHARED_TREE) 90 | 91 | /* Definition of an RSRR message header. 92 | * An Initial Query uses only the header, and an Initial Reply uses 93 | * the header and a list of vifs. 94 | */ 95 | struct rsrr_header { 96 | u_int8 version; /* RSRR Version, currently 1 */ 97 | u_int8 type; /* type of message, as defined above*/ 98 | u_int8 flags; /* flags; defined by type */ 99 | u_int8 num; /* number; defined by type */ 100 | }; 101 | 102 | /* Definition of a vif as seen by the reservation protocol. 103 | * 104 | * Routing gives the reservation protocol a list of vifs in the 105 | * Initial Reply. 106 | * 107 | * We explicitly list the ID because we can't assume that all routing 108 | * protocols will use the same numbering scheme. 109 | * 110 | * The status is a bitmask of status flags, as defined above. It is the 111 | * responsibility of the reservation protocol to perform any status checks 112 | * if it uses the MULTICAST_VIF socket option. 113 | * 114 | * The threshold indicates the ttl an outgoing packet needs in order to 115 | * be forwarded. The reservation protocol must perform this check itself if 116 | * it uses the MULTICAST_VIF socket option. 117 | * 118 | * The local address is the address of the physical interface over which 119 | * packets are sent. 120 | */ 121 | struct rsrr_vif { 122 | u_int8 id; /* vif id */ 123 | u_int8 threshold; /* vif threshold ttl */ 124 | u_int16 status; /* vif status bitmask */ 125 | u_int32 local_addr; /* vif local address */ 126 | }; 127 | 128 | /* Definition of an RSRR Route Query. 129 | * 130 | * The query asks routing for the forwarding entry for a particular 131 | * source and destination. The query ID uniquely identifies the query 132 | * for the reservation protocol. Thus, the combination of the client's 133 | * address and the query ID forms a unique identifier for routing. 134 | * Flags are defined above. 135 | */ 136 | struct rsrr_rq { 137 | u_int32 dest_addr; /* destination */ 138 | u_int32 source_addr; /* source */ 139 | u_int32 query_id; /* query ID */ 140 | }; 141 | 142 | /* Definition of an RSRR Route Reply. 143 | * 144 | * Routing uses the reply to give the reservation protocol the 145 | * forwarding entry for a source-destination pair. Routing copies the 146 | * query ID from the query and fills in the incoming vif and a bitmask 147 | * of the outgoing vifs. 148 | * Flags are defined above. 149 | */ 150 | /* TODO: XXX: in_vif is 16 bits here, but in rsrr_vif it is 8 bits. 151 | * Bug in the spec? 152 | */ 153 | struct rsrr_rr { 154 | u_int32 dest_addr; /* destination */ 155 | u_int32 source_addr; /* source */ 156 | u_int32 query_id; /* query ID */ 157 | u_int16 in_vif; /* incoming vif */ 158 | u_int16 reserved; /* reserved */ 159 | u_int32 out_vif_bm; /* outgoing vif bitmask */ 160 | }; 161 | 162 | 163 | /* TODO: XXX: THIS IS NOT IN THE SPEC! (OBSOLETE?) */ 164 | #ifdef NOT_IN_THE_SPEC 165 | /* Definition of an RSRR Service Query/Reply. 166 | * 167 | * The query asks routing to perform a service for a particular 168 | * source/destination combination. The query also lists the vif 169 | * that the service applies to. 170 | */ 171 | struct rsrr_sqr { 172 | u_int32 dest_addr; /* destination */ 173 | u_int32 source_addr; /* source */ 174 | u_int32 query_id; /* query ID */ 175 | u_int16 vif; /* vif */ 176 | u_int16 reserved; /* reserved */ 177 | }; 178 | #endif /* NOT_IN_THE_SPEC */ 179 | -------------------------------------------------------------------------------- /src/rsrr_var.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993, 1998 by the University of Southern California 3 | * All rights reserved. 4 | * 5 | * Permission to use, copy, modify, and distribute this software and its 6 | * documentation in source and binary forms for lawful purposes 7 | * and without fee is hereby granted, provided that the above copyright 8 | * notice appear in all copies and that both the copyright notice and 9 | * this permission notice appear in supporting documentation. and that 10 | * any documentation, advertising materials, and other materials related 11 | * to such distribution and use acknowledge that the software was 12 | * developed by the University of Southern California, Information 13 | * Sciences Institute. The name of the University may not be used to 14 | * endorse or promote products derived from this software without 15 | * specific prior written permission. 16 | * 17 | * THE UNIVERSITY OF SOUTHERN CALIFORNIA makes no representations about 18 | * the suitability of this software for any purpose. THIS SOFTWARE IS 19 | * PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, 20 | * INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 22 | * 23 | * Other copyrights might apply to parts of this software and are so 24 | * noted when applicable. 25 | */ 26 | 27 | /* RSRR things that are only needed by mrouted. */ 28 | 29 | /* Cache of Route Query messages, distinguished by source, 30 | * destination, and client addresses. Cache is flushed by RSRR client 31 | * -- it sends notification when an unwanted Route Reply is received. 32 | * Since this only happens during route changes, it is more likely 33 | * that the cache will be flushed when the kernel table entry is 34 | * deleted. */ 35 | struct rsrr_cache { 36 | struct rsrr_rq route_query; /* Cached Route Query */ 37 | struct sockaddr_un client_addr; /* Client address */ 38 | int client_length; /* Length of client */ 39 | struct rsrr_cache *next; /* next cache item */ 40 | }; 41 | 42 | -------------------------------------------------------------------------------- /src/trace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1998 by the University of Southern California. 3 | * All rights reserved. 4 | * 5 | * Permission to use, copy, modify, and distribute this software and 6 | * its documentation in source and binary forms for lawful 7 | * purposes and without fee is hereby granted, provided 8 | * that the above copyright notice appear in all copies and that both 9 | * the copyright notice and this permission notice appear in supporting 10 | * documentation, and that any documentation, advertising materials, 11 | * and other materials related to such distribution and use acknowledge 12 | * that the software was developed by the University of Southern 13 | * California and/or Information Sciences Institute. 14 | * The name of the University of Southern California may not 15 | * be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * 18 | * THE UNIVERSITY OF SOUTHERN CALIFORNIA DOES NOT MAKE ANY REPRESENTATIONS 19 | * ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. THIS SOFTWARE IS 20 | * PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, 21 | * INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND 23 | * NON-INFRINGEMENT. 24 | * 25 | * IN NO EVENT SHALL USC, OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY 26 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, WHETHER IN CONTRACT, 27 | * TORT, OR OTHER FORM OF ACTION, ARISING OUT OF OR IN CONNECTION WITH, 28 | * THE USE OR PERFORMANCE OF THIS SOFTWARE. 29 | * 30 | * Other copyrights might apply to parts of this software and are so 31 | * noted when applicable. 32 | */ 33 | /* 34 | * Questions concerning this software should be directed to 35 | * Pavlin Ivanov Radoslavov (pavlin@catarina.usc.edu) 36 | * 37 | * $Id: trace.h,v 1.1.1.1 1998/05/11 17:39:34 kurtw Exp $ 38 | */ 39 | /* 40 | * Part of this program has been derived from mrouted. 41 | * The mrouted program is covered by the license in the accompanying file 42 | * named "LICENSE.mrouted". 43 | * 44 | * The mrouted program is COPYRIGHT 1989 by The Board of Trustees of 45 | * Leland Stanford Junior University. 46 | * 47 | */ 48 | 49 | 50 | /* 51 | * The packet format for a traceroute request. 52 | */ 53 | struct tr_query { 54 | u_int32 tr_src; /* traceroute source */ 55 | u_int32 tr_dst; /* traceroute destination */ 56 | u_int32 tr_raddr; /* traceroute response address */ 57 | #if defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN) 58 | struct { 59 | u_int qid : 24; /* traceroute query id */ 60 | u_int ttl : 8; /* traceroute response ttl */ 61 | } q; 62 | #else 63 | struct { 64 | u_int ttl : 8; /* traceroute response ttl */ 65 | u_int qid : 24; /* traceroute query id */ 66 | } q; 67 | #endif /* BYTE_ORDER */ 68 | }; 69 | 70 | #define tr_rttl q.ttl 71 | #define tr_qid q.qid 72 | 73 | /* 74 | * Traceroute response format. A traceroute response has a tr_query at the 75 | * beginning, followed by one tr_resp for each hop taken. 76 | */ 77 | struct tr_resp { 78 | u_int32 tr_qarr; /* query arrival time */ 79 | u_int32 tr_inaddr; /* incoming interface address */ 80 | u_int32 tr_outaddr; /* outgoing interface address */ 81 | u_int32 tr_rmtaddr; /* parent address in source tree */ 82 | u_int32 tr_vifin; /* input packet count on interface */ 83 | u_int32 tr_vifout; /* output packet count on interface */ 84 | u_int32 tr_pktcnt; /* total incoming packets for src-grp */ 85 | u_char tr_rproto; /* routing protocol deployed on router */ 86 | u_char tr_fttl; /* ttl required to forward on outvif */ 87 | u_char tr_smask; /* subnet mask for src addr */ 88 | u_char tr_rflags; /* forwarding error codes */ 89 | }; 90 | 91 | /* defs within mtrace */ 92 | #define QUERY 1 93 | #define RESP 2 94 | #define QLEN sizeof(struct tr_query) 95 | #define RLEN sizeof(struct tr_resp) 96 | 97 | /* fields for tr_rflags (forwarding error codes) */ 98 | #define TR_NO_ERR 0 /* No error */ 99 | #define TR_WRONG_IF 1 /* traceroute arrived on non-oif */ 100 | #define TR_PRUNED 2 /* router has sent a prune upstream */ 101 | #define TR_OPRUNED 3 /* stop forw. after request from next hop rtr*/ 102 | #define TR_SCOPED 4 /* group adm. scoped at this hop */ 103 | #define TR_NO_RTE 5 /* no route for the source */ 104 | #define TR_NO_LHR 6 /* not the last-hop router */ 105 | #define TR_NO_FWD 7 /* not forwarding for this (S,G). Reason = ? */ 106 | #define TR_RP 8 /* I am the RP/Core */ 107 | #define TR_IIF 9 /* request arrived on the iif */ 108 | #define TR_NO_MULTI 0x0a /* multicast disabled on that interface */ 109 | #define TR_NO_SPACE 0x81 /* no space to insert responce data block */ 110 | #define TR_OLD_ROUTER 0x82 /* previous hop does not support traceroute */ 111 | #define TR_ADMIN_PROHIB 0x83 /* traceroute adm. prohibited */ 112 | 113 | /* fields for tr_smask */ 114 | #define TR_GROUP_ONLY 0x2f /* forwarding solely on group state */ 115 | #define TR_SUBNET_COUNT 0x40 /* pkt count for (S,G) is for source network */ 116 | 117 | /* fields for packets count */ 118 | #define TR_CANT_COUNT 0xffffffff /* no count can be reported */ 119 | 120 | /* fields for tr_rproto (routing protocol) */ 121 | #define PROTO_DVMRP 1 122 | #define PROTO_MOSPF 2 123 | #define PROTO_PIM 3 124 | #define PROTO_CBT 4 125 | #define PROTO_PIM_SPECIAL 5 126 | #define PROTO_PIM_STATIC 6 127 | #define PROTO_DVMRP_STATIC 7 128 | 129 | #define MASK_TO_VAL(x, i) { \ 130 | u_int32 _x = ntohl(x); \ 131 | (i) = 1; \ 132 | while ((_x) <<= 1) \ 133 | (i)++; \ 134 | }; 135 | 136 | #define VAL_TO_MASK(x, i) { \ 137 | x = htonl(~((1 << (32 - (i))) - 1)); \ 138 | }; 139 | 140 | #define NBR_VERS(n) (((n)->al_pv << 8) + (n)->al_mv) 141 | -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | .deps/* 2 | *.log 3 | *.o 4 | *.trs 5 | mping 6 | -------------------------------------------------------------------------------- /test/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = lib.sh mping.c pod.sh shared.sh single.sh three.sh 2 | CLEANFILES = *~ *.trs *.log 3 | 4 | # Step VERSION when updating from https://github.com/troglobit/mping/ 5 | noinst_PROGRAMS = mping 6 | mping_CFLAGS = -DVERSION='"1.5"' 7 | mping_SOURCES = mping.c 8 | 9 | TEST_EXTENSIONS = .sh 10 | TESTS_ENVIRONMENT = unshare -mrun 11 | 12 | TESTS = pod.sh 13 | TESTS += shared.sh 14 | TESTS += single.sh 15 | TESTS += three.sh 16 | -------------------------------------------------------------------------------- /test/single.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Verifies pimd-dense operation in a single router setup: 3 | # - forwardng multicast between two emulated end devices 4 | # - PIM Hello on both LANs 5 | # - IGMP v3 Query on both LANs 6 | 7 | # shellcheck source=/dev/null 8 | . "$(dirname "$0")/lib.sh" 9 | 10 | # Requires ethtool to disable UDP checksum offloading 11 | print "Check deps ..." 12 | check_dep ethtool 13 | check_dep tshark 14 | 15 | print "Creating world ..." 16 | left="/tmp/$NM/a1" 17 | right="/tmp/$NM/a2" 18 | touch "$left" "$right" 19 | PID=$$ 20 | 21 | echo "$left" > "/tmp/$NM/mounts" 22 | echo "$right" >> "/tmp/$NM/mounts" 23 | 24 | lif=$(basename "$left") 25 | rif=$(basename "$right") 26 | 27 | # Disabling UDP checksum offloading, frames are leaving kernel space 28 | # on these VETH pairs. (Silence noisy ethtool output) 29 | unshare --net="$left" -- ip link set lo up 30 | nsenter --net="$left" -- ip link add eth0 type veth peer "$lif" 31 | nsenter --net="$left" -- ethtool --offload eth0 tx off >/dev/null 32 | nsenter --net="$left" -- ethtool --offload eth0 rx off >/dev/null 33 | nsenter --net="$left" -- ip link set "$lif" netns $PID 34 | ethtool --offload "$lif" tx off >/dev/null 35 | ethtool --offload "$lif" rx off >/dev/null 36 | nsenter --net="$left" -- ip link set eth0 up 37 | ip link set "$lif" up 38 | 39 | unshare --net="$right" -- ip link set lo up 40 | nsenter --net="$right" -- ip link add eth0 type veth peer "$rif" 41 | nsenter --net="$right" -- ethtool --offload eth0 tx off >/dev/null 42 | nsenter --net="$right" -- ethtool --offload eth0 rx off >/dev/null 43 | nsenter --net="$right" -- ip link set "$rif" netns $PID 44 | ethtool --offload "$rif" tx off >/dev/null 45 | ethtool --offload "$rif" rx off >/dev/null 46 | nsenter --net="$right" -- ip link set eth0 up 47 | ip link set "$rif" up 48 | 49 | ip addr add 10.0.0.1/24 dev a1 50 | nsenter --net="$left" -- ip addr add 10.0.0.10/24 dev eth0 51 | nsenter --net="$left" -- ip route add default via 10.0.0.1 52 | 53 | ip addr add 20.0.0.1/24 dev a2 54 | nsenter --net="$right" -- ip addr add 20.0.0.10/24 dev eth0 55 | nsenter --net="$right" -- ip route add default via 20.0.0.1 56 | 57 | ip -br l 58 | ip -br a 59 | 60 | print "Creating config ..." 61 | cat < "/tmp/$NM/conf" 62 | no phyint 63 | phyint $lif enable 64 | phyint $rif enable 65 | EOF 66 | cat "/tmp/$NM/conf" 67 | 68 | print "Starting collectors ..." 69 | nsenter --net="$left" -- tshark -lni eth0 -w "/tmp/$NM/left.pcap" 2>/dev/null & 70 | echo $! >> "/tmp/$NM/PIDs" 71 | nsenter --net="$right" -- tshark -lni eth0 -w "/tmp/$NM/right.pcap" 2>/dev/null & 72 | echo $! >> "/tmp/$NM/PIDs" 73 | sleep 1 74 | 75 | print "Starting pimd-dense ..." 76 | ../src/pimdd -f "/tmp/$NM/conf" -n -p "/tmp/$NM/pid" -l debug -u "/tmp/$NM/sock" & 77 | sleep 1 78 | 79 | print "Starting emitter ..." 80 | nsenter --net="$right" -- ./mping -qr -d -i eth0 -t 3 -W 30 225.1.2.3 & 81 | echo $! >> "/tmp/$NM/PIDs" 82 | sleep 1 83 | 84 | if ! nsenter --net="$left" -- ./mping -s -d -i eth0 -t 3 -c 10 -w 15 225.1.2.3; then 85 | show_mroute 86 | ../src/pimctl -u "/tmp/$NM/sock" 87 | echo "Failed routing, expected at least 10 multicast ping replies" 88 | FAIL 89 | fi 90 | 91 | ../src/pimctl -u "/tmp/$NM/sock" show compat detail 92 | 93 | kill_pids 94 | sleep 1 95 | 96 | print "Analyzing left.pcap ..." 97 | lines1=$(tshark -r "/tmp/$NM/left.pcap" 2>/dev/null | grep "PIMv2 56 Hello" | tee "/tmp/$NM/result" | wc -l) 98 | lines2=$(tshark -r "/tmp/$NM/left.pcap" 2>/dev/null | grep "IGMPv3 50 Membership Query" | tee -a "/tmp/$NM/result" | wc -l) 99 | cat "/tmp/$NM/result" 100 | echo " => $lines1 PIM Hello, expected 1" 101 | echo " => $lines2 IGMP Query, expected 1" 102 | # shellcheck disable=SC2086 disable=SC2166 103 | [ $lines1 -ge 1 -a $lines2 -ge 1 ] || FAIL 104 | 105 | print "Analyzing right.pcap ..." 106 | lines1=$(tshark -r "/tmp/$NM/right.pcap" 2>/dev/null | grep "PIMv2 56 Hello" | tee "/tmp/$NM/result" | wc -l) 107 | lines2=$(tshark -r "/tmp/$NM/right.pcap" 2>/dev/null | grep "IGMPv3 50 Membership Query" | tee -a "/tmp/$NM/result" | wc -l) 108 | cat "/tmp/$NM/result" 109 | echo " => $lines1 PIM Hello, expected 1" 110 | echo " => $lines2 IGMP Query, expected 1" 111 | # shellcheck disable=SC2086 disable=SC2166 112 | [ $lines1 -ge 1 -a $lines2 -ge 1 ] || FAIL 113 | 114 | OK 115 | -------------------------------------------------------------------------------- /test/test-setup.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/troglobit/pimd-dense/fcc12dffbe251b1c31a0c5b0462ec67e3415f485/test/test-setup.pdf -------------------------------------------------------------------------------- /test/three.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Three routers in a row, end devices on each end. Every other 3 | # device in a network namespace to circumvent one-address per 4 | # subnet in Linux 5 | # 6 | # NS1 NS2 NS3 NS4 NS5 7 | # [ED1:eth0]--[eth1:R1:eth2]---[eth3:R2:eth4]---[eth5:R3:eth6]---[eth0:ED2] 8 | # 10.0.0.0/24 10.0.1.0/24 10.0.2.0/24 10.0.3.0/24 9 | 10 | # shellcheck source=/dev/null 11 | . "$(dirname "$0")/lib.sh" 12 | 13 | # Requires OSPF (bird) to build the unicast rpf tree 14 | print "Check deps ..." 15 | check_dep ethtool 16 | check_dep tshark 17 | check_dep bird 18 | 19 | print "Creating world ..." 20 | NS1="/tmp/$NM/NS1" 21 | NS2="/tmp/$NM/NS2" 22 | NS3="/tmp/$NM/NS3" 23 | NS4="/tmp/$NM/NS4" 24 | NS5="/tmp/$NM/NS5" 25 | touch "$NS1" "$NS2" "$NS3" "$NS4" "$NS5" 26 | 27 | echo "$NS1" > "/tmp/$NM/mounts" 28 | echo "$NS2" >> "/tmp/$NM/mounts" 29 | echo "$NS3" >> "/tmp/$NM/mounts" 30 | echo "$NS4" >> "/tmp/$NM/mounts" 31 | echo "$NS5" >> "/tmp/$NM/mounts" 32 | 33 | unshare --net="$NS1" -- ip link set lo up 34 | unshare --net="$NS2" -- ip link set lo up 35 | unshare --net="$NS3" -- ip link set lo up 36 | unshare --net="$NS4" -- ip link set lo up 37 | unshare --net="$NS5" -- ip link set lo up 38 | 39 | # Creates a VETH pair, one end named eth0 and the other is eth7: 40 | # 41 | # created /tmp/foo eth0 eth7 1.2.3.4/24 1.2.3.1 42 | # 43 | # Disabling UDP checksum offloading with ethtool, frames are leaving 44 | # kernel space on these VETH pairs. (Silence noisy ethtool output) 45 | created() 46 | { 47 | in=$2 48 | if echo "$3" | grep -q '@'; then 49 | ut=$(echo "$3" | cut -f1 -d@) 50 | id=$(echo "$3" | cut -f2 -d@) 51 | else 52 | ut=$3 53 | fi 54 | 55 | echo "Creating device interfaces $in and $ut ..." 56 | nsenter --net="$1" -- ip link add "$in" type veth peer "$ut" 57 | nsenter --net="$1" -- ip link set "$in" up 58 | 59 | nsenter --net="$1" -- ip addr add "$4" broadcast + dev "$2" 60 | nsenter --net="$1" -- ip route add default via "$5" 61 | 62 | for iface in "$in" "$ut"; do 63 | nsenter --net="$1" -- ethtool --offload "$iface" tx off >/dev/null 64 | nsenter --net="$1" -- ethtool --offload "$iface" rx off >/dev/null 65 | done 66 | 67 | if [ -n "$id" ]; then 68 | echo "$1 moving $ut to netns PID $id" 69 | nsenter --net="$1" -- ip link set "$ut" netns "$id" 70 | fi 71 | 72 | return $! 73 | } 74 | 75 | creater() 76 | { 77 | if echo "$2" |grep -q ':'; then 78 | x=$(echo "$2" | cut -f1 -d:) 79 | b=$(echo "$2" | cut -f2 -d:) 80 | echo "1) Found x=$x and b=$b ..." 81 | a=$(echo "$x" | cut -f1 -d@) 82 | p=$(echo "$x" | cut -f2 -d@) 83 | echo "1) Found a=$a and p=$p ..." 84 | echo "Creating router interfaces $a and $b ..." 85 | nsenter --net="$1" -- ip link add "$a" type veth peer "$b" 86 | for iface in "$a" "$b"; do 87 | nsenter --net="$1" -- ethtool --offload "$iface" tx off >/dev/null 88 | nsenter --net="$1" -- ethtool --offload "$iface" rx off >/dev/null 89 | done 90 | echo "$1 moving $a to netns PID $p" 91 | nsenter --net="$1" -- ip link set "$a" netns "$p" 92 | else 93 | b=$2 94 | fi 95 | 96 | echo "Bringing up $a with addr $4" 97 | nsenter --net="$1" -- ip link set "$b" up 98 | nsenter --net="$1" -- ip addr add "$4" broadcast + dev "$b" 99 | 100 | if echo "$3" |grep -q ':'; then 101 | a=$(echo "$3" | cut -f1 -d:) 102 | x=$(echo "$3" | cut -f2 -d:) 103 | echo "2) Found x=$x and b=$b ..." 104 | b=$(echo "$x" | cut -f1 -d@) 105 | p=$(echo "$x" | cut -f2 -d@) 106 | echo "2) Found a=$a and p=$p ..." 107 | echo "Creating router interfaces $a and $b ..." 108 | nsenter --net="$1" -- ip link add "$a" type veth peer "$b" 109 | for iface in "$a" "$b"; do 110 | nsenter --net="$1" -- ethtool --offload "$iface" tx off >/dev/null 111 | nsenter --net="$1" -- ethtool --offload "$iface" rx off >/dev/null 112 | done 113 | echo "$1 moving $b to netns PID $p" 114 | nsenter --net="$1" -- ip link set "$b" netns "$p" 115 | else 116 | a=$3 117 | fi 118 | 119 | echo "Bringing up $a with addr $5" 120 | nsenter --net="$1" -- ip link set "$a" up 121 | nsenter --net="$1" -- ip addr add "$5" broadcast + dev "$a" 122 | } 123 | 124 | dprint "Creating $NS2 router ..." 125 | nsenter --net="$NS2" -- sleep 5 & 126 | pid2=$! 127 | dprint "Creating $NS4 router ..." 128 | nsenter --net="$NS4" -- sleep 5 & 129 | pid4=$! 130 | 131 | dprint "Creating NS1 ED with eth1 in PID $pid2" 132 | created "$NS1" eth0 eth1@"$pid2" 10.0.0.10/24 10.0.0.1 133 | 134 | dprint "Creating NS3 router with eth3 in PID $pid2 and eth5 in PID $pid4" 135 | creater "$NS3" eth2@"$pid2":eth3 eth4:eth5@"$pid4" 10.0.1.2/24 10.0.2.1/24 136 | 137 | dprint "Creating NS5 ED with eth6 in PID $pid4" 138 | created "$NS5" eth0 eth6@"$pid4" 10.0.3.10/24 10.0.3.1 139 | 140 | creater "$NS2" eth1 eth2 10.0.0.1/24 10.0.1.1/24 141 | creater "$NS4" eth5 eth6 10.0.2.2/24 10.0.3.1/24 142 | 143 | dprint "$NS1" 144 | nsenter --net="$NS1" -- ip -br l 145 | nsenter --net="$NS1" -- ip -br a 146 | dprint "$NS2" 147 | nsenter --net="$NS2" -- ip -br l 148 | nsenter --net="$NS2" -- ip -br a 149 | dprint "$NS3" 150 | nsenter --net="$NS3" -- ip -br l 151 | nsenter --net="$NS3" -- ip -br a 152 | dprint "$NS4" 153 | nsenter --net="$NS4" -- ip -br l 154 | nsenter --net="$NS4" -- ip -br a 155 | dprint "$NS5" 156 | nsenter --net="$NS5" -- ip -br l 157 | nsenter --net="$NS5" -- ip -br a 158 | 159 | print "Creating OSPF config ..." 160 | cat < "/tmp/$NM/bird.conf" 161 | protocol device { 162 | } 163 | protocol direct { 164 | ipv4; 165 | } 166 | protocol kernel { 167 | ipv4 { 168 | export all; 169 | }; 170 | learn; 171 | } 172 | protocol ospf { 173 | ipv4 { 174 | import all; 175 | }; 176 | area 0 { 177 | interface "eth*" { 178 | type broadcast; 179 | hello 1; 180 | wait 3; 181 | dead 5; 182 | }; 183 | }; 184 | } 185 | EOF 186 | cat "/tmp/$NM/bird.conf" 187 | 188 | print "Starting Bird OSPF ..." 189 | nsenter --net="$NS2" -- bird -c "/tmp/$NM/bird.conf" -d -s "/tmp/$NM/r1-bird.sock" & 190 | echo $! >> "/tmp/$NM/PIDs" 191 | nsenter --net="$NS3" -- bird -c "/tmp/$NM/bird.conf" -d -s "/tmp/$NM/r2-bird.sock" & 192 | echo $! >> "/tmp/$NM/PIDs" 193 | nsenter --net="$NS4" -- bird -c "/tmp/$NM/bird.conf" -d -s "/tmp/$NM/r3-bird.sock" & 194 | echo $! >> "/tmp/$NM/PIDs" 195 | sleep 1 196 | 197 | print "Starting pimd-dense ..." 198 | nsenter --net="$NS2" -- ../src/pimdd -n -p "/tmp/$NM/r1.pid" -l debug -u "/tmp/$NM/r1.sock" & 199 | echo $! >> "/tmp/$NM/PIDs" 200 | nsenter --net="$NS3" -- ../src/pimdd -n -p "/tmp/$NM/r2.pid" -l debug -u "/tmp/$NM/r2.sock" & 201 | echo $! >> "/tmp/$NM/PIDs" 202 | nsenter --net="$NS4" -- ../src/pimdd -n -p "/tmp/$NM/r3.pid" -l debug -u "/tmp/$NM/r3.sock" & 203 | echo $! >> "/tmp/$NM/PIDs" 204 | sleep 1 205 | 206 | # Wait for routers to peer 207 | print "Waiting for OSPF routers to peer (30 sec) ..." 208 | tenacious 30 nsenter --net="$NS1" -- ping -qc 1 -W 1 10.0.3.10 >/dev/null 209 | dprint "OK" 210 | 211 | dprint "OSPF State & Routing Table $NS2:" 212 | nsenter --net="$NS2" -- echo "show ospf state" | birdc -s "/tmp/$NM/r1-bird.sock" 213 | nsenter --net="$NS2" -- echo "show ospf int" | birdc -s "/tmp/$NM/r1-bird.sock" 214 | nsenter --net="$NS2" -- echo "show ospf neigh" | birdc -s "/tmp/$NM/r1-bird.sock" 215 | nsenter --net="$NS2" -- ip route 216 | 217 | dprint "OSPF State & Routing Table $NS3:" 218 | nsenter --net="$NS4" -- echo "show ospf state" | birdc -s "/tmp/$NM/r2-bird.sock" 219 | nsenter --net="$NS4" -- echo "show ospf int" | birdc -s "/tmp/$NM/r2-bird.sock" 220 | nsenter --net="$NS3" -- echo "show ospf neigh" | birdc -s "/tmp/$NM/r2-bird.sock" 221 | nsenter --net="$NS3" -- ip route 222 | 223 | dprint "OSPF State & Routing Table $NS4:" 224 | nsenter --net="$NS4" -- echo "show ospf state" | birdc -s "/tmp/$NM/r3-bird.sock" 225 | nsenter --net="$NS4" -- echo "show ospf int" | birdc -s "/tmp/$NM/r3-bird.sock" 226 | nsenter --net="$NS4" -- echo "show ospf neigh" | birdc -s "/tmp/$NM/r3-bird.sock" 227 | nsenter --net="$NS4" -- ip route 228 | 229 | print "Starting emitter ..." 230 | nsenter --net="$NS5" -- ./mping -qr -d -i eth0 -t 5 -W 30 225.1.2.3 & 231 | echo $! >> "/tmp/$NM/PIDs" 232 | sleep 1 233 | 234 | if ! nsenter --net="$NS1" -- ./mping -s -d -i eth0 -t 5 -c 10 -w 15 225.1.2.3; then 235 | dprint "PIM Status $NS2" 236 | nsenter --net="$NS2" -- ../src/pimctl -u "/tmp/$NM/r1.sock" show compat detail 237 | dprint "PIM Status $NS3" 238 | nsenter --net="$NS3" -- ../src/pimctl -u "/tmp/$NM/r2.sock" show compat detail 239 | dprint "PIM Status $NS4" 240 | nsenter --net="$NS4" -- ../src/pimctl -u "/tmp/$NM/r3.sock" show compat detail 241 | echo "Failed routing, expected at least 10 multicast ping replies" 242 | FAIL 243 | fi 244 | 245 | OK 246 | --------------------------------------------------------------------------------