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>
|
2017-03-03 20:20:13 -04:00
|
|
|
* @copyright 2017, 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
|
|
|
|
2017-03-03 20:20:13 -04:00
|
|
|
/** @addtogroup fpga Kernel @{ */
|
|
|
|
|
2017-02-16 09:04:12 -03:00
|
|
|
#pragma once
|
2014-06-25 01:53:48 +00:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
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
|
|
|
|
2015-08-22 17:42:02 +02:00
|
|
|
#include <libconfig.h>
|
2014-06-25 01:53:48 +00:00
|
|
|
|
2015-08-22 17:42:02 +02:00
|
|
|
typedef uint32_t tc_hdl_t;
|
2014-06-25 01:53:48 +00:00
|
|
|
|
|
|
|
struct interface;
|
|
|
|
|
2015-08-22 17:42:02 +02:00
|
|
|
/** Parse network emulator (netem) settings.
|
2014-06-28 06:40:52 +00:00
|
|
|
*
|
2015-08-22 17:42:02 +02:00
|
|
|
* @param cfg A libconfig object containing the settings.
|
2015-09-14 18:05:03 +02:00
|
|
|
* @param[out] ne A pointer to a libnl3 qdisc object where setting will be written to.
|
2015-08-22 17:42:02 +02:00
|
|
|
* @retval 0 Success. Everything went well.
|
|
|
|
* @retval <0 Error. Something went wrong.
|
2014-06-28 06:40:52 +00:00
|
|
|
*/
|
2015-09-14 18:05:03 +02:00
|
|
|
int tc_parse(config_setting_t *cfg, struct rtnl_qdisc **ne);
|
2014-06-25 01:53:48 +00:00
|
|
|
|
2015-08-22 17:42:02 +02:00
|
|
|
/** Print network emulator (netem) setting into buffer.
|
2015-03-31 13:48:41 +02:00
|
|
|
*
|
2015-08-22 17:42:02 +02:00
|
|
|
* @param tc A pointer to the libnl3 qdisc object where settings will be read from.
|
2015-09-22 12:58:37 +02:00
|
|
|
* @return A pointer to a string which must be freed() by the caller.
|
2015-03-31 13:48:41 +02:00
|
|
|
*/
|
2015-09-22 12:58:37 +02:00
|
|
|
char * tc_print(struct rtnl_qdisc *ne);
|
2015-03-31 13:48:41 +02: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
|
|
|
*/
|
|
|
|
int tc_reset(struct interface *i);
|
|
|
|
|
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
|
|
|
*/
|
2015-09-14 18:05:03 +02:00
|
|
|
int tc_prio(struct 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 network emulator (netem) discipline.
|
2014-06-25 01:53:48 +00:00
|
|
|
*
|
2015-08-22 17:42:02 +02:00
|
|
|
* @param i[in] The interface to which this qdisc will be added.
|
|
|
|
* @param qd[in,out] The libnl3 object of the new prio qdisc.
|
|
|
|
* @param handle[in] The handle of the new qdisc.
|
|
|
|
* @param parent[in] Make this qdisc a child of this class
|
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
|
|
|
*/
|
2015-08-22 17:42:02 +02:00
|
|
|
int tc_netem(struct interface *i, struct rtnl_qdisc **qd, tc_hdl_t handle, tc_hdl_t parent);
|
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
|
|
|
*/
|
2017-03-03 20:20:13 -04:00
|
|
|
int tc_mark(struct interface *i, struct rtnl_cls **cls, tc_hdl_t flowid, uint32_t mark);
|
|
|
|
|
|
|
|
/** @} */
|