2025-01-14 14:42:39 +00:00
|
|
|
/* Setup interface queuing desciplines for network emulation.
|
2014-06-28 06:40:52 +00:00
|
|
|
*
|
|
|
|
* We use the firewall mark to apply individual netem qdiscs
|
|
|
|
* per node. Every node uses an own BSD socket.
|
|
|
|
* By using so SO_MARK socket option (see socket(7))
|
|
|
|
* we can classify traffic originating from a node seperately.
|
2014-06-25 01:53:48 +00:00
|
|
|
*
|
2025-01-14 14:42:39 +00:00
|
|
|
* Author: Steffen Vogel <post@steffenvogel.de>
|
|
|
|
* SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2014-06-25 01:53:48 +00:00
|
|
|
|
2017-02-16 09:04:12 -03:00
|
|
|
#pragma once
|
2014-06-25 01:53:48 +00:00
|
|
|
|
2019-06-23 16:57:00 +02:00
|
|
|
#include <cstdint>
|
2014-06-25 01:53:48 +00:00
|
|
|
|
2015-08-22 17:42:02 +02:00
|
|
|
#include <netlink/route/classifier.h>
|
2025-01-14 14:42:39 +00:00
|
|
|
#include <netlink/route/qdisc.h>
|
2014-06-25 01:53:48 +00:00
|
|
|
|
2017-08-03 00:19:27 +02:00
|
|
|
#include <jansson.h>
|
2014-06-25 01:53:48 +00:00
|
|
|
|
2020-09-13 11:01:20 +02:00
|
|
|
namespace villas {
|
|
|
|
namespace kernel {
|
|
|
|
|
2025-01-14 14:42:39 +00:00
|
|
|
// Forward declarations
|
2020-09-13 11:01:20 +02:00
|
|
|
class Interface;
|
2014-06-25 01:53:48 +00:00
|
|
|
|
2020-09-13 11:01:20 +02:00
|
|
|
namespace tc {
|
|
|
|
|
|
|
|
typedef uint32_t tc_hdl_t;
|
2014-06-25 01:53:48 +00:00
|
|
|
|
2025-01-14 14:42:39 +00:00
|
|
|
/* Remove all queuing disciplines and filters.
|
2014-06-25 01:53:48 +00:00
|
|
|
*
|
|
|
|
* @param i The interface
|
2014-12-05 12:26:47 +01:00
|
|
|
* @retval 0 Success. Everything went well.
|
|
|
|
* @retval <0 Error. Something went wrong.
|
2014-06-25 01:53:48 +00:00
|
|
|
*/
|
2020-09-13 11:01:20 +02:00
|
|
|
int reset(Interface *i);
|
2014-06-25 01:53:48 +00:00
|
|
|
|
2025-01-14 14:42:39 +00:00
|
|
|
/* Create a priority (prio) queueing discipline.
|
2014-06-25 01:53:48 +00:00
|
|
|
*
|
2015-08-22 17:42:02 +02:00
|
|
|
* @param i[in] The interface
|
|
|
|
* @param qd[in,out] The libnl3 object of the new prio qdisc.
|
|
|
|
* @param handle[in] The handle for the new qdisc
|
2015-09-14 18:05:03 +02:00
|
|
|
* @param parent[in] Make this qdisc a child of this class
|
2015-08-22 17:42:02 +02:00
|
|
|
* @param bands[in] The number of classes for this new qdisc
|
2014-12-05 12:26:47 +01:00
|
|
|
* @retval 0 Success. Everything went well.
|
|
|
|
* @retval <0 Error. Something went wrong.
|
2014-06-25 01:53:48 +00:00
|
|
|
*/
|
2025-01-14 14:42:39 +00:00
|
|
|
int prio(Interface *i, struct rtnl_qdisc **qd, tc_hdl_t handle, tc_hdl_t,
|
|
|
|
int bands);
|
2014-06-25 01:53:48 +00:00
|
|
|
|
2025-01-14 14:42:39 +00:00
|
|
|
/* Add a new filter based on the netfilter mark.
|
2014-06-28 06:40:52 +00:00
|
|
|
*
|
2015-08-22 17:42:02 +02:00
|
|
|
* @param i The interface to which this classifier is applied to.
|
|
|
|
* @param cls[in,out] The libnl3 object of the new prio qdisc.
|
2014-06-28 06:40:52 +00:00
|
|
|
* @param flowid The destination class for matched traffic
|
|
|
|
* @param mark The netfilter firewall mark (sometime called 'fwmark')
|
2014-12-05 12:26:47 +01:00
|
|
|
* @retval 0 Success. Everything went well.
|
|
|
|
* @retval <0 Error. Something went wrong.
|
2025-01-14 14:42:39 +00:00
|
|
|
*/
|
2020-09-13 11:01:20 +02:00
|
|
|
int mark(Interface *i, struct rtnl_cls **cls, tc_hdl_t flowid, uint32_t mark);
|
|
|
|
|
2025-01-14 14:42:39 +00:00
|
|
|
} // namespace tc
|
|
|
|
} // namespace kernel
|
|
|
|
} // namespace villas
|