mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-18 20:47:53 +00:00
Added basic QoS rule handling
This commit is contained in:
parent
f302fac423
commit
65b0030342
@ -744,6 +744,11 @@ enum ZT_VirtualNetworkRuleType
|
||||
*/
|
||||
ZT_NETWORK_RULE_ACTION_BREAK = 5,
|
||||
|
||||
/**
|
||||
* Place a matching frame in the specified QoS bucket
|
||||
*/
|
||||
ZT_NETWORK_RULE_ACTION_PRIORITY = 6,
|
||||
|
||||
/**
|
||||
* Maximum ID for an ACTION, anything higher is a MATCH
|
||||
*/
|
||||
@ -934,6 +939,11 @@ typedef struct
|
||||
uint32_t flags;
|
||||
uint16_t length;
|
||||
} fwd;
|
||||
|
||||
/**
|
||||
* Quality of Service (QoS) bucket we want a frame to be placed in
|
||||
*/
|
||||
uint8_t qosBucket;
|
||||
} v;
|
||||
} ZT_VirtualNetworkRule;
|
||||
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "../include/ZeroTierDebug.h"
|
||||
|
||||
#include "Constants.hpp"
|
||||
#include "../version.h"
|
||||
#include "Network.hpp"
|
||||
@ -107,7 +109,7 @@ static _doZtFilterResult _doZtFilter(
|
||||
Address &cc, // MUTABLE -- set to TEE destination if TEE action is taken or left alone otherwise
|
||||
unsigned int &ccLength, // MUTABLE -- set to length of packet payload to TEE
|
||||
bool &ccWatch, // MUTABLE -- set to true for WATCH target as opposed to normal TEE
|
||||
uint8_t &qosBucket) // MUTABLE -- set to the value of the argument provided to the matching action
|
||||
uint8_t &qosBucket) // MUTABLE -- set to the value of the argument provided to PRIORITY
|
||||
{
|
||||
// Set to true if we are a TEE/REDIRECT/WATCH target
|
||||
bool superAccept = false;
|
||||
@ -125,6 +127,10 @@ static _doZtFilterResult _doZtFilter(
|
||||
if ((unsigned int)rt <= (unsigned int)ZT_NETWORK_RULE_ACTION__MAX_ID) {
|
||||
if (thisSetMatches) {
|
||||
switch(rt) {
|
||||
case ZT_NETWORK_RULE_ACTION_PRIORITY:
|
||||
qosBucket = (rules[rn].v.qosBucket >= 0 || rules[rn].v.qosBucket <= 8) ? rules[rn].v.qosBucket : 4; // 4 = default bucket (no priority)
|
||||
return DOZTFILTER_ACCEPT;
|
||||
|
||||
case ZT_NETWORK_RULE_ACTION_DROP:
|
||||
return DOZTFILTER_DROP;
|
||||
|
||||
|
@ -65,7 +65,8 @@ const OPEN_BLOCK_KEYWORDS = {
|
||||
'tee': true,
|
||||
'watch': true,
|
||||
'redirect': true,
|
||||
'break': true
|
||||
'break': true,
|
||||
'priority': true
|
||||
};
|
||||
|
||||
// Reserved words that can't be used as tag, capability, or rule set names
|
||||
@ -81,6 +82,7 @@ const RESERVED_WORDS = {
|
||||
'watch': true,
|
||||
'redirect': true,
|
||||
'break': true,
|
||||
'priority': true,
|
||||
|
||||
'ztsrc': true,
|
||||
'ztdest': true,
|
||||
@ -131,6 +133,7 @@ const KEYWORD_TO_API_MAP = {
|
||||
'watch': 'ACTION_WATCH',
|
||||
'redirect': 'ACTION_REDIRECT',
|
||||
'break': 'ACTION_BREAK',
|
||||
'priority': 'ACTION_PRIORITY',
|
||||
|
||||
'ztsrc': 'MATCH_SOURCE_ZEROTIER_ADDRESS',
|
||||
'ztdest': 'MATCH_DEST_ZEROTIER_ADDRESS',
|
||||
|
Loading…
Reference in New Issue
Block a user