62bb3e012bc5e18c009defcdfa74b2a27f1ccb5b
[platform/upstream/connman.git] / src / shared / netlink.h
1 /*
2  *
3  *  Connection Manager
4  *
5  *  Copyright (C) 2011-2012  Intel Corporation. All rights reserved.
6  *  Copyright (C) 2013  BMW Car IT GbmH.
7  *
8  *
9  *  This library is free software; you can redistribute it and/or
10  *  modify it under the terms of the GNU Lesser General Public
11  *  License version 2.1 as published by the Free Software Foundation.
12  *
13  *  This library is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU Lesser General Public License for more details.
17  *
18  *  You should have received a copy of the GNU Lesser General Public
19  *  License along with this library; if not, write to the Free Software
20  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21  *
22  */
23
24 #include <stdint.h>
25 #include <stdbool.h>
26
27 typedef void (*netlink_debug_func_t) (const char *str, void *user_data);
28 typedef void (*netlink_command_func_t) (unsigned int error,
29                                                 uint16_t type, const void *data,
30                                                 uint32_t len, void *user_data);
31 typedef void (*netlink_notify_func_t) (uint16_t type, const void *data,
32                                                 uint32_t len, void *user_data);
33 typedef void (*netlink_destroy_func_t) (void *user_data);
34
35 struct netlink_info;
36
37 struct netlink_info *netlink_new(int protocol);
38 void netlink_destroy(struct netlink_info *netlink);
39
40 unsigned int netlink_send(struct netlink_info *netlink,
41                         uint16_t type, uint16_t flags, const void *data,
42                         uint32_t len, netlink_command_func_t function,
43                         void *user_data, netlink_destroy_func_t destroy);
44 bool netlink_cancel(struct netlink_info *netlink, unsigned int id);
45
46 unsigned int netlink_register(struct netlink_info *netlink,
47                         uint32_t group, netlink_notify_func_t function,
48                         void *user_data, netlink_destroy_func_t destroy);
49 bool netlink_unregister(struct netlink_info *netlink, unsigned int id);
50
51 bool netlink_set_debug(struct netlink_info *netlink,
52                         netlink_debug_func_t function,
53                         void *user_data, netlink_destroy_func_t destroy);