OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
security_group.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
7 
8 #include <stdio.h>
9 
10 #include <algorithm>
11 
12 
13 using std::copy;
14 using std::string;
15 
16 SecurityGroup::SecurityGroup(as2_t asn, uint32_t sgid) {
19  put_value(&data_[2], 2, asn);
20  put_value(&data_[4], 4, sgid);
21 }
22 
24  copy(data.begin(), data.end(), data_.begin());
25 }
26 
30  as2_t as_number = get_value(&data_[2], 2);
31  return as_number;
32  }
33  return 0;
34 }
35 
39  uint32_t num = get_value(&data_[4], 4);
40  return num;
41  }
42  return 0;
43 }
44 
46  uint32_t sgid = security_group_id();
47  return (sgid >= kMinGlobalId && sgid <= kMaxGlobalId);
48 }
49 
51  char temp[50];
52  snprintf(temp, sizeof(temp), "secgroup:%u:%u",
54  return string(temp);
55 }
56 
60  put_value(&data_[2], 4, asn);
61  put_value(&data_[6], 2, sgid);
62 }
63 
65  copy(data.begin(), data.end(), data_.begin());
66 }
67 
71  as_t as_number = get_value(&data_[2], 4);
72  return as_number;
73  }
74  return 0;
75 }
76 
80  uint32_t num = get_value(&data_[6], 2);
81  return num;
82  }
83  return 0;
84 }
85 
87  uint32_t sgid = security_group_id();
88  return (sgid >= kMinGlobalId && sgid <= kMaxGlobalId);
89 }
90 
92  char temp[50];
93  snprintf(temp, sizeof(temp), "secgroup:%u:%u",
95  return string(temp);
96 }
bool IsGlobal() const
static const uint32_t kMinGlobalId
static const uint32_t kMaxGlobalId
std::string ToString()
uint32_t as_t
Definition: bgp_common.h:21
static uint64_t get_value(const uint8_t *data, int size)
Definition: parse_object.h:39
uint32_t security_group_id() const
std::string ToString()
boost::array< uint8_t, kSize > bytes_type
uint16_t as2_t
Definition: bgp_common.h:22
uint32_t security_group_id() const
static const uint32_t kMaxGlobalId
boost::array< uint8_t, kSize > bytes_type
bytes_type data_
as2_t as_number() const
bool IsGlobal() const
SecurityGroup(as2_t asn, uint32_t id)
as_t as_number() const
static const uint32_t kMinGlobalId
SecurityGroup4ByteAs(as_t asn, uint32_t id)
static void put_value(uint8_t *data, int size, uint64_t value)
Definition: parse_object.h:55