Download this file

DV.h    107 lines (75 with data), 2.4 kB

  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
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
/*
* DV.h
*
* Created on: Mar 23, 2015
* Author: gaixas1
*/
#ifndef DV_H_
#define DV_H_
#include <DomainRouting/rModule.h>
namespace DMRnmsDV {
using namespace DMRnms;
///////////////////////////////////////////////////////////////////////
// Data structures
struct rtEntry {
std::string addr;
unsigned short metric;
rtEntry()
:addr(""), metric(UINT16_MAX){}
rtEntry(const std::string &_addr, const unsigned short &_metric)
:addr(_addr), metric(_metric){}
};
typedef std::vector<rtEntry> entriesL;
typedef std::vector<rtEntry>::iterator entriesIt;
typedef std::map<Address, unsigned short> neighMetric;
typedef neighMetric::iterator neighMetricIt;
struct tEntry {
Address addr;
unsigned short metric;
tEntry()
:addr(""), metric(UINT16_MAX){}
tEntry(const std::string &_addr, const unsigned short &_metric)
:addr(_addr), metric(_metric){}
};
typedef std::map<std::string, tEntry> tTable;
typedef tTable::iterator tTableIt;
typedef std::set<std::string> sSet;
typedef sSet::iterator sSetIt;
///////////////////////////////////////////////////////////////////////
// Update Message
class DVUpdate : public RoutingUpdate {
public:
DVUpdate(const Address &_addr, const std::string &_domain);
void addEntry(rtEntry _e);
entriesIt entriesBegin();
entriesIt entriesEnd();
protected:
entriesL entries;
};
///////////////////////////////////////////////////////////////////////
// Routing Module
class DomainRouting;
class DV: public rModule {
public:
DV(Routing * parent, const Address &_nAddr,const std::string &_domain, const std::string &_addr);
bool processUpdate(RoutingUpdate * update);
void addFlow(const Address &_nAddr, const std::string &_addr, const unsigned short &_metric);
void removeFlow(const Address &_nAddr, const std::string &_addr);
void addAddr(const std::string &_addr);
void removeAddr(const std::string &_addr);
void setInfMetric(const unsigned short &inf);
dmNxt getChanges();
dmNxt getAll();
void handleMessage(cMessage *msg);
protected:
tTable table;
neighMetric nei;
unsigned short infMetric;
s2A changes;
sSet changedEntries;
sSet myAddrSet;
bool scheduledUpdate;
void scheduleUpdate();
};
} /* namespace DomainRoutingDV */
#endif /* DV_H_ */