retnetlink: Add rtnetlink_destroy function.
[sliver-openvswitch.git] / lib / rtnetlink-route.h
1 /*
2  * Copyright (c) 2009 Nicira Networks.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef RTNETLINK_ROUTE_H
18 #define RTNETLINK_ROUTE_H 1
19
20 #include <stdbool.h>
21 #include <stdint.h>
22
23 struct ofpbuf;
24 struct rtnetlink_notifier;
25
26 /* A digested version of a route message sent down by the kernel to indicate
27  * that a route has changed. */
28 struct rtnetlink_route_change {
29     /* Copied from struct nlmsghdr. */
30     int nlmsg_type;               /* e.g. RTM_NEWROUTE, RTM_DELROUTE. */
31
32     /* Copied from struct rtmsg. */
33     unsigned char rtm_dst_len;
34
35     /* Extracted from Netlink attributes. */
36     uint32_t rta_dst; /* Destination in host byte order. 0 if missing. */
37     int rta_oif;      /* Output interface index. */
38 };
39
40 /* Function called to report that a route has changed.  'change' describes
41  * the specific change.  It may be null, in which case the function must assume
42  * everything has changed.  'aux' is as specified in the call to
43  * rtnetlink_route_notifier_register(). */
44 typedef
45 void rtnetlink_route_notify_func(const struct rtnetlink_route_change *change,
46                                  void *aux);
47
48 bool rtnetlink_route_parse(struct ofpbuf *, struct rtnetlink_route_change *);
49 int rtnetlink_route_notifier_register(struct rtnetlink_notifier *,
50                                      rtnetlink_route_notify_func *, void *aux);
51 void rtnetlink_route_notifier_unregister(struct rtnetlink_notifier *);
52 void rtnetlink_route_notifier_run(void);
53 void rtnetlink_route_notifier_wait(void);
54
55 #endif /* rtnetlink-route.h */