IBR-DTN  1.0.0
KeyExchangeData.h
Go to the documentation of this file.
1 /*
2  * KeyExchangeData.h
3  *
4  * Copyright (C) 2014 IBR, TU Braunschweig
5  *
6  * Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7  * Thomas Schrader <schrader.thomas@gmail.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */
22 
23 #ifndef KEYEXCHANGEDATA_H_
24 #define KEYEXCHANGEDATA_H_
25 
27 
28 #include <string>
29 #include <sstream>
30 #include <iostream>
31 
32 namespace dtn
33 {
34  namespace security
35  {
36 
37  class KeyExchangeData : public std::stringstream
38  {
39  public:
40  enum Action
41  {
42  START = 0,
43  REQUEST = 1,
44  RESPONSE = 2,
45  COMPLETE = 3,
50  ERROR = 8
51  };
52 
54  KeyExchangeData(const Action action, const KeyExchangeSession &session);
55  KeyExchangeData(const Action action, const int protocol);
56  virtual ~KeyExchangeData();
57 
59 
61 
62  int getProtocol() const;
63  void setProtocol(int protocol);
64 
65  Action getAction() const;
66  void setAction(Action action);
67 
68  void setSession(const KeyExchangeSession &session);
69  void setSessionId(unsigned int sessionId);
70  unsigned int getSessionId() const;
71 
72  int getStep() const;
73  void setStep(int step);
74 
75  friend std::ostream &operator<<(std::ostream &stream, const KeyExchangeData &obj);
76  friend std::istream &operator>>(std::istream &stream, KeyExchangeData &obj);
77 
78  std::string toString() const;
79 
80  private:
81  unsigned int _session_id;
82  Action _action;
83  int _protocol;
84  int _step;
85  };
86 
87  } /* namespace security */
88 } /* namespace dtn */
89 #endif /* KEYEXCHANGEDATA_H_ */
unsigned int getSessionId() const
friend std::ostream & operator<<(std::ostream &stream, const KeyExchangeData &obj)
void setSession(const KeyExchangeSession &session)
void setSessionId(unsigned int sessionId)
friend std::istream & operator>>(std::istream &stream, KeyExchangeData &obj)
KeyExchangeData & operator=(const KeyExchangeData &)