~vcs-imports/network-manager/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Copyright (C) 2011 Red Hat, Inc.
 */

#ifndef NM_NETLINK_UTILS_H
#define NM_NETLINK_UTILS_H

#include <netlink/route/route.h>

gboolean nm_netlink_find_address (int ifindex,
                                  int family,
                                  void *addr,  /* struct in_addr or struct in6_addr */
                                  int prefix_);

typedef enum {
	NMNL_PROP_INVALID = 0,
	NMNL_PROP_PROT,
	NMNL_PROP_SCOPE,
	NMNL_PROP_TABLE,
	NMNL_PROP_PRIO,
} NmNlProp;

struct rtnl_route * nm_netlink_route_new (int ifindex,
                                          int family,
                                          int mss,
                                          ...) __attribute__((__sentinel__));

int nm_netlink_route4_add (struct rtnl_route *route,
                           guint32 *dst,
                           int prefix,
                           guint32 *gw,
                           int flags);

int nm_netlink_route6_add (struct rtnl_route *route,
                          const struct in6_addr *dst,
                          int prefix,
                          const struct in6_addr *gw,
                          int flags);

gboolean nm_netlink_route_delete (struct rtnl_route *route);

/**
 * NlRouteForeachFunc:
 * @route: the route being processed
 * @dst: the route's destination address
 * @iface: the interface name of the index passed to nm_netlink_foreach_route()
 * @in_family: the address family passed to nm_netlink_foreach_route()
 * @user_data: the user data pointer passed to nm_netlink_foreach_route()
 *
 * Returns: a route to return to the caller of nm_netlink_foreach_route() which
 * terminates routing table iteration, or NULL to continue iterating the
 * routing table.
 **/
typedef struct rtnl_route * (*NlRouteForeachFunc) (struct rtnl_route *route,
                                                   struct nl_addr *dst,
                                                   const char *iface,
                                                   gpointer user_data);

struct rtnl_route * nm_netlink_foreach_route (int ifindex,
                                              int family,
                                              int scope,
                                              gboolean ignore_inet6_ll_mc,
                                              NlRouteForeachFunc callback,
                                              gpointer user_data);

#endif  /* NM_NETLINK_UTILS_H */