コード例 #1
0
    def __init__ (self, args, scope) :
        if len (args) > 0 :
            fn = args [0]
            if fn.startswith ('http') :
                f = urllib2.urlopen (fn)
            else :
                f = open (fn)
        else :
            f = sys.stdin

        self.et    = ETree (ElementTree.parse (f))
        self.stati = {}
        self.attrs = {}
        self.scope = scope
        self.links = {} # list of linked interfaces by link id
        self.ffm   = self.scope.FFM
        PAP        = self.scope.PAP
        self.owner = PAP.Person (first_name = "guifi", last_name = "net")
        self.modes = dict \
            ( client = 'Client'
            , ap     = 'AP'
            , ad_hoc = 'Ad_Hoc'
            )
        self.modes [None] = None

        #print self.et.pretty (with_text = 1)
        #print self.et.pretty ()

        self.networks = []
        # Umm: our test data uses lots of addresses in the 178.18.8.0/22
        # range which according to whois belongs to some russion entity.
        # We add this for now.
        # Then there is one address from 178.26.0.0/30 from a range of
        # some german cable provider which we simply ignore.
        for n in ('10.0.0.0/8', '172.16.0.0/12', '178.18.8.0/22') :
            n = self.ffm.IP4_Network (n, owner = self.owner)
            self.networks.append (n)

        self.et.walk (self.insert)