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
66
/* libnl-2.0 compat functions */
69
/* functions with similar prototypes */
70
#define nlmsg_datalen nlmsg_len
74
/* libnl-1.0 compat functions */
77
#define nl_sock nl_handle
79
/* libnl-1.0 functions with similar prototypes */
80
#define nl_socket_alloc nl_handle_alloc
81
#define nl_socket_alloc_cb nl_handle_alloc_cb
82
#define nl_socket_free nl_handle_destroy
83
#define nl_socket_set_passcred nl_set_passcred
84
#define nl_socket_disable_seq_check nl_disable_sequence_check
85
#define rtnl_route_set_priority rtnl_route_set_prio
86
#define nlmsg_datalen nlmsg_len
88
/* auxiliary functions */
89
int nl_compat_error (int);
91
/* libnl-1.0 functions with modified prototypes in libnl-2/3*/
92
static inline const char *
93
__nl_geterror (int err)
95
/* err is set, can be parsed */
96
return nl_geterror ();
98
#define nl_geterror __nl_geterror
101
__rtnl_addr_alloc_cache (struct nl_sock *h, struct nl_cache **cache)
103
g_return_val_if_fail (cache != NULL, -EINVAL);
105
*cache = rtnl_addr_alloc_cache (h);
106
return *cache ? 0 : -ENOMEM;
108
#define rtnl_addr_alloc_cache __rtnl_addr_alloc_cache
111
__rtnl_route_alloc_cache (struct nl_sock *h, int family, int flags, struct nl_cache **cache)
113
g_return_val_if_fail (cache != NULL, -EINVAL);
115
*cache = rtnl_route_alloc_cache (h);
116
return *cache ? 0 : -ENOMEM;
118
#define rtnl_route_alloc_cache __rtnl_route_alloc_cache
121
__rtnl_link_alloc_cache (struct nl_sock *h, struct nl_cache **cache)
123
g_return_val_if_fail (cache != NULL, -EINVAL);
125
*cache = rtnl_link_alloc_cache (h);
126
return *cache ? 0 : -ENOMEM;
128
#define rtnl_link_alloc_cache __rtnl_link_alloc_cache
131
__rtnl_route_get_metric (struct rtnl_route *route, int metric, unsigned int *value)
133
g_return_val_if_fail (value != NULL, -EINVAL);
135
*value = rtnl_route_get_metric (route, metric);
138
#define rtnl_route_get_metric __rtnl_route_get_metric
141
__rtnl_addr_add (struct nl_sock *h, struct rtnl_addr *addr, int flags)
143
return nl_compat_error (rtnl_addr_add (h, addr, flags));
145
#define rtnl_addr_add __rtnl_addr_add
148
__rtnl_route_add (struct nl_sock *sk, struct rtnl_route *route, int flags)
150
return nl_compat_error (rtnl_route_add (sk, route, flags));
152
#define rtnl_route_add __rtnl_route_add
155
rtnl_route_delete (struct nl_sock *h, struct rtnl_route *route, int flags)
157
return nl_compat_error (rtnl_route_del (h, route, flags));
159
#define rtnl_route_del rtnl_route_delete
162
__rtnl_link_change (struct nl_sock *h, struct rtnl_link *old, struct rtnl_link *tmpl, int flags)
164
return nl_compat_error (rtnl_link_change (h, old, tmpl,flags));
166
#define rtnl_link_change __rtnl_link_change
169
__nl_cache_include (struct nl_cache *cache, struct nl_object *obj, change_func_t cb, void *data)
171
return nl_cache_include (cache, obj, cb);
173
#define nl_cache_include __nl_cache_include
175
#define NLE_SUCCESS 0
176
#define NLE_FAILURE 1
178
#define NLE_BAD_SOCK 3
184
#define NLE_MSGSIZE 9
185
#define NLE_OPNOTSUPP 10
186
#define NLE_AF_NOSUPPORT 11
187
#define NLE_OBJ_NOTFOUND 12
188
#define NLE_NOATTR 13
189
#define NLE_MISSING_ATTR 14
190
#define NLE_AF_MISMATCH 15
191
#define NLE_SEQ_MISMATCH 16
192
#define NLE_MSG_OVERFLOW 17
193
#define NLE_MSG_TRUNC 18
194
#define NLE_NOADDR 19
195
#define NLE_SRCRT_NOSUPPORT 20
196
#define NLE_MSG_TOOSHORT 21
197
#define NLE_MSGTYPE_NOSUPPORT 22
198
#define NLE_OBJ_MISMATCH 23
199
#define NLE_NOCACHE 24
201
#define NLE_PROTO_MISMATCH 26
202
#define NLE_NOACCESS 27
204
#define NLE_PKTLOC_FILE 29
207
#endif /* NM_NETLINK_COMPAT_H */