Greenbone Vulnerability Management Libraries  22.8.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 
11 #ifndef _GVM_NETWORKING_H
12 #define _GVM_NETWORKING_H
13 
14 #include "array.h" /* for array_t */
15 
16 #include <netdb.h> /* for struct in6_addr */
17 
24 typedef enum
25 {
30 
34 struct range
35 {
36  gchar *comment;
37  gchar *id;
38  int end;
39  int exclude;
40  int start;
42 };
43 typedef struct range range_t;
44 
45 int
46 gvm_source_iface_init (const char *);
47 
48 int
50 
51 int
52 gvm_source_set_socket (int, int, int);
53 
54 void
55 gvm_source_addr (void *);
56 
57 void
58 gvm_source_addr6 (void *);
59 
60 void
61 gvm_source_addr_as_addr6 (struct in6_addr *);
62 
63 char *
64 gvm_source_addr_str (void);
65 
66 char *
68 
69 void
70 ipv4_as_ipv6 (const struct in_addr *, struct in6_addr *);
71 
72 void
73 addr6_to_str (const struct in6_addr *, char *);
74 
75 char *
76 addr6_as_str (const struct in6_addr *);
77 
78 void
79 sockaddr_as_str (const struct sockaddr_storage *, char *);
80 
81 int
82 gvm_resolve (const char *, void *, int);
83 
84 GSList *
85 gvm_resolve_list (const char *);
86 
87 int
88 gvm_resolve_as_addr6 (const char *, struct in6_addr *);
89 
90 int
91 validate_port_range (const char *);
92 
93 array_t *
94 port_range_ranges (const char *);
95 
96 int
98 
99 int
100 ipv6_is_enabled (void);
101 
102 gchar *
103 gvm_routethrough (struct sockaddr_storage *, struct sockaddr_storage *);
104 
105 char *
106 gvm_get_outgoing_iface (struct sockaddr_storage *);
107 
108 #endif /* not _GVM_NETWORKING_H */
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
void gvm_source_addr(void *)
Gives the source IPv4 address.
Definition: networking.c:174
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_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_resolve
int gvm_resolve(const char *, void *, int)
Resolves a hostname to an IPv4 or IPv6 address.
Definition: networking.c:389
array_t
GPtrArray array_t
Definition: array.h:16
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_source_addr6
void gvm_source_addr6(void *)
Gives the source IPv6 address.
Definition: networking.c:186
gvm_source_iface_init
int gvm_source_iface_init(const char *)
Initializes the source network interface name and related information.
Definition: networking.c:64
sockaddr_as_str
void sockaddr_as_str(const struct sockaddr_storage *, char *)
Convert an IP address to string format.
Definition: networking.c:298
array.h
Array utilities.
range::type
port_protocol_t type
Definition: networking.h:41
port_protocol_t
port_protocol_t
Possible port types.
Definition: networking.h:25
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
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
addr6_to_str
void addr6_to_str(const struct in6_addr *, char *)
Stringifies an IP address.
Definition: networking.c:261
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
PORT_PROTOCOL_UDP
@ PORT_PROTOCOL_UDP
Definition: networking.h:27
range::exclude
int exclude
Definition: networking.h:39
range::id
gchar * id
Definition: networking.h:37
range::comment
gchar * comment
Definition: networking.h:36
PORT_PROTOCOL_TCP
@ PORT_PROTOCOL_TCP
Definition: networking.h:26
range::end
int end
Definition: networking.h:38
range
A port range.
Definition: networking.h:35
gvm_source_addr_str
char * gvm_source_addr_str(void)
Gives the source IPv4 address in string format.
Definition: networking.c:211
port_range_ranges
array_t * port_range_ranges(const char *)
Create a range array from a port_range string.
Definition: networking.c:601
range::start
int start
Definition: networking.h:40
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
validate_port_range
int validate_port_range(const char *)
Validate a port range string.
Definition: networking.c:460
addr6_as_str
char * addr6_as_str(const struct in6_addr *)
Stringifies an IP address.
Definition: networking.c:279
gvm_source_addr6_str
char * gvm_source_addr6_str(void)
Gives the source IPv6 address in string format.
Definition: networking.c:225
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_OTHER
@ PORT_PROTOCOL_OTHER
Definition: networking.h:28
ipv6_is_enabled
int ipv6_is_enabled(void)
Checks if IPv6 support is enabled.
Definition: networking.c:752