#coding=utf-8 require "aio/core" class Aio::Module::Cmd::Maipu::ShowIpRoute < Aio::Module::Cmd::Maipu include Aio::Module def initialize super({ :cmd_full => "show ip route", :cmd_short => "sh ip rou", :author => "Elin", :ranking => Ranking_2, :description => "This is Maipu Command# show ip route", :platform => "all", :benchmark => {} }) end def parse cont = self.context.dup routing = {} useful[:routing] = routing cont.readline_match_block(reg_blank) {|b|b} cont.readline_match_block(reg_blank) {|b|b} cont.readline_range_if_loop(/^\w/, /^\s+/) do |cont_layer| parse_routing(cont_layer) end end def parse_routing(context) router = nil if context[0] =~ /^C/ context.readline_match_block(/C (?.*) is directly connected, .*, (?.*)/) do |block| route = {} router = block[:dest] useful[:routing][router] = {} useful[:routing][router][:first] = route block.update(useful[:routing][router], :dest) block.update(route, :proto, "C") block.update(route, :iface) end return end context.readline_match_block(/(?.*) (?.*) \[(?\d+)\/(?\d+)\] via (?.*), (?