]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/network/tc/tc.h
tree-wide: use -EINVAL for enum invalid values
[thirdparty/systemd.git] / src / network / tc / tc.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include "networkd-link.h"
5
6 typedef enum TrafficControlKind {
7 TC_KIND_QDISC,
8 TC_KIND_TCLASS,
9 TC_KIND_FILTER,
10 _TC_KIND_MAX,
11 _TC_KIND_INVALID = -EINVAL,
12 } TrafficControlKind;
13
14 typedef struct TrafficControl {
15 TrafficControlKind kind;
16 } TrafficControl;
17
18 /* For casting a tc into the various tc kinds */
19 #define DEFINE_TC_CAST(UPPERCASE, MixedCase) \
20 static inline MixedCase* TC_TO_##UPPERCASE(TrafficControl *tc) { \
21 if (_unlikely_(!tc || tc->kind != TC_KIND_##UPPERCASE)) \
22 return NULL; \
23 \
24 return (MixedCase*) tc; \
25 }
26
27 /* For casting the various tc kinds into a tc */
28 #define TC(tc) (&(tc)->meta)
29
30 void traffic_control_free(TrafficControl *tc);
31 int link_configure_traffic_control(Link *link);
32 void network_drop_invalid_traffic_control(Network *network);