Imported Upstream version 0.7.14
Vincent Bernat
9 years ago
0 | 0.7.14 [2015-04-04 16:29:39 +0200]: | |
1 | ||
2 | - [1d56f873a9d5] release: prepare 0.7.14 (Vincent Bernat) | |
3 | - [a8382e7f7aad] NEWS: add an entry to NEWS file for previous changes (Vincent Bernat) | |
4 | - [f9ddfae82e8c] lib: update revision info to reflect ABI update of latest changes (Vincent Bernat) | |
5 | - [8003e78962a6] lib: a change to port description is transmitted now (Vincent Bernat) | |
6 | - [bbd094f4952c] client: when receiving a port update, transmit it now (Vincent Bernat) | |
7 | - [332f8eea55d4] lldpcli: use "description" keyword when setting port description (Vincent Bernat) | |
8 | - [50a978dce0a1] lldpcli: document ability to change port id and description (Vincent Bernat) | |
9 | - [ec5a36012c23] lldpcli: ensure optional local port description cannot be repeated (Vincent Bernat) | |
10 | - [b3eba1789914] Merge pull request #101 from commodo/port_label2 (Vincent Bernat) | |
11 | - [abfea7d0be12] interfaces: management address is set to pattern on exact match (Vincent Bernat) | |
12 | - [c267d0f2ab4f] lldpd: add port description override via lldpcli (Alexandru Ardelean) | |
13 | - [8e46010cf12f] lldpd: implement basic support to override port IDs via lldpcli (Alexandru Ardelean) | |
14 | - [0979d1ba0a3b] .gitignore: ignore vim swap files (Alexandru Ardelean) | |
15 | - [81b171f47321] style: remove `if (...) free(...)` pattern (Vincent Bernat) | |
16 | - [4db5e8c68d9a] interfaces: don't test for NULL before `free` (Vincent Bernat) | |
17 | - [5683586ea1ef] priv: document improvement in crash handling in NEWS file (Vincent Bernat) | |
18 | - [55764ecb9c62] Revert "priv: on Linux, when monitor dies, kill child" (Vincent Bernat) | |
19 | - [a6128224ec0c] priv: use SOCK_STREAM for monitor communication (Vincent Bernat) | |
20 | - [c53540ffc8e6] priv: don't log anything when handling SIGCHLD (Vincent Bernat) | |
21 | - [004b5f944539] priv: ensure we write exactly what will be read (Vincent Bernat) | |
22 | - [9475dd4c835e] ctl: create control socket with close-on-exec semantic (Vincent Bernat) | |
23 | - [c642d8c7b9e4] priv: fallback to SOCK_DGRAM if SOCK_SEQPACKET not available (Vincent Bernat) | |
24 | - [10c20ba8877e] priv: use a SOCK_SEQPACKET for communication with monitor (Vincent Bernat) | |
25 | - [327b1d625c2d] priv: monitor the monitor process (Vincent Bernat) | |
26 | - [a87db231990a] log: add token to all `fatalx` instances (Vincent Bernat) | |
27 | - [4747e964096a] priv: on Linux, when monitor dies, kill child (Vincent Bernat) | |
28 | - [50efc5f74521] event: don't remember (in cfg) control socket event (Vincent Bernat) | |
29 | - [2bf63e5422e5] event: don't ignore SIGHUP twice (Vincent Bernat) | |
30 | - [bdefcdb99044] build: don't use `sort -V` (Vincent Bernat) | |
31 | - [eab6aa62d66d] check: add missing license headers to some files (Vincent Bernat) | |
32 | - [1e264e08effe] check: fix SNMP test format error (Vincent Bernat) | |
33 | - [a0cd2b9a3c68] check: more comparison with `ck_assert_ptr_eq()` (Vincent Bernat) | |
34 | - [7afbe16a637d] check: compare pointers with `ck_assert_ptr_eq()` (Vincent Bernat) | |
35 | - [47cd2807872a] check: enforce correct alignment during SNMP tests (Vincent Bernat) | |
36 | - [c2af3a9cbd02] travis: don't configure with CFLAGS=-Werror (Vincent Bernat) | |
37 | - [e6515ff5183d] configure: move LDFLAGS to LLDP_LDFLAGS (Vincent Bernat) | |
38 | - [d627ab691987] configure: move CFLAGS/CPPFLAGS to LLDP_CFLAGS/LLDP_CPPFLAGS (Vincent Bernat) | |
39 | - [a577598bb30b] configure: put cpp flags into CPPFLAGS instead of CFLAGS (Vincent Bernat) | |
40 | - [630cc035fd82] configure: enforce the use of C99 (Vincent Bernat) | |
41 | - [f215b5ec088b] Merge pull request #98 from baloo/features/document-lldp.d (Vincent Bernat) | |
42 | - [fb0921ed2f43] client: document lldp.d configuration directory (Arthur Gautier) | |
43 | - [63d2c3f8e547] interfaces: fallback to link local addresses for management (Vincent Bernat) | |
44 | - [4b67a7b2829f] interfaces: exclude IPv4 link local addresses from management addresses (Vincent Bernat) | |
45 | - [0c6a1966eead] interfaces: enforce redefinition of IN_IS_ADDR_* macros (Vincent Bernat) | |
46 | - [28bf40220840] priv: don't lookup for _lldpd when privsep is disabled (Vincent Bernat) | |
47 | - [aed91d90de68] lib: fix "unknwon" typo (Vincent Bernat) | |
48 | - [e7b282ce5ca7] lib: fix compilation error when Dot3 is disabled (Vincent Bernat) | |
49 | - [65e5293aeedf] priv: replace the use of `gethostbyname()` by `getaddrinfo()` (Vincent Bernat) | |
50 | - [1fa7d39f5b9d] priv: rename "gethostbyname" priv function to "gethostname" (Vincent Bernat) | |
51 | - [d162d7854659] build: use version sort for changelog (Vincent Bernat) | |
52 | - [ac07e7e4a038] NEWS: add an entry for the two previous commits (Vincent Bernat) | |
53 | - [78e82fcf01cc] lldp: fix boundary checks when decoding LLDP protocol identity (Vincent Bernat) | |
54 | - [feed548d366d] lldp: fix boundary checks when decoding LLDP management address (Vincent Bernat) | |
55 | - [17e55ef9b1b9] lldpcli: add "tagged" keyword to "configure med policy" (Vincent Bernat) | |
56 | - [319ca87dc14f] travis: use stable NetSNMP from Homebrew (Vincent Bernat) | |
57 | - [74da4061c4a9] libevent: enable silent rules by default (Vincent Bernat) | |
58 | - [dc93bcaf9314] libevent: update embedded copy to 2.0.22-stable (Vincent Bernat) | |
59 | - [efdd67188596] NEWS: add an entry for the two previous commits (Vincent Bernat) | |
60 | - [e770b7204bf8] lldp: send a shutdown LLDPDU on exit (Vincent Bernat) | |
61 | - [acb5f65b98b9] lldp: when MSAP changes, send a shutdown LLPDU (Vincent Bernat) | |
62 | - [b1785ed5254b] marshal: don't marshal previous port value (Vincent Bernat) | |
63 | - [9fb213a1b5ba] travis: don't compile embedded libevent + clang on OSX (Vincent Bernat) | |
64 | - [5d74a4ec5afa] travis: don't fail on unused functions (second try) (Vincent Bernat) | |
65 | - [8ef8a406fd03] travis: don't fail on unused functions (Vincent Bernat) | |
66 | - [286513f665cc] travis: don't allow any warning or error (Vincent Bernat) | |
67 | ||
68 | 0.7.13 [2014-12-30 14:11:49 +0100]: | |
69 | ||
70 | - [d9cf6428201b] version: prepare 0.7.13 release (Vincent Bernat) | |
71 | - [135ff0f7fabb] configure: let define pkg-config directory with `--with-pkgconfigdir` (Vincent Bernat) | |
72 | - [5a1f45863ed5] man: `-I` option and the like also affect sending (Vincent Bernat) | |
73 | - [a3cae2a7299f] lldp: fix display of unknown organizational ID (Vincent Bernat) | |
74 | - [17d341157926] lldpd: don't rely on a checksum to detect a port change (Vincent Bernat) | |
75 | - [28414fbdbefb] lldpd: use a macro to define offset of permanent port info (Vincent Bernat) | |
76 | - [da9c551a5511] NEWS: add an entry for the latest commit (Vincent Bernat) | |
77 | - [59ca5ddb80fe] lldpd: fix coding style in latest commit (Vincent Bernat) | |
78 | - [ea625620c6d6] Merge pull request #84 from IcyMetric/master (Vincent Bernat) | |
79 | - [1c1c519fd71e] Allow setting control socket on CLI (Robert Long) | |
80 | - [1f68881c2914] lldpd: decrease probability of collisions on port checksums (Vincent Bernat) | |
81 | - [e172ee7b999a] lldpd: decrease probability of collisions on port checksums (Vincent Bernat) | |
82 | - [24cce58cfc1b] lldpd: really ensure that port checksum can never be 0 (Vincent Bernat) | |
83 | - [280f28da5153] lldpd: fix timer initialization when checksum is 0 (Vincent Bernat) | |
84 | - [324d73a32c0a] marshal: ensure we correctly handle signed result from serialization (Vincent Bernat) | |
85 | - [21832029366d] xml: check that libxml-2 is really usable (Vincent Bernat) | |
86 | - [83d4b7761491] snmp: `agent_init()` won't modify AgentX string (Vincent Bernat) | |
87 | - [4bfe49e965c5] lib: silent a warning about uninitialized value (Vincent Bernat) | |
88 | - [fa1f3624463d] redhat: do not install the chroot (Vincent Bernat) | |
89 | - [724dfcbd3919] redhat: requires pkg-config to build devel package (Vincent Bernat) | |
90 | ||
91 | 0.7.12 [2014-11-22 20:54:19 +0100]: | |
92 | ||
93 | - [0882639dd155] release: prepare release of 0.7.12 (Vincent Bernat) | |
94 | - [acdb7107e764] lib: fix pkgconfig file substitutions (Vincent Bernat) | |
95 | - [63b4f1eede9e] client: fix "update" command (Vincent Bernat) | |
96 | - [20f10b8dd3a2] travis: travis comes with autotools and friends already installed (Vincent Bernat) | |
97 | - [2021a245926d] debian: update symbol versioning for incompatibility of `lldpctl_atom_set_str()` (Vincent Bernat) | |
98 | - [18f7b3dbcea1] lib: bump versioning (Vincent Bernat) | |
99 | - [ca8cfd460862] lib: make it safe to pass NULL to `lldpctl_atom_set_str()` (Vincent Bernat) | |
100 | - [28431faeeafc] lib: document the possibility of using NULL with `lldpctl_atom_set_str()` (Vincent Bernat) | |
101 | - [6dd83015cb74] lldpcli: allow to unset patterns and system description/hostname (Vincent Bernat) | |
102 | - [7424351a7f80] lib: replace macro by a function for `_lldpctl_atom_set_str_config()` (Vincent Bernat) | |
103 | - [8d91359cb371] lib: factor out some code in `_lldpctl_atom_set_str_config()` in a macro (Vincent Bernat) | |
104 | - [22a5375576dd] NEWS: add an entry about some flags not being persistent accross time (Vincent Bernat) | |
105 | - [cf33f40593b8] build: hide renaming of template-generated files (Vincent Bernat) | |
106 | - [abc042057d9f] lldpd: use strdup() on arguments that could be changed by lldpcli (Vincent Bernat) | |
107 | - [e4c51716848a] client: fix configuration modification (Vincent Bernat) | |
108 | - [625005be708d] lldpcli: pretty print json (kanna) | |
109 | - [dfa283134795] systemd: fix systemd unit file (Vincent Bernat) | |
110 | - [8756eb67699c] debian: update symbols file (Vincent Bernat) | |
111 | - [148a1efedcdf] interfaces: bond listening was broken only for old kernels (Vincent Bernat) | |
112 | - [08ced6b4edf2] interfaces: fix initialization of hardware h_data for bonds (Vincent Bernat) | |
113 | - [b96ca40c384a] frame: mention the licensing issue with POKE/PEEK macros (Vincent Bernat) | |
114 | - [3ea0bccfdd4c] lldpcli: handle comments in tokenizer (Vincent Bernat) | |
115 | - [5451aea8aa2f] Merge pull request #77 from Authority1980/master (Vincent Bernat) | |
116 | - [e537ab772962] Fixed Changelog dates (Wes Hardin) | |
117 | - [6d2c29c781db] lldpcli: don't complain when reading a commented line (Vincent Bernat) | |
118 | - [c66fd1a55a68] redhat: mark /var/run stuff as a ghost directory (Vincent Bernat) | |
119 | - [2e441b243656] redhat: fix group tag (Vincent Bernat) | |
120 | - [b5b304e84702] redhat: provide a longer description for devel package (Vincent Bernat) | |
121 | - [4ed3c3d8b5ab] redhat: fix RPM building on SuSE with respect to /usr/share/zsh (Vincent Bernat) | |
122 | - [e202ae37e9f0] redhat: add completions for bash and zsh (Vincent Bernat) | |
123 | - [c0e428aca21b] redhat: everything in /etc/lldpd.d is a configuration file (Vincent Bernat) | |
124 | - [4fe6e6d026da] redhat: reference /etc/lldpd.d/README.conf (Vincent Bernat) | |
125 | - [5cffb4e7a7ee] redhat: use appropriate macros for directory (Vincent Bernat) | |
126 | ||
0 | 127 | 0.7.11 [2014-10-08 19:27:00 +0200]: |
1 | 128 | |
2 | 129 | - [62446808f97a] release: prepare 0.7.11 (Vincent Bernat) |
37 | 164 | - [0a735dedbdf7] zsh: add ZSH completion (Vincent Bernat) |
38 | 165 | - [2136d8066293] bash: move bash completion outside Debian packaging (Vincent Bernat) |
39 | 166 | - [3620ee09fa2f] release: new version 0.7.10 (Vincent Bernat) |
167 | ||
168 | 0.7.10 [2014-07-21 18:06:54 +0200]: | |
169 | ||
40 | 170 | - [87ebf13df38c] NEWS: add a word about json-c library support (Vincent Bernat) |
41 | 171 | - [5dcd280d1267] lldpcli: fix jansson implementation of the JSON output (Vincent Bernat) |
42 | 172 | - [71542b4ec734] configure: if --with-json, default to jansson implementation (Vincent Bernat) |
402 | 532 | |
403 | 533 | 0.7.2 [2013-04-20 02:59:47 +0200]: |
404 | 534 | |
405 | ||
406 | 0.7.11 [2014-10-08 19:27:00 +0200]: | |
407 | ||
408 | - [62446808f97a] release: prepare 0.7.11 (Vincent Bernat) | |
409 | - [3b0273eef9c3] man: sync lldpcli description of pattern matching (Vincent Bernat) | |
410 | - [3af43e64a6cf] man: say that by default only physical interfaces are used (Vincent Bernat) | |
411 | - [a2b113ef9d48] lldpd: check if capabilities are available/supported before enabling them (kanna) | |
412 | - [71cc157933f6] build: hide invocation of sed command to generate some files (Vincent Bernat) | |
413 | - [f24382c41668] lldpd: also try /usr/lib/os-release if /etc/os-release is not present (Vincent Bernat) | |
414 | - [3a8e3db1d622] build: remove useless variables from pkgconfig file (Vincent Bernat) | |
415 | - [e26fbbae1599] build: use @sbindir@ instead of @prefix@/sbin (Vincent Bernat) | |
416 | - [95493844623c] build: use AC_CONFIG_FILES only to generate Makefiles (Vincent Bernat) | |
417 | - [326808ff3c7c] debian: ship /etc/lldpd.d (Vincent Bernat) | |
418 | - [7255aab1196e] client: ship /etc/lldpd.d and put a README file in it (Vincent Bernat) | |
419 | - [c80ee6f068fe] build: allow use of older versions of json-c (Vincent Bernat) | |
420 | - [d2badd57c3b6] lib: don't check for NULL before free (Vincent Bernat) | |
421 | - [70f6059b9b7d] lib: make a copy of state_data, since pointer can be re-used (kanna) | |
422 | - [ad7daaf7957e] debian: also install zsh completion (Vincent Bernat) | |
423 | - [38ace3d484f8] debian: also install bash completion (Vincent Bernat) | |
424 | - [9b11faad6fbb] lldpd: abort when some options are repeated (Vincent Bernat) | |
425 | - [e37cdbe61624] Revert "debian: ship files in debian/etc/lldpd.d" (Vincent Bernat) | |
426 | - [790752d0b5e7] interfaces: only use physical interfaces to get a chassis ID (Vincent Bernat) | |
427 | - [8e9bf5cd846b] debian: ship files in debian/etc/lldpd.d (Vincent Bernat) | |
428 | - [79790b96b5eb] build: check if pkg-config is correctly installed in ./autogen.sh (Vincent Bernat) | |
429 | - [17cd6a2ec9ed] build: check for needed commands in autogen.sh (Vincent Bernat) | |
430 | - [a9f774888552] build: provide a sysusers.d file (Vincent Bernat) | |
431 | - [dbfa89c6e597] lldpd: handle early cleanup in case interface cannot be created (Vincent Bernat) | |
432 | - [8568f6cd2277] lib: handle read failure in sync case (Vincent Bernat) | |
433 | - [e1556c13cceb] lib: really correctly handle read failure (Vincent Bernat) | |
434 | - [2c4dda069401] lldpcli: disable SIGPIPE (Vincent Bernat) | |
435 | - [62f2faac3c69] lib: correctly handle read failure (Vincent Bernat) | |
436 | - [89a8419047d4] lib: stricter checks when resuming an operation in progress (Vincent Bernat) | |
437 | - [797da1252a18] lldpcli: add editor local variables to bash completion (Vincent Bernat) | |
438 | - [8bddf2143914] lldpcli: add editor local variables to zsh completion (Vincent Bernat) | |
439 | - [8d641ab478fc] lldpcli: indent multiline texts (like system description) (Vincent Bernat) | |
440 | - [320238c4de15] lldpcli: fix style convention to match other files (Vincent Bernat) | |
441 | - [c2153fb65e21] bash/zsh: ensure completions are present in dist tarball (Vincent Bernat) | |
442 | - [9bc3d50e21dc] NEWS: add a word about bash/zsh completion (Vincent Bernat) | |
443 | - [0a735dedbdf7] zsh: add ZSH completion (Vincent Bernat) | |
444 | - [2136d8066293] bash: move bash completion outside Debian packaging (Vincent Bernat) | |
445 | - [3620ee09fa2f] release: new version 0.7.10 (Vincent Bernat) | |
446 | ||
447 | 0.7.10 [2014-07-21 18:06:54 +0200]: | |
448 | ||
449 | - [87ebf13df38c] NEWS: add a word about json-c library support (Vincent Bernat) | |
450 | - [5dcd280d1267] lldpcli: fix jansson implementation of the JSON output (Vincent Bernat) | |
451 | - [71542b4ec734] configure: if --with-json, default to jansson implementation (Vincent Bernat) | |
452 | - [368daef3d649] cdp: complete manual page with CDP-related options (Vincent Bernat) | |
453 | - [611aba00053c] cdp: Make it possible to enable CDPv2 without enabling CDPv1 (Michel Stam) | |
454 | - [5d8f75fe9fdc] lldpcli: Add json description to lldpcli usage (Michel Stam) | |
455 | - [619c379964fd] cdp: Add power requirement to CDPv2 frames (Michel Stam) | |
456 | - [8ff14a6d117e] lldpcli: Add support for JSON-C (Michel Stam) | |
457 | - [62d6f99d2d17] lldpcli: make complete command work on privleged commands as well (Vincent Bernat) | |
458 | - [314f382a5093] lldpcli: provide a hidden complete command for shell completion (Vincent Bernat) | |
459 | - [e13945c02c44] lldpcli: change how privileged commands are declared (Vincent Bernat) | |
460 | - [40df69956ad0] lldpcli: reformat a bit bash completion to be more readable (Vincent Bernat) | |
461 | - [ecd41283aa58] priv: avoid a socket leak when interface is already in promisc (Vincent Bernat) | |
462 | - [ba908c4eedaa] snmp: avoid deferencing a pointer when it may be NULL (Vincent Bernat) | |
463 | - [5317a14a3f0e] dcbx tlv recd are printed as log_debug (Sam Tannous) | |
464 | - [7efa65c16ec7] lldpcli: use protocol map from liblldpctl to select protocol (Vincent Bernat) | |
465 | - [baaa96d1530c] lldpcli: document `-u` argument in synopsis (Vincent Bernat) | |
466 | - [494264f0f831] lldpcli: add display filter to show nbrs running specific protocols (Sam Tannous) | |
467 | - [e147917d5257] lib: update liblldpctl versioning (Vincent Bernat) | |
468 | - [1fa64c11d337] Add call to process more messages from data already read. (Sam Tannous) | |
469 | - [0469161dd554] Add error code to the multicast address add/delete failure msg (Sam Tannous) | |
470 | - [4f670a1e8ace] Move interface update msg to debug level (Sam Tannous) | |
471 | - [003620d3104b] Add ignore handler for SIGHUP in lldpcli (Sam Tannous) | |
472 | - [aef05ae38c63] This patch adds bash completion for lldpcli. (Sam Tannous) | |
473 | - [ea51049df882] snmp: use poll() to wait for AgentX socket to be ready (Vincent Bernat) | |
474 | - [dc6436adb4db] snmp: preserve previous flags when making AgentX socket non-blocking (Vincent Bernat) | |
475 | - [b93e39a16736] make agentx socket non-blocking (Sam Tannous) | |
476 | - [ad21b578b215] Make "too many neighbors for port" msg appear less frequently (Sam Tannous) | |
477 | - [aca48e4ba570] lldpd: Fix netlink notification group for address changes (Sam Tannous) | |
478 | - [b0b8841b0b42] Increase event buffer (Sam Tannous) | |
479 | - [e595efb4c177] log: info messages should be logged on syslog but not on first debug level (Vincent Bernat) | |
480 | - [254e5134d933] lldpd: fix log_info (Sam Tannous) | |
481 | - [5e23c6b99bd3] NEWS: credit seccomp fix (Vincent Bernat) | |
482 | - [d64549384f6f] lldpd: fix use of NULL in execl* (Vincent Bernat) | |
483 | - [d769cdb235cc] Merge pull request #70 from chutz/seccomp-whitelist (Vincent Bernat) | |
484 | - [285b33afd0da] lldpd: whitelist sendto, poll, recvmsg and readv in seccomp sandbox (Patrick McLean) | |
485 | - [1059a20e7e2d] NEWS: add a word about ability to disable LLDP (Vincent Bernat) | |
486 | - [b8a802bc7d8a] lldpd: fix how LLDP can be disabled (Vincent Bernat) | |
487 | - [806eaef4832a] cdp: don't expect and off-by-one checksum (Vincent Bernat) | |
488 | - [a5a60bbf97ed] frame: fix CDP checksum (udbxtd2008) | |
489 | - [f4da5f84837c] README: document the new promisc interface in README as well (Vincent Bernat) | |
490 | - [0a6f3866b830] lldpcli: give more details in the manual page about promiscuous mode (Vincent Bernat) | |
491 | - [f84199ddf6c9] lldpcli: add an option to enable promisc mode on managed interfaces (Vincent Bernat) | |
492 | - [ace524261458] priv: don't output rc status twice when unable to open socket (Vincent Bernat) | |
493 | - [50724a52606f] README: more about Cisco sending LLDP frames on VLAN 1 (Vincent Bernat) | |
494 | - [af5f56616c7f] osx: update version to 0.7.9 (Vincent Bernat) | |
495 | - [02e51cb01a07] debian: sync a bit with official packaging (Vincent Bernat) | |
496 | - [70943e342fff] version: prepare a new release (Vincent Bernat) | |
497 | - [cf11ddf09817] lldpd: trigger regular interface refresh when changing port ID (Vincent Bernat) | |
498 | - [bef085b8dbca] lldpcli: document `configure lldp portidsubtype` command (Vincent Bernat) | |
499 | - [e82818d13e77] NEWS: mention ability to configure port ID (Vincent Bernat) | |
500 | - [ff0a278f264a] lldpcli: fix a format warning (Vincent Bernat) | |
501 | - [cf719ce84bf0] lldpcli: remove unused variable (Vincent Bernat) | |
502 | - [8fbd31953957] Support for modifying PortID TLV (Sam Tannous) | |
503 | - [ba66666322f9] README: point to the website for install instructions (Vincent Bernat) | |
504 | - [f7f82e1e2a37] README: update the intro to better match the reality (Vincent Bernat) | |
505 | - [fd7bb9f409e6] travis: don't use regular options when on coverity branch (Vincent Bernat) | |
506 | - [cddf0a08236b] travis: don't do anything if not on the coverity branch (Vincent Bernat) | |
507 | - [d82e81816b5e] travis: reduce matrix by not compiling everything with clang (Vincent Bernat) | |
508 | - [b2c51a1d62be] travis: integrate coverity script in regular run.sh (Vincent Bernat) | |
509 | - [78f816e9af24] travis: when running coverity, skip regular build (Vincent Bernat) | |
510 | - [0db5b7bbffa6] travis: don't try to install launchd/systemd stuff (Vincent Bernat) | |
511 | - [c034207574e1] travis: no need for `make install` (Vincent Bernat) | |
512 | - [7b4eb1949a4b] bsd: ensure we also have space for the padding after BPF header (Vincent Bernat) | |
513 | - [eeb66a08bdb7] bsd: ensure proper alignment of BPF header (Vincent Bernat) | |
514 | - [986effcb7a97] bsd: ensure we also have space for the BPF header (Vincent Bernat) | |
515 | - [3d596bbefdd9] bsd: fix clang warning about alignment problem with sockaddr (Vincent Bernat) | |
516 | - [dd82040caf7d] travis: run "make distcheck" with the appropriate configure arguments (Vincent Bernat) | |
517 | - [7e4a91f0481d] travis: only run "make distcheck" (Vincent Bernat) | |
518 | - [047ab6702ded] travis: on OS X, try with/without embedded libevent and with/without SNMP (Vincent Bernat) | |
519 | - [45bf176ba539] travis: try to build only with clang on OS X (Vincent Bernat) | |
520 | - [54c78d4c61e2] travis: use devel version of net-snmp on OSX (Vincent Bernat) | |
521 | - [98e2e4754996] travis: misc change to trigger a rebuild (Vincent Bernat) | |
522 | - [622d14bbdf16] lldpcli: directive to configure IP management pattern (Vincent Bernat) | |
523 | - [6afb24c220d8] lldp: fix handling of LLDPDU expiration (Vincent Bernat) | |
524 | - [a85eea84bb3f] NEWS: mention support for shutdown LLDPDU (Vincent Bernat) | |
525 | - [5a215d4b32cd] lldp: support for shutdown LLDPU (Vincent Bernat) | |
526 | - [0e29d79487c5] interfaces: default to use of a local administered MAC address for bonds (Vincent Bernat) | |
527 | - [d5f8351c8367] NEWS: mention the fix for local address use (Vincent Bernat) | |
528 | - [8229c8ebd9ba] man: more documentation for bond-slave-src-mac-type (Vincent Bernat) | |
529 | - [c6d4d3229fb8] interfaces: fallback to fixed MAC if already a local MAC (Vincent Bernat) | |
530 | - [9173f75725a8] interfaces: fix use of locally administered use on bond devices (Vincent Bernat) | |
531 | - [860c5567ba39] osx: use /var as a base for socket location (Vincent Bernat) | |
532 | - [2cbc9cc56219] man: use configured path for /var/run/lldpd.socket (Vincent Bernat) | |
533 | - [5133ce2fc2b9] configure: make default PID location configurable (Vincent Bernat) | |
534 | - [3a3a36239b5d] configure: make default socket location configurable in configure (Vincent Bernat) | |
535 | - [9a4ed64aabbb] configure: use `runstatedir` instead of /var/run in configure (Vincent Bernat) | |
536 | - [08841844176c] configure: don't use fallback values in summary (Vincent Bernat) | |
537 | - [cdcf7dc577a2] lldpcli: return success when reading commands from files (Vincent Bernat) | |
538 | - [084988d49489] osx: update Homebrew formula to match what has been done in Homebrew (Vincent Bernat) | |
539 | - [c6d3aa0f58f4] configure: enable use of colored output for gcc (Vincent Bernat) | |
540 | - [8f109ee23771] configure: use -fstack-protector-strong if available (Vincent Bernat) | |
541 | - [70f4df2aaa49] osx: new release (Vincent Bernat) | |
542 | - [17a90fc0af9c] lldpcli: document new "configure system hostname" directive (Vincent Bernat) | |
543 | - [412a1dadab09] version: prepare new release (Vincent Bernat) | |
544 | - [724d71ea13ce] NEWS: add several items to the changelog (Vincent Bernat) | |
545 | - [3dc1eb8ca263] configure: make some flags conditional (Vincent Bernat) | |
546 | - [67d43beb0834] osx: blacklist p2pX interfaces (Vincent Bernat) | |
547 | - [29760896f54e] configure: hide errors when systemd is not present (Vincent Bernat) | |
548 | - [6579462d82d4] compat: fix vsyslog to rely on the result of vasprintf (Vincent Bernat) | |
549 | - [f31ac893ad90] compat: include stdarg to get va_list (Vincent Bernat) | |
550 | - [dbc971443826] compat: fix use of vasprintf (previously _vasprintf) (Vincent Bernat) | |
551 | - [3522094f0d24] lldpcli: use a previously unused variable (Vincent Bernat) | |
552 | - [984bbcbc1126] lldpd: add a note about command-line options (Vincent Bernat) | |
553 | - [f88a0f1f8209] Merge pull request #60 from jonasj76/override-hostname (Vincent Bernat) | |
554 | - [dfa181af0730] lldpd: Remove the '-N' command-line flag (Jonas Johansson) | |
555 | - [ce347d296c89] lldp: add option/command to override hostname (Jonas Johansson) | |
556 | - [87dfd17553de] coverity: change a bit the annotations (Vincent Bernat) | |
557 | - [b64a011bf4e4] coverity: fix a false positive in SNMP transport (Vincent Bernat) | |
558 | - [79dae0f0d8fb] coverity: fix memory leak in lldpd when the same option is repeated (Vincent Bernat) | |
559 | - [af35cabd68c6] coverity: fix memory leak in lldpcli (Vincent Bernat) | |
560 | - [d0b88676ed80] redhat: enable SNMP support on RHEL 5 and CentOS 5 by default (Vincent Bernat) | |
561 | - [ae7f4c2945f0] snmp: link with Net-SNMP later (Vincent Bernat) | |
562 | - [bd3da7c52879] priv: use AF_UNIX for socketpair() (Vincent Bernat) | |
563 | - [1a3dd5a8e028] configure: _XOPEN_SOURCE=500 to be like _GNU_SOURCE=1 (Vincent Bernat) | |
564 | - [554d650db8dc] hpux: provide a replacement for daemon() for HP-UX (Vincent Bernat) | |
565 | - [9f497e04a0a8] hpux: provide a replacement for vsyslog() for HP-UX (Vincent Bernat) | |
566 | - [da0a34dd6ba6] asprintf: we are also using vasprintf, let's define it correctly (Vincent Bernat) | |
567 | - [24b8d79f8895] build: use __EXTENSIONS__ and _XOPEN_SOURCE_EXTENDED everywhere (Vincent Bernat) | |
568 | - [9fe83ec06914] bsd: check of SIOCGIFDESCR instead of IFDESCRSIZE (Vincent Bernat) | |
569 | - [f41ed9c5bd31] privsep: don't use err.h: not needed (Vincent Bernat) | |
570 | - [6a5334d4d523] asprintf: fix warnings in SNMP tests related to asprintf (Vincent Bernat) | |
571 | - [0921a7f4ce4a] asprintf: do not redeclare on SNMP tests (Vincent Bernat) | |
572 | - [46673df2cbbe] asprintf: globally define _GNU_SOURCE (Vincent Bernat) | |
573 | - [39f940da4592] debian: fix postinst to create _lldpd user (Vincent Bernat) | |
574 | - [64ee56f83848] debian: same style for postinst and postrm (Vincent Bernat) | |
575 | - [b345311cbb8f] lib: use strlcpy() instead of strcpy() (Vincent Bernat) | |
576 | - [c6aa43e5b86d] interfaces: convert a whitelisted interface to a physical one (Vincent Bernat) | |
577 | - [627e31c489e6] interfaces: circumvent any physical check on exact match (Vincent Bernat) | |
578 | - [8b53fc2c2ad5] interfaces: allow whitelisting an interface (Vincent Bernat) | |
579 | - [d5e69431014a] interfaces: document and test pattern matching (Vincent Bernat) | |
580 | - [3ff9f162a184] build: use -fno-omit-frame-pointer for ease of debug (Vincent Bernat) | |
581 | - [27faad4fd793] lib: don't use strlcpy() when strcpy() just works (Vincent Bernat) | |
582 | - [dcf5d2f72dc9] build: remove duplicate const declaration (Vincent Bernat) | |
583 | - [ed9e6f414305] travis: put installation and test instructions into shell scripts (Vincent Bernat) | |
584 | - [81c693e642a4] travis: test with OSX and clang (Vincent Bernat) | |
585 | - [971d12ce529b] build: on OSX, use glibtoolize by default (Vincent Bernat) | |
586 | - [02987888adc8] lldpcli: fix readline() wrapper to take prompt as argument (Vincent Bernat) | |
587 | - [fe8f9650079c] lldpcli: check for privileges by checking access to control socket (Vincent Bernat) | |
588 | - [91f424d16491] lldpcli: root is privileged (Vincent Bernat) | |
589 | - [cc160b887858] interfaces: reset router and wlan capability bits (Vincent Bernat) | |
590 | - [6b0954714065] lldpd: enable "stationOnly" capability if we don't have anything else (Vincent Bernat) | |
591 | - [0c1589a2fea8] lib: add URL in lldpctl.pc (Vincent Bernat) | |
592 | - [edc0cc14a8c4] lib: fix includedir in lldpctl.pc (Vincent Bernat) | |
593 | - [69abf8b2b37c] fgetln: provide a version not relying on getline() (Vincent Bernat) | |
594 | - [31594635ecc1] daemon: unset UPSTART_JOB and NOTIFY_SOCKET once used (Vincent Bernat) | |
595 | - [45bf0bd0627d] lldpd: use vfork+exec instead of fork+exec (Vincent Bernat) | |
596 | - [16bbd290d5d7] priv: add compilation without privilege separation to Travis (Vincent Bernat) | |
597 | - [71a7dbb3c64d] priv: add the ability to disable privilege separation (Vincent Bernat) | |
598 | - [d2a289bba82f] privsep: IO should specify the context (Vincent Bernat) | |
599 | - [8b0ca98ef399] README: add build instructions for Android (Vincent Bernat) | |
600 | - [69a7ffa0bac8] include: don't ship `linux/socket.h` (Vincent Bernat) | |
601 | - [afe3dabf9eed] priv: declare `res_init()` for builds against Android's Bionic (Vincent Bernat) | |
602 | - [608b5669ebf1] lldpcli: replace safe use of `strcpy` by `strlcpy` (Vincent Bernat) | |
603 | - [0fd9e6e25bfb] build: hide generation of syscall-names.h (Vincent Bernat) | |
604 | - [7ee3d13d3637] cdp: fix regression in CDP packet building (Vincent Bernat) | |
605 | - [12313820fafc] lldp: don't hard-code sysname, sysdescr and portdescr (Vincent Bernat) | |
606 | - [912dfcff033b] interfaces: remove useless return (Vincent Bernat) | |
607 | - [d79850426254] lldp: do not send system description TLV if empty (Vincent Bernat) | |
608 | - [493b0d427fb4] configure: provide GitHub address for issues (Vincent Bernat) | |
609 | - [ed409ccd3ef8] clang: use ETHER_ADDR_LEN instead of sizeof() (Vincent Bernat) | |
610 | - [dd1d33cf7c97] marshal: use __alignof__ operator if available (Vincent Bernat) | |
611 | - [e4dea55d69be] clang: fix an obvious use after free (Vincent Bernat) | |
612 | - [6f4b6d5872c3] alignof: handle sizeof(t) == 1 case (Vincent Bernat) | |
613 | - [d68f1b813cf8] coverity: really fix popt issue (Vincent Bernat) | |
614 | - [46a5f939b66d] coverity: add code annotation to remove false positives (Vincent Bernat) | |
615 | - [26667615414c] coverity: if we cannot read /etc/localtime, don't go further (Vincent Bernat) | |
616 | - [8ad3bafab619] coverity: don't fallback to next case for clarity (Vincent Bernat) | |
617 | - [e2b09091a263] coverity: replace unsafe uses of strncpy by strlcpy (Vincent Bernat) | |
618 | - [cdece23a6df4] coverity: remove always false comparison (Vincent Bernat) | |
619 | - [39d78d567ddf] coverity: remove dead code (Vincent Bernat) | |
620 | - [037d4c8ea40e] coverity: don't make `-L` flag switch off version advertisement (Vincent Bernat) | |
621 | - [3332985ad598] coverity: handle case where we didn't get enough place in getopt string (Vincent Bernat) | |
622 | - [ddd75166dd41] coverity: remove a theoritical memory leak (Vincent Bernat) | |
623 | - [4032084d12c4] coverity: fix a memory leak (Vincent Bernat) | |
624 | - [3ee3f25d9ad2] coverity: fix a resource leak (Vincent Bernat) | |
625 | - [b7e2b07c1eb6] coverity: fix TOCTOU problem when creating chroot (Vincent Bernat) | |
626 | - [0059e4786dc8] coverity: remove dead code (Vincent Bernat) | |
627 | - [a56f413747cf] coverity: remove unused pointer value (Vincent Bernat) | |
628 | - [6df40257e2c1] gitignore: add GNU global files (Vincent Bernat) | |
629 | - [872caaf9e779] debian: fix debian/lldpd.install to use provided lldpd.service (Vincent Bernat) | |
630 | - [82e23221f46a] redhat: don't try to install systemd stuff (Vincent Bernat) | |
631 | - [a28d7016c92e] redhat: fix version in lldpd.spec (Vincent Bernat) | |
632 | - [e4e5a1f8efc2] osx: update homebrew recipe (Vincent Bernat) | |
633 | - [d72c2c591fb6] release: prepare for release of 0.7.7 (Vincent Bernat) | |
634 | - [3a9dc9c133f5] lldpd: tell `lldpcli` to use the appropriate control socket (Vincent Bernat) | |
635 | - [f7242beb1ef8] lldpcli: accepts `-u` option to specify control socket (Vincent Bernat) | |
636 | - [b6312220edf5] privsep: put /etc/localtime in chroot (Vincent Bernat) | |
637 | - [4006b64e3a92] systemd: also read /etc/sysconfig/lldpd (Vincent Bernat) | |
638 | - [ff4d7fa9c7ef] systemd: require mount points to have chroot possible (Vincent Bernat) | |
639 | - [25f47deab82c] systemd: starts lldpd after network (Vincent Bernat) | |
640 | - [c2e68bff3dda] tests: only test if we have `check` installed (Vincent Bernat) | |
641 | - [246701fe22bd] seccomp: do not ship `syscall-names.h` (Vincent Bernat) | |
642 | - [6a427fb18c67] travis: don't limit tests to master branch. (Vincent Bernat) | |
643 | - [4e97a0bf8488] lib: fix a segfault introduced in ef3707 when freeing an atom (Vincent Bernat) | |
644 | - [00e40dba232c] seccomp: add support for seccomp through libseccomp (Vincent Bernat) | |
645 | - [bde52887c7f4] systemd: use full path for mkdir/cp (Vincent Bernat) | |
646 | - [140e34f05746] systemtap: provide an appropriate tapset (Vincent Bernat) | |
647 | - [bdfe41938907] dtrace: add systemtap/DTrace support (Vincent Bernat) | |
648 | - [5f7d1cd51fe9] README: explain how to handle VLAN-encapsulated LLDP frames (Vincent Bernat) | |
649 | - [f17837f781b0] configure: use a convenience library for fixed point arithmetic (Vincent Bernat) | |
650 | - [c0cdd0111f3f] Revert "README: remove inexact paragraph about stacking bonding/vlans/bridges" (Vincent Bernat) | |
651 | - [12baf7811f63] linux: fix a regression in how enslaved devices' MAC addresses are retrieved (Vincent Bernat) | |
652 | - [dbcb684662e2] event: don't call `netsnmp_check_outstanding_agent_requests()` (Vincent Bernat) | |
653 | - [9a4e257b0ad1] priv: use unistd.h to get `close()` (Vincent Bernat) | |
654 | - [4565704cef06] configure: remove an extra parenthesis in args.m4 (Vincent Bernat) | |
655 | - [4dfe31fd72ad] systemd: install service file using `systemdsystemunit_DATA` (Vincent Bernat) | |
656 | - [bdc954b77ada] lib: fix notification by reading one byte at a time from Unix socket (Vincent Bernat) | |
657 | - [9d1524b7de1c] systemd: ship lldpd.service file if possible (Vincent Bernat) | |
658 | - [41e57d5a8821] lldpd: fix a segfault when a port disappear (Vincent Bernat) | |
659 | - [42ea638d61b5] lldpd: small optimization in the expiration process (Vincent Bernat) | |
660 | - [ef3707dacfd9] lldpd: make notifications work when a port goes down (Vincent Bernat) | |
661 | - [f5a0a15ea37d] linux: add support for team devices (Vincent Bernat) | |
662 | - [5813918ade1b] rpc: don't check source MAC settings when it is 0 (Vincent Bernat) | |
663 | - [7d758eec2bf7] interfaces: mangle source MAC address on bonds for other OS too (Vincent Bernat) | |
664 | - [5347914ef1fc] interfaces: abstract a bit MAC address mangling for bonding devices (Vincent Bernat) | |
665 | - [99704cd9b9ff] interfaces: move "mangle" function for bond slaves (Vincent Bernat) | |
666 | - [bae18e13c284] lldpcli: remove unused variable (Vincent Bernat) | |
667 | - [d7166588be78] lib: update version-info to match previous changes (Vincent Bernat) | |
668 | - [2746d430fbcc] bond: reenable the possibility to use a fixed MAC address (Vincent Bernat) | |
669 | - [c9703b9640ac] client: move register of bond-slave-src-mac-type to a separate function (Vincent Bernat) | |
670 | - [dfbd7185f823] [PATCH| lldpd: use bond slave real mac with locally administered bit set as sour ce man in lldp frames sent on bond slaves (Roopa Prabhu) | |
671 | - [87bc6683c602] linux: mangle MAC address for enslaved devices (Vincent Bernat) | |
672 | - [96f2411a2bbf] lib: fix parsing of "11542." (Vincent Bernat) | |
673 | - [f730f6c5f648] lib: introduce proper fixed point parsing and representation module (Vincent Bernat) | |
674 | - [d2c04230fb3a] lib: correctly set altitude unit without erasing neighbouring data (Vincent Bernat) | |
675 | - [bec75f842fa4] event: replace `evutil_make_socket_nonblocking()` by an idempotent version (Vincent Bernat) | |
676 | - [1e0d651f6ec9] lldpd: invoke `setproctitle_init()` when needed (Vincent Bernat) | |
677 | - [5c4fa9bdc202] priv: use `sigaction()` instead of `signal()` to install non-default signals (Vincent Bernat) | |
678 | - [82fcdf156dd2] README: on OSX, /etc is a symlink to /private/etc. (Vincent Bernat) | |
679 | - [c3f855602d84] osx: make the path to /Library/LaunchDaemons configurable (Vincent Bernat) | |
680 | - [352897291cc5] osx: minimize differences with downstream Homebrew formula (Vincent Bernat) | |
681 | - [6ed2b9ad9b4f] osx: fix a syntax error in Homebrew formula (Vincent Bernat) | |
682 | - [91a63c540e59] osx: patch the installation of launchd plist file for Homebrew (Vincent Bernat) | |
683 | - [53c56a7a0fef] osx: don't remove the whole /Library/LaunchDaemons directory on uninstall! (Vincent Bernat) | |
684 | - [d0a033727caa] configure: check for `res_init()` before trying other forms. (Vincent Bernat) | |
685 | - [ba09084d4764] README: remove inexact paragraph about stacking bonding/vlans/bridges (Vincent Bernat) | |
686 | - [25354cf35113] osx: update SHA1 sum for Homebrew recipe (Vincent Bernat) | |
687 | - [09587df0ed71] osx: fix postinstall script (Vincent Bernat) | |
688 | - [3336988a6ccd] packaging: change `PreReq` to `Requires(pre)` in lldpd.spec (Vincent Bernat) | |
689 | - [03b0a19012f9] packaging: update to 0.7.6 (Vincent Bernat) | |
690 | - [22f1ea467ef9] README: show how to use tcpdump for troubleshooting (Vincent Bernat) | |
691 | - [065732ca3413] priv: correctly declare `priv_cmd` type (Vincent Bernat) | |
692 | - [bcde9c0aa535] doc: add a CONTRIBUTE document (Vincent Bernat) | |
693 | - [fef34dede19b] linux: define IFALIASZ for old systems (Vincent Bernat) | |
694 | - [3a723384557d] lldpd: fix a fd leak when we cannot write the new alias (Vincent Bernat) | |
695 | - [015ecdd5f6ac] lldpd: append "was" to an interface description when a neighbor disappear (Vincent Bernat) | |
696 | - [bb37268d812b] client: add "configure/unconfigure system interface description" command (Vincent Bernat) | |
697 | - [2de09499f87f] lib: `lldpctl_k_config_receiveonly` is a read-only property (Vincent Bernat) | |
698 | - [47820fc416cc] interfaces: overwrite interface description with neighbor found (Vincent Bernat) | |
699 | - [53d4577a63fd] priv: avoid to leak generic socket (Vincent Bernat) | |
700 | - [4ea0565ebd7c] privsep: separate OS specific code to dedicated files (Vincent Bernat) | |
701 | - [784077f8b096] redhat: require groupadd/useradd (Vincent Bernat) | |
702 | - [31e4e7c6205f] osx: don't repeat `pkg-ref` several times in `distribution.xml` (Vincent Bernat) | |
703 | - [4c4e1aef7a51] osx: don't use `domains` tag in `distribution.xml` (Vincent Bernat) | |
704 | - [462d8b6c813a] osx: add a way to compile for older versions of OS X (Vincent Bernat) | |
705 | - [fa71a00c8b1a] osx: `make pkg` can now build universal binaries (Vincent Bernat) | |
706 | - [5b90c4f5c054] osx: don't try to build universal binaries (Vincent Bernat) | |
707 | - [42494121e890] configure: remove out-dated instructions to regen autoconf out-of-git (Vincent Bernat) | |
708 | - [5e36732de776] snmp: fix a typo in `agent_priv.c` (Vincent Bernat) | |
709 | - [e9f4d63c9efa] configure: ensure that osx/scripts are executable (Vincent Bernat) | |
710 | - [7298e28fad13] osx: use HTML files instead of RTF for welcome message (Vincent Bernat) | |
711 | - [92f5db08c399] osx: simpler instructions in README.md (Vincent Bernat) | |
712 | - [b708297cbab9] osx: add a target to build an OSX package (Vincent Bernat) | |
713 | - [abacd8d20f8c] configure: fix a typo in the description of `--with-embedded-libevent` option (Vincent Bernat) | |
714 | - [e37255a58218] travis: check that we can build lldpd with embedded libevent (Vincent Bernat) | |
715 | - [f829effd3fe8] configure: add a flag to force use of embedded libevent (Vincent Bernat) | |
716 | - [eea17f742927] debian: update packaging to match downstream (Vincent Bernat) | |
717 | - [edc437d94f56] compat: include config.h in compat.h (Vincent Bernat) | |
718 | - [28178982aa65] compat: fix strndup (Vincent Bernat) | |
719 | - [2523da3af610] NEWS: add an entry about the use of `strndup()` (Vincent Bernat) | |
720 | - [7354ec8f2bd0] compat: add `strndup()` compatibility function (Vincent Bernat) | |
721 | - [d52cf1d2729f] compat: remove copyright notice for setproctitle() (Vincent Bernat) | |
722 | - [c6540ece3ea7] tests: define ck_assert_ptr_eq if check is too old (Vincent Bernat) | |
723 | - [46a402c55b96] osx: use SHA1 instead of MD5 in homebrew formula (Vincent Bernat) | |
724 | - [1e8952da6db7] check: use `ck_assert_ptr_eq` instead of `ck_assert_int_eq`. (Vincent Bernat) | |
725 | - [b0cb07f7ed0b] style: use C99 designated initializers instead of memset() when possible (Vincent Bernat) | |
726 | - [444c6862d096] packaging: update to 0.7.5 (Vincent Bernat) | |
727 | - [2169efb24f0a] tokenizer: input buffer was too small (Vincent Bernat) | |
728 | - [6712d3ec1409] packaging: update packaging (Vincent Bernat) | |
729 | - [138121782171] bpf: on OpenBSD, invert the filter direction (Vincent Bernat) | |
730 | - [96b97fac65bb] NEWS: add an entry for the use of `setproctitle()` (Vincent Bernat) | |
731 | - [f0d215766ac0] compat: declare `setproctitle()` as a printf function (Vincent Bernat) | |
732 | - [19ce8130c7f1] debian: build-depends on libbssd-dev (Vincent Bernat) | |
733 | - [e7103aff39e2] lldpd: when no `setproctitle()` available, don't count neighbors (Vincent Bernat) | |
734 | - [480f1c6130ef] lldpd: count number of chassis to get number of neighbors (Vincent Bernat) | |
735 | - [25eb1871461a] lldpd: don't call `lldpd_count_neighbors()` too many times (Vincent Bernat) | |
736 | - [66879d46ac2b] build: use libbsd if available, also use `setproctitle()` (Vincent Bernat) | |
737 | - [3f70e1182aeb] lldpcli: `configure system platform` to override platform description (Vincent Bernat) | |
738 | - [decaec0d8a67] lldpcli: `configure system description` to override chassis description (Vincent Bernat) | |
739 | - [994b3371b3b0] lldpcli: split `conf.c` into `conf-system.c` and `conf-lldp.c`. (Vincent Bernat) | |
740 | - [48d0a4b0d72e] lldpcli: `configure system interface pattern` instead of `configure lldp iface-pattern` (Vincent Bernat) | |
741 | - [a3e0896768d4] libevent: use GitHub git tree (Vincent Bernat) | |
742 | - [c11e397a7598] debian: sync packaging with official Debian package (Vincent Bernat) | |
743 | - [e39f079a1558] libevent: switch to patches-2.0 branch to get the appropriate automake fix (Vincent Bernat) | |
744 | - [8677ddc78172] git: ignore test-driver, generated by recent automake versions (Vincent Bernat) | |
745 | - [bea0d76429a2] Fixed some boundary conditions in code that cleans remote ports on ttl expiry. (Roopa Prabhu) | |
746 | - [5aeda65433fd] liblldpctl: fix infinite loop when user is reading fixed chunks (Pradosh Mohapatra) | |
747 | - [d82342940c39] marshal: fix alignment issue when unserializing (Vincent Bernat) | |
748 | - [bea703140788] log: fix memory leak when using a log handler (Vincent Bernat) | |
749 | - [a8da18644b17] marshal: don't declare serialize/unserialize helper for string (Vincent Bernat) | |
750 | - [02cf0357c916] lldpd: fix an alignment (non-)issue (Vincent Bernat) | |
751 | - [bd8a8861df79] lldpcli: don't use an hack to pass the writer to watch callback (Vincent Bernat) | |
752 | - [985a4cb5f210] marshal: provide type-specific serialization/unserialization functions (Vincent Bernat) | |
753 | - [aba549a82a0f] client: fix a memory leak when changing lldpd configuration (Vincent Bernat) | |
754 | - [93afd294af9b] ctl: fix a memory leak when cleaning control socket (Vincent Bernat) | |
755 | - [e681c859c6c9] client: trigger interface refresh when updating interface pattern (Vincent Bernat) | |
756 | - [e26a25ca4d0e] lib: fix a memory leak when modifying interface pattern (Vincent Bernat) | |
757 | - [0093777b2894] lldpcli: document "configure lldp iface-pattern" in manual page (Vincent Bernat) | |
758 | - [7e516f104a85] lldpctl.h: document possibility to write iface-pattern (Vincent Bernat) | |
759 | - [346a0f6961ba] lldpcli: Add support to set iface-pattern (roopa) | |
760 | - [0728cb8205f7] sonmp: allow SONMP unittests to work without a global config (Vincent Bernat) | |
761 | - [ea481e370199] man: document tx-hold (Vincent Bernat) | |
762 | - [cb5f7399a79f] man: tx-interval cannot be set per port (Vincent Bernat) | |
763 | - [c10302a38ece] lldpd: Add tx_hold (roopa) | |
764 | - [5920dbf73ae1] lldpcli: don't rely on `fgetln()` providing a NULL-terminated string (Vincent Bernat) | |
765 | - [655145c07b89] lldpcli: don't free input line (Vincent Bernat) | |
766 | - [d1dc456f990f] lib: keep space for new values in `lldpctl_key_t` (Vincent Bernat) | |
767 | - [40116b407603] debian: synchronize packaging with Debian (Vincent Bernat) | |
768 | - [e91ca9d0157c] release: prepare 0.7.3 (Vincent Bernat) | |
769 | - [a1728b7df077] NEWS: add a word about Solaris support (Vincent Bernat) | |
770 | - [b1a8985da685] solaris: less intrusive way to get CMSG_* macros (Vincent Bernat) | |
771 | - [815b799b44ed] solaris: assume that IP forwarding is disabled (Vincent Bernat) | |
772 | - [c3e340b6be8a] solaris: preliminary support (Vincent Bernat) | |
773 | - [d0787f4e65c4] NEWS: add an entry about LLDP-MED fast start. (Vincent Bernat) | |
774 | - [486a61330146] lldpcli: allow to enable/disable fast-start and set delay (Vincent Bernat) | |
775 | - [d6d42d56f7eb] lldpd: enable fast start by default (Vincent Bernat) | |
776 | - [be511d00bf41] lldpd: make fast start work only when receiving LLDP-MED LLDPDU (Vincent Bernat) | |
777 | - [b9de0ca613f3] lldpd: fast start support (roopa) | |
778 | - [7ba4a1832e43] configure: use `AC_PROG_EGREP` to find a suitable `grep -E` (Vincent Bernat) | |
779 | - [ae5cae025029] lib: use uint8_t instead of u_int8_t (Vincent Bernat) | |
780 | - [91e0280a7e7d] configure: display configured OS (Vincent Bernat) | |
781 | - [885aa4f4aaba] lldpcli: complete the manual page with the syntax of "show statistics" (Vincent Bernat) | |
782 | - [d947819daaaa] lldpcli: summary of statistics is done on provided ports only (Vincent Bernat) | |
783 | - [048ed9db7ddf] lldpcli: fix two warnings introduced by the previous commit (Vincent Bernat) | |
784 | - [adcb76f83ac9] NEWS: add an entry for "show statistics summary" command (Vincent Bernat) | |
785 | - [5331eb2d47f0] lldpcli: global stats command (roopa) | |
786 | - [1b3eea3d9025] os: add support for DragonFly BSD (Vincent Bernat) | |
787 | - [de461f15d788] netlink: fix IP address discovery (Vincent Bernat) | |
788 | - [3fc1a10a030f] lldpcli: fix typo in the man page for setting altitude (Vincent Bernat) | |
789 | - [45a83f305d67] bsd: don't report a warning when no media information is present (Vincent Bernat) | |
790 | 535 | - [03ee074db6ca] build: both client and lib may need shipped headers in include/ (Vincent Bernat) |
791 | 536 | - [4c758e896ded] fgetln: getline may need _GNU_SOURCE (Vincent Bernat) |
792 | 537 | - [bed9f656dc3a] install: install ChangeLog (Vincent Bernat) |
13 | 13 | ChangeLog: __force-changelog-generation |
14 | 14 | $(AM_V_GEN)if test -d $(top_srcdir)/.git; then \ |
15 | 15 | prev=$$(git describe --tags --always --match '[0-9]*' 2> /dev/null) ; \ |
16 | for tag in $$(git tag | $(EGREP) '^[0-9]+(\.[0-9]+){1,}$$' | sort -rn); do \ | |
16 | for tag in $$(git tag | $(EGREP) '^[0-9]+(\.[0-9]+){1,}$$' | sort -t. -k 1,1nr -k 2,2nr -k 3,3nr); do \ | |
17 | 17 | if [ x"$$prev" = x ]; then prev=$$tag ; fi ; \ |
18 | 18 | if [ x"$$prev" = x"$$tag" ]; then continue; fi ; \ |
19 | 19 | echo "$$prev [$$(git log $$prev -1 --pretty=format:'%ai')]:" ; \ |
342 | 342 | LIPO = @LIPO@ |
343 | 343 | LLDPD_CTL_SOCKET = @LLDPD_CTL_SOCKET@ |
344 | 344 | LLDPD_PID_FILE = @LLDPD_PID_FILE@ |
345 | LLDP_CFLAGS = @LLDP_CFLAGS@ | |
346 | LLDP_CPPFLAGS = @LLDP_CPPFLAGS@ | |
347 | LLDP_LDFLAGS = @LLDP_LDFLAGS@ | |
345 | 348 | LN_S = @LN_S@ |
346 | 349 | LTLIBOBJS = @LTLIBOBJS@ |
347 | 350 | MAINT = @MAINT@ |
428 | 431 | mkdir_p = @mkdir_p@ |
429 | 432 | oldincludedir = @oldincludedir@ |
430 | 433 | pdfdir = @pdfdir@ |
434 | pkgconfigdir = @pkgconfigdir@ | |
431 | 435 | prefix = @prefix@ |
432 | 436 | program_transform_name = @program_transform_name@ |
433 | 437 | psdir = @psdir@ |
1067 | 1071 | ChangeLog: __force-changelog-generation |
1068 | 1072 | $(AM_V_GEN)if test -d $(top_srcdir)/.git; then \ |
1069 | 1073 | prev=$$(git describe --tags --always --match '[0-9]*' 2> /dev/null) ; \ |
1070 | for tag in $$(git tag | $(EGREP) '^[0-9]+(\.[0-9]+){1,}$$' | sort -rn); do \ | |
1074 | for tag in $$(git tag | $(EGREP) '^[0-9]+(\.[0-9]+){1,}$$' | sort -t. -k 1,1nr -k 2,2nr -k 3,3nr); do \ | |
1071 | 1075 | if [ x"$$prev" = x ]; then prev=$$tag ; fi ; \ |
1072 | 1076 | if [ x"$$prev" = x"$$tag" ]; then continue; fi ; \ |
1073 | 1077 | echo "$$prev [$$(git log $$prev -1 --pretty=format:'%ai')]:" ; \ |
0 | lldpd (0.7.14) | |
1 | * Features: | |
2 | + Shutdown LLPDU are sent on MSAP change and when lldpd exits. | |
3 | + When an exact IP is provided as a management pattern, use it | |
4 | unconditionally. | |
5 | + Ability to set port ID and description to an arbitrary value, | |
6 | thanks to Alexandru Ardelean. | |
7 | * Fix: | |
8 | + Incorrect boundary check when decoding management address and | |
9 | protocol identity may lead to lldpd crash when processing | |
10 | malformed LLDPDU. | |
11 | + Many edge cases where lldpd was leaving hanging processes after | |
12 | crashing. | |
13 | ||
14 | lldpd (0.7.13) | |
15 | * Fix: | |
16 | + Unbreak customization of Unix socket path from command line. | |
17 | ||
18 | lldpd (0.7.12) | |
19 | * Features: | |
20 | + Interface pattern, management pattern, system description, | |
21 | system platform and system hostname can be unconfigured to their | |
22 | default values. | |
23 | * Fix: | |
24 | + Don't complain when parsing a commented line. | |
25 | + Correctly persist configuration changes for "system interface | |
26 | promiscuous", "system interface description" "med fast-start | |
27 | enable", "pause" and "resume". | |
28 | + Fix listening on bond devices for old kernels (< 2.6.27). | |
29 | ||
0 | 30 | lldpd (0.7.11) |
1 | 31 | * Features: |
2 | 32 | + Ship bash and zsh completion. |
377 | 377 | # configured tree to be moved without reconfiguration. |
378 | 378 | |
379 | 379 | AC_DEFUN([AM_AUX_DIR_EXPAND], |
380 | [dnl Rely on autoconf to set up CDPATH properly. | |
381 | AC_PREREQ([2.50])dnl | |
382 | # expand $ac_aux_dir to an absolute path | |
383 | am_aux_dir=`cd $ac_aux_dir && pwd` | |
380 | [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl | |
381 | # Expand $ac_aux_dir to an absolute path. | |
382 | am_aux_dir=`cd "$ac_aux_dir" && pwd` | |
384 | 383 | ]) |
385 | 384 | |
386 | 385 | # AM_CONDITIONAL -*- Autoconf -*- |
0 | 0 | #! /bin/sh |
1 | 1 | # Guess values for system-dependent variables and create Makefiles. |
2 | # Generated by GNU Autoconf 2.69 for lldpd 0.7.11. | |
2 | # Generated by GNU Autoconf 2.69 for lldpd 0.7.14. | |
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='0.7.11' | |
593 | PACKAGE_STRING='lldpd 0.7.11' | |
592 | PACKAGE_VERSION='0.7.14' | |
593 | PACKAGE_STRING='lldpd 0.7.14' | |
594 | 594 | PACKAGE_BUGREPORT='https://github.com/vincentbernat/lldpd/issues' |
595 | 595 | PACKAGE_URL='http://vincentbernat.github.io/lldpd/' |
596 | 596 | |
650 | 650 | USE_SNMP_TRUE |
651 | 651 | HAVE_CHECK_FALSE |
652 | 652 | HAVE_CHECK_TRUE |
653 | LLDP_LDFLAGS | |
654 | LLDP_CPPFLAGS | |
655 | LLDP_CFLAGS | |
653 | 656 | LLDPD_PID_FILE |
654 | 657 | LLDPD_CTL_SOCKET |
655 | 658 | PRIVSEP_CHROOT |
684 | 687 | NETSNMP_LIBS |
685 | 688 | NETSNMP_CONFIG |
686 | 689 | READLINE_LIBS |
690 | pkgconfigdir | |
687 | 691 | LIBEVENT_LDFLAGS |
688 | 692 | LIBEVENT_EMBEDDED_FALSE |
689 | 693 | LIBEVENT_EMBEDDED_TRUE |
903 | 907 | enable_doxygen_ps |
904 | 908 | enable_doxygen_pdf |
905 | 909 | with_embedded_libevent |
910 | with_pkgconfigdir | |
906 | 911 | with_readline |
907 | 912 | with_snmp |
908 | 913 | with_xml |
1496 | 1501 | # Omit some internal or obsolete options to make the list less imposing. |
1497 | 1502 | # This message is too long to be a string in the A/UX 3.1 sh. |
1498 | 1503 | cat <<_ACEOF |
1499 | \`configure' configures lldpd 0.7.11 to adapt to many kinds of systems. | |
1504 | \`configure' configures lldpd 0.7.14 to adapt to many kinds of systems. | |
1500 | 1505 | |
1501 | 1506 | Usage: $0 [OPTION]... [VAR=VALUE]... |
1502 | 1507 | |
1566 | 1571 | |
1567 | 1572 | if test -n "$ac_init_help"; then |
1568 | 1573 | case $ac_init_help in |
1569 | short | recursive ) echo "Configuration of lldpd 0.7.11:";; | |
1574 | short | recursive ) echo "Configuration of lldpd 0.7.14:";; | |
1570 | 1575 | esac |
1571 | 1576 | cat <<\_ACEOF |
1572 | 1577 | |
1622 | 1627 | (or the compiler's sysroot if not specified). |
1623 | 1628 | --with-embedded-libevent |
1624 | 1629 | Force the use of embedded libevent [default=no] |
1630 | --with-pkgconfigdir pkg-config installation directory | |
1631 | ['${libdir}/pkgconfig'] | |
1625 | 1632 | --with-readline Enable the use of readline-like library |
1626 | 1633 | [default=check] |
1627 | 1634 | --with-snmp Enable the use of SNMP [default=no] |
1757 | 1764 | test -n "$ac_init_help" && exit $ac_status |
1758 | 1765 | if $ac_init_version; then |
1759 | 1766 | cat <<\_ACEOF |
1760 | lldpd configure 0.7.11 | |
1767 | lldpd configure 0.7.14 | |
1761 | 1768 | generated by GNU Autoconf 2.69 |
1762 | 1769 | |
1763 | 1770 | Copyright (C) 2012 Free Software Foundation, Inc. |
2358 | 2365 | This file contains any messages produced by compilers while |
2359 | 2366 | running configure, to aid debugging if configure makes a mistake. |
2360 | 2367 | |
2361 | It was created by lldpd $as_me 0.7.11, which was | |
2368 | It was created by lldpd $as_me 0.7.14, which was | |
2362 | 2369 | generated by GNU Autoconf 2.69. Invocation command line was |
2363 | 2370 | |
2364 | 2371 | $ $0 $@ |
2918 | 2925 | ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' |
2919 | 2926 | program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` |
2920 | 2927 | |
2921 | # expand $ac_aux_dir to an absolute path | |
2922 | am_aux_dir=`cd $ac_aux_dir && pwd` | |
2928 | # Expand $ac_aux_dir to an absolute path. | |
2929 | am_aux_dir=`cd "$ac_aux_dir" && pwd` | |
2923 | 2930 | |
2924 | 2931 | if test x"${MISSING+set}" != xset; then |
2925 | 2932 | case $am_aux_dir in |
3232 | 3239 | |
3233 | 3240 | # Define the identity of the package. |
3234 | 3241 | PACKAGE='lldpd' |
3235 | VERSION='0.7.11' | |
3242 | VERSION='0.7.14' | |
3236 | 3243 | |
3237 | 3244 | |
3238 | 3245 | cat >>confdefs.h <<_ACEOF |
13107 | 13114 | fi |
13108 | 13115 | |
13109 | 13116 | |
13117 | if test x"$ac_cv_prog_cc_c99" = x"no"; then | |
13118 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 | |
13119 | $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} | |
13120 | as_fn_error $? "*** C99 support is mandatory | |
13121 | See \`config.log' for more details" "$LINENO" 5; } | |
13122 | fi | |
13110 | 13123 | ac_ext=cpp |
13111 | 13124 | ac_cpp='$CXXCPP $CPPFLAGS' |
13112 | 13125 | ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' |
19552 | 19565 | ;; |
19553 | 19566 | esac |
19554 | 19567 | |
19555 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking CFLAGS for gcc -D_FORTIFY_SOURCE=2" >&5 | |
19556 | $as_echo_n "checking CFLAGS for gcc -D_FORTIFY_SOURCE=2... " >&6; } | |
19568 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking CPPFLAGS for gcc -D_FORTIFY_SOURCE=2" >&5 | |
19569 | $as_echo_n "checking CPPFLAGS for gcc -D_FORTIFY_SOURCE=2... " >&6; } | |
19557 | 19570 | if ${ac_cv_cflags_gcc_option__D_FORTIFY_SOURCE_2+:} false; then : |
19558 | 19571 | $as_echo_n "(cached) " >&6 |
19559 | 19572 | else |
19600 | 19613 | .ok|.ok,*) ;; |
19601 | 19614 | .|.no|.no,*) ;; |
19602 | 19615 | *) |
19603 | if echo " $CFLAGS " | grep " ${ac_res} " 2>&1 >/dev/null | |
19604 | then { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS does contain \${ac_res}"; } >&5 | |
19605 | (: CFLAGS does contain ${ac_res}) 2>&5 | |
19616 | if echo " $CPPFLAGS " | grep " ${ac_res} " 2>&1 >/dev/null | |
19617 | then { { $as_echo "$as_me:${as_lineno-$LINENO}: : CPPFLAGS does contain \${ac_res}"; } >&5 | |
19618 | (: CPPFLAGS does contain ${ac_res}) 2>&5 | |
19606 | 19619 | ac_status=$? |
19607 | 19620 | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 |
19608 | 19621 | test $ac_status = 0; } |
19609 | else { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \${ac_res}\""; } >&5 | |
19610 | (: CFLAGS="$CFLAGS ${ac_res}") 2>&5 | |
19622 | else { { $as_echo "$as_me:${as_lineno-$LINENO}: : CPPFLAGS=\"\$CPPFLAGS \${ac_res}\""; } >&5 | |
19623 | (: CPPFLAGS="$CPPFLAGS ${ac_res}") 2>&5 | |
19611 | 19624 | ac_status=$? |
19612 | 19625 | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 |
19613 | 19626 | test $ac_status = 0; } |
19614 | CFLAGS="$CFLAGS ${ac_res}" | |
19627 | CPPFLAGS="$CPPFLAGS ${ac_res}" | |
19615 | 19628 | fi |
19616 | 19629 | ;; |
19617 | 19630 | esac |
20083 | 20096 | |
20084 | 20097 | |
20085 | 20098 | # Most of what we want can be enabled nowadays with _GNU_SOURCE |
20086 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking CFLAGS for gcc -D_GNU_SOURCE" >&5 | |
20087 | $as_echo_n "checking CFLAGS for gcc -D_GNU_SOURCE... " >&6; } | |
20099 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking CPPFLAGS for gcc -D_GNU_SOURCE" >&5 | |
20100 | $as_echo_n "checking CPPFLAGS for gcc -D_GNU_SOURCE... " >&6; } | |
20088 | 20101 | if ${ac_cv_cflags_gcc_option__D_GNU_SOURCE+:} false; then : |
20089 | 20102 | $as_echo_n "(cached) " >&6 |
20090 | 20103 | else |
20131 | 20144 | .ok|.ok,*) ;; |
20132 | 20145 | .|.no|.no,*) ;; |
20133 | 20146 | *) |
20134 | if echo " $CFLAGS " | grep " ${ac_res} " 2>&1 >/dev/null | |
20135 | then { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS does contain \${ac_res}"; } >&5 | |
20136 | (: CFLAGS does contain ${ac_res}) 2>&5 | |
20147 | if echo " $CPPFLAGS " | grep " ${ac_res} " 2>&1 >/dev/null | |
20148 | then { { $as_echo "$as_me:${as_lineno-$LINENO}: : CPPFLAGS does contain \${ac_res}"; } >&5 | |
20149 | (: CPPFLAGS does contain ${ac_res}) 2>&5 | |
20137 | 20150 | ac_status=$? |
20138 | 20151 | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 |
20139 | 20152 | test $ac_status = 0; } |
20140 | else { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \${ac_res}\""; } >&5 | |
20141 | (: CFLAGS="$CFLAGS ${ac_res}") 2>&5 | |
20153 | else { { $as_echo "$as_me:${as_lineno-$LINENO}: : CPPFLAGS=\"\$CPPFLAGS \${ac_res}\""; } >&5 | |
20154 | (: CPPFLAGS="$CPPFLAGS ${ac_res}") 2>&5 | |
20142 | 20155 | ac_status=$? |
20143 | 20156 | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 |
20144 | 20157 | test $ac_status = 0; } |
20145 | CFLAGS="$CFLAGS ${ac_res}" | |
20158 | CPPFLAGS="$CPPFLAGS ${ac_res}" | |
20146 | 20159 | fi |
20147 | 20160 | ;; |
20148 | 20161 | esac |
20149 | 20162 | |
20150 | 20163 | case $host_os in |
20151 | 20164 | solaris*) |
20152 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking CFLAGS for gcc -D__EXTENSIONS__" >&5 | |
20153 | $as_echo_n "checking CFLAGS for gcc -D__EXTENSIONS__... " >&6; } | |
20165 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking CPPFLAGS for gcc -D__EXTENSIONS__" >&5 | |
20166 | $as_echo_n "checking CPPFLAGS for gcc -D__EXTENSIONS__... " >&6; } | |
20154 | 20167 | if ${ac_cv_cflags_gcc_option__D__EXTENSIONS__+:} false; then : |
20155 | 20168 | $as_echo_n "(cached) " >&6 |
20156 | 20169 | else |
20197 | 20210 | .ok|.ok,*) ;; |
20198 | 20211 | .|.no|.no,*) ;; |
20199 | 20212 | *) |
20200 | if echo " $CFLAGS " | grep " ${ac_res} " 2>&1 >/dev/null | |
20201 | then { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS does contain \${ac_res}"; } >&5 | |
20202 | (: CFLAGS does contain ${ac_res}) 2>&5 | |
20213 | if echo " $CPPFLAGS " | grep " ${ac_res} " 2>&1 >/dev/null | |
20214 | then { { $as_echo "$as_me:${as_lineno-$LINENO}: : CPPFLAGS does contain \${ac_res}"; } >&5 | |
20215 | (: CPPFLAGS does contain ${ac_res}) 2>&5 | |
20203 | 20216 | ac_status=$? |
20204 | 20217 | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 |
20205 | 20218 | test $ac_status = 0; } |
20206 | else { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \${ac_res}\""; } >&5 | |
20207 | (: CFLAGS="$CFLAGS ${ac_res}") 2>&5 | |
20219 | else { { $as_echo "$as_me:${as_lineno-$LINENO}: : CPPFLAGS=\"\$CPPFLAGS \${ac_res}\""; } >&5 | |
20220 | (: CPPFLAGS="$CPPFLAGS ${ac_res}") 2>&5 | |
20208 | 20221 | ac_status=$? |
20209 | 20222 | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 |
20210 | 20223 | test $ac_status = 0; } |
20211 | CFLAGS="$CFLAGS ${ac_res}" | |
20224 | CPPFLAGS="$CPPFLAGS ${ac_res}" | |
20212 | 20225 | fi |
20213 | 20226 | ;; |
20214 | 20227 | esac |
20215 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking CFLAGS for gcc -D_XPG4_2" >&5 | |
20216 | $as_echo_n "checking CFLAGS for gcc -D_XPG4_2... " >&6; } | |
20228 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking CPPFLAGS for gcc -D_XPG4_2" >&5 | |
20229 | $as_echo_n "checking CPPFLAGS for gcc -D_XPG4_2... " >&6; } | |
20217 | 20230 | if ${ac_cv_cflags_gcc_option__D_XPG4_2+:} false; then : |
20218 | 20231 | $as_echo_n "(cached) " >&6 |
20219 | 20232 | else |
20260 | 20273 | .ok|.ok,*) ;; |
20261 | 20274 | .|.no|.no,*) ;; |
20262 | 20275 | *) |
20263 | if echo " $CFLAGS " | grep " ${ac_res} " 2>&1 >/dev/null | |
20264 | then { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS does contain \${ac_res}"; } >&5 | |
20265 | (: CFLAGS does contain ${ac_res}) 2>&5 | |
20276 | if echo " $CPPFLAGS " | grep " ${ac_res} " 2>&1 >/dev/null | |
20277 | then { { $as_echo "$as_me:${as_lineno-$LINENO}: : CPPFLAGS does contain \${ac_res}"; } >&5 | |
20278 | (: CPPFLAGS does contain ${ac_res}) 2>&5 | |
20266 | 20279 | ac_status=$? |
20267 | 20280 | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 |
20268 | 20281 | test $ac_status = 0; } |
20269 | else { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \${ac_res}\""; } >&5 | |
20270 | (: CFLAGS="$CFLAGS ${ac_res}") 2>&5 | |
20282 | else { { $as_echo "$as_me:${as_lineno-$LINENO}: : CPPFLAGS=\"\$CPPFLAGS \${ac_res}\""; } >&5 | |
20283 | (: CPPFLAGS="$CPPFLAGS ${ac_res}") 2>&5 | |
20271 | 20284 | ac_status=$? |
20272 | 20285 | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 |
20273 | 20286 | test $ac_status = 0; } |
20274 | CFLAGS="$CFLAGS ${ac_res}" | |
20287 | CPPFLAGS="$CPPFLAGS ${ac_res}" | |
20275 | 20288 | fi |
20276 | 20289 | ;; |
20277 | 20290 | esac |
20278 | 20291 | ;; |
20279 | 20292 | hpux*) |
20280 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking CFLAGS for gcc -D_XOPEN_SOURCE=500" >&5 | |
20281 | $as_echo_n "checking CFLAGS for gcc -D_XOPEN_SOURCE=500... " >&6; } | |
20293 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking CPPFLAGS for gcc -D_XOPEN_SOURCE=500" >&5 | |
20294 | $as_echo_n "checking CPPFLAGS for gcc -D_XOPEN_SOURCE=500... " >&6; } | |
20282 | 20295 | if ${ac_cv_cflags_gcc_option__D_XOPEN_SOURCE_500+:} false; then : |
20283 | 20296 | $as_echo_n "(cached) " >&6 |
20284 | 20297 | else |
20325 | 20338 | .ok|.ok,*) ;; |
20326 | 20339 | .|.no|.no,*) ;; |
20327 | 20340 | *) |
20328 | if echo " $CFLAGS " | grep " ${ac_res} " 2>&1 >/dev/null | |
20329 | then { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS does contain \${ac_res}"; } >&5 | |
20330 | (: CFLAGS does contain ${ac_res}) 2>&5 | |
20341 | if echo " $CPPFLAGS " | grep " ${ac_res} " 2>&1 >/dev/null | |
20342 | then { { $as_echo "$as_me:${as_lineno-$LINENO}: : CPPFLAGS does contain \${ac_res}"; } >&5 | |
20343 | (: CPPFLAGS does contain ${ac_res}) 2>&5 | |
20331 | 20344 | ac_status=$? |
20332 | 20345 | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 |
20333 | 20346 | test $ac_status = 0; } |
20334 | else { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \${ac_res}\""; } >&5 | |
20335 | (: CFLAGS="$CFLAGS ${ac_res}") 2>&5 | |
20347 | else { { $as_echo "$as_me:${as_lineno-$LINENO}: : CPPFLAGS=\"\$CPPFLAGS \${ac_res}\""; } >&5 | |
20348 | (: CPPFLAGS="$CPPFLAGS ${ac_res}") 2>&5 | |
20336 | 20349 | ac_status=$? |
20337 | 20350 | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 |
20338 | 20351 | test $ac_status = 0; } |
20339 | CFLAGS="$CFLAGS ${ac_res}" | |
20352 | CPPFLAGS="$CPPFLAGS ${ac_res}" | |
20340 | 20353 | fi |
20341 | 20354 | ;; |
20342 | 20355 | esac |
20343 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking CFLAGS for gcc -D_XOPEN_SOURCE_EXTENDED" >&5 | |
20344 | $as_echo_n "checking CFLAGS for gcc -D_XOPEN_SOURCE_EXTENDED... " >&6; } | |
20356 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking CPPFLAGS for gcc -D_XOPEN_SOURCE_EXTENDED" >&5 | |
20357 | $as_echo_n "checking CPPFLAGS for gcc -D_XOPEN_SOURCE_EXTENDED... " >&6; } | |
20345 | 20358 | if ${ac_cv_cflags_gcc_option__D_XOPEN_SOURCE_EXTENDED+:} false; then : |
20346 | 20359 | $as_echo_n "(cached) " >&6 |
20347 | 20360 | else |
20388 | 20401 | .ok|.ok,*) ;; |
20389 | 20402 | .|.no|.no,*) ;; |
20390 | 20403 | *) |
20391 | if echo " $CFLAGS " | grep " ${ac_res} " 2>&1 >/dev/null | |
20392 | then { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS does contain \${ac_res}"; } >&5 | |
20393 | (: CFLAGS does contain ${ac_res}) 2>&5 | |
20404 | if echo " $CPPFLAGS " | grep " ${ac_res} " 2>&1 >/dev/null | |
20405 | then { { $as_echo "$as_me:${as_lineno-$LINENO}: : CPPFLAGS does contain \${ac_res}"; } >&5 | |
20406 | (: CPPFLAGS does contain ${ac_res}) 2>&5 | |
20394 | 20407 | ac_status=$? |
20395 | 20408 | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 |
20396 | 20409 | test $ac_status = 0; } |
20397 | else { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \${ac_res}\""; } >&5 | |
20398 | (: CFLAGS="$CFLAGS ${ac_res}") 2>&5 | |
20410 | else { { $as_echo "$as_me:${as_lineno-$LINENO}: : CPPFLAGS=\"\$CPPFLAGS \${ac_res}\""; } >&5 | |
20411 | (: CPPFLAGS="$CPPFLAGS ${ac_res}") 2>&5 | |
20399 | 20412 | ac_status=$? |
20400 | 20413 | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 |
20401 | 20414 | test $ac_status = 0; } |
20402 | CFLAGS="$CFLAGS ${ac_res}" | |
20415 | CPPFLAGS="$CPPFLAGS ${ac_res}" | |
20403 | 20416 | fi |
20404 | 20417 | ;; |
20405 | 20418 | esac |
21765 | 21778 | # Override configure arguments |
21766 | 21779 | ac_configure_args="$ac_configure_args --disable-libevent-regress --disable-thread-support --disable-openssl" |
21767 | 21780 | ac_configure_args="$ac_configure_args --disable-malloc-replacement --disable-debug-mode --enable-function-sections" |
21768 | ac_configure_args="$ac_configure_args --disable-shared --enable-static" | |
21781 | ac_configure_args="$ac_configure_args --disable-shared --enable-static --enable-silent-rules" | |
21769 | 21782 | subdirs="$subdirs libevent" |
21770 | 21783 | |
21771 | 21784 | if test x"$LIBEVENT_EMBEDDED" != x; then |
21776 | 21789 | LIBEVENT_EMBEDDED_FALSE= |
21777 | 21790 | fi |
21778 | 21791 | |
21792 | ||
21793 | ||
21794 | ||
21795 | ||
21796 | ||
21797 | # Compatibility with pkg.m4 < 0.27 | |
21798 | ||
21799 | ||
21800 | ||
21801 | # Check whether --with-pkgconfigdir was given. | |
21802 | if test "${with_pkgconfigdir+set}" = set; then : | |
21803 | withval=$with_pkgconfigdir; | |
21804 | else | |
21805 | with_pkgconfigdir='${libdir}/pkgconfig' | |
21806 | fi | |
21807 | ||
21808 | pkgconfigdir=$with_pkgconfigdir | |
21779 | 21809 | |
21780 | 21810 | |
21781 | 21811 | |
22497 | 22527 | |
22498 | 22528 | fi |
22499 | 22529 | |
22530 | # Check if the library is usable | |
22531 | _save_flags="$CFLAGS" | |
22532 | _save_libs="$LIBS" | |
22533 | CFLAGS="$CFLAGS ${XML2_CFLAGS}" | |
22534 | LIBS="$LIBS ${XML2_LIBS}" | |
22535 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether libxml-2 work as expected" >&5 | |
22536 | $as_echo_n "checking whether libxml-2 work as expected... " >&6; } | |
22537 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext | |
22538 | /* end confdefs.h. */ | |
22539 | ||
22540 | #include <libxml/encoding.h> | |
22541 | #include <libxml/xmlwriter.h> | |
22542 | ||
22543 | int | |
22544 | main () | |
22545 | { | |
22546 | ||
22547 | xmlDocPtr doc; | |
22548 | xmlTextWriterPtr xw = xmlNewTextWriterDoc(&doc, 0); | |
22549 | return (xw != NULL); | |
22550 | ||
22551 | ; | |
22552 | return 0; | |
22553 | } | |
22554 | _ACEOF | |
22555 | if ac_fn_c_try_link "$LINENO"; then : | |
22556 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 | |
22557 | $as_echo "yes" >&6; } | |
22558 | else | |
22559 | ||
22560 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 | |
22561 | $as_echo "no" >&6; } | |
22562 | as_fn_error $? "*** unable to use libxml-2" "$LINENO" 5 | |
22563 | fi | |
22564 | rm -f core conftest.err conftest.$ac_objext \ | |
22565 | conftest$ac_exeext conftest.$ac_ext | |
22566 | CFLAGS="$_save_flags" | |
22567 | LIBS="$_save_libs" | |
22568 | ||
22500 | 22569 | |
22501 | 22570 | |
22502 | 22571 | |
23857 | 23926 | |
23858 | 23927 | ####################### |
23859 | 23928 | # Output results |
23929 | LLDP_CFLAGS=$CFLAGS | |
23930 | ||
23931 | LLDP_CPPFLAGS=$CPPFLAGS | |
23932 | ||
23933 | LLDP_LDFLAGS=$LDFLAGS | |
23934 | ||
23935 | CFLAGS= | |
23936 | CPPFLAGS= | |
23937 | LDFLAGS= | |
23860 | 23938 | if test x"$have_check" = x"yes"; then |
23861 | 23939 | HAVE_CHECK_TRUE= |
23862 | 23940 | HAVE_CHECK_FALSE='#' |
24575 | 24653 | # report actual input values of CONFIG_FILES etc. instead of their |
24576 | 24654 | # values after options handling. |
24577 | 24655 | ac_log=" |
24578 | This file was extended by lldpd $as_me 0.7.11, which was | |
24656 | This file was extended by lldpd $as_me 0.7.14, which was | |
24579 | 24657 | generated by GNU Autoconf 2.69. Invocation command line was |
24580 | 24658 | |
24581 | 24659 | CONFIG_FILES = $CONFIG_FILES |
24642 | 24720 | cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 |
24643 | 24721 | ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" |
24644 | 24722 | ac_cs_version="\\ |
24645 | lldpd config.status 0.7.11 | |
24723 | lldpd config.status 0.7.14 | |
24646 | 24724 | configured by $0, generated by GNU Autoconf 2.69, |
24647 | 24725 | with options \\"\$ac_cs_config\\" |
24648 | 24726 | |
26838 | 26916 | $PACKAGE_NAME version $PACKAGE_VERSION |
26839 | 26917 | OS.............: $os |
26840 | 26918 | Prefix.........: $prefix |
26841 | C Compiler.....: $CC $CFLAGS $CPPFLAGS | |
26842 | Linker.........: $LD $LDFLAGS $LIBS | |
26919 | C Compiler.....: $CC $LLDP_CFLAGS $LLDP_CPPFLAGS | |
26920 | Linker.........: $LD $LLDP_LDFLAGS $LIBS | |
26843 | 26921 | Libevent.......: $libevent |
26844 | 26922 | Readline.......: ${ax_cv_lib_readline} |
26845 | 26923 | Optional features: |
43 | 43 | # Checks for programs. |
44 | 44 | AC_PROG_CC |
45 | 45 | AC_PROG_CC_C99 |
46 | if test x"$ac_cv_prog_cc_c99" = x"no"; then | |
47 | AC_MSG_FAILURE([*** C99 support is mandatory]) | |
48 | fi | |
46 | 49 | AC_PROG_CXX |
47 | 50 | AM_PROG_CC_C_O |
48 | 51 | AC_PROG_LIBTOOL |
77 | 80 | AX_CFLAGS_GCC_OPTION([-fstack-protector]) |
78 | 81 | AX_CFLAGS_GCC_OPTION([-fstack-protector-strong]) |
79 | 82 | AX_CFLAGS_GCC_OPTION([-fno-omit-frame-pointer]) |
80 | AX_CFLAGS_GCC_OPTION([-D_FORTIFY_SOURCE=2]) | |
83 | AX_CFLAGS_GCC_OPTION([-D_FORTIFY_SOURCE=2], [CPPFLAGS]) | |
81 | 84 | AX_CFLAGS_GCC_OPTION([-Wno-unused-parameter]) |
82 | 85 | AX_CFLAGS_GCC_OPTION([-Wno-missing-field-initializers]) |
83 | 86 | AX_CFLAGS_GCC_OPTION([-Wno-sign-compare]) dnl Should be fixed later |
145 | 148 | # Libevent |
146 | 149 | lldp_CHECK_LIBEVENT |
147 | 150 | |
151 | # Compatibility with pkg.m4 < 0.27 | |
152 | m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], | |
153 | [AC_ARG_WITH([pkgconfigdir], | |
154 | [AS_HELP_STRING([--with-pkgconfigdir], | |
155 | [install directory for *.pc pkg-config file])], | |
156 | [],[with_pkgconfigdir='$(libdir)/pkgconfig']) | |
157 | AC_SUBST([pkgconfigdir], [${with_pkgconfigdir}])]) | |
158 | ||
148 | 159 | ####################### |
149 | 160 | ### Options |
150 | 161 | |
264 | 275 | |
265 | 276 | ####################### |
266 | 277 | # Output results |
278 | AC_SUBST([LLDP_CFLAGS], [$CFLAGS]) | |
279 | AC_SUBST([LLDP_CPPFLAGS], [$CPPFLAGS]) | |
280 | AC_SUBST([LLDP_LDFLAGS], [$LDFLAGS]) | |
281 | CFLAGS= | |
282 | CPPFLAGS= | |
283 | LDFLAGS= | |
267 | 284 | AM_CONDITIONAL([HAVE_CHECK], [test x"$have_check" = x"yes"]) |
268 | 285 | AM_CONDITIONAL([USE_SNMP], [test x"$with_snmp" = x"yes"]) |
269 | 286 | AM_CONDITIONAL([USE_XML], [test x"$with_xml" = x"yes"]) |
285 | 302 | $PACKAGE_NAME version $PACKAGE_VERSION |
286 | 303 | OS.............: $os |
287 | 304 | Prefix.........: $prefix |
288 | C Compiler.....: $CC $CFLAGS $CPPFLAGS | |
289 | Linker.........: $LD $LDFLAGS $LIBS | |
305 | C Compiler.....: $CC $LLDP_CFLAGS $LLDP_CPPFLAGS | |
306 | Linker.........: $LD $LLDP_LDFLAGS $LIBS | |
290 | 307 | Libevent.......: $libevent |
291 | 308 | Readline.......: ${ax_cv_lib_readline} |
292 | 309 | Optional features: |
0 | 0 | edit = $(SED) \ |
1 | 1 | -e 's|@bindir[@]|$(bindir)|g' \ |
2 | -e 's|@sbindir[@]|$(sbindir)|g' \ | |
2 | 3 | -e 's|@pkgdatadir[@]|$(pkgdatadir)|g' \ |
3 | 4 | -e 's|@libdir[@]|$(libdir)|g' \ |
4 | 5 | -e 's|@includedir[@]|$(includedir)|g' \ |
14 | 15 | -e 's|@LLDPD_CTL_SOCKET[@]|$(LLDPD_CTL_SOCKET)|g' |
15 | 16 | |
16 | 17 | $(TEMPLATES): Makefile |
17 | $(AM_V_GEN)$(edit) $(srcdir)/$@.in > $@.tmp | |
18 | mv $@.tmp $@ | |
18 | $(AM_V_GEN)$(edit) $(srcdir)/$@.in > $@.tmp && mv $@.tmp $@ |
0 | Changes in version 2.0.22-stable (?? ??? 2013) | |
1 | ||
2 | (As of 66dacfa2a58602d82e0413c8217ec38c9871d5cf.) | |
3 | ||
4 | BUGFIXES (evhttp, crash fix) | |
5 | o fix #73 and fix http_connection_fail_test to catch it (b618204 Greg Hazel) | |
0 | Changes in version 2.0.22-stable (5 Jan 2015) | |
1 | ||
2 | SECURITY FIXES (evbuffers) | |
3 | o Avoid integer overflow bugs in evbuffer_add() and related functions. See CVE-2014-6272 advisory for more information. (20d6d4458bee5d88bda1511c225c25b2d3198d6c) | |
4 | ||
5 | BUGFIXES (evhttp) | |
6 | o fix #73 and fix http_connection_fail_test to catch it (crash fix) (b618204 Greg Hazel) | |
7 | o Avoid racy bufferevent activation (5eb1788 Nate Rosenblum) | |
6 | 8 | |
7 | 9 | BUGFIXES (compilation and portability) |
8 | 10 | o Fix compilation with WIN32_HAVE_CONDITION_VARIABLES enabled (7e45739) |
11 | 13 | o Use AC_CONFIG_HEADERS in place of AM_CONFIG_HEADERS for autmake 1.13 compat (817ea36) |
12 | 14 | o Rename configure.in to configure.ac to appease newer autoconfs (0c79787) |
13 | 15 | o Avoid using top_srcdir in TESTS: new automakes do not like this (a55514e) |
16 | o Use windows vsnprintf fixup logic on all windows environments (e826f19) | |
17 | o Fix a compiler warning when checking for arc4random_buf linker breakage. (5cb3865) | |
18 | o Fix another arc4random_buf-related warning (e64a2b0) | |
19 | o Add -Qunused-arguments for clang on macos (b56611d Trond Norbye) | |
14 | 20 | |
15 | 21 | BUGFIXES (resource leaks/lock errors on error) |
16 | 22 | o Avoid leaking fds on evconnlistener with no callback set (69db261) |
17 | 23 | o Avoid double-close on getsockname error in evutil_ersatz_socketpair (0a822a6) |
18 | 24 | o Fix a locking error in bufferevent_socket_get_dns_error. (0a5eb2e) |
25 | o libevent/win32_dealloc() : fix sizeof(pointer) vs sizeof(*pointer) (b8f5980 Frank Denis) | |
26 | ||
27 | BUGFIXES: (other stability) | |
28 | o bufferevent_pair: don't call downcast(NULL) (f2428a2) | |
29 | o Consistently check for failure from evbuffer_pullup() (60f8f72) | |
30 | o Fix race caused by event_active (3c7d6fc vjpai) | |
31 | ||
32 | BUGFIXES (miscellaneous) | |
33 | o Avoid redundant invocations of init_extension_functions for IOCP (3b77d62) | |
34 | o Typo fixes from Linus Nordberg (cec62cb, 8cd695b) | |
35 | o Add a few files created by "make verify" to .gitignore. (1a8295a Pierre Phaneuf) | |
36 | o regress_buffer: fix 'memcmp' compare size (79800df Maks Naumov) | |
37 | o Fix bufferevent setwatermark suspend_read (b34e4ac ufo2243) | |
38 | o Fix evbuffer_peek() with len==-1 and start_at non-NULL. (fb7e76a) | |
39 | ||
40 | BUFGIXES (evdns) | |
41 | o Checking request nameserver for NULL, before using it. (5c710c0 Belobrov Andrey) | |
42 | o Fix SEGFAULT after evdns_base_resume if no nameservers installed. (f8d7df8 Azat Khuzhin) | |
43 | o Fix a crash in evdns related to shutting down evdns (9f39c88,e8fe749) | |
44 | ||
45 | BUGFIXES (epoll) | |
46 | o Check does arch have the epoll_create and __NR_epoll_wait syscalls. (dfe1e52 Marcin Juszkiewicz) | |
47 | ||
48 | BUGFIXES (evutil_secure_random) | |
49 | o Avoid other RNG initialization FS reads when urandom file is specified (9695e9c, bb52471) | |
50 | o When we seed from /proc/sys/kernel/random/uuid, count it as success (e35b540) | |
51 | o Document that arc4random is not a great cryptographic PRNG. (6e49696) | |
52 | o Add evutil_secure_rng_set_urandom_device_file (2bbb5d7) | |
53 | o Really remove RNG seeds from the stack (f5ced88) | |
54 | ||
19 | 55 | |
20 | 56 | DOCUMENTATION FIXES |
21 | 57 | o Fix a mistake in evbuffer_remove() arguments in example http server code (c322c20 Gyepi Sam) |
22 | 58 | o Fix a typo in a comment in buffer.h. Spotted by Alt_F4 (773b0a5) |
23 | ||
59 | o Clarify event_base_loop exit conditions (031a803) | |
60 | o Use FindClose for handle from FindFirstFile in http-server.c (6466e88) | |
61 | o Fix a typo in a doxygen comment. Reported by 亦得. (be1aeff) | |
24 | 62 | |
25 | 63 | |
26 | 64 | Changes in version 2.0.21-stable (18 Nov 2012) |
37 | 37 | # |
38 | 38 | # Once an RC is out, DO NOT MAKE ANY ABI-BREAKING CHANGES IN THAT SERIES |
39 | 39 | # UNLESS YOU REALLY REALLY HAVE TO. |
40 | VERSION_INFO = 6:9:1 | |
40 | VERSION_INFO = 6:10:1 | |
41 | 41 | |
42 | 42 | # History: RELEASE VERSION_INFO |
43 | 43 | # 2.0.1-alpha -- 2.0 1:0:0 |
61 | 61 | # 2.0.19-stable-- 2.0 6:7:1 (No ABI change) |
62 | 62 | # 2.0.20-stable-- 2.0 6:8:1 (No ABI change) |
63 | 63 | # 2.0.21-stable-- 2.0 6:9:1 (No ABI change) |
64 | # 2.0.22-stable-- 2.0 6:10:1 (No ABI change) | |
64 | 65 | # |
65 | 66 | # For Libevent 2.1: |
66 | 67 | # 2.1.1-alpha -- 2.1 1:0:0 |
548 | 548 | # |
549 | 549 | # Once an RC is out, DO NOT MAKE ANY ABI-BREAKING CHANGES IN THAT SERIES |
550 | 550 | # UNLESS YOU REALLY REALLY HAVE TO. |
551 | VERSION_INFO = 6:9:1 | |
551 | VERSION_INFO = 6:10:1 | |
552 | 552 | |
553 | 553 | # History: RELEASE VERSION_INFO |
554 | 554 | # 2.0.1-alpha -- 2.0 1:0:0 |
572 | 572 | # 2.0.19-stable-- 2.0 6:7:1 (No ABI change) |
573 | 573 | # 2.0.20-stable-- 2.0 6:8:1 (No ABI change) |
574 | 574 | # 2.0.21-stable-- 2.0 6:9:1 (No ABI change) |
575 | # 2.0.22-stable-- 2.0 6:10:1 (No ABI change) | |
575 | 576 | # |
576 | 577 | # For Libevent 2.1: |
577 | 578 | # 2.1.1-alpha -- 2.1 1:0:0 |
276 | 276 | /* #undef _EVENT_HAVE_WORKING_KQUEUE */ |
277 | 277 | |
278 | 278 | /* Numeric representation of the version */ |
279 | #define _EVENT_NUMERIC_VERSION 0x02001501 | |
279 | #define _EVENT_NUMERIC_VERSION 0x02001600 | |
280 | 280 | |
281 | 281 | /* Name of package */ |
282 | 282 | #define _EVENT_PACKAGE "libevent" |
333 | 333 | #define _EVENT_TIME_WITH_SYS_TIME 1 |
334 | 334 | |
335 | 335 | /* Version number of package */ |
336 | #define _EVENT_VERSION "2.0.21-stable-dev" | |
336 | #define _EVENT_VERSION "2.0.22-stable" | |
337 | 337 | |
338 | 338 | /* Define to appropriate substitue if compiler doesnt have __func__ */ |
339 | 339 | #define _EVENT___func__ __FUNCTION__ |
102 | 102 | # configured tree to be moved without reconfiguration. |
103 | 103 | |
104 | 104 | AC_DEFUN([AM_AUX_DIR_EXPAND], |
105 | [dnl Rely on autoconf to set up CDPATH properly. | |
106 | AC_PREREQ([2.50])dnl | |
107 | # expand $ac_aux_dir to an absolute path | |
108 | am_aux_dir=`cd $ac_aux_dir && pwd` | |
105 | [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl | |
106 | # Expand $ac_aux_dir to an absolute path. | |
107 | am_aux_dir=`cd "$ac_aux_dir" && pwd` | |
109 | 108 | ]) |
110 | 109 | |
111 | 110 | # AM_CONDITIONAL -*- Autoconf -*- |
160 | 160 | if (!CryptGenRandom(provider, sizeof(buf), buf)) |
161 | 161 | return -1; |
162 | 162 | arc4_addrandom(buf, sizeof(buf)); |
163 | memset(buf, 0, sizeof(buf)); | |
163 | evutil_memclear_(buf, sizeof(buf)); | |
164 | 164 | arc4_seeded_ok = 1; |
165 | 165 | return 0; |
166 | 166 | } |
198 | 198 | return -1; |
199 | 199 | |
200 | 200 | arc4_addrandom(buf, sizeof(buf)); |
201 | memset(buf, 0, sizeof(buf)); | |
201 | evutil_memclear_(buf, sizeof(buf)); | |
202 | 202 | arc4_seeded_ok = 1; |
203 | 203 | return 0; |
204 | 204 | } |
238 | 238 | return -1; |
239 | 239 | |
240 | 240 | arc4_addrandom(buf, sizeof(buf)); |
241 | memset(buf, 0, sizeof(buf)); | |
241 | evutil_memclear_(buf, sizeof(buf)); | |
242 | 242 | arc4_seeded_ok = 1; |
243 | 243 | return 0; |
244 | 244 | } |
283 | 283 | arc4_addrandom(entropy, nybbles/2); |
284 | 284 | bytes += nybbles/2; |
285 | 285 | } |
286 | memset(entropy, 0, sizeof(entropy)); | |
287 | memset(buf, 0, sizeof(buf)); | |
286 | evutil_memclear_(entropy, sizeof(entropy)); | |
287 | evutil_memclear_(buf, sizeof(buf)); | |
288 | arc4_seeded_ok = 1; | |
288 | 289 | return 0; |
289 | 290 | } |
290 | 291 | #endif |
291 | 292 | |
292 | 293 | #ifndef WIN32 |
293 | 294 | #define TRY_SEED_URANDOM |
295 | static char *arc4random_urandom_filename = NULL; | |
296 | ||
297 | static int arc4_seed_urandom_helper_(const char *fname) | |
298 | { | |
299 | unsigned char buf[ADD_ENTROPY]; | |
300 | int fd; | |
301 | size_t n; | |
302 | ||
303 | fd = evutil_open_closeonexec(fname, O_RDONLY, 0); | |
304 | if (fd<0) | |
305 | return -1; | |
306 | n = read_all(fd, buf, sizeof(buf)); | |
307 | close(fd); | |
308 | if (n != sizeof(buf)) | |
309 | return -1; | |
310 | arc4_addrandom(buf, sizeof(buf)); | |
311 | evutil_memclear_(buf, sizeof(buf)); | |
312 | arc4_seeded_ok = 1; | |
313 | return 0; | |
314 | } | |
315 | ||
294 | 316 | static int |
295 | 317 | arc4_seed_urandom(void) |
296 | 318 | { |
298 | 320 | static const char *filenames[] = { |
299 | 321 | "/dev/srandom", "/dev/urandom", "/dev/random", NULL |
300 | 322 | }; |
301 | unsigned char buf[ADD_ENTROPY]; | |
302 | int fd, i; | |
303 | size_t n; | |
323 | int i; | |
324 | if (arc4random_urandom_filename) | |
325 | return arc4_seed_urandom_helper_(arc4random_urandom_filename); | |
304 | 326 | |
305 | 327 | for (i = 0; filenames[i]; ++i) { |
306 | fd = evutil_open_closeonexec(filenames[i], O_RDONLY, 0); | |
307 | if (fd<0) | |
308 | continue; | |
309 | n = read_all(fd, buf, sizeof(buf)); | |
310 | close(fd); | |
311 | if (n != sizeof(buf)) | |
312 | return -1; | |
313 | arc4_addrandom(buf, sizeof(buf)); | |
314 | memset(buf, 0, sizeof(buf)); | |
315 | arc4_seeded_ok = 1; | |
316 | return 0; | |
328 | if (arc4_seed_urandom_helper_(filenames[i]) == 0) { | |
329 | return 0; | |
330 | } | |
317 | 331 | } |
318 | 332 | |
319 | 333 | return -1; |
336 | 350 | ok = 1; |
337 | 351 | #endif |
338 | 352 | #ifdef TRY_SEED_PROC_SYS_KERNEL_RANDOM_UUID |
339 | if (0 == arc4_seed_proc_sys_kernel_random_uuid()) | |
353 | if (arc4random_urandom_filename == NULL && | |
354 | 0 == arc4_seed_proc_sys_kernel_random_uuid()) | |
340 | 355 | ok = 1; |
341 | 356 | #endif |
342 | 357 | #ifdef TRY_SEED_SYSCTL_LINUX |
386 | 401 | */ |
387 | 402 | for (i = 0; i < 12*256; i++) |
388 | 403 | (void)arc4_getbyte(); |
404 | ||
389 | 405 | arc4_count = BYTES_BEFORE_RESEED; |
390 | 406 | |
391 | 407 | return 0; |
156 | 156 | struct evbuffer_chain *chain; |
157 | 157 | size_t to_alloc; |
158 | 158 | |
159 | if (size > EVBUFFER_CHAIN_MAX - EVBUFFER_CHAIN_SIZE) | |
160 | return (NULL); | |
161 | ||
159 | 162 | size += EVBUFFER_CHAIN_SIZE; |
160 | 163 | |
161 | 164 | /* get the next largest memory that can hold the buffer */ |
162 | to_alloc = MIN_BUFFER_SIZE; | |
163 | while (to_alloc < size) | |
164 | to_alloc <<= 1; | |
165 | if (size < EVBUFFER_CHAIN_MAX / 2) { | |
166 | to_alloc = MIN_BUFFER_SIZE; | |
167 | while (to_alloc < size) { | |
168 | to_alloc <<= 1; | |
169 | } | |
170 | } else { | |
171 | to_alloc = size; | |
172 | } | |
165 | 173 | |
166 | 174 | /* we get everything in one chunk */ |
167 | 175 | if ((chain = mm_malloc(to_alloc)) == NULL) |
1001 | 1009 | |
1002 | 1010 | buf->first = chain; |
1003 | 1011 | if (chain) { |
1012 | EVUTIL_ASSERT(remaining <= chain->off); | |
1004 | 1013 | chain->misalign += remaining; |
1005 | 1014 | chain->off -= remaining; |
1006 | 1015 | } |
1067 | 1076 | |
1068 | 1077 | if (datlen) { |
1069 | 1078 | EVUTIL_ASSERT(chain); |
1079 | EVUTIL_ASSERT(datlen <= chain->off); | |
1070 | 1080 | memcpy(data, chain->buffer + chain->misalign, datlen); |
1071 | 1081 | } |
1072 | 1082 | |
1542 | 1552 | if (buf->freeze_end) { |
1543 | 1553 | goto done; |
1544 | 1554 | } |
1555 | /* Prevent buf->total_len overflow */ | |
1556 | if (datlen > EV_SIZE_MAX - buf->total_len) { | |
1557 | goto done; | |
1558 | } | |
1545 | 1559 | |
1546 | 1560 | chain = buf->last; |
1547 | 1561 | |
1555 | 1569 | } |
1556 | 1570 | |
1557 | 1571 | if ((chain->flags & EVBUFFER_IMMUTABLE) == 0) { |
1558 | remain = (size_t)(chain->buffer_len - chain->misalign - chain->off); | |
1572 | /* Always true for mutable buffers */ | |
1573 | EVUTIL_ASSERT(chain->misalign >= 0 && | |
1574 | (ev_uint64_t)chain->misalign <= EVBUFFER_CHAIN_MAX); | |
1575 | remain = chain->buffer_len - (size_t)chain->misalign - chain->off; | |
1559 | 1576 | if (remain >= datlen) { |
1560 | 1577 | /* there's enough space to hold all the data in the |
1561 | 1578 | * current last chain */ |
1626 | 1643 | if (buf->freeze_start) { |
1627 | 1644 | goto done; |
1628 | 1645 | } |
1646 | if (datlen > EV_SIZE_MAX - buf->total_len) { | |
1647 | goto done; | |
1648 | } | |
1629 | 1649 | |
1630 | 1650 | chain = buf->first; |
1631 | 1651 | |
1638 | 1658 | |
1639 | 1659 | /* we cannot touch immutable buffers */ |
1640 | 1660 | if ((chain->flags & EVBUFFER_IMMUTABLE) == 0) { |
1661 | /* Always true for mutable buffers */ | |
1662 | EVUTIL_ASSERT(chain->misalign >= 0 && | |
1663 | (ev_uint64_t)chain->misalign <= EVBUFFER_CHAIN_MAX); | |
1664 | ||
1641 | 1665 | /* If this chain is empty, we can treat it as |
1642 | 1666 | * 'empty at the beginning' rather than 'empty at the end' */ |
1643 | 1667 | if (chain->off == 0) |
1675 | 1699 | tmp->next = chain; |
1676 | 1700 | |
1677 | 1701 | tmp->off = datlen; |
1702 | EVUTIL_ASSERT(datlen <= tmp->buffer_len); | |
1678 | 1703 | tmp->misalign = tmp->buffer_len - datlen; |
1679 | 1704 | |
1680 | 1705 | memcpy(tmp->buffer + tmp->misalign, data, datlen); |
1773 | 1798 | |
1774 | 1799 | /* Would expanding this chunk be affordable and worthwhile? */ |
1775 | 1800 | if (CHAIN_SPACE_LEN(chain) < chain->buffer_len / 8 || |
1776 | chain->off > MAX_TO_COPY_IN_EXPAND) { | |
1801 | chain->off > MAX_TO_COPY_IN_EXPAND || | |
1802 | (datlen < EVBUFFER_CHAIN_MAX && | |
1803 | EVBUFFER_CHAIN_MAX - datlen >= chain->off)) { | |
1777 | 1804 | /* It's not worth resizing this chain. Can the next one be |
1778 | 1805 | * used? */ |
1779 | 1806 | if (chain->next && CHAIN_SPACE_LEN(chain->next) >= datlen) { |
1901 | 1928 | rmv_all = 1; |
1902 | 1929 | avail = 0; |
1903 | 1930 | } else { |
1931 | /* can't overflow, since only mutable chains have | |
1932 | * huge misaligns. */ | |
1904 | 1933 | avail = (size_t) CHAIN_SPACE_LEN(chain); |
1905 | 1934 | chain = chain->next; |
1906 | 1935 | } |
1911 | 1940 | EVUTIL_ASSERT(chain->off == 0); |
1912 | 1941 | evbuffer_chain_free(chain); |
1913 | 1942 | } |
1943 | EVUTIL_ASSERT(datlen >= avail); | |
1914 | 1944 | tmp = evbuffer_chain_new(datlen - avail); |
1915 | 1945 | if (tmp == NULL) { |
1916 | 1946 | if (rmv_all) { |
2040 | 2070 | unsigned long lng = EVBUFFER_MAX_READ; |
2041 | 2071 | if (ioctlsocket(fd, FIONREAD, &lng) < 0) |
2042 | 2072 | return -1; |
2073 | /* Can overflow, but mostly harmlessly. XXXX */ | |
2043 | 2074 | return (int)lng; |
2044 | 2075 | #elif defined(FIONREAD) |
2045 | 2076 | int n = EVBUFFER_MAX_READ; |
2152 | 2183 | #ifdef USE_IOVEC_IMPL |
2153 | 2184 | remaining = n; |
2154 | 2185 | for (i=0; i < nvecs; ++i) { |
2155 | ev_ssize_t space = (ev_ssize_t) CHAIN_SPACE_LEN(*chainp); | |
2156 | if (space < remaining) { | |
2186 | /* can't overflow, since only mutable chains have | |
2187 | * huge misaligns. */ | |
2188 | size_t space = (size_t) CHAIN_SPACE_LEN(*chainp); | |
2189 | /* XXXX This is a kludge that can waste space in perverse | |
2190 | * situations. */ | |
2191 | if (space > EVBUFFER_CHAIN_MAX) | |
2192 | space = EVBUFFER_CHAIN_MAX; | |
2193 | if ((ev_ssize_t)space < remaining) { | |
2157 | 2194 | (*chainp)->off += space; |
2158 | 2195 | remaining -= (int)space; |
2159 | 2196 | } else { |
2362 | 2399 | /* XXX(nickm) Don't disable this code until we know if |
2363 | 2400 | * the WSARecv code above works. */ |
2364 | 2401 | void *p = evbuffer_pullup(buffer, howmuch); |
2402 | EVUTIL_ASSERT(p || !howmuch); | |
2365 | 2403 | n = send(fd, p, howmuch, 0); |
2366 | 2404 | #else |
2367 | 2405 | void *p = evbuffer_pullup(buffer, howmuch); |
2406 | EVUTIL_ASSERT(p || !howmuch); | |
2368 | 2407 | n = write(fd, p, howmuch); |
2369 | 2408 | #endif |
2370 | 2409 | #ifdef USE_SENDFILE |
2424 | 2463 | case EVBUFFER_PTR_ADD: |
2425 | 2464 | /* this avoids iterating over all previous chains if |
2426 | 2465 | we just want to advance the position */ |
2466 | if (pos->pos < 0 || EV_SIZE_MAX - position < (size_t)pos->pos) { | |
2467 | EVBUFFER_UNLOCK(buf); | |
2468 | return -1; | |
2469 | } | |
2427 | 2470 | chain = pos->_internal.chain; |
2428 | 2471 | pos->pos += position; |
2429 | 2472 | position = pos->_internal.pos_in_chain; |
2430 | 2473 | break; |
2431 | 2474 | } |
2432 | 2475 | |
2476 | EVUTIL_ASSERT(EV_SIZE_MAX - left >= position); | |
2433 | 2477 | while (chain && position + left >= chain->off) { |
2434 | 2478 | left -= chain->off - position; |
2435 | 2479 | chain = chain->next; |
2462 | 2506 | |
2463 | 2507 | ASSERT_EVBUFFER_LOCKED(buf); |
2464 | 2508 | |
2465 | if (pos->pos + len > buf->total_len) | |
2509 | if (pos->pos < 0 || | |
2510 | EV_SIZE_MAX - len < (size_t)pos->pos || | |
2511 | pos->pos + len > buf->total_len) | |
2466 | 2512 | return -1; |
2467 | 2513 | |
2468 | 2514 | chain = pos->_internal.chain; |
2586 | 2632 | if (n_vec == 0 && len < 0) { |
2587 | 2633 | /* If no vectors are provided and they asked for "everything", |
2588 | 2634 | * pretend they asked for the actual available amount. */ |
2589 | len = buffer->total_len - len_so_far; | |
2635 | len = buffer->total_len; | |
2636 | if (start_at) { | |
2637 | len -= start_at->pos; | |
2638 | } | |
2590 | 2639 | } |
2591 | 2640 | |
2592 | 2641 | while (chain) { |
2650 | 2699 | |
2651 | 2700 | if (sz < 0) |
2652 | 2701 | goto done; |
2702 | if (INT_MAX >= EVBUFFER_CHAIN_MAX && | |
2703 | (size_t)sz >= EVBUFFER_CHAIN_MAX) | |
2704 | goto done; | |
2653 | 2705 | if ((size_t)sz < space) { |
2654 | 2706 | chain->off += sz; |
2655 | 2707 | buf->total_len += sz; |
2742 | 2794 | int sendfile_okay = 1; |
2743 | 2795 | #endif |
2744 | 2796 | int ok = 1; |
2797 | ||
2798 | if (offset < 0 || length < 0 || | |
2799 | ((ev_uint64_t)length > EVBUFFER_CHAIN_MAX) || | |
2800 | (ev_uint64_t)offset > (ev_uint64_t)(EVBUFFER_CHAIN_MAX - length)) | |
2801 | return (-1); | |
2745 | 2802 | |
2746 | 2803 | #if defined(USE_SENDFILE) |
2747 | 2804 | if (use_sendfile) { |
2848 | 2905 | * can abort without side effects if the read fails. |
2849 | 2906 | */ |
2850 | 2907 | while (length) { |
2851 | read = evbuffer_readfile(tmp, fd, (ev_ssize_t)length); | |
2908 | ev_ssize_t to_read = length > EV_SSIZE_MAX ? EV_SSIZE_MAX : (ev_ssize_t)length; | |
2909 | read = evbuffer_readfile(tmp, fd, to_read); | |
2852 | 2910 | if (read == -1) { |
2853 | 2911 | evbuffer_free(tmp); |
2854 | 2912 | return (-1); |
544 | 544 | bufev_private->read_watermarks_cb, |
545 | 545 | EVBUFFER_CB_ENABLED|EVBUFFER_CB_NODEFER); |
546 | 546 | |
547 | if (evbuffer_get_length(bufev->input) > highmark) | |
547 | if (evbuffer_get_length(bufev->input) >= highmark) | |
548 | 548 | bufferevent_wm_suspend_read(bufev); |
549 | 549 | else if (evbuffer_get_length(bufev->input) < highmark) |
550 | 550 | bufferevent_wm_unsuspend_read(bufev); |
309 | 309 | bufferevent_pair_get_partner(struct bufferevent *bev) |
310 | 310 | { |
311 | 311 | struct bufferevent_pair *bev_p; |
312 | struct bufferevent *partner; | |
312 | struct bufferevent *partner = NULL; | |
313 | 313 | bev_p = upcast(bev); |
314 | 314 | if (! bev_p) |
315 | 315 | return NULL; |
316 | 316 | |
317 | 317 | incref_and_lock(bev); |
318 | partner = downcast(bev_p->partner); | |
318 | if (bev_p->partner) | |
319 | partner = downcast(bev_p->partner); | |
319 | 320 | decref_and_unlock(bev); |
320 | 321 | return partner; |
321 | 322 | } |
388 | 388 | |
389 | 389 | /* The size of `long long', as computed by sizeof. */ |
390 | 390 | #undef SIZEOF_LONG_LONG |
391 | ||
392 | /* The size of `off_t', as computed by sizeof. */ | |
393 | #undef SIZEOF_OFF_T | |
391 | 394 | |
392 | 395 | /* The size of `pthread_t', as computed by sizeof. */ |
393 | 396 | #undef SIZEOF_PTHREAD_T |
2799 | 2799 | ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' |
2800 | 2800 | program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` |
2801 | 2801 | |
2802 | # expand $ac_aux_dir to an absolute path | |
2803 | am_aux_dir=`cd $ac_aux_dir && pwd` | |
2802 | # Expand $ac_aux_dir to an absolute path. | |
2803 | am_aux_dir=`cd "$ac_aux_dir" && pwd` | |
2804 | 2804 | |
2805 | 2805 | if test x"${MISSING+set}" != xset; then |
2806 | 2806 | case $am_aux_dir in |
3114 | 3114 | # Define the identity of the package. |
3115 | 3115 | |
3116 | 3116 | PACKAGE=libevent |
3117 | VERSION=2.0.21-stable-dev | |
3117 | VERSION=2.0.22-stable | |
3118 | 3118 | |
3119 | 3119 | |
3120 | 3120 | cat >>confdefs.h <<_ACEOF |
3210 | 3210 | ac_config_headers="$ac_config_headers config.h" |
3211 | 3211 | |
3212 | 3212 | |
3213 | $as_echo "#define NUMERIC_VERSION 0x02001501" >>confdefs.h | |
3213 | $as_echo "#define NUMERIC_VERSION 0x02001600" >>confdefs.h | |
3214 | 3214 | |
3215 | 3215 | |
3216 | 3216 | if test "$prefix" = "NONE"; then |
14092 | 14092 | _ACEOF |
14093 | 14093 | |
14094 | 14094 | |
14095 | # The cast to long int works around a bug in the HP C Compiler | |
14096 | # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects | |
14097 | # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. | |
14098 | # This bug is HP SR number 8606223364. | |
14099 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of off_t" >&5 | |
14100 | $as_echo_n "checking size of off_t... " >&6; } | |
14101 | if ${ac_cv_sizeof_off_t+:} false; then : | |
14102 | $as_echo_n "(cached) " >&6 | |
14103 | else | |
14104 | if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (off_t))" "ac_cv_sizeof_off_t" "$ac_includes_default"; then : | |
14105 | ||
14106 | else | |
14107 | if test "$ac_cv_type_off_t" = yes; then | |
14108 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 | |
14109 | $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} | |
14110 | as_fn_error 77 "cannot compute sizeof (off_t) | |
14111 | See \`config.log' for more details" "$LINENO" 5; } | |
14112 | else | |
14113 | ac_cv_sizeof_off_t=0 | |
14114 | fi | |
14115 | fi | |
14116 | ||
14117 | fi | |
14118 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_off_t" >&5 | |
14119 | $as_echo "$ac_cv_sizeof_off_t" >&6; } | |
14120 | ||
14121 | ||
14122 | ||
14123 | cat >>confdefs.h <<_ACEOF | |
14124 | #define SIZEOF_OFF_T $ac_cv_sizeof_off_t | |
14125 | _ACEOF | |
14126 | ||
14127 | ||
14095 | 14128 | |
14096 | 14129 | ac_fn_c_check_type "$LINENO" "struct in6_addr" "ac_cv_type_struct_in6_addr" "#define _GNU_SOURCE |
14097 | 14130 | #include <sys/types.h> |
15080 | 15113 | # Disable the unused-function warnings, because these trigger |
15081 | 15114 | # for minheap-internal.h related code. |
15082 | 15115 | CFLAGS="$CFLAGS -Wno-unused-function" |
15116 | ||
15117 | # clang on macosx emits warnigns for each directory specified which | |
15118 | # isn't "used" generating a lot of build noise (typically 3 warnings | |
15119 | # per file | |
15120 | case "$host_os" in | |
15121 | darwin*) | |
15122 | CFLAGS="$CFLAGS -Qunused-arguments" | |
15123 | ;; | |
15124 | esac | |
15083 | 15125 | fi |
15084 | 15126 | |
15085 | 15127 | ##This will break the world on some 64-bit architectures |
10 | 10 | |
11 | 11 | AC_CONFIG_MACRO_DIR([m4]) |
12 | 12 | |
13 | AM_INIT_AUTOMAKE(libevent,2.0.21-stable-dev) | |
13 | AM_INIT_AUTOMAKE(libevent,2.0.22-stable) | |
14 | 14 | AC_CONFIG_HEADERS(config.h) |
15 | AC_DEFINE(NUMERIC_VERSION, 0x02001501, [Numeric representation of the version]) | |
15 | AC_DEFINE(NUMERIC_VERSION, 0x02001600, [Numeric representation of the version]) | |
16 | 16 | |
17 | 17 | dnl Initialize prefix. |
18 | 18 | if test "$prefix" = "NONE"; then |
557 | 557 | AC_CHECK_SIZEOF(short) |
558 | 558 | AC_CHECK_SIZEOF(size_t) |
559 | 559 | AC_CHECK_SIZEOF(void *) |
560 | AC_CHECK_SIZEOF(off_t) | |
560 | 561 | |
561 | 562 | AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t, struct addrinfo, struct sockaddr_storage], , , |
562 | 563 | [#define _GNU_SOURCE |
724 | 725 | # Disable the unused-function warnings, because these trigger |
725 | 726 | # for minheap-internal.h related code. |
726 | 727 | CFLAGS="$CFLAGS -Wno-unused-function" |
728 | ||
729 | # clang on macosx emits warnigns for each directory specified which | |
730 | # isn't "used" generating a lot of build noise (typically 3 warnings | |
731 | # per file | |
732 | case "$host_os" in | |
733 | darwin*) | |
734 | CFLAGS="$CFLAGS -Qunused-arguments" | |
735 | ;; | |
736 | esac | |
727 | 737 | fi |
728 | 738 | |
729 | 739 | ##This will break the world on some 64-bit architectures |
30 | 30 | #include <sys/syscall.h> |
31 | 31 | #include <sys/epoll.h> |
32 | 32 | #include <unistd.h> |
33 | #include <errno.h> | |
33 | 34 | |
34 | 35 | int |
35 | 36 | epoll_create(int size) |
36 | 37 | { |
38 | #if !defined(__NR_epoll_create) && defined(__NR_epoll_create1) | |
39 | if (size <= 0) { | |
40 | errno = EINVAL; | |
41 | return -1; | |
42 | } | |
43 | return (syscall(__NR_epoll_create1, 0)); | |
44 | #else | |
37 | 45 | return (syscall(__NR_epoll_create, size)); |
46 | #endif | |
38 | 47 | } |
39 | 48 | |
40 | 49 | int |
47 | 56 | int |
48 | 57 | epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout) |
49 | 58 | { |
59 | #if !defined(__NR_epoll_wait) && defined(__NR_epoll_pwait) | |
60 | return (syscall(__NR_epoll_pwait, epfd, events, maxevents, timeout, NULL, 0)); | |
61 | #else | |
50 | 62 | return (syscall(__NR_epoll_wait, epfd, events, maxevents, timeout)); |
63 | #endif | |
51 | 64 | } |
152 | 152 | struct bufferevent *parent; |
153 | 153 | }; |
154 | 154 | |
155 | #if _EVENT_SIZEOF_OFF_T < _EVENT_SIZEOF_SIZE_T | |
156 | typedef ev_ssize_t ev_misalign_t; | |
157 | #define EVBUFFER_CHAIN_MAX ((size_t)EV_SSIZE_MAX) | |
158 | #else | |
159 | typedef ev_off_t ev_misalign_t; | |
160 | #if _EVENT_SIZEOF_OFF_T > _EVENT_SIZEOF_SIZE_T | |
161 | #define EVBUFFER_CHAIN_MAX EV_SIZE_MAX | |
162 | #else | |
163 | #define EVBUFFER_CHAIN_MAX ((size_t)EV_SSIZE_MAX) | |
164 | #endif | |
165 | #endif | |
166 | ||
155 | 167 | /** A single item in an evbuffer. */ |
156 | 168 | struct evbuffer_chain { |
157 | 169 | /** points to next buffer in the chain */ |
162 | 174 | |
163 | 175 | /** unused space at the beginning of buffer or an offset into a |
164 | 176 | * file for sendfile buffers. */ |
165 | ev_off_t misalign; | |
177 | ev_misalign_t misalign; | |
166 | 178 | |
167 | 179 | /** Offset into buffer + misalign at which to start writing. |
168 | 180 | * In other words, the total number of bytes actually stored |
726 | 726 | |
727 | 727 | /* this function looks for space on the inflight queue and promotes */ |
728 | 728 | /* requests from the waiting queue if it can. */ |
729 | /* */ | |
730 | /* TODO: */ | |
731 | /* add return code, see at nameserver_pick() and other functions. */ | |
729 | 732 | static void |
730 | 733 | evdns_requests_pump_waiting_queue(struct evdns_base *base) { |
731 | 734 | ASSERT_LOCKED(base); |
732 | 735 | while (base->global_requests_inflight < base->global_max_requests_inflight && |
733 | 736 | base->global_requests_waiting) { |
734 | 737 | struct request *req; |
735 | /* move a request from the waiting queue to the inflight queue */ | |
738 | ||
736 | 739 | EVUTIL_ASSERT(base->req_waiting_head); |
737 | 740 | req = base->req_waiting_head; |
741 | ||
742 | req->ns = nameserver_pick(base); | |
743 | if (!req->ns) | |
744 | return; | |
745 | ||
746 | /* move a request from the waiting queue to the inflight queue */ | |
738 | 747 | evdns_request_remove(req, &base->req_waiting_head); |
739 | 748 | |
740 | 749 | base->global_requests_waiting--; |
741 | 750 | base->global_requests_inflight++; |
742 | 751 | |
743 | req->ns = nameserver_pick(base); | |
744 | 752 | request_trans_id_set(req, transaction_id_pick(base)); |
745 | 753 | |
746 | 754 | evdns_request_insert(req, &REQ_HEAD(base, req->trans_id)); |
2440 | 2448 | EVDNS_LOCK(base); |
2441 | 2449 | evdns_requests_pump_waiting_queue(base); |
2442 | 2450 | EVDNS_UNLOCK(base); |
2451 | ||
2443 | 2452 | return 0; |
2444 | 2453 | } |
2445 | 2454 | |
3936 | 3945 | event_debug_unassign(&server->event); |
3937 | 3946 | if (server->state == 0) |
3938 | 3947 | (void) event_del(&server->timeout_event); |
3948 | if (server->probe_request) { | |
3949 | evdns_cancel_request(server->base, server->probe_request); | |
3950 | server->probe_request = NULL; | |
3951 | } | |
3939 | 3952 | event_debug_unassign(&server->timeout_event); |
3940 | 3953 | mm_free(server); |
3941 | 3954 | } |
3950 | 3963 | /* Requires that we hold the lock. */ |
3951 | 3964 | |
3952 | 3965 | /* TODO(nickm) we might need to refcount here. */ |
3966 | ||
3967 | for (server = base->server_head; server; server = server_next) { | |
3968 | server_next = server->next; | |
3969 | evdns_nameserver_free(server); | |
3970 | if (server_next == base->server_head) | |
3971 | break; | |
3972 | } | |
3973 | base->server_head = NULL; | |
3974 | base->global_good_nameservers = 0; | |
3953 | 3975 | |
3954 | 3976 | for (i = 0; i < base->n_req_heads; ++i) { |
3955 | 3977 | while (base->req_heads[i]) { |
3965 | 3987 | } |
3966 | 3988 | base->global_requests_inflight = base->global_requests_waiting = 0; |
3967 | 3989 | |
3968 | for (server = base->server_head; server; server = server_next) { | |
3969 | server_next = server->next; | |
3970 | evdns_nameserver_free(server); | |
3971 | if (server_next == base->server_head) | |
3972 | break; | |
3973 | } | |
3974 | base->server_head = NULL; | |
3975 | base->global_good_nameservers = 0; | |
3976 | 3990 | |
3977 | 3991 | if (base->global_search_state) { |
3978 | 3992 | for (dom = base->global_search_state->head; dom; dom = dom_next) { |
1255 | 1255 | static inline void |
1256 | 1256 | event_persist_closure(struct event_base *base, struct event *ev) |
1257 | 1257 | { |
1258 | // Define our callback, we use this to store our callback before it's executed | |
1259 | void (*evcb_callback)(evutil_socket_t, short, void *); | |
1260 | ||
1261 | // Other fields of *ev that must be stored before executing | |
1262 | evutil_socket_t evcb_fd; | |
1263 | short evcb_res; | |
1264 | void *evcb_arg; | |
1265 | ||
1258 | 1266 | /* reschedule the persistent event if we have a timeout. */ |
1259 | 1267 | if (ev->ev_io_timeout.tv_sec || ev->ev_io_timeout.tv_usec) { |
1260 | 1268 | /* If there was a timeout, we want it to run at an interval of |
1296 | 1304 | run_at.tv_usec |= usec_mask; |
1297 | 1305 | event_add_internal(ev, &run_at, 1); |
1298 | 1306 | } |
1299 | EVBASE_RELEASE_LOCK(base, th_base_lock); | |
1300 | (*ev->ev_callback)(ev->ev_fd, ev->ev_res, ev->ev_arg); | |
1307 | ||
1308 | // Save our callback before we release the lock | |
1309 | evcb_callback = ev->ev_callback; | |
1310 | evcb_fd = ev->ev_fd; | |
1311 | evcb_res = ev->ev_res; | |
1312 | evcb_arg = ev->ev_arg; | |
1313 | ||
1314 | // Release the lock | |
1315 | EVBASE_RELEASE_LOCK(base, th_base_lock); | |
1316 | ||
1317 | // Execute the callback | |
1318 | (evcb_callback)(evcb_fd, evcb_res, evcb_arg); | |
1301 | 1319 | } |
1302 | 1320 | |
1303 | 1321 | /* |
140 | 140 | {0xb5367df2,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}} |
141 | 141 | #endif |
142 | 142 | |
143 | static int extension_fns_initialized = 0; | |
144 | ||
143 | 145 | static void |
144 | 146 | init_extension_functions(struct win32_extension_fns *ext) |
145 | 147 | { |
154 | 156 | ext->GetAcceptExSockaddrs = get_extension_function(s, |
155 | 157 | &getacceptexsockaddrs); |
156 | 158 | closesocket(s); |
159 | ||
160 | extension_fns_initialized = 1; | |
157 | 161 | } |
158 | 162 | |
159 | 163 | static struct win32_extension_fns the_extension_fns; |
160 | static int extension_fns_initialized = 0; | |
161 | 164 | |
162 | 165 | const struct win32_extension_fns * |
163 | 166 | event_get_win32_extension_fns(void) |
205 | 205 | */ |
206 | 206 | data = evbuffer_pullup( |
207 | 207 | evbuf, len < sizeof(number) + 1 ? len : sizeof(number) + 1); |
208 | if (!data) | |
209 | return (-1); | |
208 | 210 | |
209 | 211 | while (count++ < len) { |
210 | 212 | ev_uint8_t lower = *data++; |
311 | 313 | \ |
312 | 314 | /* XXX(niels): faster? */ \ |
313 | 315 | data = evbuffer_pullup(evbuf, offset + 1) + offset; \ |
316 | if (!data) \ | |
317 | return (-1); \ | |
314 | 318 | \ |
315 | 319 | nibbles = ((data[0] & 0xf0) >> 4) + 1; \ |
316 | 320 | if (nibbles > maxnibbles || (nibbles >> 1) + 1 > len) \ |
318 | 322 | len = (nibbles >> 1) + 1; \ |
319 | 323 | \ |
320 | 324 | data = evbuffer_pullup(evbuf, offset + len) + offset; \ |
325 | if (!data) \ | |
326 | return (-1); \ | |
321 | 327 | \ |
322 | 328 | while (nibbles > 0) { \ |
323 | 329 | number <<= 4; \ |
2108 | 2108 | #endif |
2109 | 2109 | } |
2110 | 2110 | |
2111 | /** | |
2112 | * Volatile pointer to memset: we use this to keep the compiler from | |
2113 | * eliminating our call to memset. | |
2114 | */ | |
2115 | void * (*volatile evutil_memset_volatile_)(void *, int, size_t) = memset; | |
2116 | ||
2117 | void | |
2118 | evutil_memclear_(void *mem, size_t len) | |
2119 | { | |
2120 | evutil_memset_volatile_(mem, 0, len); | |
2121 | } | |
2122 | ||
2111 | 2123 | int |
2112 | 2124 | evutil_sockaddr_is_loopback(const struct sockaddr *addr) |
2113 | 2125 | { |
42 | 42 | #include <stdlib.h> |
43 | 43 | #include <string.h> |
44 | 44 | int |
45 | evutil_secure_rng_set_urandom_device_file(char *fname) | |
46 | { | |
47 | (void) fname; | |
48 | return -1; | |
49 | } | |
50 | int | |
45 | 51 | evutil_secure_rng_init(void) |
46 | 52 | { |
47 | 53 | /* call arc4random() now to force it to self-initialize */ |
69 | 75 | * and fall back otherwise. (OSX does this using some linker |
70 | 76 | * trickery.) |
71 | 77 | */ |
72 | if (arc4random_buf != NULL) { | |
73 | return arc4random_buf(buf, n); | |
78 | { | |
79 | void (*tptr)(void *,size_t) = | |
80 | (void (*)(void*,size_t))arc4random_buf; | |
81 | if (tptr != NULL) { | |
82 | return arc4random_buf(buf, n); | |
83 | } | |
74 | 84 | } |
75 | 85 | #endif |
76 | 86 | /* Make sure that we start out with b at a 4-byte alignment; plenty |
123 | 133 | #endif |
124 | 134 | |
125 | 135 | int |
136 | evutil_secure_rng_set_urandom_device_file(char *fname) | |
137 | { | |
138 | #ifdef TRY_SEED_URANDOM | |
139 | _ARC4_LOCK(); | |
140 | arc4random_urandom_filename = fname; | |
141 | _ARC4_UNLOCK(); | |
142 | #endif | |
143 | return 0; | |
144 | } | |
145 | ||
146 | int | |
126 | 147 | evutil_secure_rng_init(void) |
127 | 148 | { |
128 | 149 | int val; |
382 | 382 | evcon->cb = cb; |
383 | 383 | evcon->cb_arg = arg; |
384 | 384 | |
385 | bufferevent_enable(evcon->bufev, EV_WRITE); | |
386 | ||
387 | 385 | /* Disable the read callback: we don't actually care about data; |
388 | 386 | * we only care about close detection. (We don't disable reading, |
389 | 387 | * since we *do* want to learn about any close events.) */ |
392 | 390 | evhttp_write_cb, |
393 | 391 | evhttp_error_cb, |
394 | 392 | evcon); |
393 | ||
394 | bufferevent_enable(evcon->bufev, EV_WRITE); | |
395 | 395 | } |
396 | 396 | |
397 | 397 | static void |
43 | 43 | with bufferevent_enable() and bufferevent_disable(). |
44 | 44 | |
45 | 45 | When reading is enabled, the bufferevent will try to read from the |
46 | file descriptor onto its input buffer, and and call the read callback. | |
46 | file descriptor onto its input buffer, and call the read callback. | |
47 | 47 | When writing is enabled, the bufferevent will try to write data onto its |
48 | file descriptor when writing is enabled, and call the write callback | |
49 | when the output buffer is sufficiently drained. | |
48 | file descriptor when the output buffer has enough data, and call the write | |
49 | callback when the output buffer is sufficiently drained. | |
50 | 50 | |
51 | 51 | Bufferevents come in several flavors, including: |
52 | 52 |
419 | 419 | |
420 | 420 | @param base the evdns_base to which to apply this operation |
421 | 421 | @param flags any of DNS_OPTION_NAMESERVERS|DNS_OPTION_SEARCH|DNS_OPTION_MISC| |
422 | DNS_OPTIONS_HOSTSFILE|DNS_OPTIONS_ALL | |
422 | DNS_OPTION_HOSTSFILE|DNS_OPTIONS_ALL | |
423 | 423 | @param filename the path to the resolv.conf file |
424 | 424 | @return 0 if successful, or various positive error codes if an error |
425 | 425 | occurred (see above) |
350 | 350 | /** |
351 | 351 | Event dispatching loop |
352 | 352 | |
353 | This loop will run the event base until either there are no more added | |
354 | events, or until something calls event_base_loopbreak() or | |
353 | This loop will run the event base until either there are no more pending or | |
354 | active, or until something calls event_base_loopbreak() or | |
355 | 355 | event_base_loopexit(). |
356 | 356 | |
357 | 357 | @param base the event_base structure returned by event_base_new() or |
358 | 358 | event_base_new_with_config() |
359 | @return 0 if successful, -1 if an error occurred, or 1 if no events were | |
360 | registered. | |
359 | @return 0 if successful, -1 if an error occurred, or 1 if we exited because | |
360 | no events were pending or active. | |
361 | 361 | @see event_base_loop() |
362 | 362 | */ |
363 | 363 | int event_base_dispatch(struct event_base *); |
644 | 644 | This is a more flexible version of event_base_dispatch(). |
645 | 645 | |
646 | 646 | By default, this loop will run the event base until either there are no more |
647 | added events, or until something calls event_base_loopbreak() or | |
648 | evenet_base_loopexit(). You can override this behavior with the 'flags' | |
647 | pending or active events, or until something calls event_base_loopbreak() or | |
648 | event_base_loopexit(). You can override this behavior with the 'flags' | |
649 | 649 | argument. |
650 | 650 | |
651 | 651 | @param eb the event_base structure returned by event_base_new() or |
652 | 652 | event_base_new_with_config() |
653 | 653 | @param flags any combination of EVLOOP_ONCE | EVLOOP_NONBLOCK |
654 | @return 0 if successful, -1 if an error occurred, or 1 if no events were | |
655 | registered. | |
654 | @return 0 if successful, -1 if an error occurred, or 1 if we exited because | |
655 | no events were pending or active. | |
656 | 656 | @see event_base_loopexit(), event_base_dispatch(), EVLOOP_ONCE, |
657 | 657 | EVLOOP_NONBLOCK |
658 | 658 | */ |
647 | 647 | |
648 | 648 | /** Generate n bytes of secure pseudorandom data, and store them in buf. |
649 | 649 | * |
650 | * By default, Libevent uses an ARC4-based random number generator, seeded | |
651 | * using the platform's entropy source (/dev/urandom on Unix-like systems; | |
652 | * CryptGenRandom on Windows). | |
650 | * Current versions of Libevent use an ARC4-based random number generator, | |
651 | * seeded using the platform's entropy source (/dev/urandom on Unix-like | |
652 | * systems; CryptGenRandom on Windows). This is not actually as secure as it | |
653 | * should be: ARC4 is a pretty lousy cipher, and the current implementation | |
654 | * provides only rudimentary prediction- and backtracking-resistance. Don't | |
655 | * use this for serious cryptographic applications. | |
653 | 656 | */ |
654 | 657 | void evutil_secure_rng_get_bytes(void *buf, size_t n); |
655 | 658 | |
671 | 674 | */ |
672 | 675 | int evutil_secure_rng_init(void); |
673 | 676 | |
677 | /** | |
678 | * Set a filename to use in place of /dev/urandom for seeding the secure | |
679 | * PRNG. Return 0 on success, -1 on failure. | |
680 | * | |
681 | * Call this function BEFORE calling any other initialization or RNG | |
682 | * functions. | |
683 | * | |
684 | * (This string will _NOT_ be copied internally. Do not free it while any | |
685 | * user of the secure RNG might be running. Don't pass anything other than a | |
686 | * real /dev/...random device file here, or you might lose security.) | |
687 | * | |
688 | * This API is unstable, and might change in a future libevent version. | |
689 | */ | |
690 | int evutil_secure_rng_set_urandom_device_file(char *fname); | |
691 | ||
674 | 692 | /** Seed the random number generator with extra random bytes. |
675 | 693 | |
676 | 694 | You should almost never need to call this function; it should be |
263 | 263 | #endif |
264 | 264 | evbuffer_add_printf(evb, "</ul></body></html>\n"); |
265 | 265 | #ifdef WIN32 |
266 | CloseHandle(d); | |
266 | FindClose(d); | |
267 | 267 | #else |
268 | 268 | closedir(d); |
269 | 269 | #endif |
243 | 243 | if (memcmp(evbuffer_pullup( |
244 | 244 | evb, -1), buffer, sizeof(buffer) / 2) != 0 || |
245 | 245 | memcmp(evbuffer_pullup( |
246 | evb_two, -1), buffer, sizeof(buffer) != 0)) | |
246 | evb_two, -1), buffer, sizeof(buffer)) != 0) | |
247 | 247 | tt_abort_msg("Pullup did not preserve content"); |
248 | 248 | |
249 | 249 | evbuffer_validate(evb); |
319 | 319 | #endif |
320 | 320 | #endif |
321 | 321 | |
322 | void evutil_memclear_(void *mem, size_t len); | |
323 | ||
322 | 324 | #ifdef __cplusplus |
323 | 325 | } |
324 | 326 | #endif |
371 | 371 | mm_free(win32op->exset_out); |
372 | 372 | /* XXXXX free the tree. */ |
373 | 373 | |
374 | memset(win32op, 0, sizeof(win32op)); | |
374 | memset(win32op, 0, sizeof(*win32op)); | |
375 | 375 | mm_free(win32op); |
376 | 376 | } |
69 | 69 | # compiler: $LTCC |
70 | 70 | # compiler flags: $LTCFLAGS |
71 | 71 | # linker: $LD (gnu? $with_gnu_ld) |
72 | # $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1.10 | |
72 | # $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1.11 | |
73 | 73 | # automake: $automake_version |
74 | 74 | # autoconf: $autoconf_version |
75 | 75 | # |
79 | 79 | |
80 | 80 | PROGRAM=libtool |
81 | 81 | PACKAGE=libtool |
82 | VERSION="2.4.2 Debian-2.4.2-1.10" | |
82 | VERSION="2.4.2 Debian-2.4.2-1.11" | |
83 | 83 | TIMESTAMP="" |
84 | 84 | package_revision=1.3337 |
85 | 85 |
47 | 47 | # Override configure arguments |
48 | 48 | ac_configure_args="$ac_configure_args --disable-libevent-regress --disable-thread-support --disable-openssl" |
49 | 49 | ac_configure_args="$ac_configure_args --disable-malloc-replacement --disable-debug-mode --enable-function-sections" |
50 | ac_configure_args="$ac_configure_args --disable-shared --enable-static" | |
50 | ac_configure_args="$ac_configure_args --disable-shared --enable-static --enable-silent-rules" | |
51 | 51 | AC_CONFIG_SUBDIRS([libevent]) |
52 | 52 | AM_CONDITIONAL([LIBEVENT_EMBEDDED], [test x"$LIBEVENT_EMBEDDED" != x]) |
53 | 53 | AC_SUBST([LIBEVENT_LIBS]) |
34 | 34 | # Enable some additional CFLAGS depending on the OS |
35 | 35 | AC_DEFUN([lldp_CFLAGS_OS], [ |
36 | 36 | # Most of what we want can be enabled nowadays with _GNU_SOURCE |
37 | AX_CFLAGS_GCC_OPTION([-D_GNU_SOURCE]) dnl GNU systems (asprintf, ...) | |
37 | AX_CFLAGS_GCC_OPTION([-D_GNU_SOURCE], [CPPFLAGS]) dnl GNU systems (asprintf, ...) | |
38 | 38 | |
39 | 39 | case $host_os in |
40 | 40 | solaris*) |
41 | AX_CFLAGS_GCC_OPTION([-D__EXTENSIONS__]) dnl (CMSG_*) | |
42 | AX_CFLAGS_GCC_OPTION([-D_XPG4_2]) dnl (CMSG_*) | |
41 | AX_CFLAGS_GCC_OPTION([-D__EXTENSIONS__], [CPPFLAGS]) dnl (CMSG_*) | |
42 | AX_CFLAGS_GCC_OPTION([-D_XPG4_2], [CPPFLAGS]) dnl (CMSG_*) | |
43 | 43 | ;; |
44 | 44 | hpux*) |
45 | AX_CFLAGS_GCC_OPTION([-D_XOPEN_SOURCE=500]) dnl HP-UX | |
46 | AX_CFLAGS_GCC_OPTION([-D_XOPEN_SOURCE_EXTENDED]) dnl HP-UX | |
45 | AX_CFLAGS_GCC_OPTION([-D_XOPEN_SOURCE=500], [CPPFLAGS]) dnl HP-UX | |
46 | AX_CFLAGS_GCC_OPTION([-D_XOPEN_SOURCE_EXTENDED], [CPPFLAGS]) dnl HP-UX | |
47 | 47 | ;; |
48 | 48 | esac |
49 | 49 | ]) |
14 | 14 | AC_MSG_RESULT([found!]) |
15 | 15 | ]) |
16 | 16 | |
17 | # Check if the library is usable | |
18 | _save_flags="$CFLAGS" | |
19 | _save_libs="$LIBS" | |
20 | CFLAGS="$CFLAGS ${XML2_CFLAGS}" | |
21 | LIBS="$LIBS ${XML2_LIBS}" | |
22 | AC_MSG_CHECKING([whether libxml-2 work as expected]) | |
23 | AC_LINK_IFELSE([AC_LANG_PROGRAM([ | |
24 | @%:@include <libxml/encoding.h> | |
25 | @%:@include <libxml/xmlwriter.h> | |
26 | ],[ | |
27 | xmlDocPtr doc; | |
28 | xmlTextWriterPtr xw = xmlNewTextWriterDoc(&doc, 0); | |
29 | return (xw != NULL); | |
30 | ])],[AC_MSG_RESULT(yes)],[ | |
31 | AC_MSG_RESULT(no) | |
32 | AC_MSG_ERROR([*** unable to use libxml-2])]) | |
33 | CFLAGS="$_save_flags" | |
34 | LIBS="$_save_libs" | |
35 | ||
17 | 36 | AC_SUBST([XML2_LIBS]) |
18 | 37 | AC_SUBST([XML2_CFLAGS]) |
19 | 38 | AC_DEFINE_UNQUOTED([USE_XML], 1, [Define to indicate to enable XML support]) |
231 | 231 | LIPO = @LIPO@ |
232 | 232 | LLDPD_CTL_SOCKET = @LLDPD_CTL_SOCKET@ |
233 | 233 | LLDPD_PID_FILE = @LLDPD_PID_FILE@ |
234 | LLDP_CFLAGS = @LLDP_CFLAGS@ | |
235 | LLDP_CPPFLAGS = @LLDP_CPPFLAGS@ | |
236 | LLDP_LDFLAGS = @LLDP_LDFLAGS@ | |
234 | 237 | LN_S = @LN_S@ |
235 | 238 | LTLIBOBJS = @LTLIBOBJS@ |
236 | 239 | MAINT = @MAINT@ |
317 | 320 | mkdir_p = @mkdir_p@ |
318 | 321 | oldincludedir = @oldincludedir@ |
319 | 322 | pdfdir = @pdfdir@ |
323 | pkgconfigdir = @pkgconfigdir@ | |
320 | 324 | prefix = @prefix@ |
321 | 325 | program_transform_name = @program_transform_name@ |
322 | 326 | psdir = @psdir@ |
349 | 353 | @HOST_OS_OSX_TRUE@CLEANFILES = $(TEMPLATES) |
350 | 354 | @HOST_OS_OSX_TRUE@edit = $(SED) \ |
351 | 355 | @HOST_OS_OSX_TRUE@ -e 's|@bindir[@]|$(bindir)|g' \ |
356 | @HOST_OS_OSX_TRUE@ -e 's|@sbindir[@]|$(sbindir)|g' \ | |
352 | 357 | @HOST_OS_OSX_TRUE@ -e 's|@pkgdatadir[@]|$(pkgdatadir)|g' \ |
353 | 358 | @HOST_OS_OSX_TRUE@ -e 's|@libdir[@]|$(libdir)|g' \ |
354 | 359 | @HOST_OS_OSX_TRUE@ -e 's|@includedir[@]|$(includedir)|g' \ |
631 | 636 | @HOST_OS_OSX_TRUE@ chmod +x $@ |
632 | 637 | |
633 | 638 | @HOST_OS_OSX_TRUE@$(TEMPLATES): Makefile |
634 | @HOST_OS_OSX_TRUE@ $(AM_V_GEN)$(edit) $(srcdir)/$@.in > $@.tmp | |
635 | @HOST_OS_OSX_TRUE@ mv $@.tmp $@ | |
639 | @HOST_OS_OSX_TRUE@ $(AM_V_GEN)$(edit) $(srcdir)/$@.in > $@.tmp && mv $@.tmp $@ | |
636 | 640 | |
637 | 641 | @HOST_OS_OSX_TRUE@.PHONY: pkg requirements |
638 | 642 |
0 | AM_CFLAGS = -I $(top_srcdir)/include | |
0 | AM_CFLAGS = -I $(top_srcdir)/include $(LLDP_CFLAGS) | |
1 | AM_CPPFLAGS = $(LLDP_CPPFLAGS) | |
2 | AM_LDFLAGS = $(LLDP_LDFLAGS) | |
1 | 3 | |
2 | 4 | noinst_LTLIBRARIES = libcommon-daemon-lib.la libcommon-daemon-client.la |
3 | 5 | include_HEADERS = lldp-const.h |
287 | 287 | LIPO = @LIPO@ |
288 | 288 | LLDPD_CTL_SOCKET = @LLDPD_CTL_SOCKET@ |
289 | 289 | LLDPD_PID_FILE = @LLDPD_PID_FILE@ |
290 | LLDP_CFLAGS = @LLDP_CFLAGS@ | |
291 | LLDP_CPPFLAGS = @LLDP_CPPFLAGS@ | |
292 | LLDP_LDFLAGS = @LLDP_LDFLAGS@ | |
290 | 293 | LN_S = @LN_S@ |
291 | 294 | LTLIBOBJS = @LTLIBOBJS@ |
292 | 295 | MAINT = @MAINT@ |
373 | 376 | mkdir_p = @mkdir_p@ |
374 | 377 | oldincludedir = @oldincludedir@ |
375 | 378 | pdfdir = @pdfdir@ |
379 | pkgconfigdir = @pkgconfigdir@ | |
376 | 380 | prefix = @prefix@ |
377 | 381 | program_transform_name = @program_transform_name@ |
378 | 382 | psdir = @psdir@ |
388 | 392 | top_build_prefix = @top_build_prefix@ |
389 | 393 | top_builddir = @top_builddir@ |
390 | 394 | top_srcdir = @top_srcdir@ |
391 | AM_CFLAGS = -I $(top_srcdir)/include | |
395 | AM_CFLAGS = -I $(top_srcdir)/include $(LLDP_CFLAGS) | |
396 | AM_CPPFLAGS = $(LLDP_CPPFLAGS) | |
397 | AM_LDFLAGS = $(LLDP_LDFLAGS) | |
392 | 398 | noinst_LTLIBRARIES = libcommon-daemon-lib.la libcommon-daemon-client.la |
393 | 399 | include_HEADERS = lldp-const.h |
394 | 400 | libcommon_daemon_lib_la_SOURCES = \ |
0 | AM_CFLAGS = -I $(top_srcdir)/include | |
0 | AM_CFLAGS = -I $(top_srcdir)/include $(LLDP_CFLAGS) | |
1 | AM_CPPFLAGS = $(LLDP_CPPFLAGS) | |
2 | AM_LDFLAGS = $(LLDP_LDFLAGS) | |
1 | 3 | |
2 | 4 | sbin_PROGRAMS = lldpcli |
3 | 5 | man_MANS = lldpcli.8 |
318 | 318 | LIPO = @LIPO@ |
319 | 319 | LLDPD_CTL_SOCKET = @LLDPD_CTL_SOCKET@ |
320 | 320 | LLDPD_PID_FILE = @LLDPD_PID_FILE@ |
321 | LLDP_CFLAGS = @LLDP_CFLAGS@ | |
322 | LLDP_CPPFLAGS = @LLDP_CPPFLAGS@ | |
323 | LLDP_LDFLAGS = @LLDP_LDFLAGS@ | |
321 | 324 | LN_S = @LN_S@ |
322 | 325 | LTLIBOBJS = @LTLIBOBJS@ |
323 | 326 | MAINT = @MAINT@ |
404 | 407 | mkdir_p = @mkdir_p@ |
405 | 408 | oldincludedir = @oldincludedir@ |
406 | 409 | pdfdir = @pdfdir@ |
410 | pkgconfigdir = @pkgconfigdir@ | |
407 | 411 | prefix = @prefix@ |
408 | 412 | program_transform_name = @program_transform_name@ |
409 | 413 | psdir = @psdir@ |
419 | 423 | top_build_prefix = @top_build_prefix@ |
420 | 424 | top_builddir = @top_builddir@ |
421 | 425 | top_srcdir = @top_srcdir@ |
422 | AM_CFLAGS = -I $(top_srcdir)/include | |
426 | AM_CFLAGS = -I $(top_srcdir)/include $(LLDP_CFLAGS) | |
427 | AM_CPPFLAGS = $(LLDP_CPPFLAGS) | |
428 | AM_LDFLAGS = $(LLDP_LDFLAGS) | |
423 | 429 | man_MANS = lldpcli.8 |
424 | 430 | dist_man_MANS = lldpctl.8 |
425 | 431 | lldpcli_SOURCES = client.h lldpcli.c display.c conf.c conf-med.c \ |
446 | 452 | CLEANFILES = $(TEMPLATES) |
447 | 453 | edit = $(SED) \ |
448 | 454 | -e 's|@bindir[@]|$(bindir)|g' \ |
455 | -e 's|@sbindir[@]|$(sbindir)|g' \ | |
449 | 456 | -e 's|@pkgdatadir[@]|$(pkgdatadir)|g' \ |
450 | 457 | -e 's|@libdir[@]|$(libdir)|g' \ |
451 | 458 | -e 's|@includedir[@]|$(includedir)|g' \ |
1171 | 1178 | lldpcli.8: lldpcli.8.in |
1172 | 1179 | |
1173 | 1180 | $(TEMPLATES): Makefile |
1174 | $(AM_V_GEN)$(edit) $(srcdir)/$@.in > $@.tmp | |
1175 | mv $@.tmp $@ | |
1181 | $(AM_V_GEN)$(edit) $(srcdir)/$@.in > $@.tmp && mv $@.tmp $@ | |
1176 | 1182 | |
1177 | 1183 | # Tell versions [3.59,3.63) of GNU make to not export all variables. |
1178 | 1184 | # Otherwise a system limit (for SysV at least) may be exceeded. |
0 | 0 | # You can put lldpd configuration snippets into this directory. |
1 | # Upon start, lldpd will read each files in this directory and execute content | |
2 | # as if they were passed as arguments to lldpcli | |
3 | # | |
4 | # Files should be suffixed by .conf and have content like: | |
5 | # configure system description 'my little server' | |
6 | # | |
1 | 7 | # See lldpcli(8) for more details. |
69 | 69 | } |
70 | 70 | |
71 | 71 | static int |
72 | cmd_portid_type_local(struct lldpctl_conn_t *conn, struct writer *w, | |
73 | struct cmd_env *env, void *arg) | |
74 | { | |
75 | lldpctl_atom_t *iface; | |
76 | const char *id = cmdenv_get(env, "port-id"); | |
77 | const char *descr = cmdenv_get(env, "port-descr"); | |
78 | ||
79 | if (!id || !strlen(id)) { | |
80 | log_warnx("lldpctl", "no id speficied"); | |
81 | return 0; | |
82 | } | |
83 | ||
84 | while ((iface = cmd_iterate_on_interfaces(conn, env))) { | |
85 | lldpctl_atom_t *port = lldpctl_get_port(iface); | |
86 | if (lldpctl_atom_set_str(port, lldpctl_k_port_id, id) == NULL) { | |
87 | log_warnx("lldpctl", "unable to set LLDP PortID." | |
88 | " %s", lldpctl_last_strerror(conn)); | |
89 | } | |
90 | if (descr && lldpctl_atom_set_str(port, lldpctl_k_port_descr, descr) == NULL) { | |
91 | log_warnx("lldpctl", "unable to set LLDP Port Description." | |
92 | " %s", lldpctl_last_strerror(conn)); | |
93 | } | |
94 | lldpctl_atom_dec_ref(port); | |
95 | } | |
96 | ||
97 | return 1; | |
98 | } | |
99 | ||
100 | static int | |
72 | 101 | cmd_portid_type(struct lldpctl_conn_t *conn, struct writer *w, |
73 | 102 | struct cmd_env *env, void *arg) |
74 | 103 | { |
166 | 195 | NEWLINE, NULL, |
167 | 196 | NULL, cmd_portid_type, |
168 | 197 | b_map->string); |
198 | } else if (!strcmp(b_map->string, "local")) { | |
199 | struct cmd_node *port_id = commands_new( | |
200 | commands_new(configure_lldp_portid_type, | |
201 | b_map->string, "Local", | |
202 | NULL, NULL, NULL), | |
203 | NULL, "Port ID", | |
204 | NULL, cmd_store_env_value, "port-id"); | |
205 | commands_new(port_id, | |
206 | NEWLINE, "Set local port ID", | |
207 | NULL, cmd_portid_type_local, | |
208 | b_map->string); | |
209 | commands_new( | |
210 | commands_new( | |
211 | commands_new(port_id, | |
212 | "description", | |
213 | "Also set port description", | |
214 | NULL, NULL, NULL), | |
215 | NULL, "Port description", | |
216 | NULL, cmd_store_env_value, "port-descr"), | |
217 | NEWLINE, "Set local port ID and description", | |
218 | NULL, cmd_portid_type_local, NULL); | |
169 | 219 | } else if (!strcmp(b_map->string, "macaddress")) { |
170 | 220 | commands_new( |
171 | 221 | commands_new(configure_lldp_portid_type, |
190 | 190 | (what = "unknown flag", lldpctl_atom_set_int(med_policy, |
191 | 191 | lldpctl_k_med_policy_unknown, |
192 | 192 | cmdenv_get(env, "unknown")?1:0)) == NULL || |
193 | (what = "tagged flag", lldpctl_atom_set_int(med_policy, | |
194 | lldpctl_k_med_policy_tagged, | |
195 | cmdenv_get(env, "tagged")?1:0)) == NULL || | |
193 | 196 | (what = "vlan", |
194 | 197 | cmdenv_get(env, "vlan")? |
195 | 198 | lldpctl_atom_set_str(med_policy, |
425 | 428 | "unknown", "Set unknown flag", |
426 | 429 | cmd_check_application_but_no, cmd_store_env_and_pop, "unknown"); |
427 | 430 | commands_new( |
431 | configure_medpolicy, | |
432 | "tagged", "Set tagged flag", | |
433 | cmd_check_application_but_no, cmd_store_env_and_pop, "tagged"); | |
434 | commands_new( | |
428 | 435 | commands_new( |
429 | 436 | configure_medpolicy, |
430 | 437 | "vlan", "VLAN advertising", |
32 | 32 | lldpctl_last_strerror(conn)); |
33 | 33 | return 0; |
34 | 34 | } |
35 | ||
36 | const char *value = cmdenv_get(env, "iface-pattern"); | |
35 | 37 | if (lldpctl_atom_set_str(config, |
36 | lldpctl_k_config_iface_pattern, cmdenv_get(env, "iface-pattern")) == NULL) { | |
38 | lldpctl_k_config_iface_pattern, | |
39 | value) == NULL) { | |
37 | 40 | log_warnx("lldpctl", "unable to set iface-pattern. %s", |
38 | 41 | lldpctl_last_strerror(conn)); |
39 | 42 | lldpctl_atom_dec_ref(config); |
40 | 43 | return 0; |
41 | 44 | } |
42 | log_info("lldpctl", "iface-pattern set to new value %s", cmdenv_get(env, "iface-pattern")); | |
45 | log_info("lldpctl", "iface-pattern set to new value %s", | |
46 | value?value:"(none)"); | |
43 | 47 | lldpctl_atom_dec_ref(config); |
44 | 48 | return 1; |
45 | 49 | } |
74 | 78 | struct cmd_env *env, void *arg) |
75 | 79 | { |
76 | 80 | int platform = 0; |
77 | const char *value = cmdenv_get(env, "description"); | |
78 | if (!value) { | |
81 | const char *what = arg; | |
82 | const char *value; | |
83 | if (!strcmp(what, "system")) { | |
84 | value = cmdenv_get(env, "description"); | |
85 | } else { | |
86 | value = cmdenv_get(env, "platform"); | |
79 | 87 | platform = 1; |
80 | value = cmdenv_get(env, "platform"); | |
81 | } | |
82 | log_debug("lldpctl", "set %s description", platform?"platform":"system"); | |
88 | } | |
89 | log_debug("lldpctl", "set %s description", what); | |
83 | 90 | lldpctl_atom_t *config = lldpctl_get_configuration(conn); |
84 | 91 | if (config == NULL) { |
85 | 92 | log_warnx("lldpctl", "unable to get configuration from lldpd. %s", |
95 | 102 | return 0; |
96 | 103 | } |
97 | 104 | log_info("lldpctl", "description set to new value %s", |
98 | value); | |
105 | value?value:"(none)"); | |
99 | 106 | lldpctl_atom_dec_ref(config); |
100 | 107 | return 1; |
101 | 108 | } |
112 | 119 | lldpctl_last_strerror(conn)); |
113 | 120 | return 0; |
114 | 121 | } |
122 | ||
115 | 123 | const char *value = cmdenv_get(env, "management-pattern"); |
116 | ||
117 | 124 | if (lldpctl_atom_set_str(config, |
118 | 125 | lldpctl_k_config_mgmt_pattern, value) == NULL) { |
119 | 126 | log_warnx("lldpctl", "unable to set management pattern. %s", |
121 | 128 | lldpctl_atom_dec_ref(config); |
122 | 129 | return 0; |
123 | 130 | } |
124 | log_info("lldpctl", "management pattaren set to new value %s", value); | |
131 | log_info("lldpctl", "management pattaren set to new value %s", | |
132 | value?value:"(none)"); | |
125 | 133 | lldpctl_atom_dec_ref(config); |
126 | 134 | return 1; |
127 | 135 | } |
138 | 146 | lldpctl_last_strerror(conn)); |
139 | 147 | return 0; |
140 | 148 | } |
149 | ||
141 | 150 | const char *value = cmdenv_get(env, "hostname"); |
142 | ||
143 | 151 | if (lldpctl_atom_set_str(config, |
144 | 152 | lldpctl_k_config_hostname, value) == NULL) { |
145 | 153 | log_warnx("lldpctl", "unable to set system name. %s", |
147 | 155 | lldpctl_atom_dec_ref(config); |
148 | 156 | return 0; |
149 | 157 | } |
150 | log_info("lldpctl", "system name set to new value %s", value); | |
158 | log_info("lldpctl", "system name set to new value %s", | |
159 | value?value:"(none)"); | |
151 | 160 | lldpctl_atom_dec_ref(config); |
152 | 161 | return 1; |
153 | 162 | } |
310 | 319 | NULL, "Chassis description", |
311 | 320 | NULL, cmd_store_env_value, "description"), |
312 | 321 | NEWLINE, "Override chassis description", |
313 | NULL, cmd_system_description, NULL); | |
322 | NULL, cmd_system_description, "system"); | |
323 | commands_new( | |
324 | commands_new(unconfigure_system, | |
325 | "description", "Don't override chassis description", | |
326 | NULL, NULL, NULL), | |
327 | NEWLINE, "Don't override chassis description", | |
328 | NULL, cmd_system_description, "system"); | |
314 | 329 | |
315 | 330 | commands_new( |
316 | 331 | commands_new( |
320 | 335 | NULL, "Platform description (CDP)", |
321 | 336 | NULL, cmd_store_env_value, "platform"), |
322 | 337 | NEWLINE, "Override platform description", |
323 | NULL, cmd_system_description, NULL); | |
338 | NULL, cmd_system_description, "platform"); | |
339 | commands_new( | |
340 | commands_new(unconfigure_system, | |
341 | "platform", "Don't override platform description", | |
342 | NULL, NULL, NULL), | |
343 | NEWLINE, "Don't override platform description", | |
344 | NULL, cmd_system_description, "platform"); | |
324 | 345 | |
325 | 346 | commands_new( |
326 | 347 | commands_new( |
330 | 351 | NULL, "System name", |
331 | 352 | NULL, cmd_store_env_value, "hostname"), |
332 | 353 | NEWLINE, "Override system name", |
354 | NULL, cmd_hostname, NULL); | |
355 | commands_new( | |
356 | commands_new(unconfigure_system, | |
357 | "hostname", "Don't override system name", | |
358 | NULL, NULL, NULL), | |
359 | NEWLINE, "Don't override system name", | |
333 | 360 | NULL, cmd_hostname, NULL); |
334 | 361 | |
335 | 362 | commands_new( |
347 | 374 | NULL, cmd_store_env_value, "management-pattern"), |
348 | 375 | NEWLINE, "Set IP management pattern", |
349 | 376 | NULL, cmd_management, NULL); |
377 | commands_new( | |
378 | commands_new( | |
379 | commands_new( | |
380 | commands_new(unconfigure_system, | |
381 | "ip", "IP related options", | |
382 | NULL, NULL, NULL), | |
383 | "management", "IP management related options", | |
384 | NULL, NULL, NULL), | |
385 | "pattern", "Delete any IP management pattern", | |
386 | NULL, NULL, NULL), | |
387 | NEWLINE, "Delete any IP management pattern", | |
388 | NULL, cmd_management, NULL); | |
350 | 389 | |
351 | 390 | commands_new( |
352 | 391 | commands_new( |
357 | 396 | NULL, cmd_store_env_value, "iface-pattern"), |
358 | 397 | NEWLINE, "Set active interface pattern", |
359 | 398 | NULL, cmd_iface_pattern, NULL); |
399 | commands_new( | |
400 | commands_new(unconfigure_interface, | |
401 | "pattern", "Delete any interface pattern", | |
402 | NULL, NULL, NULL), | |
403 | NEWLINE, "Delete any interface pattern", | |
404 | NULL, cmd_iface_pattern, NULL); | |
360 | 405 | |
361 | 406 | commands_new( |
362 | 407 | commands_new(configure_interface, |
224 | 224 | TAILQ_INSERT_TAIL(priv, root, next); |
225 | 225 | root->el = json_object(); |
226 | 226 | if (root->el == NULL) |
227 | fatalx("cannot create JSON root object"); | |
227 | fatalx("lldpctl", "cannot create JSON root object"); | |
228 | 228 | |
229 | 229 | result = malloc(sizeof(*result)); |
230 | 230 | if (result == NULL) fatal(NULL, NULL); |
136 | 136 | /* memory will leak... */ |
137 | 137 | } else { |
138 | 138 | struct json_element *first = TAILQ_FIRST(p); |
139 | fprintf(stdout, "%s", json_object_to_json_string(first->el)); | |
139 | int json_flags = (JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_SPACED); | |
140 | fprintf(stdout, "%s", json_object_to_json_string_ext(first->el, json_flags)); | |
140 | 141 | json_object_put(first->el); |
141 | 142 | TAILQ_REMOVE(p, first, next); |
142 | 143 | free(first); |
143 | 144 | } |
145 | fprintf(stdout, "\n"); | |
144 | 146 | free(p); |
145 | 147 | free(w); |
146 | 148 | } |
159 | 161 | TAILQ_INSERT_TAIL(priv, root, next); |
160 | 162 | root->el = json_object_new_object(); |
161 | 163 | if (root->el == NULL) |
162 | fatalx("cannot create JSON root object"); | |
164 | fatalx("lldpctl", "cannot create JSON root object"); | |
163 | 165 | |
164 | 166 | result = malloc(sizeof(*result)); |
165 | 167 | if (result == NULL) fatal(NULL, NULL); |
173 | 173 | .Ic uname -n . |
174 | 174 | .Ed |
175 | 175 | |
176 | .Cd unconfigure | |
177 | .Cd system hostname | |
178 | .Bd -ragged -offset XXXXXX | |
179 | Do not override system hostname and restore the use of the node name. | |
180 | .Ed | |
181 | ||
176 | 182 | .Cd configure |
177 | 183 | .Cd system description Ar description |
178 | 184 | .Bd -ragged -offset XXXXXX |
180 | 186 | kernel name, node name, kernel version, build date and architecture. |
181 | 187 | .Ed |
182 | 188 | |
189 | .Cd unconfigure | |
190 | .Cd system description | |
191 | .Bd -ragged -offset XXXXXX | |
192 | Do not override chassis description and use a value computed from node | |
193 | name, kernel name, kernel version, build date and architecture instead. | |
194 | .Ed | |
195 | ||
183 | 196 | .Cd configure |
184 | 197 | .Cd system platform Ar description |
185 | 198 | .Bd -ragged -offset XXXXXX |
187 | 200 | kernel name. This value is currently only used for CDP. |
188 | 201 | .Ed |
189 | 202 | |
203 | .Cd unconfigure | |
204 | .Cd system platform | |
205 | .Bd -ragged -offset XXXXXX | |
206 | Do not override platform description and use the kernel name. This | |
207 | option undoes the previous one. | |
208 | .Ed | |
209 | ||
190 | 210 | .Cd configure |
191 | 211 | .Cd system interface pattern Ar pattern |
192 | 212 | .Bd -ragged -offset XXXXXX |
193 | Specify which interface to listen to. Without this option, | |
213 | Specify which interface to listen and send LLDPDU to. Without this | |
214 | option, | |
194 | 215 | .Nm lldpd |
195 | will listen on all available physical interfaces. This option can use | |
216 | will use all available physical interfaces. This option can use | |
196 | 217 | wildcards. Several interfaces can be specified separated by commas. |
197 | 218 | It is also possible to blacklist an interface by suffixing it with an |
198 | 219 | exclamation mark. It is possible to whitelist an interface by |
201 | 222 | example, with |
202 | 223 | .Em eth*,!eth1,!eth2 |
203 | 224 | .Nm lldpd |
204 | will only listen to interfaces starting by | |
225 | will only use interfaces starting by | |
205 | 226 | .Em eth |
206 | 227 | with the exception of |
207 | 228 | .Em eth1 |
210 | 231 | While with |
211 | 232 | .Em *,!eth*,!!eth1 |
212 | 233 | .Nm |
213 | will listen to all interfaces, except interfaces starting by | |
234 | will use all interfaces, except interfaces starting by | |
214 | 235 | .Em eth |
215 | 236 | with the exception of |
216 | 237 | .Em eth1 . |
219 | 240 | is specified, it will be accepted even if this is a VLAN interface. |
220 | 241 | .Ed |
221 | 242 | |
243 | .Cd unconfigure | |
244 | .Cd system interface pattern | |
245 | .Bd -ragged -offset XXXXXX | |
246 | Remove any previously configured interface pattern and use all | |
247 | physical interafces. This option undoes the previous one. | |
248 | .Ed | |
249 | ||
222 | 250 | .Cd configure |
223 | 251 | .Cd system interface description |
224 | 252 | .Bd -ragged -offset XXXXXX |
227 | 255 | .Nm lldpd |
228 | 256 | to override this description with the name of the peer neighbor if one |
229 | 257 | is found or with the number of neighbors found. |
258 | .Ed | |
259 | ||
260 | .Cd unconfigure | |
261 | .Cd system interface descripton | |
262 | .Bd -ragged -offset XXXXXX | |
263 | Do not update interface description with the name of the peer | |
264 | neighbor. This option undoes the previous one. | |
230 | 265 | .Ed |
231 | 266 | |
232 | 267 | .Cd configure |
265 | 300 | .Bd -ragged -offset XXXXXX |
266 | 301 | Specify the management addresses of this system. As for interfaces |
267 | 302 | (described above), this option can use wildcards and inversions. |
268 | Without this option, the first IPv4 and the first IPv6 are used. If | |
269 | only negative patterns are provided, only one IPv4 and one IPv6 | |
270 | addresses are chosen. Otherwise, many of them can be selected. If you | |
271 | want to blacklist IPv6 addresses, you can use | |
303 | Without this option, the first IPv4 and the first IPv6 are used. If an | |
304 | exact IP address is provided, it is used as a management address | |
305 | without any check. If only negative patterns are provided, only one | |
306 | IPv4 and one IPv6 addresses are chosen. Otherwise, many of them can be | |
307 | selected. If you want to blacklist IPv6 addresses, you can use | |
272 | 308 | .Em !*:* . |
273 | 309 | .Ed |
274 | 310 | |
275 | .Cd configure | |
276 | .Cd portidsubtype ifname | |
277 | .Cd ifname | macaddress | |
311 | .Cd unconfigure | |
312 | .Cd system ip management pattern | |
313 | .Bd -ragged -offset XXXXXX | |
314 | Unset any specific pattern for matching management addresses. This | |
315 | option undoes the previous one. | |
316 | .Ed | |
317 | ||
318 | .Cd configure | |
319 | .Cd portidsubtype | |
320 | .Cd ifname | macaddress | local Ar value Op Cd description Ar description | |
278 | 321 | .Bd -ragged -offset XXXXXX |
279 | 322 | Force port ID subtype. By default, |
280 | 323 | .Nm |
283 | 326 | interface name will be used as port identifier and the description |
284 | 327 | will be the interface alias. With this command, you can force the port |
285 | 328 | identifier to be the interface name (with |
286 | .Cd ifname ) | |
287 | or the MAC address (with | |
288 | .Cd macaddress ) . | |
329 | .Cd ifname ) , | |
330 | the MAC address (with | |
331 | .Cd macaddress ) | |
332 | or a local value (with | |
333 | .Cd value ) . | |
334 | In the latest case, the local value should be provided. | |
335 | Optionally, a port description can also be provided after the local | |
336 | value. | |
289 | 337 | .Ed |
290 | 338 | |
291 | 339 | .Cd configure |
481 | 529 | .Cd med policy |
482 | 530 | .Cd application Ar application |
483 | 531 | .Op Cd unknown |
532 | .Op Cd tagged | |
484 | 533 | .Op Cd vlan Ar vlan |
485 | 534 | .Op Cd priority Ar priority |
486 | 535 | .Op Cd dscp Ar dscp |
522 | 571 | .Cd vlan |
523 | 572 | tells which 802.1q VLAN ID has to be advertised for the network |
524 | 573 | policy. A valid value is between 1 and 4094. |
574 | .Cd tagged | |
575 | tells the VLAN should be tagged for the specified application type. | |
525 | 576 | .Cd priority |
526 | 577 | allows one to specify IEEE 802.1d / IEEE 802.1p Layer 2 Priority, also |
527 | 578 | known as Class of Service (CoS), to be used for the specified |
528 | application type. It should be one of those values: | |
579 | application type. This field is usually ignored if no VLAN is | |
580 | specified. It should be one of those values: | |
529 | 581 | .Bl -bullet -compact -offset XXXXXXXX |
530 | 582 | .It |
531 | 583 | background |
125 | 125 | |
126 | 126 | priv = malloc(sizeof(*priv)); |
127 | 127 | if (!priv) { |
128 | fatalx("out of memory"); | |
128 | fatalx("lldpctl", "out of memory"); | |
129 | 129 | return NULL; |
130 | 130 | } |
131 | 131 | |
135 | 135 | |
136 | 136 | result = malloc(sizeof(struct writer)); |
137 | 137 | if (!result) { |
138 | fatalx("out of memory"); | |
138 | fatalx("llpctl", "out of memory"); | |
139 | 139 | free(priv); |
140 | 140 | return NULL; |
141 | 141 | } |
43 | 43 | char input[2*strlen(line) + 3]; /* 3 = 2 for '\n ' and 1 for \0 */ |
44 | 44 | memset(input, 0, 2*strlen(line) + 3); |
45 | 45 | for (int pos = 0; line[pos]; pos++) { |
46 | if (line[pos] == '#' && !escaped && !quote) | |
47 | break; | |
46 | 48 | if (!escaped && strchr(escapes, line[pos])) |
47 | 49 | escaped = 1; |
48 | 50 | else if (!escaped && strchr(quotes, line[pos]) && !quote) { |
90 | 90 | |
91 | 91 | priv = malloc( sizeof( *priv ) ); |
92 | 92 | if ( ! priv ) { |
93 | fatalx("out of memory"); | |
93 | fatalx("lldpctl", "out of memory"); | |
94 | 94 | return NULL; |
95 | 95 | } |
96 | 96 | |
97 | 97 | priv->xw = xmlNewTextWriterDoc(&(priv->doc), 0); |
98 | 98 | if ( ! priv->xw ) { |
99 | fatalx("cannot create xml writer"); | |
99 | fatalx("lldpctl", "cannot create xml writer"); | |
100 | 100 | return NULL; |
101 | 101 | } |
102 | 102 | |
103 | 103 | xmlTextWriterSetIndent(priv->xw, 4); |
104 | 104 | |
105 | 105 | if (xmlTextWriterStartDocument(priv->xw, NULL, MY_ENCODING, NULL) < 0 ) { |
106 | fatalx("cannot start xml document"); | |
106 | fatalx("lldpctl", "cannot start xml document"); | |
107 | 107 | return NULL; |
108 | 108 | } |
109 | 109 | |
110 | 110 | result = malloc( sizeof( struct writer ) ); |
111 | 111 | if ( ! result ) { |
112 | fatalx("out of memory"); | |
112 | fatalx("lldpctl", "out of memory"); | |
113 | 113 | return NULL; |
114 | 114 | } |
115 | 115 |
79 | 79 | host_triplet = @host@ |
80 | 80 | subdir = src/compat |
81 | 81 | DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am asprintf.c \ |
82 | setproctitle.c realloc.c strnlen.c malloc.c fgetln.c daemon.c \ | |
83 | vsyslog.c strndup.c strlcpy.c $(top_srcdir)/depcomp | |
82 | vsyslog.c realloc.c setproctitle.c strlcpy.c strnlen.c \ | |
83 | malloc.c daemon.c fgetln.c strndup.c $(top_srcdir)/depcomp | |
84 | 84 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 |
85 | 85 | am__aclocal_m4_deps = $(top_srcdir)/m4/alignof.m4 \ |
86 | 86 | $(top_srcdir)/m4/args.m4 \ |
250 | 250 | LIPO = @LIPO@ |
251 | 251 | LLDPD_CTL_SOCKET = @LLDPD_CTL_SOCKET@ |
252 | 252 | LLDPD_PID_FILE = @LLDPD_PID_FILE@ |
253 | LLDP_CFLAGS = @LLDP_CFLAGS@ | |
254 | LLDP_CPPFLAGS = @LLDP_CPPFLAGS@ | |
255 | LLDP_LDFLAGS = @LLDP_LDFLAGS@ | |
253 | 256 | LN_S = @LN_S@ |
254 | 257 | LTLIBOBJS = @LTLIBOBJS@ |
255 | 258 | MAINT = @MAINT@ |
336 | 339 | mkdir_p = @mkdir_p@ |
337 | 340 | oldincludedir = @oldincludedir@ |
338 | 341 | pdfdir = @pdfdir@ |
342 | pkgconfigdir = @pkgconfigdir@ | |
339 | 343 | prefix = @prefix@ |
340 | 344 | program_transform_name = @program_transform_name@ |
341 | 345 | psdir = @psdir@ |
45 | 45 | |
46 | 46 | if ((s = socket(PF_UNIX, SOCK_STREAM, 0)) == -1) |
47 | 47 | return -1; |
48 | if (fcntl(s, F_SETFD, FD_CLOEXEC) == -1) { | |
49 | close(s); | |
50 | return -1; | |
51 | } | |
48 | 52 | su.sun_family = AF_UNIX; |
49 | 53 | strlcpy(su.sun_path, name, sizeof(su.sun_path)); |
50 | 54 | if (bind(s, (struct sockaddr *)&su, sizeof(struct sockaddr_un)) == -1) { |
0 | AM_CFLAGS = -I $(top_srcdir)/include | |
0 | AM_CFLAGS = -I $(top_srcdir)/include $(LLDP_CFLAGS) | |
1 | AM_CPPFLAGS = $(LLDP_CPPFLAGS) | |
2 | AM_LDFLAGS = $(LLDP_LDFLAGS) | |
1 | 3 | BUILT_SOURCES = |
2 | 4 | CLEANFILES = |
3 | 5 | |
21 | 23 | pattern.c \ |
22 | 24 | probes.d trace.h |
23 | 25 | liblldpd_la_CFLAGS = $(AM_CFLAGS) @LIBEVENT_CFLAGS@ |
24 | liblldpd_la_CPPFLAGS = -DSYSCONFDIR='"$(sysconfdir)"' -DLLDPCLI_PATH='"$(sbindir)/lldpcli"' | |
26 | liblldpd_la_CPPFLAGS = $(AM_CPPFLAGS) -DSYSCONFDIR='"$(sysconfdir)"' -DLLDPCLI_PATH='"$(sbindir)/lldpcli"' | |
25 | 27 | liblldpd_la_LIBADD = \ |
26 | 28 | $(top_builddir)/src/libcommon-daemon-client.la \ |
27 | 29 | $(top_builddir)/src/libcommon-daemon-lib.la @LIBEVENT_LIBS@ |
73 | 75 | interfaces-bsd.c \ |
74 | 76 | dmi-osx.c \ |
75 | 77 | priv-bsd.c |
76 | liblldpd_la_LDFLAGS = -framework Foundation | |
78 | liblldpd_la_LDFLAGS = $(AM_LDFLAGS) | |
79 | liblldpd_la_LDFLAGS += -framework Foundation | |
77 | 80 | liblldpd_la_LDFLAGS += -framework CoreFoundation -framework IOKit |
78 | 81 | liblldpd_la_LDFLAGS += -framework IOKit |
79 | 82 | endif |
421 | 421 | LIPO = @LIPO@ |
422 | 422 | LLDPD_CTL_SOCKET = @LLDPD_CTL_SOCKET@ |
423 | 423 | LLDPD_PID_FILE = @LLDPD_PID_FILE@ |
424 | LLDP_CFLAGS = @LLDP_CFLAGS@ | |
425 | LLDP_CPPFLAGS = @LLDP_CPPFLAGS@ | |
426 | LLDP_LDFLAGS = @LLDP_LDFLAGS@ | |
424 | 427 | LN_S = @LN_S@ |
425 | 428 | LTLIBOBJS = @LTLIBOBJS@ |
426 | 429 | MAINT = @MAINT@ |
507 | 510 | mkdir_p = @mkdir_p@ |
508 | 511 | oldincludedir = @oldincludedir@ |
509 | 512 | pdfdir = @pdfdir@ |
513 | pkgconfigdir = @pkgconfigdir@ | |
510 | 514 | prefix = @prefix@ |
511 | 515 | program_transform_name = @program_transform_name@ |
512 | 516 | psdir = @psdir@ |
522 | 526 | top_build_prefix = @top_build_prefix@ |
523 | 527 | top_builddir = @top_builddir@ |
524 | 528 | top_srcdir = @top_srcdir@ |
525 | AM_CFLAGS = -I $(top_srcdir)/include | |
529 | AM_CFLAGS = -I $(top_srcdir)/include $(LLDP_CFLAGS) | |
530 | AM_CPPFLAGS = $(LLDP_CPPFLAGS) | |
531 | AM_LDFLAGS = $(LLDP_LDFLAGS) | |
526 | 532 | BUILT_SOURCES = $(am__append_11) $(am__append_17) |
527 | 533 | CLEANFILES = $(am__append_12) $(am__append_18) $(TEMPLATES) |
528 | 534 | man_MANS = lldpd.8 |
536 | 542 | $(am__append_7) $(am__append_8) $(am__append_14) |
537 | 543 | liblldpd_la_CFLAGS = $(AM_CFLAGS) @LIBEVENT_CFLAGS@ $(am__append_9) \ |
538 | 544 | $(am__append_15) |
539 | liblldpd_la_CPPFLAGS = -DSYSCONFDIR='"$(sysconfdir)"' -DLLDPCLI_PATH='"$(sbindir)/lldpcli"' | |
545 | liblldpd_la_CPPFLAGS = $(AM_CPPFLAGS) -DSYSCONFDIR='"$(sysconfdir)"' -DLLDPCLI_PATH='"$(sbindir)/lldpcli"' | |
540 | 546 | liblldpd_la_LIBADD = $(top_builddir)/src/libcommon-daemon-client.la \ |
541 | 547 | $(top_builddir)/src/libcommon-daemon-lib.la @LIBEVENT_LIBS@ \ |
542 | 548 | $(am__append_16) |
543 | @HOST_OS_OSX_TRUE@liblldpd_la_LDFLAGS = -framework Foundation \ | |
544 | @HOST_OS_OSX_TRUE@ -framework CoreFoundation -framework IOKit \ | |
545 | @HOST_OS_OSX_TRUE@ -framework IOKit | |
549 | @HOST_OS_OSX_TRUE@liblldpd_la_LDFLAGS = $(AM_LDFLAGS) -framework \ | |
550 | @HOST_OS_OSX_TRUE@ Foundation -framework CoreFoundation \ | |
551 | @HOST_OS_OSX_TRUE@ -framework IOKit -framework IOKit | |
546 | 552 | lldpd_SOURCES = main.c |
547 | 553 | lldpd_LDADD = liblldpd.la @LIBEVENT_LDFLAGS@ $(am__append_10) \ |
548 | 554 | $(am__append_19) |
555 | 561 | TEMPLATES = lldpd.8 lldpd.service lldpd.sysusers.conf |
556 | 562 | edit = $(SED) \ |
557 | 563 | -e 's|@bindir[@]|$(bindir)|g' \ |
564 | -e 's|@sbindir[@]|$(sbindir)|g' \ | |
558 | 565 | -e 's|@pkgdatadir[@]|$(pkgdatadir)|g' \ |
559 | 566 | -e 's|@libdir[@]|$(libdir)|g' \ |
560 | 567 | -e 's|@includedir[@]|$(includedir)|g' \ |
1298 | 1305 | lldpd.sysusers.conf: lldpd.sysusers.conf.in |
1299 | 1306 | |
1300 | 1307 | $(TEMPLATES): Makefile |
1301 | $(AM_V_GEN)$(edit) $(srcdir)/$@.in > $@.tmp | |
1302 | mv $@.tmp $@ | |
1308 | $(AM_V_GEN)$(edit) $(srcdir)/$@.in > $@.tmp && mv $@.tmp $@ | |
1303 | 1309 | |
1304 | 1310 | # Tell versions [3.59,3.63) of GNU make to not export all variables. |
1305 | 1311 | # Otherwise a system limit (for SysV at least) may be exceeded. |
1830 | 1830 | } |
1831 | 1831 | |
1832 | 1832 | void |
1833 | agent_init(struct lldpd *cfg, char *agentx) | |
1833 | agent_init(struct lldpd *cfg, const char *agentx) | |
1834 | 1834 | { |
1835 | 1835 | int rc; |
1836 | 1836 |
17 | 17 | #include "lldpd.h" |
18 | 18 | #include "trace.h" |
19 | 19 | |
20 | static int | |
20 | static ssize_t | |
21 | 21 | client_handle_none(struct lldpd *cfg, enum hmsg_type *type, |
22 | 22 | void *input, int input_len, void **output, int *subscribed) |
23 | 23 | { |
27 | 27 | } |
28 | 28 | |
29 | 29 | /* Return the global configuration */ |
30 | static int | |
30 | static ssize_t | |
31 | 31 | client_handle_get_configuration(struct lldpd *cfg, enum hmsg_type *type, |
32 | 32 | void *input, int input_len, void **output, int *subscribed) |
33 | 33 | { |
41 | 41 | return output_len; |
42 | 42 | } |
43 | 43 | |
44 | static char* | |
45 | xstrdup(const char *str) | |
46 | { | |
47 | if (!str) return NULL; | |
48 | return strdup(str); | |
49 | } | |
50 | ||
44 | 51 | /* Change the global configuration */ |
45 | static int | |
52 | static ssize_t | |
46 | 53 | client_handle_set_configuration(struct lldpd *cfg, enum hmsg_type *type, |
47 | 54 | void *input, int input_len, void **output, int *subscribed) |
48 | 55 | { |
54 | 61 | *type = NONE; |
55 | 62 | return 0; |
56 | 63 | } |
57 | ||
64 | ||
65 | #define CHANGED(w) (config->w != cfg->g_config.w) | |
66 | #define CHANGED_STR(w) (!(config->w == cfg->g_config.w || \ | |
67 | (config->w && cfg->g_config.w && !strcmp(config->w, cfg->g_config.w)))) | |
68 | ||
58 | 69 | /* What needs to be done? Transmit delay? */ |
59 | if (config->c_tx_interval > 0) { | |
60 | log_debug("rpc", "client change transmit interval to %d", | |
61 | config->c_tx_interval); | |
62 | cfg->g_config.c_tx_interval = config->c_tx_interval; | |
63 | LOCAL_CHASSIS(cfg)->c_ttl = cfg->g_config.c_tx_interval * | |
64 | cfg->g_config.c_tx_hold; | |
65 | } | |
66 | if (config->c_tx_hold > 0) { | |
70 | if (CHANGED(c_tx_interval) && config->c_tx_interval != 0) { | |
71 | if (config->c_tx_interval < 0) { | |
72 | log_debug("rpc", "client asked for immediate retransmission"); | |
73 | levent_send_now(cfg); | |
74 | } else { | |
75 | log_debug("rpc", "client change transmit interval to %d", | |
76 | config->c_tx_interval); | |
77 | cfg->g_config.c_tx_interval = config->c_tx_interval; | |
78 | LOCAL_CHASSIS(cfg)->c_ttl = cfg->g_config.c_tx_interval * | |
79 | cfg->g_config.c_tx_hold; | |
80 | } | |
81 | } | |
82 | if (CHANGED(c_tx_hold) && config->c_tx_hold > 0) { | |
67 | 83 | log_debug("rpc", "client change transmit hold to %d", |
68 | config->c_tx_hold); | |
84 | config->c_tx_hold); | |
69 | 85 | cfg->g_config.c_tx_hold = config->c_tx_hold; |
70 | 86 | LOCAL_CHASSIS(cfg)->c_ttl = cfg->g_config.c_tx_interval * |
71 | cfg->g_config.c_tx_hold; | |
72 | } | |
73 | if (config->c_tx_interval < 0) { | |
74 | log_debug("rpc", "client asked for immediate retransmission"); | |
75 | levent_send_now(cfg); | |
76 | } | |
77 | if (config->c_lldp_portid_type > LLDP_PORTID_SUBTYPE_UNKNOWN && | |
78 | config->c_lldp_portid_type <= LLDP_PORTID_SUBTYPE_MAX) { | |
79 | log_debug("rpc", "change lldp portid tlv subtype to %d", | |
80 | config->c_lldp_portid_type); | |
81 | cfg->g_config.c_lldp_portid_type = config->c_lldp_portid_type; | |
82 | levent_update_now(cfg); | |
87 | cfg->g_config.c_tx_hold; | |
88 | } | |
89 | if (CHANGED(c_lldp_portid_type) && | |
90 | config->c_lldp_portid_type > LLDP_PORTID_SUBTYPE_UNKNOWN && | |
91 | config->c_lldp_portid_type <= LLDP_PORTID_SUBTYPE_MAX) { | |
92 | log_debug("rpc", "change lldp portid tlv subtype to %d", | |
93 | config->c_lldp_portid_type); | |
94 | cfg->g_config.c_lldp_portid_type = config->c_lldp_portid_type; | |
95 | levent_update_now(cfg); | |
83 | 96 | } |
84 | 97 | /* Pause/resume */ |
85 | if (config->c_paused != cfg->g_config.c_paused) { | |
98 | if (CHANGED(c_paused)) { | |
86 | 99 | log_debug("rpc", "client asked to %s lldpd", |
87 | 100 | config->c_paused?"pause":"resume"); |
88 | 101 | cfg->g_config.c_paused = config->c_paused; |
90 | 103 | } |
91 | 104 | |
92 | 105 | #ifdef ENABLE_LLDPMED |
93 | if (config->c_enable_fast_start) { | |
94 | cfg->g_config.c_enable_fast_start = (config->c_enable_fast_start == 1); | |
106 | if (CHANGED(c_enable_fast_start)) { | |
107 | cfg->g_config.c_enable_fast_start = config->c_enable_fast_start; | |
95 | 108 | log_debug("rpc", "client asked to %s fast start", |
96 | 109 | cfg->g_config.c_enable_fast_start?"enable":"disable"); |
97 | 110 | } |
98 | if (config->c_tx_fast_interval) { | |
111 | if (CHANGED(c_tx_fast_interval) && | |
112 | config->c_tx_fast_interval > 0) { | |
99 | 113 | log_debug("rpc", "change fast interval to %d", config->c_tx_fast_interval); |
100 | 114 | cfg->g_config.c_tx_fast_interval = config->c_tx_fast_interval; |
101 | 115 | } |
102 | 116 | #endif |
103 | if (config->c_iface_pattern) { | |
104 | log_debug("rpc", "change interface pattern to %s", config->c_iface_pattern); | |
117 | if (CHANGED_STR(c_iface_pattern)) { | |
118 | log_debug("rpc", "change interface pattern to %s", | |
119 | config->c_iface_pattern?config->c_iface_pattern:"(NULL)"); | |
105 | 120 | free(cfg->g_config.c_iface_pattern); |
106 | cfg->g_config.c_iface_pattern = strdup(config->c_iface_pattern); | |
107 | levent_update_now(cfg); | |
108 | } | |
109 | if (config->c_mgmt_pattern) { | |
110 | log_debug("rpc", "change management pattern to %s", config->c_mgmt_pattern); | |
121 | cfg->g_config.c_iface_pattern = xstrdup(config->c_iface_pattern); | |
122 | levent_update_now(cfg); | |
123 | } | |
124 | if (CHANGED_STR(c_mgmt_pattern)) { | |
125 | log_debug("rpc", "change management pattern to %s", | |
126 | config->c_mgmt_pattern?config->c_mgmt_pattern:"(NULL)"); | |
111 | 127 | free(cfg->g_config.c_mgmt_pattern); |
112 | cfg->g_config.c_mgmt_pattern = strdup(config->c_mgmt_pattern); | |
113 | levent_update_now(cfg); | |
114 | } | |
115 | if (config->c_description) { | |
116 | log_debug("rpc", "change chassis description to %s", config->c_description); | |
128 | cfg->g_config.c_mgmt_pattern = xstrdup(config->c_mgmt_pattern); | |
129 | levent_update_now(cfg); | |
130 | } | |
131 | if (CHANGED_STR(c_description)) { | |
132 | log_debug("rpc", "change chassis description to %s", | |
133 | config->c_description?config->c_description:"(NULL)"); | |
117 | 134 | free(cfg->g_config.c_description); |
118 | cfg->g_config.c_description = strdup(config->c_description); | |
119 | levent_update_now(cfg); | |
120 | } | |
121 | if (config->c_platform) { | |
122 | log_debug("rpc", "change platform description to %s", config->c_platform); | |
135 | cfg->g_config.c_description = xstrdup(config->c_description); | |
136 | levent_update_now(cfg); | |
137 | } | |
138 | if (CHANGED_STR(c_platform)) { | |
139 | log_debug("rpc", "change platform description to %s", | |
140 | config->c_platform?config->c_platform:"(NULL)"); | |
123 | 141 | free(cfg->g_config.c_platform); |
124 | cfg->g_config.c_platform = strdup(config->c_platform); | |
125 | levent_update_now(cfg); | |
126 | } | |
127 | if (config->c_hostname) { | |
128 | log_debug("rpc", "change system name to %s", config->c_hostname); | |
142 | cfg->g_config.c_platform = xstrdup(config->c_platform); | |
143 | levent_update_now(cfg); | |
144 | } | |
145 | if (CHANGED_STR(c_hostname)) { | |
146 | log_debug("rpc", "change system name to %s", | |
147 | config->c_hostname?config->c_hostname:"(NULL"); | |
129 | 148 | free(cfg->g_config.c_hostname); |
130 | cfg->g_config.c_hostname = strdup(config->c_hostname); | |
131 | levent_update_now(cfg); | |
132 | } | |
133 | if (config->c_set_ifdescr != cfg->g_config.c_set_ifdescr) { | |
149 | cfg->g_config.c_hostname = xstrdup(config->c_hostname); | |
150 | levent_update_now(cfg); | |
151 | } | |
152 | if (CHANGED(c_set_ifdescr)) { | |
134 | 153 | log_debug("rpc", "%s setting of interface description based on discovered neighbors", |
135 | 154 | config->c_set_ifdescr?"enable":"disable"); |
136 | 155 | cfg->g_config.c_set_ifdescr = config->c_set_ifdescr; |
137 | 156 | levent_update_now(cfg); |
138 | 157 | } |
139 | if (config->c_promisc != cfg->g_config.c_promisc) { | |
158 | if (CHANGED(c_promisc)) { | |
140 | 159 | log_debug("rpc", "%s promiscuous mode on managed interfaces", |
141 | 160 | config->c_promisc?"enable":"disable"); |
142 | 161 | cfg->g_config.c_promisc = config->c_promisc; |
143 | 162 | levent_update_now(cfg); |
144 | 163 | } |
145 | if (config->c_bond_slave_src_mac_type != 0) { | |
164 | if (CHANGED(c_bond_slave_src_mac_type)) { | |
146 | 165 | if (config->c_bond_slave_src_mac_type > |
147 | 166 | LLDP_BOND_SLAVE_SRC_MAC_TYPE_UNKNOWN && |
148 | 167 | config->c_bond_slave_src_mac_type <= |
167 | 186 | Input: nothing. |
168 | 187 | Output: list of interface names (lldpd_interface_list) |
169 | 188 | */ |
170 | static int | |
189 | static ssize_t | |
171 | 190 | client_handle_get_interfaces(struct lldpd *cfg, enum hmsg_type *type, |
172 | 191 | void *input, int input_len, void **output, int *subscribed) |
173 | 192 | { |
174 | 193 | struct lldpd_interface *iff, *iff_next; |
175 | 194 | struct lldpd_hardware *hardware; |
176 | int output_len; | |
195 | ssize_t output_len; | |
177 | 196 | |
178 | 197 | /* Build the list of interfaces */ |
179 | 198 | struct lldpd_interface_list ifs; |
210 | 229 | Input: name of the interface (serialized) |
211 | 230 | Output: Information about the interface (lldpd_hardware) |
212 | 231 | */ |
213 | static int | |
232 | static ssize_t | |
214 | 233 | client_handle_get_interface(struct lldpd *cfg, enum hmsg_type *type, |
215 | 234 | void *input, int input_len, void **output, int *subscribed) |
216 | 235 | { |
229 | 248 | log_debug("rpc", "client request interface %s", name); |
230 | 249 | TAILQ_FOREACH(hardware, &cfg->g_hardware, h_entries) |
231 | 250 | if (!strcmp(hardware->h_ifname, name)) { |
232 | int output_len = lldpd_hardware_serialize(hardware, output); | |
251 | ssize_t output_len = lldpd_hardware_serialize(hardware, output); | |
233 | 252 | free(name); |
234 | 253 | if (output_len <= 0) { |
235 | 254 | *type = NONE; |
248 | 267 | Input: name of the interface, policy/location/power setting to be modified |
249 | 268 | Output: nothing |
250 | 269 | */ |
251 | static int | |
270 | static ssize_t | |
252 | 271 | client_handle_set_port(struct lldpd *cfg, enum hmsg_type *type, |
253 | 272 | void *input, int input_len, void **output, int *subscribed) |
254 | 273 | { |
273 | 292 | TAILQ_FOREACH(hardware, &cfg->g_hardware, h_entries) |
274 | 293 | if (!strcmp(hardware->h_ifname, set->ifname)) { |
275 | 294 | struct lldpd_port *port = &hardware->h_lport; |
276 | (void)port; | |
295 | if (set->local_id) { | |
296 | log_debug("rpc", "requested change to Port ID"); | |
297 | free(port->p_id); | |
298 | port->p_id = strdup(set->local_id); | |
299 | port->p_id_len = strlen(set->local_id); | |
300 | port->p_id_subtype = LLDP_PORTID_SUBTYPE_LOCAL; | |
301 | } | |
302 | if (set->local_descr) { | |
303 | log_debug("rpc", "requested change to Port Description"); | |
304 | free(port->p_descr); | |
305 | port->p_descr = strdup(set->local_descr); | |
306 | } | |
277 | 307 | #ifdef ENABLE_LLDPMED |
278 | 308 | if (set->med_policy && set->med_policy->type > 0) { |
279 | 309 | log_debug("rpc", "requested change to MED policy"); |
332 | 362 | |
333 | 363 | if (ret == 0) |
334 | 364 | log_warn("rpc", "no interface %s found", set->ifname); |
365 | else | |
366 | levent_update_now(cfg); | |
335 | 367 | |
336 | 368 | set_port_finished: |
337 | 369 | if (!ret) *type = NONE; |
338 | 370 | free(set->ifname); |
371 | free(set->local_id); | |
372 | free(set->local_descr); | |
339 | 373 | #ifdef ENABLE_LLDPMED |
340 | 374 | free(set->med_policy); |
341 | 375 | if (set->med_location) free(set->med_location->data); |
349 | 383 | } |
350 | 384 | |
351 | 385 | /* Register subscribtion to neighbor changes */ |
352 | static int | |
386 | static ssize_t | |
353 | 387 | client_handle_subscribe(struct lldpd *cfg, enum hmsg_type *type, |
354 | 388 | void *input, int input_len, void **output, int *subscribed) |
355 | 389 | { |
361 | 395 | struct client_handle { |
362 | 396 | enum hmsg_type type; |
363 | 397 | const char *name; |
364 | int (*handle)(struct lldpd*, enum hmsg_type *, | |
398 | ssize_t (*handle)(struct lldpd*, enum hmsg_type *, | |
365 | 399 | void *, int, void **, int *); |
366 | 400 | }; |
367 | 401 | |
383 | 417 | int *subscribed) |
384 | 418 | { |
385 | 419 | struct client_handle *ch; |
386 | void *answer; size_t len, sent; | |
420 | void *answer; ssize_t len, sent; | |
387 | 421 | |
388 | 422 | log_debug("rpc", "handle client request"); |
389 | 423 | for (ch = client_handles; ch->handle != NULL; ch++) { |
382 | 382 | } |
383 | 383 | |
384 | 384 | static void |
385 | levent_priv(evutil_socket_t fd, short what, void *arg) | |
386 | { | |
387 | struct event_base *base = arg; | |
388 | ssize_t n; | |
389 | int err; | |
390 | char one; | |
391 | (void)what; | |
392 | /* Check if we have some data available. We need to pass the socket in | |
393 | * non-blocking mode to be able to run the check without disruption. */ | |
394 | levent_make_socket_nonblocking(fd); | |
395 | n = read(fd, &one, 0); err = errno; | |
396 | levent_make_socket_blocking(fd); | |
397 | ||
398 | switch (n) { | |
399 | case -1: | |
400 | if (err == EAGAIN || err == EWOULDBLOCK) | |
401 | /* No data, all good */ | |
402 | return; | |
403 | log_warnx("event", "unable to poll monitor process, exit"); | |
404 | break; | |
405 | case 0: | |
406 | log_warnx("event", "monitor process has terminated, exit"); | |
407 | break; | |
408 | default: | |
409 | /* Unfortunately, dead code, if we have data, we have requested | |
410 | * 0 byte, so we will fall in the previous case. It seems safer | |
411 | * to ask for 0 byte than asking for 1 byte. In the later case, | |
412 | * if we have to speak with the monitor again before exiting, we | |
413 | * would be out of sync. */ | |
414 | log_warnx("event", "received unexpected data from monitor process, exit"); | |
415 | break; | |
416 | } | |
417 | event_base_loopbreak(base); | |
418 | } | |
419 | ||
420 | static void | |
385 | 421 | levent_dump(evutil_socket_t fd, short what, void *arg) |
386 | 422 | { |
387 | 423 | struct event_base *base = arg; |
431 | 467 | log_debug("event", "initialize libevent"); |
432 | 468 | event_set_log_callback(levent_log_cb); |
433 | 469 | if (!(cfg->g_base = event_base_new())) |
434 | fatalx("unable to create a new libevent base"); | |
470 | fatalx("event", "unable to create a new libevent base"); | |
435 | 471 | log_info("event", "libevent %s initialized with %s method", |
436 | 472 | event_get_version(), |
437 | 473 | event_base_get_method(cfg->g_base)); |
444 | 480 | levent_snmp_timeout, |
445 | 481 | cfg); |
446 | 482 | if (!cfg->g_snmp_timeout) |
447 | fatalx("unable to setup timeout function for SNMP"); | |
483 | fatalx("event", "unable to setup timeout function for SNMP"); | |
448 | 484 | if ((cfg->g_snmp_fds = |
449 | 485 | malloc(sizeof(struct ev_l))) == NULL) |
450 | fatalx("unable to allocate memory for SNMP events"); | |
486 | fatalx("event", "unable to allocate memory for SNMP events"); | |
451 | 487 | TAILQ_INIT(levent_snmp_fds(cfg)); |
452 | 488 | } |
453 | 489 | #endif |
457 | 493 | if (!(cfg->g_main_loop = event_new(cfg->g_base, -1, 0, |
458 | 494 | levent_update_and_send, |
459 | 495 | cfg))) |
460 | fatalx("unable to setup main timer"); | |
496 | fatalx("event", "unable to setup main timer"); | |
461 | 497 | event_active(cfg->g_main_loop, EV_TIMEOUT, 1); |
462 | 498 | |
463 | 499 | /* Setup unix socket */ |
500 | struct event *ctl_event; | |
464 | 501 | log_debug("event", "register Unix socket"); |
465 | 502 | TAILQ_INIT(&lldpd_clients); |
466 | 503 | levent_make_socket_nonblocking(cfg->g_ctl); |
467 | if ((cfg->g_ctl_event = event_new(cfg->g_base, cfg->g_ctl, | |
504 | if ((ctl_event = event_new(cfg->g_base, cfg->g_ctl, | |
468 | 505 | EV_READ|EV_PERSIST, levent_ctl_accept, cfg)) == NULL) |
469 | fatalx("unable to setup control socket event"); | |
470 | event_add(cfg->g_ctl_event, NULL); | |
506 | fatalx("event", "unable to setup control socket event"); | |
507 | event_add(ctl_event, NULL); | |
508 | ||
509 | /* Somehow monitor the monitor process */ | |
510 | struct event *monitor_event; | |
511 | log_debug("event", "monitor the monitor process"); | |
512 | if ((monitor_event = event_new(cfg->g_base, priv_fd(PRIV_UNPRIVILEGED), | |
513 | EV_READ|EV_PERSIST, levent_priv, cfg->g_base)) == NULL) | |
514 | fatalx("event", "unable to monitor monitor process"); | |
515 | event_add(monitor_event, NULL); | |
471 | 516 | |
472 | 517 | /* Signals */ |
473 | 518 | log_debug("event", "register signals"); |
474 | signal(SIGHUP, SIG_IGN); | |
475 | 519 | evsignal_add(evsignal_new(cfg->g_base, SIGUSR1, |
476 | 520 | levent_dump, cfg->g_base), |
477 | 521 | NULL); |
787 | 831 | } |
788 | 832 | return 0; |
789 | 833 | } |
834 | ||
835 | int | |
836 | levent_make_socket_blocking(int fd) | |
837 | { | |
838 | int flags; | |
839 | if ((flags = fcntl(fd, F_GETFL, NULL)) < 0) { | |
840 | log_warn("event", "fcntl(%d, F_GETFL)", fd); | |
841 | return -1; | |
842 | } | |
843 | if (!(flags & O_NONBLOCK)) return 0; | |
844 | if (fcntl(fd, F_SETFL, flags & ~O_NONBLOCK) == -1) { | |
845 | log_warn("event", "fcntl(%d, F_SETFL)", fd); | |
846 | return -1; | |
847 | } | |
848 | return 0; | |
849 | } |
0 | 0 | /* -*- mode: c; c-file-style: "openbsd" -*- */ |
1 | 1 | /* |
2 | 2 | * Copyright (c) 2009 Vincent Bernat <bernat@luffy.cx> |
3 | * Copyright (c) 2014 Michael Chapman | |
3 | 4 | * |
4 | 5 | * Permission to use, copy, modify, and/or distribute this software for any |
5 | 6 | * purpose with or without fee is hereby granted, provided that the above |
25 | 26 | |
26 | 27 | /* This set of macro are used to build packets. The current position in buffer |
27 | 28 | * is `pos'. The length of the remaining space in buffer is `length'. `type' |
28 | * should be a member of `types'. This was stolen from ladvd which was adapted | |
29 | * from Net::CDP. */ | |
29 | * should be a member of `types'. | |
30 | * | |
31 | * This was stolen from ladvd which was adapted from Net::CDP. The original | |
32 | * author of those macros, Michael Chapman, has relicensed those macros under | |
33 | * the ISC license. */ | |
30 | 34 | |
31 | 35 | #define POKE(value, type, func) \ |
32 | 36 | ((length >= sizeof(type)) && \ |
445 | 445 | interfaces_setup_multicast(cfg, hardware->h_ifname, 0); |
446 | 446 | |
447 | 447 | /* Then, we open a raw interface for the master */ |
448 | log_debug("interfaces", "bonded device %s has master %s(%d)", | |
449 | hardware->h_ifname, master->name, master->index); | |
448 | 450 | if ((fd = priv_iface_init(master->index, master->name)) == -1) { |
449 | 451 | close(hardware->h_sendfd); |
450 | 452 | return -1; |
550 | 552 | iface->name); |
551 | 553 | continue; |
552 | 554 | } |
553 | hardware->h_data = calloc(1, sizeof(struct bond_master)); | |
554 | if (!hardware->h_data) { | |
555 | bmaster = hardware->h_data = calloc(1, sizeof(struct bond_master)); | |
556 | if (!bmaster) { | |
555 | 557 | log_warn("interfaces", "not enough memory"); |
556 | 558 | lldpd_hardware_cleanup(cfg, hardware); |
557 | 559 | continue; |
558 | 560 | } |
561 | bmaster->index = master->index; | |
562 | strlcpy(bmaster->name, master->name, IFNAMSIZ); | |
559 | 563 | if (iface_bond_init(cfg, hardware) != 0) { |
560 | 564 | log_warn("interfaces", "unable to initialize %s", |
561 | 565 | hardware->h_ifname); |
339 | 339 | } |
340 | 340 | } |
341 | 341 | |
342 | #ifndef IN_IS_ADDR_LOOPBACK | |
342 | #undef IN_IS_ADDR_LOOPBACK | |
343 | 343 | #define IN_IS_ADDR_LOOPBACK(a) ((a)->s_addr == htonl(INADDR_LOOPBACK)) |
344 | #endif | |
345 | #ifndef IN_IS_ADDR_ANY | |
344 | #undef IN_IS_ADDR_ANY | |
346 | 345 | #define IN_IS_ADDR_ANY(a) ((a)->s_addr == htonl(INADDR_ANY)) |
347 | #endif | |
348 | #ifndef IN_IS_ADDR_GLOBAL | |
349 | #define IN_IS_ADDR_GLOBAL(a) (!IN_IS_ADDR_LOOPBACK(a) && !IN_IS_ADDR_ANY(a)) | |
350 | #endif | |
351 | #ifndef IN6_IS_ADDR_GLOBAL | |
346 | #undef IN_IS_ADDR_LINKLOCAL | |
347 | #define IN_IS_ADDR_LINKLOCAL(a) (((a)->s_addr & htonl(0xffff0000)) == htonl(0xa9fe0000)) | |
348 | #undef IN_IS_ADDR_GLOBAL | |
349 | #define IN_IS_ADDR_GLOBAL(a) (!IN_IS_ADDR_LOOPBACK(a) && !IN_IS_ADDR_ANY(a) && !IN_IS_ADDR_LINKLOCAL(a)) | |
350 | #undef IN6_IS_ADDR_GLOBAL | |
352 | 351 | #define IN6_IS_ADDR_GLOBAL(a) \ |
353 | 352 | (!IN6_IS_ADDR_LOOPBACK(a) && !IN6_IS_ADDR_LINKLOCAL(a)) |
354 | #endif | |
353 | ||
354 | /* Add management addresses for the given family. We only take one of each | |
355 | address family, unless a pattern is provided and is not all negative. For | |
356 | example !*:*,!10.* will only blacklist addresses. We will pick the first IPv4 | |
357 | address not matching 10.*. | |
358 | */ | |
359 | static int | |
360 | interfaces_helper_mgmt_for_af(struct lldpd *cfg, | |
361 | int af, | |
362 | struct interfaces_address_list *addrs, | |
363 | int global, int allnegative) | |
364 | { | |
365 | struct interfaces_address *addr; | |
366 | struct lldpd_mgmt *mgmt; | |
367 | char addrstrbuf[INET6_ADDRSTRLEN]; | |
368 | int found = 0; | |
369 | void *sin_addr_ptr; | |
370 | size_t sin_addr_size; | |
371 | ||
372 | TAILQ_FOREACH(addr, addrs, next) { | |
373 | if (addr->address.ss_family != lldpd_af(af)) | |
374 | continue; | |
375 | ||
376 | switch (af) { | |
377 | case LLDPD_AF_IPV4: | |
378 | sin_addr_ptr = &((struct sockaddr_in *)&addr->address)->sin_addr; | |
379 | sin_addr_size = sizeof(struct in_addr); | |
380 | if (global) { | |
381 | if (!IN_IS_ADDR_GLOBAL((struct in_addr *)sin_addr_ptr)) | |
382 | continue; | |
383 | } else { | |
384 | if (!IN_IS_ADDR_LINKLOCAL((struct in_addr *)sin_addr_ptr)) | |
385 | continue; | |
386 | } | |
387 | break; | |
388 | case LLDPD_AF_IPV6: | |
389 | sin_addr_ptr = &((struct sockaddr_in6 *)&addr->address)->sin6_addr; | |
390 | sin_addr_size = sizeof(struct in6_addr); | |
391 | if (global) { | |
392 | if (!IN6_IS_ADDR_GLOBAL((struct in6_addr *)sin_addr_ptr)) | |
393 | continue; | |
394 | } else { | |
395 | if (!IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)sin_addr_ptr)) | |
396 | continue; | |
397 | } | |
398 | break; | |
399 | default: | |
400 | assert(0); | |
401 | continue; | |
402 | } | |
403 | if (inet_ntop(lldpd_af(af), sin_addr_ptr, | |
404 | addrstrbuf, sizeof(addrstrbuf)) == NULL) { | |
405 | log_warn("interfaces", "unable to convert IP address to a string"); | |
406 | continue; | |
407 | } | |
408 | if (cfg->g_config.c_mgmt_pattern == NULL || | |
409 | pattern_match(addrstrbuf, cfg->g_config.c_mgmt_pattern, allnegative)) { | |
410 | mgmt = lldpd_alloc_mgmt(af, sin_addr_ptr, sin_addr_size, | |
411 | addr->index); | |
412 | if (mgmt == NULL) { | |
413 | assert(errno == ENOMEM); /* anything else is a bug */ | |
414 | log_warn("interfaces", "out of memory error"); | |
415 | return found; | |
416 | } | |
417 | log_debug("interfaces", "add management address %s", addrstrbuf); | |
418 | TAILQ_INSERT_TAIL(&LOCAL_CHASSIS(cfg)->c_mgmt, mgmt, m_entries); | |
419 | found = 1; | |
420 | ||
421 | /* Don't take additional address if the pattern is all negative. */ | |
422 | if (allnegative) break; | |
423 | } | |
424 | } | |
425 | return found; | |
426 | } | |
355 | 427 | |
356 | 428 | /* Find a management address in all available interfaces, even those that were |
357 | 429 | already handled. This is a special interface handler because it does not |
361 | 433 | interfaces_helper_mgmt(struct lldpd *cfg, |
362 | 434 | struct interfaces_address_list *addrs) |
363 | 435 | { |
364 | struct interfaces_address *addr; | |
365 | char addrstrbuf[INET6_ADDRSTRLEN]; | |
366 | struct lldpd_mgmt *mgmt; | |
367 | void *sin_addr_ptr; | |
368 | size_t sin_addr_size; | |
436 | int allnegative = 0; | |
369 | 437 | int af; |
370 | int allnegative = 0; | |
438 | const char *pattern = cfg->g_config.c_mgmt_pattern; | |
371 | 439 | |
372 | 440 | lldpd_chassis_mgmt_cleanup(LOCAL_CHASSIS(cfg)); |
373 | 441 | |
442 | /* Is the pattern provided an actual IP address? */ | |
443 | if (pattern && strpbrk(pattern, "!,*?") == NULL) { | |
444 | struct in6_addr addr; | |
445 | size_t addr_size; | |
446 | for (af = LLDPD_AF_UNSPEC + 1; | |
447 | af != LLDPD_AF_LAST; af++) { | |
448 | switch (af) { | |
449 | case LLDPD_AF_IPV4: addr_size = sizeof(struct in_addr); break; | |
450 | case LLDPD_AF_IPV6: addr_size = sizeof(struct in6_addr); break; | |
451 | default: assert(0); | |
452 | } | |
453 | if (inet_pton(lldpd_af(af), pattern, &addr) == 1) | |
454 | break; | |
455 | } | |
456 | if (af == LLDPD_AF_LAST) { | |
457 | log_debug("interfaces", | |
458 | "interface management pattern is an incorrect IP"); | |
459 | } else { | |
460 | struct lldpd_mgmt *mgmt; | |
461 | mgmt = lldpd_alloc_mgmt(af, &addr, addr_size, 0); | |
462 | if (mgmt == NULL) { | |
463 | log_warn("interfaces", "out of memory error"); | |
464 | return; | |
465 | } | |
466 | log_debug("interfaces", "add exact management address %s", | |
467 | pattern); | |
468 | TAILQ_INSERT_TAIL(&LOCAL_CHASSIS(cfg)->c_mgmt, mgmt, m_entries); | |
469 | } | |
470 | return; | |
471 | } | |
472 | ||
374 | 473 | /* Is the pattern provided all negative? */ |
375 | if (cfg->g_config.c_mgmt_pattern == NULL) allnegative = 1; | |
376 | else if (cfg->g_config.c_mgmt_pattern[0] == '!') { | |
474 | if (pattern == NULL) allnegative = 1; | |
475 | else if (pattern[0] == '!') { | |
377 | 476 | /* If each comma is followed by '!', its an all |
378 | 477 | negative pattern */ |
379 | char *sep = cfg->g_config.c_mgmt_pattern; | |
478 | const char *sep = pattern; | |
380 | 479 | while ((sep = strchr(sep, ',')) && |
381 | 480 | (*(++sep) == '!')); |
382 | 481 | if (sep == NULL) allnegative = 1; |
384 | 483 | |
385 | 484 | /* Find management addresses */ |
386 | 485 | for (af = LLDPD_AF_UNSPEC + 1; af != LLDPD_AF_LAST; af++) { |
387 | /* We only take one of each address family, unless a | |
388 | pattern is provided and is not all negative. For | |
389 | example !*:*,!10.* will only blacklist | |
390 | addresses. We will pick the first IPv4 address not | |
391 | matching 10.*. */ | |
392 | TAILQ_FOREACH(addr, addrs, next) { | |
393 | if (addr->address.ss_family != lldpd_af(af)) | |
394 | continue; | |
395 | ||
396 | switch (af) { | |
397 | case LLDPD_AF_IPV4: | |
398 | sin_addr_ptr = &((struct sockaddr_in *)&addr->address)->sin_addr; | |
399 | sin_addr_size = sizeof(struct in_addr); | |
400 | if (!IN_IS_ADDR_GLOBAL((struct in_addr *)sin_addr_ptr)) | |
401 | continue; | |
402 | break; | |
403 | case LLDPD_AF_IPV6: | |
404 | sin_addr_ptr = &((struct sockaddr_in6 *)&addr->address)->sin6_addr; | |
405 | sin_addr_size = sizeof(struct in6_addr); | |
406 | if (!IN6_IS_ADDR_GLOBAL((struct in6_addr *)sin_addr_ptr)) | |
407 | continue; | |
408 | break; | |
409 | default: | |
410 | assert(0); | |
411 | continue; | |
412 | } | |
413 | if (inet_ntop(lldpd_af(af), sin_addr_ptr, | |
414 | addrstrbuf, sizeof(addrstrbuf)) == NULL) { | |
415 | log_warn("interfaces", "unable to convert IP address to a string"); | |
416 | continue; | |
417 | } | |
418 | if (cfg->g_config.c_mgmt_pattern == NULL || | |
419 | pattern_match(addrstrbuf, cfg->g_config.c_mgmt_pattern, allnegative)) { | |
420 | mgmt = lldpd_alloc_mgmt(af, sin_addr_ptr, sin_addr_size, | |
421 | addr->index); | |
422 | if (mgmt == NULL) { | |
423 | assert(errno == ENOMEM); /* anything else is a bug */ | |
424 | log_warn("interfaces", "out of memory error"); | |
425 | return; | |
426 | } | |
427 | log_debug("interfaces", "add management address %s", addrstrbuf); | |
428 | TAILQ_INSERT_TAIL(&LOCAL_CHASSIS(cfg)->c_mgmt, mgmt, m_entries); | |
429 | ||
430 | /* Don't take additional address if the pattern is all negative. */ | |
431 | if (allnegative) break; | |
432 | } | |
433 | } | |
486 | (void)(interfaces_helper_mgmt_for_af(cfg, af, addrs, 1, allnegative) || | |
487 | interfaces_helper_mgmt_for_af(cfg, af, addrs, 0, allnegative)); | |
434 | 488 | } |
435 | 489 | } |
436 | 490 | |
441 | 495 | struct interfaces_device *iface) |
442 | 496 | { |
443 | 497 | struct lldpd_port *port = &hardware->h_lport; |
498 | ||
499 | if (port->p_id_subtype == LLDP_PORTID_SUBTYPE_LOCAL) | |
500 | return; | |
444 | 501 | |
445 | 502 | /* We need to set the portid to what the client configured. |
446 | 503 | This can be done from the CLI. |
451 | 508 | hardware->h_ifname); |
452 | 509 | port->p_id_subtype = LLDP_PORTID_SUBTYPE_IFNAME; |
453 | 510 | port->p_id_len = strlen(hardware->h_ifname); |
454 | if (port->p_id != NULL) { | |
455 | free(port->p_id); | |
456 | } | |
511 | free(port->p_id); | |
457 | 512 | if ((port->p_id = calloc(1, port->p_id_len)) == NULL) |
458 | 513 | fatal("interfaces", NULL); |
459 | 514 | memcpy(port->p_id, hardware->h_ifname, port->p_id_len); |
464 | 519 | log_debug("interfaces", "use MAC address for %s", |
465 | 520 | hardware->h_ifname); |
466 | 521 | port->p_id_subtype = LLDP_PORTID_SUBTYPE_LLADDR; |
467 | if (port->p_id != NULL) { | |
468 | free(port->p_id); | |
469 | } | |
522 | free(port->p_id); | |
470 | 523 | if ((port->p_id = calloc(1, ETHER_ADDR_LEN)) == NULL) |
471 | 524 | fatal("interfaces", NULL); |
472 | 525 | memcpy(port->p_id, hardware->h_lladdr, ETHER_ADDR_LEN); |
477 | 530 | /* use the actual alias in the port description */ |
478 | 531 | log_debug("interfaces", "using alias in description for %s", |
479 | 532 | hardware->h_ifname); |
480 | if (port->p_descr != NULL) { | |
481 | free(port->p_descr); | |
482 | } | |
533 | free(port->p_descr); | |
483 | 534 | port->p_descr = strdup(iface->alias); |
484 | 535 | } else { |
485 | 536 | /* use the ifname in the port description until alias is set */ |
486 | 537 | log_debug("interfaces", "using ifname in description for %s", |
487 | 538 | hardware->h_ifname); |
488 | if (port->p_descr != NULL) { | |
489 | free(port->p_descr); | |
490 | } | |
539 | free(port->p_descr); | |
491 | 540 | port->p_descr = strdup(hardware->h_ifname); |
492 | 541 | } |
493 | 542 | } |
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | int | |
55 | lldp_send(struct lldpd *global, | |
56 | struct lldpd_hardware *hardware) | |
54 | static int _lldp_send(struct lldpd *global, | |
55 | struct lldpd_hardware *hardware, | |
56 | u_int8_t c_id_subtype, | |
57 | char *c_id, | |
58 | int c_id_len, | |
59 | u_int8_t p_id_subtype, | |
60 | char *p_id, | |
61 | int p_id_len, | |
62 | int shutdown) | |
57 | 63 | { |
58 | 64 | struct lldpd_port *port; |
59 | 65 | struct lldpd_chassis *chassis; |
77 | 83 | int i; |
78 | 84 | const u_int8_t med[] = LLDP_TLV_ORG_MED; |
79 | 85 | #endif |
80 | ||
81 | log_debug("lldp", "send LLDP PDU to %s", | |
82 | hardware->h_ifname); | |
83 | ||
84 | 86 | port = &hardware->h_lport; |
85 | 87 | chassis = port->p_chassis; |
86 | 88 | length = hardware->h_mtu; |
101 | 103 | /* Chassis ID */ |
102 | 104 | if (!( |
103 | 105 | POKE_START_LLDP_TLV(LLDP_TLV_CHASSIS_ID) && |
104 | POKE_UINT8(chassis->c_id_subtype) && | |
105 | POKE_BYTES(chassis->c_id, chassis->c_id_len) && | |
106 | POKE_UINT8(c_id_subtype) && | |
107 | POKE_BYTES(c_id, c_id_len) && | |
106 | 108 | POKE_END_LLDP_TLV)) |
107 | 109 | goto toobig; |
108 | 110 | |
109 | 111 | /* Port ID */ |
110 | 112 | if (!( |
111 | 113 | POKE_START_LLDP_TLV(LLDP_TLV_PORT_ID) && |
112 | POKE_UINT8(port->p_id_subtype) && | |
113 | POKE_BYTES(port->p_id, port->p_id_len) && | |
114 | POKE_UINT8(p_id_subtype) && | |
115 | POKE_BYTES(p_id, p_id_len) && | |
114 | 116 | POKE_END_LLDP_TLV)) |
115 | 117 | goto toobig; |
116 | 118 | |
117 | 119 | /* Time to live */ |
118 | 120 | if (!( |
119 | 121 | POKE_START_LLDP_TLV(LLDP_TLV_TTL) && |
120 | POKE_UINT16(chassis->c_ttl) && | |
122 | POKE_UINT16(shutdown?0:chassis->c_ttl) && | |
121 | 123 | POKE_END_LLDP_TLV)) |
122 | 124 | goto toobig; |
125 | ||
126 | if (shutdown) | |
127 | goto end; | |
123 | 128 | |
124 | 129 | /* System name */ |
125 | 130 | if (chassis->c_name && *chassis->c_name != '\0') { |
423 | 428 | } |
424 | 429 | #endif |
425 | 430 | |
431 | end: | |
426 | 432 | /* END */ |
427 | 433 | if (!( |
428 | 434 | POKE_START_LLDP_TLV(LLDP_TLV_END) && |
440 | 446 | hardware->h_tx_cnt++; |
441 | 447 | |
442 | 448 | /* We assume that LLDP frame is the reference */ |
443 | if ((frame = (struct lldpd_frame*)malloc( | |
449 | if (!shutdown && (frame = (struct lldpd_frame*)malloc( | |
444 | 450 | sizeof(int) + pos - packet)) != NULL) { |
445 | 451 | frame->size = pos - packet; |
446 | 452 | memcpy(&frame->frame, packet, frame->size); |
449 | 455 | (memcmp(hardware->h_lport.p_lastframe->frame, frame->frame, |
450 | 456 | frame->size) != 0)) { |
451 | 457 | free(hardware->h_lport.p_lastframe); |
452 | hardware->h_lport.p_lastframe = frame; | |
453 | hardware->h_lport.p_lastchange = time(NULL); | |
454 | } else | |
455 | free(frame); | |
458 | hardware->h_lport.p_lastframe = frame; | |
459 | hardware->h_lport.p_lastchange = time(NULL); | |
460 | } else free(frame); | |
456 | 461 | } |
457 | 462 | |
458 | 463 | free(packet); |
461 | 466 | toobig: |
462 | 467 | free(packet); |
463 | 468 | return E2BIG; |
469 | } | |
470 | ||
471 | /* Send a shutdown LLDPDU. */ | |
472 | int | |
473 | lldp_send_shutdown(struct lldpd *global, | |
474 | struct lldpd_hardware *hardware) | |
475 | { | |
476 | if (hardware->h_lchassis_previous_id == NULL || | |
477 | hardware->h_lport_previous_id == NULL) | |
478 | return 0; | |
479 | return _lldp_send(global, hardware, | |
480 | hardware->h_lchassis_previous_id_subtype, | |
481 | hardware->h_lchassis_previous_id, | |
482 | hardware->h_lchassis_previous_id_len, | |
483 | hardware->h_lport_previous_id_subtype, | |
484 | hardware->h_lport_previous_id, | |
485 | hardware->h_lport_previous_id_len, | |
486 | 1); | |
487 | } | |
488 | ||
489 | int | |
490 | lldp_send(struct lldpd *global, | |
491 | struct lldpd_hardware *hardware) | |
492 | { | |
493 | struct lldpd_port *port = &hardware->h_lport; | |
494 | struct lldpd_chassis *chassis = port->p_chassis; | |
495 | int ret; | |
496 | ||
497 | /* Check if we have a change. */ | |
498 | if (hardware->h_lchassis_previous_id != NULL && | |
499 | hardware->h_lport_previous_id != NULL && | |
500 | (hardware->h_lchassis_previous_id_subtype != chassis->c_id_subtype || | |
501 | hardware->h_lchassis_previous_id_len != chassis->c_id_len || | |
502 | hardware->h_lport_previous_id_subtype != port->p_id_subtype || | |
503 | hardware->h_lport_previous_id_len != port->p_id_len || | |
504 | memcmp(hardware->h_lchassis_previous_id, | |
505 | chassis->c_id, chassis->c_id_len) || | |
506 | memcmp(hardware->h_lport_previous_id, | |
507 | port->p_id, port->p_id_len))) { | |
508 | log_info("lldp", "MSAP has changed for port %s, sending a shutdown LLDPDU", | |
509 | hardware->h_ifname); | |
510 | if ((ret = lldp_send_shutdown(global, hardware)) != 0) | |
511 | return ret; | |
512 | } | |
513 | ||
514 | log_debug("lldp", "send LLDP PDU to %s", | |
515 | hardware->h_ifname); | |
516 | ||
517 | if ((ret = _lldp_send(global, hardware, | |
518 | chassis->c_id_subtype, | |
519 | chassis->c_id, | |
520 | chassis->c_id_len, | |
521 | port->p_id_subtype, | |
522 | port->p_id, | |
523 | port->p_id_len, | |
524 | 0)) != 0) | |
525 | return ret; | |
526 | ||
527 | /* Record current chassis and port ID */ | |
528 | free(hardware->h_lchassis_previous_id); | |
529 | hardware->h_lchassis_previous_id_subtype = chassis->c_id_subtype; | |
530 | hardware->h_lchassis_previous_id_len = chassis->c_id_len; | |
531 | if ((hardware->h_lchassis_previous_id = malloc(chassis->c_id_len)) != NULL) | |
532 | memcpy(hardware->h_lchassis_previous_id, chassis->c_id, | |
533 | chassis->c_id_len); | |
534 | free(hardware->h_lport_previous_id); | |
535 | hardware->h_lport_previous_id_subtype = port->p_id_subtype; | |
536 | hardware->h_lport_previous_id_len = port->p_id_len; | |
537 | if ((hardware->h_lport_previous_id = malloc(port->p_id_len)) != NULL) | |
538 | memcpy(hardware->h_lport_previous_id, port->p_id, | |
539 | port->p_id_len); | |
540 | ||
541 | return 0; | |
464 | 542 | } |
465 | 543 | |
466 | 544 | #define CHECK_TLV_SIZE(x, name) \ |
482 | 560 | const char dot3[] = LLDP_TLV_ORG_DOT3; |
483 | 561 | const char med[] = LLDP_TLV_ORG_MED; |
484 | 562 | const char dcbx[] = LLDP_TLV_ORG_DCBX; |
485 | char orgid[3]; | |
563 | unsigned char orgid[3]; | |
486 | 564 | int length, gotend = 0, ttl_received = 0; |
487 | 565 | int tlv_size, tlv_type, tlv_subtype; |
488 | 566 | u_int8_t *pos, *tlv; |
624 | 702 | case LLDP_TLV_MGMT_ADDR: |
625 | 703 | CHECK_TLV_SIZE(1, "Management address"); |
626 | 704 | addr_str_length = PEEK_UINT8; |
627 | CHECK_TLV_SIZE(addr_str_length, "Management address"); | |
705 | CHECK_TLV_SIZE(1 + addr_str_length, "Management address"); | |
628 | 706 | PEEK_BYTES(addr_str_buffer, addr_str_length); |
629 | 707 | addr_length = addr_str_length - 1; |
630 | 708 | addr_family = addr_str_buffer[0]; |
631 | 709 | addr_ptr = &addr_str_buffer[1]; |
632 | CHECK_TLV_SIZE(5, "Management address"); | |
710 | CHECK_TLV_SIZE(1 + addr_str_length + 5, "Management address"); | |
633 | 711 | iface_subtype = PEEK_UINT8; |
634 | 712 | iface_number = PEEK_UINT32; |
635 | 713 | |
726 | 804 | goto malformed; |
727 | 805 | } |
728 | 806 | pi->p_pi_len = PEEK_UINT8; |
729 | CHECK_TLV_SIZE(1 + pi->p_pi_len, "PI"); | |
807 | CHECK_TLV_SIZE(5 + pi->p_pi_len, "PI"); | |
730 | 808 | if ((pi->p_pi = |
731 | 809 | (char *)calloc(1, pi->p_pi_len)) == NULL) { |
732 | 810 | log_warn("lldp", "unable to alloc pid name for " |
185 | 185 | .It Fl m Ar management |
186 | 186 | Specify the management addresses of this system. As for interfaces |
187 | 187 | (described below), this option can use wildcards and inversions. |
188 | Without this option, the first IPv4 and the first IPv6 are used. If | |
189 | only negative patterns are provided, only one IPv4 and one IPv6 | |
190 | addresses are chosen. Otherwise, many of them can be selected. If you | |
191 | want to blacklist IPv6 addresses, you can use | |
188 | Without this option, the first IPv4 and the first IPv6 are used. If an | |
189 | exact IP address is provided, it is used as a management address | |
190 | without any check. If only negative patterns are provided, only one | |
191 | IPv4 and one IPv6 addresses are chosen. Otherwise, many of them can be | |
192 | selected. If you want to blacklist IPv6 addresses, you can use | |
192 | 193 | .Em !*:* . |
193 | 194 | .It Fl u Ar file |
194 | 195 | Specify the Unix-domain socket used for communication with |
195 | 196 | .Xr lldpctl 8 . |
196 | 197 | .It Fl I Ar interfaces |
197 | Specify which interface to listen to. Without this option, | |
198 | .Nm | |
199 | will listen on all available physical interfaces. This option can use | |
198 | Specify which interface to listen and send LLDPDU to. Without this | |
199 | option, | |
200 | .Nm | |
201 | will use all available physical interfaces. This option can use | |
200 | 202 | wildcards. Several interfaces can be specified separated by commas. |
201 | 203 | It is also possible to blacklist an interface by suffixing it with an |
202 | 204 | exclamation mark. It is possible to whitelist an interface by |
205 | 207 | example, with |
206 | 208 | .Em eth*,!eth1,!eth2 |
207 | 209 | .Nm |
208 | will only listen to interfaces starting by | |
210 | will only use interfaces starting by | |
209 | 211 | .Em eth |
210 | 212 | with the exception of |
211 | 213 | .Em eth1 |
214 | 216 | While with |
215 | 217 | .Em *,!eth*,!!eth1 |
216 | 218 | .Nm |
217 | will listen to all interfaces, except interfaces starting by | |
219 | will use all interfaces, except interfaces starting by | |
218 | 220 | .Em eth |
219 | 221 | with the exception of |
220 | 222 | .Em eth1 . |
206 | 206 | { |
207 | 207 | log_debug("alloc", "cleanup hardware port %s", hardware->h_ifname); |
208 | 208 | |
209 | free(hardware->h_lport_previous); | |
210 | free(hardware->h_lchassis_previous_id); | |
211 | free(hardware->h_lport_previous_id); | |
209 | 212 | lldpd_port_cleanup(&hardware->h_lport, 1); |
210 | 213 | if (hardware->h_ops && hardware->h_ops->cleanup) |
211 | 214 | hardware->h_ops->cleanup(cfg, hardware); |
291 | 294 | /* Reset timer for ports that have been changed. */ |
292 | 295 | struct lldpd_hardware *hardware; |
293 | 296 | TAILQ_FOREACH(hardware, &cfg->g_hardware, h_entries) { |
294 | /* We need to compute a checksum of the local port. To do this, | |
295 | * we zero out fields that are not significant, marshal the | |
296 | * port, compute the checksum, then restore. */ | |
297 | /* We keep a flat copy of the local port to see if there is any | |
298 | * change. To do this, we zero out fields that are not | |
299 | * significant, marshal the port, then restore. */ | |
297 | 300 | struct lldpd_port *port = &hardware->h_lport; |
298 | u_int16_t cksum; | |
299 | 301 | u_int8_t *output = NULL; |
300 | size_t output_len; | |
301 | char save[offsetof(struct lldpd_port, p_id_subtype)]; | |
302 | ssize_t output_len; | |
303 | char save[LLDPD_PORT_START_MARKER]; | |
302 | 304 | memcpy(save, port, sizeof(save)); |
303 | 305 | /* coverity[suspicious_sizeof] |
304 | 306 | We intentionally partially memset port */ |
311 | 313 | hardware->h_ifname); |
312 | 314 | continue; |
313 | 315 | } |
314 | cksum = frame_checksum(output, output_len, 0); | |
315 | free(output); | |
316 | if (cksum != hardware->h_lport_cksum) { | |
316 | ||
317 | /* Compare with the previous value */ | |
318 | if (hardware->h_lport_previous && | |
319 | output_len == hardware->h_lport_previous_len && | |
320 | !memcmp(output, hardware->h_lport_previous, output_len)) { | |
321 | log_debug("localchassis", | |
322 | "no change detected for port %s", | |
323 | hardware->h_ifname); | |
324 | } else { | |
317 | 325 | log_debug("localchassis", |
318 | 326 | "change detected for port %s, resetting its timer", |
319 | 327 | hardware->h_ifname); |
320 | hardware->h_lport_cksum = cksum; | |
321 | 328 | levent_schedule_pdu(hardware); |
322 | } else { | |
323 | log_debug("localchassis", | |
324 | "no change detected for port %s", | |
325 | hardware->h_ifname); | |
326 | } | |
329 | } | |
330 | ||
331 | /* Update the value */ | |
332 | free(hardware->h_lport_previous); | |
333 | hardware->h_lport_previous = output; | |
334 | hardware->h_lport_previous_len = output_len; | |
327 | 335 | } |
328 | 336 | } |
329 | 337 | |
897 | 905 | free(buffer); |
898 | 906 | } |
899 | 907 | |
908 | static void | |
909 | lldpd_send_shutdown(struct lldpd_hardware *hardware) | |
910 | { | |
911 | struct lldpd *cfg = hardware->h_cfg; | |
912 | if (cfg->g_config.c_receiveonly || cfg->g_config.c_paused) return; | |
913 | if ((hardware->h_flags & IFF_RUNNING) == 0) | |
914 | return; | |
915 | ||
916 | /* It's safe to call `lldp_send_shutdown()` because shutdown LLDPU will | |
917 | * only be emitted if LLDP was sent on that port. */ | |
918 | if (lldp_send_shutdown(hardware->h_cfg, hardware) != 0) | |
919 | log_warnx("send", "unable to send shutdown LLDPDU on %s", | |
920 | hardware->h_ifname); | |
921 | } | |
922 | ||
900 | 923 | void |
901 | 924 | lldpd_send(struct lldpd_hardware *hardware) |
902 | 925 | { |
1006 | 1029 | log_debug("localchassis", "use overridden system name `%s`", cfg->g_config.c_hostname); |
1007 | 1030 | hp = cfg->g_config.c_hostname; |
1008 | 1031 | } else { |
1009 | if ((hp = priv_gethostbyname()) == NULL) | |
1032 | if ((hp = priv_gethostname()) == NULL) | |
1010 | 1033 | fatal("localchassis", "failed to get system name"); |
1011 | 1034 | } |
1012 | 1035 | free(LOCAL_CHASSIS(cfg)->c_name); |
1111 | 1134 | { |
1112 | 1135 | struct lldpd_hardware *hardware, *hardware_next; |
1113 | 1136 | log_debug("main", "exit lldpd"); |
1137 | ||
1138 | TAILQ_FOREACH(hardware, &cfg->g_hardware, h_entries) | |
1139 | lldpd_send_shutdown(hardware); | |
1140 | ||
1114 | 1141 | close(cfg->g_ctl); |
1115 | 1142 | priv_ctl_cleanup(cfg->g_ctlname); |
1116 | 1143 | log_debug("main", "cleanup hardware information"); |
1283 | 1310 | int ch, debug = 0; |
1284 | 1311 | #ifdef USE_SNMP |
1285 | 1312 | int snmp = 0; |
1286 | char *agentx = NULL; /* AgentX socket */ | |
1287 | #endif | |
1288 | char *ctlname = LLDPD_CTL_SOCKET; | |
1313 | const char *agentx = NULL; /* AgentX socket */ | |
1314 | #endif | |
1315 | const char *ctlname = NULL; | |
1289 | 1316 | char *mgmtp = NULL; |
1290 | 1317 | char *cidp = NULL; |
1291 | 1318 | char *interfaces = NULL; |
1307 | 1334 | int receiveonly = 0; |
1308 | 1335 | int ctl; |
1309 | 1336 | |
1337 | #ifdef ENABLE_PRIVSEP | |
1310 | 1338 | /* Non privileged user */ |
1311 | 1339 | struct passwd *user; |
1312 | 1340 | struct group *group; |
1313 | 1341 | uid_t uid; |
1314 | 1342 | gid_t gid; |
1343 | #endif | |
1315 | 1344 | |
1316 | 1345 | saved_argv = argv; |
1317 | 1346 | |
1352 | 1381 | fprintf(stderr, "-m can only be used once\n"); |
1353 | 1382 | usage(); |
1354 | 1383 | } |
1355 | mgmtp = optarg; | |
1384 | mgmtp = strdup(optarg); | |
1356 | 1385 | break; |
1357 | 1386 | case 'u': |
1358 | 1387 | if (ctlname) { |
1366 | 1395 | fprintf(stderr, "-I can only be used once\n"); |
1367 | 1396 | usage(); |
1368 | 1397 | } |
1369 | interfaces = optarg; | |
1398 | interfaces = strdup(optarg); | |
1370 | 1399 | break; |
1371 | 1400 | case 'C': |
1372 | 1401 | if (cidp) { |
1373 | 1402 | fprintf(stderr, "-C can only be used once\n"); |
1374 | 1403 | usage(); |
1375 | 1404 | } |
1376 | cidp = optarg; | |
1405 | cidp = strdup(optarg); | |
1377 | 1406 | break; |
1378 | 1407 | case 'L': |
1379 | 1408 | if (strlen(optarg)) lldpcli = optarg; |
1449 | 1478 | } |
1450 | 1479 | } |
1451 | 1480 | |
1481 | if (ctlname == NULL) ctlname = LLDPD_CTL_SOCKET; | |
1482 | ||
1452 | 1483 | /* Set correct smart mode */ |
1453 | 1484 | for (i=0; (filters[i].a != -1) && (filters[i].a != smart); i++); |
1454 | 1485 | if (filters[i].a == -1) { |
1463 | 1494 | log_debug("main", "lldpd starting..."); |
1464 | 1495 | |
1465 | 1496 | /* Grab uid and gid to use for priv sep */ |
1497 | #ifdef ENABLE_PRIVSEP | |
1466 | 1498 | if ((user = getpwnam(PRIVSEP_USER)) == NULL) |
1467 | 1499 | fatal("main", "no " PRIVSEP_USER " user for privilege separation"); |
1468 | 1500 | uid = user->pw_uid; |
1469 | 1501 | if ((group = getgrnam(PRIVSEP_GROUP)) == NULL) |
1470 | 1502 | fatal("main", "no " PRIVSEP_GROUP " group for privilege separation"); |
1471 | 1503 | gid = group->gr_gid; |
1504 | #endif | |
1472 | 1505 | |
1473 | 1506 | /* Create and setup socket */ |
1474 | 1507 | int retry = 1; |
1483 | 1516 | /* Another instance is running */ |
1484 | 1517 | close(tfd); |
1485 | 1518 | log_warnx("main", "another instance is running, please stop it"); |
1486 | fatalx("giving up"); | |
1519 | fatalx("main", "giving up"); | |
1487 | 1520 | } else if (errno == ECONNREFUSED) { |
1488 | 1521 | /* Nobody is listening */ |
1489 | 1522 | log_info("main", "old control socket is present, clean it"); |
1491 | 1524 | continue; |
1492 | 1525 | } |
1493 | 1526 | log_warn("main", "cannot determine if another daemon is already running"); |
1494 | fatalx("giving up"); | |
1527 | fatalx("main", "giving up"); | |
1495 | 1528 | } |
1496 | 1529 | log_warn("main", "unable to create control socket"); |
1497 | fatalx("giving up"); | |
1498 | } | |
1530 | fatalx("main", "giving up"); | |
1531 | } | |
1532 | #ifdef ENABLE_PRIVSEP | |
1499 | 1533 | if (chown(ctlname, uid, gid) == -1) |
1500 | 1534 | log_warn("main", "unable to chown control socket"); |
1501 | 1535 | if (chmod(ctlname, |
1502 | 1536 | S_IRUSR | S_IWUSR | S_IXUSR | |
1503 | 1537 | S_IRGRP | S_IWGRP | S_IXGRP) == -1) |
1504 | 1538 | log_warn("main", "unable to chmod control socket"); |
1539 | #endif | |
1505 | 1540 | |
1506 | 1541 | /* Disable SIGPIPE */ |
1507 | 1542 | signal(SIGPIPE, SIG_IGN); |
1546 | 1581 | } |
1547 | 1582 | |
1548 | 1583 | log_debug("main", "initialize privilege separation"); |
1584 | #ifdef ENABLE_PRIVSEP | |
1549 | 1585 | priv_init(PRIVSEP_CHROOT, ctl, uid, gid); |
1586 | #else | |
1587 | priv_init(PRIVSEP_CHROOT, ctl, 0, 0); | |
1588 | #endif | |
1550 | 1589 | |
1551 | 1590 | /* Initialization of global configuration */ |
1552 | 1591 | if ((cfg = (struct lldpd *) |
112 | 112 | int g_snmp; |
113 | 113 | struct event *g_snmp_timeout; |
114 | 114 | void *g_snmp_fds; |
115 | char *g_snmp_agentx; | |
115 | const char *g_snmp_agentx; | |
116 | 116 | #endif /* USE_SNMP */ |
117 | 117 | |
118 | 118 | /* Unix socket handling */ |
119 | 119 | const char *g_ctlname; |
120 | 120 | int g_ctl; |
121 | struct event *g_ctl_event; | |
122 | 121 | struct event *g_iface_event; /* Triggered when there is an interface change */ |
123 | 122 | struct event *g_iface_timer_event; /* Triggered one second after last interface change */ |
124 | 123 | |
157 | 156 | void levent_schedule_pdu(struct lldpd_hardware *); |
158 | 157 | void levent_schedule_cleanup(struct lldpd *); |
159 | 158 | int levent_make_socket_nonblocking(int); |
159 | int levent_make_socket_blocking(int); | |
160 | 160 | |
161 | 161 | /* lldp.c */ |
162 | int lldp_send_shutdown(PROTO_SEND_SIG); | |
162 | 163 | int lldp_send(PROTO_SEND_SIG); |
163 | 164 | int lldp_decode(PROTO_DECODE_SIG); |
164 | 165 | |
201 | 202 | #ifdef USE_SNMP |
202 | 203 | /* agent.c */ |
203 | 204 | void agent_shutdown(void); |
204 | void agent_init(struct lldpd *, char *); | |
205 | void agent_init(struct lldpd *, const char *); | |
205 | 206 | void agent_notify(struct lldpd_hardware *, int, struct lldpd_port *); |
206 | 207 | #endif |
207 | 208 | |
222 | 223 | void priv_init(const char*, int, uid_t, gid_t); |
223 | 224 | void priv_wait(void); |
224 | 225 | void priv_ctl_cleanup(const char *ctlname); |
225 | char *priv_gethostbyname(void); | |
226 | char *priv_gethostname(void); | |
226 | 227 | #ifdef HOST_OS_LINUX |
227 | 228 | int priv_open(char*); |
228 | 229 | void asroot_open(void); |
266 | 267 | void must_write(enum priv_context, const void *, size_t); |
267 | 268 | void priv_privileged_fd(int); |
268 | 269 | void priv_unprivileged_fd(int); |
270 | int priv_fd(enum priv_context); | |
269 | 271 | int receive_fd(enum priv_context); |
270 | 272 | void send_fd(enum priv_context, int); |
271 | 273 |
37 | 37 | must_write(PRIV_UNPRIVILEGED, &cmd, sizeof(enum priv_cmd)); |
38 | 38 | len = strlen(file); |
39 | 39 | must_write(PRIV_UNPRIVILEGED, &len, sizeof(int)); |
40 | must_write(PRIV_UNPRIVILEGED, file, len + 1); | |
40 | must_write(PRIV_UNPRIVILEGED, file, len); | |
41 | 41 | priv_wait(); |
42 | 42 | must_read(PRIV_UNPRIVILEGED, &rc, sizeof(int)); |
43 | 43 | if (rc == -1) |
54 | 54 | must_write(PRIV_UNPRIVILEGED, &cmd, sizeof(enum priv_cmd)); |
55 | 55 | len = strlen(ifname); |
56 | 56 | must_write(PRIV_UNPRIVILEGED, &len, sizeof(int)); |
57 | must_write(PRIV_UNPRIVILEGED, ifname, len + 1); | |
57 | must_write(PRIV_UNPRIVILEGED, ifname, len); | |
58 | 58 | priv_wait(); |
59 | 59 | must_read(PRIV_UNPRIVILEGED, &rc, sizeof(int)); |
60 | 60 | if (rc != 0) |
78 | 78 | |
79 | 79 | /* Kill children and exit */ |
80 | 80 | kill(monitored, SIGTERM); |
81 | fatalx("invalid syscall not allowed: stop here"); | |
81 | fatalx("seccomp", "invalid syscall not allowed: stop here"); | |
82 | 82 | _exit(161); |
83 | 83 | } |
84 | 84 |
34 | 34 | #include <grp.h> |
35 | 35 | #include <sys/utsname.h> |
36 | 36 | #include <sys/ioctl.h> |
37 | #include <netdb.h> | |
38 | 37 | #include <netinet/if_ether.h> |
39 | 38 | |
40 | 39 | #if defined HOST_OS_FREEBSD || HOST_OS_OSX || HOST_OS_DRAGONFLY |
95 | 94 | must_read(PRIV_UNPRIVILEGED, &rc, sizeof(int)); |
96 | 95 | } |
97 | 96 | |
98 | /* Proxy for gethostbyname */ | |
97 | /* Proxy for gethostname */ | |
99 | 98 | char * |
100 | priv_gethostbyname() | |
99 | priv_gethostname() | |
101 | 100 | { |
102 | 101 | static char *buf = NULL; |
103 | 102 | int rc; |
107 | 106 | must_read(PRIV_UNPRIVILEGED, &rc, sizeof(int)); |
108 | 107 | if ((buf = (char*)realloc(buf, rc+1)) == NULL) |
109 | 108 | fatal("privsep", NULL); |
110 | must_read(PRIV_UNPRIVILEGED, buf, rc+1); | |
109 | must_read(PRIV_UNPRIVILEGED, buf, rc); | |
110 | buf[rc] = '\0'; | |
111 | 111 | return buf; |
112 | 112 | } |
113 | 113 | |
212 | 212 | } |
213 | 213 | |
214 | 214 | static void |
215 | asroot_gethostbyname() | |
215 | asroot_gethostname() | |
216 | 216 | { |
217 | 217 | struct utsname un; |
218 | struct hostent *hp; | |
218 | struct addrinfo hints = { | |
219 | .ai_flags = AI_CANONNAME | |
220 | }; | |
221 | struct addrinfo *res; | |
219 | 222 | int len; |
220 | 223 | if (uname(&un) < 0) |
221 | 224 | fatal("privsep", "failed to get system information"); |
222 | if ((hp = gethostbyname(un.nodename)) == NULL) { | |
225 | if (getaddrinfo(un.nodename, NULL, &hints, &res) != 0) { | |
223 | 226 | log_info("privsep", "unable to get system name"); |
224 | 227 | #ifdef HAVE_RES_INIT |
225 | 228 | res_init(); |
226 | 229 | #endif |
227 | 230 | len = strlen(un.nodename); |
228 | 231 | must_write(PRIV_PRIVILEGED, &len, sizeof(int)); |
229 | must_write(PRIV_PRIVILEGED, un.nodename, len + 1); | |
232 | must_write(PRIV_PRIVILEGED, un.nodename, len); | |
230 | 233 | } else { |
231 | len = strlen(hp->h_name); | |
234 | len = strlen(res->ai_canonname); | |
232 | 235 | must_write(PRIV_PRIVILEGED, &len, sizeof(int)); |
233 | must_write(PRIV_PRIVILEGED, hp->h_name, len + 1); | |
236 | must_write(PRIV_PRIVILEGED, res->ai_canonname, len); | |
237 | freeaddrinfo(res); | |
234 | 238 | } |
235 | 239 | } |
236 | 240 | |
379 | 383 | static struct dispatch_actions actions[] = { |
380 | 384 | {PRIV_PING, asroot_ping}, |
381 | 385 | {PRIV_DELETE_CTL_SOCKET, asroot_ctl_cleanup}, |
382 | {PRIV_GET_HOSTNAME, asroot_gethostbyname}, | |
386 | {PRIV_GET_HOSTNAME, asroot_gethostname}, | |
383 | 387 | #ifdef HOST_OS_LINUX |
384 | 388 | {PRIV_OPEN, asroot_open}, |
385 | 389 | {PRIV_ETHTOOL, asroot_ethtool}, |
407 | 411 | #endif |
408 | 412 | #endif |
409 | 413 | while (!may_read(PRIV_PRIVILEGED, &cmd, sizeof(enum priv_cmd))) { |
414 | log_debug("privsep", "received command %d", cmd); | |
410 | 415 | for (a = actions; a->function != NULL; a++) { |
411 | 416 | if (cmd == a->msg) { |
412 | 417 | a->function(); |
414 | 419 | } |
415 | 420 | } |
416 | 421 | if (a->function == NULL) |
417 | fatal("privsep", "bogus message received"); | |
422 | fatalx("privsep", "bogus message received"); | |
418 | 423 | if (once) break; |
419 | 424 | } |
420 | 425 | } |
436 | 441 | priv_exit_rc_status(int rc, int status) { |
437 | 442 | switch (rc) { |
438 | 443 | case 0: |
439 | log_debug("privsep", "killing child"); | |
444 | /* kill child */ | |
440 | 445 | kill(monitored, SIGTERM); |
441 | log_debug("privsep", "waiting for child %d to terminate", monitored); | |
446 | /* we will receive a sigchld in the future */ | |
442 | 447 | return; |
443 | 448 | case -1: |
444 | log_debug("privsep", "child does not exist anymore"); | |
445 | _exit(1); /* We consider this is an error to be here */ | |
449 | /* child doesn't exist anymore, we consider this is an error to | |
450 | * be here */ | |
451 | _exit(1); | |
446 | 452 | break; |
447 | 453 | default: |
448 | log_debug("privsep", "monitored child has terminated"); | |
454 | /* Monitored child has terminated */ | |
449 | 455 | /* Mimic the exit state of the child */ |
450 | 456 | if (WIFEXITED(status)) { |
451 | log_debug("privsep", "monitored child has terminated with status %d", | |
452 | WEXITSTATUS(status)); | |
457 | /* Normal exit */ | |
453 | 458 | _exit(WEXITSTATUS(status)); |
454 | 459 | } |
455 | 460 | if (WIFSIGNALED(status)) { |
456 | log_debug("privsep", "monitored child has terminated with signal %d", | |
457 | WTERMSIG(status)); | |
461 | /* Terminated with signal */ | |
458 | 462 | signal(WTERMSIG(status), SIG_DFL); |
459 | 463 | raise(WTERMSIG(status)); |
460 | 464 | _exit(1); /* We consider that not being killed is an error. */ |
493 | 497 | if (rc == 0) { |
494 | 498 | while ((rc = waitpid(-1, &status, WNOHANG)) > 0) { |
495 | 499 | if (rc == monitored) priv_exit_rc_status(rc, status); |
496 | else log_debug("privsep", "unrelated process %d has died", | |
497 | rc); | |
498 | 500 | } |
499 | 501 | return; |
500 | 502 | } |
587 | 589 | int pair[2]; |
588 | 590 | |
589 | 591 | /* Create socket pair */ |
590 | if (socketpair(AF_UNIX, SOCK_DGRAM, PF_UNSPEC, pair) < 0) | |
591 | fatal("privsep", "unable to create socket pair for privilege separation"); | |
592 | if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pair) < 0) { | |
593 | fatal("privsep", | |
594 | "unable to create socket pair for privilege separation"); | |
595 | } | |
592 | 596 | |
593 | 597 | priv_unprivileged_fd(pair[0]); |
594 | 598 | priv_privileged_fd(pair[1]); |
25 | 25 | { |
26 | 26 | unprivileged = fd; |
27 | 27 | } |
28 | static int | |
28 | int | |
29 | 29 | priv_fd(enum priv_context ctx) |
30 | 30 | { |
31 | 31 | switch (ctx) { |
0 | AM_CFLAGS = -I $(top_srcdir)/include | |
0 | AM_CFLAGS = -I $(top_srcdir)/include $(LLDP_CFLAGS) | |
1 | AM_CPPFLAGS = $(LLDP_CPPFLAGS) | |
2 | AM_LDFLAGS = $(LLDP_LDFLAGS) | |
1 | 3 | |
2 | 4 | lib_LTLIBRARIES = liblldpctl.la |
3 | 5 | include_HEADERS = lldpctl.h |
7 | 9 | |
8 | 10 | liblldpctl_la_SOURCES = lldpctl.h private.h errors.c connection.c atom.c atom-private.c |
9 | 11 | liblldpctl_la_LIBADD = $(top_builddir)/src/libcommon-daemon-lib.la libfixedpoint.la |
10 | liblldpctl_la_LDFLAGS = -export-symbols-regex '^lldpctl_' -version-info 7:0:3 | |
12 | liblldpctl_la_LDFLAGS = $(AM_LDFLAGS) -export-symbols-regex '^lldpctl_' -version-info 9:0:5 | |
11 | 13 | |
12 | 14 | # -version-info format is `current`:`revision`:`age`. For more details, see: |
13 | 15 | # http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 |
14 | 16 | |
15 | pkgconfigdir = $(libdir)/pkgconfig | |
16 | 17 | pkgconfig_DATA = lldpctl.pc |
17 | 18 | |
18 | 19 | TEMPLATES = lldpctl.pc |
290 | 290 | LIPO = @LIPO@ |
291 | 291 | LLDPD_CTL_SOCKET = @LLDPD_CTL_SOCKET@ |
292 | 292 | LLDPD_PID_FILE = @LLDPD_PID_FILE@ |
293 | LLDP_CFLAGS = @LLDP_CFLAGS@ | |
294 | LLDP_CPPFLAGS = @LLDP_CPPFLAGS@ | |
295 | LLDP_LDFLAGS = @LLDP_LDFLAGS@ | |
293 | 296 | LN_S = @LN_S@ |
294 | 297 | LTLIBOBJS = @LTLIBOBJS@ |
295 | 298 | MAINT = @MAINT@ |
376 | 379 | mkdir_p = @mkdir_p@ |
377 | 380 | oldincludedir = @oldincludedir@ |
378 | 381 | pdfdir = @pdfdir@ |
382 | pkgconfigdir = @pkgconfigdir@ | |
379 | 383 | prefix = @prefix@ |
380 | 384 | program_transform_name = @program_transform_name@ |
381 | 385 | psdir = @psdir@ |
391 | 395 | top_build_prefix = @top_build_prefix@ |
392 | 396 | top_builddir = @top_builddir@ |
393 | 397 | top_srcdir = @top_srcdir@ |
394 | AM_CFLAGS = -I $(top_srcdir)/include | |
398 | AM_CFLAGS = -I $(top_srcdir)/include $(LLDP_CFLAGS) | |
399 | AM_CPPFLAGS = $(LLDP_CPPFLAGS) | |
400 | AM_LDFLAGS = $(LLDP_LDFLAGS) | |
395 | 401 | lib_LTLIBRARIES = liblldpctl.la |
396 | 402 | include_HEADERS = lldpctl.h |
397 | 403 | noinst_LTLIBRARIES = libfixedpoint.la |
398 | 404 | libfixedpoint_la_SOURCES = fixedpoint.h fixedpoint.c |
399 | 405 | liblldpctl_la_SOURCES = lldpctl.h private.h errors.c connection.c atom.c atom-private.c |
400 | 406 | liblldpctl_la_LIBADD = $(top_builddir)/src/libcommon-daemon-lib.la libfixedpoint.la |
401 | liblldpctl_la_LDFLAGS = -export-symbols-regex '^lldpctl_' -version-info 7:0:3 | |
407 | liblldpctl_la_LDFLAGS = $(AM_LDFLAGS) -export-symbols-regex '^lldpctl_' -version-info 9:0:5 | |
402 | 408 | |
403 | 409 | # -version-info format is `current`:`revision`:`age`. For more details, see: |
404 | 410 | # http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 |
405 | pkgconfigdir = $(libdir)/pkgconfig | |
406 | 411 | pkgconfig_DATA = lldpctl.pc |
407 | 412 | TEMPLATES = lldpctl.pc |
408 | 413 | EXTRA_DIST = lldpctl.pc.in |
409 | 414 | CLEANFILES = $(TEMPLATES) |
410 | 415 | edit = $(SED) \ |
411 | 416 | -e 's|@bindir[@]|$(bindir)|g' \ |
417 | -e 's|@sbindir[@]|$(sbindir)|g' \ | |
412 | 418 | -e 's|@pkgdatadir[@]|$(pkgdatadir)|g' \ |
413 | 419 | -e 's|@libdir[@]|$(libdir)|g' \ |
414 | 420 | -e 's|@includedir[@]|$(includedir)|g' \ |
805 | 811 | lldpctl.pc: lldpctl.pc.in |
806 | 812 | |
807 | 813 | $(TEMPLATES): Makefile |
808 | $(AM_V_GEN)$(edit) $(srcdir)/$@.in > $@.tmp | |
809 | mv $@.tmp $@ | |
814 | $(AM_V_GEN)$(edit) $(srcdir)/$@.in > $@.tmp && mv $@.tmp $@ | |
810 | 815 | |
811 | 816 | # Tell versions [3.59,3.63) of GNU make to not export all variables. |
812 | 817 | # Otherwise a system limit (for SysV at least) may be exceeded. |
148 | 148 | { LLDP_DOT3_POWER_SOURCE_PRIMARY, "Primary power source" }, |
149 | 149 | { 0, NULL } |
150 | 150 | }; |
151 | ||
151 | #endif | |
152 | ||
153 | #if defined ENABLE_DOT3 || defined ENABLE_LLDPMED | |
152 | 154 | static lldpctl_map_t port_dot3_power_priority_map[] = { |
153 | 155 | { 0, "unknown" }, |
154 | 156 | { LLDP_MED_POW_PRIO_CRITICAL, "critical" }, |
270 | 272 | static lldpctl_map_t lldp_portid_map[] = { |
271 | 273 | { LLDP_PORTID_SUBTYPE_IFNAME, "ifname"}, |
272 | 274 | { LLDP_PORTID_SUBTYPE_LLADDR, "macaddress"}, |
275 | { LLDP_PORTID_SUBTYPE_LOCAL, "local"}, | |
273 | 276 | { LLDP_PORTID_SUBTYPE_UNKNOWN, NULL}, |
274 | 277 | }; |
275 | 278 | |
292 | 295 | static int |
293 | 296 | map_reverse_lookup(lldpctl_map_t *list, const char *string) |
294 | 297 | { |
295 | unsigned int i; | |
296 | ||
297 | for (i = 0; list[i].string != NULL; i++) { | |
298 | if (!string) return -1; | |
299 | ||
300 | for (unsigned int i = 0; list[i].string != NULL; i++) { | |
298 | 301 | if (!strcasecmp(list[i].string, string)) |
299 | 302 | return list[i].value; |
300 | 303 | } |
391 | 394 | return res?res:""; |
392 | 395 | } |
393 | 396 | |
397 | static struct _lldpctl_atom_config_t* | |
398 | __lldpctl_atom_set_str_config(struct _lldpctl_atom_config_t *c, | |
399 | char **local, char **global, | |
400 | const char *value) { | |
401 | if (value) { | |
402 | char *aval = NULL; | |
403 | size_t len = strlen(value) + 1; | |
404 | aval = _lldpctl_alloc_in_atom((lldpctl_atom_t *)c, len); | |
405 | if (!aval) return NULL; | |
406 | memcpy(aval, value, len); | |
407 | *local = aval; | |
408 | free(*global); *global = strdup(aval); | |
409 | } else { | |
410 | free(*global); | |
411 | *local = *global = NULL; | |
412 | } | |
413 | return c; | |
414 | } | |
415 | ||
394 | 416 | static lldpctl_atom_t* |
395 | 417 | _lldpctl_atom_set_str_config(lldpctl_atom_t *atom, lldpctl_key_t key, |
396 | 418 | const char *value) |
397 | 419 | { |
398 | 420 | struct _lldpctl_atom_config_t *c = |
399 | 421 | (struct _lldpctl_atom_config_t *)atom; |
400 | struct lldpd_config config = {}; | |
401 | char *iface_pattern = NULL, *mgmt_pattern = NULL; | |
402 | char *description = NULL; | |
422 | struct lldpd_config config; | |
423 | memcpy(&config, c->config, sizeof(struct lldpd_config)); | |
403 | 424 | char *canary = NULL; |
404 | int rc, len; | |
405 | ||
406 | len = strlen(value) + 1; | |
425 | int rc; | |
407 | 426 | |
408 | 427 | switch (key) { |
409 | 428 | case lldpctl_k_config_iface_pattern: |
410 | iface_pattern = _lldpctl_alloc_in_atom(atom, strlen(value) + 1); | |
411 | if (!iface_pattern) | |
429 | if (!__lldpctl_atom_set_str_config(c, | |
430 | &config.c_iface_pattern, &c->config->c_iface_pattern, | |
431 | value)) | |
412 | 432 | return NULL; |
413 | memcpy(iface_pattern, value, len); | |
414 | config.c_iface_pattern = iface_pattern; | |
415 | free(c->config->c_iface_pattern); | |
416 | c->config->c_iface_pattern = strdup(iface_pattern); | |
417 | 433 | break; |
418 | 434 | case lldpctl_k_config_mgmt_pattern: |
419 | mgmt_pattern = _lldpctl_alloc_in_atom(atom, strlen(value) + 1); | |
420 | if (!mgmt_pattern) | |
435 | if (!__lldpctl_atom_set_str_config(c, | |
436 | &config.c_mgmt_pattern, &c->config->c_mgmt_pattern, | |
437 | value)) | |
421 | 438 | return NULL; |
422 | memcpy(mgmt_pattern, value, len); | |
423 | config.c_mgmt_pattern = mgmt_pattern; | |
424 | free(c->config->c_mgmt_pattern); | |
425 | c->config->c_mgmt_pattern = strdup(mgmt_pattern); | |
426 | 439 | break; |
427 | 440 | case lldpctl_k_config_description: |
428 | description = _lldpctl_alloc_in_atom(atom, strlen(value) + 1); | |
429 | if (!description) | |
441 | if (!__lldpctl_atom_set_str_config(c, | |
442 | &config.c_description, &c->config->c_description, | |
443 | value)) | |
430 | 444 | return NULL; |
431 | memcpy(description, value, len); | |
432 | config.c_description = description; | |
433 | free(c->config->c_description); | |
434 | c->config->c_description = strdup(description); | |
435 | 445 | break; |
436 | 446 | case lldpctl_k_config_platform: |
437 | description = _lldpctl_alloc_in_atom(atom, strlen(value) + 1); | |
438 | if (!description) | |
447 | if (!__lldpctl_atom_set_str_config(c, | |
448 | &config.c_platform, &c->config->c_platform, | |
449 | value)) | |
439 | 450 | return NULL; |
440 | memcpy(description, value, len); | |
441 | config.c_platform = description; | |
442 | free(c->config->c_platform); | |
443 | c->config->c_description = strdup(description); | |
444 | 451 | break; |
445 | 452 | case lldpctl_k_config_hostname: |
446 | description = _lldpctl_alloc_in_atom(atom, strlen(value) + 1); | |
447 | if (!description) | |
453 | if (!__lldpctl_atom_set_str_config(c, | |
454 | &config.c_hostname, &c->config->c_hostname, | |
455 | value)) | |
448 | 456 | return NULL; |
449 | memcpy(description, value, len); | |
450 | config.c_hostname = description; | |
451 | free(c->config->c_hostname); | |
452 | c->config->c_hostname = strdup(description); | |
453 | 457 | break; |
454 | 458 | default: |
455 | 459 | SET_ERROR(atom->conn, LLDPCTL_ERR_NOT_EXIST); |
456 | 460 | return NULL; |
457 | 461 | } |
458 | 462 | |
459 | if (asprintf(&canary, "%d%s", key, value) == -1) { | |
463 | if (asprintf(&canary, "%d%s", key, value?value:"(NULL)") == -1) { | |
460 | 464 | SET_ERROR(atom->conn, LLDPCTL_ERR_NOMEM); |
461 | 465 | return NULL; |
462 | 466 | } |
467 | 471 | NULL, NULL); |
468 | 472 | free(canary); |
469 | 473 | if (rc == 0) return atom; |
474 | ||
475 | #undef SET_STR | |
470 | 476 | |
471 | 477 | return NULL; |
472 | 478 | } |
512 | 518 | char *canary = NULL; |
513 | 519 | struct _lldpctl_atom_config_t *c = |
514 | 520 | (struct _lldpctl_atom_config_t *)atom; |
515 | struct lldpd_config config = {}; | |
521 | struct lldpd_config config; | |
522 | memcpy(&config, c->config, sizeof(struct lldpd_config)); | |
516 | 523 | |
517 | 524 | switch (key) { |
518 | 525 | case lldpctl_k_config_paused: |
530 | 537 | break; |
531 | 538 | #ifdef ENABLE_LLDPMED |
532 | 539 | case lldpctl_k_config_fast_start_enabled: |
533 | config.c_enable_fast_start = value?1:2; | |
534 | c->config->c_enable_fast_start = value; | |
540 | config.c_enable_fast_start = c->config->c_enable_fast_start = value; | |
535 | 541 | break; |
536 | 542 | case lldpctl_k_config_fast_start_interval: |
537 | 543 | config.c_tx_fast_interval = c->config->c_tx_fast_interval = value; |
838 | 844 | } |
839 | 845 | |
840 | 846 | switch (key) { |
847 | case lldpctl_k_port_id: | |
848 | set.local_id = p->port->p_id; | |
849 | break; | |
850 | case lldpctl_k_port_descr: | |
851 | set.local_descr = p->port->p_descr; | |
852 | break; | |
841 | 853 | #ifdef ENABLE_DOT3 |
842 | 854 | case lldpctl_k_port_dot3_power: |
843 | 855 | if (value->type != atom_dot3_power) { |
1017 | 1029 | SET_ERROR(atom->conn, LLDPCTL_ERR_NOT_EXIST); |
1018 | 1030 | return NULL; |
1019 | 1031 | } |
1032 | } | |
1033 | ||
1034 | static lldpctl_atom_t* | |
1035 | _lldpctl_atom_set_str_port(lldpctl_atom_t *atom, lldpctl_key_t key, | |
1036 | const char *value) | |
1037 | { | |
1038 | struct _lldpctl_atom_port_t *p = | |
1039 | (struct _lldpctl_atom_port_t *)atom; | |
1040 | struct lldpd_port *port = p->port; | |
1041 | ||
1042 | if (!value || !strlen(value)) | |
1043 | return NULL; | |
1044 | ||
1045 | switch (key) { | |
1046 | case lldpctl_k_port_id: | |
1047 | free(port->p_id); | |
1048 | port->p_id = strdup(value); | |
1049 | port->p_id_len = strlen(value); | |
1050 | break; | |
1051 | case lldpctl_k_port_descr: | |
1052 | free(port->p_descr); | |
1053 | port->p_descr = strdup(value); | |
1054 | break; | |
1055 | default: | |
1056 | SET_ERROR(atom->conn, LLDPCTL_ERR_NOT_EXIST); | |
1057 | return NULL; | |
1058 | } | |
1059 | ||
1060 | return _lldpctl_atom_set_atom_port(atom, key, NULL); | |
1020 | 1061 | } |
1021 | 1062 | |
1022 | 1063 | static long int |
1899 | 1940 | case 0: /* Disabling */ |
1900 | 1941 | case LLDP_MED_LOCFORMAT_COORD: |
1901 | 1942 | mloc->location->format = value; |
1902 | if (mloc->location->data) free(mloc->location->data); | |
1943 | free(mloc->location->data); | |
1903 | 1944 | mloc->location->data = calloc(1, 16); |
1904 | 1945 | if (mloc->location->data == NULL) { |
1905 | 1946 | mloc->location->data_len = 0; |
1910 | 1951 | return atom; |
1911 | 1952 | case LLDP_MED_LOCFORMAT_CIVIC: |
1912 | 1953 | mloc->location->format = value; |
1913 | if (mloc->location->data) free(mloc->location->data); | |
1954 | free(mloc->location->data); | |
1914 | 1955 | mloc->location->data = calloc(1, 4); |
1915 | 1956 | if (mloc->location->data == NULL) { |
1916 | 1957 | mloc->location->data_len = 0; |
1925 | 1966 | return atom; |
1926 | 1967 | case LLDP_MED_LOCFORMAT_ELIN: |
1927 | 1968 | mloc->location->format = value; |
1928 | if (mloc->location->data) free(mloc->location->data); | |
1969 | free(mloc->location->data); | |
1929 | 1970 | mloc->location->data = NULL; |
1930 | 1971 | mloc->location->data_len = 0; |
1931 | 1972 | return atom; |
2053 | 2094 | struct _lldpctl_atom_med_location_t *mloc = |
2054 | 2095 | (struct _lldpctl_atom_med_location_t *)atom; |
2055 | 2096 | struct fp_number fp; |
2056 | char *end; | |
2097 | char *end = NULL; | |
2057 | 2098 | |
2058 | 2099 | /* Only local port can be modified */ |
2059 | 2100 | if (mloc->parent->hardware == NULL) { |
2065 | 2106 | case lldpctl_k_med_location_latitude: |
2066 | 2107 | if (mloc->location->format != LLDP_MED_LOCFORMAT_COORD) goto bad; |
2067 | 2108 | if (mloc->location->data == NULL || mloc->location->data_len != 16) goto bad; |
2068 | fp = fp_strtofp(value, &end, 9, 25); | |
2109 | if (value) fp = fp_strtofp(value, &end, 9, 25); | |
2069 | 2110 | if (!end) goto bad; |
2070 | 2111 | if (end && *end != '\0') { |
2071 | 2112 | if (*(end+1) != '\0') goto bad; |
2077 | 2118 | case lldpctl_k_med_location_longitude: |
2078 | 2119 | if (mloc->location->format != LLDP_MED_LOCFORMAT_COORD) goto bad; |
2079 | 2120 | if (mloc->location->data == NULL || mloc->location->data_len != 16) goto bad; |
2080 | fp = fp_strtofp(value, &end, 9, 25); | |
2121 | if (value) fp = fp_strtofp(value, &end, 9, 25); | |
2081 | 2122 | if (!end) goto bad; |
2082 | 2123 | if (end && *end != '\0') { |
2083 | 2124 | if (*(end+1) != '\0') goto bad; |
2089 | 2130 | case lldpctl_k_med_location_altitude: |
2090 | 2131 | if (mloc->location->format != LLDP_MED_LOCFORMAT_COORD) goto bad; |
2091 | 2132 | if (mloc->location->data == NULL || mloc->location->data_len != 16) goto bad; |
2092 | fp = fp_strtofp(value, &end, 22, 8); | |
2133 | if (value) fp = fp_strtofp(value, &end, 22, 8); | |
2093 | 2134 | if (!end || *end != '\0') goto bad; |
2094 | 2135 | fp_fptobuf(fp, (unsigned char*)mloc->location->data, 84); |
2095 | 2136 | return atom; |
2096 | 2137 | case lldpctl_k_med_location_altitude_unit: |
2138 | if (!value) goto bad; | |
2097 | 2139 | if (mloc->location->format != LLDP_MED_LOCFORMAT_COORD) goto bad; |
2098 | 2140 | if (mloc->location->data == NULL || mloc->location->data_len != 16) goto bad; |
2099 | 2141 | if (!strcmp(value, "m")) |
2104 | 2146 | return _lldpctl_atom_set_int_med_location(atom, key, |
2105 | 2147 | LLDP_MED_LOCATION_ALTITUDE_UNIT_FLOOR); |
2106 | 2148 | goto bad; |
2149 | break; | |
2107 | 2150 | case lldpctl_k_med_location_geoid: |
2108 | 2151 | return _lldpctl_atom_set_int_med_location(atom, key, |
2109 | 2152 | map_reverse_lookup(port_med_geoid_map, value)); |
2110 | 2153 | case lldpctl_k_med_location_country: |
2111 | 2154 | if (mloc->location->format != LLDP_MED_LOCFORMAT_CIVIC) goto bad; |
2112 | 2155 | if (mloc->location->data == NULL || mloc->location->data_len < 3) goto bad; |
2113 | if (strlen(value) != 2) goto bad; | |
2156 | if (!value || strlen(value) != 2) goto bad; | |
2114 | 2157 | memcpy(mloc->location->data + 2, value, 2); |
2115 | 2158 | return atom; |
2116 | 2159 | case lldpctl_k_med_location_elin: |
2160 | if (!value) goto bad; | |
2117 | 2161 | if (mloc->location->format != LLDP_MED_LOCFORMAT_ELIN) goto bad; |
2118 | if (mloc->location->data) free(mloc->location->data); | |
2162 | free(mloc->location->data); | |
2119 | 2163 | mloc->location->data = calloc(1, strlen(value)); |
2120 | 2164 | if (mloc->location->data == NULL) { |
2121 | 2165 | mloc->location->data_len = 0; |
2362 | 2406 | |
2363 | 2407 | switch (key) { |
2364 | 2408 | case lldpctl_k_med_civicaddress_value: |
2409 | if (!value) goto bad; | |
2365 | 2410 | len = strlen(value) + 1; |
2366 | 2411 | if (len > 251) goto bad; |
2367 | 2412 | el->value = _lldpctl_alloc_in_atom(atom, len); |
2583 | 2628 | .get = _lldpctl_atom_get_atom_port, |
2584 | 2629 | .set = _lldpctl_atom_set_atom_port, |
2585 | 2630 | .get_str = _lldpctl_atom_get_str_port, |
2631 | .set_str = _lldpctl_atom_set_str_port, | |
2586 | 2632 | .get_int = _lldpctl_atom_get_int_port, |
2587 | 2633 | .get_buffer = _lldpctl_atom_get_buf_port }, |
2588 | 2634 | { atom_mgmts_list, sizeof(struct _lldpctl_atom_mgmts_list_t), |
135 | 135 | { |
136 | 136 | lldpctl_atom_t *result = NULL; |
137 | 137 | char *end; |
138 | long int converted; | |
139 | int isint; | |
138 | long int converted = 0; | |
139 | int isint = 0; | |
140 | 140 | int bad = 0; |
141 | 141 | |
142 | 142 | if (atom == NULL) return NULL; |
151 | 151 | bad = bad || (lldpctl_last_error(atom->conn) == LLDPCTL_ERR_BAD_VALUE); |
152 | 152 | } |
153 | 153 | |
154 | converted = strtol(value, &end, 0); | |
155 | isint = (end != value && *end == '\0'); | |
154 | if (value) { | |
155 | converted = strtol(value, &end, 0); | |
156 | isint = (end != value && *end == '\0'); | |
157 | } | |
156 | 158 | |
157 | 159 | RESET_ERROR(atom->conn); |
158 | 160 | if (atom->set_int != NULL && isint) { |
166 | 168 | |
167 | 169 | RESET_ERROR(atom->conn); |
168 | 170 | if (atom->set_buffer != NULL) { |
169 | result = atom->set_buffer(atom, key, (u_int8_t*)value, strlen(value)); | |
171 | result = atom->set_buffer(atom, key, (u_int8_t*)value, value?strlen(value):0); | |
170 | 172 | if (result) return result; |
171 | 173 | if (lldpctl_last_error(atom->conn) != LLDPCTL_ERR_NOT_EXIST && |
172 | 174 | lldpctl_last_error(atom->conn) != LLDPCTL_ERR_BAD_VALUE) |
574 | 574 | * LLDPCTL_ERR_WOULDBLOCK, you need to try again later. Usually, changes are |
575 | 575 | * transmitted immediatly. The exception are changes that need to be grouped to |
576 | 576 | * be consistent, like a LLDP MED location. When a change is transmitted |
577 | * immediatly, it is marked with (O). | |
577 | * immediatly, it is marked with (O). @c lldpctl_atom_set_str() may accept a @c | |
578 | * NULL value. This case is marked with (N) and usually reset the item to the | |
579 | * default value or no value. | |
578 | 580 | * |
579 | 581 | * Some values may also be created. They are flagged with (C). This only applies |
580 | 582 | * to elements that can be iterated (L) and written (W). The element created |
596 | 598 | typedef enum { |
597 | 599 | lldpctl_k_config_tx_interval, /**< `(I,WO)` Transmit interval. When set to -1, it is meant to transmit now. */ |
598 | 600 | lldpctl_k_config_receiveonly, /**< `(I)` Receive only mode */ |
599 | lldpctl_k_config_mgmt_pattern, /**< `(S)` Pattern to choose the management address */ | |
600 | lldpctl_k_config_iface_pattern, /**< `(S,WO)` Pattern of enabled interfaces */ | |
601 | lldpctl_k_config_mgmt_pattern, /**< `(S,WON)` Pattern to choose the management address */ | |
602 | lldpctl_k_config_iface_pattern, /**< `(S,WON)` Pattern of enabled interfaces */ | |
601 | 603 | lldpctl_k_config_cid_pattern, /**< `(S)` Interface pattern to choose the chassis ID */ |
602 | lldpctl_k_config_description, /**< `(S,WO)` Chassis description overridden */ | |
603 | lldpctl_k_config_platform, /**< `(S,WO)` Platform description overridden (CDP) */ | |
604 | lldpctl_k_config_hostname, /**< `(S,WO)` System name overridden */ | |
604 | lldpctl_k_config_description, /**< `(S,WON)` Chassis description overridden */ | |
605 | lldpctl_k_config_platform, /**< `(S,WON)` Platform description overridden (CDP) */ | |
606 | lldpctl_k_config_hostname, /**< `(S,WON)` System name overridden */ | |
605 | 607 | lldpctl_k_config_advertise_version, /**< `(I)` Advertise version */ |
606 | 608 | lldpctl_k_config_lldpmed_noinventory, /**< `(I)` Disable LLDP-MED inventory */ |
607 | 609 | lldpctl_k_config_paused, /**< `(I)` lldpd is paused */ |
623 | 625 | lldpctl_k_port_protocol, /**< `(IS)` The protocol that was used to retrieve this information. */ |
624 | 626 | lldpctl_k_port_age, /**< `(I)` Age of information, seconds from epoch. */ |
625 | 627 | lldpctl_k_port_id_subtype, /**< `(IS)` The subtype ID of this port. */ |
626 | lldpctl_k_port_id, /**< `(BS)` The ID of this port. */ | |
627 | lldpctl_k_port_descr, /**< `(S)` The description of this port. */ | |
628 | lldpctl_k_port_id, /**< `(BS,WO)` The ID of this port. */ | |
629 | lldpctl_k_port_descr, /**< `(S,WO)` The description of this port. */ | |
628 | 630 | lldpctl_k_port_hidden, /**< `(I)` Is this port hidden (or should it be displayed?)? */ |
629 | 631 | |
630 | 632 | lldpctl_k_port_dot3_mfs = 1300, /**< `(I)` MFS */ |
1 | 1 | Description: Library to interface with lldpd, a 802.1AB daemon |
2 | 2 | Version: @VERSION@ |
3 | 3 | URL: @PACKAGE_URL@ |
4 | Libs: -L${libdir} -llldpctl | |
5 | Cflags: -I${includedir} | |
4 | Libs: -L@libdir@ -llldpctl | |
5 | Cflags: -I@includedir@ |
26 | 26 | struct lldpd_mgmt *mgmt, *mgmt_next; |
27 | 27 | |
28 | 28 | log_debug("alloc", "cleanup management addresses for chassis %s", |
29 | chassis->c_name ? chassis->c_name : "(unknwon)"); | |
29 | chassis->c_name ? chassis->c_name : "(unknown)"); | |
30 | 30 | |
31 | 31 | for (mgmt = TAILQ_FIRST(&chassis->c_mgmt); |
32 | 32 | mgmt != NULL; |
42 | 42 | { |
43 | 43 | lldpd_chassis_mgmt_cleanup(chassis); |
44 | 44 | log_debug("alloc", "cleanup chassis %s", |
45 | chassis->c_name ? chassis->c_name : "(unknwon)"); | |
45 | chassis->c_name ? chassis->c_name : "(unknown)"); | |
46 | 46 | #ifdef ENABLE_LLDPMED |
47 | 47 | free(chassis->c_med_hw); |
48 | 48 | free(chassis->c_med_sw); |
160 | 160 | #endif |
161 | 161 | /* will set these to NULL so we don't free wrong memory */ |
162 | 162 | |
163 | free(port->p_id); | |
164 | port->p_id = NULL; | |
165 | free(port->p_descr); | |
166 | port->p_descr = NULL; | |
167 | 163 | if (all) { |
164 | free(port->p_id); | |
165 | port->p_id = NULL; | |
166 | free(port->p_descr); | |
167 | port->p_descr = NULL; | |
168 | 168 | free(port->p_lastframe); |
169 | 169 | if (port->p_chassis) { /* chassis may not have been attributed, yet */ |
170 | 170 | port->p_chassis->c_refcount--; |
224 | 224 | u_int8_t p_hidden_in:1; /* Considered as hidden for reception */ |
225 | 225 | u_int8_t p_hidden_out:2; /* Considered as hidden for emission */ |
226 | 226 | /* Important: all fields that should be ignored to check if a port has |
227 | * been changed should be before p_id_subtype. Check | |
228 | * `lldpd_reset_timer()`. */ | |
227 | * been changed should be before this mark. */ | |
228 | #define LLDPD_PORT_START_MARKER (offsetof(struct lldpd_port, p_id_subtype)) | |
229 | 229 | u_int8_t p_id_subtype; |
230 | 230 | char *p_id; |
231 | 231 | int p_id_len; |
274 | 274 | /* Used to modify some port related settings */ |
275 | 275 | struct lldpd_port_set { |
276 | 276 | char *ifname; |
277 | char *local_id; | |
278 | char *local_descr; | |
277 | 279 | #ifdef ENABLE_LLDPMED |
278 | 280 | struct lldpd_med_policy *med_policy; |
279 | 281 | struct lldpd_med_loc *med_location; |
285 | 287 | }; |
286 | 288 | MARSHAL_BEGIN(lldpd_port_set) |
287 | 289 | MARSHAL_STR(lldpd_port_set, ifname) |
290 | MARSHAL_STR(lldpd_port_set, local_id) | |
291 | MARSHAL_STR(lldpd_port_set, local_descr) | |
288 | 292 | #ifdef ENABLE_LLDPMED |
289 | 293 | MARSHAL_POINTER(lldpd_port_set, lldpd_med_policy, med_policy) |
290 | 294 | MARSHAL_POINTER(lldpd_port_set, lldpd_med_loc, med_location) |
397 | 401 | u_int64_t h_delete_cnt; |
398 | 402 | u_int64_t h_drop_cnt; |
399 | 403 | |
400 | u_int16_t h_lport_cksum; /* Checksum on local port to see if there is a change */ | |
404 | /* Previous values of different stuff. */ | |
405 | /* Backup of the previous local port. Used to check if there was a | |
406 | * change to send an immediate update. All those are not marshalled to | |
407 | * the client. */ | |
408 | void *h_lport_previous; | |
409 | ssize_t h_lport_previous_len; | |
410 | /* Backup of the previous chassis ID. Used to check if there was a | |
411 | * change and send an LLDP shutdown. */ | |
412 | u_int8_t h_lchassis_previous_id_subtype; | |
413 | char *h_lchassis_previous_id; | |
414 | int h_lchassis_previous_id_len; | |
415 | /* Backup of the previous port ID. Used to check if there was a change | |
416 | * and send an LLDP shutdown. */ | |
417 | u_int8_t h_lport_previous_id_subtype; | |
418 | char *h_lport_previous_id; | |
419 | int h_lport_previous_id_len; | |
420 | ||
401 | 421 | struct lldpd_port h_lport; /* Port attached to this hardware port */ |
402 | 422 | TAILQ_HEAD(, lldpd_port) h_rports; /* Remote ports */ |
403 | 423 | |
411 | 431 | MARSHAL_IGNORE(lldpd_hardware, h_ops) |
412 | 432 | MARSHAL_IGNORE(lldpd_hardware, h_data) |
413 | 433 | MARSHAL_IGNORE(lldpd_hardware, h_cfg) |
434 | MARSHAL_IGNORE(lldpd_hardware, h_lport_previous) | |
435 | MARSHAL_IGNORE(lldpd_hardware, h_lport_previous_len) | |
436 | MARSHAL_IGNORE(lldpd_hardware, h_lchassis_previous_id_subtype) | |
437 | MARSHAL_IGNORE(lldpd_hardware, h_lchassis_previous_id) | |
438 | MARSHAL_IGNORE(lldpd_hardware, h_lchassis_previous_id_len) | |
439 | MARSHAL_IGNORE(lldpd_hardware, h_lport_previous_id_subtype) | |
440 | MARSHAL_IGNORE(lldpd_hardware, h_lport_previous_id) | |
441 | MARSHAL_IGNORE(lldpd_hardware, h_lport_previous_id_len) | |
414 | 442 | MARSHAL_SUBSTRUCT(lldpd_hardware, lldpd_port, h_lport) |
415 | 443 | MARSHAL_SUBTQ(lldpd_hardware, lldpd_port, h_rports) |
416 | 444 | MARSHAL_END(lldpd_hardware); |
243 | 243 | } |
244 | 244 | |
245 | 245 | void |
246 | fatalx(const char *emsg) | |
246 | fatalx(const char *token, const char *emsg) | |
247 | 247 | { |
248 | 248 | errno = 0; |
249 | fatal(NULL, emsg); | |
250 | } | |
249 | fatal(token, emsg); | |
250 | } |
24 | 24 | void log_info(const char *, const char *, ...) __attribute__ ((format (printf, 2, 3))); |
25 | 25 | void log_debug(const char *, const char *, ...) __attribute__ ((format (printf, 2, 3))); |
26 | 26 | void fatal(const char*, const char *) __attribute__((__noreturn__)); |
27 | void fatalx(const char *) __attribute__((__noreturn__)); | |
27 | void fatalx(const char *, const char *) __attribute__((__noreturn__)); | |
28 | 28 | |
29 | 29 | void log_register(void (*cb)(int, const char*)); |
30 | 30 | void log_accept(const char *); |
0 | AM_CFLAGS = -I $(top_srcdir)/include | |
0 | AM_CFLAGS = -I $(top_srcdir)/include $(LLDP_CFLAGS) | |
1 | AM_CPPFLAGS = $(LLDP_CPPFLAGS) | |
2 | AM_LDFLAGS = $(LLDP_LDFLAGS) | |
1 | 3 | |
2 | 4 | if HAVE_CHECK |
3 | 5 | |
6 | 8 | LDADD = $(top_builddir)/src/daemon/liblldpd.la @CHECK_LIBS@ @LIBEVENT_LDFLAGS@ |
7 | 9 | |
8 | 10 | check_marshal_SOURCES = check_marshal.c \ |
9 | $(top_srcdir)/src/marshal.h | |
11 | $(top_srcdir)/src/marshal.h \ | |
12 | check-compat.h | |
10 | 13 | |
11 | 14 | check_pattern_SOURCES = check_pattern.c \ |
12 | 15 | $(top_srcdir)/src/daemon/lldpd.h |
13 | 16 | |
14 | 17 | check_lldp_SOURCES = check_lldp.c \ |
15 | 18 | $(top_srcdir)/src/daemon/lldpd.h \ |
16 | common.h common.c | |
19 | common.h common.c check-compat.h | |
17 | 20 | |
18 | 21 | check_cdp_SOURCES = check_cdp.c \ |
19 | 22 | $(top_srcdir)/src/daemon/lldpd.h \ |
20 | common.h common.c | |
23 | common.h common.c check-compat.h | |
21 | 24 | |
22 | 25 | check_sonmp_SOURCES = check_sonmp.c \ |
23 | 26 | $(top_srcdir)/src/daemon/lldpd.h \ |
24 | common.h common.c | |
27 | common.h common.c check-compat.h | |
25 | 28 | |
26 | 29 | check_edp_SOURCES = check_edp.c \ |
27 | 30 | $(top_srcdir)/src/daemon/lldpd.h \ |
28 | common.h common.c | |
31 | common.h common.c check-compat.h | |
29 | 32 | |
30 | 33 | check_fixedpoint_SOURCES = check_fixedpoint.c |
31 | 34 | check_fixedpoint_LDADD = $(top_builddir)/src/lib/libfixedpoint.la $(LDADD) |
115 | 115 | @HAVE_CHECK_TRUE@ check_edp$(EXEEXT) check_fixedpoint$(EXEEXT) \ |
116 | 116 | @HAVE_CHECK_TRUE@ $(am__EXEEXT_1) |
117 | 117 | am__check_cdp_SOURCES_DIST = check_cdp.c \ |
118 | $(top_srcdir)/src/daemon/lldpd.h common.h common.c | |
118 | $(top_srcdir)/src/daemon/lldpd.h common.h common.c \ | |
119 | check-compat.h | |
119 | 120 | @HAVE_CHECK_TRUE@am_check_cdp_OBJECTS = check_cdp.$(OBJEXT) \ |
120 | 121 | @HAVE_CHECK_TRUE@ common.$(OBJEXT) |
121 | 122 | check_cdp_OBJECTS = $(am_check_cdp_OBJECTS) |
129 | 130 | am__v_lt_0 = --silent |
130 | 131 | am__v_lt_1 = |
131 | 132 | am__check_edp_SOURCES_DIST = check_edp.c \ |
132 | $(top_srcdir)/src/daemon/lldpd.h common.h common.c | |
133 | $(top_srcdir)/src/daemon/lldpd.h common.h common.c \ | |
134 | check-compat.h | |
133 | 135 | @HAVE_CHECK_TRUE@am_check_edp_OBJECTS = check_edp.$(OBJEXT) \ |
134 | 136 | @HAVE_CHECK_TRUE@ common.$(OBJEXT) |
135 | 137 | check_edp_OBJECTS = $(am_check_edp_OBJECTS) |
148 | 150 | @HAVE_CHECK_TRUE@ $(top_builddir)/src/lib/libfixedpoint.la \ |
149 | 151 | @HAVE_CHECK_TRUE@ $(am__DEPENDENCIES_2) |
150 | 152 | am__check_lldp_SOURCES_DIST = check_lldp.c \ |
151 | $(top_srcdir)/src/daemon/lldpd.h common.h common.c | |
153 | $(top_srcdir)/src/daemon/lldpd.h common.h common.c \ | |
154 | check-compat.h | |
152 | 155 | @HAVE_CHECK_TRUE@am_check_lldp_OBJECTS = check_lldp.$(OBJEXT) \ |
153 | 156 | @HAVE_CHECK_TRUE@ common.$(OBJEXT) |
154 | 157 | check_lldp_OBJECTS = $(am_check_lldp_OBJECTS) |
157 | 160 | @HAVE_CHECK_TRUE@ $(top_builddir)/src/daemon/liblldpd.la \ |
158 | 161 | @HAVE_CHECK_TRUE@ $(am__DEPENDENCIES_1) |
159 | 162 | am__check_marshal_SOURCES_DIST = check_marshal.c \ |
160 | $(top_srcdir)/src/marshal.h | |
163 | $(top_srcdir)/src/marshal.h check-compat.h | |
161 | 164 | @HAVE_CHECK_TRUE@am_check_marshal_OBJECTS = check_marshal.$(OBJEXT) |
162 | 165 | check_marshal_OBJECTS = $(am_check_marshal_OBJECTS) |
163 | 166 | check_marshal_LDADD = $(LDADD) |
183 | 186 | @HAVE_CHECK_TRUE@ $(top_builddir)/src/daemon/liblldpd.la \ |
184 | 187 | @HAVE_CHECK_TRUE@ $(am__DEPENDENCIES_1) |
185 | 188 | am__check_sonmp_SOURCES_DIST = check_sonmp.c \ |
186 | $(top_srcdir)/src/daemon/lldpd.h common.h common.c | |
189 | $(top_srcdir)/src/daemon/lldpd.h common.h common.c \ | |
190 | check-compat.h | |
187 | 191 | @HAVE_CHECK_TRUE@am_check_sonmp_OBJECTS = check_sonmp.$(OBJEXT) \ |
188 | 192 | @HAVE_CHECK_TRUE@ common.$(OBJEXT) |
189 | 193 | check_sonmp_OBJECTS = $(am_check_sonmp_OBJECTS) |
544 | 548 | LIPO = @LIPO@ |
545 | 549 | LLDPD_CTL_SOCKET = @LLDPD_CTL_SOCKET@ |
546 | 550 | LLDPD_PID_FILE = @LLDPD_PID_FILE@ |
551 | LLDP_CFLAGS = @LLDP_CFLAGS@ | |
552 | LLDP_CPPFLAGS = @LLDP_CPPFLAGS@ | |
553 | LLDP_LDFLAGS = @LLDP_LDFLAGS@ | |
547 | 554 | LN_S = @LN_S@ |
548 | 555 | LTLIBOBJS = @LTLIBOBJS@ |
549 | 556 | MAINT = @MAINT@ |
630 | 637 | mkdir_p = @mkdir_p@ |
631 | 638 | oldincludedir = @oldincludedir@ |
632 | 639 | pdfdir = @pdfdir@ |
640 | pkgconfigdir = @pkgconfigdir@ | |
633 | 641 | prefix = @prefix@ |
634 | 642 | program_transform_name = @program_transform_name@ |
635 | 643 | psdir = @psdir@ |
645 | 653 | top_build_prefix = @top_build_prefix@ |
646 | 654 | top_builddir = @top_builddir@ |
647 | 655 | top_srcdir = @top_srcdir@ |
648 | AM_CFLAGS = -I $(top_srcdir)/include $(am__append_1) | |
656 | AM_CFLAGS = -I $(top_srcdir)/include $(LLDP_CFLAGS) $(am__append_1) | |
657 | AM_CPPFLAGS = $(LLDP_CPPFLAGS) | |
658 | AM_LDFLAGS = $(LLDP_LDFLAGS) | |
649 | 659 | @HAVE_CHECK_TRUE@LDADD = $(top_builddir)/src/daemon/liblldpd.la \ |
650 | 660 | @HAVE_CHECK_TRUE@ @CHECK_LIBS@ @LIBEVENT_LDFLAGS@ \ |
651 | 661 | @HAVE_CHECK_TRUE@ $(am__append_3) |
652 | 662 | @HAVE_CHECK_TRUE@check_marshal_SOURCES = check_marshal.c \ |
653 | @HAVE_CHECK_TRUE@ $(top_srcdir)/src/marshal.h | |
663 | @HAVE_CHECK_TRUE@ $(top_srcdir)/src/marshal.h \ | |
664 | @HAVE_CHECK_TRUE@ check-compat.h | |
654 | 665 | |
655 | 666 | @HAVE_CHECK_TRUE@check_pattern_SOURCES = check_pattern.c \ |
656 | 667 | @HAVE_CHECK_TRUE@ $(top_srcdir)/src/daemon/lldpd.h |
657 | 668 | |
658 | 669 | @HAVE_CHECK_TRUE@check_lldp_SOURCES = check_lldp.c \ |
659 | 670 | @HAVE_CHECK_TRUE@ $(top_srcdir)/src/daemon/lldpd.h \ |
660 | @HAVE_CHECK_TRUE@ common.h common.c | |
671 | @HAVE_CHECK_TRUE@ common.h common.c check-compat.h | |
661 | 672 | |
662 | 673 | @HAVE_CHECK_TRUE@check_cdp_SOURCES = check_cdp.c \ |
663 | 674 | @HAVE_CHECK_TRUE@ $(top_srcdir)/src/daemon/lldpd.h \ |
664 | @HAVE_CHECK_TRUE@ common.h common.c | |
675 | @HAVE_CHECK_TRUE@ common.h common.c check-compat.h | |
665 | 676 | |
666 | 677 | @HAVE_CHECK_TRUE@check_sonmp_SOURCES = check_sonmp.c \ |
667 | 678 | @HAVE_CHECK_TRUE@ $(top_srcdir)/src/daemon/lldpd.h \ |
668 | @HAVE_CHECK_TRUE@ common.h common.c | |
679 | @HAVE_CHECK_TRUE@ common.h common.c check-compat.h | |
669 | 680 | |
670 | 681 | @HAVE_CHECK_TRUE@check_edp_SOURCES = check_edp.c \ |
671 | 682 | @HAVE_CHECK_TRUE@ $(top_srcdir)/src/daemon/lldpd.h \ |
672 | @HAVE_CHECK_TRUE@ common.h common.c | |
683 | @HAVE_CHECK_TRUE@ common.h common.c check-compat.h | |
673 | 684 | |
674 | 685 | @HAVE_CHECK_TRUE@check_fixedpoint_SOURCES = check_fixedpoint.c |
675 | 686 | @HAVE_CHECK_TRUE@check_fixedpoint_LDADD = $(top_builddir)/src/lib/libfixedpoint.la $(LDADD) |
0 | #ifndef _CHECK_COMPAT_H | |
1 | #define _CHECK_COMPAT_H | |
2 | ||
3 | #if (CHECK_MAJOR_VERSION == 0 && (CHECK_MINOR_VERSION < 9 || (CHECK_MINOR_VERSION == 9 && CHECK_MICRO_VERSION < 10))) | |
4 | # define ck_assert_ptr_eq(X,Y) do { \ | |
5 | void* _ck_x = (X); \ | |
6 | void* _ck_y = (Y); \ | |
7 | ck_assert_msg(_ck_x == _ck_y, \ | |
8 | "Assertion '"#X"=="#Y"' failed: "#X"==%p, "#Y"==%p", \ | |
9 | _ck_x, _ck_y); \ | |
10 | } while (0) | |
11 | #endif | |
12 | ||
13 | #endif |
0 | /* -*- mode: c; c-file-style: "openbsd" -*- */ | |
1 | /* | |
2 | * Copyright (c) 2015 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 | ||
0 | 17 | #include <stdlib.h> |
1 | 18 | #include <sys/socket.h> |
2 | 19 | #include <arpa/inet.h> |
0 | /* -*- mode: c; c-file-style: "openbsd" -*- */ | |
1 | /* | |
2 | * Copyright (c) 2015 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 | ||
0 | 17 | #include <stdlib.h> |
1 | 18 | #include <sys/socket.h> |
2 | 19 | #include <arpa/inet.h> |
0 | /* -*- mode: c; c-file-style: "openbsd" -*- */ | |
1 | /* | |
2 | * Copyright (c) 2015 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 | ||
0 | 17 | #include <stdlib.h> |
1 | 18 | #include <sys/socket.h> |
2 | 19 | #include <arpa/inet.h> |
489 | 506 | ck_assert_int_eq(nport->p_id_len, ETHER_ADDR_LEN); |
490 | 507 | fail_unless(memcmp(mac2, nport->p_id, ETHER_ADDR_LEN) == 0); |
491 | 508 | ck_assert_int_eq(nchassis->c_ttl, 120); |
492 | ck_assert_int_eq(nchassis->c_name, NULL); | |
493 | ck_assert_int_eq(nchassis->c_descr, NULL); | |
494 | ck_assert_int_eq(nport->p_descr, NULL); | |
509 | ck_assert_ptr_eq(nchassis->c_name, NULL); | |
510 | ck_assert_ptr_eq(nchassis->c_descr, NULL); | |
511 | ck_assert_ptr_eq(nport->p_descr, NULL); | |
495 | 512 | } |
496 | 513 | END_TEST |
497 | 514 |
0 | /* -*- mode: c; c-file-style: "openbsd" -*- */ | |
1 | /* | |
2 | * Copyright (c) 2015 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 | ||
0 | 17 | #include <stdlib.h> |
1 | 18 | #include <unistd.h> |
2 | 19 | #include <check.h> |
3 | 20 | #include <sys/queue.h> |
4 | 21 | |
5 | 22 | #define MARSHAL_EXPORT |
23 | #include "check-compat.h" | |
6 | 24 | #include "../src/marshal.h" |
7 | 25 | #include "../src/log.h" |
8 | 26 | |
9 | 27 | /* This suite can be run in valgrind for memory leaks: |
10 | 28 | CK_FORK=no valgrind -v --leak-check=yes ./tests/check_marshal |
11 | 29 | */ |
12 | ||
13 | #if (CHECK_MAJOR_VERSION == 0 && (CHECK_MINOR_VERSION < 9 || (CHECK_MINOR_VERSION == 9 && CHECK_MICRO_VERSION < 10))) | |
14 | # define ck_assert_ptr_eq(X,Y) do { \ | |
15 | void* _ck_x = (X); \ | |
16 | void* _ck_y = (Y); \ | |
17 | ck_assert_msg(_ck_x == _ck_y, \ | |
18 | "Assertion '"#X"=="#Y"' failed: "#X"==%p, "#Y"==%p", \ | |
19 | _ck_x, _ck_y); \ | |
20 | } while (0) | |
21 | #endif | |
22 | 30 | |
23 | 31 | /* Use this callback to avoid some logs */ |
24 | 32 | void donothing(int pri, const char *msg) {}; |
497 | 505 | e2 = TAILQ_NEXT(e1, s_entries); |
498 | 506 | free(e1); |
499 | 507 | ck_assert_int_eq(e2->g1, 49); |
500 | ck_assert_int_eq(e2->g2, s); | |
508 | ck_assert_ptr_eq(e2->g2, s); | |
501 | 509 | e1 = TAILQ_NEXT(e2, s_entries); |
502 | 510 | free(e2); |
503 | 511 | ck_assert_int_eq(e1->g1, 4700); |
504 | ck_assert_int_eq(e1->g2, NULL); | |
512 | ck_assert_ptr_eq(e1->g2, NULL); | |
505 | 513 | e2 = TAILQ_NEXT(e1, s_entries); |
506 | 514 | free(e1); |
507 | 515 | ck_assert_int_eq(e2->g1, -47); |
508 | ck_assert_int_eq(e2->g2, s); | |
516 | ck_assert_ptr_eq(e2->g2, s); | |
509 | 517 | e1 = TAILQ_NEXT(e2, s_entries); |
510 | 518 | free(e2); |
511 | ck_assert_int_eq(e1, NULL); | |
519 | ck_assert_ptr_eq(e1, NULL); | |
512 | 520 | free(s); |
513 | 521 | free(destination); |
514 | 522 | } |
583 | 591 | e2 = TAILQ_NEXT(e1, s_entries); |
584 | 592 | free(e1); |
585 | 593 | ck_assert_int_eq(e2->g1, 49); |
586 | ck_assert_int_eq(e2->g2, s); | |
594 | ck_assert_ptr_eq(e2->g2, s); | |
587 | 595 | e1 = TAILQ_NEXT(e2, s_entries); |
588 | 596 | free(e2); |
589 | 597 | ck_assert_int_eq(e1->g1, 4700); |
590 | ck_assert_int_eq(e1->g2, NULL); | |
598 | ck_assert_ptr_eq(e1->g2, NULL); | |
591 | 599 | e2 = TAILQ_NEXT(e1, s_entries); |
592 | 600 | free(e1); |
593 | 601 | ck_assert_int_eq(e2->g1, -47); |
594 | ck_assert_int_eq(e2->g2, s); | |
602 | ck_assert_ptr_eq(e2->g2, s); | |
595 | 603 | e1 = TAILQ_NEXT(e2, s_entries); |
596 | 604 | free(e2); |
597 | ck_assert_int_eq(e1, NULL); | |
605 | ck_assert_ptr_eq(e1, NULL); | |
598 | 606 | free(s); |
599 | 607 | free(destination); |
600 | 608 | } |
706 | 714 | free(buffer); |
707 | 715 | ck_assert_int_eq(len, len2); |
708 | 716 | ck_assert_int_eq(destination->t1, 4544); |
709 | ck_assert_int_eq(destination->t2, NULL); | |
717 | ck_assert_ptr_eq(destination->t2, NULL); | |
710 | 718 | ck_assert_int_eq(destination->t3, 11111); |
711 | 719 | free(destination); |
712 | 720 | } |
0 | /* -*- mode: c; c-file-style: "openbsd" -*- */ | |
1 | /* | |
2 | * Copyright (c) 2015 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 | ||
0 | 17 | #include <check.h> |
1 | 18 | |
2 | 19 | #include "../src/daemon/lldpd.h" |
327 | 344 | int i; |
328 | 345 | |
329 | 346 | current = (current + 1)%4; |
330 | if (buffer[current]) free(buffer[current]); buffer[current] = NULL; | |
347 | free(buffer[current]); buffer[current] = NULL; | |
331 | 348 | |
332 | 349 | for (i = 0; i < namelen; i++) { |
333 | 350 | /* Not very efficient... */ |
334 | 351 | char *newbuffer = NULL; |
335 | if (asprintf(&newbuffer, "%s.%lu", buffer[current]?buffer[current]:"", name[i]) == -1) { | |
352 | if (asprintf(&newbuffer, "%s.%lu", buffer[current]?buffer[current]:"", | |
353 | (unsigned long)name[i]) == -1) { | |
336 | 354 | free(buffer[current]); |
337 | 355 | buffer[current] = NULL; |
338 | 356 | return NULL; |
339 | 357 | } |
340 | if (buffer[current]) free(buffer[current]); | |
358 | free(buffer[current]); | |
341 | 359 | buffer[current] = newbuffer; |
342 | 360 | } |
343 | 361 | return buffer[current++]; |
832 | 850 | { |
833 | 851 | static char *hex[] = { NULL, NULL }; |
834 | 852 | static int which = 0; |
835 | if (hex[which]) free(hex[which]); hex[which] = NULL; | |
853 | free(hex[which]); hex[which] = NULL; | |
836 | 854 | hex[which] = malloc(len * 3 + 1); |
837 | 855 | fail_unless(hex[which] != NULL, "Not enough memory?"); |
838 | 856 | for (int i = 0; i < len; i++) |
880 | 898 | u_char *result, size_t varlen, |
881 | 899 | oid *target, size_t targetlen, char *repr) |
882 | 900 | { |
901 | unsigned long int value; | |
883 | 902 | fail_unless((targetlen == sizeof(lldp_oid)/sizeof(oid) + n->namelen) && |
884 | 903 | !memcmp(target, lldp_oid, sizeof(lldp_oid)) && |
885 | 904 | !memcmp(target + sizeof(lldp_oid)/sizeof(oid), |
895 | 914 | fail_unless(varlen == sizeof(unsigned long int), |
896 | 915 | "Inappropriate length for integer type for OID %s", |
897 | 916 | repr); |
898 | fail_unless(n->value.integer == | |
899 | *(unsigned long int *)result, | |
917 | memcpy(&value, result, sizeof(value)); | |
918 | fail_unless(n->value.integer == value, | |
900 | 919 | "For OID %s, expected value %u but got %u instead", |
901 | 920 | repr, |
902 | 921 | n->value.integer, |
903 | *(unsigned long int *)result); | |
922 | value); | |
904 | 923 | break; |
905 | 924 | default: |
906 | 925 | fail_unless(((n->value.string.len == varlen) && |
0 | /* -*- mode: c; c-file-style: "openbsd" -*- */ | |
1 | /* | |
2 | * Copyright (c) 2015 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 | ||
0 | 17 | #include <stdlib.h> |
1 | 18 | #include <sys/socket.h> |
2 | 19 | #include <arpa/inet.h> |
0 | /* -*- mode: c; c-file-style: "openbsd" -*- */ | |
1 | /* | |
2 | * Copyright (c) 2015 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 | ||
0 | 17 | #include <stdlib.h> |
1 | 18 | #include <stdio.h> |
2 | 19 | #include <unistd.h> |
0 | /* -*- mode: c; c-file-style: "openbsd" -*- */ | |
1 | /* | |
2 | * Copyright (c) 2015 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 | ||
0 | 17 | #ifndef _COMMON_H |
1 | 18 | #define _COMMON_H |
2 | 19 | |
20 | #include "check-compat.h" | |
3 | 21 | #include "../src/daemon/lldpd.h" |
4 | 22 | |
5 | 23 | /* See: |