Prepare Open vSwitch 1.1.2 release.
[sliver-openvswitch.git] / lib / rtnetlink.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_H
18 #define RTNETLINK_H 1
19
20 /* These functions are Linux specific, so they should be used directly only by
21  * Linux-specific code. */
22
23 #include "list.h"
24
25 struct rtnetlink;
26 struct nlattr;
27 struct ofpbuf;
28
29 /* Function called to report rtnetlink notifications.  'change' describes the
30  * specific change filled out by an rtnetlink_parse_func.  It may be null if
31  * the buffer of change information overflowed, in which case the function must
32  * assume that everything may have changed. 'aux' is as specified in
33  * rtnetlink_notifier_register().
34  */
35 typedef void rtnetlink_notify_func(const void *change, void *aux);
36
37 /* Function called to parse incoming rtnetlink notifications.  The 'buf'
38  * message should be parsed into 'change' as specified in rtnetlink_create().
39  */
40 typedef bool rtnetlink_parse_func(struct ofpbuf *buf, void *change);
41
42 struct rtnetlink_notifier {
43     struct list node;
44     rtnetlink_notify_func *cb;
45     void *aux;
46 };
47
48 struct rtnetlink *rtnetlink_create(int multicast_group,
49                                    rtnetlink_parse_func *,
50                                    void *change);
51 void rtnetlink_destroy(struct rtnetlink *rtn);
52 int rtnetlink_notifier_register(struct rtnetlink *,
53                                 struct rtnetlink_notifier *,
54                                 rtnetlink_notify_func *, void *aux);
55 void rtnetlink_notifier_unregister(struct rtnetlink *,
56                                    struct rtnetlink_notifier *);
57 void rtnetlink_notifier_run(struct rtnetlink *);
58 void rtnetlink_notifier_wait(struct rtnetlink *);
59 #endif /* rtnetlink.h */