Update upstream source from tag 'upstream/1.0.5'
Update to upstream version '1.0.5'
with Debian dir 7d9ecf5d788db36a5abd1444ab250ee9470dbca4
Vincent Bernat
4 years ago
0 | 1.0.5 [2020-02-01 22:15:40 +0100]: | |
1 | ||
2 | - [6d83fa565e82] release: 1.0.5 (Vincent Bernat) | |
3 | - [3d65bc40a27f] include: remove in6.h from linux/bridge.h (Vincent Bernat) | |
4 | - [69a0de1dc81a] tests: provide a Dockerfile to build with wheezy (Vincent Bernat) | |
5 | - [0994188ff6a6] include: don't use __kernel_sa_family_t (Vincent Bernat) | |
6 | - [e74d1f683e89] include: don't include linux/sysinfo.h (Vincent Bernat) | |
7 | - [217b9531d405] interfaces: include "netinet/in.h" before kernel headers (Vincent Bernat) | |
8 | - [ae03f0903509] interfaces: fix usage of inet_pton() (Vincent Bernat) | |
9 | - [0b2e10b58220] travis: remove ARM64 (Vincent Bernat) | |
10 | - [8b2b28f54595] interfaces: move bitmaps function to a dedicated file (Vincent Bernat) | |
11 | - [21a0428a6ebf] snmp: additional fix around NetSNMP 5.8+ and function pointers (Vincent Bernat) | |
12 | - [31ac51a8ef2e] snmp: tentative to fix compilation with older versions of NetSNMP (Vincent Bernat) | |
13 | - [385e5e4cf3a7] interfaces: correctly handle bridges with VLAN filtering enabled (Vincent Bernat) | |
14 | - [d807e90f60b8] daemon: remove unused interface types (Vincent Bernat) | |
15 | - [24e8fda8fa36] tests: check we don't mix VLAN among interfaces (Vincent Bernat) | |
16 | - [f9e522d6cf2c] snmp: update signature for create_ostring (Vincent Bernat) | |
17 | - [f27e002f6993] snmp: update signature of fmtaddr and send functions (Vincent Bernat) | |
18 | - [98282043df36] debian: update watch file (Vincent Bernat) | |
19 | - [33a2f0f2eaf0] Merge pull request #376 from stannous/remote-vlan-limitations (Vincent Bernat) | |
20 | - [cf6d726e9057] tests: use "-Ln" to avoid logging with snmpd (Vincent Bernat) | |
21 | - [0c5525bbef50] netlink: fix detection of VLAN 1 (Vincent Bernat) | |
22 | - [b2e80798d1fc] netlink: use an optimized version of num_bits_set (Vincent Bernat) | |
23 | - [626ea3610fa3] interfaces: fix for limitation of 10 VLANs for LLDP .1q feature (Radhika Mahankali) | |
24 | - [6f66d1086b11] lib: don't break ABI by moving new config_tx_interval_ms to end (Vincent Bernat) | |
25 | - [4491a5cc42b2] Merge pull request #379 from jp-t/master (Vincent Bernat) | |
26 | - [5134d8882312] lldpd: set a 30 seconds lower limit to the safeguard timer (Jean-Pierre Tosoni) | |
27 | - [6ef305d50c07] doc, tests: milliseconds tx-interval finishing touch (Jean-Pierre Tosoni) | |
28 | - [7f6a8ace68b5] snmp agent: fix tests suite for milliseconds units (Jean-Pierre Tosoni) | |
29 | - [74f55c2e029d] Allow configuring tx-interval in milliseconds (Jean-Pierre Tosoni) | |
30 | - [b2bd6c456edc] tests: remove hack around libtool on OSX (Vincent Bernat) | |
31 | - [cbafbacca083] tests: skip tests requiring kernel features not present (Vincent Bernat) | |
32 | - [60c22a3c3180] travis: update to Bionic (Vincent Bernat) | |
33 | - [1f2e7757828c] travis: also build for arm64 (Vincent Bernat) | |
34 | - [036fca466fc7] Merge pull request #375 from stannous/master (Vincent Bernat) | |
35 | - [e512429c88d2] Fix for LLDP related netlink error messages (Radhika Mahankali) | |
36 | - [e02913c2c5a3] Revert "client: remove useless variable declaration in zsh completion" (Vincent Bernat) | |
37 | - [8e857e1b2044] client: fix zsh completion to not alter global environment (Vincent Bernat) | |
38 | - [e37dd8d0a3f6] client: remove useless variable declaration in zsh completion (Vincent Bernat) | |
39 | - [3ae837fd06da] LLDPD should document system refresh timer (tx-interval * 20) (Sam Tannous) | |
40 | - [314ca2736599] lldp: don't discard the whole LLDPDU when only one TLV is invalid (Vincent Bernat) | |
41 | - [69362215b2fb] tests: add a test with different MTU interfaces (Vincent Bernat) | |
42 | - [70845fe4e73b] redhat: fix license name in spec file (Vincent Bernat) | |
43 | - [9c49cedf8e75] lib: fix memory leak when handling I/O (Vincent Bernat) | |
44 | - [7056d802b9c5] lldpcli: ask for power pairs only when PSE (Vincent Bernat) | |
45 | - [990e4e384315] Merge pull request #350 from patrikdanielssonaxis/8023bt (Vincent Bernat) | |
46 | - [d88003ff0288] test: add tests for 802.3BT additions (Vincent Bernat) | |
47 | - [ece1209a900f] test: use scapy when sending pcap files (Vincent Bernat) | |
48 | - [7cfcd3b7efb9] lldp: Power via MDI TLV: Initial support for 802.3bt (Patrik Danielsson) | |
49 | - [92e3b3ac3199] Merge branch 'feature/vlan-enabled-bridge' (Vincent Bernat) | |
50 | - [a9fe956f3e07] lldp: when receiving a shutdown LLDPU, don't clear chassis information (Vincent Bernat) | |
51 | - [3aeae72b9771] lldp: validate a bit more received LLDP frames (Vincent Bernat) | |
52 | - [fc5526dae75f] interfaces: only register protocol handler for LLDP when only LLDP enabled (Vincent Bernat) | |
53 | - [fc8164d80bc9] lldpctl: don't reopen control socket each time we want to lock (Vincent Bernat) | |
54 | - [0a46b330f02b] lldpctl: put a lock around some commands to avoid race conditions (Vincent Bernat) | |
55 | - [5c969283279e] log: don't use black for coloring DBG (Vincent Bernat) | |
56 | - [011056b3a714] netlink: support VLAN-aware bridges (Vincent Bernat) | |
57 | - [5a85fbc93433] netlink: ignore IFLA_LINK if we previously received IFLA_LINK_NETNSID (Vincent Bernat) | |
58 | - [43b333967018] interfaces: don't log errno when detecting loops (Vincent Bernat) | |
59 | - [11df89a99dae] tests: fix skip instruction (Vincent Bernat) | |
60 | - [f6bbc43b2085] tests: don't use pytest.config (Vincent Bernat) | |
61 | - [68bc4a4d6293] interfaces: enable matching on interface name for management address (Vincent Bernat) | |
62 | - [d94afe74b665] lldpd: fix bitfield (Wataru Ashihara) | |
63 | - [92014c586860] client: fix parameter order (Wataru Ashihara) | |
64 | - [a32224491a62] lib: fix memory leak (Wataru Ashihara) | |
65 | - [07ecfcd1972e] fix typo (Wataru Ashihara) | |
66 | - [c3cb7055c02d] lib: fix enumeration (Wataru Ashihara) | |
67 | - [9b68a67f5dae] build: disable warnings on cast alignments (Vincent Bernat) | |
68 | - [27ea4d1e7e1d] tests: be verbose when running make on CI when an error happens (Vincent Bernat) | |
69 | - [30fca74bf43f] client: don't display management interface index if unknown (Vincent Bernat) | |
70 | - [b7b7dc349aa4] interfaces: compute interface index for fixed management address (Vincent Bernat) | |
71 | - [d319b0deaccf] lib: expose management interface index (Vincent Bernat) | |
72 | - [db76b2281622] lib: fix missing words in lldpctl.h (Vincent Bernat) | |
73 | - [a192a2e91f81] include: update headers to 4.19 (Vincent Bernat) | |
74 | - [869ab1032650] June 15th 2019 was a Saturday, not a Sunday (eb3095) | |
75 | - [d3fa9b099783] osx: update recipe for HomeBrew (Vincent Bernat) | |
76 | ||
0 | 77 | 1.0.4 [2019-06-15 11:09:44 +0200]: |
1 | 78 | |
2 | 79 | - [1507a0035694] release: 1.0.4 (Vincent Bernat) |
0 | lldpd (1.0.5) | |
1 | * Changes: | |
2 | + Interface names are also matched for management addresses. | |
3 | + On Linux, only register protocol handler for LLDP when only LLDP | |
4 | is enabled. | |
5 | + Stricter on LLDP incoming frames validation. | |
6 | + Add support for VLAN-aware bridges for Linux (no range support). | |
7 | + Add support for 802.3BT (no SNMP support). | |
8 | + Add support for millisecond-grained tx-interval (Jean-Pierre Tosoni). | |
9 | + Use generic names for VLAN names, instead of interface names (eg | |
10 | vlan100 instead of eth1.100). | |
11 | * Fix: | |
12 | + Don't clear chassis TLV on shutdown LLDPDU. | |
13 | + Don't require/display powerpairs for Dot3 power when device type | |
14 | is PD. | |
15 | ||
0 | 16 | lldpd (1.0.4) |
1 | 17 | * Changes: |
2 | 18 | + Add "configure system max-neighbors XX" command to modify maximum |
0 | 0 | #! /bin/sh |
1 | 1 | # Guess values for system-dependent variables and create Makefiles. |
2 | # Generated by GNU Autoconf 2.69 for lldpd 1.0.4. | |
2 | # Generated by GNU Autoconf 2.69 for lldpd 1.0.5. | |
3 | 3 | # |
4 | 4 | # Report bugs to <https://github.com/vincentbernat/lldpd/issues>. |
5 | 5 | # |
589 | 589 | # Identity of this package. |
590 | 590 | PACKAGE_NAME='lldpd' |
591 | 591 | PACKAGE_TARNAME='lldpd' |
592 | PACKAGE_VERSION='1.0.4' | |
593 | PACKAGE_STRING='lldpd 1.0.4' | |
592 | PACKAGE_VERSION='1.0.5' | |
593 | PACKAGE_STRING='lldpd 1.0.5' | |
594 | 594 | PACKAGE_BUGREPORT='https://github.com/vincentbernat/lldpd/issues' |
595 | 595 | PACKAGE_URL='http://vincentbernat.github.io/lldpd/' |
596 | 596 | |
1516 | 1516 | # Omit some internal or obsolete options to make the list less imposing. |
1517 | 1517 | # This message is too long to be a string in the A/UX 3.1 sh. |
1518 | 1518 | cat <<_ACEOF |
1519 | \`configure' configures lldpd 1.0.4 to adapt to many kinds of systems. | |
1519 | \`configure' configures lldpd 1.0.5 to adapt to many kinds of systems. | |
1520 | 1520 | |
1521 | 1521 | Usage: $0 [OPTION]... [VAR=VALUE]... |
1522 | 1522 | |
1587 | 1587 | |
1588 | 1588 | if test -n "$ac_init_help"; then |
1589 | 1589 | case $ac_init_help in |
1590 | short | recursive ) echo "Configuration of lldpd 1.0.4:";; | |
1590 | short | recursive ) echo "Configuration of lldpd 1.0.5:";; | |
1591 | 1591 | esac |
1592 | 1592 | cat <<\_ACEOF |
1593 | 1593 | |
1804 | 1804 | test -n "$ac_init_help" && exit $ac_status |
1805 | 1805 | if $ac_init_version; then |
1806 | 1806 | cat <<\_ACEOF |
1807 | lldpd configure 1.0.4 | |
1807 | lldpd configure 1.0.5 | |
1808 | 1808 | generated by GNU Autoconf 2.69 |
1809 | 1809 | |
1810 | 1810 | Copyright (C) 2012 Free Software Foundation, Inc. |
2284 | 2284 | This file contains any messages produced by compilers while |
2285 | 2285 | running configure, to aid debugging if configure makes a mistake. |
2286 | 2286 | |
2287 | It was created by lldpd $as_me 1.0.4, which was | |
2287 | It was created by lldpd $as_me 1.0.5, which was | |
2288 | 2288 | generated by GNU Autoconf 2.69. Invocation command line was |
2289 | 2289 | |
2290 | 2290 | $ $0 $@ |
3158 | 3158 | |
3159 | 3159 | # Define the identity of the package. |
3160 | 3160 | PACKAGE='lldpd' |
3161 | VERSION='1.0.4' | |
3161 | VERSION='1.0.5' | |
3162 | 3162 | |
3163 | 3163 | |
3164 | 3164 | cat >>confdefs.h <<_ACEOF |
16385 | 16385 | ;; |
16386 | 16386 | esac |
16387 | 16387 | |
16388 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking CFLAGS for gcc -Wcast-align" >&5 | |
16389 | $as_echo_n "checking CFLAGS for gcc -Wcast-align... " >&6; } | |
16390 | if ${ac_cv_cflags_gcc_option__Wcast_align+:} false; then : | |
16391 | $as_echo_n "(cached) " >&6 | |
16392 | else | |
16393 | ac_cv_cflags_gcc_option__Wcast_align="no, unknown" | |
16394 | ||
16395 | ac_ext=c | |
16396 | ac_cpp='$CPP $CPPFLAGS' | |
16397 | ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' | |
16398 | ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' | |
16399 | ac_compiler_gnu=$ac_cv_c_compiler_gnu | |
16400 | ||
16401 | ac_save_CFLAGS="$CFLAGS" | |
16402 | for ac_arg in "-pedantic -Werror % -Wcast-align" "-pedantic % -Wcast-align %% no, obsolete" # | |
16403 | do CFLAGS="$ac_save_CFLAGS $LLDP_CFLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` | |
16404 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext | |
16405 | /* end confdefs.h. */ | |
16406 | ||
16407 | int | |
16408 | main () | |
16409 | { | |
16410 | return 0; | |
16411 | ; | |
16412 | return 0; | |
16413 | } | |
16414 | _ACEOF | |
16415 | if ac_fn_c_try_compile "$LINENO"; then : | |
16416 | ac_cv_cflags_gcc_option__Wcast_align=`echo $ac_arg | sed -e 's,.*% *,,'` ; break | |
16417 | fi | |
16418 | rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext | |
16419 | done | |
16420 | CFLAGS="$ac_save_CFLAGS" | |
16421 | ac_ext=c | |
16422 | ac_cpp='$CPP $CPPFLAGS' | |
16423 | ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' | |
16424 | ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' | |
16425 | ac_compiler_gnu=$ac_cv_c_compiler_gnu | |
16426 | ||
16427 | ||
16428 | fi | |
16429 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cflags_gcc_option__Wcast_align" >&5 | |
16430 | $as_echo "$ac_cv_cflags_gcc_option__Wcast_align" >&6; } | |
16431 | ac_res=$ac_cv_cflags_gcc_option__Wcast_align | |
16432 | case ".${ac_res}" in | |
16433 | .ok|.ok,*) ;; | |
16434 | .|.no|.no,*) ;; | |
16435 | *) | |
16436 | if echo " $LLDP_CFLAGS " | grep " ${ac_res} " 2>&1 >/dev/null | |
16437 | then { { $as_echo "$as_me:${as_lineno-$LINENO}: : LLDP_CFLAGS does contain \${ac_res}"; } >&5 | |
16438 | (: LLDP_CFLAGS does contain ${ac_res}) 2>&5 | |
16439 | ac_status=$? | |
16440 | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 | |
16441 | test $ac_status = 0; } | |
16442 | else { { $as_echo "$as_me:${as_lineno-$LINENO}: : LLDP_CFLAGS=\"\$LLDP_CFLAGS \${ac_res}\""; } >&5 | |
16443 | (: LLDP_CFLAGS="$LLDP_CFLAGS ${ac_res}") 2>&5 | |
16444 | ac_status=$? | |
16445 | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 | |
16446 | test $ac_status = 0; } | |
16447 | LLDP_CFLAGS="$LLDP_CFLAGS ${ac_res}" | |
16448 | fi | |
16449 | ;; | |
16450 | esac | |
16451 | ||
16452 | 16388 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking CFLAGS for gcc -Wheader-guard" >&5 |
16453 | 16389 | $as_echo_n "checking CFLAGS for gcc -Wheader-guard... " >&6; } |
16454 | 16390 | if ${ac_cv_cflags_gcc_option__Wheader_guard+:} false; then : |
16769 | 16705 | ;; |
16770 | 16706 | esac |
16771 | 16707 | |
16772 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking CFLAGS for gcc -Wno-unused-parameter" >&5 | |
16708 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking CFLAGS for gcc -Wno-cast-align" >&5 | |
16709 | $as_echo_n "checking CFLAGS for gcc -Wno-cast-align... " >&6; } | |
16710 | if ${ac_cv_cflags_gcc_option__Wno_cast_align+:} false; then : | |
16711 | $as_echo_n "(cached) " >&6 | |
16712 | else | |
16713 | ac_cv_cflags_gcc_option__Wno_cast_align="no, unknown" | |
16714 | ||
16715 | ac_ext=c | |
16716 | ac_cpp='$CPP $CPPFLAGS' | |
16717 | ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' | |
16718 | ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' | |
16719 | ac_compiler_gnu=$ac_cv_c_compiler_gnu | |
16720 | ||
16721 | ac_save_CFLAGS="$CFLAGS" | |
16722 | for ac_arg in "-pedantic -Werror % -Wno-cast-align" "-pedantic % -Wno-cast-align %% no, obsolete" # | |
16723 | do CFLAGS="$ac_save_CFLAGS $LLDP_CFLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` | |
16724 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext | |
16725 | /* end confdefs.h. */ | |
16726 | ||
16727 | int | |
16728 | main () | |
16729 | { | |
16730 | return 0; | |
16731 | ; | |
16732 | return 0; | |
16733 | } | |
16734 | _ACEOF | |
16735 | if ac_fn_c_try_compile "$LINENO"; then : | |
16736 | ac_cv_cflags_gcc_option__Wno_cast_align=`echo $ac_arg | sed -e 's,.*% *,,'` ; break | |
16737 | fi | |
16738 | rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext | |
16739 | done | |
16740 | CFLAGS="$ac_save_CFLAGS" | |
16741 | ac_ext=c | |
16742 | ac_cpp='$CPP $CPPFLAGS' | |
16743 | ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' | |
16744 | ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' | |
16745 | ac_compiler_gnu=$ac_cv_c_compiler_gnu | |
16746 | ||
16747 | ||
16748 | fi | |
16749 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cflags_gcc_option__Wno_cast_align" >&5 | |
16750 | $as_echo "$ac_cv_cflags_gcc_option__Wno_cast_align" >&6; } | |
16751 | ac_res=$ac_cv_cflags_gcc_option__Wno_cast_align | |
16752 | case ".${ac_res}" in | |
16753 | .ok|.ok,*) ;; | |
16754 | .|.no|.no,*) ;; | |
16755 | *) | |
16756 | if echo " $LLDP_CFLAGS " | grep " ${ac_res} " 2>&1 >/dev/null | |
16757 | then { { $as_echo "$as_me:${as_lineno-$LINENO}: : LLDP_CFLAGS does contain \${ac_res}"; } >&5 | |
16758 | (: LLDP_CFLAGS does contain ${ac_res}) 2>&5 | |
16759 | ac_status=$? | |
16760 | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 | |
16761 | test $ac_status = 0; } | |
16762 | else { { $as_echo "$as_me:${as_lineno-$LINENO}: : LLDP_CFLAGS=\"\$LLDP_CFLAGS \${ac_res}\""; } >&5 | |
16763 | (: LLDP_CFLAGS="$LLDP_CFLAGS ${ac_res}") 2>&5 | |
16764 | ac_status=$? | |
16765 | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 | |
16766 | test $ac_status = 0; } | |
16767 | LLDP_CFLAGS="$LLDP_CFLAGS ${ac_res}" | |
16768 | fi | |
16769 | ;; | |
16770 | esac | |
16771 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking CFLAGS for gcc -Wno-unused-parameter" >&5 | |
16773 | 16772 | $as_echo_n "checking CFLAGS for gcc -Wno-unused-parameter... " >&6; } |
16774 | 16773 | if ${ac_cv_cflags_gcc_option__Wno_unused_parameter+:} false; then : |
16775 | 16774 | $as_echo_n "(cached) " >&6 |
23061 | 23060 | # report actual input values of CONFIG_FILES etc. instead of their |
23062 | 23061 | # values after options handling. |
23063 | 23062 | ac_log=" |
23064 | This file was extended by lldpd $as_me 1.0.4, which was | |
23063 | This file was extended by lldpd $as_me 1.0.5, which was | |
23065 | 23064 | generated by GNU Autoconf 2.69. Invocation command line was |
23066 | 23065 | |
23067 | 23066 | CONFIG_FILES = $CONFIG_FILES |
23128 | 23127 | cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 |
23129 | 23128 | ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" |
23130 | 23129 | ac_cs_version="\\ |
23131 | lldpd config.status 1.0.4 | |
23130 | lldpd config.status 1.0.5 | |
23132 | 23131 | configured by $0, generated by GNU Autoconf 2.69, |
23133 | 23132 | with options \\"\$ac_cs_config\\" |
23134 | 23133 |
77 | 77 | AX_CFLAGS_GCC_OPTION([-Wformat-security], [LLDP_CFLAGS]) |
78 | 78 | AX_CFLAGS_GCC_OPTION([-Wimplicit-fallthrough], [LLDP_CFLAGS]) |
79 | 79 | AX_CFLAGS_GCC_OPTION([-Wfatal-errors], [LLDP_CFLAGS]) |
80 | AX_CFLAGS_GCC_OPTION([-Wcast-align], [LLDP_CFLAGS]) | |
81 | 80 | AX_CFLAGS_GCC_OPTION([-Wheader-guard], [LLDP_CFLAGS]) |
82 | 81 | AX_CFLAGS_GCC_OPTION([-Wdocumentation], [LLDP_CFLAGS]) |
83 | 82 | AX_CFLAGS_GCC_OPTION([-Winline], [LLDP_CFLAGS]) |
84 | 83 | AX_CFLAGS_GCC_OPTION([-Wpointer-arith], [LLDP_CFLAGS]) |
85 | 84 | AX_CFLAGS_GCC_OPTION([-fno-omit-frame-pointer], [LLDP_CFLAGS]) |
85 | AX_CFLAGS_GCC_OPTION([-Wno-cast-align], [LLDP_CFLAGS]) dnl clang is bad at this | |
86 | 86 | AX_CFLAGS_GCC_OPTION([-Wno-unused-parameter], [LLDP_CFLAGS]) |
87 | 87 | AX_CFLAGS_GCC_OPTION([-Wno-missing-field-initializers], [LLDP_CFLAGS]) |
88 | 88 | AX_CFLAGS_GCC_OPTION([-Wno-sign-compare], [LLDP_CFLAGS]) dnl Should be fixed later |
0 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | |
1 | #ifndef __LINUX_BPF_COMMON_H__ | |
2 | #define __LINUX_BPF_COMMON_H__ | |
3 | ||
4 | /* Instruction classes */ | |
5 | #define BPF_CLASS(code) ((code) & 0x07) | |
6 | #define BPF_LD 0x00 | |
7 | #define BPF_LDX 0x01 | |
8 | #define BPF_ST 0x02 | |
9 | #define BPF_STX 0x03 | |
10 | #define BPF_ALU 0x04 | |
11 | #define BPF_JMP 0x05 | |
12 | #define BPF_RET 0x06 | |
13 | #define BPF_MISC 0x07 | |
14 | ||
15 | /* ld/ldx fields */ | |
16 | #define BPF_SIZE(code) ((code) & 0x18) | |
17 | #define BPF_W 0x00 /* 32-bit */ | |
18 | #define BPF_H 0x08 /* 16-bit */ | |
19 | #define BPF_B 0x10 /* 8-bit */ | |
20 | /* eBPF BPF_DW 0x18 64-bit */ | |
21 | #define BPF_MODE(code) ((code) & 0xe0) | |
22 | #define BPF_IMM 0x00 | |
23 | #define BPF_ABS 0x20 | |
24 | #define BPF_IND 0x40 | |
25 | #define BPF_MEM 0x60 | |
26 | #define BPF_LEN 0x80 | |
27 | #define BPF_MSH 0xa0 | |
28 | ||
29 | /* alu/jmp fields */ | |
30 | #define BPF_OP(code) ((code) & 0xf0) | |
31 | #define BPF_ADD 0x00 | |
32 | #define BPF_SUB 0x10 | |
33 | #define BPF_MUL 0x20 | |
34 | #define BPF_DIV 0x30 | |
35 | #define BPF_OR 0x40 | |
36 | #define BPF_AND 0x50 | |
37 | #define BPF_LSH 0x60 | |
38 | #define BPF_RSH 0x70 | |
39 | #define BPF_NEG 0x80 | |
40 | #define BPF_MOD 0x90 | |
41 | #define BPF_XOR 0xa0 | |
42 | ||
43 | #define BPF_JA 0x00 | |
44 | #define BPF_JEQ 0x10 | |
45 | #define BPF_JGT 0x20 | |
46 | #define BPF_JGE 0x30 | |
47 | #define BPF_JSET 0x40 | |
48 | #define BPF_SRC(code) ((code) & 0x08) | |
49 | #define BPF_K 0x00 | |
50 | #define BPF_X 0x08 | |
51 | ||
52 | #ifndef BPF_MAXINSNS | |
53 | #define BPF_MAXINSNS 4096 | |
54 | #endif | |
55 | ||
56 | #endif /* __LINUX_BPF_COMMON_H__ */ |
0 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | |
0 | 1 | /* |
1 | 2 | * ethtool.h: Defines for Linux ethtool. |
2 | 3 | * |
9 | 10 | * Portions Copyright (C) Sun Microsystems 2008 |
10 | 11 | */ |
11 | 12 | |
12 | #ifndef _UAPI_LINUX_ETHTOOL_H | |
13 | #define _UAPI_LINUX_ETHTOOL_H | |
14 | ||
13 | #ifndef _LINUX_ETHTOOL_H | |
14 | #define _LINUX_ETHTOOL_H | |
15 | ||
16 | #include <linux/kernel.h> | |
15 | 17 | #include <linux/types.h> |
16 | 18 | #include <linux/if_ether.h> |
17 | 19 | |
18 | #ifndef __KERNEL__ | |
19 | 20 | #include <limits.h> /* for INT_MAX */ |
20 | #endif | |
21 | 21 | |
22 | 22 | /* All structures exposed to userland should be defined such that they |
23 | 23 | * have the same layout for 32-bit and 64-bit userland. |
114 | 114 | __u32 reserved[2]; |
115 | 115 | }; |
116 | 116 | |
117 | static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep, | |
117 | static __inline__ void ethtool_cmd_speed_set(struct ethtool_cmd *ep, | |
118 | 118 | __u32 speed) |
119 | 119 | { |
120 | 120 | ep->speed = (__u16)(speed & 0xFFFF); |
121 | 121 | ep->speed_hi = (__u16)(speed >> 16); |
122 | 122 | } |
123 | 123 | |
124 | static inline __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep) | |
124 | static __inline__ __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep) | |
125 | 125 | { |
126 | 126 | return (ep->speed_hi << 16) | ep->speed; |
127 | 127 | } |
214 | 214 | __u32 data; |
215 | 215 | }; |
216 | 216 | |
217 | #define PFC_STORM_PREVENTION_AUTO 0xffff | |
218 | #define PFC_STORM_PREVENTION_DISABLE 0 | |
219 | ||
217 | 220 | enum tunable_id { |
218 | 221 | ETHTOOL_ID_UNSPEC, |
219 | 222 | ETHTOOL_RX_COPYBREAK, |
220 | 223 | ETHTOOL_TX_COPYBREAK, |
224 | ETHTOOL_PFC_PREVENTION_TOUT, /* timeout in msecs */ | |
221 | 225 | /* |
222 | * Add your fresh new tubale attribute above and remember to update | |
226 | * Add your fresh new tunable attribute above and remember to update | |
223 | 227 | * tunable_strings[] in net/core/ethtool.c |
224 | 228 | */ |
225 | 229 | __ETHTOOL_TUNABLE_COUNT, |
863 | 867 | * includes the %FLOW_EXT or %FLOW_MAC_EXT flag |
864 | 868 | * (see &struct ethtool_flow_ext description). |
865 | 869 | * @ring_cookie: RX ring/queue index to deliver to, or %RX_CLS_FLOW_DISC |
866 | * if packets should be discarded | |
870 | * if packets should be discarded, or %RX_CLS_FLOW_WAKE if the | |
871 | * packets should be used for Wake-on-LAN with %WAKE_FILTER | |
867 | 872 | * @location: Location of rule in the table. Locations must be |
868 | 873 | * numbered such that a flow matching multiple rules will be |
869 | 874 | * classified according to the first (lowest numbered) rule. |
892 | 897 | #define ETHTOOL_RX_FLOW_SPEC_RING 0x00000000FFFFFFFFLL |
893 | 898 | #define ETHTOOL_RX_FLOW_SPEC_RING_VF 0x000000FF00000000LL |
894 | 899 | #define ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF 32 |
895 | static inline __u64 ethtool_get_flow_spec_ring(__u64 ring_cookie) | |
900 | static __inline__ __u64 ethtool_get_flow_spec_ring(__u64 ring_cookie) | |
896 | 901 | { |
897 | 902 | return ETHTOOL_RX_FLOW_SPEC_RING & ring_cookie; |
898 | }; | |
899 | ||
900 | static inline __u64 ethtool_get_flow_spec_ring_vf(__u64 ring_cookie) | |
903 | } | |
904 | ||
905 | static __inline__ __u64 ethtool_get_flow_spec_ring_vf(__u64 ring_cookie) | |
901 | 906 | { |
902 | 907 | return (ETHTOOL_RX_FLOW_SPEC_RING_VF & ring_cookie) >> |
903 | 908 | ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF; |
904 | }; | |
909 | } | |
905 | 910 | |
906 | 911 | /** |
907 | 912 | * struct ethtool_rxnfc - command to get or set RX flow classification rules |
911 | 916 | * @flow_type: Type of flow to be affected, e.g. %TCP_V4_FLOW |
912 | 917 | * @data: Command-dependent value |
913 | 918 | * @fs: Flow classification rule |
919 | * @rss_context: RSS context to be affected | |
914 | 920 | * @rule_cnt: Number of rules to be affected |
915 | 921 | * @rule_locs: Array of used rule locations |
916 | 922 | * |
917 | 923 | * For %ETHTOOL_GRXFH and %ETHTOOL_SRXFH, @data is a bitmask indicating |
918 | 924 | * the fields included in the flow hash, e.g. %RXH_IP_SRC. The following |
919 | * structure fields must not be used. | |
925 | * structure fields must not be used, except that if @flow_type includes | |
926 | * the %FLOW_RSS flag, then @rss_context determines which RSS context to | |
927 | * act on. | |
920 | 928 | * |
921 | 929 | * For %ETHTOOL_GRXRINGS, @data is set to the number of RX rings/queues |
922 | 930 | * on return. |
928 | 936 | * set in @data then special location values should not be used. |
929 | 937 | * |
930 | 938 | * For %ETHTOOL_GRXCLSRULE, @fs.@location specifies the location of an |
931 | * existing rule on entry and @fs contains the rule on return. | |
939 | * existing rule on entry and @fs contains the rule on return; if | |
940 | * @fs.@flow_type includes the %FLOW_RSS flag, then @rss_context is | |
941 | * filled with the RSS context ID associated with the rule. | |
932 | 942 | * |
933 | 943 | * For %ETHTOOL_GRXCLSRLALL, @rule_cnt specifies the array size of the |
934 | 944 | * user buffer for @rule_locs on entry. On return, @data is the size |
939 | 949 | * For %ETHTOOL_SRXCLSRLINS, @fs specifies the rule to add or update. |
940 | 950 | * @fs.@location either specifies the location to use or is a special |
941 | 951 | * location value with %RX_CLS_LOC_SPECIAL flag set. On return, |
942 | * @fs.@location is the actual rule location. | |
952 | * @fs.@location is the actual rule location. If @fs.@flow_type | |
953 | * includes the %FLOW_RSS flag, @rss_context is the RSS context ID to | |
954 | * use for flow spreading traffic which matches this rule. The value | |
955 | * from the rxfh indirection table will be added to @fs.@ring_cookie | |
956 | * to choose which ring to deliver to. | |
943 | 957 | * |
944 | 958 | * For %ETHTOOL_SRXCLSRLDEL, @fs.@location specifies the location of an |
945 | 959 | * existing rule on entry. |
960 | 974 | __u32 flow_type; |
961 | 975 | __u64 data; |
962 | 976 | struct ethtool_rx_flow_spec fs; |
963 | __u32 rule_cnt; | |
977 | union { | |
978 | __u32 rule_cnt; | |
979 | __u32 rss_context; | |
980 | }; | |
964 | 981 | __u32 rule_locs[0]; |
965 | 982 | }; |
966 | 983 | |
987 | 1004 | /** |
988 | 1005 | * struct ethtool_rxfh - command to get/set RX flow hash indir or/and hash key. |
989 | 1006 | * @cmd: Specific command number - %ETHTOOL_GRSSH or %ETHTOOL_SRSSH |
990 | * @rss_context: RSS context identifier. | |
1007 | * @rss_context: RSS context identifier. Context 0 is the default for normal | |
1008 | * traffic; other contexts can be referenced as the destination for RX flow | |
1009 | * classification rules. %ETH_RXFH_CONTEXT_ALLOC is used with command | |
1010 | * %ETHTOOL_SRSSH to allocate a new RSS context; on return this field will | |
1011 | * contain the ID of the newly allocated context. | |
991 | 1012 | * @indir_size: On entry, the array size of the user buffer for the |
992 | 1013 | * indirection table, which may be zero, or (for %ETHTOOL_SRSSH), |
993 | 1014 | * %ETH_RXFH_INDIR_NO_CHANGE. On return from %ETHTOOL_GRSSH, |
1006 | 1027 | * size should be returned. For %ETHTOOL_SRSSH, an @indir_size of |
1007 | 1028 | * %ETH_RXFH_INDIR_NO_CHANGE means that indir table setting is not requested |
1008 | 1029 | * and a @indir_size of zero means the indir table should be reset to default |
1009 | * values. An hfunc of zero means that hash function setting is not requested. | |
1030 | * values (if @rss_context == 0) or that the RSS context should be deleted. | |
1031 | * An hfunc of zero means that hash function setting is not requested. | |
1010 | 1032 | */ |
1011 | 1033 | struct ethtool_rxfh { |
1012 | 1034 | __u32 cmd; |
1018 | 1040 | __u32 rsvd32; |
1019 | 1041 | __u32 rss_config[0]; |
1020 | 1042 | }; |
1043 | #define ETH_RXFH_CONTEXT_ALLOC 0xffffffff | |
1021 | 1044 | #define ETH_RXFH_INDIR_NO_CHANGE 0xffffffff |
1022 | 1045 | |
1023 | 1046 | /** |
1222 | 1245 | |
1223 | 1246 | #define MAX_NUM_QUEUE 4096 |
1224 | 1247 | |
1225 | #if 0 | |
1226 | 1248 | /** |
1227 | 1249 | * struct ethtool_per_queue_op - apply sub command to the queues in mask. |
1228 | 1250 | * @cmd: ETHTOOL_PERQUEUE |
1236 | 1258 | __u32 queue_mask[__KERNEL_DIV_ROUND_UP(MAX_NUM_QUEUE, 32)]; |
1237 | 1259 | char data[]; |
1238 | 1260 | }; |
1239 | #endif | |
1261 | ||
1262 | /** | |
1263 | * struct ethtool_fecparam - Ethernet forward error correction(fec) parameters | |
1264 | * @cmd: Command number = %ETHTOOL_GFECPARAM or %ETHTOOL_SFECPARAM | |
1265 | * @active_fec: FEC mode which is active on porte | |
1266 | * @fec: Bitmask of supported/configured FEC modes | |
1267 | * @rsvd: Reserved for future extensions. i.e FEC bypass feature. | |
1268 | * | |
1269 | * Drivers should reject a non-zero setting of @autoneg when | |
1270 | * autoneogotiation is disabled (or not supported) for the link. | |
1271 | * | |
1272 | */ | |
1273 | struct ethtool_fecparam { | |
1274 | __u32 cmd; | |
1275 | /* bitmask of FEC modes */ | |
1276 | __u32 active_fec; | |
1277 | __u32 fec; | |
1278 | __u32 reserved; | |
1279 | }; | |
1280 | ||
1281 | /** | |
1282 | * enum ethtool_fec_config_bits - flags definition of ethtool_fec_configuration | |
1283 | * @ETHTOOL_FEC_NONE: FEC mode configuration is not supported | |
1284 | * @ETHTOOL_FEC_AUTO: Default/Best FEC mode provided by driver | |
1285 | * @ETHTOOL_FEC_OFF: No FEC Mode | |
1286 | * @ETHTOOL_FEC_RS: Reed-Solomon Forward Error Detection mode | |
1287 | * @ETHTOOL_FEC_BASER: Base-R/Reed-Solomon Forward Error Detection mode | |
1288 | */ | |
1289 | enum ethtool_fec_config_bits { | |
1290 | ETHTOOL_FEC_NONE_BIT, | |
1291 | ETHTOOL_FEC_AUTO_BIT, | |
1292 | ETHTOOL_FEC_OFF_BIT, | |
1293 | ETHTOOL_FEC_RS_BIT, | |
1294 | ETHTOOL_FEC_BASER_BIT, | |
1295 | }; | |
1296 | ||
1297 | #define ETHTOOL_FEC_NONE (1 << ETHTOOL_FEC_NONE_BIT) | |
1298 | #define ETHTOOL_FEC_AUTO (1 << ETHTOOL_FEC_AUTO_BIT) | |
1299 | #define ETHTOOL_FEC_OFF (1 << ETHTOOL_FEC_OFF_BIT) | |
1300 | #define ETHTOOL_FEC_RS (1 << ETHTOOL_FEC_RS_BIT) | |
1301 | #define ETHTOOL_FEC_BASER (1 << ETHTOOL_FEC_BASER_BIT) | |
1240 | 1302 | |
1241 | 1303 | /* CMDs currently supported */ |
1242 | 1304 | #define ETHTOOL_GSET 0x00000001 /* DEPRECATED, Get settings. |
1330 | 1392 | #define ETHTOOL_SLINKSETTINGS 0x0000004d /* Set ethtool_link_settings */ |
1331 | 1393 | #define ETHTOOL_PHY_GTUNABLE 0x0000004e /* Get PHY tunable configuration */ |
1332 | 1394 | #define ETHTOOL_PHY_STUNABLE 0x0000004f /* Set PHY tunable configuration */ |
1395 | #define ETHTOOL_GFECPARAM 0x00000050 /* Get FEC settings */ | |
1396 | #define ETHTOOL_SFECPARAM 0x00000051 /* Set FEC settings */ | |
1333 | 1397 | |
1334 | 1398 | /* compatibility with older code */ |
1335 | 1399 | #define SPARC_ETH_GSET ETHTOOL_GSET |
1384 | 1448 | ETHTOOL_LINK_MODE_10000baseLR_Full_BIT = 44, |
1385 | 1449 | ETHTOOL_LINK_MODE_10000baseLRM_Full_BIT = 45, |
1386 | 1450 | ETHTOOL_LINK_MODE_10000baseER_Full_BIT = 46, |
1387 | ||
1451 | ETHTOOL_LINK_MODE_2500baseT_Full_BIT = 47, | |
1452 | ETHTOOL_LINK_MODE_5000baseT_Full_BIT = 48, | |
1453 | ||
1454 | ETHTOOL_LINK_MODE_FEC_NONE_BIT = 49, | |
1455 | ETHTOOL_LINK_MODE_FEC_RS_BIT = 50, | |
1456 | ETHTOOL_LINK_MODE_FEC_BASER_BIT = 51, | |
1388 | 1457 | |
1389 | 1458 | /* Last allowed bit for __ETHTOOL_LINK_MODE_LEGACY_MASK is bit |
1390 | 1459 | * 31. Please do NOT define any SUPPORTED_* or ADVERTISED_* |
1393 | 1462 | */ |
1394 | 1463 | |
1395 | 1464 | __ETHTOOL_LINK_MODE_LAST |
1396 | = ETHTOOL_LINK_MODE_10000baseER_Full_BIT, | |
1465 | = ETHTOOL_LINK_MODE_FEC_BASER_BIT, | |
1397 | 1466 | }; |
1398 | 1467 | |
1399 | 1468 | #define __ETHTOOL_LINK_MODE_LEGACY_MASK(base_name) \ |
1484 | 1553 | * it was forced up into this mode or autonegotiated. |
1485 | 1554 | */ |
1486 | 1555 | |
1487 | /* The forced speed, in units of 1Mb. All values 0 to INT_MAX are legal. */ | |
1556 | /* The forced speed, in units of 1Mb. All values 0 to INT_MAX are legal. | |
1557 | * Update drivers/net/phy/phy.c:phy_speed_to_str() and | |
1558 | * drivers/net/bonding/bond_3ad.c:__get_link_speed() when adding new values. | |
1559 | */ | |
1488 | 1560 | #define SPEED_10 10 |
1489 | 1561 | #define SPEED_100 100 |
1490 | 1562 | #define SPEED_1000 1000 |
1491 | 1563 | #define SPEED_2500 2500 |
1492 | 1564 | #define SPEED_5000 5000 |
1493 | 1565 | #define SPEED_10000 10000 |
1566 | #define SPEED_14000 14000 | |
1494 | 1567 | #define SPEED_20000 20000 |
1495 | 1568 | #define SPEED_25000 25000 |
1496 | 1569 | #define SPEED_40000 40000 |
1500 | 1573 | |
1501 | 1574 | #define SPEED_UNKNOWN -1 |
1502 | 1575 | |
1503 | static inline int ethtool_validate_speed(__u32 speed) | |
1576 | static __inline__ int ethtool_validate_speed(__u32 speed) | |
1504 | 1577 | { |
1505 | 1578 | return speed <= INT_MAX || speed == SPEED_UNKNOWN; |
1506 | 1579 | } |
1510 | 1583 | #define DUPLEX_FULL 0x01 |
1511 | 1584 | #define DUPLEX_UNKNOWN 0xff |
1512 | 1585 | |
1513 | static inline int ethtool_validate_duplex(__u8 duplex) | |
1586 | static __inline__ int ethtool_validate_duplex(__u8 duplex) | |
1514 | 1587 | { |
1515 | 1588 | switch (duplex) { |
1516 | 1589 | case DUPLEX_HALF: |
1559 | 1632 | #define WAKE_ARP (1 << 4) |
1560 | 1633 | #define WAKE_MAGIC (1 << 5) |
1561 | 1634 | #define WAKE_MAGICSECURE (1 << 6) /* only meaningful if WAKE_MAGIC */ |
1635 | #define WAKE_FILTER (1 << 7) | |
1562 | 1636 | |
1563 | 1637 | /* L2-L4 network traffic flow types */ |
1564 | 1638 | #define TCP_V4_FLOW 0x01 /* hash or spec (tcp_ip4_spec) */ |
1582 | 1656 | /* Flag to enable additional fields in struct ethtool_rx_flow_spec */ |
1583 | 1657 | #define FLOW_EXT 0x80000000 |
1584 | 1658 | #define FLOW_MAC_EXT 0x40000000 |
1659 | /* Flag to enable RSS spreading of traffic matching rule (nfc only) */ | |
1660 | #define FLOW_RSS 0x20000000 | |
1585 | 1661 | |
1586 | 1662 | /* L3-L4 network traffic flow hash options */ |
1587 | 1663 | #define RXH_L2DA (1 << 1) |
1594 | 1670 | #define RXH_DISCARD (1 << 31) |
1595 | 1671 | |
1596 | 1672 | #define RX_CLS_FLOW_DISC 0xffffffffffffffffULL |
1673 | #define RX_CLS_FLOW_WAKE 0xfffffffffffffffeULL | |
1597 | 1674 | |
1598 | 1675 | /* Special RX classification rule insert location values */ |
1599 | 1676 | #define RX_CLS_LOC_SPECIAL 0x80000000 /* flag */ |
1633 | 1710 | ETH_RESET_PHY = 1 << 6, /* Transceiver/PHY */ |
1634 | 1711 | ETH_RESET_RAM = 1 << 7, /* RAM shared between |
1635 | 1712 | * multiple components */ |
1713 | ETH_RESET_AP = 1 << 8, /* Application processor */ | |
1636 | 1714 | |
1637 | 1715 | ETH_RESET_DEDICATED = 0x0000ffff, /* All components dedicated to |
1638 | 1716 | * this interface */ |
1701 | 1779 | * %ethtool_link_mode_bit_indices for the link modes, and other |
1702 | 1780 | * link features that the link partner advertised through |
1703 | 1781 | * autonegotiation; 0 if unknown or not applicable. Read-only. |
1782 | * @transceiver: Used to distinguish different possible PHY types, | |
1783 | * reported consistently by PHYLIB. Read-only. | |
1704 | 1784 | * |
1705 | 1785 | * If autonegotiation is disabled, the speed and @duplex represent the |
1706 | 1786 | * fixed link mode and are writable if the driver supports multiple |
1752 | 1832 | __u8 eth_tp_mdix; |
1753 | 1833 | __u8 eth_tp_mdix_ctrl; |
1754 | 1834 | __s8 link_mode_masks_nwords; |
1755 | __u32 reserved[8]; | |
1835 | __u8 transceiver; | |
1836 | __u8 reserved1[3]; | |
1837 | __u32 reserved[7]; | |
1756 | 1838 | __u32 link_mode_masks[0]; |
1757 | 1839 | /* layout of link_mode_masks fields: |
1758 | 1840 | * __u32 map_supported[link_mode_masks_nwords]; |
1760 | 1842 | * __u32 map_lp_advertising[link_mode_masks_nwords]; |
1761 | 1843 | */ |
1762 | 1844 | }; |
1763 | #endif /* _UAPI_LINUX_ETHTOOL_H */ | |
1845 | #endif /* _LINUX_ETHTOOL_H */ |
0 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | |
0 | 1 | /* |
1 | 2 | * Linux Socket Filter Data Structures |
2 | 3 | */ |
6 | 7 | |
7 | 8 | |
8 | 9 | #include <linux/types.h> |
9 | ||
10 | #include <linux/bpf_common.h> | |
10 | 11 | |
11 | 12 | /* |
12 | 13 | * Current version of the filter code architecture. |
31 | 32 | struct sock_filter *filter; |
32 | 33 | }; |
33 | 34 | |
34 | /* | |
35 | * Instruction classes | |
36 | */ | |
37 | ||
38 | #define BPF_CLASS(code) ((code) & 0x07) | |
39 | #define BPF_LD 0x00 | |
40 | #define BPF_LDX 0x01 | |
41 | #define BPF_ST 0x02 | |
42 | #define BPF_STX 0x03 | |
43 | #define BPF_ALU 0x04 | |
44 | #define BPF_JMP 0x05 | |
45 | #define BPF_RET 0x06 | |
46 | #define BPF_MISC 0x07 | |
47 | ||
48 | /* ld/ldx fields */ | |
49 | #define BPF_SIZE(code) ((code) & 0x18) | |
50 | #define BPF_W 0x00 | |
51 | #define BPF_H 0x08 | |
52 | #define BPF_B 0x10 | |
53 | #define BPF_MODE(code) ((code) & 0xe0) | |
54 | #define BPF_IMM 0x00 | |
55 | #define BPF_ABS 0x20 | |
56 | #define BPF_IND 0x40 | |
57 | #define BPF_MEM 0x60 | |
58 | #define BPF_LEN 0x80 | |
59 | #define BPF_MSH 0xa0 | |
60 | ||
61 | /* alu/jmp fields */ | |
62 | #define BPF_OP(code) ((code) & 0xf0) | |
63 | #define BPF_ADD 0x00 | |
64 | #define BPF_SUB 0x10 | |
65 | #define BPF_MUL 0x20 | |
66 | #define BPF_DIV 0x30 | |
67 | #define BPF_OR 0x40 | |
68 | #define BPF_AND 0x50 | |
69 | #define BPF_LSH 0x60 | |
70 | #define BPF_RSH 0x70 | |
71 | #define BPF_NEG 0x80 | |
72 | #define BPF_JA 0x00 | |
73 | #define BPF_JEQ 0x10 | |
74 | #define BPF_JGT 0x20 | |
75 | #define BPF_JGE 0x30 | |
76 | #define BPF_JSET 0x40 | |
77 | #define BPF_SRC(code) ((code) & 0x08) | |
78 | #define BPF_K 0x00 | |
79 | #define BPF_X 0x08 | |
80 | ||
81 | 35 | /* ret - BPF_K and BPF_X also apply */ |
82 | 36 | #define BPF_RVAL(code) ((code) & 0x18) |
83 | 37 | #define BPF_A 0x10 |
86 | 40 | #define BPF_MISCOP(code) ((code) & 0xf8) |
87 | 41 | #define BPF_TAX 0x00 |
88 | 42 | #define BPF_TXA 0x80 |
89 | ||
90 | #ifndef BPF_MAXINSNS | |
91 | #define BPF_MAXINSNS 4096 | |
92 | #endif | |
93 | 43 | |
94 | 44 | /* |
95 | 45 | * Macros for filter block array initializers. |
123 | 73 | #define SKF_AD_RXHASH 32 |
124 | 74 | #define SKF_AD_CPU 36 |
125 | 75 | #define SKF_AD_ALU_XOR_X 40 |
126 | #define SKF_AD_MAX 44 | |
127 | #define SKF_NET_OFF (-0x100000) | |
128 | #define SKF_LL_OFF (-0x200000) | |
76 | #define SKF_AD_VLAN_TAG 44 | |
77 | #define SKF_AD_VLAN_TAG_PRESENT 48 | |
78 | #define SKF_AD_PAY_OFFSET 52 | |
79 | #define SKF_AD_RANDOM 56 | |
80 | #define SKF_AD_VLAN_TPID 60 | |
81 | #define SKF_AD_MAX 64 | |
129 | 82 | |
83 | #define SKF_NET_OFF (-0x100000) | |
84 | #define SKF_LL_OFF (-0x200000) | |
85 | ||
86 | #define BPF_NET_OFF SKF_NET_OFF | |
87 | #define BPF_LL_OFF SKF_LL_OFF | |
130 | 88 | |
131 | 89 | #endif /* __LINUX_FILTER_H__ */ |
0 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | |
0 | 1 | #ifndef __HDLC_IOCTL_H__ |
1 | 2 | #define __HDLC_IOCTL_H__ |
2 | 3 | |
33 | 34 | #define LMI_CCITT 3 /* ITU-T Annex A */ |
34 | 35 | #define LMI_CISCO 4 /* The "original" LMI, aka Gang of Four */ |
35 | 36 | |
36 | typedef struct { | |
37 | #ifndef __ASSEMBLY__ | |
38 | ||
39 | typedef struct { | |
37 | 40 | unsigned int clock_rate; /* bits per second */ |
38 | 41 | unsigned int clock_type; /* internal, external, TX-internal etc. */ |
39 | 42 | unsigned short loopback; |
40 | 43 | } sync_serial_settings; /* V.35, V.24, X.21 */ |
41 | 44 | |
42 | typedef struct { | |
45 | typedef struct { | |
43 | 46 | unsigned int clock_rate; /* bits per second */ |
44 | 47 | unsigned int clock_type; /* internal, external, TX-internal etc. */ |
45 | 48 | unsigned short loopback; |
77 | 80 | |
78 | 81 | /* PPP doesn't need any info now - supply length = 0 to ioctl */ |
79 | 82 | |
83 | #endif /* __ASSEMBLY__ */ | |
80 | 84 | #endif /* __HDLC_IOCTL_H__ */ |
0 | /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ | |
0 | 1 | /* |
1 | 2 | * INET An implementation of the TCP/IP protocol suite for the LINUX |
2 | 3 | * operating system. INET is implemented using the BSD Socket |
18 | 19 | #ifndef _LINUX_IF_H |
19 | 20 | #define _LINUX_IF_H |
20 | 21 | |
22 | #include <linux/libc-compat.h> /* for compatibility with glibc */ | |
21 | 23 | #include <linux/types.h> /* for "__kernel_caddr_t" et al */ |
22 | 24 | #include <linux/socket.h> /* for "struct sockaddr" et al */ |
23 | 25 | /* for "__user" et al */ |
24 | 26 | |
27 | #include <sys/socket.h> /* for struct sockaddr. */ | |
28 | ||
29 | #if __UAPI_DEF_IF_IFNAMSIZ | |
25 | 30 | #define IFNAMSIZ 16 |
31 | #endif /* __UAPI_DEF_IF_IFNAMSIZ */ | |
26 | 32 | #define IFALIASZ 256 |
27 | 33 | #include <linux/hdlc/ioctl.h> |
28 | 34 | |
29 | /* Standard interface flags (netdevice->flags). */ | |
30 | #define IFF_UP 0x1 /* interface is up */ | |
31 | #define IFF_BROADCAST 0x2 /* broadcast address valid */ | |
32 | #define IFF_DEBUG 0x4 /* turn on debugging */ | |
33 | #define IFF_LOOPBACK 0x8 /* is a loopback net */ | |
34 | #define IFF_POINTOPOINT 0x10 /* interface is has p-p link */ | |
35 | #define IFF_NOTRAILERS 0x20 /* avoid use of trailers */ | |
36 | #define IFF_RUNNING 0x40 /* interface RFC2863 OPER_UP */ | |
37 | #define IFF_NOARP 0x80 /* no ARP protocol */ | |
38 | #define IFF_PROMISC 0x100 /* receive all packets */ | |
39 | #define IFF_ALLMULTI 0x200 /* receive all multicast packets*/ | |
40 | ||
41 | #define IFF_MASTER 0x400 /* master of a load balancer */ | |
42 | #define IFF_SLAVE 0x800 /* slave of a load balancer */ | |
43 | ||
44 | #define IFF_MULTICAST 0x1000 /* Supports multicast */ | |
45 | ||
46 | #define IFF_PORTSEL 0x2000 /* can set media type */ | |
47 | #define IFF_AUTOMEDIA 0x4000 /* auto media select active */ | |
48 | #define IFF_DYNAMIC 0x8000 /* dialup device with changing addresses*/ | |
49 | ||
50 | #define IFF_LOWER_UP 0x10000 /* driver signals L1 up */ | |
51 | #define IFF_DORMANT 0x20000 /* driver signals dormant */ | |
52 | ||
53 | #define IFF_ECHO 0x40000 /* echo sent packets */ | |
35 | /* For glibc compatibility. An empty enum does not compile. */ | |
36 | #if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO != 0 || \ | |
37 | __UAPI_DEF_IF_NET_DEVICE_FLAGS != 0 | |
38 | /** | |
39 | * enum net_device_flags - &struct net_device flags | |
40 | * | |
41 | * These are the &struct net_device flags, they can be set by drivers, the | |
42 | * kernel and some can be triggered by userspace. Userspace can query and | |
43 | * set these flags using userspace utilities but there is also a sysfs | |
44 | * entry available for all dev flags which can be queried and set. These flags | |
45 | * are shared for all types of net_devices. The sysfs entries are available | |
46 | * via /sys/class/net/<dev>/flags. Flags which can be toggled through sysfs | |
47 | * are annotated below, note that only a few flags can be toggled and some | |
48 | * other flags are always preserved from the original net_device flags | |
49 | * even if you try to set them via sysfs. Flags which are always preserved | |
50 | * are kept under the flag grouping @IFF_VOLATILE. Flags which are __volatile__ | |
51 | * are annotated below as such. | |
52 | * | |
53 | * You should have a pretty good reason to be extending these flags. | |
54 | * | |
55 | * @IFF_UP: interface is up. Can be toggled through sysfs. | |
56 | * @IFF_BROADCAST: broadcast address valid. Volatile. | |
57 | * @IFF_DEBUG: turn on debugging. Can be toggled through sysfs. | |
58 | * @IFF_LOOPBACK: is a loopback net. Volatile. | |
59 | * @IFF_POINTOPOINT: interface is has p-p link. Volatile. | |
60 | * @IFF_NOTRAILERS: avoid use of trailers. Can be toggled through sysfs. | |
61 | * Volatile. | |
62 | * @IFF_RUNNING: interface RFC2863 OPER_UP. Volatile. | |
63 | * @IFF_NOARP: no ARP protocol. Can be toggled through sysfs. Volatile. | |
64 | * @IFF_PROMISC: receive all packets. Can be toggled through sysfs. | |
65 | * @IFF_ALLMULTI: receive all multicast packets. Can be toggled through | |
66 | * sysfs. | |
67 | * @IFF_MASTER: master of a load balancer. Volatile. | |
68 | * @IFF_SLAVE: slave of a load balancer. Volatile. | |
69 | * @IFF_MULTICAST: Supports multicast. Can be toggled through sysfs. | |
70 | * @IFF_PORTSEL: can set media type. Can be toggled through sysfs. | |
71 | * @IFF_AUTOMEDIA: auto media select active. Can be toggled through sysfs. | |
72 | * @IFF_DYNAMIC: dialup device with changing addresses. Can be toggled | |
73 | * through sysfs. | |
74 | * @IFF_LOWER_UP: driver signals L1 up. Volatile. | |
75 | * @IFF_DORMANT: driver signals dormant. Volatile. | |
76 | * @IFF_ECHO: echo sent packets. Volatile. | |
77 | */ | |
78 | enum net_device_flags { | |
79 | /* for compatibility with glibc net/if.h */ | |
80 | #if __UAPI_DEF_IF_NET_DEVICE_FLAGS | |
81 | IFF_UP = 1<<0, /* sysfs */ | |
82 | IFF_BROADCAST = 1<<1, /* __volatile__ */ | |
83 | IFF_DEBUG = 1<<2, /* sysfs */ | |
84 | IFF_LOOPBACK = 1<<3, /* __volatile__ */ | |
85 | IFF_POINTOPOINT = 1<<4, /* __volatile__ */ | |
86 | IFF_NOTRAILERS = 1<<5, /* sysfs */ | |
87 | IFF_RUNNING = 1<<6, /* __volatile__ */ | |
88 | IFF_NOARP = 1<<7, /* sysfs */ | |
89 | IFF_PROMISC = 1<<8, /* sysfs */ | |
90 | IFF_ALLMULTI = 1<<9, /* sysfs */ | |
91 | IFF_MASTER = 1<<10, /* __volatile__ */ | |
92 | IFF_SLAVE = 1<<11, /* __volatile__ */ | |
93 | IFF_MULTICAST = 1<<12, /* sysfs */ | |
94 | IFF_PORTSEL = 1<<13, /* sysfs */ | |
95 | IFF_AUTOMEDIA = 1<<14, /* sysfs */ | |
96 | IFF_DYNAMIC = 1<<15, /* sysfs */ | |
97 | #endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS */ | |
98 | #if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO | |
99 | IFF_LOWER_UP = 1<<16, /* __volatile__ */ | |
100 | IFF_DORMANT = 1<<17, /* __volatile__ */ | |
101 | IFF_ECHO = 1<<18, /* __volatile__ */ | |
102 | #endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */ | |
103 | }; | |
104 | #endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO != 0 || __UAPI_DEF_IF_NET_DEVICE_FLAGS != 0 */ | |
105 | ||
106 | /* for compatibility with glibc net/if.h */ | |
107 | #if __UAPI_DEF_IF_NET_DEVICE_FLAGS | |
108 | #define IFF_UP IFF_UP | |
109 | #define IFF_BROADCAST IFF_BROADCAST | |
110 | #define IFF_DEBUG IFF_DEBUG | |
111 | #define IFF_LOOPBACK IFF_LOOPBACK | |
112 | #define IFF_POINTOPOINT IFF_POINTOPOINT | |
113 | #define IFF_NOTRAILERS IFF_NOTRAILERS | |
114 | #define IFF_RUNNING IFF_RUNNING | |
115 | #define IFF_NOARP IFF_NOARP | |
116 | #define IFF_PROMISC IFF_PROMISC | |
117 | #define IFF_ALLMULTI IFF_ALLMULTI | |
118 | #define IFF_MASTER IFF_MASTER | |
119 | #define IFF_SLAVE IFF_SLAVE | |
120 | #define IFF_MULTICAST IFF_MULTICAST | |
121 | #define IFF_PORTSEL IFF_PORTSEL | |
122 | #define IFF_AUTOMEDIA IFF_AUTOMEDIA | |
123 | #define IFF_DYNAMIC IFF_DYNAMIC | |
124 | #endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS */ | |
125 | ||
126 | #if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO | |
127 | #define IFF_LOWER_UP IFF_LOWER_UP | |
128 | #define IFF_DORMANT IFF_DORMANT | |
129 | #define IFF_ECHO IFF_ECHO | |
130 | #endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */ | |
54 | 131 | |
55 | 132 | #define IFF_VOLATILE (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST|IFF_ECHO|\ |
56 | 133 | IFF_MASTER|IFF_SLAVE|IFF_RUNNING|IFF_LOWER_UP|IFF_DORMANT) |
57 | ||
58 | /* Private (from user) interface flags (netdevice->priv_flags). */ | |
59 | #define IFF_802_1Q_VLAN 0x1 /* 802.1Q VLAN device. */ | |
60 | #define IFF_EBRIDGE 0x2 /* Ethernet bridging device. */ | |
61 | #define IFF_SLAVE_INACTIVE 0x4 /* bonding slave not the curr. active */ | |
62 | #define IFF_MASTER_8023AD 0x8 /* bonding master, 802.3ad. */ | |
63 | #define IFF_MASTER_ALB 0x10 /* bonding master, balance-alb. */ | |
64 | #define IFF_BONDING 0x20 /* bonding master or slave */ | |
65 | #define IFF_SLAVE_NEEDARP 0x40 /* need ARPs for validation */ | |
66 | #define IFF_ISATAP 0x80 /* ISATAP interface (RFC4214) */ | |
67 | #define IFF_MASTER_ARPMON 0x100 /* bonding master, ARP mon in use */ | |
68 | #define IFF_WAN_HDLC 0x200 /* WAN HDLC device */ | |
69 | #define IFF_XMIT_DST_RELEASE 0x400 /* dev_hard_start_xmit() is allowed to | |
70 | * release skb->dst | |
71 | */ | |
72 | #define IFF_DONT_BRIDGE 0x800 /* disallow bridging this ether dev */ | |
73 | #define IFF_DISABLE_NETPOLL 0x1000 /* disable netpoll at run-time */ | |
74 | #define IFF_MACVLAN_PORT 0x2000 /* device used as macvlan port */ | |
75 | #define IFF_BRIDGE_PORT 0x4000 /* device used as bridge port */ | |
76 | #define IFF_OVS_DATAPATH 0x8000 /* device used as Open vSwitch | |
77 | * datapath port */ | |
78 | #define IFF_TX_SKB_SHARING 0x10000 /* The interface supports sharing | |
79 | * skbs on transmit */ | |
80 | #define IFF_UNICAST_FLT 0x20000 /* Supports unicast filtering */ | |
81 | #define IFF_TEAM_PORT 0x40000 /* device used as team port */ | |
82 | #define IFF_SUPP_NOFCS 0x80000 /* device supports sending custom FCS */ | |
83 | #define IFF_LIVE_ADDR_CHANGE 0x100000 /* device supports hardware address | |
84 | * change when it's running */ | |
85 | ||
86 | 134 | |
87 | 135 | #define IF_GET_IFACE 0x0001 /* for querying only */ |
88 | 136 | #define IF_GET_PROTO 0x0002 |
138 | 186 | * being very small might be worth keeping for clean configuration. |
139 | 187 | */ |
140 | 188 | |
189 | /* for compatibility with glibc net/if.h */ | |
190 | #if __UAPI_DEF_IF_IFMAP | |
141 | 191 | struct ifmap { |
142 | 192 | unsigned long mem_start; |
143 | 193 | unsigned long mem_end; |
147 | 197 | unsigned char port; |
148 | 198 | /* 3 bytes spare */ |
149 | 199 | }; |
200 | #endif /* __UAPI_DEF_IF_IFMAP */ | |
150 | 201 | |
151 | 202 | struct if_settings { |
152 | 203 | unsigned int type; /* Type of physical device or protocol */ |
172 | 223 | * remainder may be interface specific. |
173 | 224 | */ |
174 | 225 | |
226 | /* for compatibility with glibc net/if.h */ | |
227 | #if __UAPI_DEF_IF_IFREQ | |
175 | 228 | struct ifreq { |
176 | 229 | #define IFHWADDRLEN 6 |
177 | 230 | union |
195 | 248 | struct if_settings ifru_settings; |
196 | 249 | } ifr_ifru; |
197 | 250 | }; |
251 | #endif /* __UAPI_DEF_IF_IFREQ */ | |
198 | 252 | |
199 | 253 | #define ifr_name ifr_ifrn.ifrn_name /* interface name */ |
200 | 254 | #define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ |
221 | 275 | * must know all networks accessible). |
222 | 276 | */ |
223 | 277 | |
278 | /* for compatibility with glibc net/if.h */ | |
279 | #if __UAPI_DEF_IF_IFCONF | |
224 | 280 | struct ifconf { |
225 | 281 | int ifc_len; /* size of buffer */ |
226 | 282 | union { |
228 | 284 | struct ifreq *ifcu_req; |
229 | 285 | } ifc_ifcu; |
230 | 286 | }; |
287 | #endif /* __UAPI_DEF_IF_IFCONF */ | |
288 | ||
231 | 289 | #define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ |
232 | 290 | #define ifc_req ifc_ifcu.ifcu_req /* array of structures */ |
233 | 291 |
0 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | |
0 | 1 | #ifndef __LINUX_IF_ADDR_H |
1 | 2 | #define __LINUX_IF_ADDR_H |
2 | 3 | |
17 | 18 | * It makes no difference for normally configured broadcast interfaces, |
18 | 19 | * but for point-to-point IFA_ADDRESS is DESTINATION address, |
19 | 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. | |
20 | 24 | */ |
21 | 25 | enum { |
22 | 26 | IFA_UNSPEC, |
27 | 31 | IFA_ANYCAST, |
28 | 32 | IFA_CACHEINFO, |
29 | 33 | IFA_MULTICAST, |
34 | IFA_FLAGS, | |
35 | IFA_RT_PRIORITY, /* u32, priority/metric for prefix route */ | |
30 | 36 | __IFA_MAX, |
31 | 37 | }; |
32 | 38 | |
43 | 49 | #define IFA_F_DEPRECATED 0x20 |
44 | 50 | #define IFA_F_TENTATIVE 0x40 |
45 | 51 | #define IFA_F_PERMANENT 0x80 |
52 | #define IFA_F_MANAGETEMPADDR 0x100 | |
53 | #define IFA_F_NOPREFIXROUTE 0x200 | |
54 | #define IFA_F_MCAUTOJOIN 0x400 | |
55 | #define IFA_F_STABLE_PRIVACY 0x800 | |
46 | 56 | |
47 | 57 | struct ifa_cacheinfo { |
48 | 58 | __u32 ifa_prefered; |
52 | 62 | }; |
53 | 63 | |
54 | 64 | /* backwards compatibility for userspace */ |
55 | #define IFA_RTA(r) ((struct rtattr*)(void*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg)))) | |
65 | #define IFA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg)))) | |
56 | 66 | #define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg)) |
57 | 67 | |
58 | 68 | #endif |
0 | /* SPDX-License-Identifier: GPL-1.0+ WITH Linux-syscall-note */ | |
0 | 1 | /* |
1 | 2 | * Bond several ethernet interfaces into a Cisco, running 'Etherchannel'. |
2 | 3 | * |
90 | 91 | #define BOND_XMIT_POLICY_LAYER2 0 /* layer 2 (MAC only), default */ |
91 | 92 | #define BOND_XMIT_POLICY_LAYER34 1 /* layer 3+4 (IP ^ (TCP || UDP)) */ |
92 | 93 | #define BOND_XMIT_POLICY_LAYER23 2 /* layer 2+3 (IP ^ MAC) */ |
94 | #define BOND_XMIT_POLICY_ENCAP23 3 /* encapsulated layer 2+3 */ | |
95 | #define BOND_XMIT_POLICY_ENCAP34 4 /* encapsulated layer 3+4 */ | |
93 | 96 | |
94 | 97 | typedef struct ifbond { |
95 | 98 | __s32 bond_mode; |
0 | /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ | |
0 | 1 | /* |
1 | 2 | * Linux ethernet bridge |
2 | 3 | * |
13 | 14 | #define _LINUX_IF_BRIDGE_H |
14 | 15 | |
15 | 16 | #include <linux/types.h> |
17 | #include <linux/if_ether.h> | |
16 | 18 | |
17 | 19 | #define SYSFS_BRIDGE_ATTR "bridge" |
18 | 20 | #define SYSFS_BRIDGE_FDB "brforward" |
87 | 89 | }; |
88 | 90 | |
89 | 91 | struct __fdb_entry { |
90 | __u8 mac_addr[6]; | |
92 | __u8 mac_addr[ETH_ALEN]; | |
91 | 93 | __u8 port_no; |
92 | 94 | __u8 is_local; |
93 | 95 | __u32 ageing_timer_value; |
96 | 98 | __u16 unused; |
97 | 99 | }; |
98 | 100 | |
99 | ||
100 | #endif | |
101 | /* Bridge Flags */ | |
102 | #define BRIDGE_FLAGS_MASTER 1 /* Bridge command to/from master */ | |
103 | #define BRIDGE_FLAGS_SELF 2 /* Bridge command to/from lowerdev */ | |
104 | ||
105 | #define BRIDGE_MODE_VEB 0 /* Default loopback mode */ | |
106 | #define BRIDGE_MODE_VEPA 1 /* 802.1Qbg defined VEPA mode */ | |
107 | #define BRIDGE_MODE_UNDEF 0xFFFF /* mode undefined */ | |
108 | ||
109 | /* Bridge management nested attributes | |
110 | * [IFLA_AF_SPEC] = { | |
111 | * [IFLA_BRIDGE_FLAGS] | |
112 | * [IFLA_BRIDGE_MODE] | |
113 | * [IFLA_BRIDGE_VLAN_INFO] | |
114 | * } | |
115 | */ | |
116 | enum { | |
117 | IFLA_BRIDGE_FLAGS, | |
118 | IFLA_BRIDGE_MODE, | |
119 | IFLA_BRIDGE_VLAN_INFO, | |
120 | IFLA_BRIDGE_VLAN_TUNNEL_INFO, | |
121 | __IFLA_BRIDGE_MAX, | |
122 | }; | |
123 | #define IFLA_BRIDGE_MAX (__IFLA_BRIDGE_MAX - 1) | |
124 | ||
125 | #define BRIDGE_VLAN_INFO_MASTER (1<<0) /* Operate on Bridge device as well */ | |
126 | #define BRIDGE_VLAN_INFO_PVID (1<<1) /* VLAN is PVID, ingress untagged */ | |
127 | #define BRIDGE_VLAN_INFO_UNTAGGED (1<<2) /* VLAN egresses untagged */ | |
128 | #define BRIDGE_VLAN_INFO_RANGE_BEGIN (1<<3) /* VLAN is start of vlan range */ | |
129 | #define BRIDGE_VLAN_INFO_RANGE_END (1<<4) /* VLAN is end of vlan range */ | |
130 | #define BRIDGE_VLAN_INFO_BRENTRY (1<<5) /* Global bridge VLAN entry */ | |
131 | ||
132 | struct bridge_vlan_info { | |
133 | __u16 flags; | |
134 | __u16 vid; | |
135 | }; | |
136 | ||
137 | enum { | |
138 | IFLA_BRIDGE_VLAN_TUNNEL_UNSPEC, | |
139 | IFLA_BRIDGE_VLAN_TUNNEL_ID, | |
140 | IFLA_BRIDGE_VLAN_TUNNEL_VID, | |
141 | IFLA_BRIDGE_VLAN_TUNNEL_FLAGS, | |
142 | __IFLA_BRIDGE_VLAN_TUNNEL_MAX, | |
143 | }; | |
144 | ||
145 | #define IFLA_BRIDGE_VLAN_TUNNEL_MAX (__IFLA_BRIDGE_VLAN_TUNNEL_MAX - 1) | |
146 | ||
147 | struct bridge_vlan_xstats { | |
148 | __u64 rx_bytes; | |
149 | __u64 rx_packets; | |
150 | __u64 tx_bytes; | |
151 | __u64 tx_packets; | |
152 | __u16 vid; | |
153 | __u16 flags; | |
154 | __u32 pad2; | |
155 | }; | |
156 | ||
157 | /* Bridge multicast database attributes | |
158 | * [MDBA_MDB] = { | |
159 | * [MDBA_MDB_ENTRY] = { | |
160 | * [MDBA_MDB_ENTRY_INFO] { | |
161 | * struct br_mdb_entry | |
162 | * [MDBA_MDB_EATTR attributes] | |
163 | * } | |
164 | * } | |
165 | * } | |
166 | * [MDBA_ROUTER] = { | |
167 | * [MDBA_ROUTER_PORT] = { | |
168 | * u32 ifindex | |
169 | * [MDBA_ROUTER_PATTR attributes] | |
170 | * } | |
171 | * } | |
172 | */ | |
173 | enum { | |
174 | MDBA_UNSPEC, | |
175 | MDBA_MDB, | |
176 | MDBA_ROUTER, | |
177 | __MDBA_MAX, | |
178 | }; | |
179 | #define MDBA_MAX (__MDBA_MAX - 1) | |
180 | ||
181 | enum { | |
182 | MDBA_MDB_UNSPEC, | |
183 | MDBA_MDB_ENTRY, | |
184 | __MDBA_MDB_MAX, | |
185 | }; | |
186 | #define MDBA_MDB_MAX (__MDBA_MDB_MAX - 1) | |
187 | ||
188 | enum { | |
189 | MDBA_MDB_ENTRY_UNSPEC, | |
190 | MDBA_MDB_ENTRY_INFO, | |
191 | __MDBA_MDB_ENTRY_MAX, | |
192 | }; | |
193 | #define MDBA_MDB_ENTRY_MAX (__MDBA_MDB_ENTRY_MAX - 1) | |
194 | ||
195 | /* per mdb entry additional attributes */ | |
196 | enum { | |
197 | MDBA_MDB_EATTR_UNSPEC, | |
198 | MDBA_MDB_EATTR_TIMER, | |
199 | __MDBA_MDB_EATTR_MAX | |
200 | }; | |
201 | #define MDBA_MDB_EATTR_MAX (__MDBA_MDB_EATTR_MAX - 1) | |
202 | ||
203 | /* multicast router types */ | |
204 | enum { | |
205 | MDB_RTR_TYPE_DISABLED, | |
206 | MDB_RTR_TYPE_TEMP_QUERY, | |
207 | MDB_RTR_TYPE_PERM, | |
208 | MDB_RTR_TYPE_TEMP | |
209 | }; | |
210 | ||
211 | enum { | |
212 | MDBA_ROUTER_UNSPEC, | |
213 | MDBA_ROUTER_PORT, | |
214 | __MDBA_ROUTER_MAX, | |
215 | }; | |
216 | #define MDBA_ROUTER_MAX (__MDBA_ROUTER_MAX - 1) | |
217 | ||
218 | /* router port attributes */ | |
219 | enum { | |
220 | MDBA_ROUTER_PATTR_UNSPEC, | |
221 | MDBA_ROUTER_PATTR_TIMER, | |
222 | MDBA_ROUTER_PATTR_TYPE, | |
223 | __MDBA_ROUTER_PATTR_MAX | |
224 | }; | |
225 | #define MDBA_ROUTER_PATTR_MAX (__MDBA_ROUTER_PATTR_MAX - 1) | |
226 | ||
227 | struct br_port_msg { | |
228 | __u8 family; | |
229 | __u32 ifindex; | |
230 | }; | |
231 | ||
232 | enum { | |
233 | MDBA_SET_ENTRY_UNSPEC, | |
234 | MDBA_SET_ENTRY, | |
235 | __MDBA_SET_ENTRY_MAX, | |
236 | }; | |
237 | #define MDBA_SET_ENTRY_MAX (__MDBA_SET_ENTRY_MAX - 1) | |
238 | ||
239 | /* Embedded inside LINK_XSTATS_TYPE_BRIDGE */ | |
240 | enum { | |
241 | BRIDGE_XSTATS_UNSPEC, | |
242 | BRIDGE_XSTATS_VLAN, | |
243 | BRIDGE_XSTATS_MCAST, | |
244 | BRIDGE_XSTATS_PAD, | |
245 | __BRIDGE_XSTATS_MAX | |
246 | }; | |
247 | #define BRIDGE_XSTATS_MAX (__BRIDGE_XSTATS_MAX - 1) | |
248 | ||
249 | enum { | |
250 | BR_MCAST_DIR_RX, | |
251 | BR_MCAST_DIR_TX, | |
252 | BR_MCAST_DIR_SIZE | |
253 | }; | |
254 | ||
255 | /* IGMP/MLD statistics */ | |
256 | struct br_mcast_stats { | |
257 | __u64 igmp_v1queries[BR_MCAST_DIR_SIZE]; | |
258 | __u64 igmp_v2queries[BR_MCAST_DIR_SIZE]; | |
259 | __u64 igmp_v3queries[BR_MCAST_DIR_SIZE]; | |
260 | __u64 igmp_leaves[BR_MCAST_DIR_SIZE]; | |
261 | __u64 igmp_v1reports[BR_MCAST_DIR_SIZE]; | |
262 | __u64 igmp_v2reports[BR_MCAST_DIR_SIZE]; | |
263 | __u64 igmp_v3reports[BR_MCAST_DIR_SIZE]; | |
264 | __u64 igmp_parse_errors; | |
265 | ||
266 | __u64 mld_v1queries[BR_MCAST_DIR_SIZE]; | |
267 | __u64 mld_v2queries[BR_MCAST_DIR_SIZE]; | |
268 | __u64 mld_leaves[BR_MCAST_DIR_SIZE]; | |
269 | __u64 mld_v1reports[BR_MCAST_DIR_SIZE]; | |
270 | __u64 mld_v2reports[BR_MCAST_DIR_SIZE]; | |
271 | __u64 mld_parse_errors; | |
272 | ||
273 | __u64 mcast_bytes[BR_MCAST_DIR_SIZE]; | |
274 | __u64 mcast_packets[BR_MCAST_DIR_SIZE]; | |
275 | }; | |
276 | #endif /* _LINUX_IF_BRIDGE_H */ |
0 | /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ | |
0 | 1 | /* |
1 | 2 | * INET An implementation of the TCP/IP protocol suite for the LINUX |
2 | 3 | * operating system. INET is implemented using the BSD Socket |
28 | 29 | */ |
29 | 30 | |
30 | 31 | #define ETH_ALEN 6 /* Octets in one ethernet addr */ |
32 | #define ETH_TLEN 2 /* Octets in ethernet type field */ | |
31 | 33 | #define ETH_HLEN 14 /* Total octets in header. */ |
32 | 34 | #define ETH_ZLEN 60 /* Min. octets in frame sans FCS */ |
33 | 35 | #define ETH_DATA_LEN 1500 /* Max. octets in payload */ |
34 | 36 | #define ETH_FRAME_LEN 1514 /* Max. octets in frame sans FCS */ |
35 | 37 | #define ETH_FCS_LEN 4 /* Octets in the FCS */ |
38 | ||
39 | #define ETH_MIN_MTU 68 /* Min IPv4 MTU per RFC791 */ | |
40 | #define ETH_MAX_MTU 0xFFFFU /* 65535, same as IP_MAX_MTU */ | |
36 | 41 | |
37 | 42 | /* |
38 | 43 | * These are the defined Ethernet Protocol ID's. |
41 | 46 | #define ETH_P_LOOP 0x0060 /* Ethernet Loopback packet */ |
42 | 47 | #define ETH_P_PUP 0x0200 /* Xerox PUP packet */ |
43 | 48 | #define ETH_P_PUPAT 0x0201 /* Xerox PUP Addr Trans packet */ |
49 | #define ETH_P_TSN 0x22F0 /* TSN (IEEE 1722) packet */ | |
50 | #define ETH_P_ERSPAN2 0x22EB /* ERSPAN version 2 (type III) */ | |
44 | 51 | #define ETH_P_IP 0x0800 /* Internet Protocol packet */ |
45 | 52 | #define ETH_P_X25 0x0805 /* CCITT X.25 */ |
46 | 53 | #define ETH_P_ARP 0x0806 /* Address Resolution packet */ |
47 | 54 | #define ETH_P_BPQ 0x08FF /* G8BPQ AX.25 Ethernet Packet [ NOT AN OFFICIALLY REGISTERED ID ] */ |
48 | 55 | #define ETH_P_IEEEPUP 0x0a00 /* Xerox IEEE802.3 PUP packet */ |
49 | 56 | #define ETH_P_IEEEPUPAT 0x0a01 /* Xerox IEEE802.3 PUP Addr Trans packet */ |
57 | #define ETH_P_BATMAN 0x4305 /* B.A.T.M.A.N.-Advanced packet [ NOT AN OFFICIALLY REGISTERED ID ] */ | |
50 | 58 | #define ETH_P_DEC 0x6000 /* DEC Assigned proto */ |
51 | 59 | #define ETH_P_DNA_DL 0x6001 /* DEC DNA Dump/Load */ |
52 | 60 | #define ETH_P_DNA_RC 0x6002 /* DEC DNA Remote Console */ |
60 | 68 | #define ETH_P_ATALK 0x809B /* Appletalk DDP */ |
61 | 69 | #define ETH_P_AARP 0x80F3 /* Appletalk AARP */ |
62 | 70 | #define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */ |
71 | #define ETH_P_ERSPAN 0x88BE /* ERSPAN type II */ | |
63 | 72 | #define ETH_P_IPX 0x8137 /* IPX over DIX */ |
64 | 73 | #define ETH_P_IPV6 0x86DD /* IPv6 over bluebook */ |
65 | 74 | #define ETH_P_PAUSE 0x8808 /* IEEE Pause frames. See 802.3 31B */ |
66 | 75 | #define ETH_P_SLOW 0x8809 /* Slow Protocol. See 802.3ad 43B */ |
67 | 76 | #define ETH_P_WCCP 0x883E /* Web-cache coordination protocol |
68 | 77 | * defined in draft-wilson-wrec-wccp-v2-00.txt */ |
69 | #define ETH_P_PPP_DISC 0x8863 /* PPPoE discovery messages */ | |
70 | #define ETH_P_PPP_SES 0x8864 /* PPPoE session messages */ | |
71 | 78 | #define ETH_P_MPLS_UC 0x8847 /* MPLS Unicast traffic */ |
72 | 79 | #define ETH_P_MPLS_MC 0x8848 /* MPLS Multicast traffic */ |
73 | 80 | #define ETH_P_ATMMPOA 0x884c /* MultiProtocol Over ATM */ |
81 | #define ETH_P_PPP_DISC 0x8863 /* PPPoE discovery messages */ | |
82 | #define ETH_P_PPP_SES 0x8864 /* PPPoE session messages */ | |
74 | 83 | #define ETH_P_LINK_CTL 0x886c /* HPNA, wlan link local tunnel */ |
75 | 84 | #define ETH_P_ATMFATE 0x8884 /* Frame-based ATM Transport |
76 | 85 | * over Ethernet |
79 | 88 | #define ETH_P_AOE 0x88A2 /* ATA over Ethernet */ |
80 | 89 | #define ETH_P_8021AD 0x88A8 /* 802.1ad Service VLAN */ |
81 | 90 | #define ETH_P_802_EX1 0x88B5 /* 802.1 Local Experimental 1. */ |
91 | #define ETH_P_PREAUTH 0x88C7 /* 802.11 Preauthentication */ | |
82 | 92 | #define ETH_P_TIPC 0x88CA /* TIPC */ |
93 | #define ETH_P_MACSEC 0x88E5 /* 802.1ae MACsec */ | |
83 | 94 | #define ETH_P_8021AH 0x88E7 /* 802.1ah Backbone Service Tag */ |
95 | #define ETH_P_MVRP 0x88F5 /* 802.1Q MVRP */ | |
84 | 96 | #define ETH_P_1588 0x88F7 /* IEEE 1588 Timesync */ |
97 | #define ETH_P_NCSI 0x88F8 /* NCSI protocol */ | |
98 | #define ETH_P_PRP 0x88FB /* IEC 62439-3 PRP/HSRv0 */ | |
85 | 99 | #define ETH_P_FCOE 0x8906 /* Fibre Channel over Ethernet */ |
100 | #define ETH_P_IBOE 0x8915 /* Infiniband over Ethernet */ | |
86 | 101 | #define ETH_P_TDLS 0x890D /* TDLS */ |
87 | 102 | #define ETH_P_FIP 0x8914 /* FCoE Initialization Protocol */ |
103 | #define ETH_P_80221 0x8917 /* IEEE 802.21 Media Independent Handover Protocol */ | |
104 | #define ETH_P_HSR 0x892F /* IEC 62439-3 HSRv1 */ | |
105 | #define ETH_P_NSH 0x894F /* Network Service Header */ | |
106 | #define ETH_P_LOOPBACK 0x9000 /* Ethernet loopback packet, per IEEE 802.3 */ | |
88 | 107 | #define ETH_P_QINQ1 0x9100 /* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] */ |
89 | 108 | #define ETH_P_QINQ2 0x9200 /* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] */ |
90 | 109 | #define ETH_P_QINQ3 0x9300 /* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] */ |
91 | 110 | #define ETH_P_EDSA 0xDADA /* Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ] */ |
111 | #define ETH_P_IFE 0xED3E /* ForCES inter-FE LFB type */ | |
92 | 112 | #define ETH_P_AF_IUCV 0xFBFB /* IBM af_iucv [ NOT AN OFFICIALLY REGISTERED ID ] */ |
113 | ||
114 | #define ETH_P_802_3_MIN 0x0600 /* If the value in the ethernet type is less than this value | |
115 | * then the frame is Ethernet II. Else it is 802.3 */ | |
93 | 116 | |
94 | 117 | /* |
95 | 118 | * Non DIX types. Won't clash for 1500 types. |
119 | 142 | #define ETH_P_PHONET 0x00F5 /* Nokia Phonet frames */ |
120 | 143 | #define ETH_P_IEEE802154 0x00F6 /* IEEE802.15.4 frame */ |
121 | 144 | #define ETH_P_CAIF 0x00F7 /* ST-Ericsson CAIF protocol */ |
145 | #define ETH_P_XDSA 0x00F8 /* Multiplexed DSA protocol */ | |
146 | #define ETH_P_MAP 0x00F9 /* Qualcomm multiplexing and | |
147 | * aggregation protocol | |
148 | */ | |
122 | 149 | |
123 | 150 | /* |
124 | 151 | * This is an Ethernet frame header. |
125 | 152 | */ |
126 | 153 | |
154 | /* allow libcs like musl to deactivate this, glibc does not implement this. */ | |
155 | #ifndef __UAPI_DEF_ETHHDR | |
156 | #define __UAPI_DEF_ETHHDR 1 | |
157 | #endif | |
158 | ||
159 | #if __UAPI_DEF_ETHHDR | |
127 | 160 | struct ethhdr { |
128 | 161 | unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ |
129 | 162 | unsigned char h_source[ETH_ALEN]; /* source ether addr */ |
130 | 163 | __be16 h_proto; /* packet type ID field */ |
131 | 164 | } __attribute__((packed)); |
165 | #endif | |
132 | 166 | |
133 | 167 | |
134 | #endif /* _LINUX_IF_ETHER_H */ | |
168 | #endif /* _LINUX_IF_ETHER_H */ |
0 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | |
0 | 1 | #ifndef _LINUX_IF_LINK_H |
1 | 2 | #define _LINUX_IF_LINK_H |
2 | 3 | |
34 | 35 | /* for cslip etc */ |
35 | 36 | __u32 rx_compressed; |
36 | 37 | __u32 tx_compressed; |
38 | ||
39 | __u32 rx_nohandler; /* dropped, no handler found */ | |
37 | 40 | }; |
38 | 41 | |
39 | 42 | /* The main device statistics structure */ |
67 | 70 | /* for cslip etc */ |
68 | 71 | __u64 rx_compressed; |
69 | 72 | __u64 tx_compressed; |
73 | ||
74 | __u64 rx_nohandler; /* dropped, no handler found */ | |
70 | 75 | }; |
71 | 76 | |
72 | 77 | /* The struct should be in sync with struct ifmap */ |
148 | 153 | IFLA_LINK_NETNSID, |
149 | 154 | IFLA_PHYS_PORT_NAME, |
150 | 155 | IFLA_PROTO_DOWN, |
156 | IFLA_GSO_MAX_SEGS, | |
157 | IFLA_GSO_MAX_SIZE, | |
158 | IFLA_PAD, | |
159 | IFLA_XDP, | |
160 | IFLA_EVENT, | |
161 | IFLA_NEW_NETNSID, | |
162 | IFLA_IF_NETNSID, | |
163 | IFLA_CARRIER_UP_COUNT, | |
164 | IFLA_CARRIER_DOWN_COUNT, | |
165 | IFLA_NEW_IFINDEX, | |
166 | IFLA_MIN_MTU, | |
167 | IFLA_MAX_MTU, | |
151 | 168 | __IFLA_MAX |
152 | 169 | }; |
153 | 170 | |
155 | 172 | #define IFLA_MAX (__IFLA_MAX - 1) |
156 | 173 | |
157 | 174 | /* backwards compatibility for userspace */ |
158 | #define IFLA_RTA(r) ((struct rtattr*)(void*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg)))) | |
175 | #define IFLA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg)))) | |
159 | 176 | #define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg)) |
160 | 177 | |
161 | 178 | enum { |
215 | 232 | IN6_ADDR_GEN_MODE_EUI64, |
216 | 233 | IN6_ADDR_GEN_MODE_NONE, |
217 | 234 | IN6_ADDR_GEN_MODE_STABLE_PRIVACY, |
235 | IN6_ADDR_GEN_MODE_RANDOM, | |
218 | 236 | }; |
219 | 237 | |
220 | 238 | /* Bridge section */ |
260 | 278 | IFLA_BR_NF_CALL_IP6TABLES, |
261 | 279 | IFLA_BR_NF_CALL_ARPTABLES, |
262 | 280 | IFLA_BR_VLAN_DEFAULT_PVID, |
281 | IFLA_BR_PAD, | |
282 | IFLA_BR_VLAN_STATS_ENABLED, | |
283 | IFLA_BR_MCAST_STATS_ENABLED, | |
284 | IFLA_BR_MCAST_IGMP_VERSION, | |
285 | IFLA_BR_MCAST_MLD_VERSION, | |
263 | 286 | __IFLA_BR_MAX, |
264 | 287 | }; |
265 | 288 | |
302 | 325 | IFLA_BRPORT_HOLD_TIMER, |
303 | 326 | IFLA_BRPORT_FLUSH, |
304 | 327 | IFLA_BRPORT_MULTICAST_ROUTER, |
328 | IFLA_BRPORT_PAD, | |
329 | IFLA_BRPORT_MCAST_FLOOD, | |
330 | IFLA_BRPORT_MCAST_TO_UCAST, | |
331 | IFLA_BRPORT_VLAN_TUNNEL, | |
332 | IFLA_BRPORT_BCAST_FLOOD, | |
333 | IFLA_BRPORT_GROUP_FWD_MASK, | |
334 | IFLA_BRPORT_NEIGH_SUPPRESS, | |
335 | IFLA_BRPORT_ISOLATED, | |
336 | IFLA_BRPORT_BACKUP_PORT, | |
305 | 337 | __IFLA_BRPORT_MAX |
306 | 338 | }; |
307 | 339 | #define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1) |
397 | 429 | |
398 | 430 | #define IFLA_VRF_MAX (__IFLA_VRF_MAX - 1) |
399 | 431 | |
432 | enum { | |
433 | IFLA_VRF_PORT_UNSPEC, | |
434 | IFLA_VRF_PORT_TABLE, | |
435 | __IFLA_VRF_PORT_MAX | |
436 | }; | |
437 | ||
438 | #define IFLA_VRF_PORT_MAX (__IFLA_VRF_PORT_MAX - 1) | |
439 | ||
440 | /* MACSEC section */ | |
441 | enum { | |
442 | IFLA_MACSEC_UNSPEC, | |
443 | IFLA_MACSEC_SCI, | |
444 | IFLA_MACSEC_PORT, | |
445 | IFLA_MACSEC_ICV_LEN, | |
446 | IFLA_MACSEC_CIPHER_SUITE, | |
447 | IFLA_MACSEC_WINDOW, | |
448 | IFLA_MACSEC_ENCODING_SA, | |
449 | IFLA_MACSEC_ENCRYPT, | |
450 | IFLA_MACSEC_PROTECT, | |
451 | IFLA_MACSEC_INC_SCI, | |
452 | IFLA_MACSEC_ES, | |
453 | IFLA_MACSEC_SCB, | |
454 | IFLA_MACSEC_REPLAY_PROTECT, | |
455 | IFLA_MACSEC_VALIDATION, | |
456 | IFLA_MACSEC_PAD, | |
457 | __IFLA_MACSEC_MAX, | |
458 | }; | |
459 | ||
460 | #define IFLA_MACSEC_MAX (__IFLA_MACSEC_MAX - 1) | |
461 | ||
462 | /* XFRM section */ | |
463 | enum { | |
464 | IFLA_XFRM_UNSPEC, | |
465 | IFLA_XFRM_LINK, | |
466 | IFLA_XFRM_IF_ID, | |
467 | __IFLA_XFRM_MAX | |
468 | }; | |
469 | ||
470 | #define IFLA_XFRM_MAX (__IFLA_XFRM_MAX - 1) | |
471 | ||
472 | enum macsec_validation_type { | |
473 | MACSEC_VALIDATE_DISABLED = 0, | |
474 | MACSEC_VALIDATE_CHECK = 1, | |
475 | MACSEC_VALIDATE_STRICT = 2, | |
476 | __MACSEC_VALIDATE_END, | |
477 | MACSEC_VALIDATE_MAX = __MACSEC_VALIDATE_END - 1, | |
478 | }; | |
479 | ||
400 | 480 | /* IPVLAN section */ |
401 | 481 | enum { |
402 | 482 | IFLA_IPVLAN_UNSPEC, |
403 | 483 | IFLA_IPVLAN_MODE, |
484 | IFLA_IPVLAN_FLAGS, | |
404 | 485 | __IFLA_IPVLAN_MAX |
405 | 486 | }; |
406 | 487 | |
409 | 490 | enum ipvlan_mode { |
410 | 491 | IPVLAN_MODE_L2 = 0, |
411 | 492 | IPVLAN_MODE_L3, |
493 | IPVLAN_MODE_L3S, | |
412 | 494 | IPVLAN_MODE_MAX |
413 | 495 | }; |
496 | ||
497 | #define IPVLAN_F_PRIVATE 0x01 | |
498 | #define IPVLAN_F_VEPA 0x02 | |
414 | 499 | |
415 | 500 | /* VXLAN section */ |
416 | 501 | enum { |
440 | 525 | IFLA_VXLAN_GBP, |
441 | 526 | IFLA_VXLAN_REMCSUM_NOPARTIAL, |
442 | 527 | IFLA_VXLAN_COLLECT_METADATA, |
528 | IFLA_VXLAN_LABEL, | |
529 | IFLA_VXLAN_GPE, | |
530 | IFLA_VXLAN_TTL_INHERIT, | |
443 | 531 | __IFLA_VXLAN_MAX |
444 | 532 | }; |
445 | 533 | #define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1) |
459 | 547 | IFLA_GENEVE_PORT, /* destination port */ |
460 | 548 | IFLA_GENEVE_COLLECT_METADATA, |
461 | 549 | IFLA_GENEVE_REMOTE6, |
550 | IFLA_GENEVE_UDP_CSUM, | |
551 | IFLA_GENEVE_UDP_ZERO_CSUM6_TX, | |
552 | IFLA_GENEVE_UDP_ZERO_CSUM6_RX, | |
553 | IFLA_GENEVE_LABEL, | |
462 | 554 | __IFLA_GENEVE_MAX |
463 | 555 | }; |
464 | 556 | #define IFLA_GENEVE_MAX (__IFLA_GENEVE_MAX - 1) |
557 | ||
558 | /* PPP section */ | |
559 | enum { | |
560 | IFLA_PPP_UNSPEC, | |
561 | IFLA_PPP_DEV_FD, | |
562 | __IFLA_PPP_MAX | |
563 | }; | |
564 | #define IFLA_PPP_MAX (__IFLA_PPP_MAX - 1) | |
565 | ||
566 | /* GTP section */ | |
567 | ||
568 | enum ifla_gtp_role { | |
569 | GTP_ROLE_GGSN = 0, | |
570 | GTP_ROLE_SGSN, | |
571 | }; | |
572 | ||
573 | enum { | |
574 | IFLA_GTP_UNSPEC, | |
575 | IFLA_GTP_FD0, | |
576 | IFLA_GTP_FD1, | |
577 | IFLA_GTP_PDP_HASHSIZE, | |
578 | IFLA_GTP_ROLE, | |
579 | __IFLA_GTP_MAX, | |
580 | }; | |
581 | #define IFLA_GTP_MAX (__IFLA_GTP_MAX - 1) | |
465 | 582 | |
466 | 583 | /* Bonding section */ |
467 | 584 | |
539 | 656 | enum { |
540 | 657 | IFLA_VF_UNSPEC, |
541 | 658 | IFLA_VF_MAC, /* Hardware queue specific attributes */ |
542 | IFLA_VF_VLAN, | |
659 | IFLA_VF_VLAN, /* VLAN ID and QoS */ | |
543 | 660 | IFLA_VF_TX_RATE, /* Max TX Bandwidth Allocation */ |
544 | 661 | IFLA_VF_SPOOFCHK, /* Spoof Checking on/off switch */ |
545 | 662 | IFLA_VF_LINK_STATE, /* link state enable/disable/auto switch */ |
549 | 666 | */ |
550 | 667 | IFLA_VF_STATS, /* network device statistics */ |
551 | 668 | IFLA_VF_TRUST, /* Trust VF */ |
669 | IFLA_VF_IB_NODE_GUID, /* VF Infiniband node GUID */ | |
670 | IFLA_VF_IB_PORT_GUID, /* VF Infiniband port GUID */ | |
671 | IFLA_VF_VLAN_LIST, /* nested list of vlans, option for QinQ */ | |
552 | 672 | __IFLA_VF_MAX, |
553 | 673 | }; |
554 | 674 | |
565 | 685 | __u32 qos; |
566 | 686 | }; |
567 | 687 | |
688 | enum { | |
689 | IFLA_VF_VLAN_INFO_UNSPEC, | |
690 | IFLA_VF_VLAN_INFO, /* VLAN ID, QoS and VLAN protocol */ | |
691 | __IFLA_VF_VLAN_INFO_MAX, | |
692 | }; | |
693 | ||
694 | #define IFLA_VF_VLAN_INFO_MAX (__IFLA_VF_VLAN_INFO_MAX - 1) | |
695 | #define MAX_VLAN_LIST_LEN 1 | |
696 | ||
697 | struct ifla_vf_vlan_info { | |
698 | __u32 vf; | |
699 | __u32 vlan; /* 0 - 4095, 0 disables VLAN filter */ | |
700 | __u32 qos; | |
701 | __be16 vlan_proto; /* VLAN protocol either 802.1Q or 802.1ad */ | |
702 | }; | |
703 | ||
568 | 704 | struct ifla_vf_tx_rate { |
569 | 705 | __u32 vf; |
570 | 706 | __u32 rate; /* Max TX bandwidth in Mbps, 0 disables throttling */ |
579 | 715 | struct ifla_vf_spoofchk { |
580 | 716 | __u32 vf; |
581 | 717 | __u32 setting; |
718 | }; | |
719 | ||
720 | struct ifla_vf_guid { | |
721 | __u32 vf; | |
722 | __u64 guid; | |
582 | 723 | }; |
583 | 724 | |
584 | 725 | enum { |
605 | 746 | IFLA_VF_STATS_TX_BYTES, |
606 | 747 | IFLA_VF_STATS_BROADCAST, |
607 | 748 | IFLA_VF_STATS_MULTICAST, |
749 | IFLA_VF_STATS_PAD, | |
750 | IFLA_VF_STATS_RX_DROPPED, | |
751 | IFLA_VF_STATS_TX_DROPPED, | |
608 | 752 | __IFLA_VF_STATS_MAX, |
609 | 753 | }; |
610 | 754 | |
715 | 859 | IFLA_HSR_MULTICAST_SPEC, /* Last byte of supervision addr */ |
716 | 860 | IFLA_HSR_SUPERVISION_ADDR, /* Supervision frame multicast addr */ |
717 | 861 | IFLA_HSR_SEQ_NR, |
862 | IFLA_HSR_VERSION, /* HSR version */ | |
718 | 863 | __IFLA_HSR_MAX, |
719 | 864 | }; |
720 | 865 | |
721 | 866 | #define IFLA_HSR_MAX (__IFLA_HSR_MAX - 1) |
722 | 867 | |
868 | /* STATS section */ | |
869 | ||
870 | struct if_stats_msg { | |
871 | __u8 family; | |
872 | __u8 pad1; | |
873 | __u16 pad2; | |
874 | __u32 ifindex; | |
875 | __u32 filter_mask; | |
876 | }; | |
877 | ||
878 | /* A stats attribute can be netdev specific or a global stat. | |
879 | * For netdev stats, lets use the prefix IFLA_STATS_LINK_* | |
880 | */ | |
881 | enum { | |
882 | IFLA_STATS_UNSPEC, /* also used as 64bit pad attribute */ | |
883 | IFLA_STATS_LINK_64, | |
884 | IFLA_STATS_LINK_XSTATS, | |
885 | IFLA_STATS_LINK_XSTATS_SLAVE, | |
886 | IFLA_STATS_LINK_OFFLOAD_XSTATS, | |
887 | IFLA_STATS_AF_SPEC, | |
888 | __IFLA_STATS_MAX, | |
889 | }; | |
890 | ||
891 | #define IFLA_STATS_MAX (__IFLA_STATS_MAX - 1) | |
892 | ||
893 | #define IFLA_STATS_FILTER_BIT(ATTR) (1 << (ATTR - 1)) | |
894 | ||
895 | /* These are embedded into IFLA_STATS_LINK_XSTATS: | |
896 | * [IFLA_STATS_LINK_XSTATS] | |
897 | * -> [LINK_XSTATS_TYPE_xxx] | |
898 | * -> [rtnl link type specific attributes] | |
899 | */ | |
900 | enum { | |
901 | LINK_XSTATS_TYPE_UNSPEC, | |
902 | LINK_XSTATS_TYPE_BRIDGE, | |
903 | __LINK_XSTATS_TYPE_MAX | |
904 | }; | |
905 | #define LINK_XSTATS_TYPE_MAX (__LINK_XSTATS_TYPE_MAX - 1) | |
906 | ||
907 | /* These are stats embedded into IFLA_STATS_LINK_OFFLOAD_XSTATS */ | |
908 | enum { | |
909 | IFLA_OFFLOAD_XSTATS_UNSPEC, | |
910 | IFLA_OFFLOAD_XSTATS_CPU_HIT, /* struct rtnl_link_stats64 */ | |
911 | __IFLA_OFFLOAD_XSTATS_MAX | |
912 | }; | |
913 | #define IFLA_OFFLOAD_XSTATS_MAX (__IFLA_OFFLOAD_XSTATS_MAX - 1) | |
914 | ||
915 | /* XDP section */ | |
916 | ||
917 | #define XDP_FLAGS_UPDATE_IF_NOEXIST (1U << 0) | |
918 | #define XDP_FLAGS_SKB_MODE (1U << 1) | |
919 | #define XDP_FLAGS_DRV_MODE (1U << 2) | |
920 | #define XDP_FLAGS_HW_MODE (1U << 3) | |
921 | #define XDP_FLAGS_MODES (XDP_FLAGS_SKB_MODE | \ | |
922 | XDP_FLAGS_DRV_MODE | \ | |
923 | XDP_FLAGS_HW_MODE) | |
924 | #define XDP_FLAGS_MASK (XDP_FLAGS_UPDATE_IF_NOEXIST | \ | |
925 | XDP_FLAGS_MODES) | |
926 | ||
927 | /* These are stored into IFLA_XDP_ATTACHED on dump. */ | |
928 | enum { | |
929 | XDP_ATTACHED_NONE = 0, | |
930 | XDP_ATTACHED_DRV, | |
931 | XDP_ATTACHED_SKB, | |
932 | XDP_ATTACHED_HW, | |
933 | XDP_ATTACHED_MULTI, | |
934 | }; | |
935 | ||
936 | enum { | |
937 | IFLA_XDP_UNSPEC, | |
938 | IFLA_XDP_FD, | |
939 | IFLA_XDP_ATTACHED, | |
940 | IFLA_XDP_FLAGS, | |
941 | IFLA_XDP_PROG_ID, | |
942 | IFLA_XDP_DRV_PROG_ID, | |
943 | IFLA_XDP_SKB_PROG_ID, | |
944 | IFLA_XDP_HW_PROG_ID, | |
945 | __IFLA_XDP_MAX, | |
946 | }; | |
947 | ||
948 | #define IFLA_XDP_MAX (__IFLA_XDP_MAX - 1) | |
949 | ||
950 | enum { | |
951 | IFLA_EVENT_NONE, | |
952 | IFLA_EVENT_REBOOT, /* internal reset / reboot */ | |
953 | IFLA_EVENT_FEATURES, /* change in offload features */ | |
954 | IFLA_EVENT_BONDING_FAILOVER, /* change in active slave */ | |
955 | IFLA_EVENT_NOTIFY_PEERS, /* re-sent grat. arp/ndisc */ | |
956 | IFLA_EVENT_IGMP_RESEND, /* re-sent IGMP JOIN */ | |
957 | IFLA_EVENT_BONDING_OPTIONS, /* change in bonding options */ | |
958 | }; | |
959 | ||
960 | /* tun section */ | |
961 | ||
962 | enum { | |
963 | IFLA_TUN_UNSPEC, | |
964 | IFLA_TUN_OWNER, | |
965 | IFLA_TUN_GROUP, | |
966 | IFLA_TUN_TYPE, | |
967 | IFLA_TUN_PI, | |
968 | IFLA_TUN_VNET_HDR, | |
969 | IFLA_TUN_PERSIST, | |
970 | IFLA_TUN_MULTI_QUEUE, | |
971 | IFLA_TUN_NUM_QUEUES, | |
972 | IFLA_TUN_NUM_DISABLED_QUEUES, | |
973 | __IFLA_TUN_MAX, | |
974 | }; | |
975 | ||
976 | #define IFLA_TUN_MAX (__IFLA_TUN_MAX - 1) | |
977 | ||
978 | /* rmnet section */ | |
979 | ||
980 | #define RMNET_FLAGS_INGRESS_DEAGGREGATION (1U << 0) | |
981 | #define RMNET_FLAGS_INGRESS_MAP_COMMANDS (1U << 1) | |
982 | #define RMNET_FLAGS_INGRESS_MAP_CKSUMV4 (1U << 2) | |
983 | #define RMNET_FLAGS_EGRESS_MAP_CKSUMV4 (1U << 3) | |
984 | ||
985 | enum { | |
986 | IFLA_RMNET_UNSPEC, | |
987 | IFLA_RMNET_MUX_ID, | |
988 | IFLA_RMNET_FLAGS, | |
989 | __IFLA_RMNET_MAX, | |
990 | }; | |
991 | ||
992 | #define IFLA_RMNET_MAX (__IFLA_RMNET_MAX - 1) | |
993 | ||
994 | struct ifla_rmnet_flags { | |
995 | __u32 flags; | |
996 | __u32 mask; | |
997 | }; | |
998 | ||
723 | 999 | #endif /* _LINUX_IF_LINK_H */ |
0 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | |
0 | 1 | #ifndef __LINUX_IF_PACKET_H |
1 | 2 | #define __LINUX_IF_PACKET_H |
2 | 3 | |
25 | 26 | #define PACKET_MULTICAST 2 /* To group */ |
26 | 27 | #define PACKET_OTHERHOST 3 /* To someone else */ |
27 | 28 | #define PACKET_OUTGOING 4 /* Outgoing of any type */ |
28 | /* These ones are invisible by user level */ | |
29 | 29 | #define PACKET_LOOPBACK 5 /* MC/BRD frame looped back */ |
30 | #define PACKET_USER 6 /* To user space */ | |
31 | #define PACKET_KERNEL 7 /* To kernel space */ | |
32 | /* Unused, PACKET_FASTROUTE and PACKET_LOOPBACK are invisible to user space */ | |
30 | 33 | #define PACKET_FASTROUTE 6 /* Fastrouted frame */ |
31 | 34 | |
32 | 35 | /* Packet socket options */ |
49 | 52 | #define PACKET_TX_TIMESTAMP 16 |
50 | 53 | #define PACKET_TIMESTAMP 17 |
51 | 54 | #define PACKET_FANOUT 18 |
55 | #define PACKET_TX_HAS_OFF 19 | |
56 | #define PACKET_QDISC_BYPASS 20 | |
57 | #define PACKET_ROLLOVER_STATS 21 | |
58 | #define PACKET_FANOUT_DATA 22 | |
52 | 59 | |
53 | 60 | #define PACKET_FANOUT_HASH 0 |
54 | 61 | #define PACKET_FANOUT_LB 1 |
55 | 62 | #define PACKET_FANOUT_CPU 2 |
63 | #define PACKET_FANOUT_ROLLOVER 3 | |
64 | #define PACKET_FANOUT_RND 4 | |
65 | #define PACKET_FANOUT_QM 5 | |
66 | #define PACKET_FANOUT_CBPF 6 | |
67 | #define PACKET_FANOUT_EBPF 7 | |
68 | #define PACKET_FANOUT_FLAG_ROLLOVER 0x1000 | |
69 | #define PACKET_FANOUT_FLAG_UNIQUEID 0x2000 | |
56 | 70 | #define PACKET_FANOUT_FLAG_DEFRAG 0x8000 |
57 | 71 | |
58 | 72 | struct tpacket_stats { |
64 | 78 | unsigned int tp_packets; |
65 | 79 | unsigned int tp_drops; |
66 | 80 | unsigned int tp_freeze_q_cnt; |
81 | }; | |
82 | ||
83 | struct tpacket_rollover_stats { | |
84 | __aligned_u64 tp_all; | |
85 | __aligned_u64 tp_huge; | |
86 | __aligned_u64 tp_failed; | |
67 | 87 | }; |
68 | 88 | |
69 | 89 | union tpacket_stats_u { |
78 | 98 | __u16 tp_mac; |
79 | 99 | __u16 tp_net; |
80 | 100 | __u16 tp_vlan_tci; |
81 | __u16 tp_padding; | |
101 | __u16 tp_vlan_tpid; | |
82 | 102 | }; |
83 | 103 | |
84 | 104 | /* Rx ring - header status */ |
85 | #define TP_STATUS_KERNEL 0x0 | |
86 | #define TP_STATUS_USER 0x1 | |
87 | #define TP_STATUS_COPY 0x2 | |
88 | #define TP_STATUS_LOSING 0x4 | |
89 | #define TP_STATUS_CSUMNOTREADY 0x8 | |
90 | #define TP_STATUS_VLAN_VALID 0x10 /* auxdata has valid tp_vlan_tci */ | |
91 | #define TP_STATUS_BLK_TMO 0x20 | |
105 | #define TP_STATUS_KERNEL 0 | |
106 | #define TP_STATUS_USER (1 << 0) | |
107 | #define TP_STATUS_COPY (1 << 1) | |
108 | #define TP_STATUS_LOSING (1 << 2) | |
109 | #define TP_STATUS_CSUMNOTREADY (1 << 3) | |
110 | #define TP_STATUS_VLAN_VALID (1 << 4) /* auxdata has valid tp_vlan_tci */ | |
111 | #define TP_STATUS_BLK_TMO (1 << 5) | |
112 | #define TP_STATUS_VLAN_TPID_VALID (1 << 6) /* auxdata has valid tp_vlan_tpid */ | |
113 | #define TP_STATUS_CSUM_VALID (1 << 7) | |
92 | 114 | |
93 | 115 | /* Tx ring - header status */ |
94 | #define TP_STATUS_AVAILABLE 0x0 | |
95 | #define TP_STATUS_SEND_REQUEST 0x1 | |
96 | #define TP_STATUS_SENDING 0x2 | |
97 | #define TP_STATUS_WRONG_FORMAT 0x4 | |
116 | #define TP_STATUS_AVAILABLE 0 | |
117 | #define TP_STATUS_SEND_REQUEST (1 << 0) | |
118 | #define TP_STATUS_SENDING (1 << 1) | |
119 | #define TP_STATUS_WRONG_FORMAT (1 << 2) | |
120 | ||
121 | /* Rx and Tx ring - header status */ | |
122 | #define TP_STATUS_TS_SOFTWARE (1 << 29) | |
123 | #define TP_STATUS_TS_SYS_HARDWARE (1 << 30) /* deprecated, never set */ | |
124 | #define TP_STATUS_TS_RAW_HARDWARE (1 << 31) | |
98 | 125 | |
99 | 126 | /* Rx ring - feature request bits */ |
100 | 127 | #define TP_FT_REQ_FILL_RXHASH 0x1 |
122 | 149 | __u32 tp_sec; |
123 | 150 | __u32 tp_nsec; |
124 | 151 | __u16 tp_vlan_tci; |
125 | __u16 tp_padding; | |
152 | __u16 tp_vlan_tpid; | |
153 | __u8 tp_padding[4]; | |
126 | 154 | }; |
127 | 155 | |
128 | 156 | struct tpacket_hdr_variant1 { |
129 | 157 | __u32 tp_rxhash; |
130 | 158 | __u32 tp_vlan_tci; |
159 | __u16 tp_vlan_tpid; | |
160 | __u16 tp_padding; | |
131 | 161 | }; |
132 | 162 | |
133 | 163 | struct tpacket3_hdr { |
143 | 173 | union { |
144 | 174 | struct tpacket_hdr_variant1 hv1; |
145 | 175 | }; |
176 | __u8 tp_padding[8]; | |
146 | 177 | }; |
147 | 178 | |
148 | 179 | struct tpacket_bd_ts { |
0 | /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ | |
0 | 1 | /* |
1 | 2 | * VLAN An implementation of 802.1Q VLAN tagging. |
2 | 3 | * |
33 | 34 | VLAN_FLAG_REORDER_HDR = 0x1, |
34 | 35 | VLAN_FLAG_GVRP = 0x2, |
35 | 36 | VLAN_FLAG_LOOSE_BINDING = 0x4, |
37 | VLAN_FLAG_MVRP = 0x8, | |
36 | 38 | }; |
37 | 39 | |
38 | 40 | enum vlan_name_types { |
59 | 61 | short vlan_qos; |
60 | 62 | }; |
61 | 63 | |
62 | #endif /* !(_LINUX_IF_VLAN_H_) */ | |
64 | #endif /* _LINUX_IF_VLAN_H_ */ |
0 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | |
1 | #ifndef _LINUX_KERNEL_H | |
2 | #define _LINUX_KERNEL_H | |
3 | ||
4 | #include <linux/types.h> | |
5 | ||
6 | /* | |
7 | * 'kernel.h' contains some often-used function prototypes etc | |
8 | */ | |
9 | #define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1) | |
10 | #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask)) | |
11 | ||
12 | #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) | |
13 | ||
14 | #endif /* _LINUX_KERNEL_H */ |
0 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | |
1 | /* | |
2 | * Compatibility interface for userspace libc header coordination: | |
3 | * | |
4 | * Define compatibility macros that are used to control the inclusion or | |
5 | * exclusion of UAPI structures and definitions in coordination with another | |
6 | * userspace C library. | |
7 | * | |
8 | * This header is intended to solve the problem of UAPI definitions that | |
9 | * conflict with userspace definitions. If a UAPI header has such conflicting | |
10 | * definitions then the solution is as follows: | |
11 | * | |
12 | * * Synchronize the UAPI header and the libc headers so either one can be | |
13 | * used and such that the ABI is preserved. If this is not possible then | |
14 | * no simple compatibility interface exists (you need to write translating | |
15 | * wrappers and rename things) and you can't use this interface. | |
16 | * | |
17 | * Then follow this process: | |
18 | * | |
19 | * (a) Include libc-compat.h in the UAPI header. | |
20 | * e.g. #include <linux/libc-compat.h> | |
21 | * This include must be as early as possible. | |
22 | * | |
23 | * (b) In libc-compat.h add enough code to detect that the comflicting | |
24 | * userspace libc header has been included first. | |
25 | * | |
26 | * (c) If the userspace libc header has been included first define a set of | |
27 | * guard macros of the form __UAPI_DEF_FOO and set their values to 1, else | |
28 | * set their values to 0. | |
29 | * | |
30 | * (d) Back in the UAPI header with the conflicting definitions, guard the | |
31 | * definitions with: | |
32 | * #if __UAPI_DEF_FOO | |
33 | * ... | |
34 | * #endif | |
35 | * | |
36 | * This fixes the situation where the linux headers are included *after* the | |
37 | * libc headers. To fix the problem with the inclusion in the other order the | |
38 | * userspace libc headers must be fixed like this: | |
39 | * | |
40 | * * For all definitions that conflict with kernel definitions wrap those | |
41 | * defines in the following: | |
42 | * #if !__UAPI_DEF_FOO | |
43 | * ... | |
44 | * #endif | |
45 | * | |
46 | * This prevents the redefinition of a construct already defined by the kernel. | |
47 | */ | |
48 | #ifndef _LIBC_COMPAT_H | |
49 | #define _LIBC_COMPAT_H | |
50 | ||
51 | /* We have included glibc headers... */ | |
52 | #if defined(__GLIBC__) | |
53 | ||
54 | /* Coordinate with glibc net/if.h header. */ | |
55 | #if defined(_NET_IF_H) && defined(__USE_MISC) | |
56 | ||
57 | /* GLIBC headers included first so don't define anything | |
58 | * that would already be defined. */ | |
59 | ||
60 | #define __UAPI_DEF_IF_IFCONF 0 | |
61 | #define __UAPI_DEF_IF_IFMAP 0 | |
62 | #define __UAPI_DEF_IF_IFNAMSIZ 0 | |
63 | #define __UAPI_DEF_IF_IFREQ 0 | |
64 | /* Everything up to IFF_DYNAMIC, matches net/if.h until glibc 2.23 */ | |
65 | #define __UAPI_DEF_IF_NET_DEVICE_FLAGS 0 | |
66 | /* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */ | |
67 | #ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO | |
68 | #define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1 | |
69 | #endif /* __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO */ | |
70 | ||
71 | #else /* _NET_IF_H */ | |
72 | ||
73 | /* Linux headers included first, and we must define everything | |
74 | * we need. The expectation is that glibc will check the | |
75 | * __UAPI_DEF_* defines and adjust appropriately. */ | |
76 | ||
77 | #define __UAPI_DEF_IF_IFCONF 1 | |
78 | #define __UAPI_DEF_IF_IFMAP 1 | |
79 | #define __UAPI_DEF_IF_IFNAMSIZ 1 | |
80 | #define __UAPI_DEF_IF_IFREQ 1 | |
81 | /* Everything up to IFF_DYNAMIC, matches net/if.h until glibc 2.23 */ | |
82 | #define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1 | |
83 | /* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */ | |
84 | #define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1 | |
85 | ||
86 | #endif /* _NET_IF_H */ | |
87 | ||
88 | /* Coordinate with glibc netinet/in.h header. */ | |
89 | #if defined(_NETINET_IN_H) | |
90 | ||
91 | /* GLIBC headers included first so don't define anything | |
92 | * that would already be defined. */ | |
93 | #define __UAPI_DEF_IN_ADDR 0 | |
94 | #define __UAPI_DEF_IN_IPPROTO 0 | |
95 | #define __UAPI_DEF_IN_PKTINFO 0 | |
96 | #define __UAPI_DEF_IP_MREQ 0 | |
97 | #define __UAPI_DEF_SOCKADDR_IN 0 | |
98 | #define __UAPI_DEF_IN_CLASS 0 | |
99 | ||
100 | #define __UAPI_DEF_IN6_ADDR 0 | |
101 | /* The exception is the in6_addr macros which must be defined | |
102 | * if the glibc code didn't define them. This guard matches | |
103 | * the guard in glibc/inet/netinet/in.h which defines the | |
104 | * additional in6_addr macros e.g. s6_addr16, and s6_addr32. */ | |
105 | #if defined(__USE_MISC) || defined (__USE_GNU) | |
106 | #define __UAPI_DEF_IN6_ADDR_ALT 0 | |
107 | #else | |
108 | #define __UAPI_DEF_IN6_ADDR_ALT 1 | |
109 | #endif | |
110 | #define __UAPI_DEF_SOCKADDR_IN6 0 | |
111 | #define __UAPI_DEF_IPV6_MREQ 0 | |
112 | #define __UAPI_DEF_IPPROTO_V6 0 | |
113 | #define __UAPI_DEF_IPV6_OPTIONS 0 | |
114 | #define __UAPI_DEF_IN6_PKTINFO 0 | |
115 | #define __UAPI_DEF_IP6_MTUINFO 0 | |
116 | ||
117 | #else | |
118 | ||
119 | /* Linux headers included first, and we must define everything | |
120 | * we need. The expectation is that glibc will check the | |
121 | * __UAPI_DEF_* defines and adjust appropriately. */ | |
122 | #define __UAPI_DEF_IN_ADDR 1 | |
123 | #define __UAPI_DEF_IN_IPPROTO 1 | |
124 | #define __UAPI_DEF_IN_PKTINFO 1 | |
125 | #define __UAPI_DEF_IP_MREQ 1 | |
126 | #define __UAPI_DEF_SOCKADDR_IN 1 | |
127 | #define __UAPI_DEF_IN_CLASS 1 | |
128 | ||
129 | #define __UAPI_DEF_IN6_ADDR 1 | |
130 | /* We unconditionally define the in6_addr macros and glibc must | |
131 | * coordinate. */ | |
132 | #define __UAPI_DEF_IN6_ADDR_ALT 1 | |
133 | #define __UAPI_DEF_SOCKADDR_IN6 1 | |
134 | #define __UAPI_DEF_IPV6_MREQ 1 | |
135 | #define __UAPI_DEF_IPPROTO_V6 1 | |
136 | #define __UAPI_DEF_IPV6_OPTIONS 1 | |
137 | #define __UAPI_DEF_IN6_PKTINFO 1 | |
138 | #define __UAPI_DEF_IP6_MTUINFO 1 | |
139 | ||
140 | #endif /* _NETINET_IN_H */ | |
141 | ||
142 | /* Coordinate with glibc netipx/ipx.h header. */ | |
143 | #if defined(__NETIPX_IPX_H) | |
144 | ||
145 | #define __UAPI_DEF_SOCKADDR_IPX 0 | |
146 | #define __UAPI_DEF_IPX_ROUTE_DEFINITION 0 | |
147 | #define __UAPI_DEF_IPX_INTERFACE_DEFINITION 0 | |
148 | #define __UAPI_DEF_IPX_CONFIG_DATA 0 | |
149 | #define __UAPI_DEF_IPX_ROUTE_DEF 0 | |
150 | ||
151 | #else /* defined(__NETIPX_IPX_H) */ | |
152 | ||
153 | #define __UAPI_DEF_SOCKADDR_IPX 1 | |
154 | #define __UAPI_DEF_IPX_ROUTE_DEFINITION 1 | |
155 | #define __UAPI_DEF_IPX_INTERFACE_DEFINITION 1 | |
156 | #define __UAPI_DEF_IPX_CONFIG_DATA 1 | |
157 | #define __UAPI_DEF_IPX_ROUTE_DEF 1 | |
158 | ||
159 | #endif /* defined(__NETIPX_IPX_H) */ | |
160 | ||
161 | /* Definitions for xattr.h */ | |
162 | #if defined(_SYS_XATTR_H) | |
163 | #define __UAPI_DEF_XATTR 0 | |
164 | #else | |
165 | #define __UAPI_DEF_XATTR 1 | |
166 | #endif | |
167 | ||
168 | /* If we did not see any headers from any supported C libraries, | |
169 | * or we are being included in the kernel, then define everything | |
170 | * that we need. Check for previous __UAPI_* definitions to give | |
171 | * unsupported C libraries a way to opt out of any kernel definition. */ | |
172 | #else /* !defined(__GLIBC__) */ | |
173 | ||
174 | /* Definitions for if.h */ | |
175 | #ifndef __UAPI_DEF_IF_IFCONF | |
176 | #define __UAPI_DEF_IF_IFCONF 1 | |
177 | #endif | |
178 | #ifndef __UAPI_DEF_IF_IFMAP | |
179 | #define __UAPI_DEF_IF_IFMAP 1 | |
180 | #endif | |
181 | #ifndef __UAPI_DEF_IF_IFNAMSIZ | |
182 | #define __UAPI_DEF_IF_IFNAMSIZ 1 | |
183 | #endif | |
184 | #ifndef __UAPI_DEF_IF_IFREQ | |
185 | #define __UAPI_DEF_IF_IFREQ 1 | |
186 | #endif | |
187 | /* Everything up to IFF_DYNAMIC, matches net/if.h until glibc 2.23 */ | |
188 | #ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS | |
189 | #define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1 | |
190 | #endif | |
191 | /* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */ | |
192 | #ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO | |
193 | #define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1 | |
194 | #endif | |
195 | ||
196 | /* Definitions for in.h */ | |
197 | #ifndef __UAPI_DEF_IN_ADDR | |
198 | #define __UAPI_DEF_IN_ADDR 1 | |
199 | #endif | |
200 | #ifndef __UAPI_DEF_IN_IPPROTO | |
201 | #define __UAPI_DEF_IN_IPPROTO 1 | |
202 | #endif | |
203 | #ifndef __UAPI_DEF_IN_PKTINFO | |
204 | #define __UAPI_DEF_IN_PKTINFO 1 | |
205 | #endif | |
206 | #ifndef __UAPI_DEF_IP_MREQ | |
207 | #define __UAPI_DEF_IP_MREQ 1 | |
208 | #endif | |
209 | #ifndef __UAPI_DEF_SOCKADDR_IN | |
210 | #define __UAPI_DEF_SOCKADDR_IN 1 | |
211 | #endif | |
212 | #ifndef __UAPI_DEF_IN_CLASS | |
213 | #define __UAPI_DEF_IN_CLASS 1 | |
214 | #endif | |
215 | ||
216 | /* Definitions for in6.h */ | |
217 | #ifndef __UAPI_DEF_IN6_ADDR | |
218 | #define __UAPI_DEF_IN6_ADDR 1 | |
219 | #endif | |
220 | #ifndef __UAPI_DEF_IN6_ADDR_ALT | |
221 | #define __UAPI_DEF_IN6_ADDR_ALT 1 | |
222 | #endif | |
223 | #ifndef __UAPI_DEF_SOCKADDR_IN6 | |
224 | #define __UAPI_DEF_SOCKADDR_IN6 1 | |
225 | #endif | |
226 | #ifndef __UAPI_DEF_IPV6_MREQ | |
227 | #define __UAPI_DEF_IPV6_MREQ 1 | |
228 | #endif | |
229 | #ifndef __UAPI_DEF_IPPROTO_V6 | |
230 | #define __UAPI_DEF_IPPROTO_V6 1 | |
231 | #endif | |
232 | #ifndef __UAPI_DEF_IPV6_OPTIONS | |
233 | #define __UAPI_DEF_IPV6_OPTIONS 1 | |
234 | #endif | |
235 | #ifndef __UAPI_DEF_IN6_PKTINFO | |
236 | #define __UAPI_DEF_IN6_PKTINFO 1 | |
237 | #endif | |
238 | #ifndef __UAPI_DEF_IP6_MTUINFO | |
239 | #define __UAPI_DEF_IP6_MTUINFO 1 | |
240 | #endif | |
241 | ||
242 | /* Definitions for ipx.h */ | |
243 | #ifndef __UAPI_DEF_SOCKADDR_IPX | |
244 | #define __UAPI_DEF_SOCKADDR_IPX 1 | |
245 | #endif | |
246 | #ifndef __UAPI_DEF_IPX_ROUTE_DEFINITION | |
247 | #define __UAPI_DEF_IPX_ROUTE_DEFINITION 1 | |
248 | #endif | |
249 | #ifndef __UAPI_DEF_IPX_INTERFACE_DEFINITION | |
250 | #define __UAPI_DEF_IPX_INTERFACE_DEFINITION 1 | |
251 | #endif | |
252 | #ifndef __UAPI_DEF_IPX_CONFIG_DATA | |
253 | #define __UAPI_DEF_IPX_CONFIG_DATA 1 | |
254 | #endif | |
255 | #ifndef __UAPI_DEF_IPX_ROUTE_DEF | |
256 | #define __UAPI_DEF_IPX_ROUTE_DEF 1 | |
257 | #endif | |
258 | ||
259 | /* Definitions for xattr.h */ | |
260 | #ifndef __UAPI_DEF_XATTR | |
261 | #define __UAPI_DEF_XATTR 1 | |
262 | #endif | |
263 | ||
264 | #endif /* __GLIBC__ */ | |
265 | ||
266 | #endif /* _LIBC_COMPAT_H */ |
0 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | |
0 | 1 | #ifndef __LINUX_NEIGHBOUR_H |
1 | 2 | #define __LINUX_NEIGHBOUR_H |
2 | 3 | |
19 | 20 | NDA_LLADDR, |
20 | 21 | NDA_CACHEINFO, |
21 | 22 | NDA_PROBES, |
23 | NDA_VLAN, | |
24 | NDA_PORT, | |
25 | NDA_VNI, | |
26 | NDA_IFINDEX, | |
27 | NDA_MASTER, | |
28 | NDA_LINK_NETNSID, | |
29 | NDA_SRC_VNI, | |
22 | 30 | __NDA_MAX |
23 | 31 | }; |
24 | 32 | |
29 | 37 | */ |
30 | 38 | |
31 | 39 | #define NTF_USE 0x01 |
32 | #define NTF_PROXY 0x08 /* == ATF_PUBL */ | |
33 | #define NTF_ROUTER 0x80 | |
34 | ||
35 | 40 | #define NTF_SELF 0x02 |
36 | 41 | #define NTF_MASTER 0x04 |
42 | #define NTF_PROXY 0x08 /* == ATF_PUBL */ | |
43 | #define NTF_EXT_LEARNED 0x10 | |
44 | #define NTF_OFFLOADED 0x20 | |
45 | #define NTF_ROUTER 0x80 | |
37 | 46 | |
38 | 47 | /* |
39 | 48 | * Neighbor Cache Entry States. |
53 | 62 | |
54 | 63 | /* NUD_NOARP & NUD_PERMANENT are pseudostates, they never change |
55 | 64 | and make no address resolution or NUD. |
56 | NUD_PERMANENT is also cannot be deleted by garbage collectors. | |
65 | NUD_PERMANENT also cannot be deleted by garbage collectors. | |
57 | 66 | */ |
58 | 67 | |
59 | 68 | struct nda_cacheinfo { |
99 | 108 | __u64 ndts_rcv_probes_ucast; |
100 | 109 | __u64 ndts_periodic_gc_runs; |
101 | 110 | __u64 ndts_forced_gc_runs; |
111 | __u64 ndts_table_fulls; | |
102 | 112 | }; |
103 | 113 | |
104 | 114 | enum { |
119 | 129 | NDTPA_PROXY_QLEN, /* u32 */ |
120 | 130 | NDTPA_LOCKTIME, /* u64, msecs */ |
121 | 131 | NDTPA_QUEUE_LENBYTES, /* u32 */ |
132 | NDTPA_MCAST_REPROBES, /* u32 */ | |
133 | NDTPA_PAD, | |
122 | 134 | __NDTPA_MAX |
123 | 135 | }; |
124 | 136 | #define NDTPA_MAX (__NDTPA_MAX - 1) |
151 | 163 | NDTA_PARMS, /* nested TLV NDTPA_* */ |
152 | 164 | NDTA_STATS, /* struct ndt_stats, read-only */ |
153 | 165 | NDTA_GC_INTERVAL, /* u64, msecs */ |
166 | NDTA_PAD, | |
154 | 167 | __NDTA_MAX |
155 | 168 | }; |
156 | 169 | #define NDTA_MAX (__NDTA_MAX - 1) |
0 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | |
0 | 1 | #ifndef __LINUX_NETLINK_H |
1 | 2 | #define __LINUX_NETLINK_H |
2 | 3 | |
4 | #include <linux/kernel.h> | |
5 | #include <linux/socket.h> /* for __kernel_sa_family_t */ | |
3 | 6 | #include <linux/types.h> |
4 | 7 | |
5 | 8 | #define NETLINK_ROUTE 0 /* Routing/device hook */ |
24 | 27 | #define NETLINK_ECRYPTFS 19 |
25 | 28 | #define NETLINK_RDMA 20 |
26 | 29 | #define NETLINK_CRYPTO 21 /* Crypto layer */ |
30 | #define NETLINK_SMC 22 /* SMC monitoring */ | |
27 | 31 | |
28 | 32 | #define NETLINK_INET_DIAG NETLINK_SOCK_DIAG |
29 | 33 | |
46 | 50 | |
47 | 51 | /* Flags values */ |
48 | 52 | |
49 | #define NLM_F_REQUEST 1 /* It is request message. */ | |
50 | #define NLM_F_MULTI 2 /* Multipart message, terminated by NLMSG_DONE */ | |
51 | #define NLM_F_ACK 4 /* Reply with ack, with zero or error code */ | |
52 | #define NLM_F_ECHO 8 /* Echo this request */ | |
53 | #define NLM_F_DUMP_INTR 16 /* Dump was inconsistent due to sequence change */ | |
53 | #define NLM_F_REQUEST 0x01 /* It is request message. */ | |
54 | #define NLM_F_MULTI 0x02 /* Multipart message, terminated by NLMSG_DONE */ | |
55 | #define NLM_F_ACK 0x04 /* Reply with ack, with zero or error code */ | |
56 | #define NLM_F_ECHO 0x08 /* Echo this request */ | |
57 | #define NLM_F_DUMP_INTR 0x10 /* Dump was inconsistent due to sequence change */ | |
58 | #define NLM_F_DUMP_FILTERED 0x20 /* Dump was filtered as requested */ | |
54 | 59 | |
55 | 60 | /* Modifiers to GET request */ |
56 | 61 | #define NLM_F_ROOT 0x100 /* specify tree root */ |
64 | 69 | #define NLM_F_CREATE 0x400 /* Create, if it does not exist */ |
65 | 70 | #define NLM_F_APPEND 0x800 /* Add to end of list */ |
66 | 71 | |
72 | /* Modifiers to DELETE request */ | |
73 | #define NLM_F_NONREC 0x100 /* Do not delete recursively */ | |
74 | ||
75 | /* Flags for ACK message */ | |
76 | #define NLM_F_CAPPED 0x100 /* request was capped */ | |
77 | #define NLM_F_ACK_TLVS 0x200 /* extended ACK TVLs were included */ | |
78 | ||
67 | 79 | /* |
68 | 80 | 4.4BSD ADD NLM_F_CREATE|NLM_F_EXCL |
69 | 81 | 4.4BSD CHANGE NLM_F_REPLACE |
76 | 88 | #define NLMSG_ALIGNTO 4U |
77 | 89 | #define NLMSG_ALIGN(len) ( ((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) ) |
78 | 90 | #define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr))) |
79 | #define NLMSG_LENGTH(len) ((len)+NLMSG_ALIGN(NLMSG_HDRLEN)) | |
91 | #define NLMSG_LENGTH(len) ((len) + NLMSG_HDRLEN) | |
80 | 92 | #define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len)) |
81 | 93 | #define NLMSG_DATA(nlh) ((void*)(((char*)nlh) + NLMSG_LENGTH(0))) |
82 | 94 | #define NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \ |
83 | (struct nlmsghdr*)(void*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len))) | |
95 | (struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len))) | |
84 | 96 | #define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \ |
85 | 97 | (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \ |
86 | 98 | (nlh)->nlmsg_len <= (len)) |
96 | 108 | struct nlmsgerr { |
97 | 109 | int error; |
98 | 110 | struct nlmsghdr msg; |
99 | }; | |
100 | ||
101 | #define NETLINK_ADD_MEMBERSHIP 1 | |
102 | #define NETLINK_DROP_MEMBERSHIP 2 | |
103 | #define NETLINK_PKTINFO 3 | |
104 | #define NETLINK_BROADCAST_ERROR 4 | |
105 | #define NETLINK_NO_ENOBUFS 5 | |
111 | /* | |
112 | * followed by the message contents unless NETLINK_CAP_ACK was set | |
113 | * or the ACK indicates success (error == 0) | |
114 | * message length is aligned with NLMSG_ALIGN() | |
115 | */ | |
116 | /* | |
117 | * followed by TLVs defined in enum nlmsgerr_attrs | |
118 | * if NETLINK_EXT_ACK was set | |
119 | */ | |
120 | }; | |
121 | ||
122 | /** | |
123 | * enum nlmsgerr_attrs - nlmsgerr attributes | |
124 | * @NLMSGERR_ATTR_UNUSED: unused | |
125 | * @NLMSGERR_ATTR_MSG: error message string (string) | |
126 | * @NLMSGERR_ATTR_OFFS: offset of the invalid attribute in the original | |
127 | * message, counting from the beginning of the header (u32) | |
128 | * @NLMSGERR_ATTR_COOKIE: arbitrary subsystem specific cookie to | |
129 | * be used - in the success case - to identify a created | |
130 | * object or operation or similar (binary) | |
131 | * @__NLMSGERR_ATTR_MAX: number of attributes | |
132 | * @NLMSGERR_ATTR_MAX: highest attribute number | |
133 | */ | |
134 | enum nlmsgerr_attrs { | |
135 | NLMSGERR_ATTR_UNUSED, | |
136 | NLMSGERR_ATTR_MSG, | |
137 | NLMSGERR_ATTR_OFFS, | |
138 | NLMSGERR_ATTR_COOKIE, | |
139 | ||
140 | __NLMSGERR_ATTR_MAX, | |
141 | NLMSGERR_ATTR_MAX = __NLMSGERR_ATTR_MAX - 1 | |
142 | }; | |
143 | ||
144 | #define NETLINK_ADD_MEMBERSHIP 1 | |
145 | #define NETLINK_DROP_MEMBERSHIP 2 | |
146 | #define NETLINK_PKTINFO 3 | |
147 | #define NETLINK_BROADCAST_ERROR 4 | |
148 | #define NETLINK_NO_ENOBUFS 5 | |
149 | #define NETLINK_RX_RING 6 | |
150 | #define NETLINK_TX_RING 7 | |
151 | #define NETLINK_LISTEN_ALL_NSID 8 | |
152 | #define NETLINK_LIST_MEMBERSHIPS 9 | |
153 | #define NETLINK_CAP_ACK 10 | |
154 | #define NETLINK_EXT_ACK 11 | |
106 | 155 | |
107 | 156 | struct nl_pktinfo { |
108 | 157 | __u32 group; |
109 | 158 | }; |
159 | ||
160 | struct nl_mmap_req { | |
161 | unsigned int nm_block_size; | |
162 | unsigned int nm_block_nr; | |
163 | unsigned int nm_frame_size; | |
164 | unsigned int nm_frame_nr; | |
165 | }; | |
166 | ||
167 | struct nl_mmap_hdr { | |
168 | unsigned int nm_status; | |
169 | unsigned int nm_len; | |
170 | __u32 nm_group; | |
171 | /* credentials */ | |
172 | __u32 nm_pid; | |
173 | __u32 nm_uid; | |
174 | __u32 nm_gid; | |
175 | }; | |
176 | ||
177 | enum nl_mmap_status { | |
178 | NL_MMAP_STATUS_UNUSED, | |
179 | NL_MMAP_STATUS_RESERVED, | |
180 | NL_MMAP_STATUS_VALID, | |
181 | NL_MMAP_STATUS_COPY, | |
182 | NL_MMAP_STATUS_SKIP, | |
183 | }; | |
184 | ||
185 | #define NL_MMAP_MSG_ALIGNMENT NLMSG_ALIGNTO | |
186 | #define NL_MMAP_MSG_ALIGN(sz) __ALIGN_KERNEL(sz, NL_MMAP_MSG_ALIGNMENT) | |
187 | #define NL_MMAP_HDRLEN NL_MMAP_MSG_ALIGN(sizeof(struct nl_mmap_hdr)) | |
110 | 188 | |
111 | 189 | #define NET_MAJOR 36 /* Major 36 is reserved for networking */ |
112 | 190 | |
147 | 225 | #define NLA_ALIGN(len) (((len) + NLA_ALIGNTO - 1) & ~(NLA_ALIGNTO - 1)) |
148 | 226 | #define NLA_HDRLEN ((int) NLA_ALIGN(sizeof(struct nlattr))) |
149 | 227 | |
150 | ||
151 | #endif /* __LINUX_NETLINK_H */ | |
228 | /* Generic 32 bitflags attribute content sent to the kernel. | |
229 | * | |
230 | * The value is a bitmap that defines the values being set | |
231 | * The selector is a bitmask that defines which value is legit | |
232 | * | |
233 | * Examples: | |
234 | * value = 0x0, and selector = 0x1 | |
235 | * implies we are selecting bit 1 and we want to set its value to 0. | |
236 | * | |
237 | * value = 0x2, and selector = 0x2 | |
238 | * implies we are selecting bit 2 and we want to set its value to 1. | |
239 | * | |
240 | */ | |
241 | struct nla_bitfield32 { | |
242 | __u32 value; | |
243 | __u32 selector; | |
244 | }; | |
245 | ||
246 | #endif /* __LINUX_NETLINK_H */ |
0 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | |
0 | 1 | #ifndef __LINUX_RTNETLINK_H |
1 | 2 | #define __LINUX_RTNETLINK_H |
2 | 3 | |
119 | 120 | RTM_SETDCB, |
120 | 121 | #define RTM_SETDCB RTM_SETDCB |
121 | 122 | |
123 | RTM_NEWNETCONF = 80, | |
124 | #define RTM_NEWNETCONF RTM_NEWNETCONF | |
125 | RTM_DELNETCONF, | |
126 | #define RTM_DELNETCONF RTM_DELNETCONF | |
127 | RTM_GETNETCONF = 82, | |
128 | #define RTM_GETNETCONF RTM_GETNETCONF | |
129 | ||
130 | RTM_NEWMDB = 84, | |
131 | #define RTM_NEWMDB RTM_NEWMDB | |
132 | RTM_DELMDB = 85, | |
133 | #define RTM_DELMDB RTM_DELMDB | |
134 | RTM_GETMDB = 86, | |
135 | #define RTM_GETMDB RTM_GETMDB | |
136 | ||
137 | RTM_NEWNSID = 88, | |
138 | #define RTM_NEWNSID RTM_NEWNSID | |
139 | RTM_DELNSID = 89, | |
140 | #define RTM_DELNSID RTM_DELNSID | |
141 | RTM_GETNSID = 90, | |
142 | #define RTM_GETNSID RTM_GETNSID | |
143 | ||
144 | RTM_NEWSTATS = 92, | |
145 | #define RTM_NEWSTATS RTM_NEWSTATS | |
146 | RTM_GETSTATS = 94, | |
147 | #define RTM_GETSTATS RTM_GETSTATS | |
148 | ||
149 | RTM_NEWCACHEREPORT = 96, | |
150 | #define RTM_NEWCACHEREPORT RTM_NEWCACHEREPORT | |
151 | ||
152 | RTM_NEWCHAIN = 100, | |
153 | #define RTM_NEWCHAIN RTM_NEWCHAIN | |
154 | RTM_DELCHAIN, | |
155 | #define RTM_DELCHAIN RTM_DELCHAIN | |
156 | RTM_GETCHAIN, | |
157 | #define RTM_GETCHAIN RTM_GETCHAIN | |
158 | ||
122 | 159 | __RTM_MAX, |
123 | 160 | #define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1) |
124 | 161 | }; |
140 | 177 | |
141 | 178 | /* Macros to handle rtattributes */ |
142 | 179 | |
143 | #define RTA_ALIGNTO 4 | |
180 | #define RTA_ALIGNTO 4U | |
144 | 181 | #define RTA_ALIGN(len) ( ((len)+RTA_ALIGNTO-1) & ~(RTA_ALIGNTO-1) ) |
145 | 182 | #define RTA_OK(rta,len) ((len) >= (int)sizeof(struct rtattr) && \ |
146 | 183 | (rta)->rta_len >= sizeof(struct rtattr) && \ |
147 | 184 | (rta)->rta_len <= (len)) |
148 | 185 | #define RTA_NEXT(rta,attrlen) ((attrlen) -= RTA_ALIGN((rta)->rta_len), \ |
149 | (struct rtattr*)(void*)(((char*)(rta)) + RTA_ALIGN((rta)->rta_len))) | |
186 | (struct rtattr*)(((char*)(rta)) + RTA_ALIGN((rta)->rta_len))) | |
150 | 187 | #define RTA_LENGTH(len) (RTA_ALIGN(sizeof(struct rtattr)) + (len)) |
151 | 188 | #define RTA_SPACE(len) RTA_ALIGN(RTA_LENGTH(len)) |
152 | 189 | #define RTA_DATA(rta) ((void*)(((char*)(rta)) + RTA_LENGTH(0))) |
221 | 258 | #define RTPROT_XORP 14 /* XORP */ |
222 | 259 | #define RTPROT_NTK 15 /* Netsukuku */ |
223 | 260 | #define RTPROT_DHCP 16 /* DHCP client */ |
261 | #define RTPROT_MROUTED 17 /* Multicast daemon */ | |
262 | #define RTPROT_BABEL 42 /* Babel daemon */ | |
263 | #define RTPROT_BGP 186 /* BGP Routes */ | |
264 | #define RTPROT_ISIS 187 /* ISIS Routes */ | |
265 | #define RTPROT_OSPF 188 /* OSPF Routes */ | |
266 | #define RTPROT_RIP 189 /* RIP Routes */ | |
267 | #define RTPROT_EIGRP 192 /* EIGRP Routes */ | |
224 | 268 | |
225 | 269 | /* rtm_scope |
226 | 270 | |
248 | 292 | #define RTM_F_CLONED 0x200 /* This route is cloned */ |
249 | 293 | #define RTM_F_EQUALIZE 0x400 /* Multipath equalizer: NI */ |
250 | 294 | #define RTM_F_PREFIX 0x800 /* Prefix addresses */ |
295 | #define RTM_F_LOOKUP_TABLE 0x1000 /* set rtm_table to FIB lookup result */ | |
296 | #define RTM_F_FIB_MATCH 0x2000 /* return full fib lookup match */ | |
251 | 297 | |
252 | 298 | /* Reserved table identifiers */ |
253 | 299 | |
282 | 328 | RTA_MP_ALGO, /* no longer used */ |
283 | 329 | RTA_TABLE, |
284 | 330 | RTA_MARK, |
331 | RTA_MFC_STATS, | |
332 | RTA_VIA, | |
333 | RTA_NEWDST, | |
334 | RTA_PREF, | |
335 | RTA_ENCAP_TYPE, | |
336 | RTA_ENCAP, | |
337 | RTA_EXPIRES, | |
338 | RTA_PAD, | |
339 | RTA_UID, | |
340 | RTA_TTL_PROPAGATE, | |
341 | RTA_IP_PROTO, | |
342 | RTA_SPORT, | |
343 | RTA_DPORT, | |
285 | 344 | __RTA_MAX |
286 | 345 | }; |
287 | 346 | |
288 | 347 | #define RTA_MAX (__RTA_MAX - 1) |
289 | 348 | |
290 | #define RTM_RTA(r) ((struct rtattr*)(void*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg)))) | |
349 | #define RTM_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg)))) | |
291 | 350 | #define RTM_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct rtmsg)) |
292 | 351 | |
293 | 352 | /* RTM_MULTIPATH --- array of struct rtnexthop. |
311 | 370 | #define RTNH_F_DEAD 1 /* Nexthop is dead (used by multipath) */ |
312 | 371 | #define RTNH_F_PERVASIVE 2 /* Do recursive gateway lookup */ |
313 | 372 | #define RTNH_F_ONLINK 4 /* Gateway is forced on link */ |
373 | #define RTNH_F_OFFLOAD 8 /* offloaded route */ | |
374 | #define RTNH_F_LINKDOWN 16 /* carrier-down on nexthop */ | |
375 | #define RTNH_F_UNRESOLVED 32 /* The entry is unresolved (ipmr) */ | |
376 | ||
377 | #define RTNH_COMPARE_MASK (RTNH_F_DEAD | RTNH_F_LINKDOWN | RTNH_F_OFFLOAD) | |
314 | 378 | |
315 | 379 | /* Macros to handle hexthops */ |
316 | 380 | |
318 | 382 | #define RTNH_ALIGN(len) ( ((len)+RTNH_ALIGNTO-1) & ~(RTNH_ALIGNTO-1) ) |
319 | 383 | #define RTNH_OK(rtnh,len) ((rtnh)->rtnh_len >= sizeof(struct rtnexthop) && \ |
320 | 384 | ((int)(rtnh)->rtnh_len) <= (len)) |
321 | #define RTNH_NEXT(rtnh) ((struct rtnexthop*)(void*)(((char*)(rtnh)) + RTNH_ALIGN((rtnh)->rtnh_len))) | |
385 | #define RTNH_NEXT(rtnh) ((struct rtnexthop*)(((char*)(rtnh)) + RTNH_ALIGN((rtnh)->rtnh_len))) | |
322 | 386 | #define RTNH_LENGTH(len) (RTNH_ALIGN(sizeof(struct rtnexthop)) + (len)) |
323 | 387 | #define RTNH_SPACE(len) RTNH_ALIGN(RTNH_LENGTH(len)) |
324 | #define RTNH_DATA(rtnh) ((struct rtattr*)(void*)(((char*)(rtnh)) + RTNH_LENGTH(0))) | |
388 | #define RTNH_DATA(rtnh) ((struct rtattr*)(((char*)(rtnh)) + RTNH_LENGTH(0))) | |
325 | 389 | |
326 | 390 | /* RTM_CACHEINFO */ |
327 | 391 | |
371 | 435 | #define RTAX_RTO_MIN RTAX_RTO_MIN |
372 | 436 | RTAX_INITRWND, |
373 | 437 | #define RTAX_INITRWND RTAX_INITRWND |
438 | RTAX_QUICKACK, | |
439 | #define RTAX_QUICKACK RTAX_QUICKACK | |
440 | RTAX_CC_ALGO, | |
441 | #define RTAX_CC_ALGO RTAX_CC_ALGO | |
442 | RTAX_FASTOPEN_NO_COOKIE, | |
443 | #define RTAX_FASTOPEN_NO_COOKIE RTAX_FASTOPEN_NO_COOKIE | |
374 | 444 | __RTAX_MAX |
375 | 445 | }; |
376 | 446 | |
377 | 447 | #define RTAX_MAX (__RTAX_MAX - 1) |
378 | 448 | |
379 | #define RTAX_FEATURE_ECN 0x00000001 | |
380 | #define RTAX_FEATURE_SACK 0x00000002 | |
381 | #define RTAX_FEATURE_TIMESTAMP 0x00000004 | |
382 | #define RTAX_FEATURE_ALLFRAG 0x00000008 | |
449 | #define RTAX_FEATURE_ECN (1 << 0) | |
450 | #define RTAX_FEATURE_SACK (1 << 1) | |
451 | #define RTAX_FEATURE_TIMESTAMP (1 << 2) | |
452 | #define RTAX_FEATURE_ALLFRAG (1 << 3) | |
453 | ||
454 | #define RTAX_FEATURE_MASK (RTAX_FEATURE_ECN | RTAX_FEATURE_SACK | \ | |
455 | RTAX_FEATURE_TIMESTAMP | RTAX_FEATURE_ALLFRAG) | |
383 | 456 | |
384 | 457 | struct rta_session { |
385 | 458 | __u8 proto; |
400 | 473 | |
401 | 474 | __u32 spi; |
402 | 475 | } u; |
476 | }; | |
477 | ||
478 | struct rta_mfc_stats { | |
479 | __u64 mfcs_packets; | |
480 | __u64 mfcs_bytes; | |
481 | __u64 mfcs_wrong_if; | |
403 | 482 | }; |
404 | 483 | |
405 | 484 | /**** |
470 | 549 | int tcm_ifindex; |
471 | 550 | __u32 tcm_handle; |
472 | 551 | __u32 tcm_parent; |
552 | /* tcm_block_index is used instead of tcm_parent | |
553 | * in case tcm_ifindex == TCM_IFINDEX_MAGIC_BLOCK | |
554 | */ | |
555 | #define tcm_block_index tcm_parent | |
473 | 556 | __u32 tcm_info; |
474 | 557 | }; |
558 | ||
559 | /* For manipulation of filters in shared block, tcm_ifindex is set to | |
560 | * TCM_IFINDEX_MAGIC_BLOCK, and tcm_parent is aliased to tcm_block_index | |
561 | * which is the block index. | |
562 | */ | |
563 | #define TCM_IFINDEX_MAGIC_BLOCK (0xFFFFFFFFU) | |
475 | 564 | |
476 | 565 | enum { |
477 | 566 | TCA_UNSPEC, |
483 | 572 | TCA_FCNT, |
484 | 573 | TCA_STATS2, |
485 | 574 | TCA_STAB, |
575 | TCA_PAD, | |
576 | TCA_DUMP_INVISIBLE, | |
577 | TCA_CHAIN, | |
578 | TCA_HW_OFFLOAD, | |
579 | TCA_INGRESS_BLOCK, | |
580 | TCA_EGRESS_BLOCK, | |
486 | 581 | __TCA_MAX |
487 | 582 | }; |
488 | 583 | |
489 | 584 | #define TCA_MAX (__TCA_MAX - 1) |
490 | 585 | |
491 | #define TCA_RTA(r) ((struct rtattr*)(void*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcmsg)))) | |
586 | #define TCA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcmsg)))) | |
492 | 587 | #define TCA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcmsg)) |
493 | 588 | |
494 | 589 | /******************************************************************** |
584 | 679 | #define RTNLGRP_PHONET_ROUTE RTNLGRP_PHONET_ROUTE |
585 | 680 | RTNLGRP_DCB, |
586 | 681 | #define RTNLGRP_DCB RTNLGRP_DCB |
682 | RTNLGRP_IPV4_NETCONF, | |
683 | #define RTNLGRP_IPV4_NETCONF RTNLGRP_IPV4_NETCONF | |
684 | RTNLGRP_IPV6_NETCONF, | |
685 | #define RTNLGRP_IPV6_NETCONF RTNLGRP_IPV6_NETCONF | |
686 | RTNLGRP_MDB, | |
687 | #define RTNLGRP_MDB RTNLGRP_MDB | |
688 | RTNLGRP_MPLS_ROUTE, | |
689 | #define RTNLGRP_MPLS_ROUTE RTNLGRP_MPLS_ROUTE | |
690 | RTNLGRP_NSID, | |
691 | #define RTNLGRP_NSID RTNLGRP_NSID | |
692 | RTNLGRP_MPLS_NETCONF, | |
693 | #define RTNLGRP_MPLS_NETCONF RTNLGRP_MPLS_NETCONF | |
694 | RTNLGRP_IPV4_MROUTE_R, | |
695 | #define RTNLGRP_IPV4_MROUTE_R RTNLGRP_IPV4_MROUTE_R | |
696 | RTNLGRP_IPV6_MROUTE_R, | |
697 | #define RTNLGRP_IPV6_MROUTE_R RTNLGRP_IPV6_MROUTE_R | |
587 | 698 | __RTNLGRP_MAX |
588 | 699 | }; |
589 | 700 | #define RTNLGRP_MAX (__RTNLGRP_MAX - 1) |
594 | 705 | unsigned char tca__pad1; |
595 | 706 | unsigned short tca__pad2; |
596 | 707 | }; |
597 | #define TA_RTA(r) ((struct rtattr*)(void*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcamsg)))) | |
708 | ||
709 | enum { | |
710 | TCA_ROOT_UNSPEC, | |
711 | TCA_ROOT_TAB, | |
712 | #define TCA_ACT_TAB TCA_ROOT_TAB | |
713 | #define TCAA_MAX TCA_ROOT_TAB | |
714 | TCA_ROOT_FLAGS, | |
715 | TCA_ROOT_COUNT, | |
716 | TCA_ROOT_TIME_DELTA, /* in msecs */ | |
717 | __TCA_ROOT_MAX, | |
718 | #define TCA_ROOT_MAX (__TCA_ROOT_MAX - 1) | |
719 | }; | |
720 | ||
721 | #define TA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcamsg)))) | |
598 | 722 | #define TA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcamsg)) |
599 | #define TCA_ACT_TAB 1 /* attr type must be >=1 */ | |
600 | #define TCAA_MAX 1 | |
723 | /* tcamsg flags stored in attribute TCA_ROOT_FLAGS | |
724 | * | |
725 | * TCA_FLAG_LARGE_DUMP_ON user->kernel to request for larger than TCA_ACT_MAX_PRIO | |
726 | * actions in a dump. All dump responses will contain the number of actions | |
727 | * being dumped stored in for user app's consumption in TCA_ROOT_COUNT | |
728 | * | |
729 | */ | |
730 | #define TCA_FLAG_LARGE_DUMP_ON (1 << 0) | |
601 | 731 | |
602 | 732 | /* New extended info filters for IFLA_EXT_MASK */ |
603 | 733 | #define RTEXT_FILTER_VF (1 << 0) |
734 | #define RTEXT_FILTER_BRVLAN (1 << 1) | |
735 | #define RTEXT_FILTER_BRVLAN_COMPRESSED (1 << 2) | |
736 | #define RTEXT_FILTER_SKIP_STATS (1 << 3) | |
604 | 737 | |
605 | 738 | /* End of information exported to user level */ |
606 | 739 | |
607 | 740 | |
608 | 741 | |
609 | #endif /* __LINUX_RTNETLINK_H */ | |
742 | #endif /* __LINUX_RTNETLINK_H */ |
0 | /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ | |
0 | 1 | /* |
1 | 2 | * INET An implementation of the TCP/IP protocol suite for the LINUX |
2 | 3 | * operating system. INET is implemented using the BSD Socket |
23 | 24 | #define SIOCINQ FIONREAD |
24 | 25 | #define SIOCOUTQ TIOCOUTQ /* output queue size (not sent + not acked) */ |
25 | 26 | |
27 | #define SOCK_IOC_TYPE 0x89 | |
28 | ||
26 | 29 | /* Routing table calls. */ |
27 | 30 | #define SIOCADDRT 0x890B /* add routing table entry */ |
28 | 31 | #define SIOCDELRT 0x890C /* delete routing table entry */ |
29 | #define SIOCRTMSG 0x890D /* call to routing system */ | |
32 | #define SIOCRTMSG 0x890D /* unused */ | |
30 | 33 | |
31 | 34 | /* Socket configuration controls. */ |
32 | 35 | #define SIOCGIFNAME 0x8910 /* get iface name */ |
83 | 86 | #define SIOCWANDEV 0x894A /* get/set netdev parameters */ |
84 | 87 | |
85 | 88 | #define SIOCOUTQNSD 0x894B /* output queue size (not sent only) */ |
89 | #define SIOCGSKNS 0x894C /* get socket network namespace */ | |
86 | 90 | |
87 | 91 | /* ARP cache control calls. */ |
88 | 92 | /* 0x8950 - 0x8952 * obsolete calls, don't re-use */ |
124 | 128 | #define SIOCBRDELIF 0x89a3 /* remove interface from bridge */ |
125 | 129 | |
126 | 130 | /* hardware time stamping: parameters in linux/net_tstamp.h */ |
127 | #define SIOCSHWTSTAMP 0x89b0 | |
131 | #define SIOCSHWTSTAMP 0x89b0 /* set and get config */ | |
132 | #define SIOCGHWTSTAMP 0x89b1 /* get config */ | |
128 | 133 | |
129 | 134 | /* Device private ioctl calls */ |
130 | 135 |
0 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | |
0 | 1 | #ifndef _LINUX_TYPES_H |
1 | 2 | #define _LINUX_TYPES_H |
2 | 3 | |
17 | 18 | #else |
18 | 19 | #define __bitwise__ |
19 | 20 | #endif |
20 | #ifdef __CHECK_ENDIAN__ | |
21 | 21 | #define __bitwise __bitwise__ |
22 | #else | |
23 | #define __bitwise | |
24 | #endif | |
25 | 22 | |
26 | 23 | typedef __u16 __bitwise __le16; |
27 | 24 | typedef __u16 __bitwise __be16; |
46 | 43 | #define __aligned_be64 __be64 __attribute__((aligned(8))) |
47 | 44 | #define __aligned_le64 __le64 __attribute__((aligned(8))) |
48 | 45 | |
46 | typedef unsigned __bitwise __poll_t; | |
47 | ||
49 | 48 | #endif /* __ASSEMBLY__ */ |
50 | 49 | #endif /* _LINUX_TYPES_H */ |
0 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | |
0 | 1 | /* |
1 | 2 | * This file define a set of standard wireless extensions |
2 | 3 | * |
669 | 670 | /* |
670 | 671 | * Generic format for most parameters that fit in an int |
671 | 672 | */ |
672 | struct iw_param | |
673 | { | |
673 | struct iw_param { | |
674 | 674 | __s32 value; /* The value of the parameter itself */ |
675 | 675 | __u8 fixed; /* Hardware should not use auto select */ |
676 | 676 | __u8 disabled; /* Disable the feature */ |
681 | 681 | * For all data larger than 16 octets, we need to use a |
682 | 682 | * pointer to memory allocated in user space. |
683 | 683 | */ |
684 | struct iw_point | |
685 | { | |
684 | struct iw_point { | |
686 | 685 | void *pointer; /* Pointer to the data (in user space) */ |
687 | 686 | __u16 length; /* number of fields or size in bytes */ |
688 | 687 | __u16 flags; /* Optional params */ |
697 | 696 | * of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')... |
698 | 697 | * The power of 10 is in 'e', the result of the division is in 'm'. |
699 | 698 | */ |
700 | struct iw_freq | |
701 | { | |
699 | struct iw_freq { | |
702 | 700 | __s32 m; /* Mantissa */ |
703 | 701 | __s16 e; /* Exponent */ |
704 | 702 | __u8 i; /* List index (when in range struct) */ |
708 | 706 | /* |
709 | 707 | * Quality of the link |
710 | 708 | */ |
711 | struct iw_quality | |
712 | { | |
709 | struct iw_quality { | |
713 | 710 | __u8 qual; /* link quality (%retries, SNR, |
714 | 711 | %missed beacons or better...) */ |
715 | 712 | __u8 level; /* signal level (dBm) */ |
724 | 721 | * is already pretty exhaustive, and you should use that first. |
725 | 722 | * This is only additional stats... |
726 | 723 | */ |
727 | struct iw_discarded | |
728 | { | |
724 | struct iw_discarded { | |
729 | 725 | __u32 nwid; /* Rx : Wrong nwid/essid */ |
730 | 726 | __u32 code; /* Rx : Unable to code/decode (WEP) */ |
731 | 727 | __u32 fragment; /* Rx : Can't perform MAC reassembly */ |
737 | 733 | * Packet/Time period missed in the wireless adapter due to |
738 | 734 | * "wireless" specific problems... |
739 | 735 | */ |
740 | struct iw_missed | |
741 | { | |
736 | struct iw_missed { | |
742 | 737 | __u32 beacon; /* Missed beacons/superframe */ |
743 | 738 | }; |
744 | 739 | |
745 | 740 | /* |
746 | 741 | * Quality range (for spy threshold) |
747 | 742 | */ |
748 | struct iw_thrspy | |
749 | { | |
743 | struct iw_thrspy { | |
750 | 744 | struct sockaddr addr; /* Source address (hw/mac) */ |
751 | 745 | struct iw_quality qual; /* Quality of the link */ |
752 | 746 | struct iw_quality low; /* Low threshold */ |
764 | 758 | * Especially, scan results are required to include an entry for the |
765 | 759 | * current BSS if the driver is in Managed mode and associated with an AP. |
766 | 760 | */ |
767 | struct iw_scan_req | |
768 | { | |
761 | struct iw_scan_req { | |
769 | 762 | __u8 scan_type; /* IW_SCAN_TYPE_{ACTIVE,PASSIVE} */ |
770 | 763 | __u8 essid_len; |
771 | 764 | __u8 num_channels; /* num entries in channel_list; |
826 | 819 | * RX_SEQ_VALID for SIOCGIWENCODEEXT are optional, but can be useful for |
827 | 820 | * debugging/testing. |
828 | 821 | */ |
829 | struct iw_encode_ext | |
830 | { | |
822 | struct iw_encode_ext { | |
831 | 823 | __u32 ext_flags; /* IW_ENCODE_EXT_* */ |
832 | 824 | __u8 tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */ |
833 | 825 | __u8 rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */ |
840 | 832 | }; |
841 | 833 | |
842 | 834 | /* SIOCSIWMLME data */ |
843 | struct iw_mlme | |
844 | { | |
835 | struct iw_mlme { | |
845 | 836 | __u16 cmd; /* IW_MLME_* */ |
846 | 837 | __u16 reason_code; |
847 | 838 | struct sockaddr addr; |
854 | 845 | |
855 | 846 | #define IW_PMKID_LEN 16 |
856 | 847 | |
857 | struct iw_pmksa | |
858 | { | |
848 | struct iw_pmksa { | |
859 | 849 | __u32 cmd; /* IW_PMKSA_* */ |
860 | 850 | struct sockaddr bssid; |
861 | 851 | __u8 pmkid[IW_PMKID_LEN]; |
862 | 852 | }; |
863 | 853 | |
864 | 854 | /* IWEVMICHAELMICFAILURE data */ |
865 | struct iw_michaelmicfailure | |
866 | { | |
855 | struct iw_michaelmicfailure { | |
867 | 856 | __u32 flags; |
868 | 857 | struct sockaddr src_addr; |
869 | 858 | __u8 tsc[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */ |
871 | 860 | |
872 | 861 | /* IWEVPMKIDCAND data */ |
873 | 862 | #define IW_PMKID_CAND_PREAUTH 0x00000001 /* RNS pre-authentication enabled */ |
874 | struct iw_pmkid_cand | |
875 | { | |
863 | struct iw_pmkid_cand { | |
876 | 864 | __u32 flags; /* IW_PMKID_CAND_* */ |
877 | 865 | __u32 index; /* the smaller the index, the higher the |
878 | 866 | * priority */ |
883 | 871 | /* |
884 | 872 | * Wireless statistics (used for /proc/net/wireless) |
885 | 873 | */ |
886 | struct iw_statistics | |
887 | { | |
874 | struct iw_statistics { | |
888 | 875 | __u16 status; /* Status |
889 | 876 | * - device dependent for now */ |
890 | 877 | |
896 | 883 | |
897 | 884 | /* ------------------------ IOCTL REQUEST ------------------------ */ |
898 | 885 | /* |
899 | * This structure defines the payload of an ioctl, and is used | |
886 | * This structure defines the payload of an ioctl, and is used | |
900 | 887 | * below. |
901 | 888 | * |
902 | 889 | * Note that this structure should fit on the memory footprint |
905 | 892 | * You should check this when increasing the structures defined |
906 | 893 | * above in this file... |
907 | 894 | */ |
908 | union iwreq_data | |
909 | { | |
895 | union iwreq_data { | |
910 | 896 | /* Config - generic */ |
911 | 897 | char name[IFNAMSIZ]; |
912 | 898 | /* Name : used to verify the presence of wireless extensions. |
943 | 929 | * convenience... |
944 | 930 | * Do I need to remind you about structure size (32 octets) ? |
945 | 931 | */ |
946 | struct iwreq | |
947 | { | |
932 | struct iwreq { | |
948 | 933 | union |
949 | 934 | { |
950 | 935 | char ifrn_name[IFNAMSIZ]; /* if name, e.g. "eth0" */ |
951 | 936 | } ifr_ifrn; |
952 | 937 | |
953 | 938 | /* Data part (defined just above) */ |
954 | union iwreq_data u; | |
939 | union iwreq_data u; | |
955 | 940 | }; |
956 | 941 | |
957 | 942 | /* -------------------------- IOCTL DATA -------------------------- */ |
964 | 949 | * Range of parameters |
965 | 950 | */ |
966 | 951 | |
967 | struct iw_range | |
968 | { | |
952 | struct iw_range { | |
969 | 953 | /* Informative stuff (to choose between different interface) */ |
970 | 954 | __u32 throughput; /* To give an idea... */ |
971 | 955 | /* In theory this value should be the maximum benchmarked |
1068 | 1052 | /* |
1069 | 1053 | * Private ioctl interface information |
1070 | 1054 | */ |
1071 | ||
1072 | struct iw_priv_args | |
1073 | { | |
1055 | ||
1056 | struct iw_priv_args { | |
1074 | 1057 | __u32 cmd; /* Number of the ioctl to issue */ |
1075 | 1058 | __u16 set_args; /* Type and number of args */ |
1076 | 1059 | __u16 get_args; /* Type and number of args */ |
1087 | 1070 | /* |
1088 | 1071 | * A Wireless Event. Contains basically the same data as the ioctl... |
1089 | 1072 | */ |
1090 | struct iw_event | |
1091 | { | |
1073 | struct iw_event { | |
1092 | 1074 | __u16 len; /* Real length of this stuff */ |
1093 | 1075 | __u16 cmd; /* Wireless IOCTL */ |
1094 | 1076 | union iwreq_data u; /* IOCTL fixed payload */ |
1124 | 1106 | #define IW_EV_QUAL_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_quality)) |
1125 | 1107 | #define IW_EV_POINT_PK_LEN (IW_EV_LCP_PK_LEN + 4) |
1126 | 1108 | |
1127 | #endif /* _LINUX_WIRELESS_H */ | |
1109 | #endif /* _LINUX_WIRELESS_H */ |
61 | 61 | #endif |
62 | 62 | #undef NEWLINE |
63 | 63 | |
64 | extern const char *ctlname; | |
65 | ||
64 | 66 | /* commands.c */ |
65 | 67 | #define NEWLINE "<CR>" |
66 | 68 | struct cmd_node; |
75 | 77 | struct cmd_env*, void *), |
76 | 78 | void *); |
77 | 79 | struct cmd_node* commands_privileged(struct cmd_node *); |
80 | struct cmd_node* commands_lock(struct cmd_node *); | |
78 | 81 | struct cmd_node* commands_hidden(struct cmd_node *); |
79 | 82 | void commands_free(struct cmd_node *); |
80 | 83 | const char *cmdenv_arg(struct cmd_env*); |
17 | 17 | #include "client.h" |
18 | 18 | #include <string.h> |
19 | 19 | #include <sys/queue.h> |
20 | #include <sys/types.h> | |
21 | #include <sys/socket.h> | |
22 | #include <sys/un.h> | |
20 | 23 | |
21 | 24 | /** |
22 | 25 | * An element of the environment (a key and a value). |
67 | 70 | const char *token; /**< Token to enter this cnode */ |
68 | 71 | const char *doc; /**< Documentation string */ |
69 | 72 | int privileged; /**< Privileged command? */ |
73 | int lock; /**< Lock required for execution? */ | |
70 | 74 | int hidden; /**< Hidden command? */ |
71 | 75 | |
72 | 76 | /** |
113 | 117 | } |
114 | 118 | |
115 | 119 | /** |
120 | * Make a node accessible only with a lock. | |
121 | * | |
122 | * @param node node to use lock to execute | |
123 | * @return the modified node | |
124 | * | |
125 | * The node is modified. It is returned to ease chaining. | |
126 | */ | |
127 | struct cmd_node* | |
128 | commands_lock(struct cmd_node *node) | |
129 | { | |
130 | if (node) node->lock = 1; | |
131 | return node; | |
132 | } | |
133 | ||
134 | /** | |
116 | 135 | * Hide a node from help or completion. |
117 | 136 | * |
118 | 137 | * @param node node to hide |
343 | 362 | int n, rc = 0, completion = (word != NULL); |
344 | 363 | int help = 0; /* Are we asking for help? */ |
345 | 364 | int complete = 0; /* Are we asking for possible completions? */ |
365 | int needlock = 0; /* Do we need a lock? */ | |
346 | 366 | struct cmd_env env = { |
347 | 367 | .elements = TAILQ_HEAD_INITIALIZER(env.elements), |
348 | 368 | .stack = TAILQ_HEAD_INITIALIZER(env.stack), |
350 | 370 | .argv = argv, |
351 | 371 | .argp = 0 |
352 | 372 | }; |
373 | static int lockfd = -1; | |
353 | 374 | cmdenv_push(&env, root); |
354 | 375 | if (!completion) |
355 | 376 | for (n = 0; n < argc; n++) |
387 | 408 | !strcmp(candidate->token, token)) { |
388 | 409 | /* Exact match */ |
389 | 410 | best = candidate; |
411 | needlock = needlock || candidate->lock; | |
390 | 412 | break; |
391 | 413 | } |
392 | 414 | if (!best) best = candidate; |
405 | 427 | if (!candidate->token && |
406 | 428 | CAN_EXECUTE(candidate)) { |
407 | 429 | best = candidate; |
430 | needlock = needlock || candidate->lock; | |
408 | 431 | break; |
409 | 432 | } |
410 | 433 | } |
420 | 443 | |
421 | 444 | /* Push and execute */ |
422 | 445 | cmdenv_push(&env, best); |
423 | if (best->execute && best->execute(conn, w, &env, best->arg) != 1) { | |
424 | rc = -1; | |
425 | goto end; | |
446 | if (best->execute) { | |
447 | struct sockaddr_un su; | |
448 | if (needlock) { | |
449 | if (lockfd == -1) { | |
450 | log_debug("lldpctl", "reopen %s for locking", ctlname); | |
451 | if ((lockfd = socket(PF_UNIX, SOCK_STREAM, 0)) == -1) { | |
452 | log_warn("lldpctl", "cannot open for lock %s", ctlname); | |
453 | rc = -1; | |
454 | goto end; | |
455 | } | |
456 | su.sun_family = AF_UNIX; | |
457 | strlcpy(su.sun_path, ctlname, sizeof(su.sun_path)); | |
458 | if (connect(lockfd, (struct sockaddr *)&su, sizeof(struct sockaddr_un)) == -1) { | |
459 | log_warn("lldpctl", "cannot connect to socket %s", ctlname); | |
460 | rc = -1; | |
461 | close(lockfd); lockfd = -1; | |
462 | goto end; | |
463 | } | |
464 | } | |
465 | if (lockf(lockfd, F_LOCK, 0) == -1) { | |
466 | log_warn("lldpctl", "cannot get lock on %s", ctlname); | |
467 | rc = -1; | |
468 | close(lockfd); lockfd = -1; | |
469 | goto end; | |
470 | } | |
471 | } | |
472 | rc = best->execute(conn, w, &env, best->arg) != 1 ? -1 : rc; | |
473 | if (needlock && lockf(lockfd, F_ULOCK, 0) == -1) { | |
474 | log_warn("lldpctl", "cannot unlock %s", ctlname); | |
475 | close(lockfd); lockfd = -1; | |
476 | } | |
477 | if (rc == -1) goto end; | |
426 | 478 | } |
427 | 479 | env.argp++; |
428 | 480 | } |
25 | 25 | cmd_txdelay(struct lldpctl_conn_t *conn, struct writer *w, |
26 | 26 | struct cmd_env *env, void *arg) |
27 | 27 | { |
28 | const char *interval; | |
29 | char interval_ms[8]; /* less than 2.5 hours */ | |
30 | lldpctl_key_t key; | |
31 | int arglen; | |
32 | ||
28 | 33 | log_debug("lldpctl", "set transmit delay"); |
29 | 34 | |
30 | 35 | lldpctl_atom_t *config = lldpctl_get_configuration(conn); |
33 | 38 | lldpctl_last_strerror(conn)); |
34 | 39 | return 0; |
35 | 40 | } |
36 | if (lldpctl_atom_set_str(config, | |
37 | lldpctl_k_config_tx_interval, cmdenv_get(env, "tx-interval")) == NULL) { | |
41 | interval = cmdenv_get(env, "tx-interval"); | |
42 | key = lldpctl_k_config_tx_interval; | |
43 | /* interval is either <number> for seconds or <number>ms for milliseconds */ | |
44 | if (interval) { | |
45 | arglen = strlen(interval); | |
46 | /* room for "ms" in interval, room for interval in interval_ms */ | |
47 | if (arglen >= 2 && arglen-2 < sizeof(interval_ms) && | |
48 | strcmp("ms", interval+arglen-2) == 0) { | |
49 | /* remove "ms" suffix */ | |
50 | memcpy(interval_ms, interval, arglen-2); | |
51 | interval_ms[arglen-2] = '\0'; | |
52 | /* substitute key and value */ | |
53 | key = lldpctl_k_config_tx_interval_ms; | |
54 | interval = interval_ms; | |
55 | } | |
56 | } | |
57 | if (lldpctl_atom_set_str(config, key, interval) == NULL) { | |
38 | 58 | log_warnx("lldpctl", "unable to set transmit delay. %s", |
39 | 59 | lldpctl_last_strerror(conn)); |
40 | 60 | lldpctl_atom_dec_ref(config); |
520 | 540 | commands_new(configure_lldp, |
521 | 541 | "tx-interval", "Set LLDP transmit delay", |
522 | 542 | cmd_check_no_env, NULL, "ports"), |
523 | NULL, "LLDP transmit delay in seconds", | |
543 | NULL, "LLDP transmit <delay> in seconds or <delay>ms in milliseconds", | |
524 | 544 | NULL, cmd_store_env_value, "tx-interval"), |
525 | 545 | NEWLINE, "Set LLDP transmit delay", |
526 | 546 | NULL, cmd_txdelay, NULL); |
120 | 120 | /* Powerpairs */ |
121 | 121 | (what = "power pairs", lldpctl_atom_set_str(dot3_power, |
122 | 122 | lldpctl_k_dot3_power_pairs, |
123 | cmdenv_get(env, "powerpairs"))) == NULL || | |
123 | cmdenv_get(env, "powerpairs")?cmdenv_get(env, "powerpairs"):"unknown")) == NULL || | |
124 | 124 | /* Class */ |
125 | 125 | (what = "power class", cmdenv_get(env, "class")? |
126 | 126 | lldpctl_atom_set_str(dot3_power, |
303 | 303 | static int |
304 | 304 | cmd_check_env_power(struct cmd_env *env, void *nothing) |
305 | 305 | { |
306 | /* We need type and powerpair but if we have typeat, we also request | |
307 | * source, priority, requested and allocated. */ | |
306 | /* We need type. If we type is PSE, we need powerpairs. If we have | |
307 | * typeat, we also request source, priority, requested and allocated. */ | |
308 | 308 | if (!cmdenv_get(env, "device-type")) return 0; |
309 | if (!cmdenv_get(env, "powerpairs")) return 0; | |
309 | if (!strcmp(cmdenv_get(env, "device-type"), "pse") && | |
310 | !cmdenv_get(env, "powerpairs")) return 0; | |
310 | 311 | if (cmdenv_get(env, "typeat")) { |
311 | 312 | return (!!cmdenv_get(env, "source") && |
312 | 313 | !!cmdenv_get(env, "priority") && |
359 | 360 | /* Power pairs */ |
360 | 361 | struct cmd_node *powerpairs = commands_new( |
361 | 362 | configure_dot3power, |
362 | "powerpairs", "Which pairs are currently used for power (mandatory)", | |
363 | cmd_check_type_but_no, NULL, "powerpairs"); | |
363 | "powerpairs", "Which pairs are currently used for power", | |
364 | cmd_check_pse, NULL, "powerpairs"); | |
364 | 365 | for (lldpctl_map_t *pp_map = |
365 | 366 | lldpctl_key_get_map(lldpctl_k_dot3_power_pairs); |
366 | 367 | pp_map->string; |
36 | 36 | "unconfigure", |
37 | 37 | "Unconfigure system settings", |
38 | 38 | NULL, NULL, NULL); |
39 | commands_privileged(configure); | |
40 | commands_privileged(unconfigure); | |
39 | commands_privileged(commands_lock(configure)); | |
40 | commands_privileged(commands_lock(unconfigure)); | |
41 | 41 | cmd_restrict_ports(configure); |
42 | 42 | cmd_restrict_ports(unconfigure); |
43 | 43 |
257 | 257 | lldpctl_atom_foreach(mgmts, mgmt) { |
258 | 258 | tag_datatag(w, "mgmt-ip", "MgmtIP", |
259 | 259 | lldpctl_atom_get_str(mgmt, lldpctl_k_mgmt_ip)); |
260 | if (lldpctl_atom_get_int(mgmt, lldpctl_k_mgmt_iface_index)) | |
261 | tag_datatag(w, "mgmt-iface", "MgmtIface", | |
262 | lldpctl_atom_get_str(mgmt, lldpctl_k_mgmt_iface_index)); | |
260 | 263 | } |
261 | 264 | lldpctl_atom_dec_ref(mgmts); |
262 | 265 | |
427 | 430 | tag_data(w, lldpctl_atom_get_str(dot3_power, |
428 | 431 | lldpctl_k_dot3_power_devicetype));; |
429 | 432 | tag_end(w); |
430 | tag_start(w, "pairs", "Power pairs"); | |
431 | tag_data(w, lldpctl_atom_get_str(dot3_power, | |
432 | lldpctl_k_dot3_power_pairs)); | |
433 | tag_end(w); | |
433 | if (lldpctl_atom_get_int(dot3_power, | |
434 | lldpctl_k_dot3_power_devicetype) == LLDP_DOT3_POWER_PSE) { | |
435 | tag_start(w, "pairs", "Power pairs"); | |
436 | tag_data(w, lldpctl_atom_get_str(dot3_power, | |
437 | lldpctl_k_dot3_power_pairs)); | |
438 | tag_end(w); | |
439 | } | |
434 | 440 | tag_start(w, "class", "Class"); |
435 | 441 | tag_data(w, lldpctl_atom_get_str(dot3_power, |
436 | 442 | lldpctl_k_dot3_power_class)); |
462 | 468 | tag_start(w, "allocated", "PSE allocated power Value"); |
463 | 469 | tag_data(w, lldpctl_atom_get_str(dot3_power, |
464 | 470 | lldpctl_k_dot3_power_allocated)); |
471 | tag_end(w); | |
472 | } | |
473 | ||
474 | /* 802.3bt */ | |
475 | if (lldpctl_atom_get_int(dot3_power, | |
476 | lldpctl_k_dot3_power_type_ext) > LLDP_DOT3_POWER_8023BT_OFF) { | |
477 | tag_start(w, "requested-a", "Requested mode A"); | |
478 | tag_data(w, lldpctl_atom_get_str(dot3_power, | |
479 | lldpctl_k_dot3_power_requested_a)); | |
480 | tag_end(w); | |
481 | tag_start(w, "requested-b", "Requested mode B"); | |
482 | tag_data(w, lldpctl_atom_get_str(dot3_power, | |
483 | lldpctl_k_dot3_power_requested_b)); | |
484 | tag_end(w); | |
485 | tag_start(w, "allocated-a", "Allocated alternative A"); | |
486 | tag_data(w, lldpctl_atom_get_str(dot3_power, | |
487 | lldpctl_k_dot3_power_allocated_a)); | |
488 | tag_end(w); | |
489 | tag_start(w, "allocated-b", "Allocated alternative B"); | |
490 | tag_data(w, lldpctl_atom_get_str(dot3_power, | |
491 | lldpctl_k_dot3_power_allocated_b)); | |
492 | tag_end(w); | |
493 | tag_start(w, "pse-powering-status", "PSE powering status"); | |
494 | tag_data(w, lldpctl_atom_get_str(dot3_power, | |
495 | lldpctl_k_dot3_power_pse_status)); | |
496 | tag_end(w); | |
497 | tag_start(w, "pd-powering-status", "PD powering status"); | |
498 | tag_data(w, lldpctl_atom_get_str(dot3_power, | |
499 | lldpctl_k_dot3_power_pd_status)); | |
500 | tag_end(w); | |
501 | tag_start(w, "power-pairs-ext", "Power pairs extra"); | |
502 | tag_data(w, lldpctl_atom_get_str(dot3_power, | |
503 | lldpctl_k_dot3_power_pse_pairs_ext)); | |
504 | tag_end(w); | |
505 | tag_start(w, "power-class-ext-a", "Class extra A"); | |
506 | tag_data(w, lldpctl_atom_get_str(dot3_power, | |
507 | lldpctl_k_dot3_power_class_a)); | |
508 | tag_end(w); | |
509 | tag_start(w, "power-class-ext-b", "Class extra B"); | |
510 | tag_data(w, lldpctl_atom_get_str(dot3_power, | |
511 | lldpctl_k_dot3_power_class_b)); | |
512 | tag_end(w); | |
513 | tag_start(w, "power-class-ext", "Class extra"); | |
514 | tag_data(w, lldpctl_atom_get_str(dot3_power, | |
515 | lldpctl_k_dot3_power_class_ext)); | |
516 | tag_end(w); | |
517 | tag_start(w, "power-type-ext", "Power type extra"); | |
518 | tag_data(w, lldpctl_atom_get_str(dot3_power, | |
519 | lldpctl_k_dot3_power_type_ext)); | |
520 | tag_end(w); | |
521 | tag_start(w, "pd-load", "PD load"); | |
522 | tag_data(w, lldpctl_atom_get_str(dot3_power, | |
523 | lldpctl_k_dot3_power_pd_load)); | |
524 | tag_end(w); | |
525 | tag_start(w, "max-power", "PSE maximum available power"); | |
526 | tag_data(w, lldpctl_atom_get_str(dot3_power, | |
527 | lldpctl_k_dot3_power_pse_max)); | |
465 | 528 | tag_end(w); |
466 | 529 | } |
467 | 530 | |
489 | 552 | } |
490 | 553 | |
491 | 554 | tx_hold = lldpctl_atom_get_int(configuration, lldpctl_k_config_tx_hold); |
492 | tx_interval = lldpctl_atom_get_int(configuration, lldpctl_k_config_tx_interval); | |
493 | ||
494 | if (asprintf(&ttl, "%lu", tx_hold*tx_interval) == -1) { | |
555 | tx_interval = lldpctl_atom_get_int(configuration, lldpctl_k_config_tx_interval_ms); | |
556 | ||
557 | tx_interval = (tx_interval * tx_hold + 999) / 1000; | |
558 | ||
559 | if (asprintf(&ttl, "%lu", tx_interval) == -1) { | |
495 | 560 | log_warnx("lldpctl", "not enough memory to build TTL."); |
496 | 561 | goto end; |
497 | 562 | } |
518 | 583 | lldpctl_atom_foreach(vlans, vlan) { |
519 | 584 | vid = lldpctl_atom_get_int(vlan, |
520 | 585 | lldpctl_k_vlan_id); |
521 | if (pvid == vid) | |
522 | foundpvid = 1; | |
523 | 586 | |
524 | 587 | tag_start(w, "vlan", "VLAN"); |
525 | 588 | tag_attr(w, "vlan-id", "", |
526 | 589 | lldpctl_atom_get_str(vlan, lldpctl_k_vlan_id)); |
527 | if (pvid == vid) | |
590 | if (pvid == vid) { | |
528 | 591 | tag_attr(w, "pvid", "pvid", "yes"); |
592 | foundpvid = 1; | |
593 | } else { | |
594 | tag_attr(w, "pvid", "pvid", "no"); | |
595 | } | |
529 | 596 | tag_data(w, lldpctl_atom_get_str(vlan, |
530 | 597 | lldpctl_k_vlan_name)); |
531 | 598 | tag_end(w); |
667 | 734 | * |
668 | 735 | * @param conn Connection to lldpd. |
669 | 736 | * @param w Writer. |
737 | * @param env Environment from which we may find the list of ports. | |
670 | 738 | * @param hidden Whatever to show hidden ports. |
671 | * @param env Environment from which we may find the list of ports. | |
672 | 739 | * @param details Level of details we need (DISPLAY_*). |
673 | 740 | */ |
674 | 741 | void |
883 | 950 | |
884 | 951 | tag_datatag(w, "tx-delay", "Transmit delay", |
885 | 952 | lldpctl_atom_get_str(configuration, lldpctl_k_config_tx_interval)); |
953 | tag_datatag(w, "tx-delay-ms", "Transmit delay in milliseconds", | |
954 | lldpctl_atom_get_str(configuration, lldpctl_k_config_tx_interval_ms)); | |
886 | 955 | tag_datatag(w, "tx-hold", "Transmit hold", |
887 | 956 | lldpctl_atom_get_str(configuration, lldpctl_k_config_tx_hold)); |
888 | 957 | tag_datatag(w, "max-neighbors", "Maximum number of neighbors", |
390 | 390 | IPv4 and one IPv6 addresses are chosen. Otherwise, many of them can be |
391 | 391 | selected. If you want to blacklist IPv6 addresses, you can use |
392 | 392 | .Em !*:* . |
393 | If an interface name is matched, the first IPv4 address and the first | |
394 | IPv6 address associated to this interface will be chosen. | |
393 | 395 | .Ed |
394 | 396 | |
395 | 397 | .Cd unconfigure |
501 | 503 | .Bd -ragged -offset XXXXXX |
502 | 504 | Change transmit delay to the specified value in seconds. The transmit |
503 | 505 | delay is the delay between two transmissions of LLDP PDU. The default |
504 | value is 30 seconds. | |
506 | value is 30 seconds. Note: | |
507 | .Nm lldpd | |
508 | also starts another system based refresh timer on each port to detect | |
509 | changes such as a hostname. This is the value of the tx-interval | |
510 | multiplied by 20. | |
511 | .Pp | |
512 | You can specify an | |
513 | .Cd interval | |
514 | value in milliseconds by appending a "ms" suffix to the figure (e.g. | |
515 | "configure lldp tx-interval 1500ms" is 1.5s, not 1500s). In this case | |
516 | the TTL for received and sent LLDP frames is rounded up to the next | |
517 | second. Note: the effective interval can be limited by the operating | |
518 | system capabilities and CPU speed. | |
505 | 519 | .Ed |
506 | 520 | |
507 | 521 | .Cd configure |
891 | 905 | .Op Cd supported |
892 | 906 | .Op Cd enabled |
893 | 907 | .Op Cd paircontrol |
894 | .Cd powerpairs Ar powerpairs | |
908 | .Op Cd powerpairs Ar powerpairs | |
895 | 909 | .Op Cd class Ar class |
896 | 910 | .Op Cd type Ar type Cd source Ar source Cd priority Ar priority Cd requested Ar requested Cd allocated Ar allocated |
897 | 911 | .Bd -ragged -offset XXXXXX |
137 | 137 | |
138 | 138 | result = malloc(sizeof(struct writer)); |
139 | 139 | if (!result) { |
140 | fatalx("llpctl", "out of memory"); | |
140 | fatalx("lldpctl", "out of memory"); | |
141 | 141 | free(priv); |
142 | 142 | return NULL; |
143 | 143 | } |
19 | 19 | interfaces.c \ |
20 | 20 | event.c lldpd.c \ |
21 | 21 | pattern.c \ |
22 | bitmap.c \ | |
22 | 23 | probes.d trace.h \ |
23 | 24 | protocols/lldp.c \ |
24 | 25 | protocols/cdp.c \ |
208 | 208 | $(am__DEPENDENCIES_1) $(am__append_15) |
209 | 209 | am__liblldpd_la_SOURCES_DIST = frame.h frame.c lldp-tlv.h client.c \ |
210 | 210 | priv.c privsep.c privsep_io.c privsep_fd.c interfaces.c \ |
211 | event.c lldpd.c pattern.c probes.d trace.h protocols/lldp.c \ | |
212 | protocols/cdp.c protocols/cdp.h protocols/sonmp.c \ | |
213 | protocols/sonmp.h protocols/edp.c protocols/edp.h \ | |
214 | forward-linux.c interfaces-linux.c netlink.c dmi-linux.c \ | |
215 | priv-linux.c forward-bsd.c interfaces-bpf.c interfaces-bsd.c \ | |
216 | dmi-dummy.c priv-bsd.c dmi-freebsd.c dmi-openbsd.c dmi-osx.c \ | |
217 | forward-solaris.c interfaces-solaris.c priv-seccomp.c | |
211 | event.c lldpd.c pattern.c bitmap.c probes.d trace.h \ | |
212 | protocols/lldp.c protocols/cdp.c protocols/cdp.h \ | |
213 | protocols/sonmp.c protocols/sonmp.h protocols/edp.c \ | |
214 | protocols/edp.h forward-linux.c interfaces-linux.c netlink.c \ | |
215 | dmi-linux.c priv-linux.c forward-bsd.c interfaces-bpf.c \ | |
216 | interfaces-bsd.c dmi-dummy.c priv-bsd.c dmi-freebsd.c \ | |
217 | dmi-openbsd.c dmi-osx.c forward-solaris.c interfaces-solaris.c \ | |
218 | priv-seccomp.c | |
218 | 219 | am__dirstamp = $(am__leading_dot)dirstamp |
219 | 220 | @HOST_OS_LINUX_TRUE@am__objects_1 = liblldpd_la-forward-linux.lo \ |
220 | 221 | @HOST_OS_LINUX_TRUE@ liblldpd_la-interfaces-linux.lo \ |
257 | 258 | liblldpd_la-privsep_io.lo liblldpd_la-privsep_fd.lo \ |
258 | 259 | liblldpd_la-interfaces.lo liblldpd_la-event.lo \ |
259 | 260 | liblldpd_la-lldpd.lo liblldpd_la-pattern.lo \ |
260 | protocols/liblldpd_la-lldp.lo protocols/liblldpd_la-cdp.lo \ | |
261 | protocols/liblldpd_la-sonmp.lo protocols/liblldpd_la-edp.lo \ | |
262 | $(am__objects_1) $(am__objects_2) $(am__objects_3) \ | |
263 | $(am__objects_4) $(am__objects_5) $(am__objects_6) \ | |
264 | $(am__objects_7) $(am__objects_8) | |
261 | liblldpd_la-bitmap.lo protocols/liblldpd_la-lldp.lo \ | |
262 | protocols/liblldpd_la-cdp.lo protocols/liblldpd_la-sonmp.lo \ | |
263 | protocols/liblldpd_la-edp.lo $(am__objects_1) $(am__objects_2) \ | |
264 | $(am__objects_3) $(am__objects_4) $(am__objects_5) \ | |
265 | $(am__objects_6) $(am__objects_7) $(am__objects_8) | |
265 | 266 | am__objects_9 = |
266 | 267 | nodist_liblldpd_la_OBJECTS = $(am__objects_9) |
267 | 268 | liblldpd_la_OBJECTS = $(am_liblldpd_la_OBJECTS) \ |
291 | 292 | DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) |
292 | 293 | depcomp = $(SHELL) $(top_srcdir)/depcomp |
293 | 294 | am__maybe_remake_depfiles = depfiles |
294 | am__depfiles_remade = ./$(DEPDIR)/liblldpd_la-client.Plo \ | |
295 | am__depfiles_remade = ./$(DEPDIR)/liblldpd_la-bitmap.Plo \ | |
296 | ./$(DEPDIR)/liblldpd_la-client.Plo \ | |
295 | 297 | ./$(DEPDIR)/liblldpd_la-dmi-dummy.Plo \ |
296 | 298 | ./$(DEPDIR)/liblldpd_la-dmi-freebsd.Plo \ |
297 | 299 | ./$(DEPDIR)/liblldpd_la-dmi-linux.Plo \ |
600 | 602 | nodist_liblldpd_la_SOURCES = $(am__append_10) |
601 | 603 | liblldpd_la_SOURCES = frame.h frame.c lldp-tlv.h client.c priv.c \ |
602 | 604 | privsep.c privsep_io.c privsep_fd.c interfaces.c event.c \ |
603 | lldpd.c pattern.c probes.d trace.h protocols/lldp.c \ | |
605 | lldpd.c pattern.c bitmap.c probes.d trace.h protocols/lldp.c \ | |
604 | 606 | protocols/cdp.c protocols/cdp.h protocols/sonmp.c \ |
605 | 607 | protocols/sonmp.h protocols/edp.c protocols/edp.h \ |
606 | 608 | $(am__append_1) $(am__append_2) $(am__append_3) \ |
780 | 782 | distclean-compile: |
781 | 783 | -rm -f *.tab.c |
782 | 784 | |
785 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblldpd_la-bitmap.Plo@am__quote@ # am--include-marker | |
783 | 786 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblldpd_la-client.Plo@am__quote@ # am--include-marker |
784 | 787 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblldpd_la-dmi-dummy.Plo@am__quote@ # am--include-marker |
785 | 788 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblldpd_la-dmi-freebsd.Plo@am__quote@ # am--include-marker |
927 | 930 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pattern.c' object='liblldpd_la-pattern.lo' libtool=yes @AMDEPBACKSLASH@ |
928 | 931 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
929 | 932 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblldpd_la_CPPFLAGS) $(CPPFLAGS) $(liblldpd_la_CFLAGS) $(CFLAGS) -c -o liblldpd_la-pattern.lo `test -f 'pattern.c' || echo '$(srcdir)/'`pattern.c |
933 | ||
934 | liblldpd_la-bitmap.lo: bitmap.c | |
935 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblldpd_la_CPPFLAGS) $(CPPFLAGS) $(liblldpd_la_CFLAGS) $(CFLAGS) -MT liblldpd_la-bitmap.lo -MD -MP -MF $(DEPDIR)/liblldpd_la-bitmap.Tpo -c -o liblldpd_la-bitmap.lo `test -f 'bitmap.c' || echo '$(srcdir)/'`bitmap.c | |
936 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblldpd_la-bitmap.Tpo $(DEPDIR)/liblldpd_la-bitmap.Plo | |
937 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bitmap.c' object='liblldpd_la-bitmap.lo' libtool=yes @AMDEPBACKSLASH@ | |
938 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | |
939 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblldpd_la_CPPFLAGS) $(CPPFLAGS) $(liblldpd_la_CFLAGS) $(CFLAGS) -c -o liblldpd_la-bitmap.lo `test -f 'bitmap.c' || echo '$(srcdir)/'`bitmap.c | |
930 | 940 | |
931 | 941 | protocols/liblldpd_la-lldp.lo: protocols/lldp.c |
932 | 942 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblldpd_la_CPPFLAGS) $(CPPFLAGS) $(liblldpd_la_CFLAGS) $(CFLAGS) -MT protocols/liblldpd_la-lldp.lo -MD -MP -MF protocols/$(DEPDIR)/liblldpd_la-lldp.Tpo -c -o protocols/liblldpd_la-lldp.lo `test -f 'protocols/lldp.c' || echo '$(srcdir)/'`protocols/lldp.c |
1336 | 1346 | clean-sbinPROGRAMS mostlyclean-am |
1337 | 1347 | |
1338 | 1348 | distclean: distclean-am |
1339 | -rm -f ./$(DEPDIR)/liblldpd_la-client.Plo | |
1349 | -rm -f ./$(DEPDIR)/liblldpd_la-bitmap.Plo | |
1350 | -rm -f ./$(DEPDIR)/liblldpd_la-client.Plo | |
1340 | 1351 | -rm -f ./$(DEPDIR)/liblldpd_la-dmi-dummy.Plo |
1341 | 1352 | -rm -f ./$(DEPDIR)/liblldpd_la-dmi-freebsd.Plo |
1342 | 1353 | -rm -f ./$(DEPDIR)/liblldpd_la-dmi-linux.Plo |
1416 | 1427 | installcheck-am: |
1417 | 1428 | |
1418 | 1429 | maintainer-clean: maintainer-clean-am |
1419 | -rm -f ./$(DEPDIR)/liblldpd_la-client.Plo | |
1430 | -rm -f ./$(DEPDIR)/liblldpd_la-bitmap.Plo | |
1431 | -rm -f ./$(DEPDIR)/liblldpd_la-client.Plo | |
1420 | 1432 | -rm -f ./$(DEPDIR)/liblldpd_la-dmi-dummy.Plo |
1421 | 1433 | -rm -f ./$(DEPDIR)/liblldpd_la-dmi-freebsd.Plo |
1422 | 1434 | -rm -f ./$(DEPDIR)/liblldpd_la-dmi-linux.Plo |
638 | 638 | |
639 | 639 | switch (vp->magic) { |
640 | 640 | case LLDP_SNMP_TXINTERVAL: |
641 | long_ret = scfg->g_config.c_tx_interval; | |
641 | long_ret = (scfg->g_config.c_tx_interval+999) / 1000; | |
642 | 642 | return (u_char *)&long_ret; |
643 | 643 | case LLDP_SNMP_TXMULTIPLIER: |
644 | long_ret = scfg->g_config.c_ttl / scfg->g_config.c_tx_interval; | |
644 | long_ret = scfg->g_config.c_tx_hold; | |
645 | 645 | return (u_char *)&long_ret; |
646 | 646 | case LLDP_SNMP_REINITDELAY: |
647 | 647 | long_ret = 1; |
32 | 32 | #include <net-snmp/agent/snmp_vars.h> |
33 | 33 | #include <net-snmp/library/snmpUnixDomain.h> |
34 | 34 | |
35 | #ifdef ASN_PRIV_STOP | |
36 | /* NetSNMP 5.8+ */ | |
37 | #define F_SEND_SIGNATURE netsnmp_transport *t, const void *buf, int size, void **opaque, int *olength | |
38 | #define F_FMTADDR_SIGNATURE netsnmp_transport *t, const void *data, int len | |
39 | #define F_FROM_OSTRING_SIGNATURE const void* o, size_t o_len, int local | |
40 | #else | |
41 | #define F_SEND_SIGNATURE netsnmp_transport *t, void *buf, int size, void **opaque, int *olength | |
42 | #define F_FMTADDR_SIGNATURE netsnmp_transport *t, void *data, int len | |
43 | #define F_FROM_OSTRING_SIGNATURE const u_char* o, size_t o_len, int local | |
44 | #endif | |
45 | ||
35 | 46 | static oid netsnmp_unix[] = { TRANSPORT_DOMAIN_LOCAL }; |
36 | 47 | static netsnmp_tdomain unixDomain; |
37 | 48 | |
38 | 49 | static char * |
39 | agent_priv_unix_fmtaddr(netsnmp_transport *t, void *data, int len) | |
50 | agent_priv_unix_fmtaddr(F_FMTADDR_SIGNATURE) | |
40 | 51 | { |
41 | 52 | /* We don't bother to implement the full function */ |
42 | 53 | return strdup("Local Unix socket with privilege separation: unknown"); |
79 | 90 | |
80 | 91 | #define AGENT_WRITE_TIMEOUT 2000 |
81 | 92 | static int |
82 | agent_priv_unix_send(netsnmp_transport *t, void *buf, int size, | |
83 | void **opaque, int *olength) | |
93 | agent_priv_unix_send(F_SEND_SIGNATURE) | |
84 | 94 | { |
85 | 95 | int rc = -1; |
86 | 96 | |
216 | 226 | } |
217 | 227 | |
218 | 228 | static netsnmp_transport * |
219 | agent_priv_unix_create_ostring(const u_char * o, size_t o_len, int local) | |
229 | agent_priv_unix_create_ostring(F_FROM_OSTRING_SIGNATURE) | |
220 | 230 | { |
221 | 231 | return agent_priv_unix_transport((char *)o, o_len, local); |
222 | 232 | } |
0 | /* -*- mode: c; c-file-style: "openbsd" -*- */ | |
1 | /* | |
2 | * Copyright (c) 2020 Vincent Bernat <bernat@luffy.cx> | |
3 | * | |
4 | * Permission to use, copy, modify, and/or distribute this software for any | |
5 | * purpose with or without fee is hereby granted, provided that the above | |
6 | * copyright notice and this permission notice appear in all copies. | |
7 | * | |
8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
15 | */ | |
16 | ||
17 | /* Helpers around bitmaps */ | |
18 | ||
19 | #include "lldpd.h" | |
20 | ||
21 | /* | |
22 | * Set vlan id in the bitmap | |
23 | */ | |
24 | void | |
25 | bitmap_set(uint32_t *bmap, uint16_t vlan_id) | |
26 | { | |
27 | if (vlan_id < MAX_VLAN) | |
28 | bmap[vlan_id / 32] |= (((uint32_t) 1) << (vlan_id % 32)); | |
29 | } | |
30 | ||
31 | /* | |
32 | * Checks if the bitmap is empty | |
33 | */ | |
34 | int | |
35 | bitmap_isempty(uint32_t *bmap) | |
36 | { | |
37 | int i; | |
38 | ||
39 | for (i = 0; i < VLAN_BITMAP_LEN; i++) { | |
40 | if (bmap[i] != 0) | |
41 | return 0; | |
42 | } | |
43 | ||
44 | return 1; | |
45 | } | |
46 | ||
47 | /* | |
48 | * Calculate the number of bits set in the bitmap to get total | |
49 | * number of VLANs | |
50 | */ | |
51 | unsigned int | |
52 | bitmap_numbits(uint32_t *bmap) | |
53 | { | |
54 | unsigned int num = 0; | |
55 | ||
56 | for (int i = 0; (i < VLAN_BITMAP_LEN); i++) { | |
57 | uint32_t v = bmap[i]; | |
58 | v = v - ((v >> 1) & 0x55555555); | |
59 | v = (v & 0x33333333) + ((v >> 2) & 0x33333333); | |
60 | num += (((v + (v >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24; | |
61 | } | |
62 | ||
63 | return num; | |
64 | } |
71 | 71 | if (config->c_tx_interval < 0) { |
72 | 72 | log_debug("rpc", "client asked for immediate retransmission"); |
73 | 73 | } else { |
74 | log_debug("rpc", "client change transmit interval to %d", | |
74 | log_debug("rpc", "client change transmit interval to %d ms", | |
75 | 75 | config->c_tx_interval); |
76 | 76 | cfg->g_config.c_tx_interval = config->c_tx_interval; |
77 | 77 | cfg->g_config.c_ttl = cfg->g_config.c_tx_interval * |
78 | 78 | cfg->g_config.c_tx_hold; |
79 | cfg->g_config.c_ttl = (cfg->g_config.c_ttl + 999) / 1000; | |
79 | 80 | } |
80 | 81 | levent_send_now(cfg); |
81 | 82 | } |
85 | 86 | cfg->g_config.c_tx_hold = config->c_tx_hold; |
86 | 87 | cfg->g_config.c_ttl = cfg->g_config.c_tx_interval * |
87 | 88 | cfg->g_config.c_tx_hold; |
89 | cfg->g_config.c_ttl = (cfg->g_config.c_ttl + 999) / 1000; | |
88 | 90 | } |
89 | 91 | if (CHANGED(c_max_neighbors) && config->c_max_neighbors > 0) { |
90 | 92 | log_debug("rpc", "client change maximum neighbors to %d", |
475 | 475 | levent_update_and_send(evutil_socket_t fd, short what, void *arg) |
476 | 476 | { |
477 | 477 | struct lldpd *cfg = arg; |
478 | struct timeval tv = { cfg->g_config.c_tx_interval, 0 }; | |
478 | struct timeval tv; | |
479 | long interval_ms = cfg->g_config.c_tx_interval; | |
480 | ||
479 | 481 | (void)fd; (void)what; |
480 | 482 | lldpd_loop(cfg); |
481 | 483 | if (cfg->g_iface_event != NULL) |
482 | tv.tv_sec *= 20; | |
484 | interval_ms *= 20; | |
485 | if (interval_ms < 30000) | |
486 | interval_ms = 30000; | |
487 | tv.tv_sec = interval_ms / 1000; | |
488 | tv.tv_usec = (interval_ms % 1000) * 1000; | |
483 | 489 | event_add(cfg->g_main_loop, &tv); |
484 | 490 | } |
485 | 491 | |
821 | 827 | (long)tv.tv_sec); |
822 | 828 | if (event_add(cfg->g_cleanup_timer, &tv) == -1) { |
823 | 829 | log_warnx("event", |
824 | "unable to schedula cleanup task"); | |
830 | "unable to schedule cleanup task"); | |
825 | 831 | event_free(cfg->g_cleanup_timer); |
826 | 832 | cfg->g_cleanup_timer = NULL; |
827 | 833 | return; |
843 | 849 | hardware->h_tx_fast--; |
844 | 850 | |
845 | 851 | if (hardware->h_tx_fast > 0) |
846 | tx_interval = hardware->h_cfg->g_config.c_tx_fast_interval; | |
852 | tx_interval = hardware->h_cfg->g_config.c_tx_fast_interval * 1000; | |
847 | 853 | #endif |
848 | 854 | |
849 | struct timeval tv = { tx_interval, 0 }; | |
855 | struct timeval tv; | |
856 | tv.tv_sec = tx_interval / 1000; | |
857 | tv.tv_usec = (tx_interval % 1000) * 1000; | |
850 | 858 | if (event_add(hardware->h_timer, &tv) == -1) { |
851 | 859 | log_warnx("event", "unable to re-register timer event for port %s", |
852 | 860 | hardware->h_ifname); |
33 | 33 | |
34 | 34 | log_debug("interfaces", "initialize ethernet device %s", |
35 | 35 | hardware->h_ifname); |
36 | if ((fd = priv_iface_init(hardware->h_ifindex, hardware->h_ifname)) == -1) | |
36 | if ((fd = priv_iface_init(hardware->h_ifindex, hardware->h_ifname, 0)) == -1) | |
37 | 37 | return -1; |
38 | 38 | |
39 | 39 | /* Allocate receive buffer */ |
306 | 306 | "%s is VLAN %d of %s", |
307 | 307 | vlan->name, vreq.vlr_tag, lower->name); |
308 | 308 | vlan->lower = lower; |
309 | vlan->vlanid = vreq.vlr_tag; | |
309 | bitmap_set(vlan->vlan_bmap, vreq.vlr_tag); | |
310 | 310 | vlan->type |= IFACE_VLAN_T; |
311 | 311 | } |
312 | 312 | |
671 | 671 | #ifdef ENABLE_DOT1 |
672 | 672 | interfaces_helper_vlan(cfg, interfaces); |
673 | 673 | #endif |
674 | interfaces_helper_mgmt(cfg, addresses); | |
674 | interfaces_helper_mgmt(cfg, addresses, interfaces); | |
675 | 675 | interfaces_helper_chassis(cfg, interfaces); |
676 | 676 | |
677 | 677 | /* Mac/PHY */ |
25 | 25 | #pragma clang diagnostic push |
26 | 26 | #pragma clang diagnostic ignored "-Wdocumentation" |
27 | 27 | #endif |
28 | #include <netinet/in.h> | |
28 | 29 | #include <linux/if_vlan.h> |
29 | 30 | #include <linux/if_bonding.h> |
30 | 31 | #include <linux/if_bridge.h> |
41 | 42 | #define MAX_BRIDGES 1024 |
42 | 43 | |
43 | 44 | static int |
45 | only_lldp(struct lldpd *cfg) | |
46 | { | |
47 | int lldp_enabled = 0; | |
48 | int other_enabled = 0; | |
49 | size_t i; | |
50 | for (i=0; cfg->g_protocols[i].mode != 0; i++) { | |
51 | if (cfg->g_protocols[i].mode == LLDPD_MODE_LLDP) | |
52 | lldp_enabled = cfg->g_protocols[i].enabled; | |
53 | else other_enabled = other_enabled || cfg->g_protocols[i].enabled; | |
54 | } | |
55 | return lldp_enabled && !other_enabled; | |
56 | ||
57 | } | |
58 | ||
59 | static int | |
44 | 60 | iflinux_eth_init(struct lldpd *cfg, struct lldpd_hardware *hardware) |
45 | 61 | { |
46 | 62 | int fd; |
47 | 63 | |
48 | 64 | log_debug("interfaces", "initialize ethernet device %s", |
49 | 65 | hardware->h_ifname); |
50 | if ((fd = priv_iface_init(hardware->h_ifindex, hardware->h_ifname)) == -1) | |
66 | if ((fd = priv_iface_init(hardware->h_ifindex, hardware->h_ifname, | |
67 | only_lldp(cfg)?ETH_P_LLDP:ETH_P_ALL)) == -1) | |
51 | 68 | return -1; |
52 | 69 | hardware->h_sendfd = fd; /* Send */ |
53 | 70 | |
205 | 222 | } |
206 | 223 | |
207 | 224 | iface->lower = lower; |
208 | iface->vlanid = ifv.u.VID; | |
225 | bitmap_set(iface->vlan_bmap, ifv.u.VID); | |
209 | 226 | return 1; |
210 | 227 | } |
211 | 228 | #endif |
659 | 676 | struct bond_master *master = hardware->h_data; |
660 | 677 | int fd; |
661 | 678 | int un = 1; |
679 | int proto; | |
662 | 680 | |
663 | 681 | if (!master) return -1; |
664 | 682 | |
666 | 684 | hardware->h_ifname); |
667 | 685 | |
668 | 686 | /* First, we get a socket to the raw physical interface */ |
687 | proto = only_lldp(cfg)?ETH_P_LLDP:ETH_P_ALL; | |
669 | 688 | if ((fd = priv_iface_init(hardware->h_ifindex, |
670 | hardware->h_ifname)) == -1) | |
689 | hardware->h_ifname, proto)) == -1) | |
671 | 690 | return -1; |
672 | 691 | hardware->h_sendfd = fd; |
673 | 692 | interfaces_setup_multicast(cfg, hardware->h_ifname, 0); |
675 | 694 | /* Then, we open a raw interface for the master */ |
676 | 695 | log_debug("interfaces", "enslaved device %s has master %s(%d)", |
677 | 696 | hardware->h_ifname, master->name, master->index); |
678 | if ((fd = priv_iface_init(master->index, master->name)) == -1) { | |
697 | if ((fd = priv_iface_init(master->index, master->name, proto)) == -1) { | |
679 | 698 | close(hardware->h_sendfd); |
680 | 699 | return -1; |
681 | 700 | } |
1019 | 1038 | #ifdef ENABLE_DOT1 |
1020 | 1039 | interfaces_helper_vlan(cfg, interfaces); |
1021 | 1040 | #endif |
1022 | interfaces_helper_mgmt(cfg, addresses); | |
1041 | interfaces_helper_mgmt(cfg, addresses, interfaces); | |
1023 | 1042 | interfaces_helper_chassis(cfg, interfaces); |
1024 | 1043 | |
1025 | 1044 | /* Mac/PHY */ |
163 | 163 | interfaces_helper_whitelist(cfg, interfaces); |
164 | 164 | interfaces_helper_physical(cfg, interfaces, |
165 | 165 | &bpf_ops, ifbpf_phys_init); |
166 | interfaces_helper_mgmt(cfg, addresses); | |
166 | interfaces_helper_mgmt(cfg, addresses, interfaces); | |
167 | 167 | interfaces_helper_chassis(cfg, interfaces); |
168 | 168 | |
169 | 169 | /* Mac/PHY */ |
210 | 210 | lldpd_get_hardware(cfg, lower->name, lower->index); |
211 | 211 | struct lldpd_port *port; |
212 | 212 | struct lldpd_vlan *v; |
213 | char *name = NULL; | |
214 | uint16_t vlan_id; | |
213 | 215 | |
214 | 216 | if (hardware == NULL) { |
215 | 217 | log_debug("interfaces", |
217 | 219 | lower->name, vlan->name); |
218 | 220 | return; |
219 | 221 | } |
220 | ||
221 | /* Check if the VLAN is already here. */ | |
222 | 222 | port = &hardware->h_lport; |
223 | TAILQ_FOREACH(v, &port->p_vlans, v_entries) | |
224 | if (strncmp(vlan->name, v->v_name, IFNAMSIZ) == 0) | |
225 | return; | |
226 | if ((v = (struct lldpd_vlan *) | |
227 | calloc(1, sizeof(struct lldpd_vlan))) == NULL) | |
228 | return; | |
229 | if ((v->v_name = strdup(vlan->name)) == NULL) { | |
230 | free(v); | |
231 | return; | |
232 | } | |
233 | v->v_vid = vlan->vlanid; | |
234 | log_debug("interfaces", "append VLAN %s for %s", | |
235 | v->v_name, | |
236 | hardware->h_ifname); | |
237 | TAILQ_INSERT_TAIL(&port->p_vlans, v, v_entries); | |
223 | ||
224 | for (int i = 0; (i < VLAN_BITMAP_LEN); i++) { | |
225 | if (vlan->vlan_bmap[i] == 0) | |
226 | continue; | |
227 | for (unsigned bit = 0; bit < 32; bit++) { | |
228 | uint32_t mask = 1L << bit; | |
229 | if (!(vlan->vlan_bmap[i] & mask)) | |
230 | continue; | |
231 | vlan_id = (i * 32) + bit; | |
232 | if (asprintf(&name, "vlan%d", vlan_id) == -1) | |
233 | return; | |
234 | ||
235 | /* Check if the VLAN is already here. */ | |
236 | TAILQ_FOREACH(v, &port->p_vlans, v_entries) | |
237 | if (strncmp(name, v->v_name, IFNAMSIZ) == 0) { | |
238 | free(name); | |
239 | return; | |
240 | } | |
241 | ||
242 | if ((v = (struct lldpd_vlan *) | |
243 | calloc(1, sizeof(struct lldpd_vlan))) == NULL) { | |
244 | free(name); | |
245 | return; | |
246 | } | |
247 | v->v_name = name; | |
248 | v->v_vid = vlan_id; | |
249 | if (vlan->pvid) | |
250 | port->p_pvid = vlan->pvid; | |
251 | log_debug("interfaces", "append VLAN %s for %s", | |
252 | v->v_name, | |
253 | hardware->h_ifname); | |
254 | TAILQ_INSERT_TAIL(&port->p_vlans, v, v_entries); | |
255 | } | |
256 | } | |
238 | 257 | } |
239 | 258 | |
240 | 259 | /** |
254 | 273 | int depth) |
255 | 274 | { |
256 | 275 | if (depth > 5) { |
257 | log_warn("interfaces", | |
276 | log_warnx("interfaces", | |
258 | 277 | "BUG: maximum depth reached when applying VLAN %s (loop?)", |
259 | 278 | vlan->name); |
260 | 279 | return; |
264 | 283 | log_debug("interfaces", |
265 | 284 | "looking to apply VLAN %s to physical interface behind %s", |
266 | 285 | vlan->name, upper->name); |
286 | ||
287 | /* Some bridges managed VLAN internally, skip them. */ | |
288 | if (upper->type & IFACE_BRIDGE_VLAN_T) { | |
289 | log_debug("interfaces", "VLAN %s ignored for VLAN-aware bridge interface %s", | |
290 | vlan->name, upper->name); | |
291 | return; | |
292 | } | |
267 | 293 | |
268 | 294 | /* Easy: check if we have a lower interface. */ |
269 | 295 | if (upper->lower) { |
302 | 328 | struct interfaces_device *iface; |
303 | 329 | |
304 | 330 | TAILQ_FOREACH(iface, interfaces, next) { |
305 | if (iface->ignore) | |
306 | continue; | |
307 | if (!(iface->type & IFACE_VLAN_T)) | |
331 | if (!(iface->type & IFACE_VLAN_T) && bitmap_isempty(iface->vlan_bmap)) | |
308 | 332 | continue; |
309 | 333 | |
310 | 334 | /* We need to find the physical interfaces of this |
389 | 413 | interfaces_helper_mgmt_for_af(struct lldpd *cfg, |
390 | 414 | int af, |
391 | 415 | struct interfaces_address_list *addrs, |
416 | struct interfaces_device_list *interfaces, | |
392 | 417 | int global, int allnegative) |
393 | 418 | { |
394 | 419 | struct interfaces_address *addr; |
420 | struct interfaces_device *device; | |
395 | 421 | struct lldpd_mgmt *mgmt; |
396 | 422 | char addrstrbuf[INET6_ADDRSTRLEN]; |
397 | 423 | int found = 0; |
437 | 463 | continue; |
438 | 464 | } |
439 | 465 | if (cfg->g_config.c_mgmt_pattern == NULL || |
440 | pattern_match(addrstrbuf, cfg->g_config.c_mgmt_pattern, allnegative)) { | |
466 | /* Match on IP address */ | |
467 | pattern_match(addrstrbuf, cfg->g_config.c_mgmt_pattern, allnegative) || | |
468 | /* Match on interface name */ | |
469 | ((device = interfaces_indextointerface(interfaces, addr->index)) && | |
470 | pattern_match(device->name, cfg->g_config.c_mgmt_pattern, allnegative))) { | |
441 | 471 | mgmt = lldpd_alloc_mgmt(af, &in_addr, in_addr_size, |
442 | 472 | addr->index); |
443 | 473 | if (mgmt == NULL) { |
462 | 492 | to the local chassis). */ |
463 | 493 | void |
464 | 494 | interfaces_helper_mgmt(struct lldpd *cfg, |
465 | struct interfaces_address_list *addrs) | |
495 | struct interfaces_address_list *addrs, | |
496 | struct interfaces_device_list *interfaces) | |
466 | 497 | { |
467 | 498 | int allnegative = 0; |
468 | 499 | int af; |
474 | 505 | |
475 | 506 | /* Is the pattern provided an actual IP address? */ |
476 | 507 | if (pattern && strpbrk(pattern, "!,*?") == NULL) { |
477 | struct in6_addr addr; | |
508 | unsigned char addr[sizeof(struct in6_addr)]; | |
478 | 509 | size_t addr_size; |
510 | struct lldpd_mgmt *mgmt; | |
511 | struct interfaces_address *ifaddr; | |
512 | ||
479 | 513 | for (af = LLDPD_AF_UNSPEC + 1; |
480 | 514 | af != LLDPD_AF_LAST; af++) { |
481 | 515 | switch (af) { |
483 | 517 | case LLDPD_AF_IPV6: addr_size = sizeof(struct in6_addr); break; |
484 | 518 | default: assert(0); |
485 | 519 | } |
486 | if (inet_pton(lldpd_af(af), pattern, &addr) == 1) | |
520 | if (inet_pton(lldpd_af(af), pattern, addr) == 1) | |
487 | 521 | break; |
488 | 522 | } |
489 | if (af == LLDPD_AF_LAST) { | |
490 | log_debug("interfaces", | |
491 | "interface management pattern is an incorrect IP"); | |
492 | } else { | |
493 | struct lldpd_mgmt *mgmt; | |
494 | mgmt = lldpd_alloc_mgmt(af, &addr, addr_size, 0); | |
523 | if (af != LLDPD_AF_LAST) { | |
524 | /* Try to get the index if possible. */ | |
525 | TAILQ_FOREACH(ifaddr, addrs, next) { | |
526 | if (ifaddr->address.ss_family != lldpd_af(af)) | |
527 | continue; | |
528 | if (LLDPD_AF_IPV4 == af) { | |
529 | struct sockaddr_in *sa_sin; | |
530 | sa_sin = (struct sockaddr_in *)&ifaddr->address; | |
531 | if (0 == memcmp(addr, | |
532 | &(sa_sin->sin_addr), | |
533 | addr_size)) | |
534 | break; | |
535 | } | |
536 | else if (LLDPD_AF_IPV6 == af) { | |
537 | if (0 == memcmp(addr, | |
538 | &((struct sockaddr_in6 *)&ifaddr->address)->sin6_addr, | |
539 | addr_size)) | |
540 | break; | |
541 | } | |
542 | } | |
543 | ||
544 | mgmt = lldpd_alloc_mgmt(af, addr, addr_size, ifaddr ? ifaddr->index : 0); | |
495 | 545 | if (mgmt == NULL) { |
496 | 546 | log_warn("interfaces", "out of memory error"); |
497 | 547 | return; |
498 | 548 | } |
499 | 549 | log_debug("interfaces", "add exact management address %s", |
500 | pattern); | |
550 | pattern); | |
501 | 551 | TAILQ_INSERT_TAIL(&LOCAL_CHASSIS(cfg)->c_mgmt, mgmt, m_entries); |
502 | } | |
503 | return; | |
552 | return; | |
553 | } | |
554 | /* else: could be an interface name */ | |
504 | 555 | } |
505 | 556 | |
506 | 557 | /* Is the pattern provided all negative? */ |
516 | 567 | |
517 | 568 | /* Find management addresses */ |
518 | 569 | for (af = LLDPD_AF_UNSPEC + 1; af != LLDPD_AF_LAST; af++) { |
519 | (void)(interfaces_helper_mgmt_for_af(cfg, af, addrs, 1, allnegative) || | |
520 | interfaces_helper_mgmt_for_af(cfg, af, addrs, 0, allnegative)); | |
570 | (void)(interfaces_helper_mgmt_for_af(cfg, af, addrs, interfaces, 1, allnegative) || | |
571 | interfaces_helper_mgmt_for_af(cfg, af, addrs, interfaces, 0, allnegative)); | |
521 | 572 | } |
522 | 573 | } |
523 | 574 |
197 | 197 | IPv4 and one IPv6 addresses are chosen. Otherwise, many of them can be |
198 | 198 | selected. If you want to blacklist IPv6 addresses, you can use |
199 | 199 | .Em !*:* . |
200 | If an interface name is matched, the first IPv4 address and the first | |
201 | IPv6 address associated to this interface will be chosen. | |
200 | 202 | .It Fl u Ar file |
201 | 203 | Specify the Unix-domain socket used for communication with |
202 | 204 | .Xr lldpctl 8 . |
661 | 661 | free(oport); |
662 | 662 | } |
663 | 663 | if (ochassis) { |
664 | lldpd_move_chassis(ochassis, chassis); | |
664 | if (port->p_ttl == 0) { | |
665 | /* Shutdown LLDPDU is special. We do not want to replace | |
666 | * the chassis. Free the new chassis (which is mostly empty) */ | |
667 | log_debug("decode", "received a shutdown LLDPDU"); | |
668 | lldpd_chassis_cleanup(chassis, 1); | |
669 | } else { | |
670 | lldpd_move_chassis(ochassis, chassis); | |
671 | } | |
665 | 672 | chassis = ochassis; |
666 | 673 | } else { |
667 | 674 | /* Chassis not known, add it */ |
1000 | 1007 | selected_port->p_power.allocated, |
1001 | 1008 | hardware->h_lport.p_power.allocated); |
1002 | 1009 | hardware->h_lport.p_power.allocated = selected_port->p_power.allocated; |
1010 | hardware->h_lport.p_power.allocated_a = selected_port->p_power.allocated_a; | |
1011 | hardware->h_lport.p_power.allocated_b = selected_port->p_power.allocated_b; | |
1003 | 1012 | levent_schedule_pdu(hardware); |
1004 | 1013 | } |
1005 | 1014 | |
1852 | 1861 | if (lldpcli) |
1853 | 1862 | cfg->g_config.c_paused = 1; |
1854 | 1863 | cfg->g_config.c_receiveonly = receiveonly; |
1855 | cfg->g_config.c_tx_interval = LLDPD_TX_INTERVAL; | |
1864 | cfg->g_config.c_tx_interval = LLDPD_TX_INTERVAL * 1000; | |
1856 | 1865 | cfg->g_config.c_tx_hold = LLDPD_TX_HOLD; |
1857 | 1866 | cfg->g_config.c_ttl = cfg->g_config.c_tx_interval * cfg->g_config.c_tx_hold; |
1867 | cfg->g_config.c_ttl = (cfg->g_config.c_ttl + 999) / 1000; | |
1858 | 1868 | cfg->g_config.c_max_neighbors = LLDPD_MAX_NEIGHBORS; |
1859 | 1869 | #ifdef ENABLE_LLDPMED |
1860 | 1870 | cfg->g_config.c_enable_fast_start = enable_fast_start; |
200 | 200 | int priv_open(char*); |
201 | 201 | void asroot_open(void); |
202 | 202 | #endif |
203 | int priv_iface_init(int, char *); | |
204 | int asroot_iface_init_os(int, char *, int *); | |
203 | int priv_iface_init(int, char *, int); | |
204 | int asroot_iface_init_os(int, char *, int *, int); | |
205 | 205 | int priv_iface_multicast(const char *, const u_int8_t *, int); |
206 | 206 | int priv_iface_description(const char *, const char *); |
207 | 207 | int asroot_iface_description_os(const char *, const char *); |
261 | 261 | (ether dst 00:e0:2b:00:00:00)" |
262 | 262 | */ |
263 | 263 | |
264 | #define ETH_P_LLDP 0x88cc | |
264 | 265 | #define LLDPD_FILTER_F \ |
265 | 266 | { 0x30, 0, 0, 0x00000000 }, \ |
266 | 267 | { 0x54, 0, 0, 0x00000001 }, \ |
267 | 268 | { 0x15, 0, 16, 0x00000001 }, \ |
268 | 269 | { 0x28, 0, 0, 0x0000000c }, \ |
269 | { 0x15, 0, 6, 0x000088cc }, \ | |
270 | { 0x15, 0, 6, ETH_P_LLDP }, \ | |
270 | 271 | { 0x20, 0, 0, 0x00000002 }, \ |
271 | 272 | { 0x15, 2, 0, 0xc200000e }, \ |
272 | 273 | { 0x15, 1, 0, 0xc2000003 }, \ |
296 | 297 | |
297 | 298 | /* interfaces.c */ |
298 | 299 | /* An interface cannot be both physical and (bridge or bond or vlan) */ |
299 | #define IFACE_PHYSICAL_T (1 << 0) /* Physical interface */ | |
300 | #define IFACE_BRIDGE_T (1 << 1) /* Bridge interface */ | |
301 | #define IFACE_BOND_T (1 << 2) /* Bond interface */ | |
302 | #define IFACE_VLAN_T (1 << 3) /* VLAN interface */ | |
303 | #define IFACE_WIRELESS_T (1 << 4) /* Wireless interface */ | |
300 | #define IFACE_PHYSICAL_T (1 << 0) /* Physical interface */ | |
301 | #define IFACE_BRIDGE_T (1 << 1) /* Bridge interface */ | |
302 | #define IFACE_BOND_T (1 << 2) /* Bond interface */ | |
303 | #define IFACE_VLAN_T (1 << 3) /* VLAN interface */ | |
304 | #define IFACE_WIRELESS_T (1 << 4) /* Wireless interface */ | |
305 | #define IFACE_BRIDGE_VLAN_T (1 << 5) /* Bridge-aware VLAN interface */ | |
306 | ||
307 | #define MAX_VLAN 4096 | |
308 | #define VLAN_BITMAP_LEN (MAX_VLAN / 32) | |
304 | 309 | struct interfaces_device { |
305 | 310 | TAILQ_ENTRY(interfaces_device) next; |
306 | 311 | int ignore; /* Ignore this interface */ |
312 | 317 | int flags; /* Flags (IFF_*) */ |
313 | 318 | int mtu; /* MTU */ |
314 | 319 | int type; /* Type (see IFACE_*_T) */ |
315 | int vlanid; /* If a VLAN, what is the VLAN ID? */ | |
320 | uint32_t vlan_bmap[VLAN_BITMAP_LEN]; /* If a VLAN, what are the VLAN ID? */ | |
321 | int pvid; /* If a VLAN, what is the default VLAN? */ | |
316 | 322 | struct interfaces_device *lower; /* Lower interface (for a VLAN for example) */ |
317 | 323 | struct interfaces_device *upper; /* Upper interface (for a bridge or a bond) */ |
318 | 324 | |
360 | 366 | struct lldpd_hardware *, |
361 | 367 | struct interfaces_device *); |
362 | 368 | void interfaces_helper_mgmt(struct lldpd *, |
363 | struct interfaces_address_list *); | |
369 | struct interfaces_address_list *, | |
370 | struct interfaces_device_list *); | |
364 | 371 | #ifdef ENABLE_DOT1 |
365 | 372 | void interfaces_helper_vlan(struct lldpd *, |
366 | 373 | struct interfaces_device_list *); |
381 | 388 | #endif |
382 | 389 | |
383 | 390 | #ifndef HOST_OS_LINUX |
391 | /* interfaces-bpf.c */ | |
384 | 392 | int ifbpf_phys_init(struct lldpd *, struct lldpd_hardware *); |
385 | 393 | #endif |
386 | 394 | |
387 | 395 | /* pattern.c */ |
388 | 396 | int pattern_match(char *, char *, int); |
397 | ||
398 | /* bitmap.c */ | |
399 | void bitmap_set(uint32_t *bmap, uint16_t vlan_id); | |
400 | int bitmap_isempty(uint32_t *bmap); | |
401 | unsigned int bitmap_numbits(uint32_t *bmap); | |
389 | 402 | |
390 | 403 | struct lldpd { |
391 | 404 | int g_sock; |
24 | 24 | #include <net/if_arp.h> |
25 | 25 | #include <linux/netlink.h> |
26 | 26 | #include <linux/rtnetlink.h> |
27 | #include <linux/if_bridge.h> | |
27 | 28 | |
28 | 29 | #define NETLINK_BUFFER 4096 |
29 | 30 | |
30 | 31 | struct netlink_req { |
31 | 32 | struct nlmsghdr hdr; |
32 | struct rtgenmsg gen; | |
33 | struct ifinfomsg ifm; | |
34 | /* attribute has to be NLMSG aligned */ | |
35 | struct rtattr ext_req __attribute__ ((aligned(NLMSG_ALIGNTO))); | |
36 | __u32 ext_filter_mask; | |
33 | 37 | }; |
34 | 38 | |
35 | 39 | struct lldpd_netlink { |
40 | 44 | struct interfaces_address_list *addresses; |
41 | 45 | }; |
42 | 46 | |
43 | ||
44 | 47 | /** |
45 | 48 | * Set netlink socket buffer size. |
46 | 49 | * |
140 | 143 | { |
141 | 144 | struct netlink_req req = { |
142 | 145 | .hdr = { |
143 | .nlmsg_len = NLMSG_LENGTH(sizeof(struct rtgenmsg)), | |
146 | .nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)), | |
144 | 147 | .nlmsg_type = type, |
145 | 148 | .nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP, |
146 | 149 | .nlmsg_seq = seq, |
147 | 150 | .nlmsg_pid = getpid() }, |
148 | .gen = { .rtgen_family = family } | |
151 | .ifm = { .ifi_family = family } | |
149 | 152 | }; |
150 | 153 | struct iovec iov = { |
151 | 154 | .iov_base = &req, |
159 | 162 | .msg_namelen = sizeof(struct sockaddr_nl) |
160 | 163 | }; |
161 | 164 | |
165 | if (family == AF_BRIDGE) { | |
166 | unsigned int len = RTA_LENGTH(sizeof(__u32)); | |
167 | /* request bridge vlan attributes */ | |
168 | req.ext_req.rta_type = IFLA_EXT_MASK; | |
169 | req.ext_req.rta_len = len; | |
170 | req.ext_filter_mask = RTEXT_FILTER_BRVLAN; | |
171 | req.hdr.nlmsg_len = NLMSG_ALIGN(req.hdr.nlmsg_len) + RTA_ALIGN(len); | |
172 | iov.iov_len = req.hdr.nlmsg_len; | |
173 | } | |
174 | ||
162 | 175 | /* Send netlink message. This is synchronous but we are guaranteed |
163 | 176 | * to not block. */ |
164 | 177 | log_debug("netlink", "sending netlink message"); |
192 | 205 | { |
193 | 206 | struct rtattr *link_info_attrs[IFLA_INFO_MAX+1] = {}; |
194 | 207 | char *kind = NULL; |
208 | uint16_t vlan_id; | |
195 | 209 | |
196 | 210 | netlink_parse_rtattr(link_info_attrs, IFLA_INFO_MAX, rta, len); |
197 | 211 | |
225 | 239 | RTA_PAYLOAD(link_info_attrs[IFLA_INFO_DATA])); |
226 | 240 | |
227 | 241 | if (vlan_link_info_data_attrs[IFLA_VLAN_ID]) { |
228 | iff->vlanid = *(uint16_t *)RTA_DATA(vlan_link_info_data_attrs[IFLA_VLAN_ID]); | |
242 | vlan_id = *(uint16_t *)RTA_DATA(vlan_link_info_data_attrs[IFLA_VLAN_ID]); | |
243 | bitmap_set(iff->vlan_bmap, vlan_id); | |
229 | 244 | log_debug("netlink", "VLAN ID for interface %s is %d", |
230 | iff->name, iff->vlanid); | |
245 | iff->name, vlan_id); | |
246 | } | |
247 | } | |
248 | ||
249 | if (kind && !strcmp(kind, "bridge") && link_info_attrs[IFLA_INFO_DATA]) { | |
250 | struct rtattr *bridge_link_info_data_attrs[IFLA_BR_MAX+1] = {}; | |
251 | netlink_parse_rtattr(bridge_link_info_data_attrs, IFLA_BR_MAX, | |
252 | RTA_DATA(link_info_attrs[IFLA_INFO_DATA]), | |
253 | RTA_PAYLOAD(link_info_attrs[IFLA_INFO_DATA])); | |
254 | ||
255 | if (bridge_link_info_data_attrs[IFLA_BR_VLAN_FILTERING] && | |
256 | *(uint8_t *)RTA_DATA(bridge_link_info_data_attrs[IFLA_BR_VLAN_FILTERING]) > 0) { | |
257 | iff->type |= IFACE_BRIDGE_VLAN_T; | |
231 | 258 | } |
232 | 259 | } |
233 | 260 | |
234 | 261 | free(kind); |
262 | } | |
263 | ||
264 | /** | |
265 | * Parse a `afspec` attributes. | |
266 | * | |
267 | * @param iff where to put the result | |
268 | * @param rta afspec attribute | |
269 | * @param len length of attributes | |
270 | */ | |
271 | static void | |
272 | netlink_parse_afspec(struct interfaces_device *iff, struct rtattr *rta, int len) | |
273 | { | |
274 | while (RTA_OK(rta, len)) { | |
275 | struct bridge_vlan_info *vinfo; | |
276 | switch (rta->rta_type) { | |
277 | case IFLA_BRIDGE_VLAN_INFO: | |
278 | vinfo = RTA_DATA(rta); | |
279 | log_debug("netlink", "found VLAN %d on interface %s", | |
280 | vinfo->vid, iff->name ? iff->name : "(unknown)"); | |
281 | ||
282 | bitmap_set(iff->vlan_bmap, vinfo->vid); | |
283 | if (vinfo->flags & (BRIDGE_VLAN_INFO_PVID | BRIDGE_VLAN_INFO_UNTAGGED)) | |
284 | iff->pvid = vinfo->vid; | |
285 | break; | |
286 | default: | |
287 | log_debug("netlink", "unknown afspec attribute type %d for iface %s", | |
288 | rta->rta_type, iff->name ? iff->name : "(unknown)"); | |
289 | break; | |
290 | } | |
291 | rta = RTA_NEXT(rta, len); | |
292 | } | |
293 | /* All enbridged interfaces will have VLAN 1 by default, ignore it */ | |
294 | if (iff->vlan_bmap[0] == 2 && (bitmap_numbits(iff->vlan_bmap) == 1) | |
295 | && iff->pvid == 1) { | |
296 | log_debug("netlink", "found only default VLAN 1 on interface %s, removing", | |
297 | iff->name ? iff->name : "(unknown)"); | |
298 | iff->vlan_bmap[0] = iff->pvid = 0; | |
299 | } | |
235 | 300 | } |
236 | 301 | |
237 | 302 | /** |
282 | 347 | break; |
283 | 348 | case IFLA_LINK: |
284 | 349 | /* Index of "lower" interface */ |
285 | iff->lower_idx = *(int*)RTA_DATA(attribute); | |
286 | log_debug("netlink", "attribute IFLA_LINK for %s: %d", | |
287 | iff->name ? iff->name : "(unknown)", iff->lower_idx); | |
350 | if (iff->lower_idx == -1) { | |
351 | iff->lower_idx = *(int*)RTA_DATA(attribute); | |
352 | log_debug("netlink", "attribute IFLA_LINK for %s: %d", | |
353 | iff->name ? iff->name : "(unknown)", iff->lower_idx); | |
354 | } else { | |
355 | log_debug("netlink", "attribute IFLA_LINK for %s: %d (ignored)", | |
356 | iff->name ? iff->name : "(unknown)", iff->lower_idx); | |
357 | } | |
288 | 358 | break; |
289 | 359 | case IFLA_LINK_NETNSID: |
290 | 360 | /* Is the lower interface into another namesapce? */ |
291 | iff->lower_idx = -1; | |
361 | iff->lower_idx = -2; | |
292 | 362 | log_debug("netlink", "attribute IFLA_LINK_NETNSID received for %s", |
293 | 363 | iff->name ? iff->name : "(unknown)"); |
294 | 364 | break; |
302 | 372 | break; |
303 | 373 | case IFLA_LINKINFO: |
304 | 374 | netlink_parse_linkinfo(iff, RTA_DATA(attribute), RTA_PAYLOAD(attribute)); |
375 | break; | |
376 | case IFLA_AF_SPEC: | |
377 | if (ifi->ifi_family != AF_BRIDGE) break; | |
378 | netlink_parse_afspec(iff, RTA_DATA(attribute), RTA_PAYLOAD(attribute)); | |
305 | 379 | break; |
306 | 380 | default: |
307 | 381 | log_debug("netlink", "unhandled link attribute type %d for iface %s", |
320 | 394 | * and we don't want to miss it. */ |
321 | 395 | iff->flags &= ~IFF_SLAVE; |
322 | 396 | } |
397 | if (iff->lower_idx == -2) | |
398 | iff->lower_idx = -1; | |
323 | 399 | |
324 | 400 | if (ifi->ifi_family == AF_BRIDGE && msg->nlmsg_type == RTM_DELLINK && iff->upper_idx != -1) { |
325 | 401 | log_debug("netlink", "removal of %s from bridge %d", |
326 | 402 | iff->name, iff->upper_idx); |
327 | 403 | msg->nlmsg_type = RTM_NEWLINK; |
328 | 404 | iff->upper_idx = -1; |
329 | } else if (ifi->ifi_family != 0) { | |
330 | log_debug("netlink", "skip non-generic message update %d at index %d", | |
331 | ifi->ifi_type, ifi->ifi_index); | |
332 | return -1; | |
333 | 405 | } |
334 | 406 | |
335 | 407 | log_debug("netlink", "parsed link %d (%s, flags: %d)", |
422 | 494 | new->mtu = old->mtu; |
423 | 495 | if (new->type == 0) |
424 | 496 | new->type = old->type; |
425 | if (new->vlanid == 0) | |
426 | new->vlanid = old->vlanid; | |
497 | ||
498 | if (bitmap_isempty(new->vlan_bmap) && new->type == IFACE_VLAN_T) | |
499 | memcpy((void *)new->vlan_bmap, (void *)old->vlan_bmap, | |
500 | sizeof(uint32_t) * VLAN_BITMAP_LEN); | |
427 | 501 | |
428 | 502 | /* It's not possible for lower link to change */ |
429 | 503 | new->lower_idx = old->lower_idx; |
687 | 761 | if (iface2->lower_idx == iface1->index) { |
688 | 762 | iface1->lower = NULL; |
689 | 763 | log_debug("netlink", |
690 | "link loop detected between %s and %s", | |
691 | iface1->name, iface2->name); | |
764 | "link loop detected between %s(%d) and %s(%d)", | |
765 | iface1->name, | |
766 | iface1->index, | |
767 | iface2->name, | |
768 | iface2->index); | |
692 | 769 | } else { |
693 | 770 | log_debug("netlink", |
694 | 771 | "lower interface for %s is %s", |
758 | 835 | static int |
759 | 836 | netlink_initialize(struct lldpd *cfg) |
760 | 837 | { |
838 | #ifdef ENABLE_DOT1 | |
839 | struct interfaces_device *iff; | |
840 | #endif | |
841 | ||
761 | 842 | if (cfg->g_netlink) return 0; |
762 | 843 | |
763 | 844 | log_debug("netlink", "initialize netlink subsystem"); |
793 | 874 | if (netlink_send(cfg->g_netlink->nl_socket, RTM_GETLINK, AF_PACKET, 2) == -1) |
794 | 875 | goto end; |
795 | 876 | netlink_recv(cfg, ifs, NULL); |
877 | #ifdef ENABLE_DOT1 | |
878 | /* If we have a bridge, search for VLAN-aware bridges */ | |
879 | TAILQ_FOREACH(iff, ifs, next) { | |
880 | if (iff->type & IFACE_BRIDGE_T) { | |
881 | log_debug("netlink", "interface %s is a bridge, check for VLANs", iff->name); | |
882 | if (netlink_send(cfg->g_netlink->nl_socket, RTM_GETLINK, AF_BRIDGE, 3) == -1) | |
883 | goto end; | |
884 | netlink_recv(cfg, ifs, NULL); | |
885 | break; | |
886 | } | |
887 | } | |
888 | #endif | |
796 | 889 | |
797 | 890 | /* Listen to any future change */ |
798 | 891 | cfg->g_iface_cb = netlink_change_cb; |
26 | 26 | #include <string.h> |
27 | 27 | |
28 | 28 | int |
29 | asroot_iface_init_os(int ifindex, char *name, int *fd) | |
29 | asroot_iface_init_os(int ifindex, char *name, int *fd, int proto) | |
30 | 30 | { |
31 | 31 | int enable, required, rc; |
32 | 32 | struct bpf_insn filter[] = { LLDPD_FILTER_F }; |
114 | 114 | } |
115 | 115 | |
116 | 116 | int |
117 | asroot_iface_init_os(int ifindex, char *name, int *fd) | |
117 | asroot_iface_init_os(int ifindex, char *name, int *fd, int proto) | |
118 | 118 | { |
119 | 119 | int rc; |
120 | 120 | /* Open listening socket to receive/send frames */ |
121 | 121 | if ((*fd = socket(PF_PACKET, SOCK_RAW, |
122 | htons(ETH_P_ALL))) < 0) { | |
122 | htons(proto))) < 0) { | |
123 | 123 | rc = errno; |
124 | 124 | return rc; |
125 | 125 | } |
119 | 119 | |
120 | 120 | |
121 | 121 | int |
122 | priv_iface_init(int index, char *iface) | |
122 | priv_iface_init(int index, char *iface, int proto) | |
123 | 123 | { |
124 | 124 | int rc; |
125 | 125 | char dev[IFNAMSIZ] = {}; |
128 | 128 | must_write(PRIV_UNPRIVILEGED, &index, sizeof(int)); |
129 | 129 | strlcpy(dev, iface, IFNAMSIZ); |
130 | 130 | must_write(PRIV_UNPRIVILEGED, dev, IFNAMSIZ); |
131 | must_write(PRIV_UNPRIVILEGED, &proto, sizeof(int)); | |
131 | 132 | priv_wait(); |
132 | 133 | must_read(PRIV_UNPRIVILEGED, &rc, sizeof(int)); |
133 | 134 | if (rc != 0) return -1; |
249 | 250 | { |
250 | 251 | int rc = -1, fd = -1; |
251 | 252 | int ifindex; |
253 | int proto; | |
252 | 254 | char name[IFNAMSIZ]; |
253 | 255 | must_read(PRIV_PRIVILEGED, &ifindex, sizeof(ifindex)); |
254 | 256 | must_read(PRIV_PRIVILEGED, &name, sizeof(name)); |
255 | 257 | name[sizeof(name) - 1] = '\0'; |
258 | must_read(PRIV_PRIVILEGED, &proto, sizeof(proto)) | |
256 | 259 | |
257 | 260 | TRACE(LLDPD_PRIV_INTERFACE_INIT(name)); |
258 | rc = asroot_iface_init_os(ifindex, name, &fd); | |
261 | rc = asroot_iface_init_os(ifindex, name, &fd, proto); | |
259 | 262 | must_write(PRIV_PRIVILEGED, &rc, sizeof(rc)); |
260 | 263 | if (rc == 0 && fd >=0) send_fd(PRIV_PRIVILEGED, fd); |
261 | 264 | if (fd >= 0) close(fd); |
307 | 307 | goto malformed; |
308 | 308 | } |
309 | 309 | port->p_ttl = cfg?cfg->g_config.c_tx_interval * cfg->g_config.c_tx_hold:0; |
310 | port->p_ttl = (port->p_ttl + 999) / 1000; | |
310 | 311 | chassis->c_id_subtype = LLDP_CHASSISID_SUBTYPE_LLADDR; |
311 | 312 | chassis->c_id_len = ETHER_ADDR_LEN; |
312 | 313 | if ((chassis->c_id = (char *)malloc(ETHER_ADDR_LEN)) == NULL) { |
293 | 293 | /* Power */ |
294 | 294 | if (port->p_power.devicetype) { |
295 | 295 | if (!( |
296 | POKE_START_LLDP_TLV(LLDP_TLV_ORG) && | |
296 | (port->p_power.type_ext != LLDP_DOT3_POWER_8023BT_OFF ? | |
297 | (tlv = pos, POKE_UINT16((LLDP_TLV_ORG << 9) | (0x1d))): | |
298 | POKE_START_LLDP_TLV(LLDP_TLV_ORG)) && | |
297 | 299 | POKE_BYTES(dot3, sizeof(dot3)) && |
298 | 300 | POKE_UINT8(LLDP_TLV_DOT3_POWER) && |
299 | 301 | POKE_UINT8(( |
300 | (((2 - port->p_power.devicetype) %(1<< 1))<<0) | | |
301 | (( port->p_power.supported %(1<< 1))<<1) | | |
302 | (( port->p_power.enabled %(1<< 1))<<2) | | |
303 | (( port->p_power.paircontrol %(1<< 1))<<3))) && | |
302 | (((2 - port->p_power.devicetype) %(1<< 1))<<0) | | |
303 | (( port->p_power.supported %(1<< 1))<<1) | | |
304 | (( port->p_power.enabled %(1<< 1))<<2) | | |
305 | (( port->p_power.paircontrol %(1<< 1))<<3))) && | |
304 | 306 | POKE_UINT8(port->p_power.pairs) && |
305 | 307 | POKE_UINT8(port->p_power.class))) |
306 | 308 | goto toobig; |
307 | 309 | /* 802.3at */ |
308 | 310 | if (port->p_power.powertype != LLDP_DOT3_POWER_8023AT_OFF) { |
309 | 311 | if (!( |
310 | POKE_UINT8(( | |
311 | (((port->p_power.powertype == | |
312 | POKE_UINT8(((((port->p_power.powertype == | |
312 | 313 | LLDP_DOT3_POWER_8023AT_TYPE1)?1:0) << 7) | |
313 | (((port->p_power.devicetype == | |
314 | (((port->p_power.devicetype == | |
314 | 315 | LLDP_DOT3_POWER_PSE)?0:1) << 6) | |
315 | ((port->p_power.source %(1<< 2))<<4) | | |
316 | ((port->p_power.priority %(1<< 2))<<0))) && | |
317 | POKE_UINT16(port->p_power.requested) && | |
318 | POKE_UINT16(port->p_power.allocated))) | |
316 | ((port->p_power.source %(1<< 2))<<4) | | |
317 | ((port->p_power.pd_4pid %(1 << 1))<<2) | | |
318 | ((port->p_power.priority %(1<< 2))<<0))) && | |
319 | POKE_UINT16(port->p_power.requested) && | |
320 | POKE_UINT16(port->p_power.allocated))) | |
319 | 321 | goto toobig; |
320 | 322 | } |
321 | if (!(POKE_END_LLDP_TLV)) | |
322 | goto toobig; | |
323 | if (port->p_power.type_ext != LLDP_DOT3_POWER_8023BT_OFF) { | |
324 | if (!( | |
325 | POKE_UINT16(port->p_power.requested_a) && | |
326 | POKE_UINT16(port->p_power.requested_b) && | |
327 | POKE_UINT16(port->p_power.allocated_a) && | |
328 | POKE_UINT16(port->p_power.allocated_b) && | |
329 | POKE_UINT16(( | |
330 | (port->p_power.pse_status << 14) | | |
331 | (port->p_power.pd_status << 12) | | |
332 | (port->p_power.pse_pairs_ext << 10) | | |
333 | (port->p_power.class_a << 7) | | |
334 | (port->p_power.class_b << 4) | | |
335 | (port->p_power.class_ext << 0))) && | |
336 | POKE_UINT8( | |
337 | /* Adjust by -1 to enable 0 to mean no 802.3bt support */ | |
338 | ((port->p_power.type_ext -1) << 1) | | |
339 | (port->p_power.pd_load << 0)) && | |
340 | POKE_UINT16(port->p_power.pse_max) && | |
341 | /* Send 0 for autoclass and power down requests */ | |
342 | POKE_UINT8(0) && | |
343 | POKE_UINT16(0) && | |
344 | POKE_UINT8(0))) | |
345 | goto toobig; | |
346 | } | |
347 | if (!(POKE_END_LLDP_TLV)) | |
348 | goto toobig; | |
323 | 349 | } |
324 | 350 | #endif |
325 | 351 | |
491 | 517 | return 0; |
492 | 518 | |
493 | 519 | toobig: |
520 | log_info("lldp", "Cannot send LLDP packet for %s, Too big message", p_id); | |
494 | 521 | free(packet); |
495 | 522 | return E2BIG; |
496 | 523 | } |
574 | 601 | hardware->h_ifname); \ |
575 | 602 | goto malformed; \ |
576 | 603 | } } while (0) |
604 | #define CHECK_TLV_MAX_SIZE(x, name) \ | |
605 | do { if (tlv_size > (x)) { \ | |
606 | log_warnx("lldp", name " TLV too large received on %s", \ | |
607 | hardware->h_ifname); \ | |
608 | goto malformed; \ | |
609 | } } while (0) | |
577 | 610 | |
578 | 611 | int |
579 | 612 | lldp_decode(struct lldpd *cfg, char *frame, int s, |
589 | 622 | const char dcbx[] = LLDP_TLV_ORG_DCBX; |
590 | 623 | unsigned char orgid[3]; |
591 | 624 | int length, gotend = 0, ttl_received = 0; |
592 | int tlv_size, tlv_type, tlv_subtype; | |
625 | int tlv_size, tlv_type, tlv_subtype, tlv_count = 0; | |
593 | 626 | u_int8_t *pos, *tlv; |
594 | 627 | char *b; |
595 | 628 | #ifdef ENABLE_DOT1 |
666 | 699 | hardware->h_ifname); |
667 | 700 | goto malformed; |
668 | 701 | } |
702 | /* Check order for mandatory TLVs */ | |
703 | tlv_count++; | |
704 | switch (tlv_type) { | |
705 | case LLDP_TLV_CHASSIS_ID: | |
706 | if (tlv_count != 1) { | |
707 | log_warnx("lldp", "first TLV should be a chassis ID on %s, not %d", | |
708 | hardware->h_ifname, tlv_type); | |
709 | goto malformed; | |
710 | } | |
711 | break; | |
712 | case LLDP_TLV_PORT_ID: | |
713 | if (tlv_count != 2) { | |
714 | log_warnx("lldp", "second TLV should be a port ID on %s, not %d", | |
715 | hardware->h_ifname, tlv_type); | |
716 | goto malformed; | |
717 | } | |
718 | break; | |
719 | case LLDP_TLV_TTL: | |
720 | if (tlv_count != 3) { | |
721 | log_warnx("lldp", "third TLV should be a TTL on %s, not %d", | |
722 | hardware->h_ifname, tlv_type); | |
723 | goto malformed; | |
724 | } | |
725 | break; | |
726 | } | |
727 | ||
669 | 728 | switch (tlv_type) { |
670 | 729 | case LLDP_TLV_END: |
671 | 730 | if (tlv_size != 0) { |
680 | 739 | break; |
681 | 740 | case LLDP_TLV_CHASSIS_ID: |
682 | 741 | case LLDP_TLV_PORT_ID: |
683 | CHECK_TLV_SIZE(2, "Port Id"); | |
742 | CHECK_TLV_SIZE(2, "Port/Chassis Id"); | |
743 | CHECK_TLV_MAX_SIZE(256, "Port/Chassis Id"); | |
684 | 744 | tlv_subtype = PEEK_UINT8; |
685 | 745 | if ((tlv_subtype == 0) || (tlv_subtype > 7)) { |
686 | 746 | log_warnx("lldp", "unknown subtype for tlv id received on %s", |
695 | 755 | } |
696 | 756 | PEEK_BYTES(b, tlv_size - 1); |
697 | 757 | if (tlv_type == LLDP_TLV_PORT_ID) { |
758 | if (port->p_id != NULL) { | |
759 | log_warnx("lldp", "Port ID TLV received twice on %s", | |
760 | hardware->h_ifname); | |
761 | free(b); | |
762 | goto malformed; | |
763 | } | |
698 | 764 | port->p_id_subtype = tlv_subtype; |
699 | 765 | port->p_id = b; |
700 | 766 | port->p_id_len = tlv_size - 1; |
701 | 767 | } else { |
768 | if (chassis->c_id != NULL) { | |
769 | log_warnx("lldp", "Chassis ID TLV received twice on %s", | |
770 | hardware->h_ifname); | |
771 | free(b); | |
772 | goto malformed; | |
773 | } | |
702 | 774 | chassis->c_id_subtype = tlv_subtype; |
703 | 775 | chassis->c_id = b; |
704 | 776 | chassis->c_id_len = tlv_size - 1; |
705 | 777 | } |
706 | 778 | break; |
707 | 779 | case LLDP_TLV_TTL: |
780 | if (ttl_received) { | |
781 | log_warnx("lldp", "TTL TLV received twice on %s", | |
782 | hardware->h_ifname); | |
783 | goto malformed; | |
784 | } | |
708 | 785 | CHECK_TLV_SIZE(2, "TTL"); |
709 | 786 | port->p_ttl = PEEK_UINT16; |
710 | 787 | ttl_received = 1; |
922 | 999 | } else |
923 | 1000 | port->p_power.powertype = |
924 | 1001 | LLDP_DOT3_POWER_8023AT_OFF; |
1002 | /* 802.3bt? */ | |
1003 | if (tlv_size >= 29) { | |
1004 | port->p_power.requested_a = PEEK_UINT16; | |
1005 | port->p_power.requested_b = PEEK_UINT16; | |
1006 | port->p_power.allocated_a = PEEK_UINT16; | |
1007 | port->p_power.allocated_b = PEEK_UINT16; | |
1008 | port->p_power.pse_status = PEEK_UINT16; | |
1009 | port->p_power.pd_status = | |
1010 | (port->p_power.pse_status & (1<<13 | 1<<12)) >> 12; | |
1011 | port->p_power.pse_pairs_ext = | |
1012 | (port->p_power.pse_status & (1<<11 | 1<<10)) >> 10; | |
1013 | port->p_power.class_a = | |
1014 | (port->p_power.pse_status & (1<<9 | 1<<8 | 1<<7)) >> 7; | |
1015 | port->p_power.class_b = | |
1016 | (port->p_power.pse_status & (1<<6 | 1<<5 | 1<<4)) >> 4; | |
1017 | port->p_power.class_ext = | |
1018 | (port->p_power.pse_status & 0xf); | |
1019 | port->p_power.pse_status = | |
1020 | (port->p_power.pse_status & (1<<15 | 1<<14)) >> 14; | |
1021 | port->p_power.type_ext = PEEK_UINT8; | |
1022 | port->p_power.pd_load = | |
1023 | (port->p_power.type_ext & 0x1); | |
1024 | port->p_power.type_ext = | |
1025 | ((port->p_power.type_ext & (1<<3 | 1<<2 | 1<<1)) + 1); | |
1026 | port->p_power.pse_max = PEEK_UINT16; | |
1027 | } else { | |
1028 | port->p_power.type_ext = | |
1029 | LLDP_DOT3_POWER_8023BT_OFF; | |
1030 | } | |
925 | 1031 | break; |
926 | 1032 | default: |
927 | 1033 | /* Unknown Dot3 TLV, ignore it */ |
1147 | 1253 | log_warnx("lldp", "unknown tlv (%d) received on %s", |
1148 | 1254 | tlv_type, hardware->h_ifname); |
1149 | 1255 | hardware->h_rx_unrecognized_cnt++; |
1150 | goto malformed; | |
1256 | break; | |
1151 | 1257 | } |
1152 | 1258 | if (pos > tlv + tlv_size) { |
1153 | 1259 | log_warnx("lldp", "BUG: already past TLV!"); |
366 | 366 | TAILQ_INSERT_TAIL(&chassis->c_mgmt, mgmt, m_entries); |
367 | 367 | port->p_ttl = cfg?(cfg->g_config.c_tx_interval * cfg->g_config.c_tx_hold): |
368 | 368 | LLDPD_TTL; |
369 | port->p_ttl = (port->p_ttl + 999) / 1000; | |
369 | 370 | |
370 | 371 | port->p_id_subtype = LLDP_PORTID_SUBTYPE_LOCAL; |
371 | 372 | if (asprintf(&port->p_id, "%02x-%02x-%02x", |
321 | 321 | return SET_ERROR(conn, LLDPCTL_ERR_SERIALIZATION); |
322 | 322 | conn->state = state_send; |
323 | 323 | if (state_data) |
324 | conn->state_data = strdup(state_data); | |
324 | strlcpy(conn->state_data, state_data, sizeof(conn->state_data)); | |
325 | else | |
326 | conn->state_data[0] = 0; | |
325 | 327 | } |
326 | 328 | if (conn->state == state_send && |
327 | (state_data == NULL || !strcmp(conn->state_data, state_data))) { | |
329 | (state_data == NULL || !strncmp(conn->state_data, state_data, sizeof(conn->state_data)))) { | |
328 | 330 | /* We need to send the currently built message */ |
329 | 331 | rc = lldpctl_send(conn); |
330 | 332 | if (rc < 0) |
332 | 334 | conn->state = state_recv; |
333 | 335 | } |
334 | 336 | if (conn->state == state_recv && |
335 | (state_data == NULL || !strcmp(conn->state_data, state_data))) { | |
337 | (state_data == NULL || !strncmp(conn->state_data, state_data, sizeof(conn->state_data)))) { | |
336 | 338 | /* We need to receive the answer */ |
337 | 339 | while ((rc = ctl_msg_recv_unserialized(&conn->input_buffer, |
338 | 340 | &conn->input_buffer_len, |
346 | 348 | return SET_ERROR(conn, LLDPCTL_ERR_SERIALIZATION); |
347 | 349 | /* rc == 0 */ |
348 | 350 | conn->state = CONN_STATE_IDLE; |
349 | free(conn->state_data); | |
350 | conn->state_data = NULL; | |
351 | conn->state_data[0] = 0; | |
351 | 352 | return 0; |
352 | 353 | } else |
353 | 354 | return SET_ERROR(conn, LLDPCTL_ERR_INVALID_STATE); |
46 | 46 | #define CONN_STATE_SET_WATCH_SEND 7 |
47 | 47 | #define CONN_STATE_SET_WATCH_RECV 8 |
48 | 48 | #define CONN_STATE_GET_CONFIG_SEND 9 |
49 | #define CONN_STATE_GET_CONFIG_RECV 9 | |
50 | #define CONN_STATE_SET_CONFIG_SEND 10 | |
51 | #define CONN_STATE_SET_CONFIG_RECV 11 | |
52 | #define CONN_STATE_GET_CHASSIS_SEND 12 | |
53 | #define CONN_STATE_GET_CHASSIS_RECV 13 | |
54 | #define CONN_STATE_GET_DEFAULT_PORT_SEND 14 | |
55 | #define CONN_STATE_GET_DEFAULT_PORT_RECV 15 | |
49 | #define CONN_STATE_GET_CONFIG_RECV 10 | |
50 | #define CONN_STATE_SET_CONFIG_SEND 11 | |
51 | #define CONN_STATE_SET_CONFIG_RECV 12 | |
52 | #define CONN_STATE_GET_CHASSIS_SEND 13 | |
53 | #define CONN_STATE_GET_CHASSIS_RECV 14 | |
54 | #define CONN_STATE_GET_DEFAULT_PORT_SEND 15 | |
55 | #define CONN_STATE_GET_DEFAULT_PORT_RECV 16 | |
56 | 56 | int state; /* Current state */ |
57 | char *state_data; /* Data attached to the state. It is used to | |
58 | * check that we are using the same data as a | |
59 | * previous call until the state machine goes to | |
60 | * CONN_STATE_IDLE. */ | |
61 | ||
57 | /* Data attached to the state. It is used to check that we are using the | |
58 | * same data as a previous call until the state machine goes to | |
59 | * CONN_STATE_IDLE. */ | |
60 | char state_data[IFNAMSIZ + 64]; | |
62 | 61 | /* Error handling */ |
63 | 62 | lldpctl_error_t error; /* Last error */ |
64 | 63 | |
80 | 79 | void *to_send, struct marshal_info *mi_send, |
81 | 80 | void **to_recv, struct marshal_info *mi_recv); |
82 | 81 | |
83 | /* error.c */ | |
82 | /* errors.c */ | |
84 | 83 | #define SET_ERROR(conn, x) ((conn)->error = x) |
85 | 84 | #define RESET_ERROR(conn) SET_ERROR((conn), LLDPCTL_NO_ERROR) |
86 | 85 |
220 | 220 | case lldpctl_k_config_paused: |
221 | 221 | return c->config->c_paused; |
222 | 222 | case lldpctl_k_config_tx_interval: |
223 | return c->config->c_tx_interval; | |
223 | return (c->config->c_tx_interval+999)/1000; /* s units */ | |
224 | case lldpctl_k_config_tx_interval_ms: | |
225 | return c->config->c_tx_interval; /* ms units */ | |
224 | 226 | case lldpctl_k_config_receiveonly: |
225 | 227 | return c->config->c_receiveonly; |
226 | 228 | case lldpctl_k_config_advertise_version: |
266 | 268 | config.c_paused = c->config->c_paused = value; |
267 | 269 | break; |
268 | 270 | case lldpctl_k_config_tx_interval: |
271 | config.c_tx_interval = value * 1000; | |
272 | if (value > 0) c->config->c_tx_interval = value * 1000; | |
273 | break; | |
274 | case lldpctl_k_config_tx_interval_ms: | |
269 | 275 | config.c_tx_interval = value; |
270 | 276 | if (value > 0) c->config->c_tx_interval = value; |
271 | 277 | break; |
47 | 47 | static struct atom_map port_dot3_power_pairs_map = { |
48 | 48 | .key = lldpctl_k_dot3_power_pairs, |
49 | 49 | .map = { |
50 | { 0, "unknown" }, | |
50 | 51 | { LLDP_DOT3_POWERPAIRS_SIGNAL, "signal" }, |
51 | 52 | { LLDP_DOT3_POWERPAIRS_SPARE, "spare" }, |
52 | 53 | { 0, NULL } |
75 | 76 | { 0, NULL }, |
76 | 77 | }, |
77 | 78 | }; |
79 | ||
80 | static struct atom_map port_dot3_power_pd_4pid_map = { | |
81 | .key = lldpctl_k_dot3_power_pd_4pid, | |
82 | .map = { | |
83 | { 0, "PD does not support powering both modes" }, | |
84 | { 1, "PD supports powering both modes" }, | |
85 | }, | |
86 | }; | |
87 | ||
88 | static struct atom_map port_dot3_power_pse_status_map = { | |
89 | .key = lldpctl_k_dot3_power_pse_status, | |
90 | .map = { | |
91 | { 0, "Unknown" }, | |
92 | { 1, "2-pair powering" }, | |
93 | { 2, "4-pair powering dual-signature PD" }, | |
94 | { 3, "4-pair powering single-signature PD" }, | |
95 | }, | |
96 | }; | |
97 | ||
98 | static struct atom_map port_dot3_power_pd_status_map = { | |
99 | .key = lldpctl_k_dot3_power_pd_status, | |
100 | .map = { | |
101 | { 0, "Unknown" }, | |
102 | { 1, "2-pair powered PD" }, | |
103 | { 2, "4-pair powered dual-signature PD" }, | |
104 | { 3, "4-pair powered single-signature PD" }, | |
105 | }, | |
106 | }; | |
107 | ||
108 | static struct atom_map port_dot3_power_pse_pairs_ext_map = { | |
109 | .key = lldpctl_k_dot3_power_pse_pairs_ext, | |
110 | .map = { | |
111 | { 0, "Unknown" }, | |
112 | { 1, "Alternative A" }, | |
113 | { 2, "Alternative B" }, | |
114 | { 3, "Both alternatives" }, | |
115 | }, | |
116 | }; | |
117 | ||
118 | static struct atom_map port_dot3_power_class_a_map = { | |
119 | .key = lldpctl_k_dot3_power_class_a, | |
120 | .map = { | |
121 | { 0, "Unknown" }, | |
122 | { 1, "Class 1" }, | |
123 | { 2, "Class 2" }, | |
124 | { 3, "Class 3" }, | |
125 | { 4, "Class 4" }, | |
126 | { 5, "Class 5" }, | |
127 | { 6, "Unknown" }, | |
128 | { 7, "Single-signature PD or 2-pair only PSE" }, | |
129 | }, | |
130 | }; | |
131 | ||
132 | static struct atom_map port_dot3_power_class_b_map = { | |
133 | .key = lldpctl_k_dot3_power_class_b, | |
134 | .map = { | |
135 | { 0, "Unknown" }, | |
136 | { 1, "Class 1" }, | |
137 | { 2, "Class 2" }, | |
138 | { 3, "Class 3" }, | |
139 | { 4, "Class 4" }, | |
140 | { 5, "Class 5" }, | |
141 | { 6, "Unknown" }, | |
142 | { 7, "Single-signature PD or 2-pair only PSE" }, | |
143 | }, | |
144 | }; | |
145 | ||
146 | static struct atom_map port_dot3_power_class_ext_map = { | |
147 | .key = lldpctl_k_dot3_power_class_ext, | |
148 | .map = { | |
149 | { 0, "Unknown" }, | |
150 | { 1, "Class 1" }, | |
151 | { 2, "Class 2" }, | |
152 | { 3, "Class 3" }, | |
153 | { 4, "Class 4" }, | |
154 | { 5, "Class 5" }, | |
155 | { 6, "Class 6" }, | |
156 | { 7, "Class 7" }, | |
157 | { 8, "Class 8" }, | |
158 | { 9, "Unknown" }, | |
159 | { 10, "Unknown" }, | |
160 | { 11, "Unknown" }, | |
161 | { 12, "Unknown" }, | |
162 | { 13, "Unknown" }, | |
163 | { 14, "Unknown" }, | |
164 | { 15, "Dual-signature PD" }, | |
165 | }, | |
166 | }; | |
167 | ||
168 | static struct atom_map port_dot3_power_type_ext_map = { | |
169 | .key = lldpctl_k_dot3_power_type_ext, | |
170 | .map = { | |
171 | { LLDP_DOT3_POWER_8023BT_OFF, "802.3bt off" }, | |
172 | { 1, "Type 3 PSE" }, | |
173 | { 2, "Type 4 PSE" }, | |
174 | { 3, "Type 3 single-signature PD" }, | |
175 | { 4, "Type 3 dual-signature PD" }, | |
176 | { 5, "Type 4 single-signature PD" }, | |
177 | { 6, "Type 4 dual-signature PD" }, | |
178 | { 7, "Unknown" }, | |
179 | { 8, "Unknown" }, | |
180 | }, | |
181 | }; | |
182 | ||
183 | static struct atom_map port_dot3_power_pd_load_map = { | |
184 | .key = lldpctl_k_dot3_power_pd_load, | |
185 | .map = { | |
186 | { 0, "PD is single- or dual-signature and power is not " | |
187 | "electrically isolated" }, | |
188 | { 1, "PD is dual-signature and power is electrically " | |
189 | "isolated" }, | |
190 | }, | |
191 | }; | |
192 | ||
78 | 193 | |
79 | 194 | ATOM_MAP_REGISTER(port_dot3_power_pairs_map, 4); |
80 | 195 | ATOM_MAP_REGISTER(port_dot3_power_class_map, 5); |
124 | 239 | case lldpctl_k_dot3_power_priority: |
125 | 240 | return map_lookup(port_dot3_power_priority_map.map, |
126 | 241 | port->p_power.priority); |
242 | case lldpctl_k_dot3_power_pd_4pid: | |
243 | return map_lookup(port_dot3_power_pd_4pid_map.map, | |
244 | port->p_power.pd_4pid); | |
245 | case lldpctl_k_dot3_power_pse_status: | |
246 | return map_lookup(port_dot3_power_pse_status_map.map, | |
247 | port->p_power.pse_status); | |
248 | case lldpctl_k_dot3_power_pd_status: | |
249 | return map_lookup(port_dot3_power_pd_status_map.map, | |
250 | port->p_power.pd_status); | |
251 | case lldpctl_k_dot3_power_pse_pairs_ext: | |
252 | return map_lookup(port_dot3_power_pse_pairs_ext_map.map, | |
253 | port->p_power.pse_pairs_ext); | |
254 | case lldpctl_k_dot3_power_class_a: | |
255 | return map_lookup(port_dot3_power_class_a_map.map, | |
256 | port->p_power.class_a); | |
257 | case lldpctl_k_dot3_power_class_b: | |
258 | return map_lookup(port_dot3_power_class_b_map.map, | |
259 | port->p_power.class_b); | |
260 | case lldpctl_k_dot3_power_class_ext: | |
261 | return map_lookup(port_dot3_power_class_ext_map.map, | |
262 | port->p_power.class_ext); | |
263 | case lldpctl_k_dot3_power_type_ext: | |
264 | return map_lookup(port_dot3_power_type_ext_map.map, | |
265 | port->p_power.type_ext); | |
266 | case lldpctl_k_dot3_power_pd_load: | |
267 | return map_lookup(port_dot3_power_pd_load_map.map, | |
268 | port->p_power.pd_load); | |
127 | 269 | default: |
128 | 270 | SET_ERROR(atom->conn, LLDPCTL_ERR_NOT_EXIST); |
129 | 271 | return NULL; |
161 | 303 | return port->p_power.requested * 100; |
162 | 304 | case lldpctl_k_dot3_power_allocated: |
163 | 305 | return port->p_power.allocated * 100; |
306 | /* 802.3bt additions */ | |
307 | case lldpctl_k_dot3_power_pd_4pid: | |
308 | return port->p_power.pd_4pid; | |
309 | case lldpctl_k_dot3_power_requested_a: | |
310 | return port->p_power.requested_a * 100; | |
311 | case lldpctl_k_dot3_power_requested_b: | |
312 | return port->p_power.requested_b * 100; | |
313 | case lldpctl_k_dot3_power_allocated_a: | |
314 | return port->p_power.allocated_a * 100; | |
315 | case lldpctl_k_dot3_power_allocated_b: | |
316 | return port->p_power.allocated_b * 100; | |
317 | case lldpctl_k_dot3_power_pse_status: | |
318 | return port->p_power.pse_status; | |
319 | case lldpctl_k_dot3_power_pd_status: | |
320 | return port->p_power.pd_status; | |
321 | case lldpctl_k_dot3_power_pse_pairs_ext: | |
322 | return port->p_power.pse_pairs_ext; | |
323 | case lldpctl_k_dot3_power_class_a: | |
324 | return port->p_power.class_a; | |
325 | case lldpctl_k_dot3_power_class_b: | |
326 | return port->p_power.class_b; | |
327 | case lldpctl_k_dot3_power_class_ext: | |
328 | return port->p_power.class_ext; | |
329 | case lldpctl_k_dot3_power_type_ext: | |
330 | return port->p_power.type_ext; | |
331 | case lldpctl_k_dot3_power_pd_load: | |
332 | return port->p_power.pd_load; | |
333 | case lldpctl_k_dot3_power_pse_max: | |
334 | return port->p_power.pse_max * 100; | |
164 | 335 | default: |
165 | 336 | return SET_ERROR(atom->conn, LLDPCTL_ERR_NOT_EXIST); |
166 | 337 | } |
216 | 387 | } |
217 | 388 | case lldpctl_k_dot3_power_pairs: |
218 | 389 | switch (value) { |
390 | case 0: | |
219 | 391 | case 1: |
220 | 392 | case 2: |
221 | 393 | port->p_power.pairs = value; |
258 | 430 | case lldpctl_k_dot3_power_requested: |
259 | 431 | if (value < 0) goto bad; |
260 | 432 | port->p_power.requested = value / 100; |
433 | return atom; | |
434 | /* 802.3bt additions */ | |
435 | case lldpctl_k_dot3_power_pd_4pid: | |
436 | port->p_power.pd_4pid = value; | |
437 | return atom; | |
438 | case lldpctl_k_dot3_power_requested_a: | |
439 | port->p_power.requested_a = value / 100; | |
440 | return atom; | |
441 | case lldpctl_k_dot3_power_requested_b: | |
442 | port->p_power.requested_b = value / 100; | |
443 | return atom; | |
444 | case lldpctl_k_dot3_power_allocated_a: | |
445 | port->p_power.allocated_a = value / 100; | |
446 | return atom; | |
447 | case lldpctl_k_dot3_power_allocated_b: | |
448 | port->p_power.allocated_b = value / 100; | |
449 | return atom; | |
450 | case lldpctl_k_dot3_power_pse_status: | |
451 | port->p_power.pse_status = value; | |
452 | return atom; | |
453 | case lldpctl_k_dot3_power_pd_status: | |
454 | port->p_power.pd_status = value; | |
455 | return atom; | |
456 | case lldpctl_k_dot3_power_pse_pairs_ext: | |
457 | port->p_power.pse_pairs_ext = value; | |
458 | return atom; | |
459 | case lldpctl_k_dot3_power_class_a: | |
460 | port->p_power.class_a = value; | |
461 | return atom; | |
462 | case lldpctl_k_dot3_power_class_b: | |
463 | port->p_power.class_b = value; | |
464 | return atom; | |
465 | case lldpctl_k_dot3_power_class_ext: | |
466 | port->p_power.class_ext = value; | |
467 | return atom; | |
468 | case lldpctl_k_dot3_power_type_ext: | |
469 | port->p_power.type_ext = value; | |
470 | return atom; | |
471 | case lldpctl_k_dot3_power_pd_load: | |
472 | port->p_power.pd_load = value; | |
473 | return atom; | |
474 | case lldpctl_k_dot3_power_pse_max: | |
475 | port->p_power.pse_max = value / 100; | |
261 | 476 | return atom; |
262 | 477 | default: |
263 | 478 | SET_ERROR(atom->conn, LLDPCTL_ERR_NOT_EXIST); |
86 | 86 | lldpctl_atom_dec_ref(mgmt->parent); |
87 | 87 | } |
88 | 88 | |
89 | static long int | |
90 | _lldpctl_atom_get_int_mgmt(lldpctl_atom_t *atom, lldpctl_key_t key) | |
91 | { | |
92 | struct _lldpctl_atom_mgmt_t *m = | |
93 | (struct _lldpctl_atom_mgmt_t *)atom; | |
94 | ||
95 | /* Local and remote port */ | |
96 | switch (key) { | |
97 | case lldpctl_k_mgmt_iface_index: | |
98 | return m->mgmt->m_iface; | |
99 | default: | |
100 | return SET_ERROR(atom->conn, LLDPCTL_ERR_NOT_EXIST); | |
101 | } | |
102 | } | |
103 | ||
89 | 104 | static const char* |
90 | 105 | _lldpctl_atom_get_str_mgmt(lldpctl_atom_t *atom, lldpctl_key_t key) |
91 | 106 | { |
135 | 150 | { atom_mgmt, sizeof(struct _lldpctl_atom_mgmt_t), |
136 | 151 | .init = _lldpctl_atom_new_mgmt, |
137 | 152 | .free = _lldpctl_atom_free_mgmt, |
153 | .get_int = _lldpctl_atom_get_int_mgmt, | |
138 | 154 | .get_str = _lldpctl_atom_get_str_mgmt }; |
139 | 155 | |
140 | 156 | ATOM_BUILDER_REGISTER(mgmts_list, 6); |
328 | 328 | struct lldpd_hardware *hardware = p->hardware; |
329 | 329 | struct lldpd_port_set set = {}; |
330 | 330 | int rc; |
331 | char *canary; | |
331 | char *canary = NULL; | |
332 | 332 | |
333 | 333 | #ifdef ENABLE_DOT3 |
334 | 334 | struct _lldpctl_atom_dot3_power_t *dpow; |
113 | 113 | } |
114 | 114 | if (!send && !recv) { |
115 | 115 | if ((data = malloc(sizeof(struct lldpctl_conn_sync_t))) == NULL) { |
116 | free(conn->ctlname); | |
116 | 117 | free(conn); |
117 | 118 | return NULL; |
118 | 119 | } |
230 | 230 | * translate this error code. |
231 | 231 | * |
232 | 232 | * When a function returns an integer, it may return a negative value. It |
233 | * usually means this is an error but some functions may return a legetimate | |
233 | * usually means this is an error but some functions may return a legitimate | |
234 | 234 | * negative value (for example @ref lldpctl_atom_get_int()). When there is a |
235 | 235 | * doubt, @ref lldpctl_last_error() should be checked. |
236 | 236 | * |
641 | 641 | * written. An atom marked with (IS) can be retrieved as an integer and features |
642 | 642 | * an appropriate representation as a string (usually, the name of a constant) |
643 | 643 | * which is more meaningful than just the integer. An atom marked as (I) can be |
644 | * retrieved and as a string. In the later case, this is just a string | |
645 | * representation of the integer. An atom marked with (AL) can be retrieved as | |
646 | * an atom only and can be iterated over. This is usually a list of things. An | |
647 | * atom marked (I,W) can be read as an integer or a string and can be written as | |
648 | * an integer. The change would not be commited until the atom is written to the | |
649 | * nearest atom supporting (A,WO) operation (eventually with an indirection, i.e | |
650 | * first write to a (A,W), then to a (A,WO)). | |
644 | * retrieved as an integer and as a string. In the later case, this is just a | |
645 | * string representation of the integer. An atom marked with (AL) can be | |
646 | * retrieved as an atom only and can be iterated over. This is usually a list of | |
647 | * things. An atom marked (I,W) can be read as an integer or a string and can be | |
648 | * written as an integer. The change would not be commited until the atom is | |
649 | * written to the nearest atom supporting (A,WO) operation (eventually with an | |
650 | * indirection, i.e first write to a (A,W), then to a (A,WO)). | |
651 | 651 | */ |
652 | 652 | typedef enum { |
653 | 653 | lldpctl_k_config_tx_interval, /**< `(I,WO)` Transmit interval. When set to -1, it is meant to transmit now. */ |
669 | 669 | lldpctl_k_config_chassis_mgmt_advertise, /**< `(I,WO)` Enable or disable management addresses advertisement */ |
670 | 670 | lldpctl_k_config_cid_string, /**< `(S,WON)` User defined string for the chassis ID */ |
671 | 671 | lldpctl_k_config_perm_iface_pattern, /**< `(S,WON)` Pattern of permanent interfaces */ |
672 | lldpctl_k_config_tx_interval_ms, /**< `(I,WO)` Transmit interval in milliseconds. Set to -1 to transmit now. */ | |
672 | 673 | |
673 | 674 | lldpctl_k_interface_name = 1000, /**< `(S)` The interface name. */ |
674 | 675 | |
710 | 711 | lldpctl_k_dot3_power_allocated, /**< `(I,W)` 802.3AT power allocated */ |
711 | 712 | lldpctl_k_dot3_power_requested, /**< `(I,W)` 802.3AT power requested */ |
712 | 713 | |
714 | /* 802.3bt additions */ | |
715 | lldpctl_k_dot3_power_pd_4pid, /**< `(IS,W)` 802.3BT both modes supported? */ | |
716 | lldpctl_k_dot3_power_requested_a, /**< `(I,W)` 802.3BT power value requested for A */ | |
717 | lldpctl_k_dot3_power_requested_b, /**< `(I,W)` 802.3BT power value requested for B */ | |
718 | lldpctl_k_dot3_power_allocated_a, /**< `(I,W)` 802.3BT power value allocated for A */ | |
719 | lldpctl_k_dot3_power_allocated_b, /**< `(I,W)` 802.3BT power value allocated for B */ | |
720 | lldpctl_k_dot3_power_pse_status, /**< `(IS,W)` 802.3BT PSE powering status */ | |
721 | lldpctl_k_dot3_power_pd_status, /**< `(IS,W)` 802.3BT PD powering status */ | |
722 | lldpctl_k_dot3_power_pse_pairs_ext, /**< `(IS,W)` 802.3BT PSE power pairs */ | |
723 | lldpctl_k_dot3_power_class_a, /**< `(IS,W)` 802.3BT power class for A */ | |
724 | lldpctl_k_dot3_power_class_b, /**< `(IS,W)` 802.3BT power class for B */ | |
725 | lldpctl_k_dot3_power_class_ext, /**< `(IS,W)` 802.3BT power class */ | |
726 | lldpctl_k_dot3_power_type_ext, /**< `(IS,W)` 802.3BT power type */ | |
727 | lldpctl_k_dot3_power_pd_load, /**< `(IS,W)` 802.3BT dualsig isolated? */ | |
728 | lldpctl_k_dot3_power_pse_max, /**< `(I,W)` 802.3BT maximum available power */ | |
729 | ||
713 | 730 | lldpctl_k_port_vlan_pvid = 1500, /**< `(I)` Primary VLAN ID */ |
714 | 731 | lldpctl_k_port_vlans, /**< `(AL)` List of VLAN */ |
715 | 732 | lldpctl_k_vlan_id, /**< `(I)` VLAN ID */ |
777 | 794 | lldpctl_k_med_power_val, /**< `(I,W)` LLDP MED power value */ |
778 | 795 | |
779 | 796 | lldpctl_k_mgmt_ip = 3000, /**< `(S)` IP address */ |
797 | lldpctl_k_mgmt_iface_index = 30001, /**< `(I)` Interface index */ | |
780 | 798 | |
781 | 799 | lldpctl_k_tx_cnt = 4000, /**< `(I)` tx cnt. Only works for a local port. */ |
782 | 800 | lldpctl_k_rx_cnt, /**< `(I)` rx cnt. Only works for a local port. */ |
139 | 139 | #define LLDP_DOT3_POWER_8023AT_TYPE1 1 |
140 | 140 | #define LLDP_DOT3_POWER_8023AT_TYPE2 2 |
141 | 141 | |
142 | /* 802.3bt additions */ | |
143 | #define LLDP_DOT3_POWER_8023BT_OFF 0 | |
144 | #define LLDP_DOT3_POWER_8023BT_TYPE3 1 | |
145 | #define LLDP_DOT3_POWER_8023BT_TYPE4 2 | |
146 | ||
142 | 147 | /* Dot3 power source */ |
143 | 148 | #define LLDP_DOT3_POWER_SOURCE_UNKNOWN 0 |
144 | 149 | #define LLDP_DOT3_POWER_SOURCE_PRIMARY 1 |
124 | 124 | u_int8_t priority; |
125 | 125 | u_int16_t requested; |
126 | 126 | u_int16_t allocated; |
127 | ||
128 | /* For 802.3BT */ | |
129 | u_int8_t pd_4pid; | |
130 | u_int16_t requested_a; | |
131 | u_int16_t requested_b; | |
132 | u_int16_t allocated_a; | |
133 | u_int16_t allocated_b; | |
134 | u_int16_t pse_status; | |
135 | u_int8_t pd_status; | |
136 | u_int8_t pse_pairs_ext; | |
137 | u_int8_t class_a; | |
138 | u_int8_t class_b; | |
139 | u_int8_t class_ext; | |
140 | u_int8_t type_ext; | |
141 | u_int8_t pd_load; | |
142 | u_int16_t pse_max; | |
127 | 143 | }; |
128 | 144 | MARSHAL(lldpd_dot3_power); |
129 | 145 | #endif |
243 | 259 | struct lldpd_frame *p_lastframe; /* Frame received during last update */ |
244 | 260 | u_int8_t p_protocol; /* Protocol used to get this port */ |
245 | 261 | u_int8_t p_hidden_in:1; /* Considered as hidden for reception */ |
246 | u_int8_t p_hidden_out:2; /* Considered as hidden for emission */ | |
247 | u_int8_t p_disable_rx:3; /* Should RX be disabled for this port? */ | |
248 | u_int8_t p_disable_tx:4; /* Should TX be disabled for this port? */ | |
262 | u_int8_t p_hidden_out:1; /* Considered as hidden for emission */ | |
263 | u_int8_t p_disable_rx:1; /* Should RX be disabled for this port? */ | |
264 | u_int8_t p_disable_tx:1; /* Should TX be disabled for this port? */ | |
249 | 265 | /* Important: all fields that should be ignored to check if a port has |
250 | 266 | * been changed should be before this mark. */ |
251 | 267 | #define LLDPD_PORT_START_MARKER (offsetof(struct lldpd_port, _p_hardware_flags)) |
371 | 387 | |
372 | 388 | struct lldpd_config { |
373 | 389 | int c_paused; /* lldpd is paused */ |
374 | int c_tx_interval; /* Transmit interval */ | |
390 | int c_tx_interval; /* Transmit interval (in ms) */ | |
375 | 391 | int c_ttl; /* TTL */ |
376 | 392 | int c_smart; /* Bitmask for smart configuration (see SMART_*) */ |
377 | 393 | int c_receiveonly; /* Receive only mode */ |
114 | 114 | case LOG_WARNING: return "\033[1;33m[WARN"; |
115 | 115 | case LOG_NOTICE: return "\033[1;34m[NOTI"; |
116 | 116 | case LOG_INFO: return "\033[1;34m[INFO"; |
117 | case LOG_DEBUG: return "\033[1;30m[ DBG"; | |
117 | case LOG_DEBUG: return "\033[36m[ DBG"; | |
118 | 118 | } |
119 | 119 | break; |
120 | 120 | default: |
3 | 3 | |
4 | 4 | if HAVE_CHECK |
5 | 5 | |
6 | TESTS = check_marshal check_pattern check_lldp check_cdp check_sonmp check_edp check_fixedpoint | |
6 | TESTS = check_marshal check_pattern check_bitmap check_fixedpoint \ | |
7 | check_lldp check_cdp check_sonmp check_edp | |
7 | 8 | AM_CFLAGS += @check_CFLAGS@ |
8 | 9 | LDADD = $(top_builddir)/src/daemon/liblldpd.la @check_LIBS@ @libevent_LDFLAGS@ |
9 | 10 | |
12 | 13 | check-compat.h |
13 | 14 | |
14 | 15 | check_pattern_SOURCES = check_pattern.c \ |
16 | $(top_srcdir)/src/daemon/lldpd.h | |
17 | ||
18 | check_bitmap_SOURCES = check_bitmap.c \ | |
15 | 19 | $(top_srcdir)/src/daemon/lldpd.h |
16 | 20 | |
17 | 21 | check_lldp_SOURCES = check_lldp.c \ |
87 | 87 | build_triplet = @build@ |
88 | 88 | host_triplet = @host@ |
89 | 89 | @HAVE_CHECK_TRUE@TESTS = check_marshal$(EXEEXT) check_pattern$(EXEEXT) \ |
90 | @HAVE_CHECK_TRUE@ check_lldp$(EXEEXT) check_cdp$(EXEEXT) \ | |
91 | @HAVE_CHECK_TRUE@ check_sonmp$(EXEEXT) check_edp$(EXEEXT) \ | |
92 | @HAVE_CHECK_TRUE@ check_fixedpoint$(EXEEXT) $(am__EXEEXT_1) | |
90 | @HAVE_CHECK_TRUE@ check_bitmap$(EXEEXT) \ | |
91 | @HAVE_CHECK_TRUE@ check_fixedpoint$(EXEEXT) check_lldp$(EXEEXT) \ | |
92 | @HAVE_CHECK_TRUE@ check_cdp$(EXEEXT) check_sonmp$(EXEEXT) \ | |
93 | @HAVE_CHECK_TRUE@ check_edp$(EXEEXT) $(am__EXEEXT_1) | |
93 | 94 | @HAVE_CHECK_TRUE@am__append_1 = @check_CFLAGS@ |
94 | 95 | @HAVE_CHECK_TRUE@@USE_SNMP_TRUE@am__append_2 = check_snmp |
95 | 96 | @HAVE_CHECK_TRUE@@USE_SNMP_TRUE@am__append_3 = @NETSNMP_LIBS@ |
122 | 123 | CONFIG_CLEAN_VPATH_FILES = |
123 | 124 | @HAVE_CHECK_TRUE@@USE_SNMP_TRUE@am__EXEEXT_1 = check_snmp$(EXEEXT) |
124 | 125 | @HAVE_CHECK_TRUE@am__EXEEXT_2 = check_marshal$(EXEEXT) \ |
125 | @HAVE_CHECK_TRUE@ check_pattern$(EXEEXT) check_lldp$(EXEEXT) \ | |
126 | @HAVE_CHECK_TRUE@ check_pattern$(EXEEXT) check_bitmap$(EXEEXT) \ | |
127 | @HAVE_CHECK_TRUE@ check_fixedpoint$(EXEEXT) check_lldp$(EXEEXT) \ | |
126 | 128 | @HAVE_CHECK_TRUE@ check_cdp$(EXEEXT) check_sonmp$(EXEEXT) \ |
127 | @HAVE_CHECK_TRUE@ check_edp$(EXEEXT) check_fixedpoint$(EXEEXT) \ | |
128 | @HAVE_CHECK_TRUE@ $(am__EXEEXT_1) | |
129 | @HAVE_CHECK_TRUE@ check_edp$(EXEEXT) $(am__EXEEXT_1) | |
130 | am__check_bitmap_SOURCES_DIST = check_bitmap.c \ | |
131 | $(top_srcdir)/src/daemon/lldpd.h | |
132 | @HAVE_CHECK_TRUE@am_check_bitmap_OBJECTS = check_bitmap.$(OBJEXT) | |
133 | check_bitmap_OBJECTS = $(am_check_bitmap_OBJECTS) | |
134 | check_bitmap_LDADD = $(LDADD) | |
135 | am__DEPENDENCIES_1 = | |
136 | @HAVE_CHECK_TRUE@check_bitmap_DEPENDENCIES = \ | |
137 | @HAVE_CHECK_TRUE@ $(top_builddir)/src/daemon/liblldpd.la \ | |
138 | @HAVE_CHECK_TRUE@ $(am__DEPENDENCIES_1) | |
139 | AM_V_lt = $(am__v_lt_@AM_V@) | |
140 | am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) | |
141 | am__v_lt_0 = --silent | |
142 | am__v_lt_1 = | |
129 | 143 | am__check_cdp_SOURCES_DIST = check_cdp.c \ |
130 | 144 | $(top_srcdir)/src/daemon/lldpd.h common.h common.c \ |
131 | 145 | check-compat.h |
133 | 147 | @HAVE_CHECK_TRUE@ common.$(OBJEXT) |
134 | 148 | check_cdp_OBJECTS = $(am_check_cdp_OBJECTS) |
135 | 149 | check_cdp_LDADD = $(LDADD) |
136 | am__DEPENDENCIES_1 = | |
137 | 150 | @HAVE_CHECK_TRUE@check_cdp_DEPENDENCIES = \ |
138 | 151 | @HAVE_CHECK_TRUE@ $(top_builddir)/src/daemon/liblldpd.la \ |
139 | 152 | @HAVE_CHECK_TRUE@ $(am__DEPENDENCIES_1) |
140 | AM_V_lt = $(am__v_lt_@AM_V@) | |
141 | am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) | |
142 | am__v_lt_0 = --silent | |
143 | am__v_lt_1 = | |
144 | 153 | am__check_edp_SOURCES_DIST = check_edp.c \ |
145 | 154 | $(top_srcdir)/src/daemon/lldpd.h common.h common.c \ |
146 | 155 | check-compat.h |
230 | 239 | DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) |
231 | 240 | depcomp = $(SHELL) $(top_srcdir)/depcomp |
232 | 241 | am__maybe_remake_depfiles = depfiles |
233 | am__depfiles_remade = ./$(DEPDIR)/check_cdp.Po \ | |
234 | ./$(DEPDIR)/check_edp.Po ./$(DEPDIR)/check_fixedpoint.Po \ | |
235 | ./$(DEPDIR)/check_lldp.Po ./$(DEPDIR)/check_marshal.Po \ | |
236 | ./$(DEPDIR)/check_pattern.Po ./$(DEPDIR)/check_snmp.Po \ | |
237 | ./$(DEPDIR)/check_sonmp.Po ./$(DEPDIR)/common.Po \ | |
238 | ./$(DEPDIR)/decode.Po | |
242 | am__depfiles_remade = ./$(DEPDIR)/check_bitmap.Po \ | |
243 | ./$(DEPDIR)/check_cdp.Po ./$(DEPDIR)/check_edp.Po \ | |
244 | ./$(DEPDIR)/check_fixedpoint.Po ./$(DEPDIR)/check_lldp.Po \ | |
245 | ./$(DEPDIR)/check_marshal.Po ./$(DEPDIR)/check_pattern.Po \ | |
246 | ./$(DEPDIR)/check_snmp.Po ./$(DEPDIR)/check_sonmp.Po \ | |
247 | ./$(DEPDIR)/common.Po ./$(DEPDIR)/decode.Po | |
239 | 248 | am__mv = mv -f |
240 | 249 | COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ |
241 | 250 | $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) |
255 | 264 | am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) |
256 | 265 | am__v_CCLD_0 = @echo " CCLD " $@; |
257 | 266 | am__v_CCLD_1 = |
258 | SOURCES = $(check_cdp_SOURCES) $(check_edp_SOURCES) \ | |
259 | $(check_fixedpoint_SOURCES) $(check_lldp_SOURCES) \ | |
260 | $(check_marshal_SOURCES) $(check_pattern_SOURCES) \ | |
261 | $(check_snmp_SOURCES) $(check_sonmp_SOURCES) $(decode_SOURCES) | |
262 | DIST_SOURCES = $(am__check_cdp_SOURCES_DIST) \ | |
263 | $(am__check_edp_SOURCES_DIST) \ | |
267 | SOURCES = $(check_bitmap_SOURCES) $(check_cdp_SOURCES) \ | |
268 | $(check_edp_SOURCES) $(check_fixedpoint_SOURCES) \ | |
269 | $(check_lldp_SOURCES) $(check_marshal_SOURCES) \ | |
270 | $(check_pattern_SOURCES) $(check_snmp_SOURCES) \ | |
271 | $(check_sonmp_SOURCES) $(decode_SOURCES) | |
272 | DIST_SOURCES = $(am__check_bitmap_SOURCES_DIST) \ | |
273 | $(am__check_cdp_SOURCES_DIST) $(am__check_edp_SOURCES_DIST) \ | |
264 | 274 | $(am__check_fixedpoint_SOURCES_DIST) \ |
265 | 275 | $(am__check_lldp_SOURCES_DIST) \ |
266 | 276 | $(am__check_marshal_SOURCES_DIST) \ |
696 | 706 | @HAVE_CHECK_TRUE@check_pattern_SOURCES = check_pattern.c \ |
697 | 707 | @HAVE_CHECK_TRUE@ $(top_srcdir)/src/daemon/lldpd.h |
698 | 708 | |
709 | @HAVE_CHECK_TRUE@check_bitmap_SOURCES = check_bitmap.c \ | |
710 | @HAVE_CHECK_TRUE@ $(top_srcdir)/src/daemon/lldpd.h | |
711 | ||
699 | 712 | @HAVE_CHECK_TRUE@check_lldp_SOURCES = check_lldp.c \ |
700 | 713 | @HAVE_CHECK_TRUE@ $(top_srcdir)/src/daemon/lldpd.h \ |
701 | 714 | @HAVE_CHECK_TRUE@ common.h common.c check-compat.h |
766 | 779 | echo " rm -f" $$list; \ |
767 | 780 | rm -f $$list |
768 | 781 | |
782 | check_bitmap$(EXEEXT): $(check_bitmap_OBJECTS) $(check_bitmap_DEPENDENCIES) $(EXTRA_check_bitmap_DEPENDENCIES) | |
783 | @rm -f check_bitmap$(EXEEXT) | |
784 | $(AM_V_CCLD)$(LINK) $(check_bitmap_OBJECTS) $(check_bitmap_LDADD) $(LIBS) | |
785 | ||
769 | 786 | check_cdp$(EXEEXT): $(check_cdp_OBJECTS) $(check_cdp_DEPENDENCIES) $(EXTRA_check_cdp_DEPENDENCIES) |
770 | 787 | @rm -f check_cdp$(EXEEXT) |
771 | 788 | $(AM_V_CCLD)$(LINK) $(check_cdp_OBJECTS) $(check_cdp_LDADD) $(LIBS) |
808 | 825 | distclean-compile: |
809 | 826 | -rm -f *.tab.c |
810 | 827 | |
828 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_bitmap.Po@am__quote@ # am--include-marker | |
811 | 829 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_cdp.Po@am__quote@ # am--include-marker |
812 | 830 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_edp.Po@am__quote@ # am--include-marker |
813 | 831 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_fixedpoint.Po@am__quote@ # am--include-marker |
1062 | 1080 | --log-file $$b.log --trs-file $$b.trs \ |
1063 | 1081 | $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ |
1064 | 1082 | "$$tst" $(AM_TESTS_FD_REDIRECT) |
1083 | check_bitmap.log: check_bitmap$(EXEEXT) | |
1084 | @p='check_bitmap$(EXEEXT)'; \ | |
1085 | b='check_bitmap'; \ | |
1086 | $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ | |
1087 | --log-file $$b.log --trs-file $$b.trs \ | |
1088 | $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ | |
1089 | "$$tst" $(AM_TESTS_FD_REDIRECT) | |
1090 | check_fixedpoint.log: check_fixedpoint$(EXEEXT) | |
1091 | @p='check_fixedpoint$(EXEEXT)'; \ | |
1092 | b='check_fixedpoint'; \ | |
1093 | $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ | |
1094 | --log-file $$b.log --trs-file $$b.trs \ | |
1095 | $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ | |
1096 | "$$tst" $(AM_TESTS_FD_REDIRECT) | |
1065 | 1097 | check_lldp.log: check_lldp$(EXEEXT) |
1066 | 1098 | @p='check_lldp$(EXEEXT)'; \ |
1067 | 1099 | b='check_lldp'; \ |
1086 | 1118 | check_edp.log: check_edp$(EXEEXT) |
1087 | 1119 | @p='check_edp$(EXEEXT)'; \ |
1088 | 1120 | b='check_edp'; \ |
1089 | $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ | |
1090 | --log-file $$b.log --trs-file $$b.trs \ | |
1091 | $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ | |
1092 | "$$tst" $(AM_TESTS_FD_REDIRECT) | |
1093 | check_fixedpoint.log: check_fixedpoint$(EXEEXT) | |
1094 | @p='check_fixedpoint$(EXEEXT)'; \ | |
1095 | b='check_fixedpoint'; \ | |
1096 | 1121 | $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ |
1097 | 1122 | --log-file $$b.log --trs-file $$b.trs \ |
1098 | 1123 | $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ |
1198 | 1223 | mostlyclean-am |
1199 | 1224 | |
1200 | 1225 | distclean: distclean-am |
1201 | -rm -f ./$(DEPDIR)/check_cdp.Po | |
1226 | -rm -f ./$(DEPDIR)/check_bitmap.Po | |
1227 | -rm -f ./$(DEPDIR)/check_cdp.Po | |
1202 | 1228 | -rm -f ./$(DEPDIR)/check_edp.Po |
1203 | 1229 | -rm -f ./$(DEPDIR)/check_fixedpoint.Po |
1204 | 1230 | -rm -f ./$(DEPDIR)/check_lldp.Po |
1253 | 1279 | installcheck-am: |
1254 | 1280 | |
1255 | 1281 | maintainer-clean: maintainer-clean-am |
1256 | -rm -f ./$(DEPDIR)/check_cdp.Po | |
1282 | -rm -f ./$(DEPDIR)/check_bitmap.Po | |
1283 | -rm -f ./$(DEPDIR)/check_cdp.Po | |
1257 | 1284 | -rm -f ./$(DEPDIR)/check_edp.Po |
1258 | 1285 | -rm -f ./$(DEPDIR)/check_fixedpoint.Po |
1259 | 1286 | -rm -f ./$(DEPDIR)/check_lldp.Po |
0 | /* -*- mode: c; c-file-style: "openbsd" -*- */ | |
1 | /* | |
2 | * Copyright (c) 2020 Vincent Bernat <bernat@luffy.cx> | |
3 | * | |
4 | * Permission to use, copy, modify, and/or distribute this software for any | |
5 | * purpose with or without fee is hereby granted, provided that the above | |
6 | * copyright notice and this permission notice appear in all copies. | |
7 | * | |
8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
15 | */ | |
16 | ||
17 | #include <check.h> | |
18 | ||
19 | #include "../src/daemon/lldpd.h" | |
20 | ||
21 | START_TEST(test_empty) { | |
22 | uint32_t vlan_bmap[VLAN_BITMAP_LEN] = {}; | |
23 | ck_assert(bitmap_isempty(vlan_bmap)); | |
24 | ck_assert_int_eq(bitmap_numbits(vlan_bmap), 0); | |
25 | } | |
26 | END_TEST | |
27 | ||
28 | START_TEST(test_first_bit) { | |
29 | uint32_t vlan_bmap[VLAN_BITMAP_LEN] = {}; | |
30 | bitmap_set(vlan_bmap, 1); | |
31 | ck_assert_int_eq(vlan_bmap[0], 2); | |
32 | ck_assert_int_eq(bitmap_numbits(vlan_bmap), 1); | |
33 | } | |
34 | END_TEST | |
35 | ||
36 | START_TEST(test_some_bits) { | |
37 | uint32_t vlan_bmap[VLAN_BITMAP_LEN] = {}; | |
38 | bitmap_set(vlan_bmap, 1); | |
39 | bitmap_set(vlan_bmap, 6); | |
40 | bitmap_set(vlan_bmap, 31); | |
41 | bitmap_set(vlan_bmap, 50); | |
42 | ck_assert_int_eq(vlan_bmap[0], (1L << 1) | (1L << 6) | (1L << 31)); | |
43 | ck_assert_int_eq(vlan_bmap[1], (1L << (50-32))); | |
44 | ck_assert_int_eq(vlan_bmap[2], 0); | |
45 | ck_assert_int_eq(bitmap_numbits(vlan_bmap), 4); | |
46 | } | |
47 | END_TEST | |
48 | ||
49 | Suite * | |
50 | bitmap_suite(void) | |
51 | { | |
52 | Suite *s = suite_create("Bitmap handling"); | |
53 | ||
54 | TCase *tc_bitmap = tcase_create("Bitmap handling"); | |
55 | tcase_add_test(tc_bitmap, test_empty); | |
56 | tcase_add_test(tc_bitmap, test_first_bit); | |
57 | tcase_add_test(tc_bitmap, test_some_bits); | |
58 | suite_add_tcase(s, tc_bitmap); | |
59 | ||
60 | return s; | |
61 | } | |
62 | ||
63 | int | |
64 | main() | |
65 | { | |
66 | int number_failed; | |
67 | Suite *s = bitmap_suite(); | |
68 | SRunner *sr = srunner_create(s); | |
69 | srunner_run_all(sr, CK_ENV); | |
70 | number_failed = srunner_ntests_failed(sr); | |
71 | srunner_free(sr); | |
72 | return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; | |
73 | } |