]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/libsystemd/sd-netlink/netlink-util.h
d41113d15bc792b8a4d2f877f4e75e33aca826ad
[thirdparty/systemd.git] / src / libsystemd / sd-netlink / netlink-util.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 Copyright (C) 2013 Tom Gundersen <teg@jklm.no>
6 ***/
7
8 #include "sd-netlink.h"
9
10 #include "util.h"
11
12 int rtnl_message_new_synthetic_error(sd_netlink *rtnl, int error, uint32_t serial, sd_netlink_message **ret);
13 uint32_t rtnl_message_get_serial(sd_netlink_message *m);
14 void rtnl_message_seal(sd_netlink_message *m);
15
16 static inline bool rtnl_message_type_is_neigh(uint16_t type) {
17 return IN_SET(type, RTM_NEWNEIGH, RTM_GETNEIGH, RTM_DELNEIGH);
18 }
19
20 static inline bool rtnl_message_type_is_route(uint16_t type) {
21 return IN_SET(type, RTM_NEWROUTE, RTM_GETROUTE, RTM_DELROUTE);
22 }
23
24 static inline bool rtnl_message_type_is_link(uint16_t type) {
25 return IN_SET(type, RTM_NEWLINK, RTM_SETLINK, RTM_GETLINK, RTM_DELLINK);
26 }
27
28 static inline bool rtnl_message_type_is_addr(uint16_t type) {
29 return IN_SET(type, RTM_NEWADDR, RTM_GETADDR, RTM_DELADDR);
30 }
31
32 static inline bool rtnl_message_type_is_addrlabel(uint16_t type) {
33 return IN_SET(type, RTM_NEWADDRLABEL, RTM_DELADDRLABEL, RTM_GETADDRLABEL);
34 }
35
36 static inline bool rtnl_message_type_is_routing_policy_rule(uint16_t type) {
37 return IN_SET(type, RTM_NEWRULE, RTM_DELRULE, RTM_GETRULE);
38 }
39
40 int rtnl_set_link_name(sd_netlink **rtnl, int ifindex, const char *name);
41 int rtnl_set_link_properties(sd_netlink **rtnl, int ifindex, const char *alias, const struct ether_addr *mac, uint32_t mtu);
42
43 int rtnl_log_parse_error(int r);
44 int rtnl_log_create_error(int r);