chiark / gitweb /
e5fa785a99434694e2bb67cfbf4a17a0358ea15a
[elogind.git] / src / systemd / sd-rtnl.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #ifndef foosdrtnlhfoo
4 #define foosdrtnlhfoo
5
6 /***
7   This file is part of systemd.
8
9   Copyright 2013 Tom Gundersen <teg@jklm.no>
10
11   systemd is free software; you can redistribute it and/or modify it
12   under the terms of the GNU Lesser General Public License as published by
13   the Free Software Foundation; either version 2.1 of the License, or
14   (at your option) any later version.
15
16   systemd is distributed in the hope that it will be useful, but
17   WITHOUT ANY WARRANTY; without even the implied warranty of
18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19   Lesser General Public License for more details.
20
21   You should have received a copy of the GNU Lesser General Public License
22   along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 ***/
24
25 #include <inttypes.h>
26
27 #include "sd-event.h"
28 #include "_sd-common.h"
29
30 _SD_BEGIN_DECLARATIONS;
31
32 typedef struct sd_rtnl sd_rtnl;
33 typedef struct sd_rtnl_message sd_rtnl_message;
34
35 /* callback */
36
37 typedef int (*sd_rtnl_message_handler_t)(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata);
38
39 /* bus */
40 int sd_rtnl_open(uint32_t groups, sd_rtnl **nl);
41
42 sd_rtnl *sd_rtnl_ref(sd_rtnl *nl);
43 sd_rtnl *sd_rtnl_unref(sd_rtnl *nl);
44
45 int sd_rtnl_send(sd_rtnl *nl, sd_rtnl_message *message, uint32_t *serial);
46 int sd_rtnl_call_async(sd_rtnl *nl, sd_rtnl_message *message,
47                        sd_rtnl_message_handler_t callback,
48                        void *userdata, uint64_t usec, uint32_t *serial);
49 int sd_rtnl_call_async_cancel(sd_rtnl *nl, uint32_t serial);
50 int sd_rtnl_call(sd_rtnl *nl, sd_rtnl_message *message, uint64_t timeout,
51                  sd_rtnl_message **reply);
52
53
54 int sd_rtnl_get_events(sd_rtnl *nl);
55 int sd_rtnl_get_timeout(sd_rtnl *nl, uint64_t *timeout);
56 int sd_rtnl_process(sd_rtnl *nl, sd_rtnl_message **ret);
57 int sd_rtnl_wait(sd_rtnl *nl, uint64_t timeout);
58 int sd_rtnl_flush(sd_rtnl *nl);
59
60 int sd_rtnl_attach_event(sd_rtnl *nl, sd_event *e, int priority);
61 int sd_rtnl_detach_event(sd_rtnl *nl);
62
63 /* messages */
64 int sd_rtnl_message_link_new(uint16_t msg_type, int index, unsigned int type,
65                              unsigned int flags, sd_rtnl_message **ret);
66 int sd_rtnl_message_addr_new(uint16_t msg_type, int index, unsigned char family,
67                              unsigned char prefixlen, unsigned char flags,
68                              unsigned char scope, sd_rtnl_message **ret);
69 int sd_rtnl_message_route_new(uint16_t nlmsg_type, unsigned char rtm_family,
70                               unsigned char rtm_dst_len, unsigned char rtm_src_len,
71                               unsigned char rtm_tos, unsigned char rtm_table,
72                               unsigned char rtm_scope, unsigned char rtm_protocol,
73                               unsigned char rtm_type, unsigned flags, sd_rtnl_message **ret);
74 sd_rtnl_message *sd_rtnl_message_ref(sd_rtnl_message *m);
75 sd_rtnl_message *sd_rtnl_message_unref(sd_rtnl_message *m);
76
77 int sd_rtnl_message_get_errno(sd_rtnl_message *m);
78 int sd_rtnl_message_get_type(sd_rtnl_message *m, uint16_t *type);
79 int sd_rtnl_message_append(sd_rtnl_message *m, unsigned short type, const void *data);
80 int sd_rtnl_message_read(sd_rtnl_message *m, unsigned short *type, void **data);
81
82 _SD_END_DECLARATIONS;
83
84 #endif