]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/network/tc/tclass.h
add ipv6 range element creation test cases
[thirdparty/systemd.git] / src / network / tc / tclass.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later
2 * Copyright © 2019 VMware, Inc. */
3 #pragma once
4
5 #include "conf-parser.h"
6 #include "networkd-link.h"
7 #include "networkd-network.h"
8 #include "networkd-util.h"
9 #include "tc.h"
10
11 typedef enum TClassKind {
12 TCLASS_KIND_DRR,
13 TCLASS_KIND_HTB,
14 TCLASS_KIND_QFQ,
15 _TCLASS_KIND_MAX,
16 _TCLASS_KIND_INVALID = -1,
17 } TClassKind;
18
19 typedef struct TClass {
20 TrafficControl meta;
21
22 NetworkConfigSection *section;
23 Network *network;
24
25 uint32_t classid;
26 uint32_t parent;
27
28 TClassKind kind;
29 } TClass;
30
31 typedef struct TClassVTable {
32 size_t object_size;
33 const char *tca_kind;
34 /* called in tclass_new() */
35 int (*init)(TClass *tclass);
36 int (*fill_message)(Link *link, TClass *tclass, sd_netlink_message *m);
37 int (*verify)(TClass *tclass);
38 } TClassVTable;
39
40 extern const TClassVTable * const tclass_vtable[_TCLASS_KIND_MAX];
41
42 #define TCLASS_VTABLE(t) ((t)->kind != _TCLASS_KIND_INVALID ? tclass_vtable[(t)->kind] : NULL)
43
44 /* For casting a tclass into the various tclass kinds */
45 #define DEFINE_TCLASS_CAST(UPPERCASE, MixedCase) \
46 static inline MixedCase* TCLASS_TO_##UPPERCASE(TClass *t) { \
47 if (_unlikely_(!t || t->kind != TCLASS_KIND_##UPPERCASE)) \
48 return NULL; \
49 \
50 return (MixedCase*) t; \
51 }
52
53 /* For casting the various tclass kinds into a tclass */
54 #define TCLASS(t) (&(t)->meta)
55
56 void tclass_free(TClass *tclass);
57 int tclass_new_static(TClassKind kind, Network *network, const char *filename, unsigned section_line, TClass **ret);
58
59 int tclass_configure(Link *link, TClass *tclass);
60 int tclass_section_verify(TClass *tclass);
61
62 DEFINE_NETWORK_SECTION_FUNCTIONS(TClass, tclass_free);
63
64 DEFINE_TC_CAST(TCLASS, TClass);
65
66 CONFIG_PARSER_PROTOTYPE(config_parse_tclass_parent);
67 CONFIG_PARSER_PROTOTYPE(config_parse_tclass_classid);
68
69 #include "drr.h"
70 #include "htb.h"
71 #include "qfq.h"