Greenbone Vulnerability Management Libraries  21.4.2
networking.h
Go to the documentation of this file.
1 /* Copyright (C) 2013-2021 Greenbone Networks GmbH
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 
38 typedef enum
39 {
44 
48 struct range
49 {
50  gchar *comment;
51  gchar *id;
52  int end;
53  int exclude;
54  int start;
56 };
57 typedef struct range range_t;
58 
59 int
60 gvm_source_iface_init (const char *);
61 
62 int
64 
65 int
66 gvm_source_set_socket (int, int, int);
67 
68 void
69 gvm_source_addr (void *);
70 
71 void
72 gvm_source_addr6 (void *);
73 
74 void
75 gvm_source_addr_as_addr6 (struct in6_addr *);
76 
77 char *
78 gvm_source_addr_str (void);
79 
80 char *
82 
83 void
84 ipv4_as_ipv6 (const struct in_addr *, struct in6_addr *);
85 
86 void
87 addr6_to_str (const struct in6_addr *, char *);
88 
89 char *
90 addr6_as_str (const struct in6_addr *);
91 
92 void
93 sockaddr_as_str (const struct sockaddr_storage *, char *);
94 
95 int
96 gvm_resolve (const char *, void *, int);
97 
98 GSList *
99 gvm_resolve_list (const char *);
100 
101 int
102 gvm_resolve_as_addr6 (const char *, struct in6_addr *);
103 
104 int
105 validate_port_range (const char *);
106 
107 array_t *
108 port_range_ranges (const char *);
109 
110 int
112 
113 int
114 ipv6_is_enabled ();
115 
116 gchar *
117 gvm_routethrough (struct sockaddr_storage *, struct sockaddr_storage *);
118 
119 #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:248
void sockaddr_as_str(const struct sockaddr_storage *, char *)
Convert an IP address to string format.
Definition: networking.c:303
void gvm_source_addr(void *)
Gives the source IPv4 address.
Definition: networking.c:179
char * addr6_as_str(const struct in6_addr *)
Stringifies an IP address.
Definition: networking.c:284
int ipv6_is_enabled()
Checks if IPv6 support is enabled.
Definition: networking.c:757
GSList * gvm_resolve_list(const char *)
Returns a list of addresses that a hostname resolves to.
Definition: networking.c:344
int gvm_source_set_socket(int, int, int)
Binds a socket to use the global source address.
Definition: networking.c:141
array_t * port_range_ranges(const char *)
Create a range array from a port_range string.
Definition: networking.c:606
char * gvm_source_addr_str(void)
Gives the source IPv4 address in string format.
Definition: networking.c:216
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:204
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
char * gvm_source_addr6_str(void)
Gives the source IPv6 address in string format.
Definition: networking.c:230
void addr6_to_str(const struct in6_addr *, char *)
Stringifies an IP address.
Definition: networking.c:266
void gvm_source_addr6(void *)
Gives the source IPv6 address.
Definition: networking.c:191
int port_in_port_ranges(int, port_protocol_t, array_t *)
Checks if a port num is in port ranges array.
Definition: networking.c:733
int validate_port_range(const char *)
Validate a port range string.
Definition: networking.c:465
int gvm_resolve_as_addr6(const char *, struct in6_addr *)
Resolves a hostname to an IPv4-mapped IPv6 or IPv6 address.
Definition: networking.c:448
int gvm_source_iface_is_set(void)
Check if global_source global_source_iface is set.
Definition: networking.c:126
int gvm_resolve(const char *, void *, int)
Resolves a hostname to an IPv4 or IPv6 address.
Definition: networking.c:394
int gvm_source_iface_init(const char *)
Initializes the source network interface name and related information.
Definition: networking.c:72
gchar * gvm_routethrough(struct sockaddr_storage *, struct sockaddr_storage *)
Get Interface which should be used for routing to destination addr.
Definition: networking.c:999
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