Wireshark  4.3.0
The Wireshark network protocol analyzer
Macros | Functions
addr_and_mask.h File Reference
#include <wsutil/inet_ipv4.h>
#include <wsutil/inet_ipv6.h>

Go to the source code of this file.

Macros

#define PREFIX_LEN_OK   0
 
#define PREFIX_LEN_TOO_LONG   1
 
#define PREFIX_LEN_ZERO   2
 

Functions

int tvb_get_ipv4_addr_with_prefix_len (tvbuff_t *tvb, int offset, ws_in4_addr *addr, guint32 prefix_len)
 
int tvb_get_ipv6_addr_with_prefix_len (tvbuff_t *tvb, int offset, ws_in6_addr *addr, guint32 prefix_len)
 
guint32 ip_get_subnet_mask (const guint32 mask_length)
 

Detailed Description

Declarations of routines to fetch IPv4 and IPv6 addresses from a tvbuff and then mask out bits other than those covered by a prefix length

Wireshark - Network traffic analyzer By Gerald Combs geral.nosp@m.d@wi.nosp@m.resha.nosp@m.rk.o.nosp@m.rg Copyright 1998 Gerald Combs

SPDX-License-Identifier: GPL-2.0-or-later

Function Documentation

◆ ip_get_subnet_mask()

guint32 ip_get_subnet_mask ( const guint32  mask_length)

Returns the IPv4 subnet mask of the specified length

Parameters
mask_lengththe number of bits in the subnet mask (max of 32)
Returns
the subnet mask of the specified length

◆ tvb_get_ipv4_addr_with_prefix_len()

int tvb_get_ipv4_addr_with_prefix_len ( tvbuff_t tvb,
int  offset,
ws_in4_addr *  addr,
guint32  prefix_len 
)

Fetches an IPv4 address from a tvbuff and masks out bits other than those covered by a prefix length

Parameters
tvbtvbuff to read an IPv4 address from
offsetoffset in the tvbuff to read the IPv4 address from
addrmemory location where the IPv4 address read should be stored
prefix_lenthe length of the prefix (in bits)
Returns
the length (in bytes) of the address on success, or -1 on failure

◆ tvb_get_ipv6_addr_with_prefix_len()

int tvb_get_ipv6_addr_with_prefix_len ( tvbuff_t tvb,
int  offset,
ws_in6_addr addr,
guint32  prefix_len 
)

Fetches an IPv6 address from a tvbuff and masks out bits other than those covered by a prefix length

Parameters
tvbtvbuff to read an IPv6 address from
offsetoffset in the tvbuff to read the IPv6 address from
addrmemory location where the IPv6 address read should be stored
prefix_lenthe length of the prefix (in bits)
Returns
the length (in bytes) of the address on success, or -1 on failure