]> git.proxmox.com Git - systemd.git/blob - src/systemd/sd-netlink.h
Enable seccomp support on powerpc, ppc64el, and s390x
[systemd.git] / src / systemd / sd-netlink.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #ifndef foosdnetlinkhfoo
4 #define foosdnetlinkhfoo
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 #include <netinet/in.h>
27 #include <netinet/ether.h>
28 #include <linux/rtnetlink.h>
29 #include <linux/neighbour.h>
30
31 #include "sd-event.h"
32 #include "_sd-common.h"
33
34 _SD_BEGIN_DECLARATIONS;
35
36 typedef struct sd_netlink sd_netlink;
37 typedef struct sd_netlink_message sd_netlink_message;
38
39 /* callback */
40
41 typedef int (*sd_netlink_message_handler_t)(sd_netlink *nl, sd_netlink_message *m, void *userdata);
42
43 /* bus */
44 int sd_netlink_new_from_netlink(sd_netlink **nl, int fd);
45 int sd_netlink_open(sd_netlink **nl);
46 int sd_netlink_open_fd(sd_netlink **nl, int fd);
47 int sd_netlink_inc_rcvbuf(const sd_netlink *const rtnl, const int size);
48
49 sd_netlink *sd_netlink_ref(sd_netlink *nl);
50 sd_netlink *sd_netlink_unref(sd_netlink *nl);
51
52 int sd_netlink_send(sd_netlink *nl, sd_netlink_message *message, uint32_t *serial);
53 int sd_netlink_call_async(sd_netlink *nl, sd_netlink_message *message,
54 sd_netlink_message_handler_t callback,
55 void *userdata, uint64_t usec, uint32_t *serial);
56 int sd_netlink_call_async_cancel(sd_netlink *nl, uint32_t serial);
57 int sd_netlink_call(sd_netlink *nl, sd_netlink_message *message, uint64_t timeout,
58 sd_netlink_message **reply);
59
60 int sd_netlink_get_events(sd_netlink *nl);
61 int sd_netlink_get_timeout(sd_netlink *nl, uint64_t *timeout);
62 int sd_netlink_process(sd_netlink *nl, sd_netlink_message **ret);
63 int sd_netlink_wait(sd_netlink *nl, uint64_t timeout);
64
65 int sd_netlink_add_match(sd_netlink *nl, uint16_t match, sd_netlink_message_handler_t c, void *userdata);
66 int sd_netlink_remove_match(sd_netlink *nl, uint16_t match, sd_netlink_message_handler_t c, void *userdata);
67
68 int sd_netlink_attach_event(sd_netlink *nl, sd_event *e, int priority);
69 int sd_netlink_detach_event(sd_netlink *nl);
70
71 int sd_netlink_message_append_string(sd_netlink_message *m, unsigned short type, const char *data);
72 int sd_netlink_message_append_flag(sd_netlink_message *m, unsigned short type);
73 int sd_netlink_message_append_u8(sd_netlink_message *m, unsigned short type, uint8_t data);
74 int sd_netlink_message_append_u16(sd_netlink_message *m, unsigned short type, uint16_t data);
75 int sd_netlink_message_append_u32(sd_netlink_message *m, unsigned short type, uint32_t data);
76 int sd_netlink_message_append_in_addr(sd_netlink_message *m, unsigned short type, const struct in_addr *data);
77 int sd_netlink_message_append_in6_addr(sd_netlink_message *m, unsigned short type, const struct in6_addr *data);
78 int sd_netlink_message_append_ether_addr(sd_netlink_message *m, unsigned short type, const struct ether_addr *data);
79 int sd_netlink_message_append_cache_info(sd_netlink_message *m, unsigned short type, const struct ifa_cacheinfo *info);
80
81 int sd_netlink_message_open_container(sd_netlink_message *m, unsigned short type);
82 int sd_netlink_message_open_container_union(sd_netlink_message *m, unsigned short type, const char *key);
83 int sd_netlink_message_close_container(sd_netlink_message *m);
84
85 int sd_netlink_message_read_string(sd_netlink_message *m, unsigned short type, const char **data);
86 int sd_netlink_message_read_u8(sd_netlink_message *m, unsigned short type, uint8_t *data);
87 int sd_netlink_message_read_u16(sd_netlink_message *m, unsigned short type, uint16_t *data);
88 int sd_netlink_message_read_u32(sd_netlink_message *m, unsigned short type, uint32_t *data);
89 int sd_netlink_message_read_ether_addr(sd_netlink_message *m, unsigned short type, struct ether_addr *data);
90 int sd_netlink_message_read_cache_info(sd_netlink_message *m, unsigned short type, struct ifa_cacheinfo *info);
91 int sd_netlink_message_read_in_addr(sd_netlink_message *m, unsigned short type, struct in_addr *data);
92 int sd_netlink_message_read_in6_addr(sd_netlink_message *m, unsigned short type, struct in6_addr *data);
93 int sd_netlink_message_enter_container(sd_netlink_message *m, unsigned short type);
94 int sd_netlink_message_exit_container(sd_netlink_message *m);
95
96 int sd_netlink_message_rewind(sd_netlink_message *m);
97
98 sd_netlink_message *sd_netlink_message_next(sd_netlink_message *m);
99
100 sd_netlink_message *sd_netlink_message_ref(sd_netlink_message *m);
101 sd_netlink_message *sd_netlink_message_unref(sd_netlink_message *m);
102
103 int sd_netlink_message_request_dump(sd_netlink_message *m, int dump);
104 int sd_netlink_message_is_error(sd_netlink_message *m);
105 int sd_netlink_message_get_errno(sd_netlink_message *m);
106 int sd_netlink_message_get_type(sd_netlink_message *m, uint16_t *type);
107 int sd_netlink_message_set_flags(sd_netlink_message *m, uint16_t flags);
108 int sd_netlink_message_is_broadcast(sd_netlink_message *m);
109
110 /* rtnl */
111
112 int sd_rtnl_message_new_link(sd_netlink *nl, sd_netlink_message **ret, uint16_t msg_type, int index);
113 int sd_rtnl_message_new_addr_update(sd_netlink *nl, sd_netlink_message **ret, int index, int family);
114 int sd_rtnl_message_new_addr(sd_netlink *nl, sd_netlink_message **ret, uint16_t msg_type, int index, int family);
115 int sd_rtnl_message_new_route(sd_netlink *nl, sd_netlink_message **ret, uint16_t nlmsg_type, int rtm_family, unsigned char rtm_protocol);
116 int sd_rtnl_message_new_neigh(sd_netlink *nl, sd_netlink_message **ret, uint16_t msg_type, int index, int nda_family);
117
118 int sd_rtnl_message_get_family(sd_netlink_message *m, int *family);
119
120 int sd_rtnl_message_addr_set_prefixlen(sd_netlink_message *m, unsigned char prefixlen);
121 int sd_rtnl_message_addr_set_scope(sd_netlink_message *m, unsigned char scope);
122 int sd_rtnl_message_addr_set_flags(sd_netlink_message *m, unsigned char flags);
123 int sd_rtnl_message_addr_get_family(sd_netlink_message *m, int *family);
124 int sd_rtnl_message_addr_get_prefixlen(sd_netlink_message *m, unsigned char *prefixlen);
125 int sd_rtnl_message_addr_get_scope(sd_netlink_message *m, unsigned char *scope);
126 int sd_rtnl_message_addr_get_flags(sd_netlink_message *m, unsigned char *flags);
127 int sd_rtnl_message_addr_get_ifindex(sd_netlink_message *m, int *ifindex);
128
129 int sd_rtnl_message_link_set_flags(sd_netlink_message *m, unsigned flags, unsigned change);
130 int sd_rtnl_message_link_set_type(sd_netlink_message *m, unsigned type);
131 int sd_rtnl_message_link_set_family(sd_netlink_message *m, unsigned family);
132 int sd_rtnl_message_link_get_ifindex(sd_netlink_message *m, int *ifindex);
133 int sd_rtnl_message_link_get_flags(sd_netlink_message *m, unsigned *flags);
134 int sd_rtnl_message_link_get_type(sd_netlink_message *m, unsigned *type);
135
136 int sd_rtnl_message_route_set_dst_prefixlen(sd_netlink_message *m, unsigned char prefixlen);
137 int sd_rtnl_message_route_set_src_prefixlen(sd_netlink_message *m, unsigned char prefixlen);
138 int sd_rtnl_message_route_set_scope(sd_netlink_message *m, unsigned char scope);
139 int sd_rtnl_message_route_set_flags(sd_netlink_message *m, unsigned flags);
140 int sd_rtnl_message_route_get_flags(sd_netlink_message *m, unsigned *flags);
141 int sd_rtnl_message_route_get_family(sd_netlink_message *m, int *family);
142 int sd_rtnl_message_route_get_protocol(sd_netlink_message *m, unsigned char *protocol);
143 int sd_rtnl_message_route_get_scope(sd_netlink_message *m, unsigned char *scope);
144 int sd_rtnl_message_route_get_tos(sd_netlink_message *m, unsigned char *tos);
145 int sd_rtnl_message_route_get_table(sd_netlink_message *m, unsigned char *table);
146 int sd_rtnl_message_route_get_dst_prefixlen(sd_netlink_message *m, unsigned char *dst_len);
147 int sd_rtnl_message_route_get_src_prefixlen(sd_netlink_message *m, unsigned char *src_len);
148
149 int sd_rtnl_message_neigh_set_flags(sd_netlink_message *m, uint8_t flags);
150 int sd_rtnl_message_neigh_set_state(sd_netlink_message *m, uint16_t state);
151 int sd_rtnl_message_neigh_get_family(sd_netlink_message *m, int *family);
152 int sd_rtnl_message_neigh_get_ifindex(sd_netlink_message *m, int *family);
153 int sd_rtnl_message_neigh_get_state(sd_netlink_message *m, uint16_t *state);
154 int sd_rtnl_message_neigh_get_flags(sd_netlink_message *m, uint8_t *flags);
155
156 _SD_END_DECLARATIONS;
157
158 #endif