OpenVAS Libraries  8.0.3
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 
47 struct range
48 {
49  gchar *comment; /* Comment. */
50  int end; /* End port. 0 for single port. */
51  int exclude; /* Whether to exclude range. */
52  gchar *id; /* UUID. */
53  int start; /* Start port. */
54  int type; /* Port protocol. */
55 };
56 typedef struct range range_t;
57 
64 typedef enum
65 {
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 int
102 openvas_resolve (const char *, void *, int);
103 
104 int
105 openvas_resolve_as_addr6 (const char *, struct in6_addr *);
106 
107 int
108 validate_port_range (const char *);
109 
110 array_t*
111 port_range_ranges (const char *);
112 
113 int
115 
116 char *
117 openvas_ssh_public_from_private (const char *, const char *);
118 
119 char *
120 openvas_ssh_pkcs8_decrypt (const char *, const char *);
121 #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:184
gchar * id
Definition: openvas_networking.h:52
int openvas_source_iface_init(const char *)
Initializes the source network interface name and related information.
Definition: openvas_networking.c:59
int end
Definition: openvas_networking.h:50
void openvas_source_addr6(void *)
Gives the source IPv6 address.
Definition: openvas_networking.c:171
char * addr6_as_str(const struct in6_addr *)
Definition: openvas_networking.c:240
char * openvas_ssh_public_from_private(const char *, const char *)
Exports a base64 encoded public key from a private key and its passphrase.
Definition: openvas_networking.c:630
int type
Definition: openvas_networking.h:54
Definition: openvas_networking.h:66
void openvas_source_addr(void *)
Gives the source IPv4 address.
Definition: openvas_networking.c:159
int validate_port_range(const char *)
Validate a port range string.
Definition: openvas_networking.c:337
Definition: openvas_networking.h:67
char * openvas_source_addr_str(void)
Gives the source IPv4 address in string format.
Definition: openvas_networking.c:196
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:320
int openvas_source_set_socket(int, int, int)
Binds a socket to use the global source address.
Definition: openvas_networking.c:123
char * openvas_source_addr6_str(void)
Gives the source IPv6 address in string format.
Definition: openvas_networking.c:210
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:266
char * openvas_ssh_pkcs8_decrypt(const char *, const char *)
Decrypts a base64 encrypted ssh private key.
Definition: openvas_networking.c:592
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:565
port_protocol_t
Possible port types.
Definition: openvas_networking.h:64
A port range.
Definition: openvas_networking.h:47
array_t * port_range_ranges(const char *)
Create a range array from a port_range string.
Definition: openvas_networking.c:465
int start
Definition: openvas_networking.h:53
int exclude
Definition: openvas_networking.h:51
Definition: openvas_networking.h:68
int openvas_source_iface_is_set(void)
Definition: openvas_networking.c:108
gchar * comment
Definition: openvas_networking.h:49
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:228