OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tunnel_encap.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
6 
7 
8 #include <algorithm>
9 #include <sstream>
10 
11 
12 using std::copy;
13 using std::fill;
14 using std::string;
15 
16 TunnelEncap::TunnelEncap(string encap) {
17  fill(data_.begin(), data_.end(), 0);
19  if (id == TunnelEncapType::UNSPEC) return;
20  data_[0] = 0x03;
21  data_[1] = 0x0C;
22  // Reserved
23  put_value(&data_[2], 4, 0);
24  put_value(&data_[6], 2, id);
25 }
26 
28  fill(data_.begin(), data_.end(), 0);
29  data_[0] = 0x03;
30  data_[1] = 0x0C;
31  // Reserved
32  put_value(&data_[2], 4, 0);
33  put_value(&data_[6], 2, tunnel_encap);
34 }
35 
37  copy(data.begin(), data.end(), data_.begin());
38 }
39 
41  if (data_[0] != 0x03 || data_[1] != 0x0c)
43  uint16_t value = get_value(&data_[6], 2);
45  return static_cast<TunnelEncapType::Encap>(value);
46  } else {
48  }
49 }
50 
52  string str("encapsulation:");
54  return str;
55 }
56 
59 }
static bool TunnelEncapIsValid(uint16_t value)
std::string ToString()
Definition: tunnel_encap.cc:51
static const std::string & TunnelEncapToString(TunnelEncapType::Encap encap)
TunnelEncap(TunnelEncapType::Encap encap)
Definition: tunnel_encap.cc:27
static uint64_t get_value(const uint8_t *data, int size)
Definition: parse_object.h:39
std::string ToXmppString()
Definition: tunnel_encap.cc:57
bytes_type data_
Definition: tunnel_encap.h:39
TunnelEncapType::Encap tunnel_encap() const
Definition: tunnel_encap.cc:40
static const std::string & TunnelEncapToXmppString(TunnelEncapType::Encap encap)
boost::array< uint8_t, kSize > bytes_type
Definition: tunnel_encap.h:20
static TunnelEncapType::Encap TunnelEncapFromString(const std::string &encap)
static void put_value(uint8_t *data, int size, uint64_t value)
Definition: parse_object.h:55