2014-06-28 06:40:52 +00:00
|
|
|
/** Setup interface queuing desciplines for network emulation
|
|
|
|
*
|
|
|
|
* 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
|
|
|
*
|
2014-06-28 06:40:52 +00:00
|
|
|
* @file
|
2015-06-02 21:53:04 +02:00
|
|
|
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
2020-01-20 17:17:00 +01:00
|
|
|
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
2017-04-27 12:56:43 +02:00
|
|
|
* @license GNU General Public License (version 3)
|
|
|
|
*
|
|
|
|
* VILLASnode
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* any later version.
|
2017-05-05 19:24:16 +00:00
|
|
|
*
|
2017-04-27 12:56:43 +02:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2017-05-05 19:24:16 +00:00
|
|
|
*
|
2017-04-27 12:56:43 +02:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2015-06-02 21:53:04 +02:00
|
|
|
*********************************************************************************/
|
2014-06-25 01:53:48 +00:00
|
|
|
|
2018-06-30 01:29:56 +02:00
|
|
|
/** @addtogroup kernel Kernel
|
|
|
|
* @{
|
|
|
|
*/
|
2017-03-03 20:20:13 -04: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/qdisc.h>
|
|
|
|
#include <netlink/route/classifier.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 {
|
|
|
|
|
|
|
|
/* Forward declarations */
|
|
|
|
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
|
|
|
|
2014-07-14 11:49:44 +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
|
|
|
|
2014-07-14 11:49:44 +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
|
|
|
*/
|
2020-09-13 11:01:20 +02: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
|
|
|
|
2014-07-14 11:49:44 +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.
|
2014-06-28 06:40:52 +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);
|
|
|
|
|
|
|
|
} /* namespace tc */
|
|
|
|
} /* namespace kernel */
|
|
|
|
} /* namespace villas */
|
2017-03-03 20:20:13 -04:00
|
|
|
|
2017-07-24 19:33:35 +02:00
|
|
|
/** @} */
|