1
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2
/* NetworkManager -- Network link manager
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License along
15
* with this program; if not, write to the Free Software Foundation, Inc.,
16
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
* Copyright (C) 2011 Caixa Magica Software.
21
#ifndef NM_NETLINK_COMPAT_H
22
#define NM_NETLINK_COMPAT_H
26
#include <netlink/netlink.h>
27
#include <netlink/route/rtnl.h>
28
#include <netlink/route/link.h>
29
#include <netlink/route/route.h>
30
#include <netlink/route/addr.h>
33
#include <netlink/netlink.h>
34
#include <netlink/cache.h>
35
#include <netlink/utils.h>
36
#include <netlink/data.h>
37
#include <netlink/route/rtnl.h>
38
#include <netlink/route/route.h>
39
#include <netlink/route/link.h>
40
#include <netlink/route/nexthop.h>
44
/* libnl-1 API compatibility for libnl-2/3*/
47
struct rtnl_nexthop * nm_netlink_get_nh(struct rtnl_route *);
48
int rtnl_route_get_oif(struct rtnl_route *);
49
int rtnl_route_set_oif(struct rtnl_route *, int);
50
int rtnl_route_set_gateway(struct rtnl_route *, struct nl_addr *);
51
int rtnl_route_get_dst_len(struct rtnl_route *);
52
struct nl_addr * rtnl_route_get_gateway(struct rtnl_route *);
55
/* libnl-2 API compatibility for libnl-3 */
58
__rtnl_link_alloc_cache (struct nl_sock *h, struct nl_cache **cache)
60
return rtnl_link_alloc_cache (h, AF_UNSPEC, cache);
62
#define rtnl_link_alloc_cache __rtnl_link_alloc_cache
65
/* libnl-1.0 compat functions */
68
#define nl_sock nl_handle
70
/* libnl-1.0 functions with similar prototypes */
71
#define nl_socket_alloc nl_handle_alloc
72
#define nl_socket_alloc_cb nl_handle_alloc_cb
73
#define nl_socket_free nl_handle_destroy
74
#define nl_socket_set_passcred nl_set_passcred
75
#define nl_socket_disable_seq_check nl_disable_sequence_check
76
#define rtnl_route_set_priority rtnl_route_set_prio
78
/* auxiliary functions */
79
int nl_compat_error (int);
81
/* libnl-1.0 functions with modified prototypes in libnl-2/3*/
82
static inline const char *
83
__nl_geterror (int err)
85
/* err is set, can be parsed */
86
return nl_geterror ();
88
#define nl_geterror __nl_geterror
91
__rtnl_addr_alloc_cache (struct nl_sock *h, struct nl_cache **cache)
93
g_return_val_if_fail (cache != NULL, -EINVAL);
95
*cache = rtnl_addr_alloc_cache (h);
96
return *cache ? 0 : -ENOMEM;
98
#define rtnl_addr_alloc_cache __rtnl_addr_alloc_cache
101
__rtnl_route_alloc_cache (struct nl_sock *h, int family, int flags, struct nl_cache **cache)
103
g_return_val_if_fail (cache != NULL, -EINVAL);
105
*cache = rtnl_route_alloc_cache (h);
106
return *cache ? 0 : -ENOMEM;
108
#define rtnl_route_alloc_cache __rtnl_route_alloc_cache
111
__rtnl_link_alloc_cache (struct nl_sock *h, struct nl_cache **cache)
113
g_return_val_if_fail (cache != NULL, -EINVAL);
115
*cache = rtnl_link_alloc_cache (h);
116
return *cache ? 0 : -ENOMEM;
118
#define rtnl_link_alloc_cache __rtnl_link_alloc_cache
121
__rtnl_route_get_metric (struct rtnl_route *route, int metric, unsigned int *value)
123
g_return_val_if_fail (value != NULL, -EINVAL);
125
*value = rtnl_route_get_metric (route, metric);
128
#define rtnl_route_get_metric __rtnl_route_get_metric
131
__rtnl_addr_add (struct nl_sock *h, struct rtnl_addr *addr, int flags)
133
return nl_compat_error (rtnl_addr_add (h, addr, flags));
135
#define rtnl_addr_add __rtnl_addr_add
138
rtnl_route_delete (struct nl_sock *h, struct rtnl_route *route, int flags)
140
return nl_compat_error (rtnl_route_del (h, route, flags));
142
#define rtnl_route_del rtnl_route_delete
145
__rtnl_link_change (struct nl_sock *h, struct rtnl_link *old, struct rtnl_link *tmpl, int flags)
147
return nl_compat_error (rtnl_link_change (h, old, tmpl,flags));
149
#define rtnl_link_change __rtnl_link_change
152
__nl_cache_include (struct nl_cache *cache, struct nl_object *obj, change_func_t cb, void *data)
154
return nl_cache_include (cache, obj, cb);
156
#define nl_cache_include __nl_cache_include
158
#define NLE_SUCCESS 0
159
#define NLE_FAILURE 1
161
#define NLE_BAD_SOCK 3
167
#define NLE_MSGSIZE 9
168
#define NLE_OPNOTSUPP 10
169
#define NLE_AF_NOSUPPORT 11
170
#define NLE_OBJ_NOTFOUND 12
171
#define NLE_NOATTR 13
172
#define NLE_MISSING_ATTR 14
173
#define NLE_AF_MISMATCH 15
174
#define NLE_SEQ_MISMATCH 16
175
#define NLE_MSG_OVERFLOW 17
176
#define NLE_MSG_TRUNC 18
177
#define NLE_NOADDR 19
178
#define NLE_SRCRT_NOSUPPORT 20
179
#define NLE_MSG_TOOSHORT 21
180
#define NLE_MSGTYPE_NOSUPPORT 22
181
#define NLE_OBJ_MISMATCH 23
182
#define NLE_NOCACHE 24
184
#define NLE_PROTO_MISMATCH 26
185
#define NLE_NOACCESS 27
187
#define NLE_PKTLOC_FILE 29
190
#endif /* NM_NETLINK_COMPAT_H */