summaryrefslogtreecommitdiffstats
path: root/src/test/test-in-addr-util.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* test: add basic tests for in_addr_prefix_covers_full()Yu Watanabe2024-05-101-0/+51
|
* ASSERT_STREQ for simple casesIvan Kruglov2024-04-151-6/+6
|
* in-addr-util: drop unused mode to parse prefix lengthYu Watanabe2023-01-191-37/+26
|
* basic: generate netmasks for IPv6 and generic IP family addressesTopi Miettinen2022-08-291-0/+52
| | | | Added functions to generate netmasks for IPv6 and generic IP family addresses.
* Revert "networkd: NetLabel integration"Yu Watanabe2022-06-221-31/+0
| | | | | | | | | | | | | | This reverts PR #23269 and its follow-up commit. Especially, 2299b1cae32c1fb8911da0ce26efced68032f4f8 (partially), and 3cf63830acdef9d8afdc9ef1cf25aa7e85a5e4d5. The PR was merged without final approval, and has several issues: - The NetLabel for static addresses are not assigned, as labels are stored in the Address objects managed by Network, instead of Link. - If NetLabel is specified for a static address, then the address section will be invalid and the address will not be configured, - It should be implemented with Request object, - There is no test about the feature.
* Merge pull request #23616 from keszybz/in-addr-to-string-formattingYu Watanabe2022-06-091-8/+9
|\ | | | | Add macros that allocate a fixed buffer for in_addr_to_string(), in_addr_prefix+to_string()
| * basic/in-addr-util: add IN_ADDR_PREFIX_TO_STRINGZbigniew Jędrzejewski-Szmek2022-06-061-6/+5
| |
| * basic/in-addr-util: drop check for prefix length in formatting functionZbigniew Jędrzejewski-Szmek2022-06-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The general rule should be to be strict when parsing data, but lenient when printing it. Or in other words, we should verify data in verification functions, but not when printing things. It doesn't make sense to refuse to print a value that we are using internally. We were tripping ourselves in some of the print functions: we want to report than an address was configured with too-long prefix, but the log line would use "n/a" if the prefix was too long. This is not useful. Most of the time, the removal of the check doesn't make any difference, because we verified the prefix length on input.
| * basic/in-addr-util: add IN_ADDR_TO_STRINGZbigniew Jędrzejewski-Szmek2022-06-061-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since we don't need the error value, and the buffer is allocated with a fixed size, the whole logic provided by in_addr_to_string() becomes unnecessary, so it's enough to wrap inet_ntop() directly. inet_ntop() can only fail with ENOSPC. But we specify a buffer that is supposed to be large enough, so this should never fail. A bunch of tests of this are added. This allows all the wrappers like strna(), strnull(), strempty() to be dropped. The guard of 'if (DEBUG_LOGGING)' can be dropped from around log_debug(), because log_debug() implements the check outside of the function call. But log_link_debug() does not, so it we need it to avoid unnecessary evaluation of the formatting.
* | networkd: NetLabel integrationTopi Miettinen2022-06-061-0/+31
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | New directive `NetLabel=` provides a method for integrating dynamic network configuration into Linux NetLabel subsystem rules, used by Linux security modules (LSMs) for network access control. The option expects a whitespace separated list of NetLabel labels. The labels must conform to lexical restrictions of LSM labels. When an interface is configured with IP addresses, the addresses and subnetwork masks will be appended to the NetLabel Fallback Peer Labeling rules. They will be removed when the interface is deconfigured. Failures to manage the labels will be ignored. Example: ``` [DHCP] NetLabel=system_u:object_r:localnet_peer_t:s0 ``` With the above rules for interface `eth0`, when the interface is configured with an IPv4 address of 10.0.0.0/8, `systemd-networkd` performs the equivalent of `netlabelctl` operation ``` $ sudo netlabelctl unlbl add interface eth0 address:10.0.0.0/8 label:system_u:object_r:localnet_peer_t:s0 ``` Result: ``` $ sudo netlabelctl -p unlbl list ... interface: eth0 address: 10.0.0.0/8 label: "system_u:object_r:localnet_peer_t:s0" ... ```
* test: Use TEST macroJan Janssen2021-11-251-42/+10
| | | | | | | | | This converts to TEST macro where it is trivial. Some additional notable changes: - simplify HAVE_LIBIDN #ifdef in test-dns-domain.c - use saved_argc/saved_argv in test-copy.c, test-path-util.c, test-tmpfiles.c and test-unit-file.c
* test: slightly modernize test-in-addr-util.cYu Watanabe2021-09-141-5/+13
|
* in-addr-util: introduce in_addr_prefix_range()Yu Watanabe2021-02-171-0/+42
| | | | This will replace nft_in6addr_to_range() in later commit.
* in-addr-util: make in_addr_prefix_nth() always return valid prefixYu Watanabe2021-02-171-5/+8
| | | | | Previously, e.g. in_addr_prefix_nth(2400::1, prefixlen=32, nth=1) does not return 2400:1:: but does 2400:1::1.
* in-addr-util: make in_addr_prefix_nth() returns 0 on successYu Watanabe2021-02-171-2/+2
|
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* test-in-addr-util: add log headersZbigniew Jędrzejewski-Szmek2020-09-101-2/+8
|
* test: move several tests from test-socket-util.cYu Watanabe2020-09-041-0/+153
|
* test: add tests for test_in_addr_prefix_to_string()Yu Watanabe2019-03-041-0/+49
|
* test: move tests for in_addr_prefix_from_string()Yu Watanabe2019-03-041-27/+30
|
* test: add tests for in_addr_random_prefix()Yu Watanabe2019-03-011-0/+48
|
* util: add a new mode for in_addr_prefix_from_string_auto_internal() which ↵Yu Watanabe2019-01-291-60/+62
| | | | | | | refuses address without prefixlen This also drops in_addr_default_prefix_from_string(), as it is only used by test-in-addr.
* in-addr-util: make in_addr_default_prefix_from_string() or friend set 0 to ↵Yu Watanabe2018-11-071-1/+1
| | | | | | | prefixlen when family == AF_INET6 (#10665) Follow-up for a4798d4e6d88c2be2625ce62d8326eaa9b80f2ee. Fixes #10662.
* test: add tests for in_addr_default_prefix_from_string() or friendYu Watanabe2018-11-051-28/+54
|
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* in-addr-util: add new helper call in_addr_prefix_from_string_auto()Lennart Poettering2017-09-221-0/+75
This is much like in_addr_prefix_from_string(), but automatically determines whether IPv4 or IPv6 addresses are specified. Also adds a test for it.