Greenbone Vulnerability Management Libraries 22.5.1
networking.h
Go to the documentation of this file.
1/* Copyright (C) 2013-2022 Greenbone AG
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
25#ifndef _GVM_NETWORKING_H
26#define _GVM_NETWORKING_H
27
28#include "array.h" /* for array_t */
29
30#include <netdb.h> /* for struct in6_addr */
31
38typedef enum
39{
44
48struct range
49{
50 gchar *comment;
51 gchar *id;
52 int end;
53 int exclude;
54 int start;
56};
57typedef struct range range_t;
58
59int
60gvm_source_iface_init (const char *);
61
62int
64
65int
66gvm_source_set_socket (int, int, int);
67
68void
69gvm_source_addr (void *);
70
71void
72gvm_source_addr6 (void *);
73
74void
75gvm_source_addr_as_addr6 (struct in6_addr *);
76
77char *
79
80char *
82
83void
84ipv4_as_ipv6 (const struct in_addr *, struct in6_addr *);
85
86void
87addr6_to_str (const struct in6_addr *, char *);
88
89char *
90addr6_as_str (const struct in6_addr *);
91
92void
93sockaddr_as_str (const struct sockaddr_storage *, char *);
94
95int
96gvm_resolve (const char *, void *, int);
97
98GSList *
99gvm_resolve_list (const char *);
100
101int
102gvm_resolve_as_addr6 (const char *, struct in6_addr *);
103
104int
105validate_port_range (const char *);
106
107array_t *
108port_range_ranges (const char *);
109
110int
112
113int
114ipv6_is_enabled (void);
115
116gchar *
117gvm_routethrough (struct sockaddr_storage *, struct sockaddr_storage *);
118
119char *
120gvm_get_outgoing_iface (struct sockaddr_storage *);
121
122#endif /* not _GVM_NETWORKING_H */
Array utilities.
GPtrArray array_t
Definition: array.h:30
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:251
array_t * port_range_ranges(const char *)
Create a range array from a port_range string.
Definition: networking.c:615
void sockaddr_as_str(const struct sockaddr_storage *, char *)
Convert an IP address to string format.
Definition: networking.c:306
void gvm_source_addr(void *)
Gives the source IPv4 address.
Definition: networking.c:182
char * addr6_as_str(const struct in6_addr *)
Stringifies an IP address.
Definition: networking.c:287
int ipv6_is_enabled(void)
Checks if IPv6 support is enabled.
Definition: networking.c:766
gchar * gvm_routethrough(struct sockaddr_storage *, struct sockaddr_storage *)
Get Interface which should be used for routing to destination addr.
Definition: networking.c:1008
int gvm_source_set_socket(int, int, int)
Binds a socket to use the global source address.
Definition: networking.c:144
GSList * gvm_resolve_list(const char *)
Returns a list of addresses that a hostname resolves to.
Definition: networking.c:347
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:207
port_protocol_t
Possible port types.
Definition: networking.h:39
@ PORT_PROTOCOL_TCP
Definition: networking.h:40
@ PORT_PROTOCOL_OTHER
Definition: networking.h:42
@ PORT_PROTOCOL_UDP
Definition: networking.h:41
void addr6_to_str(const struct in6_addr *, char *)
Stringifies an IP address.
Definition: networking.c:269
void gvm_source_addr6(void *)
Gives the source IPv6 address.
Definition: networking.c:194
int port_in_port_ranges(int, port_protocol_t, array_t *)
Checks if a port num is in port ranges array.
Definition: networking.c:742
char * gvm_source_addr6_str(void)
Gives the source IPv6 address in string format.
Definition: networking.c:233
int validate_port_range(const char *)
Validate a port range string.
Definition: networking.c:474
int gvm_resolve_as_addr6(const char *, struct in6_addr *)
Resolves a hostname to an IPv4-mapped IPv6 or IPv6 address.
Definition: networking.c:457
char * gvm_get_outgoing_iface(struct sockaddr_storage *)
Get the outgoing interface name for a given destination addr.
Definition: networking.c:1296
int gvm_source_iface_is_set(void)
Check if global_source global_source_iface is set.
Definition: networking.c:129
int gvm_resolve(const char *, void *, int)
Resolves a hostname to an IPv4 or IPv6 address.
Definition: networking.c:403
char * gvm_source_addr_str(void)
Gives the source IPv4 address in string format.
Definition: networking.c:219
int gvm_source_iface_init(const char *)
Initializes the source network interface name and related information.
Definition: networking.c:72
A port range.
Definition: networking.h:49
gchar * comment
Definition: networking.h:50
int start
Definition: networking.h:54
int exclude
Definition: networking.h:53
gchar * id
Definition: networking.h:51
port_protocol_t type
Definition: networking.h:55
int end
Definition: networking.h:52