A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
cs-parameters.cc
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 INRIA, UDcast
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
19  *
20  */
21 #include "wimax-tlv.h"
22 #include "cs-parameters.h"
23 
24 namespace ns3 {
25 CsParameters::CsParameters ()
26 {
27  m_classifierDscAction = CsParameters::ADD;
28 }
29 CsParameters::~CsParameters ()
30 {
31 
32 }
33 
34 CsParameters::CsParameters (Tlv tlv)
35 {
36  NS_ASSERT_MSG (tlv.GetType () == SfVectorTlvValue::IPV4_CS_Parameters,
37  "Invalid TLV");
38  CsParamVectorTlvValue* param = ((CsParamVectorTlvValue*)(tlv.PeekValue ()));
39 
40  for (std::vector<Tlv*>::const_iterator iter = param->Begin (); iter
41  != param->End (); ++iter)
42  {
43  switch ((*iter)->GetType ())
44  {
45  case CsParamVectorTlvValue::Classifier_DSC_Action:
46  {
47  m_classifierDscAction
48  = (enum CsParameters::Action)((U8TlvValue*)((*iter)->PeekValue ()))->GetValue ();
49  break;
50  }
51  case CsParamVectorTlvValue::Packet_Classification_Rule:
52  {
53  m_packetClassifierRule
54  = IpcsClassifierRecord (*(*iter));
55  break;
56  }
57  }
58  }
59 }
60 
61 CsParameters::CsParameters (enum CsParameters::Action classifierDscAction,
62  IpcsClassifierRecord classifier)
63 {
64  m_classifierDscAction = classifierDscAction;
65  m_packetClassifierRule = classifier;
66 }
67 void
68 CsParameters::SetClassifierDscAction (enum CsParameters::Action action)
69 {
70  m_classifierDscAction = action;
71 }
72 void
74 {
75  m_packetClassifierRule = packetClassifierRule;
76 }
77 enum CsParameters::Action
79 {
80  return m_classifierDscAction;
81 }
84 {
85  return m_packetClassifierRule;
86 }
87 Tlv
88 CsParameters::ToTlv (void) const
89 {
91  tmp.Add (Tlv (CsParamVectorTlvValue::Classifier_DSC_Action,1, U8TlvValue (m_classifierDscAction)));
92  tmp.Add (m_packetClassifierRule.ToTlv ());
93  return Tlv (SfVectorTlvValue::IPV4_CS_Parameters, tmp.GetSerializedSize (), tmp);
94 }
95 }
enum Action GetClassifierDscAction(void) const
void SetClassifierDscAction(enum Action action)
sets the dynamic service classifier action to ADD, Change or delete. Only ADD is supported ...
this class implements the convergence sub-layer descriptor as a tlv vector
Definition: wimax-tlv.h:235
This class implements the Type-Len-Value structure channel encodings as described by "IEEE Standard f...
Definition: wimax-tlv.h:64
void SetPacketClassifierRule(IpcsClassifierRecord packetClassifierRule)
sets the packet classifier rules
Tlv ToTlv(void) const
creates a tlv from the classifier record
#define NS_ASSERT_MSG(condition, message)
Definition: assert.h:86
Tlv ToTlv(void) const
Creates a TLV from this classifier.
IpcsClassifierRecord GetPacketClassifierRule(void) const