00001 /* -*- Mode:C++; c-basic-offset:2; tab-width:2; indent-tabs-mode:f -*- */ 00002 /* Nix-Vector routing capable node. */ 00003 /* George F. Riley, Georgia Tech, Spring 2000 */ 00004 /* Changed to NOT subclass the Node class, suggestion from ns developers */ 00005 00006 #ifndef __NIXNODE_H__ 00007 #define __NIXNODE_H__ 00008 00009 #include "routealgo/rnode.h" 00010 #include "object.h" 00011 #include <map> 00012 00013 // Define the edge class 00014 class Edge { 00015 public : 00016 Edge( nodeid_t n) : m_n(n) { }; 00017 public : 00018 nodeid_t m_n; // Other end of edge neighbor 00019 }; 00020 00021 typedef vector<Edge*> EdgeVec_t; 00022 typedef EdgeVec_t::iterator EdgeVec_it; 00023 00024 typedef vector<NsObject*> ObjVec_t; 00025 typedef ObjVec_t::iterator ObjVec_it; 00026 00027 // Use a map to keep a table of known NixVectors 00028 typedef map<nodeid_t, NixVec*, less<nodeid_t> > NVMap_t; 00029 typedef NVMap_t::iterator NVMap_it; 00030 typedef NVMap_t::value_type NVPair_t; 00031 00032 class NixNode : public RNode { 00033 public : 00034 NixNode(); 00035 void Id(nodeid_t id) { m_id = id;} 00036 nodeid_t Id() const { return m_id;} 00037 int Map() const { return m_Map;} 00038 void AddAdj(nodeid_t); // Add a simplex link from this to neighbor 00039 int IsNeighbor(nodeid_t); // True if specified node is neighbor 00040 virtual const NodeWeight_t NextAdj( const NodeWeight_t&); // Return next adjacent 00041 NixVec* ComputeNixVector(nodeid_t); // Compute the NixVector to target 00042 virtual NixPair_t GetNix(nodeid_t); // Get neighbor index/length 00043 virtual Nixl_t GetNixl(); // Get bits needed for nix entry 00044 virtual nodeid_t GetNeighbor(Nix_t, NixVec*); // Get neighbor from nix 00045 NixVec* GetNixVector(nodeid_t); // Get a nix vector for a target 00046 NsObject* GetNsNeighbor(Nix_t); // Get the ns nexthop neighbor 00047 void PopulateObjects(void); // Populate NS NextHop objects 00048 static NixNode* GetNodeObject(nodeid_t); // Get a node obj. based on id 00049 static void PopulateAllObjects(void);// Populate the next hop objects 00050 private : 00051 EdgeVec_t m_Adj; // Adjacent edges 00052 ObjVec_t m_AdjObj; // NS Objects for adjacencies 00053 int m_Map; // Which system this node is mapped to 00054 NVMap_t* m_pNixVecs; // Hash-map list of known NixVectors 00055 }; 00056 #endif 00057 00058
1.4.6