Greenbone Vulnerability Management Libraries: base/networking.h Source File

Greenbone Vulnerability Management Libraries 23.7.0

networking.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2013-2023 Greenbone AG
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later
4 */
5
10
11#ifndef _GVM_BASE_NETWORKING_H
12#define _GVM_BASE_NETWORKING_H
13
14#include "array.h" /* for array_t */
15
16#include <netdb.h> /* for struct in6_addr */
17
24 typedef enum
25{
26 PORT_PROTOCOL_TCP = 0,
27 PORT_PROTOCOL_UDP = 1,
28 PORT_PROTOCOL_OTHER = 2
29} port_protocol_t;
30
34 struct range
35{
36 gchar *comment;
37 gchar *id;
38 int end;
39 int exclude;
40 int start;
41 port_protocol_t type;
42};
43 typedef struct range range_t;
44
45int
46 gvm_source_iface_init (const char *);
47
48int
49 gvm_source_iface_is_set (void);
50
51int
52 gvm_source_set_socket (int, int, int);
53
54void
55 gvm_source_addr (void *);
56
57void
58 gvm_source_addr6 (void *);
59
60void
61 gvm_source_addr_as_addr6 (struct in6_addr *);
62
63char *
64 gvm_source_addr_str (void);
65
66char *
67 gvm_source_addr6_str (void);
68
69void
70 ipv4_as_ipv6 (const struct in_addr *, struct in6_addr *);
71
72void
73 addr6_to_str (const struct in6_addr *, char *);
74
75char *
76 addr6_as_str (const struct in6_addr *);
77
78void
79 sockaddr_as_str (const struct sockaddr_storage *, char *);
80
81int
82 gvm_resolve (const char *, void *, int);
83
84GSList *
85 gvm_resolve_list (const char *);
86
87int
88 gvm_resolve_as_addr6 (const char *, struct in6_addr *);
89
90int
91 validate_port_range (const char *);
92
93 array_t *
94 port_range_ranges (const char *);
95
96int
97 port_in_port_ranges (int, port_protocol_t, array_t *);
98
99int
100 ipv6_is_enabled (void);
101
102gchar *
103 gvm_routethrough (struct sockaddr_storage *, struct sockaddr_storage *);
104
105char *
106 gvm_get_outgoing_iface (struct sockaddr_storage *);
107
108#endif /* not _GVM_BASE_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:1017
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
range_t
struct range range_t
Definition networking.h:43
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:1297
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