OverSim
I3.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
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 
24 #ifndef __I3_H__
25 #define __I3_H__
26 
27 #include "I3Trigger.h"
28 #include "I3Identifier.h"
29 #include <omnetpp.h>
30 #include <OverlayKey.h>
31 #include "I3Message.h"
32 #include <BaseApp.h>
33 
35 class I3TriggerSet : public std::set<I3Trigger>
36 {
37  friend std::ostream& operator<<(std::ostream& os, const I3TriggerSet &t);
38 };
39 
40 typedef std::map< I3Identifier, I3TriggerSet > I3TriggerTable;
41 
46 class I3 : public BaseApp
47 {
48 protected:
52 
55 
58 
61 
63  cMessage *expirationTimer;
64 
66  int numInitStages() const;
67 
71  virtual void initializeApp(int stage);
72 
77  virtual void deliver(OverlayKey &key, cMessage *msg);
78 
82  virtual void handleUDPMessage(cMessage *msg);
83 
87  virtual void handleTimerEvent(cMessage* msg);
88 
93  void sendQueryReply(const I3Identifier &id, const I3IPAddress &add);
94 
95  virtual void forward(OverlayKey *key, cPacket **msg, NodeHandle* nextHopNode);
96 
99 
100  virtual void finish();
101 
102 public:
105 
112  const I3Identifier *findClosestMatch(const I3Identifier &t) const;
113 
117  void insertTrigger(I3Trigger &t);
118 
122  void removeTrigger(I3Trigger &t);
123 
132  void sendPacket(I3SendPacketMessage *msg);
133 
137  void sendToNode(I3SendPacketMessage *imsg);
138 
139 };
140 
141 #endif