Merge remote-tracking branch 'origin/ovs-dev' into bsd-port
[sliver-openvswitch.git] / lib / rtbsd.h
1 /*
2  * Copyright (c) 2011 Gaetano Catalli. 
3  * 
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  * 
7  *    1. Redistributions of source code must retain the above copyright notice,
8  *       this list of conditions and the following disclaimer.
9  * 
10  *    2. Redistributions in binary form must reproduce the above copyright
11  *       notice, this list of conditions and the following disclaimer in the
12  *       documentation and/or other materials provided with the distribution.
13  * 
14  * THIS SOFTWARE IS PROVIDED ``AS IS'' WITHOUT ANY WARRANTIES OF ANY KIND.
15  */
16
17 #ifndef RTBSD_H
18 #define RTBSD_H 1
19
20 #include "list.h"
21
22 /*
23  * A digested version of a message received from a PF_ROUTE socket which
24  * indicates that a network device has been created or destroyed or changed. 
25  */
26 struct rtbsd_change {
27     /* Copied from struct if_msghdr. */
28     int msg_type;             /* e.g. XXX. */
29
30     /* Copied from struct if_msghdr. */
31     int if_index;              /* Index of network device. */
32
33     char if_name[IF_NAMESIZE];         /* Name of network device. */
34     int master_ifindex;         /* Ifindex of datapath master (0 if none). */
35 };
36
37 /*
38  * Function called to report that a netdev has changed.  'change' describes the
39  * specific change.  It may be null if the buffer of change information
40  * overflowed, in which case the function must assume that every device may
41  * have changed.  'aux' is as specified in the call to
42  * rtbsd_notifier_register(). 
43  */
44 typedef void rtbsd_notify_func(const struct rtbsd_change *, void *aux);
45
46 struct rtbsd_notifier {
47     struct list node;
48     rtbsd_notify_func *cb;
49     void *aux;
50 };
51
52 int rtbsd_notifier_register(struct rtbsd_notifier *,
53                                 rtbsd_notify_func *, void *aux);
54 void rtbsd_notifier_unregister(struct rtbsd_notifier *);
55 void rtbsd_notifier_run(void);
56 void rtbsd_notifier_wait(void);
57
58 #endif /* rtbsd.h */