OpenVAS Libraries  9.0.1
openvas_networking.h
Go to the documentation of this file.
1 /* openvas-libraries/base
2  * $Id$
3  * Description: OpenVAS Networking related API.
4  *
5  * Authors:
6  * Hani Benhabiles <hani.benhabiles@greenbone.net>
7  *
8  * Copyright:
9  * Copyright (C) 2013 Greenbone Networks GmbH
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25 
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include <arpa/inet.h>
30 #include <net/if.h>
31 #include <sys/types.h>
32 #include <ifaddrs.h>
33 #include <netdb.h>
34 #include <glib.h>
35 #include <errno.h>
36 #include <ctype.h>
37 #include <assert.h>
38 
39 #include "array.h"
40 
41 #ifndef _OPENVAS_NETWORKING_H
42 #define _OPENVAS_NETWORKING_H
43 
50 typedef enum
51 {
56 
60 struct range
61 {
62  gchar *comment; /* Comment. */
63  gchar *id; /* UUID. */
64  int end; /* End port. 0 for single port. */
65  int exclude; /* Whether to exclude range. */
66  int start; /* Start port. */
67  port_protocol_t type; /* Port protocol. */
68 };
69 typedef struct range range_t;
70 
71 int
72 openvas_source_iface_init (const char *);
73 
74 int
76 
77 int
78 openvas_source_set_socket (int, int, int);
79 
80 void
81 openvas_source_addr (void *);
82 
83 void
84 openvas_source_addr6 (void *);
85 
86 void
87 openvas_source_addr_as_addr6 (struct in6_addr *);
88 
89 char *
91 
92 char *
94 
95 void
96 ipv4_as_ipv6 (const struct in_addr *, struct in6_addr *);
97 
98 char *
99 addr6_as_str (const struct in6_addr *);
100 
101 void
102 sockaddr_as_str (const struct sockaddr_storage *, char *);
103 
104 int
105 openvas_resolve (const char *, void *, int);
106 
107 int
108 openvas_resolve_as_addr6 (const char *, struct in6_addr *);
109 
110 int
111 validate_port_range (const char *);
112 
113 array_t*
114 port_range_ranges (const char *);
115 
116 int
118 
119 int
120 ipv6_is_enabled ();
121 
122 #endif /* not _OPENVAS_NETWORKING_H */
void openvas_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.168.20.10.
Definition: openvas_networking.c:178
gchar * id
Definition: openvas_networking.h:63
int openvas_source_iface_init(const char *)
Initializes the source network interface name and related information.
Definition: openvas_networking.c:53
int end
Definition: openvas_networking.h:64
void openvas_source_addr6(void *)
Gives the source IPv6 address.
Definition: openvas_networking.c:165
char * addr6_as_str(const struct in6_addr *)
Definition: openvas_networking.c:234
Definition: openvas_networking.h:52
void openvas_source_addr(void *)
Gives the source IPv4 address.
Definition: openvas_networking.c:153
int validate_port_range(const char *)
Validate a port range string.
Definition: openvas_networking.c:359
Definition: openvas_networking.h:53
char * openvas_source_addr_str(void)
Gives the source IPv4 address in string format.
Definition: openvas_networking.c:190
int openvas_resolve_as_addr6(const char *, struct in6_addr *)
Resolves a hostname to an IPv4-mapped IPv6 or IPv6 address.
Definition: openvas_networking.c:342
int openvas_source_set_socket(int, int, int)
Binds a socket to use the global source address.
Definition: openvas_networking.c:117
int ipv6_is_enabled()
Checks if IPv6 support is enabled.
Definition: openvas_networking.c:614
char * openvas_source_addr6_str(void)
Gives the source IPv6 address in string format.
Definition: openvas_networking.c:204
GPtrArray array_t
Definition: array.h:31
int openvas_resolve(const char *, void *, int)
Resolves a hostname to an IPv4 or IPv6 address.
Definition: openvas_networking.c:288
int port_in_port_ranges(int, port_protocol_t, array_t *)
Checks if a port num is in port ranges array.
Definition: openvas_networking.c:590
port_protocol_t
Possible port types.
Definition: openvas_networking.h:50
A port range.
Definition: openvas_networking.h:60
void sockaddr_as_str(const struct sockaddr_storage *, char *)
Convert an IP address to string format.
Definition: openvas_networking.c:256
array_t * port_range_ranges(const char *)
Create a range array from a port_range string.
Definition: openvas_networking.c:487
int start
Definition: openvas_networking.h:66
int exclude
Definition: openvas_networking.h:65
Definition: openvas_networking.h:54
int openvas_source_iface_is_set(void)
Definition: openvas_networking.c:102
port_protocol_t type
Definition: openvas_networking.h:67
gchar * comment
Definition: openvas_networking.h:62
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.168.10.20.
Definition: openvas_networking.c:222