#include #include #include #include #include using namespace std;int FLAG = 0;class port{ public: int id = 0; int link_port = 0; string bridge_name = ““; void set(int a) { link_port = a; //link_port = 1; }; // map link; // void insert (int port string id){ link.insert(pair(portid));} // string get(int port){ // map::iterator iter; // iter = link.find(port); // return iter->second; // }; // void set(int port string id){ // map::iterator iter; // iter = link.find(port); // iter -> second = id; // }};class bridge{ private: public: string name; map ports; map trans; port *get_port(int id) { map::iterator iter; iter = ports.find(id); return &iter->second; }; void update(string host int p) { map::iterator iter; iter = trans.find(host); if (iter != trans.end()) { return; } else { port *a = get_port(p); trans.insert(pair(host *a)); } };};static map net;//bridge find_bridge(string name)//{//////}void broadcast(string bridge_id string host int p_id){ bridge *source = &net.find(bridge_id)->second; source->update(host p_id); map::iterator iter; cout << source->name << “ “ << “ table“ << endl; for (iter = source->trans.begin(); iter != source->trans.end(); iter++) cout << iter->first << “ “ << iter->second.id << endl; map::iterator iter_p; //for(iter_p = source->ports.begin(); iter_p != source->ports.end(); iter_p++) // cout<first<<“ “<second.bridge_name + ‘ ‘ + to_string(iter_p->second.link_port)< //iter_p = source.ports.find(p_id); //int flag= p_id; //iter_p->first; for (iter_p = source->ports.begin(); iter_p != source->ports.end(); iter_p++) { if (iter_p->first == p_id && FLAG != 0) continue; if (iter_p->second.bridge_name.
共有 条评论
评论
共有 条评论