~ubuntu-branches/debian/sid/network-manager/sid

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Michael Biebl
  • Date: 2011-11-03 21:32:50 UTC
  • mfrom: (1.4.6)
  • Revision ID: package-import@ubuntu.com-20111103213250-w49ucjmux3hbwnta
Tags: 0.9.1.95-1
* New upstream release (0.9.2 rc1).
  - Fix connection sharing with newer iptables versions. (Closes: #638995)
  - Fix handling of numeric SSIDs in the keyfile plugin. (Closes: #642912)
* debian/watch: Track .xz tarballs.
* debian/libnm-util2.symbols: Add new symbols for libnm-util.
* debian/patches/04-dont-update-routing-and-dns-for-unmanaged-devices.patch
  - Avoid blowing away existing routes and resolv.conf if NM never managed
    any devices. (Closes: #546893, #624159, #637005, #641904)
* debian/control: Add Build-Depends on libglib2.0-doc for proper
  cross-references in the gtk-doc API documentation.
* Enable default hardening options from dpkg-buildflags.
  - Use buildflags.mk snippet in debian/rules.
  - Add Build-Depends on dpkg-dev (>= 1.6.1).

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
 
 
66
/* libnl-2.0 compat functions */
 
67
#ifdef HAVE_LIBNL2
 
68
 
 
69
/* functions with similar prototypes */
 
70
#define nlmsg_datalen nlmsg_len
 
71
#endif
 
72
 
 
73
 
 
74
/* libnl-1.0 compat functions */
 
75
#ifdef HAVE_LIBNL1
 
76
 
 
77
#define nl_sock nl_handle
 
78
 
 
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
 
87
 
 
88
/* auxiliary functions */
 
89
int nl_compat_error (int);
 
90
 
 
91
/* libnl-1.0 functions with modified prototypes in libnl-2/3*/
 
92
static inline const char * 
 
93
__nl_geterror (int err)
 
94
{
 
95
        /* err is set, can be parsed */
 
96
        return nl_geterror ();
 
97
}
 
98
#define nl_geterror __nl_geterror
 
99
 
 
100
static inline int
 
101
__rtnl_addr_alloc_cache (struct nl_sock *h, struct nl_cache **cache)
 
102
{
 
103
        g_return_val_if_fail (cache != NULL, -EINVAL);
 
104
 
 
105
        *cache = rtnl_addr_alloc_cache (h);
 
106
        return *cache ? 0 : -ENOMEM;
 
107
}
 
108
#define rtnl_addr_alloc_cache __rtnl_addr_alloc_cache
 
109
 
 
110
static inline int
 
111
__rtnl_route_alloc_cache (struct nl_sock *h, int family, int flags, struct nl_cache **cache)
 
112
{
 
113
        g_return_val_if_fail (cache != NULL, -EINVAL);
 
114
 
 
115
        *cache = rtnl_route_alloc_cache (h);
 
116
        return *cache ? 0 : -ENOMEM;
 
117
}
 
118
#define rtnl_route_alloc_cache __rtnl_route_alloc_cache
 
119
 
 
120
static inline int
 
121
__rtnl_link_alloc_cache (struct nl_sock *h, struct nl_cache **cache)
 
122
{
 
123
        g_return_val_if_fail (cache != NULL, -EINVAL);
 
124
 
 
125
        *cache = rtnl_link_alloc_cache (h);
 
126
        return *cache ? 0 : -ENOMEM;
 
127
}
 
128
#define rtnl_link_alloc_cache __rtnl_link_alloc_cache
 
129
 
 
130
static inline int
 
131
__rtnl_route_get_metric (struct rtnl_route *route, int metric, unsigned int *value)
 
132
{
 
133
        g_return_val_if_fail (value != NULL, -EINVAL);
 
134
 
 
135
        *value = rtnl_route_get_metric (route, metric);
 
136
        return 0;
 
137
}
 
138
#define rtnl_route_get_metric __rtnl_route_get_metric
 
139
 
 
140
static inline int
 
141
__rtnl_addr_add (struct nl_sock *h, struct rtnl_addr *addr, int flags)
 
142
{
 
143
        return nl_compat_error (rtnl_addr_add (h, addr, flags));
 
144
}
 
145
#define rtnl_addr_add __rtnl_addr_add
 
146
 
 
147
static inline int
 
148
__rtnl_route_add (struct nl_sock *sk, struct rtnl_route *route, int flags)
 
149
{
 
150
        return nl_compat_error (rtnl_route_add (sk, route, flags));
 
151
}
 
152
#define rtnl_route_add __rtnl_route_add
 
153
 
 
154
static inline int
 
155
rtnl_route_delete (struct nl_sock *h, struct rtnl_route *route, int flags)
 
156
{
 
157
        return nl_compat_error (rtnl_route_del (h, route, flags));
 
158
}
 
159
#define rtnl_route_del rtnl_route_delete
 
160
 
 
161
static inline int
 
162
__rtnl_link_change (struct nl_sock *h, struct rtnl_link *old, struct rtnl_link *tmpl, int flags)
 
163
{
 
164
        return nl_compat_error (rtnl_link_change (h, old, tmpl,flags));
 
165
}
 
166
#define rtnl_link_change __rtnl_link_change
 
167
 
 
168
static inline int
 
169
__nl_cache_include (struct nl_cache *cache, struct nl_object *obj, change_func_t cb, void *data)
 
170
{
 
171
        return nl_cache_include (cache, obj, cb);
 
172
}
 
173
#define nl_cache_include __nl_cache_include
 
174
 
 
175
#define NLE_SUCCESS             0
 
176
#define NLE_FAILURE             1
 
177
#define NLE_INTR                2
 
178
#define NLE_BAD_SOCK            3
 
179
#define NLE_AGAIN               4
 
180
#define NLE_NOMEM               5
 
181
#define NLE_EXIST               6
 
182
#define NLE_INVAL               7
 
183
#define NLE_RANGE               8
 
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
 
200
#define NLE_BUSY                25
 
201
#define NLE_PROTO_MISMATCH      26
 
202
#define NLE_NOACCESS            27
 
203
#define NLE_PERM                28
 
204
#define NLE_PKTLOC_FILE         29
 
205
#endif
 
206
 
 
207
#endif /* NM_NETLINK_COMPAT_H */