OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
esi_label.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
6 
7 #include <stdio.h>
8 
9 #include <algorithm>
10 #include <string>
11 
12 #include "base/parse_object.h"
13 
14 using std::copy;
15 using std::fill;
16 using std::string;
17 
19  copy(data.begin(), data.end(), data_.begin());
20 }
21 
22 EsiLabel::EsiLabel(bool single_active) {
23  fill(data_.begin(), data_.end(), 0);
26  if (single_active) {
27  data_[2] |= 0x01;
28  }
29 }
30 
31 string EsiLabel::flags() const {
32  return (data_[2] & 0x01) ? string("sa") : string("aa");
33 }
34 
35 int EsiLabel::label() const {
38  int value = get_value(&data_[5], 3);
39  return value >> 4;
40  }
41  return 0;
42 }
43 
44 string EsiLabel::ToString() const {
45  char temp[50];
46  snprintf(temp, sizeof(temp), "esilabel:%s:%d", flags().c_str(), label());
47  return string(temp);
48 }
std::string flags() const
Definition: esi_label.cc:31
bytes_type data_
Definition: esi_label.h:37
static uint64_t get_value(const uint8_t *data, int size)
Definition: parse_object.h:39
int label() const
Definition: esi_label.cc:35
boost::array< uint8_t, kSize > bytes_type
Definition: esi_label.h:19
std::string ToString() const
Definition: esi_label.cc:44
EsiLabel(const bytes_type &data)
Definition: esi_label.cc:18