-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRTSPacketTable.cc
96 lines (81 loc) · 2.55 KB
/
RTSPacketTable.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//
// Copyright (C) 2004 Andras Varga
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#include "RTSPacketTable.h"
void RTSPacketTable::addPacket(int squm ,RBVTRPacket * packet,IPv4Datagram * ipv4)
{
waitinglist[squm] = RBVTRPacketTOIPv4Datagram(packet, ipv4);
// waitinglist[squm] = packet;
}
RBVTRPacket * RTSPacketTable::getRBVTRPacket(int squm )
{
SqumtoRDPacket::const_iterator it = waitinglist.find(squm);
if (it == waitinglist.end())
return NULL;
else
{
return it->second.first;
}
}
void RTSPacketTable::addNexthop(int squm ,IPv4Address ipv4)
{
nexthoplist[squm] = ipv4;
}
bool RTSPacketTable::isnexthop(int squm)
{
SqumtoNextHop::const_iterator it = nexthoplist.find(squm);
if (it == nexthoplist.end())
return false;
else
{
return true;
}
}
IPv4Address RTSPacketTable::findnexthop(int squm)
{
SqumtoNextHop::const_iterator it = nexthoplist.find(squm);
return it->second;
}
IPv4Datagram * RTSPacketTable::getDataPacket(int squm )
{
SqumtoRDPacket::const_iterator it = waitinglist.find(squm);
if (it == waitinglist.end())
return NULL;
else
{
return it->second.second;
}
}
void RTSPacketTable::removePacket(int squm) {
SqumtoRDPacket::iterator it = waitinglist.find(squm);
//delete it->second;
waitinglist.erase(it);
// cancelAndDelete(squm);
}
int RTSPacketTable::findPacket(RBVTRPacket* packet) {
for (SqumtoRDPacket::const_iterator it = waitinglist.begin(); it != waitinglist.end(); it++)
{
if(it->second.first->getSeqnum()==packet->getSeqnum()&&it->second.first->getsrcAddress()==packet->getsrcAddress())
{
return it->first;
}
}
return NULL;
}
void RTSPacketTable::clear() {
waitinglist.clear();
}