A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipcs-classifier-record.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007,2008, 2009 INRIA, UDcast
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
7 *
8 */
9
10#ifndef IPCS_CLASSIFIER_RECORD_H
11#define IPCS_CLASSIFIER_RECORD_H
12
13#include "wimax-tlv.h"
14
15#include "ns3/ipv4-address.h"
16
17#include <stdint.h>
18
19namespace ns3
20{
21
22/**
23 * \ingroup wimax
24 * \brief IpcsClassifierRecord class
25 */
27{
28 public:
31 /**
32 * \brief creates a classifier records and sets all its parameters
33 * \param srcAddress the source ip address
34 * \param srcMask the mask to apply on the source ip address
35 * \param dstAddress the destination ip address
36 * \param dstMask the mask to apply on the destination ip address
37 * \param srcPortLow the lower boundary of the source port range
38 * \param srcPortHigh the higher boundary of the source port range
39 * \param dstPortLow the lower boundary of the destination port range
40 * \param dstPortHigh the higher boundary of the destination port range
41 * \param protocol the L4 protocol
42 * \param priority the priority of this classifier
43 *
44 */
46 Ipv4Mask srcMask,
47 Ipv4Address dstAddress,
48 Ipv4Mask dstMask,
49 uint16_t srcPortLow,
50 uint16_t srcPortHigh,
51 uint16_t dstPortLow,
52 uint16_t dstPortHigh,
53 uint8_t protocol,
54 uint8_t priority);
55 /**
56 * \brief Decodes a TLV and creates a classifier
57 * \param tlv the TLV to decode and from which the classifier parameters will be extracted
58 */
60 /**
61 * \brief Creates a TLV from this classifier
62 * \return the created TLV
63 */
64 Tlv ToTlv() const;
65 /**
66 * \brief add a new source ip address to the classifier
67 * \param srcAddress the source ip address
68 * \param srcMask the mask to apply on the source ip address
69 */
70 void AddSrcAddr(Ipv4Address srcAddress, Ipv4Mask srcMask);
71 /**
72 * \brief add a new destination ip address to the classifier
73 * \param dstAddress the destination ip address
74 * \param dstMask the mask to apply on the destination ip address
75 */
76 void AddDstAddr(Ipv4Address dstAddress, Ipv4Mask dstMask);
77 /**
78 * \brief add a range of source port to the classifier
79 * \param srcPortLow the lower boundary of the source port range
80 * \param srcPortHigh the higher boundary of the source port range
81 */
82 void AddSrcPortRange(uint16_t srcPortLow, uint16_t srcPortHigh);
83 /**
84 * \brief add a range of destination port to the classifier
85 * \param dstPortLow the lower boundary of the destination port range
86 * \param dstPortHigh the higher boundary of the destination port range
87 */
88 void AddDstPortRange(uint16_t dstPortLow, uint16_t dstPortHigh);
89 /**
90 * \brief add a protocol to the classifier
91 * \param proto the L4 protocol to add
92 */
93 void AddProtocol(uint8_t proto);
94 /**
95 * \brief Set the priority of this classifier
96 * \param prio the priority of the classifier
97 */
98 void SetPriority(uint8_t prio);
99 /**
100 * \brief Set the index of the classifier
101 * \param index the index of the classifier
102 */
103 void SetIndex(uint16_t index);
104 /**
105 * \brief check if a packets can be used with this classifier
106 * \param srcAddress the source ip address of the packet
107 * \param dstAddress the destination ip address of the packet
108 * \param srcPort the source port of the packet
109 * \param dstPort the destination port of the packet
110 * \param proto The L4 protocol of the packet
111 * \return true if there is a match
112 */
113 bool CheckMatch(Ipv4Address srcAddress,
114 Ipv4Address dstAddress,
115 uint16_t srcPort,
116 uint16_t dstPort,
117 uint8_t proto) const;
118 /**
119 * \return the cid associated with this classifier
120 */
121 uint16_t GetCid() const;
122 /**
123 * \return the priority of this classifier
124 */
125 uint8_t GetPriority() const;
126 /**
127 * \return the index of this classifier
128 */
129 uint16_t GetIndex() const;
130 /**
131 * \brief Set the cid associated to this classifier
132 * \param cid the connection identifier
133 */
134 void SetCid(uint16_t cid);
135
136 private:
137 /**
138 * Check match source address function
139 * \param srcAddress source IP address to check
140 * \returns true if a match
141 */
142 bool CheckMatchSrcAddr(Ipv4Address srcAddress) const;
143 /**
144 * Check match destination address function
145 * \param dstAddress destination IP address to check
146 * \returns true if a match
147 */
148 bool CheckMatchDstAddr(Ipv4Address dstAddress) const;
149 /**
150 * Check match source port function
151 * \param srcPort source port to check
152 * \returns true if a match
153 */
154 bool CheckMatchSrcPort(uint16_t srcPort) const;
155 /**
156 * Check match destination port function
157 * \param dstPort destination port to check
158 * \returns true if a match
159 */
160 bool CheckMatchDstPort(uint16_t dstPort) const;
161 /**
162 * Check match protocol function
163 * \param proto protocol number to check
164 * \returns true if a match
165 */
166 bool CheckMatchProtocol(uint8_t proto) const;
167
168 /// PortRange structure
170 {
171 uint16_t PortLow; ///< port low
172 uint16_t PortHigh; ///< port high
173 };
174
175 /// Ipv4Addr structure
176 struct Ipv4Addr
177 {
178 Ipv4Address Address; ///< IP address
179 Ipv4Mask Mask; ///< net mask
180 };
181
182 uint8_t m_priority; ///< priority
183 uint16_t m_index; ///< index
184 uint8_t m_tosLow; ///< TOS low
185 uint8_t m_tosHigh; ///< TOS high
186 uint8_t m_tosMask; ///< TOS mask
187 std::vector<uint8_t> m_protocol; ///< protocol
188 std::vector<Ipv4Addr> m_srcAddr; ///< source address
189 std::vector<Ipv4Addr> m_dstAddr; ///< destination address
190 std::vector<PortRange> m_srcPortRange; ///< source port range
191 std::vector<PortRange> m_dstPortRange; ///< destination port range
192
193 uint16_t m_cid; ///< the CID
194};
195} // namespace ns3
196
197#endif /* IPCS_CLASSIFIER_RECORD_H */
IpcsClassifierRecord class.
void SetPriority(uint8_t prio)
Set the priority of this classifier.
std::vector< PortRange > m_dstPortRange
destination port range
bool CheckMatchSrcAddr(Ipv4Address srcAddress) const
Check match source address function.
bool CheckMatchProtocol(uint8_t proto) const
Check match protocol function.
void SetIndex(uint16_t index)
Set the index of the classifier.
void AddDstAddr(Ipv4Address dstAddress, Ipv4Mask dstMask)
add a new destination ip address to the classifier
bool CheckMatchSrcPort(uint16_t srcPort) const
Check match source port function.
std::vector< PortRange > m_srcPortRange
source port range
void AddSrcPortRange(uint16_t srcPortLow, uint16_t srcPortHigh)
add a range of source port to the classifier
std::vector< Ipv4Addr > m_dstAddr
destination address
bool CheckMatchDstAddr(Ipv4Address dstAddress) const
Check match destination address function.
Tlv ToTlv() const
Creates a TLV from this classifier.
bool CheckMatch(Ipv4Address srcAddress, Ipv4Address dstAddress, uint16_t srcPort, uint16_t dstPort, uint8_t proto) const
check if a packets can be used with this classifier
void SetCid(uint16_t cid)
Set the cid associated to this classifier.
void AddDstPortRange(uint16_t dstPortLow, uint16_t dstPortHigh)
add a range of destination port to the classifier
std::vector< uint8_t > m_protocol
protocol
void AddSrcAddr(Ipv4Address srcAddress, Ipv4Mask srcMask)
add a new source ip address to the classifier
std::vector< Ipv4Addr > m_srcAddr
source address
void AddProtocol(uint8_t proto)
add a protocol to the classifier
bool CheckMatchDstPort(uint16_t dstPort) const
Check match destination port function.
Ipv4 addresses are stored in host order in this class.
a class to represent an Ipv4 address mask
This class implements the Type-Len-Value structure channel encodings as described by "IEEEStandard fo...
Definition wimax-tlv.h:76
Every class exported by the ns3 library is enclosed in the ns3 namespace.