]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/systemd/sd-rtnl.h
Added attribute support for sd-rtnl
[thirdparty/systemd.git] / src / systemd / sd-rtnl.h
CommitLineData
65f568bb
TG
1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
0a0a6828
LP
3#ifndef foosdrtnlhfoo
4#define foosdrtnlhfoo
5
65f568bb
TG
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
a33dece5 25#include <inttypes.h>
0a0dc69b
TG
26#include <netinet/in.h>
27#include <netinet/ether.h>
65f568bb 28
b4f2a5b1 29#include "sd-event.h"
0095c454
LP
30#include "_sd-common.h"
31
32_SD_BEGIN_DECLARATIONS;
6695ed7a 33
65f568bb
TG
34typedef struct sd_rtnl sd_rtnl;
35typedef struct sd_rtnl_message sd_rtnl_message;
36
e16bcf98
TG
37/* callback */
38
39typedef int (*sd_rtnl_message_handler_t)(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata);
40
65f568bb 41/* bus */
dabfa9d1 42int sd_rtnl_open(uint32_t groups, sd_rtnl **nl);
65f568bb
TG
43
44sd_rtnl *sd_rtnl_ref(sd_rtnl *nl);
45sd_rtnl *sd_rtnl_unref(sd_rtnl *nl);
46
4555ec72 47int sd_rtnl_send(sd_rtnl *nl, sd_rtnl_message *message, uint32_t *serial);
e16bcf98
TG
48int sd_rtnl_call_async(sd_rtnl *nl, sd_rtnl_message *message,
49 sd_rtnl_message_handler_t callback,
50 void *userdata, uint64_t usec, uint32_t *serial);
51int sd_rtnl_call_async_cancel(sd_rtnl *nl, uint32_t serial);
fe4824e0
TG
52int sd_rtnl_call(sd_rtnl *nl, sd_rtnl_message *message, uint64_t timeout,
53 sd_rtnl_message **reply);
65f568bb 54
b4f2a5b1
TG
55
56int sd_rtnl_get_events(sd_rtnl *nl);
57int sd_rtnl_get_timeout(sd_rtnl *nl, uint64_t *timeout);
4555ec72
TG
58int sd_rtnl_process(sd_rtnl *nl, sd_rtnl_message **ret);
59int sd_rtnl_wait(sd_rtnl *nl, uint64_t timeout);
b4f2a5b1
TG
60int sd_rtnl_flush(sd_rtnl *nl);
61
8cec01b9
TG
62int sd_rtnl_add_match(sd_rtnl *nl, uint16_t match, sd_rtnl_message_handler_t c, void *userdata);
63int sd_rtnl_remove_match(sd_rtnl *nl, uint16_t match, sd_rtnl_message_handler_t c, void *userdata);
64
b4f2a5b1
TG
65int sd_rtnl_attach_event(sd_rtnl *nl, sd_event *e, int priority);
66int sd_rtnl_detach_event(sd_rtnl *nl);
4555ec72 67
65f568bb 68/* messages */
fc25d7f8 69int sd_rtnl_message_link_new(uint16_t msg_type, int index, sd_rtnl_message **ret);
03d7e632 70int sd_rtnl_message_addr_new(uint16_t msg_type, int index, unsigned char family,
5a723174 71 sd_rtnl_message **ret);
03d7e632 72int sd_rtnl_message_route_new(uint16_t nlmsg_type, unsigned char rtm_family,
1f01fb4f
TG
73 sd_rtnl_message **ret);
74/*
03d7e632
TG
75 unsigned char rtm_dst_len, unsigned char rtm_src_len,
76 unsigned char rtm_tos, unsigned char rtm_table,
77 unsigned char rtm_scope, unsigned char rtm_protocol,
78 unsigned char rtm_type, unsigned flags, sd_rtnl_message **ret);
1f01fb4f 79*/
65f568bb
TG
80sd_rtnl_message *sd_rtnl_message_ref(sd_rtnl_message *m);
81sd_rtnl_message *sd_rtnl_message_unref(sd_rtnl_message *m);
82
e16bcf98 83int sd_rtnl_message_get_errno(sd_rtnl_message *m);
dabfa9d1 84int sd_rtnl_message_get_type(sd_rtnl_message *m, uint16_t *type);
33125ac5 85
5a723174
TG
86int sd_rtnl_message_addr_set_prefixlen(sd_rtnl_message *m, unsigned char prefixlen);
87int sd_rtnl_message_addr_set_scope(sd_rtnl_message *m, unsigned char scope);
88int sd_rtnl_message_addr_set_flags(sd_rtnl_message *m, unsigned char flags);
89
5d4795f3 90int sd_rtnl_message_link_set_flags(sd_rtnl_message *m, unsigned flags, unsigned change);
fc25d7f8 91int sd_rtnl_message_link_set_type(sd_rtnl_message *m, unsigned type);
33125ac5 92int sd_rtnl_message_link_get_ifindex(sd_rtnl_message *m, int *ifindex);
50b3c42f 93int sd_rtnl_message_link_get_flags(sd_rtnl_message *m, unsigned *flags);
33125ac5 94
1f01fb4f
TG
95int sd_rtnl_message_route_set_dst_prefixlen(sd_rtnl_message *m, unsigned char prefixlen);
96
0a0dc69b 97int sd_rtnl_message_append_string(sd_rtnl_message *m, unsigned short type, const char *data);
7b179640 98int sd_rtnl_message_append_u8(sd_rtnl_message *m, unsigned short type, uint8_t data);
01b36069 99int sd_rtnl_message_append_u16(sd_rtnl_message *m, unsigned short type, uint16_t data);
0a0dc69b
TG
100int sd_rtnl_message_append_u32(sd_rtnl_message *m, unsigned short type, uint32_t data);
101int sd_rtnl_message_append_in_addr(sd_rtnl_message *m, unsigned short type, const struct in_addr *data);
102int sd_rtnl_message_append_in6_addr(sd_rtnl_message *m, unsigned short type, const struct in6_addr *data);
103int sd_rtnl_message_append_ether_addr(sd_rtnl_message *m, unsigned short type, const struct ether_addr *data);
104
33125ac5
TG
105int sd_rtnl_message_open_container(sd_rtnl_message *m, unsigned short type);
106int sd_rtnl_message_close_container(sd_rtnl_message *m);
107
65f568bb 108int sd_rtnl_message_read(sd_rtnl_message *m, unsigned short *type, void **data);
e5c4350b 109int sd_rtnl_message_exit_container(sd_rtnl_message *m);
0a0a6828 110
0fc7531b
TG
111int sd_rtnl_message_rewind(sd_rtnl_message *m);
112
0095c454 113_SD_END_DECLARATIONS;
6695ed7a 114
0a0a6828 115#endif