OpFlex Framework  1.3.0
MAC.h
Go to the documentation of this file.
1 /* -*- C++ -*-; c-basic-offset: 4; indent-tabs-mode: nil */
6 /*
7  * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
8  *
9  * This program and the accompanying materials are made available under the
10  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
11  * and is available at http://www.eclipse.org/legal/epl-v10.html
12  */
13 
14 #ifndef MODB_MAC_H
15 #define MODB_MAC_H
16 
17 #include <boost/shared_ptr.hpp>
18 #include <boost/any.hpp>
19 #include <boost/functional/hash.hpp>
20 #include <string>
21 #include <vector>
22 
23 namespace opflex {
24 namespace modb {
25 
40 class MAC {
41 public:
45  MAC();
46 
53  explicit MAC(const std::string& mac);
54 
61  explicit MAC(uint8_t mac[6]);
62 
66  ~MAC();
67 
71  std::string toString() const;
72 
76  void toUIntArray(/* out */uint8_t mac[6]) const;
77 
78 private:
86  explicit MAC(uint64_t mac);
87 
92  uint64_t mac;
93 
94  friend bool operator==(const MAC& lhs, const MAC& rhs);
95  friend bool operator!=(const MAC& lhs, const MAC& rhs);
96  friend size_t hash_value(MAC const& mac);
97 };
98 
102 std::ostream & operator<<(std::ostream &os, const MAC& mac);
103 
107 bool operator==(const MAC& lhs, const MAC& rhs);
111 bool operator!=(const MAC& lhs, const MAC& rhs);
116 size_t hash_value(MAC const& mac);
117 
118 /* @} modb */
119 /* @} cpp */
120 
121 } /* namespace modb */
122 } /* namespace opflex */
123 
124 #endif /* MODB_MAC_H */
bool operator==(const MAC &lhs, const MAC &rhs)
Check for MAC equality.
std::ostream & operator<<(std::ostream &os, const MAC &mac)
Stream insertion operator.
std::string toString() const
Get the MAC represented as a string.
friend size_t hash_value(MAC const &mac)
Compute a hash value for the MAC, making MAC suitable as a key in an unordered_map.
bool operator!=(const MAC &lhs, const MAC &rhs)
Check for MAC inequality.
~MAC()
Destroy the MAC.
friend bool operator!=(const MAC &lhs, const MAC &rhs)
Check for MAC inequality.
MAC()
Construct a MAC consisting of all zeroes.
void toUIntArray(uint8_t mac[6]) const
Get the MAC represented as an array of 6 bytes in network byte order.
friend bool operator==(const MAC &lhs, const MAC &rhs)
Check for MAC equality.
A MAC address is used to identify devices on an ethernet network.
Definition: MAC.h:40
size_t hash_value(MAC const &mac)
Compute a hash value for the MAC, making MAC suitable as a key in an unordered_map.