1 from gi.repository
import Gtk
30 @param self this object
31 @param visualizer visualizer object
32 @param node_index the node index
34 InformationWindow.__init__(self)
35 self.
winwin = Gtk.Dialog(parent=visualizer.window,
36 flags=Gtk.DialogFlags.DESTROY_WITH_PARENT,
37 buttons=(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE))
39 self.
winwin.set_title(
"IPv4 routing table for node %i" % node_index)
43 self.
table_modeltable_model = Gtk.ListStore(str, str, str, str, int)
45 treeview = Gtk.TreeView(self.
table_modeltable_model)
47 sw = Gtk.ScrolledWindow()
48 sw.set_properties(hscrollbar_policy=Gtk.PolicyType.AUTOMATIC,
49 vscrollbar_policy=Gtk.PolicyType.AUTOMATIC)
52 self.
winwin.vbox.add(sw)
53 self.
winwin.set_default_size(600, 300)
56 column = Gtk.TreeViewColumn(
'Destination', Gtk.CellRendererText(),
57 text=self.COLUMN_DESTINATION)
58 treeview.append_column(column)
61 column = Gtk.TreeViewColumn(
'Next hop', Gtk.CellRendererText(),
62 text=self.COLUMN_NEXT_HOP)
63 treeview.append_column(column)
66 column = Gtk.TreeViewColumn(
'Interface', Gtk.CellRendererText(),
67 text=self.COLUMN_INTERFACE)
68 treeview.append_column(column)
71 column = Gtk.TreeViewColumn(
'Type', Gtk.CellRendererText(),
72 text=self.COLUMN_TYPE)
73 treeview.append_column(column)
76 column = Gtk.TreeViewColumn(
'Prio', Gtk.CellRendererText(),
77 text=self.COLUMN_PRIO)
78 treeview.append_column(column)
80 self.
visualizervisualizer.add_information_window(self)
85 Response callback function
86 @param self this object
88 @param response the response
92 self.
visualizervisualizer.remove_information_window(self)
97 @param self this object
100 node = ns.network.NodeList.GetNode(self.
node_indexnode_index)
101 ipv4 = node.GetObject(ns.internet.Ipv4.GetTypeId())
102 routing = ipv4.GetRoutingProtocol()
106 routing_protocols = []
108 if isinstance(routing, ns.internet.Ipv4StaticRouting):
109 ipv4_routing = routing_protocols.append((routing,
"static", 0))
110 elif isinstance(routing, ns.internet.Ipv4ListRouting):
111 list_routing = routing
112 for rI
in range(list_routing.GetNRoutingProtocols()):
113 routing, prio = list_routing.GetRoutingProtocol(rI)
114 if isinstance(routing, ns.internet.Ipv4StaticRouting):
115 routing_protocols.append((routing,
"static", prio))
116 elif isinstance(routing, ns.internet.Ipv4GlobalRouting):
117 routing_protocols.append((routing,
"global", prio))
118 if not routing_protocols:
122 for route_proto, type_string, prio
in routing_protocols:
123 for routeI
in range(route_proto.GetNRoutes()):
124 route = route_proto.GetRoute(routeI)
126 netdevice = ipv4.GetNetDevice(route.GetInterface())
127 if netdevice
is None:
128 interface_name =
'lo'
130 interface_name = ns.core.Names.FindName(netdevice)
131 if not interface_name:
132 interface_name =
"(interface %i)" % route.GetInterface()
134 self.COLUMN_DESTINATION, str(route.GetDest()),
135 self.COLUMN_NEXT_HOP, str(route.GetGateway()),
136 self.COLUMN_INTERFACE, interface_name,
137 self.COLUMN_TYPE, type_string,
138 self.COLUMN_PRIO, prio)
142 menu_item = Gtk.MenuItem(
"Show IPv4 Routing Table")
145 def _show_ipv4_routing_table(dummy_menu_item):
148 menu_item.connect(
"activate", _show_ipv4_routing_table)
152 viz.connect(
"populate-node-menu", populate_node_menu)
ShowIpv4RoutingTable class.
def _response_cb(self, win, response)
Response callback function.
def __init__(self, visualizer, node_index)
Initializer.
def update(self)
Update function.
def populate_node_menu(viz, node, menu)