A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
app-key.h
Go to the documentation of this file.
1/*
2 * Copyright(c) 2020 DOTFEESA www.tk.etf.unsa.ba
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 *
7 *
8 * Author: Emir Dervisevic <emir.dervisevic@etf.unsa.ba>
9 * Miralem Mehic <miralem.mehic@ieee.org>
10 */
11#ifndef APP_KEY_H
12#define APP_KEY_H
13
14#include <stdint.h>
15#include <algorithm>
16#include <stdint.h>
17
18#include "ns3/packet.h"
19#include "ns3/object.h"
20#include "ns3/callback.h"
21#include "ns3/assert.h"
22#include "ns3/ptr.h"
23#include "ns3/simulator.h"
24#include "ns3/nstime.h"
25#include "ns3/traced-callback.h"
26#include "ns3/deprecated.h"
27#include "qkd-key.h"
28
29
30namespace ns3 {
31
32/**
33 * @ingroup qkd
34 * @brief The key at the application layer. It has lifetime and type attributes in addition
35 * to QKD key class attributes.
36 */
37 class AppKey : public QKDKey {
38 public:
39
45
47 std::string id,
48 std::string value,
49 Type type,
50 uint32_t lifetime
51 ) : QKDKey(id, value) {
52 m_type = type;
53 m_lifetime = lifetime;
54
55 }
56
58 uint32_t index,
59 std::string value,
60 Type type,
61 uint32_t lifetime
62 ) : QKDKey("", value) {
63 m_index = index;
64 m_type = type;
65 m_lifetime = lifetime;
66 }
67
69 return m_lifetime;
70 }
71
72 void SetLifetime(uint32_t lifetime) {
73 m_lifetime = lifetime;
74 }
75
77 if(m_lifetime >= amount)
79 else
80 m_lifetime = 0;
81 }
82
83 Type GetType() const {
84 return m_type;
85 }
86
87 void SetType(Type type) {
88 m_type = type;
89 }
90
91 void SetIndex(uint32_t index){
92 m_index = index;
93 }
94
96 return m_index;
97 }
98
99
100 private:
101
102 Type m_type; //<!Key type
103 uint32_t m_index; //<!Key index(for ETSI 004 clients)
104 uint32_t m_lifetime; //<!Key lifetime value in bytes
105
106 };
107
108} // namespace ns3
109
110#endif /* APP_KEY_H */
The key at the application layer.
Definition app-key.h:37
AppKey(uint32_t index, std::string value, Type type, uint32_t lifetime)
Definition app-key.h:57
AppKey(std::string id, std::string value, Type type, uint32_t lifetime)
Definition app-key.h:46
uint32_t m_index
Definition app-key.h:103
Type m_type
Definition app-key.h:102
uint32_t GetLifetime() const
Definition app-key.h:68
void SetLifetime(uint32_t lifetime)
Definition app-key.h:72
@ AUTHENTICATION
Definition app-key.h:43
uint32_t m_lifetime
Definition app-key.h:104
Type GetType() const
Definition app-key.h:83
uint32_t GetIndex() const
Definition app-key.h:95
void SetType(Type type)
Definition app-key.h:87
void SetIndex(uint32_t index)
Definition app-key.h:91
void UseLifetime(uint32_t amount)
Definition app-key.h:76
The QKD key is an elementary class of QKDNetSim.
Definition qkd-key.h:59
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static unsigned int value(char c)