├── .gitignore ├── .indent.pro ├── .travis.yml ├── .travis └── run.sh ├── COPYING ├── ChangeLog ├── Makefile.am ├── autogen.sh ├── configure.ac ├── doc ├── .gitignore ├── AUTHORS ├── COPYING ├── Doxyfile.in ├── DoxygenLayout.xml ├── Makefile.am ├── README ├── api │ └── .gitignore ├── autogen.sh ├── configure.ac ├── core.txt ├── doxygen-link.py ├── gen-tags.sh ├── images │ ├── .gitignore │ ├── addressing.png │ ├── attribute_hdr.png │ ├── classful_qdisc.png │ ├── classless_qdisc.png │ ├── classless_qdisc_nbands.png │ ├── icons │ │ ├── README │ │ ├── callouts │ │ │ ├── 1.png │ │ │ ├── 10.png │ │ │ ├── 11.png │ │ │ ├── 12.png │ │ │ ├── 13.png │ │ │ ├── 14.png │ │ │ ├── 15.png │ │ │ ├── 2.png │ │ │ ├── 3.png │ │ │ ├── 4.png │ │ │ ├── 5.png │ │ │ ├── 6.png │ │ │ ├── 7.png │ │ │ ├── 8.png │ │ │ └── 9.png │ │ ├── caution.png │ │ ├── example.png │ │ ├── home.png │ │ ├── important.png │ │ ├── next.png │ │ ├── note.png │ │ ├── prev.png │ │ ├── tip.png │ │ ├── up.png │ │ └── warning.png │ ├── ifinfomsg.png │ ├── library_overview.png │ ├── nlmsgerr.png │ ├── nlmsghdr.png │ ├── qdisc_default.png │ ├── qdisc_mq.png │ ├── tc_obj.png │ └── tc_overview.png ├── index.txt ├── libnl.css ├── m4 │ └── ax_python.m4 ├── resolve-asciidoc-refs.py ├── route.txt ├── src │ ├── hidden.c │ └── toc.c └── stylesheets │ ├── asciidoc-manpage.css │ ├── asciidoc.css │ ├── docbook-xsl.css │ ├── flask-manpage.css │ ├── flask.css │ ├── pygments.css │ ├── slidy.css │ ├── toc2.css │ ├── volnitsky-manpage.css │ ├── volnitsky.css │ ├── xhtml11-quirks.css │ └── xhtml11.css ├── etc ├── classid └── pktloc ├── include ├── Makefile.am ├── linux-private │ └── linux │ │ ├── can │ │ └── netlink.h │ │ ├── fib_rules.h │ │ ├── gen_stats.h │ │ ├── genetlink.h │ │ ├── if.h │ │ ├── if_addr.h │ │ ├── if_arp.h │ │ ├── if_bridge.h │ │ ├── if_ether.h │ │ ├── if_link.h │ │ ├── if_tunnel.h │ │ ├── if_vlan.h │ │ ├── inet_diag.h │ │ ├── ip.h │ │ ├── ip_mp_alg.h │ │ ├── ipv6.h │ │ ├── neighbour.h │ │ ├── netfilter.h │ │ ├── netfilter │ │ ├── nf_conntrack_common.h │ │ ├── nfnetlink.h │ │ ├── nfnetlink_compat.h │ │ ├── nfnetlink_conntrack.h │ │ ├── nfnetlink_log.h │ │ └── nfnetlink_queue.h │ │ ├── netlink.h │ │ ├── pkt_cls.h │ │ ├── pkt_sched.h │ │ ├── rtnetlink.h │ │ ├── snmp.h │ │ ├── sock_diag.h │ │ ├── tc_act │ │ ├── tc_mirred.h │ │ └── tc_skbedit.h │ │ ├── tc_ematch │ │ └── tc_em_meta.h │ │ ├── veth.h │ │ └── xfrm.h ├── netlink-private │ ├── cache-api.h │ ├── genl.h │ ├── netlink.h │ ├── object-api.h │ ├── route │ │ ├── link │ │ │ └── api.h │ │ └── tc-api.h │ ├── socket.h │ ├── tc.h │ └── types.h └── netlink │ ├── .gitignore │ ├── addr.h │ ├── attr.h │ ├── cache-api.h │ ├── cache.h │ ├── cli │ ├── addr.h │ ├── class.h │ ├── cls.h │ ├── ct.h │ ├── exp.h │ ├── link.h │ ├── neigh.h │ ├── qdisc.h │ ├── route.h │ ├── rule.h │ ├── tc.h │ └── utils.h │ ├── data.h │ ├── errno.h │ ├── fib_lookup │ ├── lookup.h │ └── request.h │ ├── genl │ ├── ctrl.h │ ├── family.h │ ├── genl.h │ └── mngt.h │ ├── handlers.h │ ├── hash.h │ ├── hashtable.h │ ├── idiag │ ├── idiagnl.h │ ├── meminfo.h │ ├── msg.h │ ├── req.h │ └── vegasinfo.h │ ├── list.h │ ├── msg.h │ ├── netfilter │ ├── ct.h │ ├── exp.h │ ├── log.h │ ├── log_msg.h │ ├── netfilter.h │ ├── nfnl.h │ ├── queue.h │ └── queue_msg.h │ ├── netlink-compat.h │ ├── netlink-kernel.h │ ├── netlink.h │ ├── object-api.h │ ├── object.h │ ├── route │ ├── act │ │ ├── mirred.h │ │ └── skbedit.h │ ├── action.h │ ├── addr.h │ ├── class.h │ ├── classifier.h │ ├── cls │ │ ├── basic.h │ │ ├── cgroup.h │ │ ├── ematch.h │ │ ├── ematch │ │ │ ├── cmp.h │ │ │ ├── meta.h │ │ │ ├── nbyte.h │ │ │ └── text.h │ │ ├── fw.h │ │ ├── police.h │ │ └── u32.h │ ├── link.h │ ├── link │ │ ├── api.h │ │ ├── bonding.h │ │ ├── bridge.h │ │ ├── can.h │ │ ├── inet.h │ │ ├── inet6.h │ │ ├── info-api.h │ │ ├── ip6tnl.h │ │ ├── ipgre.h │ │ ├── ipip.h │ │ ├── ipvti.h │ │ ├── macvlan.h │ │ ├── sit.h │ │ ├── veth.h │ │ ├── vlan.h │ │ └── vxlan.h │ ├── neighbour.h │ ├── neightbl.h │ ├── nexthop.h │ ├── pktloc.h │ ├── qdisc.h │ ├── qdisc │ │ ├── cbq.h │ │ ├── dsmark.h │ │ ├── fifo.h │ │ ├── fq_codel.h │ │ ├── hfsc.h │ │ ├── htb.h │ │ ├── netem.h │ │ ├── plug.h │ │ ├── prio.h │ │ ├── red.h │ │ ├── sfq.h │ │ └── tbf.h │ ├── route.h │ ├── rtnl.h │ ├── rule.h │ ├── tc-api.h │ └── tc.h │ ├── socket.h │ ├── types.h │ ├── utils.h │ ├── version.h.in │ └── xfrm │ ├── ae.h │ ├── lifetime.h │ ├── sa.h │ ├── selector.h │ ├── sp.h │ └── template.h ├── lib ├── .gitignore ├── Makefile.am ├── addr.c ├── attr.c ├── cache.c ├── cache_mngr.c ├── cache_mngt.c ├── cli │ ├── cls │ │ ├── basic.c │ │ └── cgroup.c │ └── qdisc │ │ ├── bfifo.c │ │ ├── blackhole.c │ │ ├── fq_codel.c │ │ ├── hfsc.c │ │ ├── htb.c │ │ ├── ingress.c │ │ ├── pfifo.c │ │ └── plug.c ├── data.c ├── error.c ├── fib_lookup │ ├── lookup.c │ └── request.c ├── genl │ ├── ctrl.c │ ├── family.c │ ├── genl.c │ └── mngt.c ├── handlers.c ├── hash.c ├── hashtable.c ├── idiag │ ├── idiag.c │ ├── idiag_meminfo_obj.c │ ├── idiag_msg_obj.c │ ├── idiag_req_obj.c │ └── idiag_vegasinfo_obj.c ├── msg.c ├── netfilter │ ├── ct.c │ ├── ct_obj.c │ ├── exp.c │ ├── exp_obj.c │ ├── log.c │ ├── log_msg.c │ ├── log_msg_obj.c │ ├── log_obj.c │ ├── netfilter.c │ ├── nfnl.c │ ├── queue.c │ ├── queue_msg.c │ ├── queue_msg_obj.c │ └── queue_obj.c ├── nl.c ├── object.c ├── route │ ├── .gitignore │ ├── act.c │ ├── act │ │ ├── mirred.c │ │ └── skbedit.c │ ├── addr.c │ ├── class.c │ ├── classid.c │ ├── cls.c │ ├── cls │ │ ├── .gitignore │ │ ├── basic.c │ │ ├── cgroup.c │ │ ├── ematch.c │ │ ├── ematch │ │ │ ├── cmp.c │ │ │ ├── container.c │ │ │ ├── meta.c │ │ │ ├── nbyte.c │ │ │ └── text.c │ │ ├── ematch_grammar.l │ │ ├── ematch_syntax.y │ │ ├── fw.c │ │ ├── police.c │ │ └── u32.c │ ├── link.c │ ├── link │ │ ├── api.c │ │ ├── bonding.c │ │ ├── bridge.c │ │ ├── can.c │ │ ├── dummy.c │ │ ├── ifb.c │ │ ├── inet.c │ │ ├── inet6.c │ │ ├── ip6tnl.c │ │ ├── ipgre.c │ │ ├── ipip.c │ │ ├── ipvti.c │ │ ├── macvlan.c │ │ ├── sit.c │ │ ├── veth.c │ │ ├── vlan.c │ │ └── vxlan.c │ ├── neigh.c │ ├── neightbl.c │ ├── nexthop.c │ ├── pktloc.c │ ├── pktloc_grammar.l │ ├── pktloc_syntax.y │ ├── qdisc.c │ ├── qdisc │ │ ├── blackhole.c │ │ ├── cbq.c │ │ ├── dsmark.c │ │ ├── fifo.c │ │ ├── fq_codel.c │ │ ├── hfsc.c │ │ ├── htb.c │ │ ├── ingress.c │ │ ├── netem.c │ │ ├── plug.c │ │ ├── prio.c │ │ ├── red.c │ │ ├── sfq.c │ │ └── tbf.c │ ├── route.c │ ├── route_obj.c │ ├── route_utils.c │ ├── rtnl.c │ ├── rule.c │ └── tc.c ├── socket.c ├── utils.c ├── version.c └── xfrm │ ├── ae.c │ ├── lifetime.c │ ├── sa.c │ ├── selector.c │ ├── sp.c │ └── template.c ├── libnl-3.0.pc.in ├── libnl-3.sym ├── libnl-cli-3.0.pc.in ├── libnl-cli-3.sym ├── libnl-genl-3.0.pc.in ├── libnl-genl-3.sym ├── libnl-idiag-3.0.pc.in ├── libnl-idiag-3.sym ├── libnl-nf-3.0.pc.in ├── libnl-nf-3.sym ├── libnl-route-3.0.pc.in ├── libnl-route-3.sym ├── libnl-xfrm-3.0.pc.in ├── libnl-xfrm-3.sym ├── m4 ├── .gitignore ├── ax_pkg_swig.m4 ├── ax_python.m4 ├── ax_python_devel.m4 └── ax_swig_python.m4 ├── man ├── Makefile.am ├── genl-ctrl-list.8 ├── nl-classid-lookup.8 ├── nl-pktloc-lookup.8 ├── nl-qdisc-add.8 ├── nl-qdisc-delete.8 └── nl-qdisc-list.8 ├── python ├── .gitignore ├── Makefile.am ├── README ├── doc │ ├── Makefile.am │ ├── conf.py │ ├── core.rst │ ├── index.rst │ ├── route.rst │ └── route_addr.rst ├── examples │ ├── Makefile.am │ ├── iface.py │ ├── nl80211.py │ └── wiphy.py ├── netlink │ ├── Makefile.am │ ├── __init__.py │ ├── capi.i │ ├── core.py │ ├── fixes.h │ ├── genl │ │ ├── Makefile.am │ │ ├── __init__.py │ │ └── capi.i │ ├── route │ │ ├── Makefile.am │ │ ├── __init__.py │ │ ├── address.py │ │ ├── capi.i │ │ ├── link.py │ │ ├── links │ │ │ ├── __init__.py │ │ │ ├── bridge.py │ │ │ ├── dummy.py │ │ │ ├── inet.py │ │ │ └── vlan.py │ │ ├── qdisc │ │ │ ├── __init__.py │ │ │ └── htb.py │ │ └── tc.py │ ├── util.py │ └── utils.h ├── setup.py.in └── tests │ ├── Makefile.am │ └── test-create-bridge.py ├── src ├── .gitignore ├── Makefile.am ├── genl-ctrl-list.c ├── idiag-socket-details.c ├── lib │ ├── Makefile.am │ ├── addr.c │ ├── class.c │ ├── cls.c │ ├── ct.c │ ├── exp.c │ ├── link.c │ ├── neigh.c │ ├── qdisc.c │ ├── route.c │ ├── rule.c │ ├── tc.c │ └── utils.c ├── nf-ct-add.c ├── nf-ct-list.c ├── nf-exp-add.c ├── nf-exp-delete.c ├── nf-exp-list.c ├── nf-log.c ├── nf-monitor.c ├── nf-queue.c ├── nl-addr-add.c ├── nl-addr-delete.c ├── nl-addr-list.c ├── nl-class-add.c ├── nl-class-delete.c ├── nl-class-list.c ├── nl-classid-lookup.c ├── nl-cls-add.c ├── nl-cls-delete.c ├── nl-cls-list.c ├── nl-fib-lookup.c ├── nl-link-enslave.c ├── nl-link-ifindex2name.c ├── nl-link-list.c ├── nl-link-name2ifindex.c ├── nl-link-release.c ├── nl-link-set.c ├── nl-link-stats.c ├── nl-list-caches.c ├── nl-list-sockets.c ├── nl-monitor.c ├── nl-neigh-add.c ├── nl-neigh-delete.c ├── nl-neigh-list.c ├── nl-neightbl-list.c ├── nl-pktloc-lookup.c ├── nl-qdisc-add.c ├── nl-qdisc-delete.c ├── nl-qdisc-list.c ├── nl-route-add.c ├── nl-route-delete.c ├── nl-route-get.c ├── nl-route-list.c ├── nl-rule-list.c ├── nl-tctree-list.c └── nl-util-addr.c └── tests ├── .gitignore ├── Makefile.am ├── check-addr.c ├── check-all.c ├── check-attr.c ├── test-cache-mngr.c ├── test-complex-HTB-with-hash-filters.c ├── test-create-bond.c ├── test-create-bridge.c ├── test-create-ifb.c ├── test-create-ip6tnl.c ├── test-create-ipgre.c ├── test-create-ipip.c ├── test-create-ipvti.c ├── test-create-macvlan.c ├── test-create-sit.c ├── test-create-veth.c ├── test-create-vlan.c ├── test-create-vxlan.c ├── test-delete-link.c ├── test-genl.c ├── test-nf-cache-mngr.c ├── test-socket-creation.c ├── test-u32-filter-with-actions.c └── util.h /.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | .libs 3 | .dirstamp 4 | *.la 5 | *.lo 6 | *.o 7 | *.swp 8 | *.patch 9 | Makefile 10 | Makefile.in 11 | defs.h.in 12 | defs.h.in~ 13 | /lib/stamp-h1 14 | 15 | /libnl-1.pc 16 | /lib/defs.h 17 | cscope.* 18 | /tags 19 | 20 | /aclocal.m4 21 | /autom4te.cache 22 | /build-aux/ 23 | /config.* 24 | /configure 25 | /libtool 26 | /*.pc 27 | -------------------------------------------------------------------------------- /.indent.pro: -------------------------------------------------------------------------------- 1 | -linux -il0 -cs -lp -cbi0 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | compiler: 3 | - gcc 4 | - clang 5 | 6 | before_install: 7 | 8 | script: ./.travis/run.sh 9 | -------------------------------------------------------------------------------- /.travis/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | CFLAGS="-Werror" 6 | 7 | if [ "$CC" = "clang" ]; then 8 | CFLAGS="$CFLAGS -Wno-error=unused-command-line-argument" 9 | fi 10 | 11 | ./autogen.sh 12 | ./configure 13 | make CFLAGS="$CFLAGS" 14 | make CFLAGS="$CFLAGS" check 15 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | # -*- Makefile -*- 2 | 3 | ACLOCAL_AMFLAGS = -I m4 4 | 5 | SUBDIRS = include lib man python tests 6 | 7 | pkgconfig_DATA = libnl-3.0.pc \ 8 | libnl-route-3.0.pc \ 9 | libnl-genl-3.0.pc \ 10 | libnl-nf-3.0.pc \ 11 | libnl-xfrm-3.0.pc \ 12 | libnl-idiag-3.0.pc 13 | 14 | if ENABLE_CLI 15 | SUBDIRS += src 16 | pkgconfig_DATA += libnl-cli-3.0.pc 17 | endif 18 | 19 | 20 | pkgsysconfdir = ${sysconfdir}/libnl 21 | pkgsysconf_DATA = etc/pktloc etc/classid 22 | 23 | EXTRA_DIST = \ 24 | $(pkgsysconf_DATA) \ 25 | libnl-3.sym \ 26 | libnl-cli-3.sym \ 27 | libnl-genl-3.sym \ 28 | libnl-idiag-3.sym \ 29 | libnl-nf-3.sym \ 30 | libnl-route-3.sym \ 31 | libnl-xfrm-3.sym 32 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | die() { 4 | echo "$@" >&2 5 | exit 1 6 | } 7 | 8 | BASEDIR="$(dirname "$0")" 9 | 10 | cd "$BASEDIR" || die "Could not change into base directory $BASEDIR" 11 | 12 | autoreconf -fi || die "Error during autoreconf" 13 | rm -Rf autom4te.cache; 14 | 15 | doc/autogen.sh || die "Error during doc/autogen.sh" 16 | -------------------------------------------------------------------------------- /doc/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | libnl.dict 3 | Doxyfile 4 | /aclocal.m4 5 | /autom4te.cache/ 6 | /build-aux/ 7 | /config.* 8 | /configure 9 | -------------------------------------------------------------------------------- /doc/AUTHORS: -------------------------------------------------------------------------------- 1 | Thomas Graf 2 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | # -*- Makefile -*- 2 | 3 | .PHONY: gendoc api_ref asciidoc 4 | 5 | ASCIIDOCOPTS=-a pygments -a language=c -a icons \ 6 | -a toc2 \ 7 | -a numbered \ 8 | -a imagesdir="./images/" \ 9 | -a iconsdir="./images/icons" \ 10 | -a stylesdir="${abs_srcdir}/stylesheets/" 11 | 12 | EXTRA_DIST = \ 13 | core.txt \ 14 | core.html \ 15 | route.txt \ 16 | route.html \ 17 | index.txt \ 18 | index.html \ 19 | libnl.css \ 20 | stylesheets \ 21 | images \ 22 | api 23 | 24 | dist-hook: 25 | rm -f $(distdir)/aclocal.m4 26 | rm -f $(distdir)/configure 27 | rm -f $(distdir)/configure.in 28 | rm -rf $(distdir)/m4 29 | rm -f $(distdir)/README 30 | rm -f $(distdir)/missing 31 | rm -f $(distdir)/Doxyfile.in 32 | rm -f $(distdir)/Makefile.am 33 | rm -f $(distdir)/Makefile.in 34 | 35 | link_doc: 36 | if LINK_DOC 37 | ./gen-tags.sh > libnl.dict 38 | else 39 | @echo "Warning: Linking to API reference is disabled, check configure output" 40 | endif 41 | 42 | 43 | %.html: %.txt link_doc 44 | ./resolve-asciidoc-refs.py $< > asciidoc.tmp 45 | asciidoc $(ASCIIDOCOPTS) -o $@ asciidoc.tmp 46 | if LINK_DOC 47 | ./doxygen-link.py libnl.dict $@ > asciidoc.tmp 48 | mv asciidoc.tmp $@ 49 | endif 50 | 51 | asciidoc: core.html route.html index.html 52 | 53 | api_ref: 54 | doxygen Doxyfile; 55 | 56 | gendoc: 57 | if GENERATE_DOC 58 | if HAVE_DOXYGEN 59 | $(MAKE) api_ref 60 | else 61 | @echo "Warning: Building of API reference (doxygen) is disabled, check autoconf logs" 62 | endif 63 | if HAVE_ASCIIDOC 64 | $(MAKE) asciidoc 65 | else 66 | @echo "Warning: Building of asciidoc files is disabled, check autoconf logs" 67 | endif 68 | else 69 | @echo "Warning: Building of documentation disabled by user or autoconf" 70 | endif 71 | 72 | clean-local: 73 | rm -f api/* libnl.dict *.html; 74 | -------------------------------------------------------------------------------- /doc/README: -------------------------------------------------------------------------------- 1 | Requirements to build documentation 2 | 3 | mscgen 4 | http://www.mcternan.me.uk/mscgen/ 5 | 6 | mscgen-filter-1.2 7 | http://code.google.com/p/asciidoc-mscgen-filter/ 8 | 9 | asciidoc > 8.6.x 10 | doxygen > 1.8.0 11 | 12 | Building the documentation: 13 | make gendoc 14 | -------------------------------------------------------------------------------- /doc/api/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.png 3 | *.css 4 | *.map 5 | *.md5 6 | *.js 7 | formula.repository 8 | jquery.js 9 | -------------------------------------------------------------------------------- /doc/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | autoreconf -fi; 4 | rm -Rf autom4te.cache; 5 | -------------------------------------------------------------------------------- /doc/doxygen-link.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from __future__ import print_function 4 | import fileinput 5 | import re 6 | import sys 7 | 8 | 9 | rc_script = re.compile(r'\s*(.*\S)?\s*') 10 | 11 | def parse_dict(filename): 12 | links = {} 13 | for line in open(filename, 'r'): 14 | m = re.match('^([^=]+)=([^\n]+)$', line); 15 | if not m: 16 | continue 17 | name = m.group(1) 18 | value = m.group(2) 19 | 20 | # strip leading and trailing whitespace 21 | m = rc_script.match(name) 22 | if m: 23 | name = m.group(1) 24 | 25 | # skip special names 26 | if name == '': 27 | continue 28 | if name == '\\': 29 | continue 30 | 31 | links[name] = "" + name + "" 32 | return links 33 | 34 | links = parse_dict(sys.argv[1]) 35 | 36 | def translate(match): 37 | return links[match.group(1)] 38 | 39 | # match for all names, with word boundaries \b 40 | rc = re.compile(r'\b(' + '|'.join(map(re.escape, sorted(links, reverse=True))) + r')\b') 41 | 42 | for line in open(sys.argv[2], 'r'): 43 | print(rc.sub(translate, line), end='') 44 | -------------------------------------------------------------------------------- /doc/gen-tags.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Based on a script found on the englinemtn-devel mailinglist 5 | # written by Carsten Haitzler 6 | # 7 | 8 | for f in api/group__*.html 9 | do 10 | bf=$(basename $f) 11 | 12 | grep -oE "href=\"$bf#[a-z0-9]+\">[^<]+" $f | 13 | sed 's/href="\([^"]*\)">\([^<]*\)<\/a>/\2=api\/\1/' 14 | done 15 | -------------------------------------------------------------------------------- /doc/images/.gitignore: -------------------------------------------------------------------------------- 1 | core__* 2 | asciidoc__*.png 3 | *.odg 4 | -------------------------------------------------------------------------------- /doc/images/addressing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/addressing.png -------------------------------------------------------------------------------- /doc/images/attribute_hdr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/attribute_hdr.png -------------------------------------------------------------------------------- /doc/images/classful_qdisc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/classful_qdisc.png -------------------------------------------------------------------------------- /doc/images/classless_qdisc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/classless_qdisc.png -------------------------------------------------------------------------------- /doc/images/classless_qdisc_nbands.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/classless_qdisc_nbands.png -------------------------------------------------------------------------------- /doc/images/icons/README: -------------------------------------------------------------------------------- 1 | Replaced the plain DocBook XSL admonition icons with Jimmac's DocBook 2 | icons (http://jimmac.musichall.cz/ikony.php3). I dropped transparency 3 | from the Jimmac icons to get round MS IE and FOP PNG incompatibilies. 4 | 5 | Stuart Rackham 6 | -------------------------------------------------------------------------------- /doc/images/icons/callouts/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/callouts/1.png -------------------------------------------------------------------------------- /doc/images/icons/callouts/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/callouts/10.png -------------------------------------------------------------------------------- /doc/images/icons/callouts/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/callouts/11.png -------------------------------------------------------------------------------- /doc/images/icons/callouts/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/callouts/12.png -------------------------------------------------------------------------------- /doc/images/icons/callouts/13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/callouts/13.png -------------------------------------------------------------------------------- /doc/images/icons/callouts/14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/callouts/14.png -------------------------------------------------------------------------------- /doc/images/icons/callouts/15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/callouts/15.png -------------------------------------------------------------------------------- /doc/images/icons/callouts/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/callouts/2.png -------------------------------------------------------------------------------- /doc/images/icons/callouts/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/callouts/3.png -------------------------------------------------------------------------------- /doc/images/icons/callouts/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/callouts/4.png -------------------------------------------------------------------------------- /doc/images/icons/callouts/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/callouts/5.png -------------------------------------------------------------------------------- /doc/images/icons/callouts/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/callouts/6.png -------------------------------------------------------------------------------- /doc/images/icons/callouts/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/callouts/7.png -------------------------------------------------------------------------------- /doc/images/icons/callouts/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/callouts/8.png -------------------------------------------------------------------------------- /doc/images/icons/callouts/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/callouts/9.png -------------------------------------------------------------------------------- /doc/images/icons/caution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/caution.png -------------------------------------------------------------------------------- /doc/images/icons/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/example.png -------------------------------------------------------------------------------- /doc/images/icons/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/home.png -------------------------------------------------------------------------------- /doc/images/icons/important.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/important.png -------------------------------------------------------------------------------- /doc/images/icons/next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/next.png -------------------------------------------------------------------------------- /doc/images/icons/note.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/note.png -------------------------------------------------------------------------------- /doc/images/icons/prev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/prev.png -------------------------------------------------------------------------------- /doc/images/icons/tip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/tip.png -------------------------------------------------------------------------------- /doc/images/icons/up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/up.png -------------------------------------------------------------------------------- /doc/images/icons/warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/icons/warning.png -------------------------------------------------------------------------------- /doc/images/ifinfomsg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/ifinfomsg.png -------------------------------------------------------------------------------- /doc/images/library_overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/library_overview.png -------------------------------------------------------------------------------- /doc/images/nlmsgerr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/nlmsgerr.png -------------------------------------------------------------------------------- /doc/images/nlmsghdr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/nlmsghdr.png -------------------------------------------------------------------------------- /doc/images/qdisc_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/qdisc_default.png -------------------------------------------------------------------------------- /doc/images/qdisc_mq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/qdisc_mq.png -------------------------------------------------------------------------------- /doc/images/tc_obj.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/tc_obj.png -------------------------------------------------------------------------------- /doc/images/tc_overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/doc/images/tc_overview.png -------------------------------------------------------------------------------- /doc/index.txt: -------------------------------------------------------------------------------- 1 | Documentation Overview - libnl Suite 2 | ==================================== 3 | 4 | == Libraries 5 | 6 | image:library_overview.png["Library Hierarchy"] 7 | 8 | link:core.html[Netlink Library] (libnl):: 9 | Socket handling, sending and receiving, message construction and parsing, ... 10 | 11 | link:route.html[Routing Family Library] (libnl-route):: 12 | Adresses, links, neighbours, routing, traffic control, neighbour tables, ... 13 | 14 | Netfilter Library (libnl-nf):: 15 | Connection tracking, logging, queueing 16 | 17 | Generic Netlink Library (libnl-genl):: 18 | Controller API, family and command registration 19 | 20 | == Python Packages 21 | - netlink.core 22 | - netlink.route.link 23 | -------------------------------------------------------------------------------- /doc/resolve-asciidoc-refs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import fileinput 4 | import re 5 | import sys 6 | 7 | refs = {} 8 | complete_file = "" 9 | 10 | for line in open(sys.argv[1], 'r'): 11 | complete_file += line 12 | 13 | for m in re.findall('\[\[(.+)\]\]\n=+ ([^\n]+)', complete_file): 14 | ref, title = m 15 | refs["<<" + ref + ">>"] = "<<" + ref + ", " + title + ">>" 16 | 17 | def translate(match): 18 | try: 19 | return refs[match.group(0)] 20 | except KeyError: 21 | return "" 22 | 23 | rc = re.compile('|'.join(map(re.escape, sorted(refs, reverse=True)))) 24 | for line in open(sys.argv[1], 'r'): 25 | print rc.sub(translate, line), 26 | -------------------------------------------------------------------------------- /doc/src/hidden.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \cond skip 3 | * vim:syntax=doxygen 4 | * \endcond 5 | 6 | \page auto_ack_warning Disabling Auto-ACK 7 | 8 | \attention Disabling Auto-ACK (nl_socket_disable_auto_ack()) will cause this 9 | function to return immediately after sending the netlink message. 10 | The function will not wait for an eventual error message. It is 11 | the responsibility of the caller to handle any error messages or 12 | ACKs returned. 13 | 14 | \page pointer_lifetime_warning Pointer Lifetime 15 | 16 | \attention The reference counter of the returned object is not incremented. 17 | Therefore, the returned pointer is only valid during the lifetime 18 | of the parent object. Increment the reference counter if the object 19 | is supposed to stay around after the parent object was freed. 20 | 21 | \page private_struct Private Structure 22 | 23 | \note The definition of this structure is private to allow modification 24 | without breaking API. Use the designated accessor functions to 25 | access individual object attributes. 26 | 27 | \page read_only_attribute Read-Only Attribute 28 | 29 | \note The attribute this accessor is modifying is a read-only attribute 30 | which can not be modified in the kernel. Any changes to the 31 | attribute only have an effect on the local copy of the object. The 32 | accessor function is provided solely for the purpose of creating 33 | objects for comparison and filtering. 34 | 35 | \page low_level_api Low Level API 36 | 37 | \note This is a low level API function. A high level function implementing 38 | the same functionality with a simplified usage pattern exists. This 39 | function is available as an alternative if the default library 40 | behaviour is not desirable. 41 | 42 | */ 43 | -------------------------------------------------------------------------------- /doc/src/toc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * \cond skip 3 | * vim:syntax=doxygen 4 | * \endcond 5 | 6 | \mainpage 7 | 8 | \section main_intro Introduction 9 | 10 | libnl is a set of libraries to deal with the netlink protocol and some 11 | of the high level protocols implemented on top of it. The goal is to 12 | provide APIs on different levels of abstraction. The core library libnl 13 | provides a fundamental set of functions to deal with sockets, construct 14 | messages, and send/receive those messages. Additional high level interfaces 15 | for several individual netlink protocols are provided in separate 16 | libraries (e.g. "nl-route", "nl-genl", ...). 17 | 18 | The library is designed to ensure that all components are optional, i.e. 19 | even though the core library provides a caching system which allows to 20 | easly manage objects of any kind, no application is required to use this 21 | caching system if it has no need for it. 22 | 23 | The library was developed and tested on 2.6.x and 3.x kernel releases. It 24 | may or may not work with older kernel series. Also, although all netlink 25 | protocols are required to maintain backwards compatibility, this has not 26 | always achieved and undesired side effects can occur if a recent libnl 27 | version is used with a considerably older kernel. 28 | 29 | \section main_toc Table of Contents 30 | 31 | \section main_trees GIT Trees 32 | 33 | \subsection tree_dev Development Tree 34 | 35 | @code 36 | git://git.infradead.org/users/tgr/libnl.git 37 | @endcode 38 | - Web: http://git.infradead.org/users/tgr/libnl.git 39 | 40 | \section main_website Website 41 | 42 | - http://www.infradead.org/~tgr/libnl/ 43 | 44 | \section main_mailinglist Mailinglist 45 | 46 | Please post questions and patches to the libnl mailinglist: 47 | 48 | @code 49 | libnl@lists.infradead.org 50 | @endcode 51 | 52 | - Archives: http://canuck.infradead.org/pipermail/libnl/ 53 | 54 | */ 55 | -------------------------------------------------------------------------------- /doc/stylesheets/asciidoc-manpage.css: -------------------------------------------------------------------------------- 1 | /* Overrides for manpage documents */ 2 | h1 { 3 | padding-top: 0.5em; 4 | padding-bottom: 0.5em; 5 | border-top: 2px solid silver; 6 | border-bottom: 2px solid silver; 7 | } 8 | h2 { 9 | border-style: none; 10 | } 11 | div.sectionbody { 12 | margin-left: 3em; 13 | } 14 | 15 | @media print { 16 | div#toc { display: none; } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /doc/stylesheets/flask-manpage.css: -------------------------------------------------------------------------------- 1 | /* Empty placeholder file */ 2 | -------------------------------------------------------------------------------- /doc/stylesheets/toc2.css: -------------------------------------------------------------------------------- 1 | @media screen { 2 | body { 3 | max-width: 50em; /* approximately 80 characters wide */ 4 | margin-left: 16em; 5 | } 6 | 7 | #toc { 8 | position: fixed; 9 | top: 0; 10 | left: 0; 11 | bottom: 0; 12 | width: 13em; 13 | padding: 0.5em; 14 | padding-bottom: 1.5em; 15 | margin: 0; 16 | overflow: auto; 17 | border-right: 3px solid #f8f8f8; 18 | } 19 | 20 | #toc .toclevel1 { 21 | margin-top: 0.5em; 22 | } 23 | 24 | #toc .toclevel2 { 25 | margin-top: 0.25em; 26 | display: list-item; 27 | /* OLD color: #aaaaaa; */ 28 | color: #990000; 29 | } 30 | 31 | #toctitle { 32 | margin-top: 0.5em; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /doc/stylesheets/volnitsky-manpage.css: -------------------------------------------------------------------------------- 1 | /* Empty placeholder file */ 2 | -------------------------------------------------------------------------------- /doc/stylesheets/xhtml11-quirks.css: -------------------------------------------------------------------------------- 1 | /* Workarounds for IE6's broken and incomplete CSS2. */ 2 | 3 | div.sidebar-content { 4 | background: #ffffee; 5 | border: 1px solid silver; 6 | padding: 0.5em; 7 | } 8 | div.sidebar-title, div.image-title { 9 | color: #527bbd; 10 | font-family: sans-serif; 11 | font-weight: bold; 12 | margin-top: 0.0em; 13 | margin-bottom: 0.5em; 14 | } 15 | 16 | div.listingblock div.content { 17 | border: 1px solid silver; 18 | background: #f4f4f4; 19 | padding: 0.5em; 20 | } 21 | 22 | div.quoteblock-attribution { 23 | padding-top: 0.5em; 24 | text-align: right; 25 | } 26 | 27 | pre.verseblock-content { 28 | font-family: inherit; 29 | } 30 | div.verseblock-attribution { 31 | padding-top: 0.75em; 32 | text-align: left; 33 | } 34 | 35 | div.exampleblock-content { 36 | border-left: 3px solid #dddddd; 37 | padding-left: 0.5em; 38 | } 39 | 40 | div.imageblock.latex div.image-title { margin-top: 0.5em; } 41 | 42 | /* IE6 sets dynamically generated links as visited. */ 43 | div#toc a:visited { color: blue; } 44 | -------------------------------------------------------------------------------- /etc/classid: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # 3 | # ClassID <-> Name Translation Table 4 | # 5 | # This file can be used to assign names to classids for easier reference 6 | # in all libnl tools. 7 | # 8 | # Format: 9 | # # qdisc definition 10 | # # class deifnition 11 | # # class definition referencing an 12 | # existing qdisc definition. 13 | # 14 | # Example: 15 | # 1: top # top -> 1:0 16 | # top:1 interactive # interactive -> 1:1 17 | # top:2 www # www -> 1:2 18 | # top:3 bulk # bulk -> 1:3 19 | # 2:1 test_class # test_class -> 2:1 20 | # 21 | # Illegal Example: 22 | # 30:1 classD 23 | # classD:2 invalidClass # classD refers to a class, not a qdisc 24 | # 25 | ############################################################################### 26 | 27 | # 28 | 29 | # Reserved default classids 30 | 0:0 none 31 | ffff:ffff root 32 | ffff:fff1 ingress 33 | 34 | # 35 | # List your classid definitions here: 36 | # 37 | 38 | 39 | 40 | ############################################################################### 41 | # List of auto-generated classids 42 | # 43 | # DO NOT ADD CLASSID DEFINITIONS BELOW THIS LINE 44 | # 45 | # 46 | -------------------------------------------------------------------------------- /etc/pktloc: -------------------------------------------------------------------------------- 1 | # 2 | # Location definitions for packet matching 3 | # 4 | 5 | # name alignment offset mask shift 6 | ip.version u8 net+0 0xF0 4 7 | ip.hdrlen u8 net+0 0x0F 8 | ip.diffserv u8 net+1 9 | ip.length u16 net+2 10 | ip.id u16 net+4 11 | ip.flag.res u8 net+6 0xff 7 12 | ip.df u8 net+6 0x40 6 13 | ip.mf u8 net+6 0x20 5 14 | ip.offset u16 net+6 0x1FFF 15 | ip.ttl u8 net+8 16 | ip.proto u8 net+9 17 | ip.chksum u16 net+10 18 | ip.src u32 net+12 19 | ip.dst u32 net+16 20 | 21 | # if ip.ihl > 5 22 | ip.opts u32 net+20 23 | 24 | 25 | # 26 | # IP version 6 27 | # 28 | # name alignment offset mask shift 29 | ip6.version u8 net+0 0xF0 4 30 | ip6.tc u16 net+0 0xFF0 4 31 | ip6.flowlabel u32 net+0 0xFFFFF 32 | ip6.length u16 net+4 33 | ip6.nexthdr u8 net+6 34 | ip6.hoplimit u8 net+7 35 | ip6.src 16 net+8 36 | ip6.dst 16 net+24 37 | 38 | # 39 | # Transmission Control Protocol (TCP) 40 | # 41 | # name alignment offset mask shift 42 | tcp.sport u16 tcp+0 43 | tcp.dport u16 tcp+2 44 | tcp.seq u32 tcp+4 45 | tcp.ack u32 tcp+8 46 | 47 | # Data offset (4 bits) 48 | tcp.off u8 tcp+12 0xF0 4 49 | 50 | # Reserved [0 0 0] (3 bits) 51 | tcp.reserved u8 tcp+12 0x04 1 52 | 53 | # ECN [N C E] (3 bits) 54 | tcp.ecn u16 tcp+12 0x01C00 6 55 | 56 | # Individual TCP flags (0|1) (6 bits in total) 57 | tcp.flag.urg u8 tcp+13 0x20 5 58 | tcp.flag.ack u8 tcp+13 0x10 4 59 | tcp.flag.psh u8 tcp+13 0x08 3 60 | tcp.flag.rst u8 tcp+13 0x04 2 61 | tcp.flag.syn u8 tcp+13 0x02 1 62 | tcp.flag.fin u8 tcp+13 0x01 63 | 64 | tcp.win u16 tcp+14 65 | tcp.csum u16 tcp+16 66 | tcp.urg u16 tcp+18 67 | tcp.opts u32 tcp+20 68 | 69 | # 70 | # User Datagram Protocol (UDP) 71 | # 72 | # name alignment offset mask shift 73 | udp.sport u16 tcp+0 74 | udp.dport u16 tcp+2 75 | udp.length u16 tcp+4 76 | udp.csum u16 tcp+6 77 | -------------------------------------------------------------------------------- /include/linux-private/linux/fib_rules.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_FIB_RULES_H 2 | #define __LINUX_FIB_RULES_H 3 | 4 | /* rule is permanent, and cannot be deleted */ 5 | #define FIB_RULE_PERMANENT 0x00000001 6 | #define FIB_RULE_INVERT 0x00000002 7 | #define FIB_RULE_UNRESOLVED 0x00000004 8 | #define FIB_RULE_IIF_DETACHED 0x00000008 9 | #define FIB_RULE_DEV_DETACHED FIB_RULE_IIF_DETACHED 10 | #define FIB_RULE_OIF_DETACHED 0x00000010 11 | 12 | /* try to find source address in routing lookups */ 13 | #define FIB_RULE_FIND_SADDR 0x00010000 14 | 15 | struct fib_rule_hdr { 16 | __u8 family; 17 | __u8 dst_len; 18 | __u8 src_len; 19 | __u8 tos; 20 | 21 | __u8 table; 22 | __u8 res1; /* reserved */ 23 | __u8 res2; /* reserved */ 24 | __u8 action; 25 | 26 | __u32 flags; 27 | }; 28 | 29 | enum { 30 | FRA_UNSPEC, 31 | FRA_DST, /* destination address */ 32 | FRA_SRC, /* source address */ 33 | FRA_IIFNAME, /* interface name */ 34 | #define FRA_IFNAME FRA_IIFNAME 35 | FRA_GOTO, /* target to jump to (FR_ACT_GOTO) */ 36 | FRA_UNUSED2, 37 | FRA_PRIORITY, /* priority/preference */ 38 | FRA_UNUSED3, 39 | FRA_UNUSED4, 40 | FRA_UNUSED5, 41 | FRA_FWMARK, /* mark */ 42 | FRA_FLOW, /* flow/class id */ 43 | FRA_UNUSED6, 44 | FRA_UNUSED7, 45 | FRA_UNUSED8, 46 | FRA_TABLE, /* Extended table id */ 47 | FRA_FWMASK, /* mask for netfilter mark */ 48 | FRA_OIFNAME, 49 | __FRA_MAX 50 | }; 51 | 52 | #define FRA_MAX (__FRA_MAX - 1) 53 | 54 | enum { 55 | FR_ACT_UNSPEC, 56 | FR_ACT_TO_TBL, /* Pass to fixed table */ 57 | FR_ACT_GOTO, /* Jump to another rule */ 58 | FR_ACT_NOP, /* No operation */ 59 | FR_ACT_RES3, 60 | FR_ACT_RES4, 61 | FR_ACT_BLACKHOLE, /* Drop without notification */ 62 | FR_ACT_UNREACHABLE, /* Drop with ENETUNREACH */ 63 | FR_ACT_PROHIBIT, /* Drop with EACCES */ 64 | __FR_ACT_MAX, 65 | }; 66 | 67 | #define FR_ACT_MAX (__FR_ACT_MAX - 1) 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /include/linux-private/linux/gen_stats.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_GEN_STATS_H 2 | #define __LINUX_GEN_STATS_H 3 | 4 | #include 5 | 6 | enum { 7 | TCA_STATS_UNSPEC, 8 | TCA_STATS_BASIC, 9 | TCA_STATS_RATE_EST, 10 | TCA_STATS_QUEUE, 11 | TCA_STATS_APP, 12 | __TCA_STATS_MAX, 13 | }; 14 | #define TCA_STATS_MAX (__TCA_STATS_MAX - 1) 15 | 16 | /** 17 | * struct gnet_stats_basic - byte/packet throughput statistics 18 | * @bytes: number of seen bytes 19 | * @packets: number of seen packets 20 | */ 21 | struct gnet_stats_basic { 22 | __u64 bytes; 23 | __u32 packets; 24 | }; 25 | struct gnet_stats_basic_packed { 26 | __u64 bytes; 27 | __u32 packets; 28 | } __attribute__ ((packed)); 29 | 30 | /** 31 | * struct gnet_stats_rate_est - rate estimator 32 | * @bps: current byte rate 33 | * @pps: current packet rate 34 | */ 35 | struct gnet_stats_rate_est { 36 | __u32 bps; 37 | __u32 pps; 38 | }; 39 | 40 | /** 41 | * struct gnet_stats_queue - queuing statistics 42 | * @qlen: queue length 43 | * @backlog: backlog size of queue 44 | * @drops: number of dropped packets 45 | * @requeues: number of requeues 46 | * @overlimits: number of enqueues over the limit 47 | */ 48 | struct gnet_stats_queue { 49 | __u32 qlen; 50 | __u32 backlog; 51 | __u32 drops; 52 | __u32 requeues; 53 | __u32 overlimits; 54 | }; 55 | 56 | /** 57 | * struct gnet_estimator - rate estimator configuration 58 | * @interval: sampling period 59 | * @ewma_log: the log of measurement window weight 60 | */ 61 | struct gnet_estimator { 62 | signed char interval; 63 | unsigned char ewma_log; 64 | }; 65 | 66 | 67 | #endif /* __LINUX_GEN_STATS_H */ 68 | -------------------------------------------------------------------------------- /include/linux-private/linux/if_addr.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_IF_ADDR_H 2 | #define __LINUX_IF_ADDR_H 3 | 4 | #include 5 | #include 6 | 7 | struct ifaddrmsg { 8 | __u8 ifa_family; 9 | __u8 ifa_prefixlen; /* The prefix length */ 10 | __u8 ifa_flags; /* Flags */ 11 | __u8 ifa_scope; /* Address scope */ 12 | __u32 ifa_index; /* Link index */ 13 | }; 14 | 15 | /* 16 | * Important comment: 17 | * IFA_ADDRESS is prefix address, rather than local interface address. 18 | * It makes no difference for normally configured broadcast interfaces, 19 | * but for point-to-point IFA_ADDRESS is DESTINATION address, 20 | * local address is supplied in IFA_LOCAL attribute. 21 | * 22 | * IFA_FLAGS is a u32 attribute that extends the u8 field ifa_flags. 23 | * If present, the value from struct ifaddrmsg will be ignored. 24 | */ 25 | enum { 26 | IFA_UNSPEC, 27 | IFA_ADDRESS, 28 | IFA_LOCAL, 29 | IFA_LABEL, 30 | IFA_BROADCAST, 31 | IFA_ANYCAST, 32 | IFA_CACHEINFO, 33 | IFA_MULTICAST, 34 | IFA_FLAGS, 35 | __IFA_MAX, 36 | }; 37 | 38 | #define IFA_MAX (__IFA_MAX - 1) 39 | 40 | /* ifa_flags */ 41 | #define IFA_F_SECONDARY 0x01 42 | #define IFA_F_TEMPORARY IFA_F_SECONDARY 43 | 44 | #define IFA_F_NODAD 0x02 45 | #define IFA_F_OPTIMISTIC 0x04 46 | #define IFA_F_DADFAILED 0x08 47 | #define IFA_F_HOMEADDRESS 0x10 48 | #define IFA_F_DEPRECATED 0x20 49 | #define IFA_F_TENTATIVE 0x40 50 | #define IFA_F_PERMANENT 0x80 51 | #define IFA_F_MANAGETEMPADDR 0x100 52 | #define IFA_F_NOPREFIXROUTE 0x200 53 | 54 | struct ifa_cacheinfo { 55 | __u32 ifa_prefered; 56 | __u32 ifa_valid; 57 | __u32 cstamp; /* created timestamp, hundredths of seconds */ 58 | __u32 tstamp; /* updated timestamp, hundredths of seconds */ 59 | }; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /include/linux-private/linux/if_vlan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * VLAN An implementation of 802.1Q VLAN tagging. 3 | * 4 | * Authors: Ben Greear 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 9 | * 2 of the License, or (at your option) any later version. 10 | * 11 | */ 12 | 13 | #ifndef _LINUX_IF_VLAN_H_ 14 | #define _LINUX_IF_VLAN_H_ 15 | 16 | /* VLAN IOCTLs are found in sockios.h */ 17 | 18 | /* Passed in vlan_ioctl_args structure to determine behaviour. */ 19 | enum vlan_ioctl_cmds { 20 | ADD_VLAN_CMD, 21 | DEL_VLAN_CMD, 22 | SET_VLAN_INGRESS_PRIORITY_CMD, 23 | SET_VLAN_EGRESS_PRIORITY_CMD, 24 | GET_VLAN_INGRESS_PRIORITY_CMD, 25 | GET_VLAN_EGRESS_PRIORITY_CMD, 26 | SET_VLAN_NAME_TYPE_CMD, 27 | SET_VLAN_FLAG_CMD, 28 | GET_VLAN_REALDEV_NAME_CMD, /* If this works, you know it's a VLAN device, btw */ 29 | GET_VLAN_VID_CMD /* Get the VID of this VLAN (specified by name) */ 30 | }; 31 | 32 | enum vlan_flags { 33 | VLAN_FLAG_REORDER_HDR = 0x1, 34 | VLAN_FLAG_GVRP = 0x2, 35 | VLAN_FLAG_LOOSE_BINDING = 0x4, 36 | }; 37 | 38 | enum vlan_name_types { 39 | VLAN_NAME_TYPE_PLUS_VID, /* Name will look like: vlan0005 */ 40 | VLAN_NAME_TYPE_RAW_PLUS_VID, /* name will look like: eth1.0005 */ 41 | VLAN_NAME_TYPE_PLUS_VID_NO_PAD, /* Name will look like: vlan5 */ 42 | VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD, /* Name will look like: eth0.5 */ 43 | VLAN_NAME_TYPE_HIGHEST 44 | }; 45 | 46 | struct vlan_ioctl_args { 47 | int cmd; /* Should be one of the vlan_ioctl_cmds enum above. */ 48 | char device1[24]; 49 | 50 | union { 51 | char device2[24]; 52 | int VID; 53 | unsigned int skb_priority; 54 | unsigned int name_type; 55 | unsigned int bind_type; 56 | unsigned int flag; /* Matches vlan_dev_info flags */ 57 | } u; 58 | 59 | short vlan_qos; 60 | }; 61 | 62 | #endif /* !(_LINUX_IF_VLAN_H_) */ 63 | -------------------------------------------------------------------------------- /include/linux-private/linux/ip_mp_alg.h: -------------------------------------------------------------------------------- 1 | /* ip_mp_alg.h: IPV4 multipath algorithm support, user-visible values. 2 | * 3 | * Copyright (C) 2004, 2005 Einar Lueck 4 | * Copyright (C) 2005 David S. Miller 5 | */ 6 | 7 | #ifndef _LINUX_IP_MP_ALG_H 8 | #define _LINUX_IP_MP_ALG_H 9 | 10 | enum ip_mp_alg { 11 | IP_MP_ALG_NONE, 12 | IP_MP_ALG_RR, 13 | IP_MP_ALG_DRR, 14 | IP_MP_ALG_RANDOM, 15 | IP_MP_ALG_WRANDOM, 16 | __IP_MP_ALG_MAX 17 | }; 18 | 19 | #define IP_MP_ALG_MAX (__IP_MP_ALG_MAX - 1) 20 | 21 | #endif /* _LINUX_IP_MP_ALG_H */ 22 | 23 | -------------------------------------------------------------------------------- /include/linux-private/linux/netfilter.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_NETFILTER_H 2 | #define __LINUX_NETFILTER_H 3 | 4 | #include 5 | 6 | /* Responses from hook functions. */ 7 | #define NF_DROP 0 8 | #define NF_ACCEPT 1 9 | #define NF_STOLEN 2 10 | #define NF_QUEUE 3 11 | #define NF_REPEAT 4 12 | #define NF_STOP 5 13 | #define NF_MAX_VERDICT NF_STOP 14 | 15 | /* we overload the higher bits for encoding auxiliary data such as the queue 16 | * number. Not nice, but better than additional function arguments. */ 17 | #define NF_VERDICT_MASK 0x0000ffff 18 | #define NF_VERDICT_BITS 16 19 | 20 | #define NF_VERDICT_QMASK 0xffff0000 21 | #define NF_VERDICT_QBITS 16 22 | 23 | #define NF_QUEUE_NR(x) ((((x) << NF_VERDICT_BITS) & NF_VERDICT_QMASK) | NF_QUEUE) 24 | 25 | /* Generic cache responses from hook functions. 26 | <= 0x2000 is used for protocol-flags. */ 27 | #define NFC_UNKNOWN 0x4000 28 | #define NFC_ALTERED 0x8000 29 | 30 | enum nf_inet_hooks { 31 | NF_INET_PRE_ROUTING, 32 | NF_INET_LOCAL_IN, 33 | NF_INET_FORWARD, 34 | NF_INET_LOCAL_OUT, 35 | NF_INET_POST_ROUTING, 36 | NF_INET_NUMHOOKS 37 | }; 38 | 39 | enum { 40 | NFPROTO_UNSPEC = 0, 41 | NFPROTO_IPV4 = 2, 42 | NFPROTO_ARP = 3, 43 | NFPROTO_BRIDGE = 7, 44 | NFPROTO_IPV6 = 10, 45 | NFPROTO_DECNET = 12, 46 | NFPROTO_NUMPROTO, 47 | }; 48 | 49 | union nf_inet_addr { 50 | __u32 all[4]; 51 | __be32 ip; 52 | __be32 ip6[4]; 53 | struct in_addr in; 54 | struct in6_addr in6; 55 | }; 56 | 57 | #endif /*__LINUX_NETFILTER_H*/ 58 | -------------------------------------------------------------------------------- /include/linux-private/linux/netfilter/nfnetlink.h: -------------------------------------------------------------------------------- 1 | #ifndef _UAPI_NFNETLINK_H 2 | #define _UAPI_NFNETLINK_H 3 | #include 4 | #include 5 | 6 | enum nfnetlink_groups { 7 | NFNLGRP_NONE, 8 | #define NFNLGRP_NONE NFNLGRP_NONE 9 | NFNLGRP_CONNTRACK_NEW, 10 | #define NFNLGRP_CONNTRACK_NEW NFNLGRP_CONNTRACK_NEW 11 | NFNLGRP_CONNTRACK_UPDATE, 12 | #define NFNLGRP_CONNTRACK_UPDATE NFNLGRP_CONNTRACK_UPDATE 13 | NFNLGRP_CONNTRACK_DESTROY, 14 | #define NFNLGRP_CONNTRACK_DESTROY NFNLGRP_CONNTRACK_DESTROY 15 | NFNLGRP_CONNTRACK_EXP_NEW, 16 | #define NFNLGRP_CONNTRACK_EXP_NEW NFNLGRP_CONNTRACK_EXP_NEW 17 | NFNLGRP_CONNTRACK_EXP_UPDATE, 18 | #define NFNLGRP_CONNTRACK_EXP_UPDATE NFNLGRP_CONNTRACK_EXP_UPDATE 19 | NFNLGRP_CONNTRACK_EXP_DESTROY, 20 | #define NFNLGRP_CONNTRACK_EXP_DESTROY NFNLGRP_CONNTRACK_EXP_DESTROY 21 | __NFNLGRP_MAX, 22 | }; 23 | #define NFNLGRP_MAX (__NFNLGRP_MAX - 1) 24 | 25 | /* General form of address family dependent message. 26 | */ 27 | struct nfgenmsg { 28 | __u8 nfgen_family; /* AF_xxx */ 29 | __u8 version; /* nfnetlink version */ 30 | __be16 res_id; /* resource id */ 31 | }; 32 | 33 | #define NFNETLINK_V0 0 34 | 35 | /* netfilter netlink message types are split in two pieces: 36 | * 8 bit subsystem, 8bit operation. 37 | */ 38 | 39 | #define NFNL_SUBSYS_ID(x) ((x & 0xff00) >> 8) 40 | #define NFNL_MSG_TYPE(x) (x & 0x00ff) 41 | 42 | /* No enum here, otherwise __stringify() trick of MODULE_ALIAS_NFNL_SUBSYS() 43 | * won't work anymore */ 44 | #define NFNL_SUBSYS_NONE 0 45 | #define NFNL_SUBSYS_CTNETLINK 1 46 | #define NFNL_SUBSYS_CTNETLINK_EXP 2 47 | #define NFNL_SUBSYS_QUEUE 3 48 | #define NFNL_SUBSYS_ULOG 4 49 | #define NFNL_SUBSYS_OSF 5 50 | #define NFNL_SUBSYS_IPSET 6 51 | #define NFNL_SUBSYS_ACCT 7 52 | #define NFNL_SUBSYS_CTNETLINK_TIMEOUT 8 53 | #define NFNL_SUBSYS_CTHELPER 9 54 | #define NFNL_SUBSYS_COUNT 10 55 | 56 | #endif /* _UAPI_NFNETLINK_H */ 57 | -------------------------------------------------------------------------------- /include/linux-private/linux/sock_diag.h: -------------------------------------------------------------------------------- 1 | #ifndef _UAPI__SOCK_DIAG_H__ 2 | #define _UAPI__SOCK_DIAG_H__ 3 | 4 | #include 5 | 6 | #define SOCK_DIAG_BY_FAMILY 20 7 | 8 | struct sock_diag_req { 9 | __u8 sdiag_family; 10 | __u8 sdiag_protocol; 11 | }; 12 | 13 | enum { 14 | SK_MEMINFO_RMEM_ALLOC, 15 | SK_MEMINFO_RCVBUF, 16 | SK_MEMINFO_WMEM_ALLOC, 17 | SK_MEMINFO_SNDBUF, 18 | SK_MEMINFO_FWD_ALLOC, 19 | SK_MEMINFO_WMEM_QUEUED, 20 | SK_MEMINFO_OPTMEM, 21 | SK_MEMINFO_BACKLOG, 22 | 23 | SK_MEMINFO_VARS, 24 | }; 25 | 26 | #endif /* _UAPI__SOCK_DIAG_H__ */ 27 | -------------------------------------------------------------------------------- /include/linux-private/linux/tc_act/tc_mirred.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_TC_MIR_H 2 | #define __LINUX_TC_MIR_H 3 | 4 | #include 5 | #include 6 | 7 | #define TCA_ACT_MIRRED 8 8 | #define TCA_EGRESS_REDIR 1 /* packet redirect to EGRESS*/ 9 | #define TCA_EGRESS_MIRROR 2 /* mirror packet to EGRESS */ 10 | #define TCA_INGRESS_REDIR 3 /* packet redirect to INGRESS*/ 11 | #define TCA_INGRESS_MIRROR 4 /* mirror packet to INGRESS */ 12 | 13 | struct tc_mirred { 14 | tc_gen; 15 | int eaction; /* one of IN/EGRESS_MIRROR/REDIR */ 16 | __u32 ifindex; /* ifindex of egress port */ 17 | }; 18 | 19 | enum { 20 | TCA_MIRRED_UNSPEC, 21 | TCA_MIRRED_TM, 22 | TCA_MIRRED_PARMS, 23 | __TCA_MIRRED_MAX 24 | }; 25 | #define TCA_MIRRED_MAX (__TCA_MIRRED_MAX - 1) 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /include/linux-private/linux/tc_act/tc_skbedit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008, Intel Corporation. 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms and conditions of the GNU General Public License, 6 | * version 2, as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope it will be useful, but WITHOUT 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 | * more details. 12 | * 13 | * You should have received a copy of the GNU General Public License along with 14 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple 15 | * Place - Suite 330, Boston, MA 02111-1307 USA. 16 | * 17 | * Author: Alexander Duyck 18 | */ 19 | 20 | #ifndef __LINUX_TC_SKBEDIT_H 21 | #define __LINUX_TC_SKBEDIT_H 22 | 23 | #include 24 | 25 | #define TCA_ACT_SKBEDIT 11 26 | 27 | #define SKBEDIT_F_PRIORITY 0x1 28 | #define SKBEDIT_F_QUEUE_MAPPING 0x2 29 | #define SKBEDIT_F_MARK 0x4 30 | 31 | struct tc_skbedit { 32 | tc_gen; 33 | }; 34 | 35 | enum { 36 | TCA_SKBEDIT_UNSPEC, 37 | TCA_SKBEDIT_TM, 38 | TCA_SKBEDIT_PARMS, 39 | TCA_SKBEDIT_PRIORITY, 40 | TCA_SKBEDIT_QUEUE_MAPPING, 41 | TCA_SKBEDIT_MARK, 42 | __TCA_SKBEDIT_MAX 43 | }; 44 | #define TCA_SKBEDIT_MAX (__TCA_SKBEDIT_MAX - 1) 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /include/linux-private/linux/veth.h: -------------------------------------------------------------------------------- 1 | #ifndef __NET_VETH_H_ 2 | #define __NET_VETH_H_ 3 | 4 | enum { 5 | VETH_INFO_UNSPEC, 6 | VETH_INFO_PEER, 7 | 8 | __VETH_INFO_MAX 9 | #define VETH_INFO_MAX (__VETH_INFO_MAX - 1) 10 | }; 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /include/netlink-private/genl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink-private/genl.h Local Generic Netlink Interface 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2013 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_GENL_PRIV_H_ 13 | #define NETLINK_GENL_PRIV_H_ 14 | 15 | #include 16 | #include 17 | 18 | #define GENL_HDRSIZE(hdrlen) (GENL_HDRLEN + (hdrlen)) 19 | 20 | extern int genl_resolve_id(struct genl_ops *ops); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /include/netlink-private/socket.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink-private/socket.h Private declarations for socket 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2014 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_SOCKET_PRIV_H_ 13 | #define NETLINK_SOCKET_PRIV_H_ 14 | 15 | #include 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | int _nl_socket_is_local_port_unspecified (struct nl_sock *sk); 22 | uint32_t _nl_socket_generate_local_port_no_release(struct nl_sock *sk); 23 | 24 | void _nl_socket_used_ports_release_all(const uint32_t *used_ports); 25 | void _nl_socket_used_ports_set(uint32_t *used_ports, uint32_t port); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /include/netlink-private/tc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink-private/tc.h Local Traffic Control Interface 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2013 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_TC_PRIV_H_ 13 | #define NETLINK_TC_PRIV_H_ 14 | 15 | #include 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #define TCA_ATTR_HANDLE 0x0001 22 | #define TCA_ATTR_PARENT 0x0002 23 | #define TCA_ATTR_IFINDEX 0x0004 24 | #define TCA_ATTR_KIND 0x0008 25 | #define TCA_ATTR_FAMILY 0x0010 26 | #define TCA_ATTR_INFO 0x0020 27 | #define TCA_ATTR_OPTS 0x0040 28 | #define TCA_ATTR_STATS 0x0080 29 | #define TCA_ATTR_XSTATS 0x0100 30 | #define TCA_ATTR_LINK 0x0200 31 | #define TCA_ATTR_MTU 0x0400 32 | #define TCA_ATTR_MPU 0x0800 33 | #define TCA_ATTR_OVERHEAD 0x1000 34 | #define TCA_ATTR_LINKTYPE 0x2000 35 | #define TCA_ATTR_MAX TCA_ATTR_LINKTYPE 36 | 37 | extern int tca_parse(struct nlattr **, int, struct rtnl_tc *, 38 | struct nla_policy *); 39 | 40 | #define RTNL_TC_RTABLE_SIZE 256 41 | 42 | extern int rtnl_tc_build_rate_table(struct rtnl_tc *tc, struct rtnl_ratespec *, 43 | uint32_t *); 44 | 45 | 46 | static inline void *tca_xstats(struct rtnl_tc *tca) 47 | { 48 | return tca->tc_xstats->d_data; 49 | } 50 | 51 | extern struct nl_af_group tc_groups[]; 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /include/netlink/.gitignore: -------------------------------------------------------------------------------- 1 | version.h 2 | -------------------------------------------------------------------------------- /include/netlink/cache-api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/cache-api.h Caching API 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2013 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_DUMMY_CACHE_API_H_ 13 | #define NETLINK_DUMMY_CACHE_API_H_ 14 | 15 | #include 16 | #include 17 | 18 | #warning "You are including a deprecated header file, include ." 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /include/netlink/cli/addr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/cli/addr.h CLI Address Helpers 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2008-2009 Thomas Graf 10 | */ 11 | 12 | #ifndef __NETLINK_CLI_ADDR_H_ 13 | #define __NETLINK_CLI_ADDR_H_ 14 | 15 | #include 16 | 17 | #define nl_cli_addr_alloc_cache(sk) \ 18 | nl_cli_alloc_cache((sk), "address", rtnl_addr_alloc_cache) 19 | 20 | extern struct rtnl_addr *nl_cli_addr_alloc(void); 21 | 22 | extern void nl_cli_addr_parse_family(struct rtnl_addr *, char *); 23 | extern void nl_cli_addr_parse_local(struct rtnl_addr *, char *); 24 | extern void nl_cli_addr_parse_dev(struct rtnl_addr *, struct nl_cache *,char *); 25 | extern void nl_cli_addr_parse_label(struct rtnl_addr *, char *); 26 | extern void nl_cli_addr_parse_peer(struct rtnl_addr *, char *); 27 | extern void nl_cli_addr_parse_scope(struct rtnl_addr *, char *); 28 | extern void nl_cli_addr_parse_broadcast(struct rtnl_addr *, char *); 29 | extern void nl_cli_addr_parse_preferred(struct rtnl_addr *, char *); 30 | extern void nl_cli_addr_parse_valid(struct rtnl_addr *, char *); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /include/netlink/cli/class.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/cli/class.h CLI Class Helpers 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2010 Thomas Graf 10 | */ 11 | 12 | #ifndef __NETLINK_CLI_CLASS_H_ 13 | #define __NETLINK_CLI_CLASS_H_ 14 | 15 | #include 16 | #include 17 | 18 | extern struct rtnl_class *nl_cli_class_alloc(void); 19 | extern struct nl_cache *nl_cli_class_alloc_cache(struct nl_sock *, int); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /include/netlink/cli/cls.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/cli/cls.h CLI Classifier Helpers 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2010 Thomas Graf 10 | */ 11 | 12 | #ifndef __NETLINK_CLI_CLS_H_ 13 | #define __NETLINK_CLI_CLS_H_ 14 | 15 | #include 16 | #include 17 | 18 | extern struct rtnl_cls * nl_cli_cls_alloc(void); 19 | extern struct nl_cache * nl_cli_cls_alloc_cache(struct nl_sock *, 20 | int, uint32_t); 21 | extern void nl_cli_cls_parse_proto(struct rtnl_cls *, char *); 22 | extern struct rtnl_ematch_tree *nl_cli_cls_parse_ematch(struct rtnl_cls *, char *); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /include/netlink/cli/ct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/cli/ct.h CLI Conntrack Helper 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2008-2009 Thomas Graf 10 | */ 11 | 12 | #ifndef __NETLINK_CLI_CT_H_ 13 | #define __NETLINK_CLI_CT_H_ 14 | 15 | #include 16 | #include 17 | 18 | extern struct nfnl_ct *nl_cli_ct_alloc(void); 19 | extern struct nl_cache *nl_cli_ct_alloc_cache(struct nl_sock *); 20 | 21 | extern void nl_cli_ct_parse_family(struct nfnl_ct *, char *); 22 | extern void nl_cli_ct_parse_protocol(struct nfnl_ct *, char *); 23 | extern void nl_cli_ct_parse_mark(struct nfnl_ct *, char *); 24 | extern void nl_cli_ct_parse_timeout(struct nfnl_ct *, char *); 25 | extern void nl_cli_ct_parse_id(struct nfnl_ct *, char *); 26 | extern void nl_cli_ct_parse_use(struct nfnl_ct *, char *); 27 | extern void nl_cli_ct_parse_src(struct nfnl_ct *, int, char *); 28 | extern void nl_cli_ct_parse_dst(struct nfnl_ct *, int, char *); 29 | extern void nl_cli_ct_parse_src_port(struct nfnl_ct *, int, char *); 30 | extern void nl_cli_ct_parse_dst_port(struct nfnl_ct *, int, char *); 31 | extern void nl_cli_ct_parse_tcp_state(struct nfnl_ct *, char *); 32 | extern void nl_cli_ct_parse_status(struct nfnl_ct *, char *); 33 | extern void nl_cli_ct_parse_zone(struct nfnl_ct *, char *); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /include/netlink/cli/exp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/cli/exp.h CLI Expectation Helper 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2012 Rich Fought 10 | * Copyright (c) 2008-2009 Thomas Graf 11 | */ 12 | 13 | #ifndef __NETLINK_CLI_EXP_H_ 14 | #define __NETLINK_CLI_EXP_H_ 15 | 16 | #include 17 | #include 18 | 19 | extern struct nfnl_exp *nl_cli_exp_alloc(void); 20 | extern struct nl_cache *nl_cli_exp_alloc_cache(struct nl_sock *); 21 | 22 | extern void nl_cli_exp_parse_family(struct nfnl_exp *, char *); 23 | extern void nl_cli_exp_parse_timeout(struct nfnl_exp *, char *); 24 | extern void nl_cli_exp_parse_id(struct nfnl_exp *, char *); 25 | extern void nl_cli_exp_parse_helper_name(struct nfnl_exp *, char *); 26 | extern void nl_cli_exp_parse_zone(struct nfnl_exp *, char *); 27 | extern void nl_cli_exp_parse_flags(struct nfnl_exp *, char *); 28 | extern void nl_cli_exp_parse_class(struct nfnl_exp *, char *); 29 | extern void nl_cli_exp_parse_nat_dir(struct nfnl_exp *, char *); 30 | extern void nl_cli_exp_parse_fn(struct nfnl_exp *, char *); 31 | 32 | extern void nl_cli_exp_parse_src(struct nfnl_exp *, int, char *); 33 | extern void nl_cli_exp_parse_dst(struct nfnl_exp *, int, char *); 34 | extern void nl_cli_exp_parse_l4protonum(struct nfnl_exp *, int, char *); 35 | extern void nl_cli_exp_parse_src_port(struct nfnl_exp *, int, char *); 36 | extern void nl_cli_exp_parse_dst_port(struct nfnl_exp *, int, char *); 37 | extern void nl_cli_exp_parse_icmp_id(struct nfnl_exp *, int, char *); 38 | extern void nl_cli_exp_parse_icmp_type(struct nfnl_exp *, int, char *); 39 | extern void nl_cli_exp_parse_icmp_code(struct nfnl_exp *, int, char *); 40 | 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /include/netlink/cli/link.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/cli/link.h CLI Link Helpers 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2008-2010 Thomas Graf 10 | */ 11 | 12 | #ifndef __NETLINK_CLI_LINK_H_ 13 | #define __NETLINK_CLI_LINK_H_ 14 | 15 | #include 16 | #include 17 | 18 | extern struct rtnl_link *nl_cli_link_alloc(void); 19 | extern struct nl_cache *nl_cli_link_alloc_cache_family(struct nl_sock *, int); 20 | extern struct nl_cache *nl_cli_link_alloc_cache(struct nl_sock *); 21 | 22 | extern void nl_cli_link_parse_family(struct rtnl_link *, char *); 23 | extern void nl_cli_link_parse_name(struct rtnl_link *, char *); 24 | extern void nl_cli_link_parse_mtu(struct rtnl_link *, char *); 25 | extern void nl_cli_link_parse_ifindex(struct rtnl_link *, char *); 26 | extern void nl_cli_link_parse_txqlen(struct rtnl_link *, char *); 27 | extern void nl_cli_link_parse_weight(struct rtnl_link *, char *); 28 | extern void nl_cli_link_parse_ifalias(struct rtnl_link *, char *); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /include/netlink/cli/neigh.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/cli/neighbour.h CLI Neighbour Helpers 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2008-2009 Thomas Graf 10 | */ 11 | 12 | #ifndef __NETLINK_CLI_NEIGH_H_ 13 | #define __NETLINK_CLI_NEIGH_H_ 14 | 15 | #include 16 | 17 | #define nl_cli_neigh_alloc_cache(sk) \ 18 | nl_cli_alloc_cache((sk), "neighbour", rtnl_neigh_alloc_cache) 19 | 20 | extern struct rtnl_neigh *nl_cli_neigh_alloc(void); 21 | extern void nl_cli_neigh_parse_dst(struct rtnl_neigh *, char *); 22 | extern void nl_cli_neigh_parse_lladdr(struct rtnl_neigh *, char *); 23 | extern void nl_cli_neigh_parse_dev(struct rtnl_neigh *, struct nl_cache *, char *); 24 | extern void nl_cli_neigh_parse_family(struct rtnl_neigh *, char *); 25 | extern void nl_cli_neigh_parse_state(struct rtnl_neigh *, char *); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /include/netlink/cli/qdisc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/cli/qdisc.h CLI QDisc Helpers 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2008-2011 Thomas Graf 10 | */ 11 | 12 | #ifndef __NETLINK_CLI_QDISC_H_ 13 | #define __NETLINK_CLI_QDISC_H_ 14 | 15 | #include 16 | 17 | #define nl_cli_qdisc_alloc_cache(sk) \ 18 | nl_cli_alloc_cache((sk), "queueing disciplines", \ 19 | rtnl_qdisc_alloc_cache) 20 | 21 | extern struct rtnl_qdisc *nl_cli_qdisc_alloc(void); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /include/netlink/cli/route.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/cli//route.h CLI Route Helpers 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2008-2009 Thomas Graf 10 | */ 11 | 12 | #ifndef __NETLINK_CLI_ROUTE_H_ 13 | #define __NETLINK_CLI_ROUTE_H_ 14 | 15 | #include 16 | 17 | extern struct rtnl_route *nl_cli_route_alloc(void); 18 | 19 | extern struct nl_cache *nl_cli_route_alloc_cache(struct nl_sock *, int); 20 | 21 | extern void nl_cli_route_parse_family(struct rtnl_route *, char *); 22 | extern void nl_cli_route_parse_dst(struct rtnl_route *, char *); 23 | extern void nl_cli_route_parse_src(struct rtnl_route *, char *); 24 | extern void nl_cli_route_parse_pref_src(struct rtnl_route *, char *); 25 | extern void nl_cli_route_parse_metric(struct rtnl_route *, char *); 26 | extern void nl_cli_route_parse_nexthop(struct rtnl_route *, char *, struct nl_cache *); 27 | extern void nl_cli_route_parse_table(struct rtnl_route *, char *); 28 | extern void nl_cli_route_parse_prio(struct rtnl_route *, char *); 29 | extern void nl_cli_route_parse_scope(struct rtnl_route *, char *); 30 | extern void nl_cli_route_parse_protocol(struct rtnl_route *, char *); 31 | extern void nl_cli_route_parse_type(struct rtnl_route *, char *); 32 | extern void nl_cli_route_parse_iif(struct rtnl_route *, char *, struct nl_cache *); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /include/netlink/cli/rule.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/cli/rule.h CLI Routing Rule Helpers 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2008-2009 Thomas Graf 10 | */ 11 | 12 | #ifndef __NETLINK_CLI_RULE_H_ 13 | #define __NETLINK_CLI_RULE_H_ 14 | 15 | #include 16 | 17 | extern struct rtnl_rule *nl_cli_rule_alloc(void); 18 | extern struct nl_cache *nl_cli_rule_alloc_cache(struct nl_sock *); 19 | extern void nl_cli_rule_parse_family(struct rtnl_rule *, char *); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /include/netlink/cli/tc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/cli/tc.h CLI Traffic Control Helpers 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2010-2011 Thomas Graf 10 | */ 11 | 12 | #ifndef __NETLINK_CLI_TC_H_ 13 | #define __NETLINK_CLI_TC_H_ 14 | 15 | #include 16 | 17 | struct rtnl_tc_ops; 18 | 19 | extern void nl_cli_tc_parse_dev(struct rtnl_tc *, struct nl_cache *, char *); 20 | extern void nl_cli_tc_parse_parent(struct rtnl_tc *, char *); 21 | extern void nl_cli_tc_parse_handle(struct rtnl_tc *, char *, int); 22 | extern void nl_cli_tc_parse_mtu(struct rtnl_tc *, char *); 23 | extern void nl_cli_tc_parse_mpu(struct rtnl_tc *, char *); 24 | extern void nl_cli_tc_parse_overhead(struct rtnl_tc *, char *); 25 | extern void nl_cli_tc_parse_linktype(struct rtnl_tc *, char *); 26 | extern void nl_cli_tc_parse_kind(struct rtnl_tc *, char *); 27 | 28 | struct nl_cli_tc_module 29 | { 30 | const char * tm_name; 31 | enum rtnl_tc_type tm_type; 32 | struct rtnl_tc_ops * tm_ops; 33 | void (*tm_parse_argv)(struct rtnl_tc *, int, char **); 34 | struct nl_list_head tm_list; 35 | }; 36 | 37 | extern struct nl_cli_tc_module *nl_cli_tc_lookup(struct rtnl_tc_ops *); 38 | extern void nl_cli_tc_register(struct nl_cli_tc_module *); 39 | extern void nl_cli_tc_unregister(struct nl_cli_tc_module *); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /include/netlink/data.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/data.h Abstract Data 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2008 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_DATA_H_ 13 | #define NETLINK_DATA_H_ 14 | 15 | #include 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | struct nl_data; 22 | 23 | /* General */ 24 | extern struct nl_data * nl_data_alloc(const void *, size_t); 25 | extern struct nl_data * nl_data_alloc_attr(const struct nlattr *); 26 | extern struct nl_data * nl_data_clone(const struct nl_data *); 27 | extern int nl_data_append(struct nl_data *, const void *, size_t); 28 | extern void nl_data_free(struct nl_data *); 29 | 30 | /* Access Functions */ 31 | extern void * nl_data_get(const struct nl_data *); 32 | extern size_t nl_data_get_size(const struct nl_data *); 33 | 34 | /* Misc */ 35 | extern int nl_data_cmp(const struct nl_data *, 36 | const struct nl_data *); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /include/netlink/errno.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/errno.h Error Numbers 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2008 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_ERRNO_H_ 13 | #define NETLINK_ERRNO_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | #define NLE_SUCCESS 0 20 | #define NLE_FAILURE 1 21 | #define NLE_INTR 2 22 | #define NLE_BAD_SOCK 3 23 | #define NLE_AGAIN 4 24 | #define NLE_NOMEM 5 25 | #define NLE_EXIST 6 26 | #define NLE_INVAL 7 27 | #define NLE_RANGE 8 28 | #define NLE_MSGSIZE 9 29 | #define NLE_OPNOTSUPP 10 30 | #define NLE_AF_NOSUPPORT 11 31 | #define NLE_OBJ_NOTFOUND 12 32 | #define NLE_NOATTR 13 33 | #define NLE_MISSING_ATTR 14 34 | #define NLE_AF_MISMATCH 15 35 | #define NLE_SEQ_MISMATCH 16 36 | #define NLE_MSG_OVERFLOW 17 37 | #define NLE_MSG_TRUNC 18 38 | #define NLE_NOADDR 19 39 | #define NLE_SRCRT_NOSUPPORT 20 40 | #define NLE_MSG_TOOSHORT 21 41 | #define NLE_MSGTYPE_NOSUPPORT 22 42 | #define NLE_OBJ_MISMATCH 23 43 | #define NLE_NOCACHE 24 44 | #define NLE_BUSY 25 45 | #define NLE_PROTO_MISMATCH 26 46 | #define NLE_NOACCESS 27 47 | #define NLE_PERM 28 48 | #define NLE_PKTLOC_FILE 29 49 | #define NLE_PARSE_ERR 30 50 | #define NLE_NODEV 31 51 | #define NLE_IMMUTABLE 32 52 | #define NLE_DUMP_INTR 33 53 | 54 | #define NLE_MAX NLE_DUMP_INTR 55 | 56 | extern const char * nl_geterror(int); 57 | extern void nl_perror(int, const char *); 58 | extern int nl_syserr2nlerr(int); 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /include/netlink/fib_lookup/lookup.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/fib_lookup/fib_lookup.h FIB Lookup 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2008 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_FIB_LOOKUP_H_ 13 | #define NETLINK_FIB_LOOKUP_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | struct flnl_result; 25 | 26 | extern struct flnl_result * flnl_result_alloc(void); 27 | extern void flnl_result_put(struct flnl_result *); 28 | 29 | extern struct nl_cache * flnl_result_alloc_cache(void); 30 | 31 | extern int flnl_lookup_build_request(struct flnl_request *, 32 | int, 33 | struct nl_msg **); 34 | extern int flnl_lookup(struct nl_sock *, 35 | struct flnl_request *, 36 | struct nl_cache *); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /include/netlink/fib_lookup/request.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/fib_lookup/request.h FIB Lookup Request 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2006 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_FIB_LOOKUP_REQUEST_H_ 13 | #define NETLINK_FIB_LOOKUP_REQUEST_H_ 14 | 15 | #include 16 | #include 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | struct flnl_request; 23 | 24 | #define REQUEST_CAST(ptr) ((struct flnl_request *) (ptr)) 25 | 26 | extern struct flnl_request * flnl_request_alloc(void); 27 | 28 | extern void flnl_request_set_fwmark(struct flnl_request *, 29 | uint64_t); 30 | extern uint64_t flnl_request_get_fwmark(struct flnl_request *); 31 | extern void flnl_request_set_tos(struct flnl_request *, 32 | int); 33 | extern int flnl_request_get_tos(struct flnl_request *); 34 | extern void flnl_request_set_scope(struct flnl_request *, 35 | int); 36 | extern int flnl_request_get_scope(struct flnl_request *); 37 | extern void flnl_request_set_table(struct flnl_request *, 38 | int); 39 | extern int flnl_request_get_table(struct flnl_request *); 40 | extern int flnl_request_set_addr(struct flnl_request *, 41 | struct nl_addr *); 42 | extern struct nl_addr * flnl_request_get_addr(struct flnl_request *); 43 | 44 | extern int flnl_request_cmp(struct flnl_request *, 45 | struct flnl_request *); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /include/netlink/genl/ctrl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/genl/ctrl.h Generic Netlink Controller 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2012 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_GENL_CTRL_H_ 13 | #define NETLINK_GENL_CTRL_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | struct genl_family; 24 | 25 | extern int genl_ctrl_alloc_cache(struct nl_sock *, 26 | struct nl_cache **); 27 | extern struct genl_family * genl_ctrl_search(struct nl_cache *, int); 28 | extern struct genl_family * genl_ctrl_search_by_name(struct nl_cache *, 29 | const char *); 30 | extern int genl_ctrl_resolve(struct nl_sock *, 31 | const char *); 32 | extern int genl_ctrl_resolve_grp(struct nl_sock *sk, 33 | const char *family, 34 | const char *grp); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /include/netlink/genl/family.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/genl/family.h Generic Netlink Family 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2012 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_GENL_FAMILY_H_ 13 | #define NETLINK_GENL_FAMILY_H_ 14 | 15 | #include 16 | #include 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | struct genl_family; 23 | 24 | extern struct genl_family * genl_family_alloc(void); 25 | extern void genl_family_put(struct genl_family *); 26 | 27 | extern unsigned int genl_family_get_id(struct genl_family *); 28 | extern void genl_family_set_id(struct genl_family *, unsigned int); 29 | extern char * genl_family_get_name(struct genl_family *); 30 | extern void genl_family_set_name(struct genl_family *, const char *); 31 | extern uint8_t genl_family_get_version(struct genl_family *); 32 | extern void genl_family_set_version(struct genl_family *, uint8_t); 33 | extern uint32_t genl_family_get_hdrsize(struct genl_family *); 34 | extern void genl_family_set_hdrsize(struct genl_family *, uint32_t); 35 | extern uint32_t genl_family_get_maxattr(struct genl_family *); 36 | extern void genl_family_set_maxattr(struct genl_family *, uint32_t); 37 | 38 | extern int genl_family_add_op(struct genl_family *, int, int); 39 | extern int genl_family_add_grp(struct genl_family *, uint32_t , 40 | const char *); 41 | 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /include/netlink/genl/genl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/genl/genl.h Generic Netlink 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2012 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_GENL_H_ 13 | #define NETLINK_GENL_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | extern int genl_connect(struct nl_sock *); 24 | extern int genl_send_simple(struct nl_sock *, int, int, 25 | int, int); 26 | 27 | extern void * genlmsg_put(struct nl_msg *, uint32_t, uint32_t, 28 | int, int, int, uint8_t, uint8_t); 29 | 30 | extern int genlmsg_valid_hdr(struct nlmsghdr *, int); 31 | extern int genlmsg_validate(struct nlmsghdr *, int, int, 32 | struct nla_policy *); 33 | extern int genlmsg_parse(struct nlmsghdr *, int, struct nlattr **, 34 | int, struct nla_policy *); 35 | extern struct genlmsghdr * 36 | genlmsg_hdr(struct nlmsghdr *); 37 | extern void * genlmsg_data(const struct genlmsghdr *); 38 | extern void * genlmsg_user_hdr(const struct genlmsghdr *); 39 | extern void * genlmsg_user_data(const struct genlmsghdr *, const int); 40 | extern int genlmsg_user_datalen(const struct genlmsghdr *, 41 | const int); 42 | extern int genlmsg_len(const struct genlmsghdr *); 43 | extern struct nlattr * genlmsg_attrdata(const struct genlmsghdr *, int); 44 | extern int genlmsg_attrlen(const struct genlmsghdr *, int); 45 | 46 | extern char * genl_op2name(int, int, char *, size_t); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /include/netlink/hashtable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/hashtable.h Netlink hashtable Utilities 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2012 Cumulus Networks, Inc 10 | */ 11 | 12 | #ifndef NETLINK_HASHTABLE_H_ 13 | #define NETLINK_HASHTABLE_H_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | typedef struct nl_hash_node { 20 | uint32_t key; 21 | uint32_t key_size; 22 | struct nl_object * obj; 23 | struct nl_hash_node * next; 24 | } nl_hash_node_t; 25 | 26 | typedef struct nl_hash_table { 27 | int size; 28 | nl_hash_node_t ** nodes; 29 | } nl_hash_table_t; 30 | 31 | /* Default hash table size */ 32 | #define NL_MAX_HASH_ENTRIES 1024 33 | 34 | /* Access Functions */ 35 | extern nl_hash_table_t * nl_hash_table_alloc(int size); 36 | extern void nl_hash_table_free(nl_hash_table_t *ht); 37 | 38 | extern int nl_hash_table_add(nl_hash_table_t *ht, 39 | struct nl_object *obj); 40 | extern int nl_hash_table_del(nl_hash_table_t *ht, 41 | struct nl_object *obj); 42 | 43 | extern struct nl_object * nl_hash_table_lookup(nl_hash_table_t *ht, 44 | struct nl_object *obj); 45 | extern uint32_t nl_hash(void *k, size_t length, 46 | uint32_t initval); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* NETLINK_HASHTABLE_H_ */ 53 | -------------------------------------------------------------------------------- /include/netlink/idiag/meminfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/idiag/meminfo.h Inetdiag Netlink Memory Info 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2013 Sassano Systems LLC 10 | */ 11 | 12 | #ifndef NETLINK_IDIAGNL_MEMINFO_H_ 13 | #define NETLINK_IDIAGNL_MEMINFO_H_ 14 | 15 | #include 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif /* __cplusplus */ 20 | 21 | extern struct nl_object_ops idiagnl_meminfo_obj_ops; 22 | 23 | extern struct idiagnl_meminfo *idiagnl_meminfo_alloc(void); 24 | extern void idiagnl_meminfo_get(struct idiagnl_meminfo *); 25 | extern void idiagnl_meminfo_put(struct idiagnl_meminfo *); 26 | 27 | extern uint32_t idiagnl_meminfo_get_rmem(const struct idiagnl_meminfo *); 28 | extern uint32_t idiagnl_meminfo_get_wmem(const struct idiagnl_meminfo *); 29 | extern uint32_t idiagnl_meminfo_get_fmem(const struct idiagnl_meminfo *); 30 | extern uint32_t idiagnl_meminfo_get_tmem(const struct idiagnl_meminfo *); 31 | 32 | extern void idiagnl_meminfo_set_rmem(struct idiagnl_meminfo *, uint32_t); 33 | extern void idiagnl_meminfo_set_wmem(struct idiagnl_meminfo *, uint32_t); 34 | extern void idiagnl_meminfo_set_fmem(struct idiagnl_meminfo *, uint32_t); 35 | extern void idiagnl_meminfo_set_tmem(struct idiagnl_meminfo *, uint32_t); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif /* __cplusplus */ 40 | 41 | #endif /* NETLINK_IDIAGNL_MEMINFO_H_ */ 42 | -------------------------------------------------------------------------------- /include/netlink/idiag/vegasinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/idiag/vegasinfo.h Inetdiag Netlink TCP Vegas Info 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2013 Sassano Systems LLC 10 | */ 11 | 12 | #ifndef NETLINK_IDIAGNL_VEGASINFO_H_ 13 | #define NETLINK_IDIAGNL_VEGASINFO_H_ 14 | 15 | #include 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif /* __cplusplus */ 20 | 21 | extern struct nl_object_ops idiagnl_vegasinfo_obj_ops; 22 | extern struct idiagnl_vegasinfo * idiagnl_vegasinfo_alloc(void); 23 | extern void idiagnl_vegasinfo_get(struct idiagnl_vegasinfo *); 24 | extern void idiagnl_vegasinfo_put(struct idiagnl_vegasinfo *); 25 | 26 | extern uint32_t idiagnl_vegasinfo_get_enabled(const struct idiagnl_vegasinfo *); 27 | extern uint32_t idiagnl_vegasinfo_get_rttcnt(const struct idiagnl_vegasinfo *); 28 | extern uint32_t idiagnl_vegasinfo_get_rtt(const struct idiagnl_vegasinfo *); 29 | extern uint32_t idiagnl_vegasinfo_get_minrtt(const struct idiagnl_vegasinfo *); 30 | 31 | extern void idiagnl_vegasinfo_set_enabled(struct idiagnl_vegasinfo *, 32 | uint32_t); 33 | extern void idiagnl_vegasinfo_set_rttcnt(struct idiagnl_vegasinfo *, 34 | uint32_t); 35 | extern void idiagnl_vegasinfo_set_rtt(struct idiagnl_vegasinfo *, uint32_t); 36 | extern void idiagnl_vegasinfo_set_minrtt(struct idiagnl_vegasinfo *, 37 | uint32_t); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif /* __cplusplus */ 42 | 43 | #endif /* NETLINK_IDIAGNL_VEGASINFO_H_ */ 44 | -------------------------------------------------------------------------------- /include/netlink/netfilter/netfilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/netfilter/netfilter.h Netfilter generic functions 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2008 Patrick McHardy 10 | */ 11 | 12 | #ifndef NETLINK_NETFILTER_H_ 13 | #define NETLINK_NETFILTER_H_ 14 | 15 | #include 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | extern char * nfnl_verdict2str(unsigned int, char *, size_t); 22 | extern unsigned int nfnl_str2verdict(const char *); 23 | 24 | extern char * nfnl_inet_hook2str(unsigned int, char *, size_t); 25 | extern unsigned int nfnl_str2inet_hook(const char *); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /include/netlink/netfilter/nfnl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/nfnl/nfnl.h Netfilter Netlink 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2008 Thomas Graf 10 | * Copyright (c) 2007 Philip Craig 11 | * Copyright (c) 2007 Secure Computing Corporation 12 | */ 13 | 14 | #ifndef NETLINK_NFNL_H_ 15 | #define NETLINK_NFNL_H_ 16 | 17 | #include 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | #define NFNL_HDRLEN NLMSG_ALIGN(sizeof(struct nfgenmsg)) 24 | #define NFNLMSG_TYPE(subsys, subtype) (((subsys) << 8) | (subtype)) 25 | 26 | extern int nfnl_connect(struct nl_sock *); 27 | 28 | extern uint8_t nfnlmsg_subsys(struct nlmsghdr *); 29 | extern uint8_t nfnlmsg_subtype(struct nlmsghdr *); 30 | extern uint8_t nfnlmsg_family(struct nlmsghdr *); 31 | extern uint16_t nfnlmsg_res_id(struct nlmsghdr *); 32 | 33 | extern int nfnl_send_simple(struct nl_sock *, uint8_t, uint8_t, 34 | int, uint8_t, uint16_t); 35 | extern struct nl_msg * nfnlmsg_alloc_simple(uint8_t, uint8_t, int, 36 | uint8_t, uint16_t); 37 | extern int nfnlmsg_put(struct nl_msg *, uint32_t, uint32_t, 38 | uint8_t, uint8_t, int, uint8_t, uint16_t); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /include/netlink/netlink-compat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/netlink-compat.h Netlink Compatability 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2006 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_COMPAT_H_ 13 | #define NETLINK_COMPAT_H_ 14 | 15 | #if !defined _LINUX_SOCKET_H && !defined _BITS_SOCKADDR_H 16 | typedef unsigned short sa_family_t; 17 | #endif 18 | 19 | #ifndef IFNAMSIZ 20 | /** Maximum length of a interface name */ 21 | #define IFNAMSIZ 16 22 | #endif 23 | 24 | /* patch 2.4.x if_arp */ 25 | #ifndef ARPHRD_INFINIBAND 26 | #define ARPHRD_INFINIBAND 32 27 | #endif 28 | 29 | /* patch 2.4.x eth header file */ 30 | #ifndef ETH_P_MPLS_UC 31 | #define ETH_P_MPLS_UC 0x8847 32 | #endif 33 | 34 | #ifndef ETH_P_MPLS_MC 35 | #define ETH_P_MPLS_MC 0x8848 36 | #endif 37 | 38 | #ifndef ETH_P_EDP2 39 | #define ETH_P_EDP2 0x88A2 40 | #endif 41 | 42 | #ifndef ETH_P_HDLC 43 | #define ETH_P_HDLC 0x0019 44 | #endif 45 | 46 | #ifndef AF_LLC 47 | #define AF_LLC 26 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /include/netlink/object-api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/object-api.h Object API 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2013 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_DUMMY_OBJECT_API_H_ 13 | #define NETLINK_DUMMY_OBJECT_API_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /include/netlink/route/act/mirred.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/cls/mirred.h mirred action 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2013 Cong Wang 10 | */ 11 | 12 | #ifndef NETLINK_MIRRED_H_ 13 | #define NETLINK_MIRRED_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | extern int rtnl_mirred_set_action(struct rtnl_act *, int); 25 | extern int rtnl_mirred_get_action(struct rtnl_act *); 26 | extern int rtnl_mirred_set_ifindex(struct rtnl_act *, uint32_t); 27 | extern uint32_t rtnl_mirred_get_ifindex(struct rtnl_act *); 28 | extern int rtnl_mirred_set_policy(struct rtnl_act *, int); 29 | extern int rtnl_mirred_get_policy(struct rtnl_act *); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /include/netlink/route/act/skbedit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/act/skbedit.h skbedit action 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2015 Cong Wang 10 | */ 11 | 12 | #ifndef NETLINK_SKBEDIT_H_ 13 | #define NETLINK_SKBEDIT_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | extern int rtnl_skbedit_set_action(struct rtnl_act *act, int action); 25 | extern int rtnl_skbedit_get_action(struct rtnl_act *act); 26 | extern int rtnl_skbedit_set_queue_mapping(struct rtnl_act *act, uint16_t index); 27 | extern int rtnl_skbedit_get_queue_mapping(struct rtnl_act *act, uint16_t *index); 28 | extern int rtnl_skbedit_set_mark(struct rtnl_act *act, uint32_t mark); 29 | extern int rtnl_skbedit_get_mark(struct rtnl_act *act, uint32_t *mark); 30 | extern int rtnl_skbedit_set_priority(struct rtnl_act *act, uint32_t prio); 31 | extern int rtnl_skbedit_get_priority(struct rtnl_act *act, uint32_t *prio); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /include/netlink/route/action.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/action.h Actions 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2013 Cong Wang 10 | */ 11 | 12 | #ifndef NETLINK_ACTION_H_ 13 | #define NETLINK_ACTION_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | extern struct rtnl_act *rtnl_act_alloc(void); 25 | extern void rtnl_act_get(struct rtnl_act *); 26 | extern void rtnl_act_put(struct rtnl_act *); 27 | extern int rtnl_act_build_add_request(struct rtnl_act *, int, 28 | struct nl_msg **); 29 | extern int rtnl_act_add(struct nl_sock *, struct rtnl_act *, int); 30 | extern int rtnl_act_change(struct nl_sock *, struct rtnl_act *, int); 31 | 32 | extern int rtnl_act_build_change_request(struct rtnl_act *, int, 33 | struct nl_msg **); 34 | extern int rtnl_act_build_delete_request(struct rtnl_act *, int, 35 | struct nl_msg **); 36 | extern int rtnl_act_delete(struct nl_sock *, struct rtnl_act *, 37 | int); 38 | extern int rtnl_act_append(struct rtnl_act **, struct rtnl_act *); 39 | extern int rtnl_act_remove(struct rtnl_act **, struct rtnl_act *); 40 | extern int rtnl_act_fill(struct nl_msg *, int, struct rtnl_act *); 41 | extern void rtnl_act_put_all(struct rtnl_act **); 42 | extern int rtnl_act_parse(struct rtnl_act **, struct nlattr *); 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /include/netlink/route/class.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/class.h Traffic Classes 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2011 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_CLASS_H_ 13 | #define NETLINK_CLASS_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | struct rtnl_class; 24 | 25 | extern struct rtnl_class * 26 | rtnl_class_alloc(void); 27 | extern void rtnl_class_put(struct rtnl_class *); 28 | 29 | extern int rtnl_class_alloc_cache(struct nl_sock *, int, 30 | struct nl_cache **); 31 | extern struct rtnl_class * 32 | rtnl_class_get(struct nl_cache *, int, uint32_t); 33 | 34 | extern struct rtnl_qdisc * 35 | rtnl_class_leaf_qdisc(struct rtnl_class *, 36 | struct nl_cache *); 37 | 38 | extern int rtnl_class_build_add_request(struct rtnl_class *, int, 39 | struct nl_msg **); 40 | extern int rtnl_class_add(struct nl_sock *, struct rtnl_class *, 41 | int); 42 | 43 | extern int rtnl_class_build_delete_request(struct rtnl_class *, 44 | struct nl_msg **); 45 | extern int rtnl_class_delete(struct nl_sock *, 46 | struct rtnl_class *); 47 | 48 | /* deprecated functions */ 49 | extern void rtnl_class_foreach_child(struct rtnl_class *, 50 | struct nl_cache *, 51 | void (*cb)(struct nl_object *, 52 | void *), 53 | void *) 54 | __attribute__((deprecated)); 55 | extern void rtnl_class_foreach_cls(struct rtnl_class *, 56 | struct nl_cache *, 57 | void (*cb)(struct nl_object *, 58 | void *), 59 | void *) 60 | __attribute__((deprecated)); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /include/netlink/route/classifier.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/classifier.h Classifiers 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2011 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_CLASSIFIER_H_ 13 | #define NETLINK_CLASSIFIER_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | extern struct rtnl_cls *rtnl_cls_alloc(void); 25 | extern void rtnl_cls_put(struct rtnl_cls *); 26 | 27 | extern int rtnl_cls_alloc_cache(struct nl_sock *, int, uint32_t, 28 | struct nl_cache **); 29 | 30 | extern int rtnl_cls_build_add_request(struct rtnl_cls *, int, 31 | struct nl_msg **); 32 | extern int rtnl_cls_add(struct nl_sock *, struct rtnl_cls *, int); 33 | extern int rtnl_cls_change(struct nl_sock *, struct rtnl_cls *, int); 34 | 35 | extern int rtnl_cls_build_change_request(struct rtnl_cls *, int, 36 | struct nl_msg **); 37 | extern int rtnl_cls_build_delete_request(struct rtnl_cls *, int, 38 | struct nl_msg **); 39 | extern int rtnl_cls_delete(struct nl_sock *, struct rtnl_cls *, 40 | int); 41 | 42 | extern void rtnl_cls_set_prio(struct rtnl_cls *, uint16_t); 43 | extern uint16_t rtnl_cls_get_prio(struct rtnl_cls *); 44 | 45 | extern void rtnl_cls_set_protocol(struct rtnl_cls *, uint16_t); 46 | extern uint16_t rtnl_cls_get_protocol(struct rtnl_cls *); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /include/netlink/route/cls/basic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/cls/basic.h Basic Classifier 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2008-2010 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_BASIC_H_ 13 | #define NETLINK_BASIC_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | extern void rtnl_basic_set_target(struct rtnl_cls *, uint32_t); 25 | extern uint32_t rtnl_basic_get_target(struct rtnl_cls *); 26 | extern void rtnl_basic_set_ematch(struct rtnl_cls *, 27 | struct rtnl_ematch_tree *); 28 | extern struct rtnl_ematch_tree *rtnl_basic_get_ematch(struct rtnl_cls *); 29 | extern int rtnl_basic_add_action(struct rtnl_cls *, struct rtnl_act *); 30 | extern int rtnl_basic_del_action(struct rtnl_cls *, struct rtnl_act *); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /include/netlink/route/cls/cgroup.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/cls/cgroup.h Control Groups Classifier 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2009-2010 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_CLS_CGROUP_H_ 13 | #define NETLINK_CLS_CGROUP_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | extern void rtnl_cgroup_set_ematch(struct rtnl_cls *, 25 | struct rtnl_ematch_tree *); 26 | struct rtnl_ematch_tree * rtnl_cgroup_get_ematch(struct rtnl_cls *); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /include/netlink/route/cls/ematch/cmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/cls/ematch/cmp.h Simple Comparison 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2008-2010 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_CLS_EMATCH_CMP_H_ 13 | #define NETLINK_CLS_EMATCH_CMP_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | extern void rtnl_ematch_cmp_set(struct rtnl_ematch *, 24 | struct tcf_em_cmp *); 25 | extern struct tcf_em_cmp * 26 | rtnl_ematch_cmp_get(struct rtnl_ematch *); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /include/netlink/route/cls/ematch/meta.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/cls/ematch/meta.h Metadata Match 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2010 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_CLS_EMATCH_META_H_ 13 | #define NETLINK_CLS_EMATCH_META_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | struct rtnl_meta_value; 24 | 25 | extern struct rtnl_meta_value * rtnl_meta_value_alloc_int(uint64_t); 26 | extern struct rtnl_meta_value * rtnl_meta_value_alloc_var(void *, size_t); 27 | extern struct rtnl_meta_value * rtnl_meta_value_alloc_id(uint8_t, uint16_t, 28 | uint8_t, uint64_t); 29 | extern void rtnl_meta_value_put(struct rtnl_meta_value *); 30 | 31 | extern void rtnl_ematch_meta_set_lvalue(struct rtnl_ematch *, 32 | struct rtnl_meta_value *); 33 | void rtnl_ematch_meta_set_rvalue(struct rtnl_ematch *, 34 | struct rtnl_meta_value *); 35 | extern void rtnl_ematch_meta_set_operand(struct rtnl_ematch *, uint8_t); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /include/netlink/route/cls/ematch/nbyte.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/cls/ematch/nbyte.h N-Byte Comparison 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2010 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_CLS_EMATCH_NBYTE_H_ 13 | #define NETLINK_CLS_EMATCH_NBYTE_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | extern void rtnl_ematch_nbyte_set_offset(struct rtnl_ematch *, 24 | uint8_t, uint16_t); 25 | extern uint16_t rtnl_ematch_nbyte_get_offset(struct rtnl_ematch *); 26 | extern uint8_t rtnl_ematch_nbyte_get_layer(struct rtnl_ematch *); 27 | extern void rtnl_ematch_nbyte_set_pattern(struct rtnl_ematch *, 28 | uint8_t *, size_t); 29 | extern uint8_t * rtnl_ematch_nbyte_get_pattern(struct rtnl_ematch *); 30 | extern size_t rtnl_ematch_nbyte_get_len(struct rtnl_ematch *); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /include/netlink/route/cls/ematch/text.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/cls/ematch/text.h Text Search 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2010 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_CLS_EMATCH_TEXT_H_ 13 | #define NETLINK_CLS_EMATCH_TEXT_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | extern void rtnl_ematch_text_set_from(struct rtnl_ematch *, 24 | uint8_t, uint16_t); 25 | extern uint16_t rtnl_ematch_text_get_from_offset(struct rtnl_ematch *); 26 | extern uint8_t rtnl_ematch_text_get_from_layer(struct rtnl_ematch *); 27 | extern void rtnl_ematch_text_set_to(struct rtnl_ematch *, 28 | uint8_t, uint16_t); 29 | extern uint16_t rtnl_ematch_text_get_to_offset(struct rtnl_ematch *); 30 | extern uint8_t rtnl_ematch_text_get_to_layer(struct rtnl_ematch *); 31 | extern void rtnl_ematch_text_set_pattern(struct rtnl_ematch *, 32 | char *, size_t); 33 | extern char * rtnl_ematch_text_get_pattern(struct rtnl_ematch *); 34 | extern size_t rtnl_ematch_text_get_len(struct rtnl_ematch *); 35 | extern void rtnl_ematch_text_set_algo(struct rtnl_ematch *, const char *); 36 | extern char * rtnl_ematch_text_get_algo(struct rtnl_ematch *); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /include/netlink/route/cls/fw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/cls/fw.h fw classifier 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2006 Thomas Graf 10 | * Copyright (c) 2006 Petr Gotthard 11 | * Copyright (c) 2006 Siemens AG Oesterreich 12 | */ 13 | 14 | #ifndef NETLINK_FW_H_ 15 | #define NETLINK_FW_H_ 16 | 17 | #include 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | extern int rtnl_fw_set_classid(struct rtnl_cls *, uint32_t); 25 | extern int rtnl_fw_set_mask(struct rtnl_cls *, uint32_t); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /include/netlink/route/cls/police.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/cls/police.h Policer 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2006 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_CLS_POLICE_H_ 13 | #define NETLINK_CLS_POLICE_H_ 14 | 15 | #include 16 | #include 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | extern char * nl_police2str(int, char *, size_t); 23 | extern int nl_str2police(const char *); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /include/netlink/route/link/api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/link/api.h Link Modules API 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2013 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_DUMMY_LINK_API_H_ 13 | #define NETLINK_DUMMY_LINK_API_H_ 14 | 15 | #include 16 | #include 17 | 18 | #warning "You are including a deprecated header file, include ." 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /include/netlink/route/link/bonding.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/link/bonding.h Bonding Interface 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2011-2013 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_LINK_BONDING_H_ 13 | #define NETLINK_LINK_BONDING_H_ 14 | 15 | #include 16 | #include 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | extern struct rtnl_link *rtnl_link_bond_alloc(void); 23 | 24 | extern int rtnl_link_bond_add(struct nl_sock *, const char *, 25 | struct rtnl_link *); 26 | 27 | extern int rtnl_link_bond_enslave_ifindex(struct nl_sock *, int, int); 28 | extern int rtnl_link_bond_enslave(struct nl_sock *, struct rtnl_link *, 29 | struct rtnl_link *); 30 | 31 | extern int rtnl_link_bond_release_ifindex(struct nl_sock *, int); 32 | extern int rtnl_link_bond_release(struct nl_sock *, struct rtnl_link *); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /include/netlink/route/link/bridge.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/link/bridge.h Bridge 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2013 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_LINK_BRIDGE_H_ 13 | #define NETLINK_LINK_BRIDGE_H_ 14 | 15 | #include 16 | #include 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | /** 23 | * Bridge flags 24 | * @ingroup bridge 25 | */ 26 | enum rtnl_link_bridge_flags { 27 | RTNL_BRIDGE_HAIRPIN_MODE = 0x0001, 28 | RTNL_BRIDGE_BPDU_GUARD = 0x0002, 29 | RTNL_BRIDGE_ROOT_BLOCK = 0x0004, 30 | RTNL_BRIDGE_FAST_LEAVE = 0x0008, 31 | }; 32 | 33 | extern struct rtnl_link *rtnl_link_bridge_alloc(void); 34 | 35 | extern int rtnl_link_is_bridge(struct rtnl_link *); 36 | extern int rtnl_link_bridge_has_ext_info(struct rtnl_link *); 37 | 38 | extern int rtnl_link_bridge_set_port_state(struct rtnl_link *, uint8_t ); 39 | extern int rtnl_link_bridge_get_port_state(struct rtnl_link *); 40 | 41 | extern int rtnl_link_bridge_set_priority(struct rtnl_link *, uint16_t); 42 | extern int rtnl_link_bridge_get_priority(struct rtnl_link *); 43 | 44 | extern int rtnl_link_bridge_set_cost(struct rtnl_link *, uint32_t); 45 | extern int rtnl_link_bridge_get_cost(struct rtnl_link *, uint32_t *); 46 | 47 | extern int rtnl_link_bridge_unset_flags(struct rtnl_link *, unsigned int); 48 | extern int rtnl_link_bridge_set_flags(struct rtnl_link *, unsigned int); 49 | extern int rtnl_link_bridge_get_flags(struct rtnl_link *); 50 | 51 | extern char * rtnl_link_bridge_flags2str(int, char *, size_t); 52 | extern int rtnl_link_bridge_str2flags(const char *); 53 | 54 | extern int rtnl_link_bridge_add(struct nl_sock *sk, const char *name); 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif 60 | 61 | -------------------------------------------------------------------------------- /include/netlink/route/link/inet.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/link/inet.h INET Link Module 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2010 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_LINK_INET_H_ 13 | #define NETLINK_LINK_INET_H_ 14 | 15 | #include 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | extern const char * rtnl_link_inet_devconf2str(int, char *, size_t); 22 | extern int rtnl_link_inet_str2devconf(const char *); 23 | 24 | extern int rtnl_link_inet_get_conf(struct rtnl_link *, 25 | const unsigned int, uint32_t *); 26 | extern int rtnl_link_inet_set_conf(struct rtnl_link *, 27 | const unsigned int, uint32_t); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /include/netlink/route/link/inet6.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/link/inet6.h INET6 Link Module 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2014 Dan Williams 10 | */ 11 | 12 | #ifndef NETLINK_LINK_INET6_H_ 13 | #define NETLINK_LINK_INET6_H_ 14 | 15 | #include 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | const char * rtnl_link_inet6_addrgenmode2str (uint8_t mode, 22 | char *buf, 23 | size_t len); 24 | 25 | uint8_t rtnl_link_inet6_str2addrgenmode (const char *mode); 26 | 27 | extern int rtnl_link_inet6_get_token(struct rtnl_link *, 28 | struct nl_addr **); 29 | 30 | extern int rtnl_link_inet6_set_token(struct rtnl_link *, 31 | struct nl_addr *); 32 | 33 | extern int rtnl_link_inet6_get_addr_gen_mode(struct rtnl_link *, 34 | uint8_t *); 35 | 36 | extern int rtnl_link_inet6_set_addr_gen_mode(struct rtnl_link *, 37 | uint8_t); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /include/netlink/route/link/info-api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/link/info-api.h Link Modules API 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2013 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_DUMMY_LINK_INFO_API_H_ 13 | #define NETLINK_DUMMY_LINK_INFO_API_H_ 14 | 15 | #include 16 | #include 17 | 18 | #warning "You are including a deprecated header file, include ." 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /include/netlink/route/link/ipip.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/link/ipip.h IPIP interface 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2014 Susant Sahani 10 | */ 11 | 12 | #ifndef NETLINK_LINK_IPIP_H_ 13 | #define NETLINK_LINK_IPIP_H_ 14 | 15 | #include 16 | #include 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | extern struct rtnl_link *rtnl_link_ipip_alloc(void); 23 | extern int rtnl_link_ipip_add(struct nl_sock *sk, const char *name); 24 | 25 | extern uint32_t rtnl_link_ipip_get_link(struct rtnl_link *link); 26 | extern int rtnl_link_ipip_set_link(struct rtnl_link *link, uint32_t index); 27 | 28 | extern int rtnl_link_ipip_set_local(struct rtnl_link *link, uint32_t addr); 29 | extern uint32_t rtnl_link_ipip_get_local(struct rtnl_link *link); 30 | 31 | extern int rtnl_link_ipip_set_remote(struct rtnl_link *link, uint32_t addr); 32 | extern uint32_t rtnl_link_ipip_get_remote(struct rtnl_link *link); 33 | 34 | extern int rtnl_link_ipip_set_ttl(struct rtnl_link *link, uint8_t ttl); 35 | extern uint8_t rtnl_link_ipip_get_ttl(struct rtnl_link *link); 36 | 37 | extern int rtnl_link_ipip_set_tos(struct rtnl_link *link, uint8_t tos); 38 | extern uint8_t rtnl_link_ipip_get_tos(struct rtnl_link *link); 39 | 40 | extern int rtnl_link_ipip_set_pmtudisc(struct rtnl_link *link, uint8_t pmtudisc); 41 | extern uint8_t rtnl_link_ipip_get_pmtudisc(struct rtnl_link *link); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /include/netlink/route/link/ipvti.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/link/ipvti.h IPVTI interface 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2014 Susant Sahani 10 | */ 11 | 12 | #ifndef NETLINK_LINK_IPVTI_H_ 13 | #define NETLINK_LINK_IPVTI_H_ 14 | 15 | #include 16 | #include 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | extern struct rtnl_link *rtnl_link_ipvti_alloc(void); 22 | extern int rtnl_link_ipvti_add(struct nl_sock *sk, const char *name); 23 | 24 | extern int rtnl_link_ipvti_set_link(struct rtnl_link *link, uint32_t index); 25 | extern uint32_t rtnl_link_ipvti_get_link(struct rtnl_link *link); 26 | 27 | extern int rtnl_link_ipvti_set_ikey(struct rtnl_link *link, uint32_t ikey); 28 | extern uint32_t rtnl_link_get_ikey(struct rtnl_link *link); 29 | 30 | extern int rtnl_link_ipvti_set_okey(struct rtnl_link *link, uint32_t okey); 31 | extern uint32_t rtnl_link_get_okey(struct rtnl_link *link); 32 | 33 | extern int rtnl_link_ipvti_set_local(struct rtnl_link *link, uint32_t addr); 34 | extern uint32_t rtnl_link_get_local(struct rtnl_link *link); 35 | 36 | extern int rtnl_link_ipvti_set_remote(struct rtnl_link *link, uint32_t addr); 37 | extern uint32_t rtnl_link_get_remote(struct rtnl_link *link); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /include/netlink/route/link/macvlan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/link/macvlan.h MACVLAN interface 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2013 Michael Braun 10 | */ 11 | 12 | #ifndef NETLINK_LINK_MACVLAN_H_ 13 | #define NETLINK_LINK_MACVLAN_H_ 14 | 15 | #include 16 | #include 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | extern struct rtnl_link *rtnl_link_macvlan_alloc(void); 23 | 24 | extern int rtnl_link_is_macvlan(struct rtnl_link *); 25 | 26 | extern char * rtnl_link_macvlan_mode2str(int, char *, size_t); 27 | extern int rtnl_link_macvlan_str2mode(const char *); 28 | 29 | extern char * rtnl_link_macvlan_flags2str(int, char *, size_t); 30 | extern int rtnl_link_macvlan_str2flags(const char *); 31 | 32 | extern int rtnl_link_macvlan_set_mode(struct rtnl_link *, 33 | uint32_t); 34 | extern uint32_t rtnl_link_macvlan_get_mode(struct rtnl_link *); 35 | 36 | extern int rtnl_link_macvlan_set_flags(struct rtnl_link *, 37 | uint16_t); 38 | extern int rtnl_link_macvlan_unset_flags(struct rtnl_link *, 39 | uint16_t); 40 | extern uint16_t rtnl_link_macvlan_get_flags(struct rtnl_link *); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /include/netlink/route/link/sit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/link/sit.h SIT interface 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2014 Susant Sahani 10 | */ 11 | 12 | #ifndef NETLINK_LINK_SIT_H_ 13 | #define NETLINK_LINK_SIT_H_ 14 | 15 | #include 16 | #include 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | extern struct rtnl_link *rtnl_link_sit_alloc(void); 23 | extern int rtnl_link_sit_add(struct nl_sock *sk, const char *name); 24 | 25 | extern int rtnl_link_sit_set_link(struct rtnl_link *link, uint32_t index); 26 | extern uint32_t rtnl_link_sit_get_link(struct rtnl_link *link); 27 | 28 | extern int rtnl_link_sit_set_local(struct rtnl_link *link, uint32_t addr); 29 | extern uint32_t rtnl_link_get_sit_local(struct rtnl_link *link); 30 | 31 | extern int rtnl_link_sit_set_remote(struct rtnl_link *link, uint32_t addr); 32 | extern uint32_t rtnl_link_sit_get_remote(struct rtnl_link *link); 33 | 34 | extern int rtnl_link_sit_set_ttl(struct rtnl_link *link, uint8_t ttl); 35 | extern uint8_t rtnl_link_sit_get_ttl(struct rtnl_link *link); 36 | 37 | extern int rtnl_link_sit_set_tos(struct rtnl_link *link, uint8_t tos); 38 | extern uint8_t rtnl_link_sit_get_tos(struct rtnl_link *link); 39 | 40 | extern int rtnl_link_sit_set_pmtudisc(struct rtnl_link *link, uint8_t pmtudisc); 41 | extern uint8_t rtnl_link_sit_get_pmtudisc(struct rtnl_link *link); 42 | 43 | extern int rtnl_link_sit_set_flags(struct rtnl_link *link, uint16_t flags); 44 | extern uint16_t rtnl_link_sit_get_flags(struct rtnl_link *link); 45 | 46 | int rtnl_link_sit_set_proto(struct rtnl_link *link, uint8_t proto); 47 | uint8_t rtnl_link_get_proto(struct rtnl_link *link); 48 | 49 | #ifdef _cplusplus 50 | } 51 | #endif 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /include/netlink/route/link/veth.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/link/veth.h VETH interface 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2013 Cong Wang 10 | */ 11 | 12 | #ifndef NETLINK_LINK_VETH_H_ 13 | #define NETLINK_LINK_VETH_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | extern struct rtnl_link *rtnl_link_veth_alloc(void); 24 | extern void rtnl_link_veth_release(struct rtnl_link *); 25 | 26 | extern int rtnl_link_is_veth(struct rtnl_link *); 27 | 28 | extern struct rtnl_link *rtnl_link_veth_get_peer(struct rtnl_link *); 29 | extern int rtnl_link_veth_add(struct nl_sock *sock, const char *name, 30 | const char *peer, pid_t pid); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /include/netlink/route/link/vlan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/link/vlan.h VLAN interface 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2013 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_LINK_VLAN_H_ 13 | #define NETLINK_LINK_VLAN_H_ 14 | 15 | #include 16 | #include 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | struct vlan_map 23 | { 24 | uint32_t vm_from; 25 | uint32_t vm_to; 26 | }; 27 | 28 | #define VLAN_PRIO_MAX 7 29 | 30 | extern struct rtnl_link *rtnl_link_vlan_alloc(void); 31 | 32 | extern int rtnl_link_is_vlan(struct rtnl_link *); 33 | 34 | extern char * rtnl_link_vlan_flags2str(int, char *, size_t); 35 | extern int rtnl_link_vlan_str2flags(const char *); 36 | 37 | extern int rtnl_link_vlan_set_protocol(struct rtnl_link *link, uint16_t); 38 | extern int rtnl_link_vlan_get_protocol(struct rtnl_link *link); 39 | 40 | extern int rtnl_link_vlan_set_id(struct rtnl_link *, uint16_t); 41 | extern int rtnl_link_vlan_get_id(struct rtnl_link *); 42 | 43 | extern int rtnl_link_vlan_set_flags(struct rtnl_link *, 44 | unsigned int); 45 | extern int rtnl_link_vlan_unset_flags(struct rtnl_link *, 46 | unsigned int); 47 | extern int rtnl_link_vlan_get_flags(struct rtnl_link *); 48 | 49 | extern int rtnl_link_vlan_set_ingress_map(struct rtnl_link *, 50 | int, uint32_t); 51 | extern uint32_t * rtnl_link_vlan_get_ingress_map(struct rtnl_link *); 52 | 53 | extern int rtnl_link_vlan_set_egress_map(struct rtnl_link *, 54 | uint32_t, int); 55 | extern struct vlan_map *rtnl_link_vlan_get_egress_map(struct rtnl_link *, 56 | int *); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /include/netlink/route/pktloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/pktloc.h Packet Location Aliasing 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2010 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_PKTLOC_H_ 13 | #define NETLINK_PKTLOC_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | struct rtnl_pktloc 26 | { 27 | char * name; 28 | uint8_t layer; 29 | uint8_t shift; 30 | uint16_t offset; 31 | uint16_t align; 32 | uint32_t mask; 33 | uint32_t refcnt; 34 | 35 | struct nl_list_head list; 36 | }; 37 | 38 | extern int rtnl_pktloc_lookup(const char *, struct rtnl_pktloc **); 39 | extern struct rtnl_pktloc *rtnl_pktloc_alloc(void); 40 | extern void rtnl_pktloc_put(struct rtnl_pktloc *); 41 | extern int rtnl_pktloc_add(struct rtnl_pktloc *); 42 | extern void rtnl_pktloc_foreach(void (*cb)(struct rtnl_pktloc *, void *), 43 | void *); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /include/netlink/route/qdisc/cbq.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/sch/cbq.h Class Based Queueing 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2006 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_CBQ_H_ 13 | #define NETLINK_CBQ_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | extern char * nl_ovl_strategy2str(int, char *, size_t); 24 | extern int nl_str2ovl_strategy(const char *); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /include/netlink/route/qdisc/dsmark.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/sch/dsmark.h DSMARK 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2011 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_DSMARK_H_ 13 | #define NETLINK_DSMARK_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | extern int rtnl_class_dsmark_set_bitmask(struct rtnl_class *, uint8_t); 24 | extern int rtnl_class_dsmark_get_bitmask(struct rtnl_class *); 25 | 26 | extern int rtnl_class_dsmark_set_value(struct rtnl_class *, uint8_t); 27 | extern int rtnl_class_dsmark_get_value(struct rtnl_class *); 28 | 29 | extern int rtnl_qdisc_dsmark_set_indices(struct rtnl_qdisc *, uint16_t); 30 | extern int rtnl_qdisc_dsmark_get_indices(struct rtnl_qdisc *); 31 | 32 | extern int rtnl_qdisc_dsmark_set_default_index(struct rtnl_qdisc *, 33 | uint16_t); 34 | extern int rtnl_qdisc_dsmark_get_default_index(struct rtnl_qdisc *); 35 | 36 | extern int rtnl_qdisc_dsmark_set_set_tc_index(struct rtnl_qdisc *, int); 37 | extern int rtnl_qdisc_dsmark_get_set_tc_index(struct rtnl_qdisc *); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /include/netlink/route/qdisc/fifo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/sch/fifo.c FIFO Qdisc 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2006 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_FIFO_H_ 13 | #define NETLINK_FIFO_H_ 14 | 15 | #include 16 | #include 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | extern int rtnl_qdisc_fifo_set_limit(struct rtnl_qdisc *, int); 23 | extern int rtnl_qdisc_fifo_get_limit(struct rtnl_qdisc *); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /include/netlink/route/qdisc/fq_codel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/sch/fq_codel.h fq_codel 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2013 Cong Wang 10 | */ 11 | 12 | #ifndef NETLINK_FQ_CODEL_H_ 13 | #define NETLINK_FQ_CODEL_H_ 14 | 15 | #include 16 | #include 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | extern int rtnl_qdisc_fq_codel_set_limit(struct rtnl_qdisc *, int); 23 | extern int rtnl_qdisc_fq_codel_get_limit(struct rtnl_qdisc *); 24 | 25 | extern int rtnl_qdisc_fq_codel_set_target(struct rtnl_qdisc *, uint32_t); 26 | extern uint32_t rtnl_qdisc_fq_codel_get_target(struct rtnl_qdisc *); 27 | 28 | extern int rtnl_qdisc_fq_codel_set_interval(struct rtnl_qdisc *, uint32_t); 29 | extern uint32_t rtnl_qdisc_fq_codel_get_interval(struct rtnl_qdisc *); 30 | 31 | extern int rtnl_qdisc_fq_codel_set_quantum(struct rtnl_qdisc *, uint32_t); 32 | extern uint32_t rtnl_qdisc_fq_codel_get_quantum(struct rtnl_qdisc *); 33 | 34 | extern int rtnl_qdisc_fq_codel_set_flows(struct rtnl_qdisc *, int); 35 | extern int rtnl_qdisc_fq_codel_get_flows(struct rtnl_qdisc *); 36 | 37 | extern int rtnl_qdisc_fq_codel_set_ecn(struct rtnl_qdisc *, int); 38 | extern int rtnl_qdisc_fq_codel_get_ecn(struct rtnl_qdisc *); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /include/netlink/route/qdisc/hfsc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/sch/hfsc.h HFSC Qdisc 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2014 Cong Wang 10 | */ 11 | 12 | #ifndef NETLINK_HFSC_H_ 13 | #define NETLINK_HFSC_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | extern uint32_t rtnl_qdisc_hfsc_get_defcls(const struct rtnl_qdisc *); 25 | extern int rtnl_qdisc_hfsc_set_defcls(struct rtnl_qdisc *, uint32_t); 26 | 27 | extern int rtnl_class_hfsc_get_rsc(const struct rtnl_class *class, struct tc_service_curve *tsc); 28 | extern int rtnl_class_hfsc_set_rsc(struct rtnl_class *class, const struct tc_service_curve *tsc); 29 | extern int rtnl_class_hfsc_get_fsc(const struct rtnl_class *class, struct tc_service_curve *tsc); 30 | extern int rtnl_class_hfsc_set_fsc(struct rtnl_class *class, const struct tc_service_curve *tsc); 31 | extern int rtnl_class_hfsc_get_usc(const struct rtnl_class *class, struct tc_service_curve *tsc); 32 | extern int rtnl_class_hfsc_set_usc(struct rtnl_class *class, const struct tc_service_curve *tsc); 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /include/netlink/route/qdisc/htb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/sch/htb.h HTB Qdisc 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2011 Thomas Graf 10 | * Copyright (c) 2005 Petr Gotthard 11 | * Copyright (c) 2005 Siemens AG Oesterreich 12 | */ 13 | 14 | #ifndef NETLINK_HTB_H_ 15 | #define NETLINK_HTB_H_ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | extern uint32_t rtnl_htb_get_rate2quantum(struct rtnl_qdisc *); 27 | extern int rtnl_htb_set_rate2quantum(struct rtnl_qdisc *, uint32_t); 28 | extern uint32_t rtnl_htb_get_defcls(struct rtnl_qdisc *); 29 | extern int rtnl_htb_set_defcls(struct rtnl_qdisc *, uint32_t); 30 | 31 | extern uint32_t rtnl_htb_get_prio(struct rtnl_class *); 32 | extern int rtnl_htb_set_prio(struct rtnl_class *, uint32_t); 33 | extern uint32_t rtnl_htb_get_rate(struct rtnl_class *); 34 | extern int rtnl_htb_set_rate(struct rtnl_class *, uint32_t); 35 | extern uint32_t rtnl_htb_get_ceil(struct rtnl_class *); 36 | extern int rtnl_htb_set_ceil(struct rtnl_class *, uint32_t); 37 | extern uint32_t rtnl_htb_get_rbuffer(struct rtnl_class *); 38 | extern int rtnl_htb_set_rbuffer(struct rtnl_class *, uint32_t); 39 | extern uint32_t rtnl_htb_get_cbuffer(struct rtnl_class *); 40 | extern int rtnl_htb_set_cbuffer(struct rtnl_class *, uint32_t); 41 | extern uint32_t rtnl_htb_get_quantum(struct rtnl_class *); 42 | extern int rtnl_htb_set_quantum(struct rtnl_class *, uint32_t); 43 | extern int rtnl_htb_set_level(struct rtnl_class *, int); 44 | extern int rtnl_htb_get_level(struct rtnl_class *); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /include/netlink/route/qdisc/plug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/qdisc/plug.c PLUG Qdisc 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2012 Shriram Rajagopalan 10 | */ 11 | 12 | #ifndef NETLINK_PLUG_H_ 13 | #define NETLINK_PLUG_H_ 14 | 15 | #include 16 | #include 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | extern int rtnl_qdisc_plug_set_limit(struct rtnl_qdisc *, int); 23 | extern int rtnl_qdisc_plug_buffer(struct rtnl_qdisc *); 24 | extern int rtnl_qdisc_plug_release_one(struct rtnl_qdisc *); 25 | extern int rtnl_qdisc_plug_release_indefinite(struct rtnl_qdisc *); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /include/netlink/route/qdisc/prio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/sch/prio.c PRIO Qdisc 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2011 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_PRIO_H_ 13 | #define NETLINK_PRIO_H_ 14 | 15 | #include 16 | #include 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | /** 23 | * @name Default Values 24 | * @{ 25 | */ 26 | 27 | /** 28 | * Default number of bands. 29 | * @ingroup prio 30 | */ 31 | #define QDISC_PRIO_DEFAULT_BANDS 3 32 | 33 | /** 34 | * Default priority mapping. 35 | * @ingroup prio 36 | */ 37 | #define QDISC_PRIO_DEFAULT_PRIOMAP \ 38 | { 1, 2, 2, 2, 1, 2, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 } 39 | 40 | /** @} */ 41 | 42 | extern void rtnl_qdisc_prio_set_bands(struct rtnl_qdisc *, int); 43 | extern int rtnl_qdisc_prio_get_bands(struct rtnl_qdisc *); 44 | extern int rtnl_qdisc_prio_set_priomap(struct rtnl_qdisc *, uint8_t[], int); 45 | extern uint8_t *rtnl_qdisc_prio_get_priomap(struct rtnl_qdisc *); 46 | 47 | extern char * rtnl_prio2str(int, char *, size_t); 48 | extern int rtnl_str2prio(const char *); 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/netlink/route/qdisc/red.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/sch/red.h RED Qdisc 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2006 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_RED_H_ 13 | #define NETLINK_RED_H_ 14 | 15 | #include 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /include/netlink/route/qdisc/sfq.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/sch/sfq.c SFQ Qdisc 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2011 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_SFQ_H_ 13 | #define NETLINK_SFQ_H_ 14 | 15 | #include 16 | #include 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | extern void rtnl_sfq_set_quantum(struct rtnl_qdisc *, int); 23 | extern int rtnl_sfq_get_quantum(struct rtnl_qdisc *); 24 | 25 | extern void rtnl_sfq_set_limit(struct rtnl_qdisc *, int); 26 | extern int rtnl_sfq_get_limit(struct rtnl_qdisc *); 27 | 28 | extern void rtnl_sfq_set_perturb(struct rtnl_qdisc *, int); 29 | extern int rtnl_sfq_get_perturb(struct rtnl_qdisc *); 30 | 31 | extern int rtnl_sfq_get_divisor(struct rtnl_qdisc *); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /include/netlink/route/qdisc/tbf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/sch/tbf.h TBF Qdisc 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2011 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_TBF_H_ 13 | #define NETLINK_TBF_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | extern void rtnl_qdisc_tbf_set_limit(struct rtnl_qdisc *, int); 24 | extern int rtnl_qdisc_tbf_set_limit_by_latency(struct rtnl_qdisc *, int); 25 | extern int rtnl_qdisc_tbf_get_limit(struct rtnl_qdisc *); 26 | 27 | extern void rtnl_qdisc_tbf_set_rate(struct rtnl_qdisc *, int, int, int); 28 | extern int rtnl_qdisc_tbf_get_rate(struct rtnl_qdisc *); 29 | extern int rtnl_qdisc_tbf_get_rate_bucket(struct rtnl_qdisc *); 30 | extern int rtnl_qdisc_tbf_get_rate_cell(struct rtnl_qdisc *); 31 | 32 | extern int rtnl_qdisc_tbf_set_peakrate(struct rtnl_qdisc *, int, int, int); 33 | extern int rtnl_qdisc_tbf_get_peakrate(struct rtnl_qdisc *); 34 | extern int rtnl_qdisc_tbf_get_peakrate_bucket(struct rtnl_qdisc *); 35 | extern int rtnl_qdisc_tbf_get_peakrate_cell(struct rtnl_qdisc *); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /include/netlink/route/rtnl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/rtnl.h Routing Netlink 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2008 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_RTNL_H_ 13 | #define NETLINK_RTNL_H_ 14 | 15 | #include 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | /** 22 | * @name Realms 23 | * @{ 24 | */ 25 | 26 | /** 27 | * Mask specying the size of each realm part 28 | * @ingroup rtnl 29 | */ 30 | #define RTNL_REALM_MASK (0xFFFF) 31 | 32 | /** 33 | * Extract FROM realm from a realms field 34 | */ 35 | #define RTNL_REALM_FROM(realm) ((realm) >> 16) 36 | 37 | /** 38 | * Extract TO realm from a realms field 39 | */ 40 | #define RTNL_REALM_TO(realm) ((realm) & RTNL_REALM_MASK) 41 | 42 | /** 43 | * Build a realms field 44 | */ 45 | #define RTNL_MAKE_REALM(from, to) \ 46 | ((RTNL_REALM_TO(from) << 16) & RTNL_REALM_TO(to)) 47 | 48 | /** @} */ 49 | 50 | 51 | /* General */ 52 | extern int nl_rtgen_request(struct nl_sock *, int, int, int); 53 | 54 | /* Routing Type Translations */ 55 | extern char * nl_rtntype2str(int, char *, size_t); 56 | extern int nl_str2rtntype(const char *); 57 | 58 | /* Scope Translations */ 59 | extern char * rtnl_scope2str(int, char *, size_t); 60 | extern int rtnl_str2scope(const char *); 61 | 62 | /* Realms Translations */ 63 | extern char * rtnl_realms2str(uint32_t, char *, size_t); 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /include/netlink/route/tc-api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/route/tc-api.h Traffic Control API 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2013 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_DUMMY_TC_API_H_ 13 | #define NETLINK_DUMMY_TC_API_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #warning "You are including a deprecated header file, include ." 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /include/netlink/version.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * netlink/version.h Versioning Information 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2008-2011 Thomas Graf 10 | */ 11 | 12 | #ifndef NETLINK_VERSION_H_ 13 | #define NETLINK_VERSION_H_ 14 | 15 | /* Compile Time Versioning Information */ 16 | 17 | #define LIBNL_STRING "@PACKAGE_STRING@" 18 | #define LIBNL_VERSION "@PACKAGE_VERSION@" 19 | 20 | #define LIBNL_VER_MAJ @MAJ_VERSION@ 21 | #define LIBNL_VER_MIN @MIN_VERSION@ 22 | #define LIBNL_VER_MIC @MIC_VERSION@ 23 | #define LIBNL_VER(maj,min) ((maj) << 8 | (min)) 24 | #define LIBNL_VER_NUM LIBNL_VER(LIBNL_VER_MAJ, LIBNL_VER_MIN) 25 | 26 | #define LIBNL_CURRENT @LT_CURRENT@ 27 | #define LIBNL_REVISION @LT_REVISION@ 28 | #define LIBNL_AGE @LT_AGE@ 29 | 30 | /* Run-time version information */ 31 | 32 | extern const int nl_ver_num; 33 | extern const int nl_ver_maj; 34 | extern const int nl_ver_min; 35 | extern const int nl_ver_mic; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /lib/.gitignore: -------------------------------------------------------------------------------- 1 | libnl.so* 2 | libnl-*.so* 3 | lex.yy.c 4 | -------------------------------------------------------------------------------- /lib/cli/cls/cgroup.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/cli/cls/cgroup.c cgroup classifier module for CLI lib 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2010-2011 Thomas Graf 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | static void print_usage(void) 18 | { 19 | printf( 20 | "Usage: nl-cls-add [...] cgroup [OPTIONS]...\n" 21 | "\n" 22 | "OPTIONS\n" 23 | " -h, --help Show this help text.\n" 24 | " -e, --ematch=EXPR Ematch expression\n" 25 | "\n" 26 | "EXAMPLE" 27 | " nl-cls-add --dev=eth0 --parent=q_root cgroup\n"); 28 | } 29 | 30 | static void parse_argv(struct rtnl_tc *tc, int argc, char **argv) 31 | { 32 | struct rtnl_cls *cls = (struct rtnl_cls *) tc; 33 | struct rtnl_ematch_tree *tree; 34 | 35 | for (;;) { 36 | int c, optidx = 0; 37 | static struct option long_opts[] = { 38 | { "help", 0, 0, 'h' }, 39 | { "ematch", 1, 0, 'e' }, 40 | { 0, 0, 0, 0 } 41 | }; 42 | 43 | c = getopt_long(argc, argv, "he:", long_opts, &optidx); 44 | if (c == -1) 45 | break; 46 | 47 | switch (c) { 48 | case 'h': 49 | print_usage(); 50 | exit(0); 51 | 52 | case 'e': 53 | tree = nl_cli_cls_parse_ematch(cls, optarg); 54 | rtnl_cgroup_set_ematch(cls, tree); 55 | break; 56 | } 57 | } 58 | } 59 | 60 | static struct nl_cli_tc_module cgroup_module = 61 | { 62 | .tm_name = "cgroup", 63 | .tm_type = RTNL_TC_TYPE_CLS, 64 | .tm_parse_argv = parse_argv, 65 | }; 66 | 67 | static void __init cgroup_init(void) 68 | { 69 | nl_cli_tc_register(&cgroup_module); 70 | } 71 | 72 | static void __exit cgroup_exit(void) 73 | { 74 | nl_cli_tc_unregister(&cgroup_module); 75 | } 76 | -------------------------------------------------------------------------------- /lib/cli/qdisc/blackhole.c: -------------------------------------------------------------------------------- 1 | /* 2 | * src/lib/blackhole.c Blackhole module for CLI lib 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2010-2011 Thomas Graf 10 | */ 11 | 12 | #include 13 | #include 14 | 15 | static void print_usage(void) 16 | { 17 | printf( 18 | "Usage: nl-qdisc-add [...] blackhole [OPTIONS]...\n" 19 | "\n" 20 | "OPTIONS\n" 21 | " --help Show this help text.\n" 22 | "\n" 23 | "EXAMPLE" 24 | " # Drop all outgoing packets on eth1\n" 25 | " nl-qdisc-add --dev=eth1 --parent=root blackhole\n"); 26 | } 27 | 28 | static void blackhole_parse_argv(struct rtnl_tc *tc, int argc, char **argv) 29 | { 30 | for (;;) { 31 | int c, optidx = 0; 32 | static struct option long_opts[] = { 33 | { "help", 0, 0, 'h' }, 34 | { 0, 0, 0, 0 } 35 | }; 36 | 37 | c = getopt_long(argc, argv, "h", long_opts, &optidx); 38 | if (c == -1) 39 | break; 40 | 41 | switch (c) { 42 | case 'h': 43 | print_usage(); 44 | return; 45 | } 46 | } 47 | } 48 | 49 | static struct nl_cli_tc_module blackhole_module = 50 | { 51 | .tm_name = "blackhole", 52 | .tm_type = RTNL_TC_TYPE_QDISC, 53 | .tm_parse_argv = blackhole_parse_argv, 54 | }; 55 | 56 | static void __init blackhole_init(void) 57 | { 58 | nl_cli_tc_register(&blackhole_module); 59 | } 60 | 61 | static void __exit blackhole_exit(void) 62 | { 63 | nl_cli_tc_unregister(&blackhole_module); 64 | } 65 | -------------------------------------------------------------------------------- /lib/cli/qdisc/ingress.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * src/lib/ingress.c ingress module for CLI lib 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation version 2.1 8 | * of the License. 9 | * 10 | * Copyright (c) 2013 Cong Wang 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | static void print_usage(void) 17 | { 18 | printf( 19 | "Usage: nl-qdisc-add [...] ingress\n" 20 | "\n" 21 | "OPTIONS\n" 22 | " --help Show this help text.\n" 23 | "\n" 24 | "EXAMPLE" 25 | " # Attach ingress to eth1\n" 26 | " nl-qdisc-add --dev=eth1 --parent=root ingress\n"); 27 | } 28 | 29 | static void ingress_parse_argv(struct rtnl_tc *tc, int argc, char **argv) 30 | { 31 | for (;;) { 32 | int c, optidx = 0; 33 | static struct option long_opts[] = { 34 | { "help", 0, 0, 'h' }, 35 | { 0, 0, 0, 0 } 36 | }; 37 | 38 | c = getopt_long(argc, argv, "h", long_opts, &optidx); 39 | if (c == -1) 40 | break; 41 | 42 | switch (c) { 43 | case 'h': 44 | print_usage(); 45 | return; 46 | } 47 | } 48 | } 49 | 50 | static struct nl_cli_tc_module ingress_module = 51 | { 52 | .tm_name = "ingress", 53 | .tm_type = RTNL_TC_TYPE_QDISC, 54 | .tm_parse_argv = ingress_parse_argv, 55 | }; 56 | 57 | static void __init ingress_init(void) 58 | { 59 | nl_cli_tc_register(&ingress_module); 60 | } 61 | 62 | static void __exit ingress_exit(void) 63 | { 64 | nl_cli_tc_unregister(&ingress_module); 65 | } 66 | -------------------------------------------------------------------------------- /lib/cli/qdisc/pfifo.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * src/lib/pfifo.c pfifo module for CLI lib 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation version 2.1 8 | * of the License. 9 | * 10 | * Copyright (c) 2010-2011 Thomas Graf 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | static void print_usage(void) 18 | { 19 | printf( 20 | "Usage: nl-qdisc-add [...] pfifo [OPTIONS]...\n" 21 | "\n" 22 | "OPTIONS\n" 23 | " --help Show this help text.\n" 24 | " --limit=LIMIT Maximum queue length in number of packets.\n" 25 | "\n" 26 | "EXAMPLE" 27 | " # Attach pfifo with a 32 packet limit to eth1\n" 28 | " nl-qdisc-add --dev=eth1 --parent=root pfifo --limit=32\n"); 29 | } 30 | 31 | static void pfifo_parse_argv(struct rtnl_tc *tc, int argc, char **argv) 32 | { 33 | struct rtnl_qdisc *qdisc = (struct rtnl_qdisc *) tc; 34 | 35 | for (;;) { 36 | int c, optidx = 0; 37 | enum { 38 | ARG_LIMIT = 257, 39 | }; 40 | static struct option long_opts[] = { 41 | { "help", 0, 0, 'h' }, 42 | { "limit", 1, 0, ARG_LIMIT }, 43 | { 0, 0, 0, 0 } 44 | }; 45 | 46 | c = getopt_long(argc, argv, "h", long_opts, &optidx); 47 | if (c == -1) 48 | break; 49 | 50 | switch (c) { 51 | case 'h': 52 | print_usage(); 53 | return; 54 | 55 | case ARG_LIMIT: 56 | rtnl_qdisc_fifo_set_limit(qdisc, nl_cli_parse_u32(optarg)); 57 | break; 58 | } 59 | } 60 | } 61 | 62 | static struct nl_cli_tc_module pfifo_module = 63 | { 64 | .tm_name = "pfifo", 65 | .tm_type = RTNL_TC_TYPE_QDISC, 66 | .tm_parse_argv = pfifo_parse_argv, 67 | }; 68 | 69 | static void __init pfifo_init(void) 70 | { 71 | nl_cli_tc_register(&pfifo_module); 72 | } 73 | 74 | static void __exit pfifo_exit(void) 75 | { 76 | nl_cli_tc_unregister(&pfifo_module); 77 | } 78 | -------------------------------------------------------------------------------- /lib/netfilter/netfilter.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/netfilter/netfilter.c Netfilter Generic Functions 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2008 Patrick McHardy 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | static const struct trans_tbl nfnl_verdicts[] = { 17 | __ADD(NF_DROP, NF_DROP), 18 | __ADD(NF_ACCEPT, NF_ACCEPT), 19 | __ADD(NF_STOLEN, NF_STOLEN), 20 | __ADD(NF_QUEUE, NF_QUEUE), 21 | __ADD(NF_REPEAT, NF_REPEAT), 22 | __ADD(NF_STOP, NF_STOP), 23 | }; 24 | 25 | char *nfnl_verdict2str(unsigned int verdict, char *buf, size_t len) 26 | { 27 | return __type2str(verdict, buf, len, nfnl_verdicts, 28 | ARRAY_SIZE(nfnl_verdicts)); 29 | } 30 | 31 | unsigned int nfnl_str2verdict(const char *name) 32 | { 33 | return __str2type(name, nfnl_verdicts, ARRAY_SIZE(nfnl_verdicts)); 34 | } 35 | 36 | static const struct trans_tbl nfnl_inet_hooks[] = { 37 | __ADD(NF_INET_PRE_ROUTING, NF_INET_PREROUTING), 38 | __ADD(NF_INET_LOCAL_IN, NF_INET_LOCAL_IN), 39 | __ADD(NF_INET_FORWARD, NF_INET_FORWARD), 40 | __ADD(NF_INET_LOCAL_OUT, NF_INET_LOCAL_OUT), 41 | __ADD(NF_INET_POST_ROUTING, NF_INET_POST_ROUTING), 42 | }; 43 | 44 | char *nfnl_inet_hook2str(unsigned int hook, char *buf, size_t len) 45 | { 46 | return __type2str(hook, buf, len, nfnl_inet_hooks, 47 | ARRAY_SIZE(nfnl_inet_hooks)); 48 | } 49 | 50 | unsigned int nfnl_str2inet_hook(const char *name) 51 | { 52 | return __str2type(name, nfnl_inet_hooks, ARRAY_SIZE(nfnl_inet_hooks)); 53 | } 54 | -------------------------------------------------------------------------------- /lib/route/.gitignore: -------------------------------------------------------------------------------- 1 | pktloc_grammar.h 2 | pktloc_grammar.c 3 | pktloc_syntax.h 4 | pktloc_syntax.c 5 | -------------------------------------------------------------------------------- /lib/route/cls/.gitignore: -------------------------------------------------------------------------------- 1 | ematch_syntax.[ch] 2 | ematch_grammar.[ch] 3 | -------------------------------------------------------------------------------- /lib/route/cls/ematch/container.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/route/cls/ematch/container.c Container Ematch 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2008-2013 Thomas Graf 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | static int container_parse(struct rtnl_ematch *e, void *data, size_t len __attribute__((unused))) 18 | { 19 | /* 20 | The kernel may provide more than 4 bytes of data in the future and we want 21 | older libnl versions to be ok with that. We want interfaces to be growable 22 | so we only ever enforce a minimum data length and copy as much as we are 23 | aware of. Thomas Graf. 24 | */ 25 | memcpy(e->e_data, data, sizeof(uint32_t)); 26 | 27 | return 0; 28 | } 29 | 30 | static int container_fill(struct rtnl_ematch *e, struct nl_msg *msg) 31 | { 32 | return nlmsg_append(msg, e->e_data, sizeof(uint32_t), 0); 33 | } 34 | 35 | static struct rtnl_ematch_ops container_ops = { 36 | .eo_kind = TCF_EM_CONTAINER, 37 | .eo_name = "container", 38 | .eo_minlen = sizeof(uint32_t), 39 | .eo_datalen = sizeof(uint32_t), 40 | .eo_parse = container_parse, 41 | .eo_fill = container_fill, 42 | }; 43 | 44 | static void __init container_init(void) 45 | { 46 | rtnl_ematch_register(&container_ops); 47 | } 48 | -------------------------------------------------------------------------------- /lib/route/cls/police.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/route/cls/police.c Policer 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2013 Thomas Graf 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | /** 21 | * @name Policer Type 22 | * @{ 23 | */ 24 | 25 | static const struct trans_tbl police_types[] = { 26 | __ADD(TC_POLICE_UNSPEC,unspec), 27 | __ADD(TC_POLICE_OK,ok), 28 | __ADD(TC_POLICE_RECLASSIFY,reclassify), 29 | __ADD(TC_POLICE_SHOT,shot), 30 | #ifdef TC_POLICE_PIPE 31 | __ADD(TC_POLICE_PIPE,pipe), 32 | #endif 33 | }; 34 | 35 | /** 36 | * Transform a policer type number into a character string (Reentrant). 37 | * @arg type policer type 38 | * @arg buf destination buffer 39 | * @arg len buffer length 40 | * 41 | * Transforms a policer type number into a character string and stores 42 | * it in the provided buffer. 43 | * 44 | * @return The destination buffer or the type encoded in hex if no match was found. 45 | */ 46 | char * nl_police2str(int type, char *buf, size_t len) 47 | { 48 | return __type2str(type, buf, len, police_types, 49 | ARRAY_SIZE(police_types)); 50 | } 51 | 52 | /** 53 | * Transform a character string into a policer type number 54 | * @arg name policer type name 55 | * 56 | * Transform the provided character string specifying a policer 57 | * type into the corresponding numeric value 58 | * 59 | * @return Policer type number or a negative value. 60 | */ 61 | int nl_str2police(const char *name) 62 | { 63 | return __str2type(name, police_types, ARRAY_SIZE(police_types)); 64 | } 65 | 66 | /** @} */ 67 | -------------------------------------------------------------------------------- /lib/route/link/dummy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/route/link/dummy.c Dummy Interfaces 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2011 Thomas Graf 10 | */ 11 | 12 | /** 13 | * @ingroup link 14 | * @defgroup dummy Dummy 15 | * 16 | * @details 17 | * \b Link Type Name: "dummy" 18 | * 19 | * @{ 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | static struct rtnl_link_info_ops dummy_info_ops = { 27 | .io_name = "dummy", 28 | }; 29 | 30 | static void __init dummy_init(void) 31 | { 32 | rtnl_link_register_info(&dummy_info_ops); 33 | } 34 | 35 | static void __exit dummy_exit(void) 36 | { 37 | rtnl_link_unregister_info(&dummy_info_ops); 38 | } 39 | 40 | /** @} */ 41 | -------------------------------------------------------------------------------- /lib/route/link/ifb.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/route/link/ifb.c IFB Interfaces 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2014 Cong Wang 10 | */ 11 | 12 | /** 13 | * @ingroup link 14 | * @defgroup ifb Intermediate Functional Block 15 | * 16 | * @details 17 | * \b Link Type Name: "ifb" 18 | * 19 | * @{ 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | static struct rtnl_link_info_ops ifb_info_ops = { 27 | .io_name = "ifb", 28 | }; 29 | 30 | static void __init ifb_init(void) 31 | { 32 | rtnl_link_register_info(&ifb_info_ops); 33 | } 34 | 35 | static void __exit ifb_exit(void) 36 | { 37 | rtnl_link_unregister_info(&ifb_info_ops); 38 | } 39 | 40 | /** @} */ 41 | -------------------------------------------------------------------------------- /lib/route/pktloc_grammar.l: -------------------------------------------------------------------------------- 1 | %{ 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "pktloc_syntax.h" 8 | %} 9 | 10 | %option 8bit 11 | %option reentrant 12 | %option warn 13 | %option noyywrap 14 | %option noinput 15 | %option nounput 16 | %option bison-bridge 17 | %option bison-locations 18 | %option prefix="pktloc_" 19 | 20 | %% 21 | 22 | [ \t\r\n]+ 23 | 24 | "#".* 25 | 26 | [[:digit:]]+ | 27 | 0[xX][[:xdigit:]]+ { 28 | yylval->i = strtoul(yytext, NULL, 0); 29 | return NUMBER; 30 | } 31 | 32 | "+" { return yylval->i = yytext[0]; } 33 | 34 | [uU]8 { yylval->i = TCF_EM_ALIGN_U8; return ALIGN; } 35 | [uU]16 { yylval->i = TCF_EM_ALIGN_U16; return ALIGN; } 36 | [uU]32 { yylval->i = TCF_EM_ALIGN_U32; return ALIGN; } 37 | 38 | [lL][iI][nN][kK] | 39 | [eE][tT][hH] { yylval->i = TCF_LAYER_LINK; return LAYER; } 40 | [nN][eE][tT] | 41 | [iI][pP] { yylval->i = TCF_LAYER_NETWORK; return LAYER; } 42 | [tT][rR][aA][nN][sS][pP][oO][rR][tT] | 43 | [tT][cC][pP] { yylval->i = TCF_LAYER_TRANSPORT; return LAYER; } 44 | 45 | 46 | [^ \t\r\n+]+ { 47 | yylval->s = strdup(yytext); 48 | if (yylval->s == NULL) 49 | return ERROR; 50 | return NAME; 51 | } 52 | -------------------------------------------------------------------------------- /lib/route/pktloc_syntax.y: -------------------------------------------------------------------------------- 1 | %{ 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | %} 8 | 9 | %locations 10 | %error-verbose 11 | %define api.pure 12 | %name-prefix "pktloc_" 13 | 14 | %parse-param {void *scanner} 15 | %lex-param {void *scanner} 16 | %expect 1 17 | 18 | %union { 19 | struct rtnl_pktloc *l; 20 | uint32_t i; 21 | char *s; 22 | } 23 | 24 | %{ 25 | extern int pktloc_lex(YYSTYPE *, YYLTYPE *, void *); 26 | 27 | static void yyerror(YYLTYPE *locp, void *scanner, const char *msg) 28 | { 29 | NL_DBG(1, "Error while parsing packet location file: %s\n", msg); 30 | } 31 | %} 32 | 33 | %token ERROR NUMBER LAYER ALIGN 34 | %token NAME 35 | 36 | %type mask layer align shift 37 | %type location 38 | 39 | %destructor { free($$); } NAME 40 | 41 | %start input 42 | 43 | %% 44 | 45 | input: 46 | /* empty */ 47 | | location input 48 | ; 49 | 50 | location: 51 | NAME align layer NUMBER mask shift 52 | { 53 | struct rtnl_pktloc *loc; 54 | 55 | if (!(loc = rtnl_pktloc_alloc())) { 56 | NL_DBG(1, "Allocating a packet location " 57 | "object failed.\n"); 58 | YYABORT; 59 | } 60 | 61 | loc->name = $1; 62 | loc->align = $2; 63 | loc->layer = $3; 64 | loc->offset = $4; 65 | loc->mask = $5; 66 | loc->shift = $6; 67 | 68 | if (rtnl_pktloc_add(loc) < 0) { 69 | NL_DBG(1, "Duplicate packet location entry " 70 | "\"%s\"\n", $1); 71 | } 72 | 73 | $$ = loc; 74 | } 75 | ; 76 | 77 | align: 78 | ALIGN 79 | { $$ = $1; } 80 | | NUMBER 81 | { $$ = $1; } 82 | ; 83 | 84 | layer: 85 | /* empty */ 86 | { $$ = TCF_LAYER_NETWORK; } 87 | | LAYER '+' 88 | { $$ = $1; } 89 | ; 90 | 91 | mask: 92 | /* empty */ 93 | { $$ = 0; } 94 | | NUMBER 95 | { $$ = $1; } 96 | ; 97 | 98 | shift: 99 | /* empty */ 100 | { $$ = 0; } 101 | | NUMBER 102 | { $$ = $1; } 103 | ; 104 | -------------------------------------------------------------------------------- /lib/route/qdisc/blackhole.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/route/qdisc/blackhole.c Blackhole Qdisc 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2011 Thomas Graf 10 | */ 11 | 12 | /** 13 | * @ingroup qdisc 14 | * @defgroup qdisc_blackhole Blackhole 15 | * @{ 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | static struct rtnl_tc_ops blackhole_ops = { 23 | .to_kind = "blackhole", 24 | .to_type = RTNL_TC_TYPE_QDISC, 25 | }; 26 | 27 | static void __init blackhole_init(void) 28 | { 29 | rtnl_tc_register(&blackhole_ops); 30 | } 31 | 32 | static void __exit blackhole_exit(void) 33 | { 34 | rtnl_tc_unregister(&blackhole_ops); 35 | } 36 | 37 | /** @} */ 38 | -------------------------------------------------------------------------------- /lib/route/qdisc/ingress.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/route/qdisc/ingress.c ingress 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2013 Cong Wang 10 | */ 11 | 12 | /** 13 | * @ingroup qdisc 14 | * @defgroup qdisc_ingress Ingress qdisc 15 | * 16 | * @{ 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | struct dumb { 27 | uint32_t foo; 28 | }; 29 | 30 | static int dumb_msg_parser(struct rtnl_tc *tc, void *data) 31 | { 32 | return 0; 33 | } 34 | 35 | static void dumb_dump_line(struct rtnl_tc *tc, void *data, 36 | struct nl_dump_params *p) 37 | { 38 | } 39 | 40 | static int dumb_msg_fill(struct rtnl_tc *tc, void *data, struct nl_msg *msg) 41 | { 42 | return 0; 43 | } 44 | 45 | static struct rtnl_tc_ops ingress_ops = { 46 | .to_kind = "ingress", 47 | .to_type = RTNL_TC_TYPE_QDISC, 48 | .to_size = sizeof(struct dumb), 49 | .to_msg_parser = dumb_msg_parser, 50 | .to_dump[NL_DUMP_LINE] = dumb_dump_line, 51 | .to_msg_fill = dumb_msg_fill, 52 | }; 53 | 54 | static void __init ingress_init(void) 55 | { 56 | rtnl_tc_register(&ingress_ops); 57 | } 58 | 59 | static void __exit ingress_exit(void) 60 | { 61 | rtnl_tc_unregister(&ingress_ops); 62 | } 63 | 64 | /** @} */ 65 | -------------------------------------------------------------------------------- /lib/version.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/version.c Run-time version information 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2012 Thomas Graf 10 | */ 11 | 12 | /** 13 | * @ingroup core 14 | * @defgroup utils Utilities 15 | * 16 | * Run-time version information 17 | * 18 | * @{ 19 | */ 20 | 21 | 22 | /** 23 | * @name Run-time version information 24 | * @{ 25 | */ 26 | 27 | #include 28 | 29 | const int nl_ver_num = LIBNL_VER_NUM; 30 | const int nl_ver_maj = LIBNL_VER_MAJ; 31 | const int nl_ver_min = LIBNL_VER_MIN; 32 | const int nl_ver_mic = LIBNL_VER_MIC; 33 | 34 | /** @} */ 35 | 36 | /** @} */ 37 | -------------------------------------------------------------------------------- /libnl-3.0.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libnl 7 | Description: Convenience library for netlink sockets 8 | Version: @PACKAGE_VERSION@ 9 | Libs: -L${libdir} -lnl-@MAJ_VERSION@ 10 | Cflags: -I${includedir}/libnl@MAJ_VERSION@ 11 | -------------------------------------------------------------------------------- /libnl-cli-3.0.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libnl-cli 7 | Description: Command Line Interface library for netlink sockets 8 | Version: @PACKAGE_VERSION@ 9 | Libs: -L${libdir} -lnl-cli-@MAJ_VERSION@ 10 | Cflags: -I${includedir} 11 | Requires: libnl-3.0 libnl-genl-3.0 libnl-nf-3.0 libnl-route-3.0 12 | -------------------------------------------------------------------------------- /libnl-genl-3.0.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libnl-genl 7 | Description: Generic Netlink Library 8 | Version: @PACKAGE_VERSION@ 9 | Requires: libnl-3.0 10 | Libs: -L${libdir} -lnl-genl-@MAJ_VERSION@ 11 | Cflags: -I${includedir}/libnl@MAJ_VERSION@ 12 | -------------------------------------------------------------------------------- /libnl-genl-3.sym: -------------------------------------------------------------------------------- 1 | libnl_3 { 2 | global: 3 | # these functions are in private header files and should have never 4 | # been exported. We might hide them later. 5 | genl_resolve_id; 6 | 7 | genl_connect; 8 | genl_ctrl_alloc_cache; 9 | genl_ctrl_resolve; 10 | genl_ctrl_resolve_grp; 11 | genl_ctrl_search; 12 | genl_ctrl_search_by_name; 13 | genl_family_add_grp; 14 | genl_family_add_op; 15 | genl_family_alloc; 16 | genl_family_get_hdrsize; 17 | genl_family_get_id; 18 | genl_family_get_maxattr; 19 | genl_family_get_name; 20 | genl_family_get_version; 21 | genl_family_ops; 22 | genl_family_put; 23 | genl_family_set_hdrsize; 24 | genl_family_set_id; 25 | genl_family_set_maxattr; 26 | genl_family_set_name; 27 | genl_family_set_version; 28 | genl_handle_msg; 29 | genl_mngt_resolve; 30 | genl_op2name; 31 | genl_ops_resolve; 32 | genl_register; 33 | genl_register_family; 34 | genl_send_simple; 35 | genl_unregister; 36 | genl_unregister_family; 37 | genlmsg_attrdata; 38 | genlmsg_attrlen; 39 | genlmsg_data; 40 | genlmsg_hdr; 41 | genlmsg_len; 42 | genlmsg_parse; 43 | genlmsg_put; 44 | genlmsg_user_data; 45 | genlmsg_user_datalen; 46 | genlmsg_user_hdr; 47 | genlmsg_valid_hdr; 48 | genlmsg_validate; 49 | local: 50 | *; 51 | }; 52 | -------------------------------------------------------------------------------- /libnl-idiag-3.0.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libnl-idiag 7 | Description: Netlink Inet Diag Family Library 8 | Version: @PACKAGE_VERSION@ 9 | Requires: libnl-3.0 10 | Libs: -L${libdir} -lnl-idiag-@MAJ_VERSION@ 11 | Cflags: -I${includedir}/libnl@MAJ_VERSION@ 12 | 13 | -------------------------------------------------------------------------------- /libnl-nf-3.0.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libnl-nf 7 | Description: Netfilter Netlink Library 8 | Version: @PACKAGE_VERSION@ 9 | Requires: libnl-route-3.0 10 | Libs: -L${libdir} -lnl-nf-@MAJ_VERSION@ 11 | Cflags: -I${includedir}/libnl@MAJ_VERSION@ 12 | -------------------------------------------------------------------------------- /libnl-route-3.0.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libnl-route 7 | Description: Netlink Routing Family Library 8 | Version: @PACKAGE_VERSION@ 9 | Requires: libnl-3.0 10 | Libs: -L${libdir} -lnl-route-@MAJ_VERSION@ 11 | Cflags: -I${includedir}/libnl@MAJ_VERSION@ 12 | -------------------------------------------------------------------------------- /libnl-xfrm-3.0.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libnl-xfrm 7 | Description: Netlink Routing Family Library 8 | Version: @PACKAGE_VERSION@ 9 | Requires: libnl-3.0 10 | Libs: -L${libdir} -lnl-xfrm-@MAJ_VERSION@ 11 | Cflags: -I${includedir}/libnl@MAJ_VERSION@ 12 | -------------------------------------------------------------------------------- /m4/.gitignore: -------------------------------------------------------------------------------- 1 | /lt*.m4 2 | /libtool.m4 3 | -------------------------------------------------------------------------------- /man/Makefile.am: -------------------------------------------------------------------------------- 1 | # -*- Makefile -*- 2 | 3 | dist_man8_MANS = \ 4 | nl-classid-lookup.8 \ 5 | nl-pktloc-lookup.8 \ 6 | nl-qdisc-add.8 nl-qdisc-delete.8 nl-qdisc-list.8 \ 7 | genl-ctrl-list.8 8 | -------------------------------------------------------------------------------- /man/nl-classid-lookup.8: -------------------------------------------------------------------------------- 1 | .TH nl\-classid\-lookup 8 "19 October 2010" "libnl" 2 | .SH NAME 3 | nl\-classid\-lookup - Lookup classid definitions 4 | .SH SYNOPSIS 5 | .B nl\-classid\-lookup 6 | .RB [ \-hv ] 7 | .RB [ \-r ] 8 | .RB [ \-\-raw ] 9 | .I name 10 | 11 | .SH DESCRIPTION 12 | .PP 13 | nl\-classid\-lookup searches the classid database for a matching entry. It is used 14 | to resolve qdisc/class names to classid values and vice versa. 15 | 16 | .SH OPTIONS 17 | .TP 18 | .BR \-\^h " or " \-\-help 19 | Print help text to console and exit. 20 | .TP 21 | .BR \-\^v " or " \-\-version 22 | Print versioning information to console and exit. 23 | .TP 24 | .BR \-\^r " or " \-\-reverse 25 | Do a reverse lookup. Lookup a classid and print its name. 26 | .TP 27 | .B \-\-raw 28 | Print the raw classid in hexadecimal format, do not pretty print it. 29 | 30 | .SH USAGE 31 | .PP 32 | Resolve the qdisc/class name "interactive": 33 | .PP 34 | .RS 35 | # nl\-classid\-lookup interactive 36 | .RE 37 | .PP 38 | Lookup the name of classid 1:2: 39 | .PP 40 | .RS 41 | # nl\-classid\-lookup -r 1:2 42 | .RE 43 | 44 | .SH FILES 45 | .PP 46 | /etc/libnl/classid 47 | 48 | .SH AUTHOR 49 | .PP 50 | Thomas Graf is the original author and current maintainer of libnl and 51 | libnl tools. Many people have contributed to it since. 52 | -------------------------------------------------------------------------------- /man/nl-pktloc-lookup.8: -------------------------------------------------------------------------------- 1 | .TH nl\-pktloc-lookup 8 "27 October 2010" "libnl" 2 | .SH NAME 3 | nl\-pktloc\-lookup - Lookup packet location definitions 4 | .SH SYNOPSIS 5 | .B nl\-pktloc\-lookup 6 | .I name 7 | .br 8 | .B nl\-pktloc\-lookup \-\-list 9 | 10 | .SH DESCRIPTION 11 | .PP 12 | nl\-pktloc\-lookup searches the packet location database for a matching 13 | entry. It is used to resolve packet location aliases to their definition, 14 | i.e. alignment, layer, offset, and mask. 15 | 16 | .SH OPTIONS 17 | .TP 18 | .BR \-\^h " or " \-\-help 19 | Print help text to console and exit. 20 | .TP 21 | .BR \-\^v " or " \-\-version 22 | Print versioning information to console and exit. 23 | .TP 24 | .BR \-\^l " or " \-\-list 25 | List all packet location definitions. 26 | .TP 27 | .BR \-\-u32=VALUE 28 | Prints the packet location definition in a special format that is 29 | understood by iproute2's u32 selector parser. It will output a 30 | u32 selector which will compare the provided value with the value 31 | specified by the packet location. 32 | 33 | Please note that due to the limitation of u32, it is not possible 34 | to use packet locations based on the link layer. nl-pktloc-lookup 35 | will print an error message in this case. 36 | 37 | Example: 38 | selector=$(nl-pktloc-lookup --u32 22 tcp.sport) 39 | tc filter add [...] u32 match $(selector) flowid 1:2 40 | 41 | .SH FILES 42 | .PP 43 | /etc/libnl/pktloc 44 | 45 | .SH AUTHOR 46 | .PP 47 | Thomas Graf is the original author and current maintainer of libnl and 48 | libnl tools. Many people have contributed to it since. 49 | -------------------------------------------------------------------------------- /man/nl-qdisc-delete.8: -------------------------------------------------------------------------------- 1 | .so man8/nl-qdisc-add.8 2 | -------------------------------------------------------------------------------- /man/nl-qdisc-list.8: -------------------------------------------------------------------------------- 1 | .so man8/nl-qdisc-add.8 2 | -------------------------------------------------------------------------------- /python/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | capi_wrap.c 3 | capi.py 4 | setup.py 5 | -------------------------------------------------------------------------------- /python/Makefile.am: -------------------------------------------------------------------------------- 1 | # -*- Makefile -*- 2 | 3 | SUBDIRS = doc examples netlink tests 4 | -------------------------------------------------------------------------------- /python/README: -------------------------------------------------------------------------------- 1 | 2 | *************************************************************************** 3 | 4 | NOTE: The python wrapper is experimental and may or may not work. 5 | 6 | *************************************************************************** 7 | 8 | For the brave: 9 | 10 | (requires an installed libnl) 11 | - $ python ./setup.py build 12 | - $ sudo python ./setup.py install 13 | -------------------------------------------------------------------------------- /python/doc/Makefile.am: -------------------------------------------------------------------------------- 1 | # -*- Makefile -*- 2 | 3 | EXTRA_DIST = \ 4 | conf.py \ 5 | core.rst \ 6 | index.rst \ 7 | route_addr.rst \ 8 | route.rst 9 | -------------------------------------------------------------------------------- /python/doc/index.rst: -------------------------------------------------------------------------------- 1 | .. libnl-python documentation master file, created by 2 | sphinx-quickstart on Mon May 9 10:58:58 2011. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to libnl-python's documentation! 7 | ======================================== 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | core 15 | route 16 | route_addr 17 | 18 | Indices and tables 19 | ================== 20 | 21 | * :ref:`genindex` 22 | * :ref:`modindex` 23 | * :ref:`search` 24 | 25 | -------------------------------------------------------------------------------- /python/doc/route.rst: -------------------------------------------------------------------------------- 1 | ********************** 2 | Routing 3 | ********************** 4 | -------------------------------------------------------------------------------- /python/doc/route_addr.rst: -------------------------------------------------------------------------------- 1 | ================= 2 | Network Addresses 3 | ================= 4 | 5 | The **Address** module provides access to the network address configuration 6 | of the kernel. It provides an interface to fetch all configured addresses, 7 | add new addresses and to delete existing addresses. 8 | 9 | Fetching the list of network addresses is achieved by creating a new 10 | address cache:: 11 | 12 | import netlink.route.address as Address 13 | 14 | addr_cache = Address.AddressCache() 15 | addr_cache.refill() 16 | 17 | for addr in addr_cache: 18 | print addr 19 | 20 | .. py:module:: netlink.route.addr 21 | 22 | 23 | AddressCache 24 | ------------ 25 | 26 | .. py:class:: AddressCache 27 | 28 | Represents a cache containing all or a subset of network addresses. 29 | 30 | .. py:method:: lookup(ifindex, local) 31 | 32 | Lookup the address which matches ifindex and local address 33 | 34 | :raises: KeyError if address is not found. 35 | 36 | Address 37 | ------- 38 | 39 | .. py:class:: Address 40 | 41 | Representation of a configured network address. 42 | 43 | .. py:attribute:: ifindex 44 | 45 | Interface index 46 | 47 | :rtype: int 48 | -------------------------------------------------------------------------------- /python/examples/Makefile.am: -------------------------------------------------------------------------------- 1 | # -*- Makefile -*- 2 | 3 | EXTRA_DIST = \ 4 | iface.py \ 5 | nl80211.py \ 6 | wiphy.py 7 | -------------------------------------------------------------------------------- /python/netlink/Makefile.am: -------------------------------------------------------------------------------- 1 | # -*- Makefile -*- 2 | 3 | SUBDIRS = route genl 4 | 5 | EXTRA_DIST = \ 6 | capi.i \ 7 | fixes.h \ 8 | __init__.py \ 9 | core.py \ 10 | util.py \ 11 | utils.h 12 | -------------------------------------------------------------------------------- /python/netlink/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/python/netlink/__init__.py -------------------------------------------------------------------------------- /python/netlink/fixes.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /python/netlink/genl/Makefile.am: -------------------------------------------------------------------------------- 1 | # -*- Makefile -*- 2 | 3 | EXTRA_DIST = \ 4 | capi.i \ 5 | __init__.py 6 | -------------------------------------------------------------------------------- /python/netlink/genl/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/python/netlink/genl/__init__.py -------------------------------------------------------------------------------- /python/netlink/route/Makefile.am: -------------------------------------------------------------------------------- 1 | # -*- Makefile -*- 2 | 3 | EXTRA_DIST = \ 4 | capi.i \ 5 | __init__.py \ 6 | address.py \ 7 | link.py \ 8 | tc.py \ 9 | links/__init__.py \ 10 | links/dummy.py \ 11 | links/inet.py \ 12 | links/vlan.py \ 13 | qdisc/__init__.py \ 14 | qdisc/htb.py 15 | -------------------------------------------------------------------------------- /python/netlink/route/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/python/netlink/route/__init__.py -------------------------------------------------------------------------------- /python/netlink/route/links/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/python/netlink/route/links/__init__.py -------------------------------------------------------------------------------- /python/netlink/route/links/dummy.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2011 Thomas Graf 3 | # 4 | 5 | """Dummy 6 | 7 | """ 8 | from __future__ import absolute_import 9 | 10 | __version__ = '1.0' 11 | __all__ = [ 12 | 'init', 13 | ] 14 | 15 | 16 | class DummyLink(object): 17 | def __init__(self, link): 18 | self._rtnl_link = link 19 | 20 | @staticmethod 21 | def brief(): 22 | return 'dummy' 23 | 24 | def init(link): 25 | link.dummy = DummyLink(link._rtnl_link) 26 | return link.dummy 27 | -------------------------------------------------------------------------------- /python/netlink/route/qdisc/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tgraf/libnl/43bfe43fc58130efa3bda010621aef67a279faca/python/netlink/route/qdisc/__init__.py -------------------------------------------------------------------------------- /python/netlink/utils.h: -------------------------------------------------------------------------------- 1 | struct list_head { 2 | struct list_head *next; 3 | }; 4 | 5 | #define LIST_HEAD(name) \ 6 | struct list_head name = { &(name) } 7 | 8 | static inline int list_empty(const struct list_head *head) 9 | { 10 | return head->next == head; 11 | } 12 | 13 | static inline void list_add(struct list_head *new, struct list_head *head) 14 | { 15 | new->next = head->next; 16 | head->next = new; 17 | } 18 | 19 | static inline void list_del(struct list_head *entry, struct list_head *prev) 20 | { 21 | prev->next = entry->next; 22 | entry->next = entry; 23 | } 24 | 25 | #define list_for_each_safe(pos, n, head) \ 26 | for (n = (head), pos = (head)->next; pos != (head); \ 27 | n = pos, pos = n->next) 28 | 29 | #undef offsetof 30 | #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) 31 | 32 | #define container_of(ptr, type, member) ({ \ 33 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ 34 | (type *)( (char *)__mptr - offsetof(type,member) );}) 35 | 36 | #ifdef DEBUG 37 | #define pynl_dbg(fmt, ...) \ 38 | fprintf(stderr, "%s: " fmt, __func__, __VA_ARGS__) 39 | #else 40 | #define pynl_dbg(fmt, ...) 41 | #endif 42 | -------------------------------------------------------------------------------- /python/setup.py.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from distutils.core import setup, Extension 4 | 5 | opts = ['-O', '-nodefaultctor'] 6 | include = ['@top_builddir@/include', '@top_srcdir@/include'] 7 | library_dirs = ['@top_builddir@/lib/.libs'] 8 | 9 | netlink_capi = Extension('netlink/_capi', 10 | sources = ['@srcdir@/netlink/capi.i'], 11 | include_dirs = include, 12 | swig_opts = opts, 13 | library_dirs = library_dirs, 14 | libraries = ['nl-3'], 15 | ) 16 | 17 | route_capi = Extension('netlink/route/_capi', 18 | sources = ['@srcdir@/netlink/route/capi.i'], 19 | include_dirs = include, 20 | swig_opts = opts, 21 | library_dirs = library_dirs, 22 | libraries = ['nl-3', 'nl-route-3'], 23 | ) 24 | 25 | genl_capi = Extension('netlink/genl/_capi', 26 | sources = ['@srcdir@/netlink/genl/capi.i'], 27 | include_dirs = include, 28 | swig_opts = opts, 29 | library_dirs = library_dirs, 30 | libraries = ['nl-3', 'nl-genl-3'], 31 | ) 32 | 33 | setup(name = 'netlink', 34 | version = '1.0', 35 | description = 'Python wrapper for netlink protocols', 36 | author = 'Thomas Graf', 37 | author_email = 'tgraf@suug.ch', 38 | url = 'http://www.infradead.org/~tgr/libnl/', 39 | license = 'LGPL 2', 40 | platforms = 'linux2', 41 | long_description = 'Experimental python bindings for libnl', 42 | ext_modules = [netlink_capi, route_capi, genl_capi], 43 | package_dir = {'': '@srcdir@'}, 44 | packages = ['netlink', 'netlink.genl', 'netlink.route', 45 | 'netlink.route.links', 'netlink.route.qdisc'], 46 | ) 47 | -------------------------------------------------------------------------------- /python/tests/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | # -*- Makefile -*- 3 | 4 | EXTRA_DIST = \ 5 | test-create-bridge.py 6 | -------------------------------------------------------------------------------- /python/tests/test-create-bridge.py: -------------------------------------------------------------------------------- 1 | import netlink.core as netlink 2 | import netlink.route.capi as capi 3 | import netlink.route.link as link 4 | 5 | sock = netlink.lookup_socket(netlink.NETLINK_ROUTE) 6 | 7 | cache = link.LinkCache() 8 | cache.refill(sock) 9 | 10 | testtap1 = cache['testtap1'] 11 | print testtap1 12 | 13 | lbr = link.Link() 14 | lbr.type = 'bridge' 15 | lbr.name = 'testbridge' 16 | print lbr 17 | lbr.add() 18 | 19 | cache.refill(sock) 20 | lbr = cache['testbridge'] 21 | print lbr 22 | 23 | lbr.enslave(testtap1) 24 | cache.refill(sock) 25 | testtap1 = cache['testtap1'] 26 | 27 | print capi.rtnl_link_is_bridge(lbr._rtnl_link) 28 | print capi.rtnl_link_get_master(testtap1._rtnl_link) 29 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | genl-ctrl-list 2 | /nf-ct-add 3 | nf-ct-list 4 | nf-exp-list 5 | nf-exp-add 6 | nf-exp-delete 7 | nf-log 8 | nf-monitor 9 | nl-addr-add 10 | nl-addr-delete 11 | nl-addr-list 12 | nl-fib-lookup 13 | nl-link-list 14 | nl-link-ifindex2name 15 | nl-link-name2ifindex 16 | nl-link-set 17 | nl-link-stats 18 | nl-list-caches 19 | nl-list-sockets 20 | nl-monitor 21 | nl-neigh-add 22 | nl-neigh-delete 23 | nl-neigh-list 24 | nl-neightbl-list 25 | nl-qdisc-add 26 | nl-qdisc-delete 27 | nl-qdisc-list 28 | nl-class-add 29 | nl-class-delete 30 | nl-class-list 31 | nl-cls-add 32 | nl-cls-delete 33 | nl-cls-list 34 | nl-route-add 35 | nl-route-delete 36 | nl-route-list 37 | nl-route-get 38 | nl-rule-list 39 | nl-tctree-list 40 | nl-util-addr 41 | nf-queue 42 | nl-classid-lookup 43 | nl-pktloc-lookup 44 | nl-link-enslave 45 | nl-link-release 46 | idiag-socket-details 47 | -------------------------------------------------------------------------------- /src/genl-ctrl-list.c: -------------------------------------------------------------------------------- 1 | /* 2 | * src/genl-ctrl-list.c List Generic Netlink Families 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2012 Thomas Graf 10 | */ 11 | 12 | #include 13 | 14 | static struct nl_cache *alloc_genl_family_cache(struct nl_sock *sk) 15 | { 16 | return nl_cli_alloc_cache(sk, "generic netlink family", 17 | genl_ctrl_alloc_cache); 18 | } 19 | 20 | static void print_usage(void) 21 | { 22 | printf( 23 | "Usage: genl-ctrl-list [--details]\n" 24 | "\n" 25 | "Options\n" 26 | " -d, --details Include detailed information in the list\n" 27 | " -h, --help Show this help\n" 28 | " -v, --version Show versioning information\n" 29 | ); 30 | exit(0); 31 | } 32 | 33 | int main(int argc, char *argv[]) 34 | { 35 | struct nl_sock *sock; 36 | struct nl_cache *family_cache; 37 | struct nl_dump_params params = { 38 | .dp_type = NL_DUMP_LINE, 39 | .dp_fd = stdout, 40 | }; 41 | 42 | sock = nl_cli_alloc_socket(); 43 | nl_cli_connect(sock, NETLINK_GENERIC); 44 | family_cache = alloc_genl_family_cache(sock); 45 | 46 | for (;;) { 47 | int c, optidx = 0; 48 | static struct option long_opts[] = { 49 | { "details", 0, 0, 'd' }, 50 | { "format", 1, 0, 'f' }, 51 | { "help", 0, 0, 'h' }, 52 | { "version", 0, 0, 'v' }, 53 | { 0, 0, 0, 0 } 54 | }; 55 | 56 | c = getopt_long(argc, argv, "df:hv", long_opts, &optidx); 57 | if (c == -1) 58 | break; 59 | 60 | switch (c) { 61 | case 'f': params.dp_type = nl_cli_parse_dumptype(optarg); break; 62 | case 'd': params.dp_type = NL_DUMP_DETAILS; break; 63 | case 'h': print_usage(); break; 64 | case 'v': nl_cli_print_version(); break; 65 | } 66 | } 67 | 68 | nl_cache_dump(family_cache, ¶ms); 69 | 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /src/lib/Makefile.am: -------------------------------------------------------------------------------- 1 | # -*- Makefile -*- 2 | 3 | AM_CPPFLAGS = \ 4 | -I${top_srcdir}/include/linux-private \ 5 | -I${top_srcdir}/include \ 6 | -I${top_builddir}/include \ 7 | -D_GNU_SOURCE \ 8 | -DPKGLIBDIR=\"$(pkglibdir)\" \ 9 | -DSYSCONFDIR=\"$(sysconfdir)\" \ 10 | -rdynamic 11 | 12 | AM_CFLAGS = -Wall 13 | AM_LDFLAGS = \ 14 | -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) 15 | NL_LIBADD = \ 16 | -L${top_builddir}/lib \ 17 | -ldl 18 | 19 | #nobase_pkglib_LTLIBRARIES = cls/basic.la cls/ematch/cmp.la 20 | #cls_basic_la_LDFLAGS = -module -version-info 2:0:0 21 | #cls_ematch_cmp_la_LDFLAGS = -module -version-info 2:0:0 22 | 23 | #cls/ematch_grammar.c: cls/ematch_grammar.l 24 | # $(LEX) --header-file=cls/ematch_grammar.h $(LFLAGS) -o $@ $^ 25 | 26 | #cls/ematch_syntax.c: cls/ematch_syntax.y 27 | # $(YACC) -d $(YFLAGS) -o $@ $^ 28 | 29 | #cls/pktloc_grammar.c: cls/pktloc_grammar.l 30 | # $(LEX) --header-file=cls/pktloc_grammar.h $(LFLAGS) -o $@ $^ 31 | 32 | #cls/pktloc_syntax.c: cls/pktloc_syntax.y 33 | # $(YACC) -d $(YFLAGS) -o $@ $^ 34 | 35 | #CLEANFILES = \ 36 | # cls/ematch_grammar.c cls/ematch_grammar.h \ 37 | # cls/ematch_syntax.c cls/ematch_syntax.h \ 38 | # cls/pktloc_grammar.c cls/pktloc_grammar.h \ 39 | # cls/pktloc_syntax.c cls/pktloc_syntax.h 40 | 41 | lib_LTLIBRARIES = \ 42 | libnl-cli-3.la 43 | 44 | libnl_cli_3_la_LDFLAGS = \ 45 | -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ 46 | -Wl,--version-script=$(top_builddir)/libnl-cli-3.sym 47 | libnl_cli_3_la_DEPENDENCIES = \ 48 | $(top_builddir)/libnl-cli-3.sym 49 | 50 | libnl_cli_3_la_LIBADD = ${top_builddir}/lib/libnl-3.la \ 51 | ${top_builddir}/lib/libnl-route-3.la \ 52 | ${top_builddir}/lib/libnl-nf-3.la \ 53 | ${top_builddir}/lib/libnl-genl-3.la ${NL_LIBADD} 54 | 55 | libnl_cli_3_la_SOURCES = \ 56 | utils.c addr.c ct.c link.c neigh.c rule.c route.c \ 57 | tc.c qdisc.c class.c cls.c exp.c 58 | # cls/ematch_syntax.c cls/ematch_grammar.c cls/ematch.c 59 | # cls/pktloc_syntax.c cls/pktloc_grammar.c cls/utils.c 60 | -------------------------------------------------------------------------------- /src/lib/class.c: -------------------------------------------------------------------------------- 1 | /* 2 | * src/lib/class.c CLI Class Helpers 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2010-2011 Thomas Graf 10 | */ 11 | 12 | /** 13 | * @ingroup cli 14 | * @defgroup cli_class Traffic Classes 15 | * @{ 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | struct rtnl_class *nl_cli_class_alloc(void) 22 | { 23 | struct rtnl_class *class; 24 | 25 | if (!(class = rtnl_class_alloc())) 26 | nl_cli_fatal(ENOMEM, "Unable to allocate class object"); 27 | 28 | return class; 29 | } 30 | 31 | struct nl_cache *nl_cli_class_alloc_cache(struct nl_sock *sock, int ifindex) 32 | { 33 | struct nl_cache *cache; 34 | int err; 35 | 36 | if ((err = rtnl_class_alloc_cache(sock, ifindex, &cache)) < 0) 37 | nl_cli_fatal(err, "Unable to allocate class cache: %s", 38 | nl_geterror(err)); 39 | 40 | nl_cache_mngt_provide(cache); 41 | 42 | return cache; 43 | } 44 | 45 | /** @} */ 46 | -------------------------------------------------------------------------------- /src/lib/cls.c: -------------------------------------------------------------------------------- 1 | /* 2 | * src/lib/cls.c CLI Classifier Helpers 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2010-2011 Thomas Graf 10 | */ 11 | 12 | /** 13 | * @ingroup cli 14 | * @defgroup cli_cls Classifiers 15 | * @{ 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | struct rtnl_cls *nl_cli_cls_alloc(void) 23 | { 24 | struct rtnl_cls *cls; 25 | 26 | if (!(cls = rtnl_cls_alloc())) 27 | nl_cli_fatal(ENOMEM, "Unable to allocate classifier object"); 28 | 29 | return cls; 30 | } 31 | 32 | struct nl_cache *nl_cli_cls_alloc_cache(struct nl_sock *sock, int ifindex, 33 | uint32_t parent) 34 | { 35 | struct nl_cache *cache; 36 | int err; 37 | 38 | if ((err = rtnl_cls_alloc_cache(sock, ifindex, parent, &cache)) < 0) 39 | nl_cli_fatal(err, "Unable to allocate classifier cache: %s", 40 | nl_geterror(err)); 41 | 42 | return cache; 43 | } 44 | 45 | void nl_cli_cls_parse_proto(struct rtnl_cls *cls, char *arg) 46 | { 47 | int proto; 48 | 49 | if ((proto = nl_str2ether_proto(arg)) < 0) 50 | nl_cli_fatal(proto, "Unknown protocol \"%s\".", arg); 51 | 52 | rtnl_cls_set_protocol(cls, proto); 53 | } 54 | 55 | struct rtnl_ematch_tree *nl_cli_cls_parse_ematch(struct rtnl_cls *cls, char *arg) 56 | { 57 | struct rtnl_ematch_tree *tree; 58 | char *errstr = NULL; 59 | int err; 60 | 61 | if ((err = rtnl_ematch_parse_expr(arg, &errstr, &tree)) < 0) 62 | nl_cli_fatal(err, "Unable to parse ematch expression: %s", 63 | errstr); 64 | 65 | if (errstr) 66 | free(errstr); 67 | 68 | return tree; 69 | } 70 | 71 | /** @} */ 72 | -------------------------------------------------------------------------------- /src/lib/qdisc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * src/lib/qdisc.c CLI QDisc Helpers 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2008-2011 Thomas Graf 10 | */ 11 | 12 | /** 13 | * @ingroup cli 14 | * @defgroup cli_qdisc Queueing Disciplines 15 | * @{ 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | struct rtnl_qdisc *nl_cli_qdisc_alloc(void) 23 | { 24 | struct rtnl_qdisc *qdisc; 25 | 26 | if (!(qdisc = rtnl_qdisc_alloc())) 27 | nl_cli_fatal(ENOMEM, "Unable to allocate qdisc object"); 28 | 29 | return qdisc; 30 | } 31 | 32 | /** @} */ 33 | -------------------------------------------------------------------------------- /src/lib/rule.c: -------------------------------------------------------------------------------- 1 | /* 2 | * src/lib/rule.c CLI Routing Rule Helpers 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2008-2009 Thomas Graf 10 | */ 11 | 12 | /** 13 | * @ingroup cli 14 | * @defgroup cli_rule Routing Rules 15 | * 16 | * @{ 17 | */ 18 | 19 | #include 20 | #include 21 | 22 | struct rtnl_rule *nl_cli_rule_alloc(void) 23 | { 24 | struct rtnl_rule *rule; 25 | 26 | rule = rtnl_rule_alloc(); 27 | if (!rule) 28 | nl_cli_fatal(ENOMEM, "Unable to allocate rule object"); 29 | 30 | return rule; 31 | } 32 | 33 | struct nl_cache *nl_cli_rule_alloc_cache(struct nl_sock *sk) 34 | { 35 | struct nl_cache *cache; 36 | int err; 37 | 38 | if ((err = rtnl_rule_alloc_cache(sk, AF_UNSPEC, &cache)) < 0) 39 | nl_cli_fatal(err, "Unable to allocate routing rule cache: %s\n", 40 | nl_geterror(err)); 41 | 42 | nl_cache_mngt_provide(cache); 43 | 44 | return cache; 45 | } 46 | 47 | void nl_cli_rule_parse_family(struct rtnl_rule *rule, char *arg) 48 | { 49 | int family; 50 | 51 | if ((family = nl_str2af(arg)) != AF_UNSPEC) 52 | rtnl_rule_set_family(rule, family); 53 | } 54 | 55 | /** @} */ 56 | -------------------------------------------------------------------------------- /src/nl-link-enslave.c: -------------------------------------------------------------------------------- 1 | /* 2 | * src/nl-link-enslave.c Enslave a link 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2011 Thomas Graf 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | int main(int argc, char *argv[]) 17 | { 18 | struct nl_sock *sock; 19 | struct nl_cache *link_cache; 20 | struct rtnl_link *master, *slave; 21 | int err; 22 | 23 | if (argc < 3) { 24 | fprintf(stderr, "Usage: nl-link-enslave master slave\n"); 25 | return 1; 26 | } 27 | 28 | sock = nl_cli_alloc_socket(); 29 | nl_cli_connect(sock, NETLINK_ROUTE); 30 | link_cache = nl_cli_link_alloc_cache(sock); 31 | 32 | if (!(master = rtnl_link_get_by_name(link_cache, argv[1]))) { 33 | fprintf(stderr, "Unknown link: %s\n", argv[1]); 34 | return 1; 35 | } 36 | 37 | if (!(slave = rtnl_link_get_by_name(link_cache, argv[2]))) { 38 | fprintf(stderr, "Unknown link: %s\n", argv[2]); 39 | return 1; 40 | } 41 | 42 | if ((err = rtnl_link_bond_enslave(sock, master, slave)) < 0) { 43 | fprintf(stderr, "Unable to enslave %s to %s: %s\n", 44 | argv[2], argv[1], nl_geterror(err)); 45 | return 1; 46 | } 47 | 48 | return 0; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /src/nl-link-ifindex2name.c: -------------------------------------------------------------------------------- 1 | /* 2 | * src/nl-link-ifindex2name.c Transform a interface index to its name 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2009 Thomas Graf 10 | */ 11 | 12 | #include 13 | #include 14 | 15 | static void print_usage(void) 16 | { 17 | printf("Usage: nl-link-ifindex2name \n"); 18 | exit(0); 19 | } 20 | 21 | int main(int argc, char *argv[]) 22 | { 23 | struct nl_sock *sock; 24 | struct nl_cache *link_cache; 25 | char name[IFNAMSIZ]; 26 | uint32_t ifindex; 27 | 28 | if (argc < 2) 29 | print_usage(); 30 | 31 | sock = nl_cli_alloc_socket(); 32 | nl_cli_connect(sock, NETLINK_ROUTE); 33 | link_cache = nl_cli_link_alloc_cache(sock); 34 | 35 | ifindex = nl_cli_parse_u32(argv[1]); 36 | 37 | if (!rtnl_link_i2name(link_cache, ifindex, name, sizeof(name))) 38 | nl_cli_fatal(ENOENT, "Interface index %d does not exist", 39 | ifindex); 40 | 41 | printf("%s\n", name); 42 | 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /src/nl-link-name2ifindex.c: -------------------------------------------------------------------------------- 1 | /* 2 | * src/nl-link-name2ifindex.c Transform a interface name to its index 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2008 Thomas Graf 10 | */ 11 | 12 | #include 13 | #include 14 | 15 | static void print_usage(void) 16 | { 17 | printf("Usage: nl-link-name2ifindex \n"); 18 | exit(0); 19 | } 20 | 21 | int main(int argc, char *argv[]) 22 | { 23 | struct nl_sock *sock; 24 | struct nl_cache *link_cache; 25 | uint32_t ifindex; 26 | 27 | if (argc < 2) 28 | print_usage(); 29 | 30 | sock = nl_cli_alloc_socket(); 31 | nl_cli_connect(sock, NETLINK_ROUTE); 32 | link_cache = nl_cli_link_alloc_cache(sock); 33 | 34 | if (!(ifindex = rtnl_link_name2i(link_cache, argv[1]))) 35 | nl_cli_fatal(ENOENT, "Interface \"%s\" does not exist", 36 | argv[1]); 37 | 38 | printf("%u\n", ifindex); 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /src/nl-link-release.c: -------------------------------------------------------------------------------- 1 | /* 2 | * src/nl-link-release.c release a link 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2011 Thomas Graf 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | int main(int argc, char *argv[]) 17 | { 18 | struct nl_sock *sock; 19 | struct nl_cache *link_cache; 20 | struct rtnl_link *slave; 21 | int err; 22 | 23 | if (argc < 2) { 24 | fprintf(stderr, "Usage: nl-link-release slave\n"); 25 | return 1; 26 | } 27 | 28 | sock = nl_cli_alloc_socket(); 29 | nl_cli_connect(sock, NETLINK_ROUTE); 30 | link_cache = nl_cli_link_alloc_cache(sock); 31 | 32 | if (!(slave = rtnl_link_get_by_name(link_cache, argv[1]))) { 33 | fprintf(stderr, "Unknown link: %s\n", argv[1]); 34 | return 1; 35 | } 36 | 37 | if ((err = rtnl_link_bond_release(sock, slave)) < 0) { 38 | fprintf(stderr, "Unable to release slave %s: %s\n", 39 | argv[1], nl_geterror(err)); 40 | return 1; 41 | } 42 | 43 | return 0; 44 | } 45 | 46 | -------------------------------------------------------------------------------- /src/nl-list-sockets.c: -------------------------------------------------------------------------------- 1 | /* 2 | * nl-list-sockets.c Pretty-print /proc/net/netlink 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2009 Thomas Graf 10 | */ 11 | 12 | #include 13 | 14 | #define PROC_NETLINK "/proc/net/netlink" 15 | 16 | int main(int argc, char *argv[]) 17 | { 18 | FILE *fd; 19 | char buf[2048], p[64]; 20 | 21 | fd = fopen(PROC_NETLINK, "r"); 22 | if (fd == NULL) { 23 | perror("fopen"); 24 | return -1; 25 | } 26 | 27 | printf("Address Family PID Groups rmem " 28 | "wmem CB refcnt\n"); 29 | 30 | while (fgets(buf, sizeof(buf), fd)) { 31 | unsigned long sk, cb; 32 | int ret, proto, pid, rmem, wmem, refcnt; 33 | unsigned int groups; 34 | 35 | ret = sscanf(buf, "%lx %d %d %08x %d %d %lx %d\n", 36 | &sk, &proto, &pid, &groups, &rmem, &wmem, 37 | &cb, &refcnt); 38 | if (ret != 8) 39 | continue; 40 | 41 | printf("0x%016lx %-16s %-6d %08x %-6d %-6d 0x%08lx %d\n", 42 | sk, nl_nlfamily2str(proto, p, sizeof(p)), pid, 43 | groups, rmem, wmem, cb, refcnt); 44 | } 45 | 46 | fclose(fd); 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /src/nl-neightbl-list.c: -------------------------------------------------------------------------------- 1 | /* 2 | * src/nl-neightbl-list.c Dump neighbour tables 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2009 Thomas Graf 10 | */ 11 | 12 | #include 13 | #include 14 | 15 | static void print_usage(void) 16 | { 17 | printf( 18 | "Usage: nl-neightbl-list [OPTION]...\n" 19 | "\n" 20 | "Options\n" 21 | " -f, --format=TYPE Output format { brief | details | stats }\n" 22 | " -h, --help Show this help\n" 23 | " -v, --version Show versioning information\n" 24 | ); 25 | exit(0); 26 | } 27 | 28 | int main(int argc, char *argv[]) 29 | { 30 | struct nl_sock *sock; 31 | struct nl_cache *neightbl_cache; 32 | struct nl_dump_params params = { 33 | .dp_type = NL_DUMP_LINE, 34 | .dp_fd = stdout, 35 | }; 36 | 37 | sock = nl_cli_alloc_socket(); 38 | nl_cli_connect(sock, NETLINK_ROUTE); 39 | nl_cli_link_alloc_cache(sock); 40 | neightbl_cache = nl_cli_alloc_cache(sock, "neighbour table", 41 | rtnl_neightbl_alloc_cache); 42 | 43 | for (;;) { 44 | int c, optidx = 0; 45 | static struct option long_opts[] = { 46 | { "format", 1, 0, 'f' }, 47 | { "help", 0, 0, 'h' }, 48 | { "version", 0, 0, 'v' }, 49 | { 0, 0, 0, 0 } 50 | }; 51 | 52 | c = getopt_long(argc, argv, "f:hv", long_opts, &optidx); 53 | if (c == -1) 54 | break; 55 | 56 | switch (c) { 57 | case 'f': params.dp_type = nl_cli_parse_dumptype(optarg); break; 58 | case 'h': print_usage(); break; 59 | case 'v': nl_cli_print_version(); break; 60 | } 61 | } 62 | 63 | nl_cache_dump(neightbl_cache, ¶ms); 64 | 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /src/nl-util-addr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * src/nl-util-addr.c Address Helper 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2003-2009 Thomas Graf 10 | */ 11 | 12 | #include 13 | 14 | int main(int argc, char *argv[]) 15 | { 16 | int err; 17 | char host[256]; 18 | struct nl_addr *a; 19 | 20 | if (argc < 2) { 21 | fprintf(stderr, "Usage: nl-util-addr
\n"); 22 | return -1; 23 | } 24 | 25 | a = nl_cli_addr_parse(argv[1], AF_UNSPEC); 26 | err = nl_addr_resolve(a, host, sizeof(host)); 27 | if (err != 0) 28 | nl_cli_fatal(err, "Unable to resolve address \"%s\": %s", 29 | argv[1], nl_geterror(err)); 30 | 31 | printf("%s\n", host); 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /tests/.gitignore: -------------------------------------------------------------------------------- 1 | /check-all 2 | /check-all.log 3 | /check-all.trs 4 | /test-*.log 5 | /test-*.trs 6 | /test-cache-mngr 7 | /test-complex-HTB-with-hash-filters 8 | /test-create-bond 9 | /test-create-bridge 10 | /test-create-ip6tnl 11 | /test-create-ipgre 12 | /test-create-ipip 13 | /test-create-ipvti 14 | /test-create-macvlan 15 | /test-create-sit 16 | /test-create-veth 17 | /test-create-vlan 18 | /test-create-vxlan 19 | /test-create-ifb 20 | /test-delete-link 21 | /test-genl 22 | /test-nf-cache-mngr 23 | /test-socket-creation 24 | /test-suite.log 25 | /test-u32-filter-with-actions 26 | -------------------------------------------------------------------------------- /tests/check-all.c: -------------------------------------------------------------------------------- 1 | /* 2 | * tests/check-all.c overall unit test program 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation version 2.1 7 | * of the License. 8 | * 9 | * Copyright (c) 2013 Thomas Graf 10 | */ 11 | 12 | #include 13 | 14 | extern Suite *make_nl_addr_suite(void); 15 | extern Suite *make_nl_attr_suite(void); 16 | 17 | static Suite *main_suite(void) 18 | { 19 | Suite *suite = suite_create("main"); 20 | 21 | return suite; 22 | } 23 | 24 | int main(int argc, char *argv[]) 25 | { 26 | SRunner *runner; 27 | int nfailed; 28 | 29 | runner = srunner_create(main_suite()); 30 | 31 | /* Add testsuites below */ 32 | 33 | srunner_add_suite(runner, make_nl_addr_suite()); 34 | srunner_add_suite(runner, make_nl_attr_suite()); 35 | 36 | /* Do not add testsuites below this line */ 37 | 38 | srunner_run_all(runner, CK_ENV); 39 | 40 | nfailed = srunner_ntests_failed(runner); 41 | srunner_free(runner); 42 | 43 | return nfailed != 0; 44 | } 45 | -------------------------------------------------------------------------------- /tests/test-cache-mngr.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | static int quit = 0; 9 | 10 | static struct nl_dump_params dp = { 11 | .dp_type = NL_DUMP_LINE, 12 | }; 13 | 14 | 15 | static void change_cb(struct nl_cache *cache, struct nl_object *obj, 16 | int action, void *data) 17 | { 18 | if (action == NL_ACT_NEW) 19 | printf("NEW "); 20 | else if (action == NL_ACT_DEL) 21 | printf("DEL "); 22 | else if (action == NL_ACT_CHANGE) 23 | printf("CHANGE "); 24 | 25 | nl_object_dump(obj, &dp); 26 | } 27 | 28 | static void sigint(int arg) 29 | { 30 | quit = 1; 31 | } 32 | 33 | int main(int argc, char *argv[]) 34 | { 35 | struct nl_cache_mngr *mngr; 36 | struct nl_cache *cache; 37 | int err, i; 38 | 39 | dp.dp_fd = stdout; 40 | 41 | signal(SIGINT, sigint); 42 | 43 | err = nl_cache_mngr_alloc(NULL, NETLINK_ROUTE, NL_AUTO_PROVIDE, &mngr); 44 | if (err < 0) 45 | nl_cli_fatal(err, "Unable to allocate cache manager: %s", 46 | nl_geterror(err)); 47 | 48 | for (i = 1; i < argc; i++) { 49 | err = nl_cache_mngr_add(mngr, argv[i], &change_cb, NULL, &cache); 50 | if (err < 0) 51 | nl_cli_fatal(err, "Unable to add cache %s: %s", 52 | argv[i], nl_geterror(err)); 53 | } 54 | 55 | while (!quit) { 56 | int err = nl_cache_mngr_poll(mngr, 1000); 57 | if (err < 0 && err != -NLE_INTR) 58 | nl_cli_fatal(err, "Polling failed: %s", nl_geterror(err)); 59 | 60 | nl_cache_mngr_info(mngr, &dp); 61 | } 62 | 63 | nl_cache_mngr_free(mngr); 64 | 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /tests/test-create-bond.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | struct rtnl_link *link; 8 | struct nl_sock *sk; 9 | int err; 10 | 11 | sk = nl_socket_alloc(); 12 | if ((err = nl_connect(sk, NETLINK_ROUTE)) < 0) { 13 | nl_perror(err, "Unable to connect socket"); 14 | return err; 15 | } 16 | 17 | link = rtnl_link_bond_alloc(); 18 | rtnl_link_set_name(link, "my_bond"); 19 | 20 | if ((err = rtnl_link_add(sk, link, NLM_F_CREATE)) < 0) { 21 | nl_perror(err, "Unable to add link"); 22 | return err; 23 | } 24 | 25 | rtnl_link_put(link); 26 | nl_close(sk); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /tests/test-create-ifb.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | struct rtnl_link *link; 7 | struct nl_sock *sk; 8 | int err; 9 | 10 | sk = nl_socket_alloc(); 11 | if ((err = nl_connect(sk, NETLINK_ROUTE)) < 0) { 12 | nl_perror(err, "Unable to connect socket"); 13 | return err; 14 | } 15 | 16 | link = rtnl_link_alloc(); 17 | rtnl_link_set_type(link, "ifb"); 18 | rtnl_link_set_name(link, "ifb1"); 19 | 20 | if ((err = rtnl_link_add(sk, link, NLM_F_CREATE)) < 0) { 21 | nl_perror(err, "Unable to add link"); 22 | return err; 23 | } 24 | 25 | rtnl_link_put(link); 26 | nl_close(sk); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /tests/test-create-ip6tnl.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | struct nl_cache *link_cache; 7 | struct rtnl_link *link; 8 | struct in6_addr addr; 9 | struct nl_sock *sk; 10 | int err, if_index; 11 | 12 | sk = nl_socket_alloc(); 13 | if ((err = nl_connect(sk, NETLINK_ROUTE)) < 0) { 14 | nl_perror(err, "Unable to connect socket"); 15 | return err; 16 | } 17 | 18 | err = rtnl_link_alloc_cache(sk, AF_UNSPEC, &link_cache); 19 | if ( err < 0) { 20 | nl_perror(err, "Unable to allocate cache"); 21 | return err; 22 | } 23 | 24 | if_index = rtnl_link_name2i(link_cache, "ens33"); 25 | if (!if_index) { 26 | fprintf(stderr, "Unable to lookup ens33"); 27 | return -1; 28 | } 29 | 30 | link = rtnl_link_ip6_tnl_alloc(); 31 | if(!link) { 32 | nl_perror(err, "Unable to allocate link"); 33 | return -1; 34 | 35 | } 36 | rtnl_link_set_name(link, "ip6tnl-tun"); 37 | rtnl_link_ip6_tnl_set_link(link, if_index); 38 | 39 | inet_pton(AF_INET6, "2607:f0d0:1002:51::4", &addr); 40 | rtnl_link_ip6_tnl_set_local(link, &addr); 41 | 42 | inet_pton(AF_INET6, "2607:f0d0:1002:52::5", &addr); 43 | rtnl_link_ip6_tnl_set_remote(link, &addr); 44 | 45 | err = rtnl_link_add(sk, link, NLM_F_CREATE); 46 | if (err < 0) { 47 | nl_perror(err, "Unable to add link"); 48 | return err; 49 | } 50 | 51 | rtnl_link_put(link); 52 | nl_close(sk); 53 | 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /tests/test-create-ipgre.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | struct nl_cache *link_cache; 7 | struct rtnl_link *link; 8 | struct in_addr addr; 9 | struct nl_sock *sk; 10 | int err, if_index; 11 | 12 | sk = nl_socket_alloc(); 13 | if ((err = nl_connect(sk, NETLINK_ROUTE)) < 0) { 14 | nl_perror(err, "Unable to connect socket"); 15 | return err; 16 | } 17 | 18 | err = rtnl_link_alloc_cache(sk, AF_UNSPEC, &link_cache); 19 | if ( err < 0) { 20 | nl_perror(err, "Unable to allocate cache"); 21 | return err; 22 | } 23 | 24 | if_index = rtnl_link_name2i(link_cache, "eno16777736"); 25 | if (!if_index) { 26 | fprintf(stderr, "Unable to lookup eno16777736"); 27 | return -1; 28 | } 29 | 30 | link = rtnl_link_ipgre_alloc(); 31 | if(!link) { 32 | nl_perror(err, "Unable to allocate link"); 33 | return -1; 34 | 35 | } 36 | rtnl_link_set_name(link, "ipgre-tun"); 37 | rtnl_link_ipgre_set_link(link, if_index); 38 | 39 | inet_pton(AF_INET, "192.168.254.12", &addr.s_addr); 40 | rtnl_link_ipgre_set_local(link, addr.s_addr); 41 | 42 | inet_pton(AF_INET, "192.168.254.13", &addr.s_addr); 43 | rtnl_link_ipgre_set_remote(link, addr.s_addr); 44 | 45 | rtnl_link_ipgre_set_ttl(link, 64); 46 | err = rtnl_link_add(sk, link, NLM_F_CREATE); 47 | if (err < 0) { 48 | nl_perror(err, "Unable to add link"); 49 | return err; 50 | } 51 | 52 | rtnl_link_put(link); 53 | nl_close(sk); 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /tests/test-create-ipip.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | struct nl_cache *link_cache; 7 | struct rtnl_link *link; 8 | struct in_addr addr; 9 | struct nl_sock *sk; 10 | int err, if_index; 11 | 12 | sk = nl_socket_alloc(); 13 | if ((err = nl_connect(sk, NETLINK_ROUTE)) < 0) { 14 | nl_perror(err, "Unable to connect socket"); 15 | return err; 16 | } 17 | 18 | err = rtnl_link_alloc_cache(sk, AF_UNSPEC, &link_cache); 19 | if ( err < 0) { 20 | nl_perror(err, "Unable to allocate cache"); 21 | return err; 22 | } 23 | 24 | if_index = rtnl_link_name2i(link_cache, "eno16777736"); 25 | if (!if_index) { 26 | fprintf(stderr, "Unable to lookup eno16777736"); 27 | return -1; 28 | } 29 | 30 | link = rtnl_link_ipip_alloc(); 31 | if(!link) { 32 | nl_perror(err, "Unable to allocate link"); 33 | return -1; 34 | } 35 | 36 | rtnl_link_set_name(link, "ipip-tun"); 37 | rtnl_link_ipip_set_link(link, if_index); 38 | 39 | inet_pton(AF_INET, "192.168.254.12", &addr.s_addr); 40 | rtnl_link_ipip_set_local(link, addr.s_addr); 41 | 42 | inet_pton(AF_INET, "192.168.254.13", &addr.s_addr); 43 | rtnl_link_ipip_set_remote(link, addr.s_addr); 44 | 45 | rtnl_link_ipip_set_ttl(link, 64); 46 | err = rtnl_link_add(sk, link, NLM_F_CREATE); 47 | if (err < 0) { 48 | nl_perror(err, "Unable to add link"); 49 | return err; 50 | } 51 | 52 | rtnl_link_put(link); 53 | nl_close(sk); 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /tests/test-create-ipvti.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | struct nl_cache *link_cache; 7 | struct rtnl_link *link; 8 | struct in_addr addr; 9 | struct nl_sock *sk; 10 | int err, if_index; 11 | 12 | sk = nl_socket_alloc(); 13 | if ((err = nl_connect(sk, NETLINK_ROUTE)) < 0) { 14 | nl_perror(err, "Unable to connect socket"); 15 | return err; 16 | } 17 | 18 | err = rtnl_link_alloc_cache(sk, AF_UNSPEC, &link_cache); 19 | if ( err < 0) { 20 | nl_perror(err, "Unable to allocate cache"); 21 | return err; 22 | } 23 | 24 | if_index = rtnl_link_name2i(link_cache, "ens33"); 25 | if (!if_index) { 26 | fprintf(stderr, "Unable to lookup ens33"); 27 | return -1; 28 | } 29 | 30 | link = rtnl_link_ipvti_alloc(); 31 | if(!link) { 32 | nl_perror(err, "Unable to allocate link"); 33 | return -1; 34 | 35 | } 36 | rtnl_link_set_name(link, "ipvti-tun"); 37 | rtnl_link_ipvti_set_link(link, if_index); 38 | 39 | inet_pton(AF_INET, "192.168.254.12", &addr.s_addr); 40 | rtnl_link_ipvti_set_local(link, addr.s_addr); 41 | 42 | inet_pton(AF_INET, "192.168.254.13", &addr.s_addr); 43 | rtnl_link_ipvti_set_remote(link, addr.s_addr); 44 | 45 | err = rtnl_link_add(sk, link, NLM_F_CREATE); 46 | if (err < 0) { 47 | nl_perror(err, "Unable to add link"); 48 | return err; 49 | } 50 | 51 | rtnl_link_put(link); 52 | nl_close(sk); 53 | 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /tests/test-create-macvlan.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | int main(int argc, char *argv[]) 8 | { 9 | struct rtnl_link *link; 10 | struct nl_cache *link_cache; 11 | struct nl_sock *sk; 12 | struct nl_addr* addr; 13 | int err, master_index; 14 | 15 | sk = nl_socket_alloc(); 16 | if ((err = nl_connect(sk, NETLINK_ROUTE)) < 0) { 17 | nl_perror(err, "Unable to connect socket"); 18 | return err; 19 | } 20 | 21 | if ((err = rtnl_link_alloc_cache(sk, AF_UNSPEC, &link_cache)) < 0) { 22 | nl_perror(err, "Unable to allocate cache"); 23 | return err; 24 | } 25 | 26 | if (!(master_index = rtnl_link_name2i(link_cache, "eth0"))) { 27 | fprintf(stderr, "Unable to lookup eth0"); 28 | return -1; 29 | } 30 | 31 | link = rtnl_link_macvlan_alloc(); 32 | 33 | rtnl_link_set_link(link, master_index); 34 | 35 | addr = nl_addr_build(AF_LLC, ether_aton("00:11:22:33:44:55"), ETH_ALEN); 36 | rtnl_link_set_addr(link, addr); 37 | nl_addr_put(addr); 38 | 39 | rtnl_link_macvlan_set_mode(link, rtnl_link_macvlan_str2mode("bridge")); 40 | 41 | if ((err = rtnl_link_add(sk, link, NLM_F_CREATE)) < 0) { 42 | nl_perror(err, "Unable to add link"); 43 | return err; 44 | } 45 | 46 | rtnl_link_put(link); 47 | nl_close(sk); 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /tests/test-create-sit.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | struct nl_cache *link_cache; 7 | struct rtnl_link *link; 8 | struct in_addr addr; 9 | struct nl_sock *sk; 10 | int err, if_index; 11 | 12 | sk = nl_socket_alloc(); 13 | if ((err = nl_connect(sk, NETLINK_ROUTE)) < 0) { 14 | nl_perror(err, "Unable to connect socket"); 15 | return err; 16 | } 17 | 18 | err = rtnl_link_alloc_cache(sk, AF_UNSPEC, &link_cache); 19 | if ( err < 0) { 20 | nl_perror(err, "Unable to allocate cache"); 21 | return err; 22 | } 23 | 24 | if_index = rtnl_link_name2i(link_cache, "eno16777736"); 25 | if (!if_index) { 26 | fprintf(stderr, "Unable to lookup eno16777736"); 27 | return -1; 28 | } 29 | 30 | link = rtnl_link_sit_alloc(); 31 | if(!link) { 32 | nl_perror(err, "Unable to allocate link"); 33 | return -1; 34 | 35 | } 36 | rtnl_link_set_name(link, "sit-tun"); 37 | rtnl_link_sit_set_link(link, if_index); 38 | 39 | inet_pton(AF_INET, "192.168.254.12", &addr.s_addr); 40 | rtnl_link_sit_set_local(link, addr.s_addr); 41 | 42 | inet_pton(AF_INET, "192.168.254.13", &addr.s_addr); 43 | rtnl_link_sit_set_remote(link, addr.s_addr); 44 | 45 | rtnl_link_sit_set_ttl(link, 64); 46 | err = rtnl_link_add(sk, link, NLM_F_CREATE); 47 | if (err < 0) { 48 | nl_perror(err, "Unable to add link"); 49 | return err; 50 | } 51 | 52 | rtnl_link_put(link); 53 | nl_close(sk); 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /tests/test-create-veth.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | struct rtnl_link *link; 8 | struct nl_sock *sk; 9 | int err; 10 | struct rtnl_link *peer; 11 | 12 | sk = nl_socket_alloc(); 13 | if ((err = nl_connect(sk, NETLINK_ROUTE)) < 0) { 14 | nl_perror(err, "Unable to connect socket"); 15 | return err; 16 | } 17 | 18 | #if 0 19 | rtnl_link_veth_add(sk, "veth2", "veth3", getpid()); 20 | #else 21 | link = rtnl_link_veth_alloc(); 22 | if (!link) { 23 | nl_perror(err, "Unable to alloc link"); 24 | return err; 25 | } 26 | 27 | rtnl_link_set_name(link, "veth8"); 28 | peer = rtnl_link_veth_get_peer(link); 29 | rtnl_link_set_name(peer, "veth9"); 30 | 31 | if ((err = rtnl_link_add(sk, link, NLM_F_CREATE)) < 0) { 32 | nl_perror(err, "Unable to add link"); 33 | return err; 34 | } 35 | printf("peer is %s\n", rtnl_link_get_name(peer)); 36 | rtnl_link_put(peer); 37 | rtnl_link_put(link); 38 | #endif 39 | nl_close(sk); 40 | 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /tests/test-create-vlan.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | struct rtnl_link *link; 8 | struct nl_cache *link_cache; 9 | struct nl_sock *sk; 10 | int err, master_index; 11 | 12 | sk = nl_socket_alloc(); 13 | if ((err = nl_connect(sk, NETLINK_ROUTE)) < 0) { 14 | nl_perror(err, "Unable to connect socket"); 15 | return err; 16 | } 17 | 18 | if ((err = rtnl_link_alloc_cache(sk, AF_UNSPEC, &link_cache)) < 0) { 19 | nl_perror(err, "Unable to allocate cache"); 20 | return err; 21 | } 22 | 23 | if (!(master_index = rtnl_link_name2i(link_cache, "eth0"))) { 24 | fprintf(stderr, "Unable to lookup eth0"); 25 | return -1; 26 | } 27 | 28 | link = rtnl_link_vlan_alloc(); 29 | 30 | rtnl_link_set_link(link, master_index); 31 | 32 | rtnl_link_vlan_set_id(link, 10); 33 | 34 | if ((err = rtnl_link_add(sk, link, NLM_F_CREATE)) < 0) { 35 | nl_perror(err, "Unable to add link"); 36 | return err; 37 | } 38 | 39 | rtnl_link_put(link); 40 | nl_close(sk); 41 | 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /tests/test-create-vxlan.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | struct rtnl_link *link; 8 | struct nl_addr *addr; 9 | struct nl_sock *sk; 10 | int err; 11 | 12 | sk = nl_socket_alloc(); 13 | if ((err = nl_connect(sk, NETLINK_ROUTE)) < 0) { 14 | nl_perror(err, "Unable to connect socket"); 15 | return err; 16 | } 17 | 18 | link = rtnl_link_vxlan_alloc(); 19 | 20 | rtnl_link_set_name(link, "vxlan128"); 21 | 22 | if ((err = rtnl_link_vxlan_set_id(link, 128)) < 0) { 23 | nl_perror(err, "Unable to set VXLAN network identifier"); 24 | return err; 25 | } 26 | 27 | if ((err = nl_addr_parse("239.0.0.1", AF_INET, &addr)) < 0) { 28 | nl_perror(err, "Unable to parse IP address"); 29 | return err; 30 | } 31 | 32 | if ((err = rtnl_link_vxlan_set_group(link, addr)) < 0) { 33 | nl_perror(err, "Unable to set multicast IP address"); 34 | return err; 35 | } 36 | nl_addr_put(addr); 37 | 38 | if ((err = rtnl_link_add(sk, link, NLM_F_CREATE)) < 0) { 39 | nl_perror(err, "Unable to add link"); 40 | return err; 41 | } 42 | 43 | rtnl_link_put(link); 44 | nl_close(sk); 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /tests/test-delete-link.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | struct rtnl_link *link; 7 | struct nl_sock *sk; 8 | int err; 9 | 10 | sk = nl_socket_alloc(); 11 | if ((err = nl_connect(sk, NETLINK_ROUTE)) < 0) { 12 | nl_perror(err, "Unable to connect socket"); 13 | return err; 14 | } 15 | 16 | link = rtnl_link_alloc(); 17 | rtnl_link_set_name(link, "my_bond"); 18 | 19 | if ((err = rtnl_link_delete(sk, link)) < 0) { 20 | nl_perror(err, "Unable to delete link"); 21 | return err; 22 | } 23 | 24 | rtnl_link_put(link); 25 | nl_close(sk); 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /tests/test-nf-cache-mngr.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static void change_cb(struct nl_cache *cache, struct nl_object *obj, 4 | int action, void *data) 5 | { 6 | struct nfnl_ct *ct = (struct nfnl_ct *) obj; 7 | static struct nl_addr *hack = NULL; 8 | 9 | if (!hack) 10 | nl_addr_parse("194.88.212.233", AF_INET, &hack); 11 | 12 | if (!nl_addr_cmp(hack, nfnl_ct_get_src(ct, 1)) || 13 | !nl_addr_cmp(hack, nfnl_ct_get_dst(ct, 1))) { 14 | struct nl_dump_params dp = { 15 | .dp_type = NL_DUMP_LINE, 16 | .dp_fd = stdout, 17 | }; 18 | 19 | printf("UPDATE "); 20 | nl_object_dump(obj, &dp); 21 | } 22 | } 23 | 24 | int main(int argc, char *argv[]) 25 | { 26 | struct nl_cache_mngr *mngr; 27 | struct nl_sock *sock; 28 | struct nl_cache *ct; 29 | int err; 30 | 31 | sock = nl_cli_alloc_socket(); 32 | 33 | err = nl_cache_mngr_alloc(sock, NETLINK_NETFILTER, NL_AUTO_PROVIDE, &mngr); 34 | if (err < 0) { 35 | nl_perror(err, "nl_cache_mngr_alloc"); 36 | return -1; 37 | } 38 | 39 | err = nl_cache_mngr_add(mngr, "netfilter/ct", &change_cb, NULL, &ct); 40 | if (err < 0) { 41 | nl_perror(err, "nl_cache_mngr_add(netfilter/ct)"); 42 | return -1; 43 | } 44 | 45 | for (;;) { 46 | int err = nl_cache_mngr_poll(mngr, 5000); 47 | if (err < 0) { 48 | nl_perror(err, "nl_cache_mngr_poll()"); 49 | return -1; 50 | } 51 | 52 | } 53 | 54 | nl_cache_mngr_free(mngr); 55 | 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /tests/test-socket-creation.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | struct nl_sock *h[1025]; 7 | int i; 8 | 9 | h[0] = nl_socket_alloc(); 10 | printf("Created handle with port 0x%x\n", 11 | nl_socket_get_local_port(h[0])); 12 | nl_socket_free(h[0]); 13 | h[0] = nl_socket_alloc(); 14 | printf("Created handle with port 0x%x\n", 15 | nl_socket_get_local_port(h[0])); 16 | nl_socket_free(h[0]); 17 | 18 | for (i = 0; i < 1025; i++) { 19 | h[i] = nl_socket_alloc(); 20 | if (h[i] == NULL) 21 | nl_perror(ENOMEM, "Unable to allocate socket"); 22 | else 23 | printf("Created handle with port 0x%x\n", 24 | nl_socket_get_local_port(h[i])); 25 | } 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /tests/util.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define nl_fail_if(condition, error, message) \ 4 | fail_if((condition), "nlerr=%d (%s): %s", \ 5 | (error), nl_geterror(error), (message)) 6 | --------------------------------------------------------------------------------