1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3 * Copyright (c) 2007,2008, 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 * Author: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
19 * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
20 */
21
22 #include "ss-record.h"
23 #include "service-flow.h"
24 #include <stdint.h>
25
26 namespace ns3 {
27
SSRecord(void)28 SSRecord::SSRecord (void)
29 {
30 Initialize ();
31 }
32
SSRecord(Mac48Address macAddress)33 SSRecord::SSRecord (Mac48Address macAddress)
34 {
35 m_macAddress = macAddress;
36 Initialize ();
37 }
38
SSRecord(Mac48Address macAddress,Ipv4Address IPaddress)39 SSRecord::SSRecord (Mac48Address macAddress, Ipv4Address IPaddress)
40 {
41 m_macAddress = macAddress;
42 m_IPAddress = IPaddress;
43 Initialize ();
44 }
45
46 void
Initialize(void)47 SSRecord::Initialize (void)
48 {
49 m_basicCid = Cid ();
50 m_primaryCid = Cid ();
51
52 m_rangingCorrectionRetries = 0;
53 m_invitedRangingRetries = 0;
54 m_modulationType = WimaxPhy::MODULATION_TYPE_BPSK_12;
55 m_rangingStatus = WimaxNetDevice::RANGING_STATUS_EXPIRED;
56 m_pollForRanging = false;
57 m_areServiceFlowsAllocated = false;
58 m_pollMeBit = false;
59
60 m_sfTransactionId = 0;
61 m_dsaRspRetries = 0;
62
63 m_serviceFlows = new std::vector<ServiceFlow*> ();
64 m_dsaRsp = DsaRsp ();
65 m_broadcast = 0;
66 }
67
~SSRecord(void)68 SSRecord::~SSRecord (void)
69 {
70 delete m_serviceFlows;
71 m_serviceFlows = 0;
72 }
73
74 void
SetIPAddress(Ipv4Address IPAddress)75 SSRecord::SetIPAddress (Ipv4Address IPAddress)
76 {
77 m_IPAddress = IPAddress;
78 }
79
GetIPAddress(void)80 Ipv4Address SSRecord::GetIPAddress (void)
81 {
82 return m_IPAddress;
83 }
84
85 void
SetBasicCid(Cid basicCid)86 SSRecord::SetBasicCid (Cid basicCid)
87 {
88 m_basicCid = basicCid;
89 }
90
91 Cid
GetBasicCid(void) const92 SSRecord::GetBasicCid (void) const
93 {
94 return m_basicCid;
95 }
96
97 void
SetPrimaryCid(Cid primaryCid)98 SSRecord::SetPrimaryCid (Cid primaryCid)
99 {
100 m_primaryCid = primaryCid;
101 }
102
103 Cid
GetPrimaryCid(void) const104 SSRecord::GetPrimaryCid (void) const
105 {
106 return m_primaryCid;
107 }
108
109 void
SetMacAddress(Mac48Address macAddress)110 SSRecord::SetMacAddress (Mac48Address macAddress)
111 {
112 m_macAddress = macAddress;
113 }
114
115 Mac48Address
GetMacAddress(void) const116 SSRecord::GetMacAddress (void) const
117 {
118 return m_macAddress;
119 }
120
121 uint8_t
GetRangingCorrectionRetries(void) const122 SSRecord::GetRangingCorrectionRetries (void) const
123 {
124 return m_rangingCorrectionRetries;
125 }
126
127 void
ResetRangingCorrectionRetries(void)128 SSRecord::ResetRangingCorrectionRetries (void)
129 {
130 m_rangingCorrectionRetries = 0;
131 }
132
133 void
IncrementRangingCorrectionRetries(void)134 SSRecord::IncrementRangingCorrectionRetries (void)
135 {
136 m_rangingCorrectionRetries++;
137 }
138
139 uint8_t
GetInvitedRangRetries(void) const140 SSRecord::GetInvitedRangRetries (void) const
141 {
142 return m_invitedRangingRetries;
143 }
144
145 void
ResetInvitedRangingRetries(void)146 SSRecord::ResetInvitedRangingRetries (void)
147 {
148 m_invitedRangingRetries = 0;
149 }
150
151 void
IncrementInvitedRangingRetries(void)152 SSRecord::IncrementInvitedRangingRetries (void)
153 {
154 m_invitedRangingRetries++;
155 }
156
157 void
SetModulationType(WimaxPhy::ModulationType modulationType)158 SSRecord::SetModulationType (WimaxPhy::ModulationType modulationType)
159 {
160 m_modulationType = modulationType;
161 }
162
163 WimaxPhy::ModulationType
GetModulationType(void) const164 SSRecord::GetModulationType (void) const
165 {
166 return m_modulationType;
167 }
168
169 void
SetRangingStatus(WimaxNetDevice::RangingStatus rangingStatus)170 SSRecord::SetRangingStatus (WimaxNetDevice::RangingStatus rangingStatus)
171 {
172 m_rangingStatus = rangingStatus;
173 }
174
175 WimaxNetDevice::RangingStatus
GetRangingStatus(void) const176 SSRecord::GetRangingStatus (void) const
177 {
178 return m_rangingStatus;
179 }
180
181 void
EnablePollForRanging(void)182 SSRecord::EnablePollForRanging (void)
183 {
184 m_pollForRanging = true;
185 }
186
187 void
DisablePollForRanging(void)188 SSRecord::DisablePollForRanging (void)
189 {
190 m_pollForRanging = false;
191 }
192
193 bool
GetPollForRanging(void) const194 SSRecord::GetPollForRanging (void) const
195 {
196 return m_pollForRanging;
197 }
198
199 void
SetAreServiceFlowsAllocated(bool val)200 SSRecord::SetAreServiceFlowsAllocated (bool val)
201 {
202 m_areServiceFlowsAllocated = val;
203 }
204
205 bool
GetAreServiceFlowsAllocated(void) const206 SSRecord::GetAreServiceFlowsAllocated (void) const
207 {
208 return m_areServiceFlowsAllocated;
209 }
210
211 void
SetPollMeBit(bool pollMeBit)212 SSRecord::SetPollMeBit (bool pollMeBit)
213 {
214 m_pollMeBit = pollMeBit;
215 }
216
217 bool
GetPollMeBit(void) const218 SSRecord::GetPollMeBit (void) const
219 {
220 return m_pollMeBit;
221 }
222
223 void
AddServiceFlow(ServiceFlow * serviceFlow)224 SSRecord::AddServiceFlow (ServiceFlow *serviceFlow)
225 {
226 m_serviceFlows->push_back (serviceFlow);
227 }
228
GetServiceFlows(enum ServiceFlow::SchedulingType schedulingType) const229 std::vector<ServiceFlow*> SSRecord::GetServiceFlows (enum ServiceFlow::SchedulingType schedulingType) const
230 {
231 std::vector<ServiceFlow*> tmpServiceFlows;
232 for (std::vector<ServiceFlow*>::iterator iter = m_serviceFlows->begin (); iter != m_serviceFlows->end (); ++iter)
233 {
234 if (((*iter)->GetSchedulingType () == schedulingType) || (schedulingType == ServiceFlow::SF_TYPE_ALL))
235 {
236 tmpServiceFlows.push_back ((*iter));
237 }
238 }
239 return tmpServiceFlows;
240 }
241
242 void
SetIsBroadcastSS(bool broadcast_enable)243 SSRecord::SetIsBroadcastSS (bool broadcast_enable)
244 {
245 m_broadcast = broadcast_enable;
246 }
247
248 bool
GetIsBroadcastSS(void)249 SSRecord::GetIsBroadcastSS (void)
250 {
251 return m_broadcast;
252 }
253
254 bool
GetHasServiceFlowUgs(void) const255 SSRecord::GetHasServiceFlowUgs (void) const
256 {
257 for (std::vector<ServiceFlow*>::iterator iter = m_serviceFlows->begin (); iter != m_serviceFlows->end (); ++iter)
258 {
259 if ((*iter)->GetSchedulingType () == ServiceFlow::SF_TYPE_UGS)
260 {
261 return true;
262 }
263 }
264 return false;
265 }
266
267 bool
GetHasServiceFlowRtps(void) const268 SSRecord::GetHasServiceFlowRtps (void) const
269 {
270 for (std::vector<ServiceFlow*>::iterator iter = m_serviceFlows->begin (); iter != m_serviceFlows->end (); ++iter)
271 {
272 if ((*iter)->GetSchedulingType () == ServiceFlow::SF_TYPE_RTPS)
273 {
274 return true;
275 }
276 }
277 return false;
278 }
279
280 bool
GetHasServiceFlowNrtps(void) const281 SSRecord::GetHasServiceFlowNrtps (void) const
282 {
283 for (std::vector<ServiceFlow*>::iterator iter = m_serviceFlows->begin (); iter != m_serviceFlows->end (); ++iter)
284 {
285 if ((*iter)->GetSchedulingType () == ServiceFlow::SF_TYPE_NRTPS)
286 {
287 return true;
288 }
289 }
290 return false;
291 }
292
293 bool
GetHasServiceFlowBe(void) const294 SSRecord::GetHasServiceFlowBe (void) const
295 {
296 for (std::vector<ServiceFlow*>::iterator iter = m_serviceFlows->begin (); iter != m_serviceFlows->end (); ++iter)
297 {
298 if ((*iter)->GetSchedulingType () == ServiceFlow::SF_TYPE_BE)
299 {
300 return true;
301 }
302 }
303 return false;
304 }
305
306 void
SetSfTransactionId(uint16_t sfTransactionId)307 SSRecord::SetSfTransactionId (uint16_t sfTransactionId)
308 {
309 m_sfTransactionId = sfTransactionId;
310 }
311
GetSfTransactionId(void) const312 uint16_t SSRecord::GetSfTransactionId (void) const
313 {
314 return m_sfTransactionId;
315 }
316
317 void
SetDsaRspRetries(uint8_t dsaRspRetries)318 SSRecord::SetDsaRspRetries (uint8_t dsaRspRetries)
319 {
320 m_dsaRspRetries = dsaRspRetries;
321 }
322
323 void
IncrementDsaRspRetries(void)324 SSRecord::IncrementDsaRspRetries (void)
325 {
326 m_dsaRspRetries++;
327 }
328
329 uint8_t
GetDsaRspRetries(void) const330 SSRecord::GetDsaRspRetries (void) const
331 {
332 return m_dsaRspRetries;
333 }
334
335 void
SetDsaRsp(DsaRsp dsaRsp)336 SSRecord::SetDsaRsp (DsaRsp dsaRsp)
337 {
338 m_dsaRsp = dsaRsp;
339 }
340
341 DsaRsp
GetDsaRsp(void) const342 SSRecord::GetDsaRsp (void) const
343 {
344 return m_dsaRsp;
345 }
346
347 } // namespace ns3
348