summaryrefslogtreecommitdiffstats
path: root/src/mac_mapping.h
diff options
context:
space:
mode:
authorDan Klein <danklei@cisco.com>2015-10-20 05:39:14 +0300
committerDan Klein <danklei@cisco.com>2015-10-20 05:39:14 +0300
commitcf753587ffb7b89cff1863c74ca334b8c41fd0c0 (patch)
treef9d8bd9e67cb93306e93041f11f5e4124a6e151a /src/mac_mapping.h
parentd09df99769f67819c64a7a025dbdcd39811c7b44 (diff)
parent51ad078182d17b42a36c239c3c21381eeb3eec85 (diff)
Merge branch 'master' into master-demo +
working demo of loading a YAML, and attaching it to server
Diffstat (limited to 'src/mac_mapping.h')
-rw-r--r--src/mac_mapping.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/mac_mapping.h b/src/mac_mapping.h
new file mode 100644
index 00000000..84151e8c
--- /dev/null
+++ b/src/mac_mapping.h
@@ -0,0 +1,60 @@
+#ifndef MAC_MAPPING_H_
+#define MAC_MAPPING_H_
+
+#define INUSED 0
+#define UNUSED 1
+typedef struct mac_addr_align_ {
+public:
+ uint8_t mac[6];
+ uint8_t inused;
+ uint8_t pad;
+} mac_addr_align_t;
+
+typedef struct mac_mapping_ {
+ mac_addr_align_t mac;
+ uint32_t ip;
+} mac_mapping_t;
+
+class CFlowGenListMac {
+public:
+ CFlowGenListMac() {
+ set_configured(false);
+ }
+
+ std::map<uint32_t, mac_addr_align_t> &
+ get_mac_info () {
+ return m_mac_info;
+ }
+
+ bool is_configured() {
+ return is_mac_info_configured;
+ }
+
+ void set_configured(bool is_conf) {
+ is_mac_info_configured = is_conf;
+ }
+
+ void clear() {
+ set_configured(false);
+ m_mac_info.clear();
+ }
+
+ uint32_t is_mac_exist(uint32_t ip) {
+ if (is_configured()) {
+ return m_mac_info.count(ip);
+ } else {
+ return 0;
+ }
+ }
+ mac_addr_align_t* get_mac_addr_by_ip(uint32_t ip) {
+ if (is_mac_exist(ip)!=0) {
+ return &(m_mac_info[ip]);
+ }
+ return NULL;
+ }
+private:
+ bool is_mac_info_configured;
+ std::map<uint32_t, mac_addr_align_t> m_mac_info; /* global mac info loaded form mac_file*/
+};
+
+#endif //MAC_MAPPING_H_