Setting tag sliver-openvswitch-2.2.90-1
[sliver-openvswitch.git] / lib / rtnetlink-link.h
1 /*
2  * Copyright (c) 2009 Nicira, Inc.
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_LINK_H
18 #define RTNETLINK_LINK_H 1
19
20 #include <stdbool.h>
21 #include <stdint.h>
22 #include <linux/if_ether.h>
23
24 struct ofpbuf;
25 struct nln_notifier;
26
27 /* These functions are Linux specific, so they should be used directly only by
28  * Linux-specific code. */
29
30 /* A digested version of an rtnetlink_link message sent down by the kernel to
31  * indicate that a network device has been created, destroyed or changed.  */
32 struct rtnetlink_link_change {
33     /* Copied from struct nlmsghdr. */
34     int nlmsg_type;             /* e.g. RTM_NEWLINK, RTM_DELLINK. */
35
36     /* Copied from struct ifinfomsg. */
37     int ifi_index;              /* Index of network device. */
38
39     /* Extracted from Netlink attributes. */
40     const char *ifname;         /* Name of network device. */
41     int master_ifindex;         /* Ifindex of datapath master (0 if none). */
42     int mtu;                    /* Current MTU. */
43     uint8_t addr[ETH_ALEN];
44     unsigned int ifi_flags;     /* Flags of network device. */
45 };
46
47 /* Function called to report that a netdev has changed.  'change' describes the
48  * specific change.  It may be null if the buffer of change information
49  * overflowed, in which case the function must assume that every device may
50  * have changed.  'aux' is as specified in the call to
51  * rtnetlink_link_notifier_register().  */
52 typedef
53 void rtnetlink_link_notify_func(const struct rtnetlink_link_change *change,
54                                 void *aux);
55
56 bool rtnetlink_link_parse(struct ofpbuf *buf,
57                           struct rtnetlink_link_change *change);
58 struct nln_notifier *
59 rtnetlink_link_notifier_create(rtnetlink_link_notify_func *, void *aux);
60 void rtnetlink_link_notifier_destroy(struct nln_notifier *);
61 void rtnetlink_link_run(void);
62 void rtnetlink_link_wait(void);
63 #endif /* rtnetlink-link.h */