'Configure a routed control network on controller and switches.
For use with the user datapath only right now.'

def configureRoutedControlNetwork(self, ip='192.168.123.1', prefixLen=16):

    controller = self.controllers[0]
    info((controller.name + '    <->'))
    cip = ip
    snum = ipParse(ip)
    for switch in self.switches:
        info(('    ' + switch.name))
        link = self.link(switch, controller, port1=0)
        (sintf, cintf) = (link.intf1, link.intf2)
        switch.controlIntf = sintf
        snum += 1
        while ((snum & 255) in [0, 255]):
            snum += 1
        sip = ipStr(snum)
        cintf.setIP(cip, prefixLen)
        sintf.setIP(sip, prefixLen)
        controller.setHostRoute(sip, cintf)
        switch.setHostRoute(cip, sintf)
    info('\n')
    info('***    Testing    control    network\n')
    while (not cintf.isUp()):
        info('***    Waiting    for', cintf, 'to    come    up\n')
        sleep(1)
    for switch in self.switches:
        while (not sintf.isUp()):
            info('***    Waiting    for', sintf, 'to    come    up\n')
            sleep(1)
        if (self.ping(hosts=[switch, controller]) != 0):
            error('***    Error:    control    network    test    failed\n')
            exit(1)
    info('\n')
