OpenVAS Libraries  7.0.7
openvas_hosts.h
Go to the documentation of this file.
1 /* openvas-libraries/base
2  * $Id$
3  * Description: API (structs and protos) for Hosts objects
4  *
5  * Authors:
6  * Hani Benhabiles <hani.benhabiles@greenbone.net>
7  * Jan-Oliver Wagner <jan-oliver.wagner@greenbone.net>
8  *
9  * Copyright:
10  * Copyright (C) 2013 Greenbone Networks GmbH
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License version 2,
14  * or, at your option, any later version as published by the Free
15  * Software Foundation
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
25  */
26 
35 #ifndef _OPENVAS_HOSTS_H
36 #define _OPENVAS_HOSTS_H
37 
38 #include "openvas_networking.h"
39 
40 #include <glib.h>
41 #include <ctype.h>
42 #include <string.h>
43 #include <stdio.h>
44 #include <stdlib.h>
45 #include <errno.h>
46 #include <arpa/inet.h>
47 #include <netdb.h>
48 
49 /* Static values */
50 
51 enum host_type {
52  HOST_TYPE_NAME = 0, /* Hostname eg. foo */
53  HOST_TYPE_IPV4, /* eg. 192.168.1.1 */
54  HOST_TYPE_CIDR_BLOCK, /* eg. 192.168.15.0/24 */
55  HOST_TYPE_RANGE_SHORT, /* eg. 192.168.15.10-20 */
56  HOST_TYPE_RANGE_LONG, /* eg. 192.168.15.10-192.168.18.3 */
57  HOST_TYPE_IPV6, /* eg. ::1 */
58  HOST_TYPE_CIDR6_BLOCK, /* eg. ::ffee/120 */
59  HOST_TYPE_RANGE6_LONG, /* eg. ::1:200:7-::1:205:500 */
60  HOST_TYPE_RANGE6_SHORT, /* eg. ::1-fe10 */
61  HOST_TYPE_MAX /* Boundary checking. */
62 };
63 
64 /* Typedefs */
67 
68 /* Data structures. */
69 
77 {
78  union {
79  gchar *name; /* Hostname. */
80  struct in_addr addr; /* IPv4 address */
81  struct in6_addr addr6; /* IPv6 address */
82  };
83  enum host_type type; /* HOST_TYPE_NAME, HOST_TYPE_IPV4 or HOST_TYPE_IPV6. */
84 };
85 
93 {
94  gchar *orig_str; /* Original hosts definition string. */
95  GList *hosts; /* Hosts objects list. */
96  GList *current; /* Current host object in iteration. */
97  unsigned int count; /* Number of single host objects in hosts list. */
98  unsigned int removed; /* Number of duplicate/excluded values. */
99 };
100 
101 /* Function prototypes. */
102 
103  /* openvas_hosts_t related */
105 openvas_hosts_new (const gchar *);
106 
108 openvas_hosts_new_with_max (const gchar *, unsigned int);
109 
112 
113 void
115 
116 void
118 
119 void
121 
122 void
124 
125 int
126 openvas_hosts_exclude (openvas_hosts_t *, const gchar *, int);
127 
128 int
130 
131 int
133 
134 unsigned int
136 
137 unsigned int
139 
140  /* openvas_host_t related */
141 
142 int
143 openvas_host_in_hosts (const openvas_host_t *, const struct in6_addr *,
144  const openvas_hosts_t *);
145 
146 gchar *
148 
149 int
151 
152 gchar *
154 
155 int
156 openvas_host_resolve (const openvas_host_t *, void *, int);
157 
158 int
159 openvas_host_get_addr6 (const openvas_host_t *, struct in6_addr *);
160 
161 #endif /* not _OPENVAS_HOSTS_H */