mirror of
https://github.com/systemd/systemd.git
synced 2025-03-09 12:58:26 +03:00
sd-netlink: Make use of IN_SET (#5977)
This commit is contained in:
parent
2d66f64865
commit
cb4d8b2d05
@ -116,51 +116,6 @@ int rtnl_message_new_synthetic_error(int error, uint32_t serial, sd_netlink_mess
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool rtnl_message_type_is_neigh(uint16_t type) {
|
||||
switch (type) {
|
||||
case RTM_NEWNEIGH:
|
||||
case RTM_GETNEIGH:
|
||||
case RTM_DELNEIGH:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool rtnl_message_type_is_route(uint16_t type) {
|
||||
switch (type) {
|
||||
case RTM_NEWROUTE:
|
||||
case RTM_GETROUTE:
|
||||
case RTM_DELROUTE:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool rtnl_message_type_is_link(uint16_t type) {
|
||||
switch (type) {
|
||||
case RTM_NEWLINK:
|
||||
case RTM_SETLINK:
|
||||
case RTM_GETLINK:
|
||||
case RTM_DELLINK:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool rtnl_message_type_is_addr(uint16_t type) {
|
||||
switch (type) {
|
||||
case RTM_NEWADDR:
|
||||
case RTM_GETADDR:
|
||||
case RTM_DELADDR:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int rtnl_log_parse_error(int r) {
|
||||
return log_error_errno(r, "Failed to parse netlink message: %m");
|
||||
}
|
||||
|
@ -27,10 +27,21 @@ int rtnl_message_new_synthetic_error(int error, uint32_t serial, sd_netlink_mess
|
||||
uint32_t rtnl_message_get_serial(sd_netlink_message *m);
|
||||
void rtnl_message_seal(sd_netlink_message *m);
|
||||
|
||||
bool rtnl_message_type_is_link(uint16_t type);
|
||||
bool rtnl_message_type_is_addr(uint16_t type);
|
||||
bool rtnl_message_type_is_route(uint16_t type);
|
||||
bool rtnl_message_type_is_neigh(uint16_t type);
|
||||
static inline bool rtnl_message_type_is_neigh(uint16_t type) {
|
||||
return IN_SET(type, RTM_NEWNEIGH, RTM_GETNEIGH, RTM_DELNEIGH);
|
||||
}
|
||||
|
||||
static inline bool rtnl_message_type_is_route(uint16_t type) {
|
||||
return IN_SET(type, RTM_NEWROUTE, RTM_GETROUTE, RTM_DELROUTE);
|
||||
}
|
||||
|
||||
static inline bool rtnl_message_type_is_link(uint16_t type) {
|
||||
return IN_SET(type, RTM_NEWLINK, RTM_SETLINK, RTM_GETLINK, RTM_DELLINK);
|
||||
}
|
||||
|
||||
static inline bool rtnl_message_type_is_addr(uint16_t type) {
|
||||
return IN_SET(type, RTM_NEWADDR, RTM_GETADDR, RTM_DELADDR);
|
||||
}
|
||||
|
||||
static inline bool rtnl_message_type_is_addrlabel(uint16_t type) {
|
||||
return IN_SET(type, RTM_NEWADDRLABEL, RTM_DELADDRLABEL, RTM_GETADDRLABEL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user