def addremovectrlif(self, node, netidx=0,  remove=False, conf_reqd=True):
        ''' Add a control interface to a node when a 'controlnet' prefix is
            listed in the config file or session options. Uses
            addremovectrlnet() to build or remove the control bridge.
            If conf_reqd is False, the control network may be built even
            when the user has not configured one (e.g. for EMANE.)
        '''
        ctrlnet = self.addremovectrlnet(netidx, remove, conf_reqd)
        if ctrlnet is None:
            return
        if node is None:
            return
        if node.netif(ctrlnet.CTRLIF_IDX_BASE + netidx):
            return  # ctrl# already exists
        ctrlip = node.objid
        try:
            addrlist = ["%s/%s" % (ctrlnet.prefix.addr(ctrlip),
                                   ctrlnet.prefix.prefixlen)]
        except __HOLE__:
            msg = "Control interface not added to node %s. " % node.objid
            msg += "Invalid control network prefix (%s). " % ctrlnet.prefix
            msg += "A longer prefix length may be required for this many nodes."
            node.exception(coreapi.CORE_EXCP_LEVEL_ERROR,
                           "Session.addremovectrlif()", msg)
            return
        ifi = node.newnetif(net = ctrlnet, ifindex = ctrlnet.CTRLIF_IDX_BASE + netidx,
                            ifname = "ctrl%d" % netidx, hwaddr = MacAddr.random(),
                            addrlist = addrlist)
        node.netif(ifi).control = True
dataset/ETHPy150Open coreemu/core/daemon/core/session.py/Session.addremovectrlif