summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* src: minor coding style cleanupJoachim Wiberg2022-12-282-54/+42
| | | | Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
* libnet_if_addr.c: fix segfault when number of IPs > 512Andy Roulin2022-11-231-2/+24
| | | | | | | | | | | | The current code has a hardcoded limit of 512 IP addresses. The static array will be overflowed when more addresses are present. Fix the static limit by using realloc when the array needs to grow to accomodate more interfaces. Growing the array by a factor of 1.5 each time (close to golden ratio) to maximize reuse of previously allocated space.
* libnet_raw: don't change the TX buffer size for raw socketsBeniamin Sandu2022-09-262-37/+20
| | | | | | | | Instead of trying to set the max TX buffer size for every raw socket, export this to a separate interface that can be used when needed, called libnet_setfd_max_sndbuf(). Signed-off-by: Beniamin Sandu <beniaminsandu@gmail.com>
* src: lldp: drop extra const for consistency with rest of libnetJoachim Wiberg2021-08-111-3/+3
| | | | | | https://github.com/libnet/libnet/commit/4059e2ef7f277b962dc4a93bd2df9445361c7cca#r54752736 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
* Minor coding style changesJoachim Wiberg2021-08-111-261/+240
| | | | | | | | | | - Four space indent - Braces on their own row, not cuddled - No need for braces if only one statement, like return/goto - Space between if and its parenthesis - Variable decl. at top of function or block Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
* fix: lldp: remove unnecessary assertsValery Ivanov2021-08-111-17/+0
|
* chore(src/libnet_internal): update lldp infoValery Ivanov2021-05-081-0/+12
|
* chore(src/Makefile.am): add libnet_build_lldp.c to sourcesValery Ivanov2021-05-081-0/+1
|
* feat(functions): add libnet_build_lldp_org_spec functionValery Ivanov2021-05-081-0/+59
|
* feat(functions): add libnet_build_lldp_end functionValery Ivanov2021-05-081-0/+46
|
* feat(functions): add libnet_build_lldp_ttl functionValery Ivanov2021-05-081-0/+60
|
* feat(functions): add libnet_build_lldp_port functionValery Ivanov2021-05-081-0/+76
|
* feat(functions): add libnet_build_lldp_chassis functionValery Ivanov2021-05-071-0/+83
|
* Fix potential name conflict with cpp keyword 'new'Valery Ivanov2021-05-021-8/+8
|
* Merge pull request #122 from ivalery111/fix-unused-parameter-warningJoachim Wiberg2021-05-013-0/+5
|\ | | | | Fix unused parameter warnings
| * Fix unused parameter warningsValery Ivanov2021-04-283-0/+5
| | | | | | | | Signed-off-by: Valery Ivanov <ivalery111@gmail.com>
* | libnet_cq.c: fix 'dereference of possibly-NULL'Adrian Reber2021-04-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libnet_cq.c:139:18: warning: dereference of possibly-NULL ‘new_18’ [CWE-690] [-Wanalyzer-possible-null-dereference] 139 | new->context = l; | ~~~~~~~~~~~~~^~~ ‘libnet_cq_add.part.0’: events 1-6 | | 71 | libnet_cq_add(libnet_t *l, char *label) | | ^~~~~~~~~~~~~ | | | | | (1) entry to ‘libnet_cq_add.part.0’ |...... | 89 | if (label == NULL) | | ~ | | | | | (2) following ‘false’ branch (when ‘label_1(D)’ is non-NULL)... |...... | 97 | if (l_cq == NULL) | | ~~ ~ | | | | | | | (4) following ‘false’ branch... | | (3) ...to here |...... | 124 | if (libnet_cq_dup_check(l, label)) | | ~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | | | (6) calling ‘libnet_cq_dup_check’ from ‘libnet_cq_add.part.0’ | | (5) ...to here | +--> ‘libnet_cq_dup_check’: events 7-13 | | 269 | libnet_cq_dup_check(libnet_t *l, char *label) | | ^~~~~~~~~~~~~~~~~~~ | | | | | (7) entry to ‘libnet_cq_dup_check’ |...... | 273 | for (p = l_cq; p; p = p->next) | | ~ ~~~~~~~~~~~ | | | | | | | (13) ...to here | | (8) following ‘true’ branch (when ‘p_6’ is non-NULL)... | 274 | { | 275 | if (p->context == l) | | ~~ ~ | | | | | | | (10) following ‘false’ branch... | | (9) ...to here |...... | 281 | if (strncmp(p->context->label, label, LIBNET_LABEL_SIZE) == 0) | | ~~ ~ | | | | | | | (12) following ‘false’ branch... | | (11) ...to here | <------+ | ‘libnet_cq_add.part.0’: events 14-20 | | 124 | if (libnet_cq_dup_check(l, label)) | | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | || | | |(14) returning to ‘libnet_cq_add.part.0’ from ‘libnet_cq_dup_check’ | | (15) following ‘false’ branch... |...... | 130 | new = (libnet_cq_t *)malloc(sizeof (libnet_cq_t)); | | ~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | | | (17) this call could return NULL | | (16) ...to here | 131 | if (l_cq == NULL) | | ~ | | | | | (18) following ‘false’ branch... |...... | 139 | new->context = l; | | ~~~~~~~~~~~~~~~~ | | | | | | | (20) ‘new_18’ could be NULL: unchecked value from (17) | | (19) ...to here | Signed-off-by: Adrian Reber <areber@redhat.com>
* | libnet_pblock.c: fix warning "unused variable ‘c’"Adrian Reber2021-04-141-1/+0
| | | | | | | | Signed-off-by: Adrian Reber <areber@redhat.com>
* | libnet_port_list.c: fix gcc -fanalyzer warningAdrian Reber2021-04-141-0/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes: libnet_port_list.c:99:8: warning: leak of ‘_8’ [CWE-401] [-Wanalyzer-malloc-leak] 99 | if (!all_lists) | ^ ‘libnet_plist_chain_new’: events 1-3 | | 48 | if (l == NULL) | | ^ | | | | | (1) following ‘false’ branch (when ‘l_70(D)’ is non-NULL)... |...... | 53 | if (token_list == NULL) | | ~~ ~ | | | | | | | (3) following ‘false’ branch (when ‘token_list_71(D)’ is non-NULL)... | | (2) ...to here | ‘libnet_plist_chain_new’: event 4 | |cc1: | (4): ...to here | ‘libnet_plist_chain_new’: events 5-9 | | 83 | *plist = malloc(sizeof (libnet_plist_t)); | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | (5) allocated here | 84 | | 85 | if (!(*plist)) | | ~ | | | | | (6) assuming ‘*plist_74(D)’ is non-NULL | | (7) following ‘false’ branch... |...... | 93 | tmp = *plist; | | ~~~ | | | | | (8) ...to here |...... | 99 | if (!all_lists) | | ~ | | | | | (9) ‘_8’ leaks here; was allocated at (5) | Signed-off-by: Adrian Reber <areber@redhat.com>
* Fix segmentation fault in libnet_ifaddrlistStephan Hartmann2021-01-011-1/+1
| | | | | According to getifaddrs man page, ifa_addr can be NULL. Skip such interfaces to avoid NULL dereference.
* Merge pull request #94 from libnet/license-cleanupJoachim Nilsson2020-07-109-134/+198
|\ | | | | Major license change: 4-clause BSD to 3-clause BSD
| * Speculatively fix bpf.h include for snoop and dlpilicense-cleanupJoachim Nilsson2019-10-202-2/+2
| | | | | | | | Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
| * Fix bpf.h include after removal, macOS has this in net/bpf.hJoachim Nilsson2019-10-201-2/+0
| | | | | | | | Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
| * Change from 4-clause to 3-clause BSD license for src/libnet_link_*.cJoachim Nilsson2019-10-208-113/+177
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adopts the 3-clause BSD license for all src/libnet_link_*.c files previously under the 4-clause BSD license. Effectively this drops the "obnoxious" advertising clause which is usually what is under most contention when BSD licenses are discussed. For a background, the https://en.wikipedia.org/wiki/BSD_licenses page provides an interesting read. Briefly, in 1999 Berkeley rescinded the original 3rd clause (see below) leading to a change in major software projects to, not only adopt this new BSD license, but also renumber the listed provisions. Ref. ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
| * libnet_ansn1.c: Align header 2-clause BSD license with libnet_asn1.hJoachim Nilsson2019-10-201-17/+19
| | | | | | | | Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
* | Fix possible overflowsThomas Habets2019-11-011-3/+4
| |
* | Merge pull request #98 from ThomasHabets/signedJoachim Nilsson2019-10-2335-222/+143
|\ \ | | | | | | Clean up some signed/unsigned comparisons
| * | Clean up some signed/unsigned comparisonsThomas Habets2019-10-2235-222/+143
| |/
* | Merge pull request #96 from ThomasHabets/pointwarnJoachim Nilsson2019-10-231-5/+5
|\ \ | | | | | | Cast pointer to (void*) to silence -Wextra warning
| * | Cast pointer to (void*) to silence -Wextra warningThomas Habets2019-10-211-5/+5
| |/
* | Fix some non-standard types to build with -std=c18Thomas Habets2019-10-213-2/+10
|/
* Minor, whitespaceJoachim Nilsson2019-10-191-2/+2
| | | | Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
* Must include Packet32.h first to get struct bpf_program for pcap.hJoachim Nilsson2019-10-191-4/+5
| | | | Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
* Remove generated file from GITJoachim Nilsson2019-10-191-176/+0
| | | | Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
* doc: Update URLs to point at new official home for libnet projectJoachim Nilsson2019-10-101-1/+1
| | | | Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
* Follow-up to 0cf7642d: missing ; in statement after refactorJoachim Nilsson2019-10-091-2/+2
| | | | Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
* Rerun ./bin/map-pblock-types to add missing typesSam Roberts2019-10-091-0/+2
|
* libnet_in_cksum(): Clean up, remove unused DEBIAN codeJoachim Nilsson2019-10-091-26/+3
| | | | | | | | | | | | | This removes the last (unused) remnants of a Debian discussion about checksumming odd sized packets. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=284729 The resulting code from this change is what we've had for several years now, without any more bug reports. So I'm removing the unused code to make it easier to read. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
* Add coding style hinting for EmacsJoachim Nilsson2019-10-0859-15/+361
| | | | Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
* Follow-up to f3b4dea3: Missing starting " in snprintf()Joachim Nilsson2019-10-081-1/+1
| | | | Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
* Minor, coding style/whitespace cleanupJoachim Nilsson2019-10-084-126/+145
| | | | | | | | - Avoid assignment inside if-statements - Add missing whitespace; if () rather than if() - Spaces vs tabs Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
* libnet_destroy(): Don't close() l->fd if -1Joachim Nilsson2019-10-081-1/+2
| | | | | | Found by Valgrind Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
* Skip sys/timeb.h also on FreeBSD, deprecatedJoachim Nilsson2019-10-081-1/+1
| | | | Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
* Drop gratuitous EOF and end of fileJoachim Nilsson2019-10-0647-47/+0
| | | | Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
* Fix sign mismatch in getsockopt() optlenSam Roberts2019-10-011-1/+1
| | | | | Modern systems declare this as `.. socklen_t)`, but older systems don't use that. Use unsigned because its at least sign-compatible.
* Remove unused variablesSam Roberts2019-10-012-19/+1
|
* src: libnet_link_snoop.c: Fix more #endifs than #ifdefsJoachim Nilsson2019-09-291-5/+2
| | | | | | Found in https://codedocs.xyz/libnet/libnet.log Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
* Merge branch 'master' of https://github.com/sgeto/libnet into sgeto-masterJoachim Nilsson2019-09-2810-221/+441
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .gitignore .travis.yml BUILD-FROM-GIT.txt Makefile.am Makefile.am.common Prepare acinclude.m4 autogen.sh configure.ac doc/html/Makefile.am doc/html/closed.png doc/html/globals_func.html doc/html/tab_s.png doc/libnet.doxygen.conf doc/man/Makefile.am doc/man/man3/Makefile.am doc/man/man3/libnet-functions.h.3 doc/man/man3/libnet-macros.h.3 include/libnet.h include/libnet/Makefile.am libnet/acinclude.m4 libnet/libnet-config.in libnet/m4/acinclude.m4 lua/Makefile lua/msvcbuild.bat sample/Makefile.am scripts/Push src/libnet_link_win32.c win32/Makefile.am
* Minor, fix spellingBarak A. Pearlmutter2019-09-281-1/+1
|
* Use getiffaddrs(3) on OpenBSD and Linuxdohnuts2019-09-251-0/+51
| | | | | | | | | * In GLIBC since 2002 * Available in recetn uClibc, https://github.com/hwoarang/uClibc/blob/master-metag/libc/inet/ifaddrs.c * In OpenBSD since 2.7 Tested on OpenBSD with arping, compiled on linux by @sgeto