diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:14:53 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:14:53 +0000 |
commit | a86c5f7cae7ec9a3398300555a0b644689d946a1 (patch) | |
tree | 39fe4b107c71174fd1e8a8ceb9a4d2aa14116248 /wsutil/inet_cidr.h | |
parent | Releasing progress-linux version 4.2.6-1~progress7.99u1. (diff) | |
download | wireshark-a86c5f7cae7ec9a3398300555a0b644689d946a1.tar.xz wireshark-a86c5f7cae7ec9a3398300555a0b644689d946a1.zip |
Merging upstream version 4.4.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'wsutil/inet_cidr.h')
-rw-r--r-- | wsutil/inet_cidr.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/wsutil/inet_cidr.h b/wsutil/inet_cidr.h new file mode 100644 index 00000000..352b01de --- /dev/null +++ b/wsutil/inet_cidr.h @@ -0,0 +1,62 @@ +/** @file + * Definitions of IPv4 address-and-mask structure, which is what an + * FT_IPV4 value is (even if there's no mask in a packet, those + * values can be compared against an address+mask in a filter + * expression). + * + * Gilbert Ramirez <gram@alumni.rice.edu> + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef __IPV4_H__ +#define __IPV4_H__ + +#include <wireshark.h> +#include <wsutil/inet_addr.h> + +typedef struct { + uint32_t addr; /* stored in host order */ + uint32_t nmask; /* stored in host order */ +} ipv4_addr_and_mask; + +typedef struct { + ws_in6_addr addr; + uint32_t prefix; +} ipv6_addr_and_prefix; + +/* + ********** IPv4 ********* + */ + +/** +* Returns the IPv4 subnet mask of the specified length +* +* @param mask_length the number of bits in the subnet mask (max of 32) +* @return the subnet mask of the specified length +*/ +WS_DLL_PUBLIC +uint32_t +ws_ipv4_get_subnet_mask(const uint32_t mask_length); + +WS_DLL_PUBLIC +void +ws_ipv4_addr_and_mask_init(ipv4_addr_and_mask *dst, ws_in4_addr src_addr, int src_bits); + +WS_DLL_PUBLIC +bool +ws_ipv4_addr_and_mask_contains(const ipv4_addr_and_mask *ipv4, const ws_in4_addr *addr); + +/* + ********** IPv6 ********* + */ + +WS_DLL_PUBLIC +bool +ws_ipv6_addr_and_prefix_contains(const ipv6_addr_and_prefix *ipv6, const ws_in6_addr *addr); + +#endif |