-
Notifications
You must be signed in to change notification settings - Fork 2
/
ClientMemory.cc
125 lines (105 loc) · 2.49 KB
/
ClientMemory.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include <string.h>
#include <omnetpp.h>
#include <bitset>
#include <iostream>
#include "ClientMemory.h"
#include "MacTableEntry_m.h"
#include "QuantumKeyEntry_m.h"
Define_Module(ClientMemory);
void ClientMemory::initialize()
{
}
void ClientMemory::handleMessage(cMessage *msg)
{
}
MacTableEntry ClientMemory::getMacTable(int index)
{
MacTableEntry *macTableEntry = (MacTableEntry *) this->quantumTable[index];
return *macTableEntry;
}
void ClientMemory::addMacTableEntry(MacTableEntry *macTableEntry)
{
this->quantumTable.add(macTableEntry);
}
int ClientMemory::getMacTableSize()
{
return this->quantumTable.size();
}
QuantumKeyEntry ClientMemory::getQuantumKey(int index)
{
QuantumKeyEntry *quantumKeyEntry = (QuantumKeyEntry *) this->quantumKey[index];
return *quantumKeyEntry;
}
void ClientMemory::addQautumKey(QuantumKeyEntry *key)
{
this->quantumKey.add(key);
}
int ClientMemory::getNumberOfKey()
{
return this->quantumKey.size();
}
int ClientMemory::getPendingTransaction()
{
int index = 0;
for(int i=0; i<this->quantumKey.size(); i++)
{
QuantumKeyEntry *qKey = (QuantumKeyEntry *) this->quantumKey[i];
if(strcmp(qKey->getKey(),"") == 0)
{
index = i;
break;
}
}
return index;
}
std::string ClientMemory::getPendingKeyMacAddress()
{
std::string desMac = "";
for(int i=0; i<this->quantumKey.size(); i++)
{
QuantumKeyEntry *qKey = (QuantumKeyEntry *) this->quantumKey[i];
if(strcmp(qKey->getStatus(),"") == 0)
{
desMac = qKey->getMacAddress();
qKey->setStatus("Active");
break;
}
}
return desMac;
}
void ClientMemory::setPendingKey(std::string key)
{
for(int i=0; i<this->quantumKey.size(); i++)
{
QuantumKeyEntry *qKey = (QuantumKeyEntry *) this->quantumKey[i];
if(strcmp(qKey->getKey(),"") == 0)
{
qKey->setKey(key.c_str());
break;
}
}
}
std::string ClientMemory::getInitialKey()
{
return this->initialKey;
}
void ClientMemory::setInitialKey(std::string key)
{
this->initialKey=key;
}
std::string ClientMemory::getPolarizationStates()
{
return this->polarizationStates;
}
void ClientMemory::setPolarizationStates(std::string states)
{
this->polarizationStates = states;
}
std::string ClientMemory::getInitialKeyBin()
{
return this->initialKeyBin;
}
void ClientMemory::setInitialKeyBin(std::string bin)
{
this->initialKeyBin = bin;
}