Skip to content
Snippets Groups Projects
Commit d80ff10f authored by Maxim Menshikov's avatar Maxim Menshikov
Browse files

Introduce draft of QoS module

parent 4899873c
No related branches found
No related tags found
No related merge requests found
......@@ -32,7 +32,8 @@ AGENT_OBJS = \
config.o \
main.o \
nl.o \
dpp.o
dpp.o \
qos.o
ifneq (,$(findstring VENDOR_EXTENSION,$(CFLAGS)))
AGENT_OBJS += extension.o
......
/*
* rules.c - rules wrapper functions
*
* Copyright (C) 2019 IOPSYS Software Solutions AB. All rights reserved.
*
* Author: anjan.chanda@iopsys.eu
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <libubox/list.h>
#include <1905_tlvs.h>
#include "utils/debug.h"
#include "steer_rules.h"
/* Rule types */
enum qos_rule_type {
QOS_RULE_TYPE_DSCP_PCP,
QOS_RULE_TYPE_MSCS,
QOS_RULE_TYPE_SCS,
QOS_RULE_TYPE_MGMT,
};
/* Temporary rule structure which contains both SPR and DSCP parts */
typedef struct temp_rule {
struct list_head list;
struct tlv_spr spr;
enum qos_rule_type type;
union {
struct ieee1905_dscp_pcp_usr dscp;
};
} temp_rule;
/* Rules list */
LIST_HEAD(rules);
int qos_add_dscp_rule(struct tlv_spr *spr, struct ieee1905_dscp_pcp_usr *dscp_pcp)
{
struct temp_rule *r;
dbg("%s: adding DSCP rule...\n", __func__);
list_for_each_entry(r, &rules, list) {
if (r->spr.rule_id == spr->rule_id) {
err("%s: adding DSCP rule exists\n", __func__);
return -1;
}
}
r = calloc(1, sizeof(struct temp_rule));
if (r == NULL) {
return -1;
}
r->type = QOS_RULE_TYPE_DSCP_PCP;
memcpy(&r->spr, spr, sizeof(struct tlv_spr));
memcpy(&r->dscp, dscp_pcp, sizeof(struct ieee1905_dscp_pcp_usr));
dbg("%s: DSCP rule added\n", __func__);
list_add_tail(&r->list, &rules);
return 0;
}
int qos_get_rules(void)
{
struct temp_rule *r;
int nr = 0;
info("Registered QoS rules: ");
list_for_each_entry(r, &rules, list) {
info("[%d] add %d prec %doutput %d always %d",
r->spr.rule_id,
r->spr.add_remove,
r->spr.precedence,
r->spr.output,
r->spr.always_match);
nr++;
}
info("\n");
return nr;
}
#ifndef MAPAGENT_QOS_H
#define MAPAGENT_QOS_H
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <libubox/list.h>
#include <1905_tlvs.h>
int qos_add_dscp_rule(struct tlv_spr *spr, struct ieee1905_dscp_pcp_usr *dscp_pcp);
int qos_get_rules(void);
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment