OpenVPN
networking.h
Go to the documentation of this file.
1 /*
2  * Generic interface to platform specific networking code
3  *
4  * Copyright (C) 2016-2018 Antonio Quartulli <a@unstable.cc>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2
8  * as published by the Free Software Foundation.
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 (see the file COPYING included with this
17  * distribution); if not, write to the Free Software Foundation, Inc.,
18  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 
21 #ifndef NETWORKING_H_
22 #define NETWORKING_H_
23 
24 #include "syshead.h"
25 
26 struct context;
27 
28 #ifdef ENABLE_SITNL
29 #include "networking_sitnl.h"
30 #elif ENABLE_IPROUTE
31 #include "networking_iproute2.h"
32 #else
33 /* define mock types to ensure code builds on any platform */
34 typedef void * openvpn_net_ctx_t;
35 typedef void * openvpn_net_iface_t;
36 
37 static inline int
39 {
40  return 0;
41 }
42 #endif
43 
44 #if defined(ENABLE_SITNL) || defined(ENABLE_IPROUTE)
45 
54 int net_ctx_init(struct context *c, openvpn_net_ctx_t *ctx);
55 
65 int net_iface_up(openvpn_net_ctx_t *ctx, const openvpn_net_iface_t *iface,
66  bool up);
67 
77 int net_iface_mtu_set(openvpn_net_ctx_t *ctx,
78  const openvpn_net_iface_t *iface, uint32_t mtu);
79 
91 int net_addr_v4_add(openvpn_net_ctx_t *ctx, const openvpn_net_iface_t *iface,
92  const in_addr_t *addr, int prefixlen,
93  const in_addr_t *broadcast);
94 
106 int net_addr_v6_add(openvpn_net_ctx_t *ctx, const openvpn_net_iface_t *iface,
107  const struct in6_addr *addr, int prefixlen);
108 
118 int net_addr_v4_del(openvpn_net_ctx_t *ctx, const openvpn_net_iface_t *iface,
119  const in_addr_t *addr, int prefixlen);
120 
130 int net_addr_v6_del(openvpn_net_ctx_t *ctx, const openvpn_net_iface_t *iface,
131  const struct in6_addr *addr, int prefixlen);
132 
143 int net_addr_ptp_v4_add(openvpn_net_ctx_t *ctx,
144  const openvpn_net_iface_t *iface,
145  const in_addr_t *local, const in_addr_t *remote);
146 
157 int net_addr_ptp_v4_del(openvpn_net_ctx_t *ctx,
158  const openvpn_net_iface_t *iface,
159  const in_addr_t *local, const in_addr_t *remote);
160 
161 
176 int net_route_v4_add(openvpn_net_ctx_t *ctx, const in_addr_t *dst,
177  int prefixlen, const in_addr_t *gw,
178  const openvpn_net_iface_t *iface, uint32_t table,
179  int metric);
180 
195 int net_route_v6_add(openvpn_net_ctx_t *ctx, const struct in6_addr *dst,
196  int prefixlen, const struct in6_addr *gw,
197  const openvpn_net_iface_t *iface,
198  uint32_t table, int metric);
199 
214 int net_route_v4_del(openvpn_net_ctx_t *ctx, const in_addr_t *dst,
215  int prefixlen, const in_addr_t *gw,
216  const openvpn_net_iface_t *iface, uint32_t table,
217  int metric);
218 
233 int net_route_v6_del(openvpn_net_ctx_t *ctx, const struct in6_addr *dst,
234  int prefixlen, const struct in6_addr *gw,
235  const openvpn_net_iface_t *iface,
236  uint32_t table, int metric);
237 
250 int net_route_v4_best_gw(openvpn_net_ctx_t *ctx, const in_addr_t *dst,
251  int prefixlen, in_addr_t *best_gw,
252  openvpn_net_iface_t *best_iface);
253 
266 int net_route_v6_best_gw(openvpn_net_ctx_t *ctx, const struct in6_addr *dst,
267  int prefixlen, struct in6_addr *best_gw,
268  openvpn_net_iface_t *best_iface);
269 
270 #endif /* ENABLE_SITNL || ENABLE_IPROUTE */
271 
272 #endif /* NETWORKING_H_ */
Contains all state information for one tunnel.
Definition: openvpn.h:500
static char * iface
#define in_addr_t
Definition: config-msvc.h:104
void * openvpn_net_iface_t
Definition: networking.h:35
void * openvpn_net_ctx_t
Definition: networking.h:26
static int net_ctx_init(struct context *c, openvpn_net_ctx_t *ctx)
Definition: networking.h:38
unsigned __int32 uint32_t
Definition: config-msvc.h:121
char * dst
Definition: compat-lz4.h:455