networking.h
Go to the documentation of this file.
/* SPDX-FileCopyrightText: 2013-2023 Greenbone AG
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef _GVM_NETWORKING_H
#define _GVM_NETWORKING_H
#include "array.h" /* for array_t */
#include <netdb.h> /* for struct in6_addr */
typedef enum
{
PORT_PROTOCOL_TCP = 0,
PORT_PROTOCOL_UDP = 1,
PORT_PROTOCOL_OTHER = 2
} port_protocol_t;
struct range
{
gchar *comment;
gchar *id;
int end;
int exclude;
int start;
port_protocol_t type;
};
typedef struct range range_t;
int
gvm_source_iface_init (const char *);
int
gvm_source_iface_is_set (void);
int
gvm_source_set_socket (int, int, int);
void
gvm_source_addr (void *);
void
gvm_source_addr6 (void *);
void
gvm_source_addr_as_addr6 (struct in6_addr *);
char *
gvm_source_addr_str (void);
char *
gvm_source_addr6_str (void);
void
ipv4_as_ipv6 (const struct in_addr *, struct in6_addr *);
void
addr6_to_str (const struct in6_addr *, char *);
char *
addr6_as_str (const struct in6_addr *);
void
sockaddr_as_str (const struct sockaddr_storage *, char *);
int
gvm_resolve (const char *, void *, int);
GSList *
gvm_resolve_list (const char *);
int
gvm_resolve_as_addr6 (const char *, struct in6_addr *);
int
validate_port_range (const char *);
array_t *
port_range_ranges (const char *);
int
port_in_port_ranges (int, port_protocol_t, array_t *);
int
ipv6_is_enabled (void);
gchar *
gvm_routethrough (struct sockaddr_storage *, struct sockaddr_storage *);
char *
gvm_get_outgoing_iface (struct sockaddr_storage *);
#endif /* not _GVM_NETWORKING_H */
array.h
Array utilities.
array_t
GPtrArray array_t
Definition array.h:16
ipv4_as_ipv6
void ipv4_as_ipv6(const struct in_addr *, struct in6_addr *)
Maps an IPv4 address as an IPv6 address. eg. 192.168.10.20 would map to ::ffff:192....
Definition networking.c:243
port_range_ranges
array_t * port_range_ranges(const char *)
Create a range array from a port_range string.
Definition networking.c:601
sockaddr_as_str
void sockaddr_as_str(const struct sockaddr_storage *, char *)
Convert an IP address to string format.
Definition networking.c:298
gvm_source_addr
void gvm_source_addr(void *)
Gives the source IPv4 address.
Definition networking.c:174
addr6_as_str
char * addr6_as_str(const struct in6_addr *)
Stringifies an IP address.
Definition networking.c:279
ipv6_is_enabled
int ipv6_is_enabled(void)
Checks if IPv6 support is enabled.
Definition networking.c:752
gvm_routethrough
gchar * gvm_routethrough(struct sockaddr_storage *, struct sockaddr_storage *)
Get Interface which should be used for routing to destination addr.
Definition networking.c:994
gvm_source_set_socket
int gvm_source_set_socket(int, int, int)
Binds a socket to use the global source address.
Definition networking.c:136
gvm_resolve_list
GSList * gvm_resolve_list(const char *)
Returns a list of addresses that a hostname resolves to.
Definition networking.c:339
gvm_source_addr_as_addr6
void gvm_source_addr_as_addr6(struct in6_addr *)
Gives the source IPv4 mapped as an IPv6 address. eg. 192.168.20.10 would map to ::ffff:192....
Definition networking.c:199
port_protocol_t
port_protocol_t
Possible port types.
Definition networking.h:25
PORT_PROTOCOL_TCP
@ PORT_PROTOCOL_TCP
Definition networking.h:26
PORT_PROTOCOL_OTHER
@ PORT_PROTOCOL_OTHER
Definition networking.h:28
PORT_PROTOCOL_UDP
@ PORT_PROTOCOL_UDP
Definition networking.h:27
addr6_to_str
void addr6_to_str(const struct in6_addr *, char *)
Stringifies an IP address.
Definition networking.c:261
gvm_source_addr6
void gvm_source_addr6(void *)
Gives the source IPv6 address.
Definition networking.c:186
port_in_port_ranges
int port_in_port_ranges(int, port_protocol_t, array_t *)
Checks if a port num is in port ranges array.
Definition networking.c:728
gvm_source_addr6_str
char * gvm_source_addr6_str(void)
Gives the source IPv6 address in string format.
Definition networking.c:225
validate_port_range
int validate_port_range(const char *)
Validate a port range string.
Definition networking.c:460
gvm_resolve_as_addr6
int gvm_resolve_as_addr6(const char *, struct in6_addr *)
Resolves a hostname to an IPv4-mapped IPv6 or IPv6 address.
Definition networking.c:443
gvm_get_outgoing_iface
char * gvm_get_outgoing_iface(struct sockaddr_storage *)
Get the outgoing interface name for a given destination addr.
Definition networking.c:1282
gvm_source_iface_is_set
int gvm_source_iface_is_set(void)
Check if global_source global_source_iface is set.
Definition networking.c:121
gvm_resolve
int gvm_resolve(const char *, void *, int)
Resolves a hostname to an IPv4 or IPv6 address.
Definition networking.c:389
gvm_source_addr_str
char * gvm_source_addr_str(void)
Gives the source IPv4 address in string format.
Definition networking.c:211
gvm_source_iface_init
int gvm_source_iface_init(const char *)
Initializes the source network interface name and related information.
Definition networking.c:64
range
A port range.
Definition networking.h:35
range::comment
gchar * comment
Definition networking.h:36
range::start
int start
Definition networking.h:40
range::exclude
int exclude
Definition networking.h:39
range::id
gchar * id
Definition networking.h:37
range::type
port_protocol_t type
Definition networking.h:41
range::end
int end
Definition networking.h:38