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