QfiRuleSet.h Source File

Simu5G: QfiRuleSet.h Source File
Simu5G
QfiRuleSet.h
1//
2// Simu5G
3//
4// Authors: Andras Varga (OpenSim Ltd)
5//
6// This file is part of a software released under the license included in file
7// "license.pdf". Please read LICENSE and README files before using it.
8// The above files and the present reference are part of the software itself,
9// and cannot be removed from it.
10//
11
12#ifndef _QFI_RULE_SET_H_
13#define _QFI_RULE_SET_H_
14
15#include <memory>
16#include <vector>
17
18#include <inet/common/packet/PacketFilter.h>
19
20#include "simu5g/common/LteCommon.h"
21
22namespace omnetpp { class cValueMap; }
23
24namespace simu5g {
25
57{
58 protected:
59 struct QfiRule {
60 std::unique_ptr<inet::PacketFilter> filter; // null = match all
61 Qfi qfi = QFI_NONE;
62 bool dscpAsQfi = false;
63 };
64 std::vector<QfiRule> rules_;
65
66 public:
67 // Parse and validate one rule and append it; 'what' names the rule in error
68 // messages (e.g. "dlQfiRules entry 2"), and errors throw at setup time rather
69 // than on the first packet. Only the rule grammar's own fields are read: the
70 // full entry schema, including the delivery-scoping columns that ride in the
71 // same maps, is the caller's to validate.
72 void parseRule(const omnetpp::cValueMap *rule, const char *what);
73
74 // The QFI of the first matching rule, or QFI_NONE if no rule covers the packet;
75 // dscp is the packet's DSCP field, the QFI of a dscpAsQfi rule
76 Qfi classify(inet::Packet *pkt, uint8_t dscp) const;
77
78 // The same for an Ethernet frame (the payload of an Ethernet session), which has
79 // no DSCP field: a dscpAsQfi rule does not match it
80 Qfi classifyFrame(inet::Packet *pkt) const;
81
82 bool empty() const { return rules_.empty(); }
83
84 friend std::ostream& operator<<(std::ostream& os, const QfiRuleSet& e)
85 {
86 os << "rules=" << e.rules_.size();
87 for (size_t i = 0; i < e.rules_.size(); i++) {
88 const auto& r = e.rules_[i];
89 os << " [" << i << ": " << (r.filter ? "filtered" : "matchAll")
90 << (r.dscpAsQfi ? " dscpAsQfi" : "") << " qfi=" << r.qfi << "]";
91 }
92 return os;
93 }
94};
95
96} // namespace simu5g
97
98#endif
An ordered set of QFI-assignment rules, shared by every module that classifies packets to QoS flows.
Definition QfiRuleSet.h:57
Definition AlertReceiver.h:24
constexpr Qfi QFI_NONE
Logical Connection Identifier (used in MAC layer)
Definition LteTypes.h:82