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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
18 *
19 */
20
21#ifndef IPCS_CLASSIFIER_RECORD_H
22#define IPCS_CLASSIFIER_RECORD_H
23
24#include "wimax-tlv.h"
25
26#include "ns3/ipv4-address.h"
27
28#include <stdint.h>
29
30namespace ns3
31{
32
33/**
34 * \ingroup wimax
35 * \brief IpcsClassifierRecord class
36 */
38{
39 public:
42 /**
43 * \brief creates a classifier records and sets all its parameters
44 * \param srcAddress the source ip address
45 * \param srcMask the mask to apply on the source ip address
46 * \param dstAddress the destination ip address
47 * \param dstMask the mask to apply on the destination ip address
48 * \param srcPortLow the lower boundary of the source port range
49 * \param srcPortHigh the higher boundary of the source port range
50 * \param dstPortLow the lower boundary of the destination port range
51 * \param dstPortHigh the higher boundary of the destination port range
52 * \param protocol the L4 protocol
53 * \param priority the priority of this classifier
54 *
55 */
57 Ipv4Mask srcMask,
58 Ipv4Address dstAddress,
59 Ipv4Mask dstMask,
60 uint16_t srcPortLow,
61 uint16_t srcPortHigh,
62 uint16_t dstPortLow,
63 uint16_t dstPortHigh,
64 uint8_t protocol,
65 uint8_t priority);
66 /**
67 * \brief Decodes a TLV and creates a classifier
68 * \param tlv the TLV to decode and from which the classifier parameters will be extracted
69 */
71 /**
72 * \brief Creates a TLV from this classifier
73 * \return the created TLV
74 */
75 Tlv ToTlv() const;
76 /**
77 * \brief add a new source ip address to the classifier
78 * \param srcAddress the source ip address
79 * \param srcMask the mask to apply on the source ip address
80 */
81 void AddSrcAddr(Ipv4Address srcAddress, Ipv4Mask srcMask);
82 /**
83 * \brief add a new destination ip address to the classifier
84 * \param dstAddress the destination ip address
85 * \param dstMask the mask to apply on the destination ip address
86 */
87 void AddDstAddr(Ipv4Address dstAddress, Ipv4Mask dstMask);
88 /**
89 * \brief add a range of source port to the classifier
90 * \param srcPortLow the lower boundary of the source port range
91 * \param srcPortHigh the higher boundary of the source port range
92 */
93 void AddSrcPortRange(uint16_t srcPortLow, uint16_t srcPortHigh);
94 /**
95 * \brief add a range of destination port to the classifier
96 * \param dstPortLow the lower boundary of the destination port range
97 * \param dstPortHigh the higher boundary of the destination port range
98 */
99 void AddDstPortRange(uint16_t dstPortLow, uint16_t dstPortHigh);
100 /**
101 * \brief add a protocol to the classifier
102 * \param proto the L4 protocol to add
103 */
104 void AddProtocol(uint8_t proto);
105 /**
106 * \brief Set the priority of this classifier
107 * \param prio the priority of the classifier
108 */
109 void SetPriority(uint8_t prio);
110 /**
111 * \brief Set the index of the classifier
112 * \param index the index of the classifier
113 */
114 void SetIndex(uint16_t index);
115 /**
116 * \brief check if a packets can be used with this classifier
117 * \param srcAddress the source ip address of the packet
118 * \param dstAddress the destination ip address of the packet
119 * \param srcPort the source port of the packet
120 * \param dstPort the destination port of the packet
121 * \param proto The L4 protocol of the packet
122 * \return true if there is a match
123 */
124 bool CheckMatch(Ipv4Address srcAddress,
125 Ipv4Address dstAddress,
126 uint16_t srcPort,
127 uint16_t dstPort,
128 uint8_t proto) const;
129 /**
130 * \return the cid associated with this classifier
131 */
132 uint16_t GetCid() const;
133 /**
134 * \return the priority of this classifier
135 */
136 uint8_t GetPriority() const;
137 /**
138 * \return the index of this classifier
139 */
140 uint16_t GetIndex() const;
141 /**
142 * \brief Set the cid associated to this classifier
143 * \param cid the connection identifier
144 */
145 void SetCid(uint16_t cid);
146
147 private:
148 /**
149 * Check match source address function
150 * \param srcAddress source IP address to check
151 * \returns true if a match
152 */
153 bool CheckMatchSrcAddr(Ipv4Address srcAddress) const;
154 /**
155 * Check match destination address function
156 * \param dstAddress destination IP address to check
157 * \returns true if a match
158 */
159 bool CheckMatchDstAddr(Ipv4Address dstAddress) const;
160 /**
161 * Check match source port function
162 * \param srcPort source port to check
163 * \returns true if a match
164 */
165 bool CheckMatchSrcPort(uint16_t srcPort) const;
166 /**
167 * Check match destination port function
168 * \param dstPort destination port to check
169 * \returns true if a match
170 */
171 bool CheckMatchDstPort(uint16_t dstPort) const;
172 /**
173 * Check match protocol function
174 * \param proto protocol number to check
175 * \returns true if a match
176 */
177 bool CheckMatchProtocol(uint8_t proto) const;
178
179 /// PortRange structure
181 {
182 uint16_t PortLow; ///< port low
183 uint16_t PortHigh; ///< port high
184 };
185
186 /// Ipv4Addr structure
187 struct Ipv4Addr
188 {
189 Ipv4Address Address; ///< IP address
190 Ipv4Mask Mask; ///< net mask
191 };
192
193 uint8_t m_priority; ///< priority
194 uint16_t m_index; ///< index
195 uint8_t m_tosLow; ///< TOS low
196 uint8_t m_tosHigh; ///< TOS high
197 uint8_t m_tosMask; ///< TOS mask
198 std::vector<uint8_t> m_protocol; ///< protocol
199 std::vector<Ipv4Addr> m_srcAddr; ///< source address
200 std::vector<Ipv4Addr> m_dstAddr; ///< destination address
201 std::vector<PortRange> m_srcPortRange; ///< source port range
202 std::vector<PortRange> m_dstPortRange; ///< destination port range
203
204 uint16_t m_cid; ///< the CID
205};
206} // namespace ns3
207
208#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.
Definition: ipv4-address.h:42
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:257
This class implements the Type-Len-Value structure channel encodings as described by "IEEE Standard f...
Definition: wimax-tlv.h:87
Every class exported by the ns3 library is enclosed in the ns3 namespace.