summaryrefslogtreecommitdiffstats
path: root/src/mac_mapping.h
blob: ed9c5d881df851a7883996338bc86f6043bd76ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef MAC_MAPPING_H_
#define MAC_MAPPING_H_
#if 0
#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
#endif //MAC_MAPPING_H_