A Discrete-Event Network Simulator
API
qkd-app-header.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2020 DOTFEESA www.tk.etf.unsa.ba
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
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  * Author: Miralem Mehic <miralem.mehic@ieee.org>,
19  * Emir Dervisevic <emir.dervisevic@etf.unsa.ba>
20  * Oliver Mauhart <oliver.maurhart@ait.ac.at>
21  */
22 
23 #ifndef QKD_APP_HEADER_H
24 #define QKD_APP_HEADER_H
25 
26 #include <queue>
27 #include <string>
28 #include "ns3/packet.h"
29 #include "ns3/header.h"
30 #include "ns3/object.h"
31 
32 namespace ns3 {
33 
70 class QKDAppHeader : public Header
71 {
72  public:
73 
77  QKDAppHeader ();
78 
83  static TypeId GetTypeId ();
88  TypeId GetInstanceTypeId () const;
89 
94  void Print (std::ostream &os) const;
95 
101  bool operator== (QKDAppHeader const & o) const;
102 
107  uint32_t GetSerializedSize () const;
108 
113  void Serialize (Buffer::Iterator start) const;
114 
120 
125  void SetLength (uint32_t value);
126 
131  uint32_t GetLength (void) const;
132 
137  void SetMessageId (uint32_t value);
138 
143  uint32_t GetMessageId (void) const;
144 
149  void SetEncrypted (uint32_t value);
150 
155  uint32_t GetEncrypted (void) const;
156 
161  void SetAuthenticated (uint32_t value);
162 
167  uint32_t GetAuthenticated (void) const;
168 
173  void SetEncryptionKeyId (std::string value);
174 
179  std::string GetEncryptionKeyId (void) const;
180 
185  void SetAuthenticationKeyId (std::string keyID);
186 
191  std::string GetAuthenticationKeyId (void) const;
192 
197  void SetAuthTag (std::string value);
198 
203  std::string GetAuthTag (void) const;
204 
209  bool IsValid () const
210  {
211  return m_valid;
212  }
213 
214  private:
215 
216  uint32_t m_length;
217  uint32_t m_messageId;
218 
219  uint8_t m_encryped;
220  uint8_t m_authenticated;
221 
222  std::string m_encryptionKeyId;
223  std::string m_authenticationKeyId;
224  std::string m_authTag;
225 
226  bool m_valid;
227 
228  };
229 
230 
231 }
232 // namespace ns3
233 
234 #endif /* QKD_APP_HEADER_H */
235 
236 
iterator in a Buffer instance
Definition: buffer.h:99
Protocol header serialization and deserialization.
Definition: header.h:43
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
QKD app packet header that carries info about used encryption, auth tag and other.
bool m_valid
Is the header valid or corrupted?
bool operator==(QKDAppHeader const &o) const
Compare the two QKDApp packets.
QKDAppHeader()
Constructor.
std::string GetEncryptionKeyId(void) const
Read the encryption key identifier.
std::string GetAuthTag(void) const
Read the authentication tag.
uint32_t m_messageId
The message identifier field.
uint32_t GetSerializedSize() const
Get the serialized size of a packet.
std::string m_authTag
The authentication tag field.
uint32_t m_length
The message length field.
uint8_t m_authenticated
The authentication flag.
void SetMessageId(uint32_t value)
Set message identifier.
void SetEncryptionKeyId(std::string value)
Set the encryption key identifier.
uint8_t m_encryped
The encryption flag.
void SetEncrypted(uint32_t value)
Set the encrypted field.
uint32_t GetLength(void) const
Get message length.
void SetLength(uint32_t value)
Set the message length.
bool IsValid() const
Check that type is valid.
void SetAuthenticated(uint32_t value)
Set the authentication field.
uint32_t GetAuthenticated(void) const
Read the authentication field.
void SetAuthTag(std::string value)
Set the authentication tag.
std::string GetAuthenticationKeyId(void) const
Read the authentication key identifier.
uint32_t GetMessageId(void) const
Get message identifier.
TypeId GetInstanceTypeId() const
Get the type ID.
std::string m_authenticationKeyId
The authentication key identifier field.
void Print(std::ostream &os) const
Print the QKDApp packet.
void SetAuthenticationKeyId(std::string keyID)
Set the authentication key identifier.
static TypeId GetTypeId()
Get the type ID.
uint32_t GetEncrypted(void) const
Read the encrypted field.
std::string m_encryptionKeyId
The encryption key identifier field.
void Serialize(Buffer::Iterator start) const
Serialize the packet.
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.
def start()
Definition: core.py:1853