OpenSDN source code
security_group.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  * Copyright Contributors to the OpenSDN project
4  */
5 
8 
9 #include <stdio.h>
10 
11 #include <algorithm>
12 
13 
14 using std::copy;
15 using std::string;
16 
17 SecurityGroup::SecurityGroup(as2_t asn, uint32_t sgid) {
20  put_value(&data_[2], 2, asn);
21  put_value(&data_[4], 4, sgid);
22 }
23 
25  copy(data.begin(), data.end(), data_.begin());
26 }
27 
31  as2_t as_number = get_value(&data_[2], 2);
32  return as_number;
33  }
34  return 0;
35 }
36 
40  uint32_t num = get_value(&data_[4], 4);
41  return num;
42  }
43  return 0;
44 }
45 
47  uint32_t sgid = security_group_id();
48  return (sgid >= kMinGlobalId && sgid <= kMaxGlobalId);
49 }
50 
52  char temp[50];
53  snprintf(temp, sizeof(temp), "secgroup:%u:%u",
55  return string(temp);
56 }
57 
61  put_value(&data_[2], 4, asn);
62  put_value(&data_[6], 2, sgid);
63 }
64 
66  copy(data.begin(), data.end(), data_.begin());
67 }
68 
72  as_t as_number = get_value(&data_[2], 4);
73  return as_number;
74  }
75  return 0;
76 }
77 
81  uint32_t num = get_value(&data_[6], 2);
82  return num;
83  }
84  return 0;
85 }
86 
88  uint32_t sgid = security_group_id();
89  return (sgid >= kMinGlobalId && sgid <= kMaxGlobalId);
90 }
91 
93  char temp[50];
94  snprintf(temp, sizeof(temp), "secgroup:%u:%u",
96  return string(temp);
97 }
uint16_t as2_t
Definition: bgp_common.h:23
uint32_t as_t
Definition: bgp_common.h:22
SecurityGroup4ByteAs(as_t asn, uint32_t id)
as_t as_number() const
static const uint32_t kMinGlobalId
uint32_t security_group_id() const
boost::array< uint8_t, kSize > bytes_type
std::string ToString()
static const uint32_t kMaxGlobalId
uint32_t security_group_id() const
bool IsGlobal() const
static const uint32_t kMinGlobalId
static const uint32_t kMaxGlobalId
boost::array< uint8_t, kSize > bytes_type
std::string ToString()
bytes_type data_
as2_t as_number() const
SecurityGroup(as2_t asn, uint32_t id)
static void put_value(uint8_t *data, int size, uint64_t value)
Definition: parse_object.h:56
static uint64_t get_value(const uint8_t *data, int size)
Definition: parse_object.h:40