summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Fix win32 regression introduced in 36e96bfJoachim Wiberg2022-12-311-2/+2
| | | | | | libnet_if_addr.c(467): error C2082: redefinition of formal parameter 'dev' Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
* Follow-up to 6954544: update license in man pages and dll infoJoachim Wiberg2022-12-301-1/+1
| | | | Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
* src: alllow returning lo when dev i set also on Linux and OpenBSDJoachim Wiberg2022-12-301-4/+2
| | | | | | | | | | The other (older) implementations of libnet_ifaddrlist() explicitly check if dev is unset before discarding any loopback interface. This patch adds the same behavior to the Linux and OpeBSD backends for consistency. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
* src: minor, fix parametner unused in windows backendJoachim Wiberg2022-12-301-1/+3
| | | | Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
* src: fix signed vs unsigned comparison warning, found by appveyorJoachim Wiberg2022-12-301-13/+11
| | | | Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
* src: refactor non-linux & non-windows libnet_ifadrrlist()Joachim Wiberg2022-12-301-67/+136
| | | | | | | | | Split the non-linux HAVE_LINUX_PROCFS non-windows libnet_ifadrrlist() in two functions for readability. It is very unclear atm. which OS this might actually be, new function tested on Linux. The remaining, cleaned up non-HAVE_LINUX_PROCFS version is what runs on FreeBSD and macOS. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
* src: minor cleanup, for consistency in variable useJoachim Wiberg2022-12-301-10/+7
| | | | Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
* src: simplify and align different libnet_ifaddrlist() backendsJoachim Wiberg2022-12-301-20/+21
| | | | Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
* src: drop useless call to free() on not yet allocated pointerJoachim Wiberg2022-12-301-2/+0
| | | | | | Affects all non-Linux/OpenBSD and non-Windows platforms. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
* src: ensure ifaddrlist is always freedJoachim Wiberg2022-12-301-27/+20
| | | | | | Simplifies code a lot and we never risk leaking memory. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
* include: drop internal-only ifaddrlist.h includeJoachim Wiberg2022-12-301-1/+15
| | | | | | Only used in libnet_if_addr.c and never documented as a public API. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
* De-register, compiler knows bestJoachim Wiberg2022-12-297-34/+29
| | | | Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
* Follow-up to 8b4688c: fix regression on WindowsJoachim Wiberg2022-12-281-10/+39
| | | | | | | | | | | | libnet has multiple libnet_ifaddrlist(), one for each OS family. The changes in PR #150, fixing the aribtrary MAX IP address limit on LInux, unfortunately broke all other operating systems. This is a specualtive change for the Windows operating system, untested. Issue #150 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
* Follow-up to 8b4688c: fix regression on macOSJoachim Wiberg2022-12-281-4/+26
| | | | | | | | | | | | | libnet has multiple libnet_ifaddrlist(), one for each OS family. The changes in PR #150, fixing the aribtrary MAX IP address limit on LInux, unfortunately broke all other operating systems. This change is for the "other" operating system that are not Windows. Tested on macOS. Issue #150 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
* libnet_destroy(): verify l->device is a pointer before calling freeJoachim Wiberg2022-12-281-1/+2
| | | | Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
* src: simplify, exit earlyJoachim Wiberg2022-12-281-2/+1
| | | | Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
* src: reduce code duplication and protect against NULL ptr derefJoachim Wiberg2022-12-281-14/+13
| | | | Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
* 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>