~ubuntu-branches/ubuntu/oneiric/network-manager/oneiric

« back to all changes in this revision

Viewing changes to src/nm-netlink-compat.h

  • Committer: Bazaar Package Importer
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2011-08-08 10:17:28 UTC
  • Revision ID: james.westby@ubuntu.com-20110808101728-nbhqa7aztcwetla2
Tags: 0.8.9997+git.20110721t045648.36db194-0ubuntu2
* debian/control: bump libnl Build-Depends to libnl3-dev.
* debian/patches/libnl3-port.patch: backport changes from NM's libnl3 git
  branch to port to libnl3 APIs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
 
2
/* NetworkManager -- Network link manager
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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.
 
17
 *
 
18
 * Copyright (C) 2011 Caixa Magica Software.
 
19
 */
 
20
 
 
21
#ifndef NM_NETLINK_COMPAT_H
 
22
#define NM_NETLINK_COMPAT_H
 
23
 
 
24
#include <errno.h>
 
25
 
 
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>
 
31
 
 
32
 
 
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>
 
41
 
 
42
#include <config.h>
 
43
 
 
44
/* libnl-1 API compatibility for libnl-2/3*/
 
45
#ifndef HAVE_LIBNL1
 
46
 
 
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 *);
 
53
#endif
 
54
 
 
55
/* libnl-2 API compatibility for libnl-3 */
 
56
#ifdef HAVE_LIBNL3
 
57
static inline int
 
58
__rtnl_link_alloc_cache (struct nl_sock *h, struct nl_cache **cache)
 
59
{
 
60
       return rtnl_link_alloc_cache (h, AF_UNSPEC, cache);
 
61
}
 
62
#define rtnl_link_alloc_cache __rtnl_link_alloc_cache
 
63
#endif
 
64
 
 
65
/* libnl-1.0 compat functions */
 
66
#ifdef HAVE_LIBNL1
 
67
 
 
68
#define nl_sock nl_handle
 
69
 
 
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
 
77
 
 
78
/* auxiliary functions */
 
79
int nl_compat_error (int);
 
80
 
 
81
/* libnl-1.0 functions with modified prototypes in libnl-2/3*/
 
82
static inline const char * 
 
83
__nl_geterror (int err)
 
84
{
 
85
        /* err is set, can be parsed */
 
86
        return nl_geterror ();
 
87
}
 
88
#define nl_geterror __nl_geterror
 
89
 
 
90
static inline int
 
91
__rtnl_addr_alloc_cache (struct nl_sock *h, struct nl_cache **cache)
 
92
{
 
93
        g_return_val_if_fail (cache != NULL, -EINVAL);
 
94
 
 
95
        *cache = rtnl_addr_alloc_cache (h);
 
96
        return *cache ? 0 : -ENOMEM;
 
97
}
 
98
#define rtnl_addr_alloc_cache __rtnl_addr_alloc_cache
 
99
 
 
100
static inline int
 
101
__rtnl_route_alloc_cache (struct nl_sock *h, int family, int flags, struct nl_cache **cache)
 
102
{
 
103
        g_return_val_if_fail (cache != NULL, -EINVAL);
 
104
 
 
105
        *cache = rtnl_route_alloc_cache (h);
 
106
        return *cache ? 0 : -ENOMEM;
 
107
}
 
108
#define rtnl_route_alloc_cache __rtnl_route_alloc_cache
 
109
 
 
110
static inline int
 
111
__rtnl_link_alloc_cache (struct nl_sock *h, struct nl_cache **cache)
 
112
{
 
113
        g_return_val_if_fail (cache != NULL, -EINVAL);
 
114
 
 
115
        *cache = rtnl_link_alloc_cache (h);
 
116
        return *cache ? 0 : -ENOMEM;
 
117
}
 
118
#define rtnl_link_alloc_cache __rtnl_link_alloc_cache
 
119
 
 
120
static inline int
 
121
__rtnl_route_get_metric (struct rtnl_route *route, int metric, unsigned int *value)
 
122
{
 
123
        g_return_val_if_fail (value != NULL, -EINVAL);
 
124
 
 
125
        *value = rtnl_route_get_metric (route, metric);
 
126
        return 0;
 
127
}
 
128
#define rtnl_route_get_metric __rtnl_route_get_metric
 
129
 
 
130
static inline int
 
131
__rtnl_addr_add (struct nl_sock *h, struct rtnl_addr *addr, int flags)
 
132
{
 
133
        return nl_compat_error (rtnl_addr_add (h, addr, flags));
 
134
}
 
135
#define rtnl_addr_add __rtnl_addr_add
 
136
 
 
137
static inline int
 
138
rtnl_route_delete (struct nl_sock *h, struct rtnl_route *route, int flags)
 
139
{
 
140
        return nl_compat_error (rtnl_route_del (h, route, flags));
 
141
}
 
142
#define rtnl_route_del rtnl_route_delete
 
143
 
 
144
static inline int
 
145
__rtnl_link_change (struct nl_sock *h, struct rtnl_link *old, struct rtnl_link *tmpl, int flags)
 
146
{
 
147
        return nl_compat_error (rtnl_link_change (h, old, tmpl,flags));
 
148
}
 
149
#define rtnl_link_change __rtnl_link_change
 
150
 
 
151
static inline int
 
152
__nl_cache_include (struct nl_cache *cache, struct nl_object *obj, change_func_t cb, void *data)
 
153
{
 
154
        return nl_cache_include (cache, obj, cb);
 
155
}
 
156
#define nl_cache_include __nl_cache_include
 
157
 
 
158
#define NLE_SUCCESS             0
 
159
#define NLE_FAILURE             1
 
160
#define NLE_INTR                2
 
161
#define NLE_BAD_SOCK            3
 
162
#define NLE_AGAIN               4
 
163
#define NLE_NOMEM               5
 
164
#define NLE_EXIST               6
 
165
#define NLE_INVAL               7
 
166
#define NLE_RANGE               8
 
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
 
183
#define NLE_BUSY                25
 
184
#define NLE_PROTO_MISMATCH      26
 
185
#define NLE_NOACCESS            27
 
186
#define NLE_PERM                28
 
187
#define NLE_PKTLOC_FILE         29
 
188
#endif
 
189
 
 
190
#endif /* NM_NETLINK_COMPAT_H */