Ejemplo n.º 1
0
def addRoute(daemon, ip, cip, multiPort, testedInterfaces):
    port1 = 0
    port2 = 0
    try:
        if not daemon:
            ip = cip
        routes = Route.read_route_table()
        for interface,interfaceIp in testedInterfaces.iteritems():
            if interfaceIp == ip:
                port1 = interface
            else:
                port2 = interface
        route1 = Route('224.0.0.0','0.0.0.0',port1,'240.0.0.0')
        route2 = Route('239.0.0.0','0.0.0.0',port2,'255.0.0.0')
        rc = checkRoute(routes,'240.0.0.0')
        if rc == FAIL:
            return FAIL
        Route.add(route1)
        if multiPort:
            rc = checkRoute(routes,'239.0.0.0')
            if rc == FAIL:
                return FAIL
            Route.add(route2)
        return SUCCESS
    except Exception,e:
        msg =  '-E- Failed to add the multicast routes on the machine. Error: %s' % (e)
        print msg
        now = datetime.datetime.now()
        logFile.write(now.strftime('%Y/%m/%d %H:%M:%S: ') + '%s\n' % (msg))
        return FAIL
Ejemplo n.º 2
0
def checkRoute(routes, multicastRange):
    try:
        match = [route for route in routes if multicastRange in str(route)]
        if len(match) != 0:
            Route.delete(match[0])
        return SUCCESS
    except Exception,e:
        msg =  '-E- Failed to check existing routes on the machine. Error: %s' % (e)
        print msg
        now = datetime.datetime.now()
        logFile.write(now.strftime('%Y/%m/%d %H:%M:%S: ') + '%s\n' % (msg))
        return FAIL