Added ability to output Ethernet Bridge State
authorRichard Whitehouse <github@richardwhiuk.com>
Sat, 7 May 2011 17:16:14 +0000 (18:16 +0100)
committerRichard Whitehouse <github@richardwhiuk.com>
Sat, 7 May 2011 17:16:14 +0000 (18:16 +0100)
src/devices/bridge/model/bridge-state.cc
src/devices/bridge/model/bridge-state.h

index ca2ffa44679c653333390035d7e65bf451cbb669..6c301622991d9779828054f979d22f11b9c730ab 100644 (file)
@@ -96,6 +96,19 @@ Time BridgeState::GetExpirationTime(){
        return m_time;
 }
 
+std::ostream& operator<<(std::ostream& file, BridgeState& state){
+       // Output state
+       file << state.m_learnState.size();
+       std::map<Mac48Address, BridgeState::Host>::iterator it;
+       for(it = state.m_learnState.begin(); it != state.m_learnState.end(); ++it){
+               file << std::endl;
+               file << it->first << std::endl;
+               file << it->second.associatedPort << std::endl;
+               file << it->second.expirationTime;
+       }
+       return file;
+}
+
 }
 
 
index d6963664d48670c8c25f3eb2cdad5639390bec60..91b986f8ac9cbab6f23f3813550c5cdaf9b97411 100644 (file)
@@ -57,8 +57,12 @@ private:
 
        std::map<Mac48Address, Host> m_learnState;
 
+       friend std::ostream& operator<<(std::ostream&, BridgeState&);
+
 };
 
+std::ostream& operator<<(std::ostream&, BridgeState&);
+
 }
 
 #endif