def setatm(wsid, dom, port, sub, prim, sec, fb): if port == '-': log.l.LogIt('RTG002', 'E', 'dom %s: bad port', (dom)) cfg.atm[wsid]['gasock'].handle_close() return atmdb.insert(wsid, dom, port, sub, prim, sec, fb) cfg.atm[wsid]['domain'] = dom if not cfg.domain.has_key(dom): cfg.domain[dom] = {} cfg.domain[dom]['apr'] = cfg.name cfg.domain[dom]['bnmconnect'] = 0 cfg.domain[dom]['wsids'] = [] # set these every time, changes take effect for new connects without restart cfg.domain[dom]['bnmport'] = int(port) cfg.domain[dom]['fallback'] = fb if sub == prim: cfg.domain[dom]['active'] = 0 else: cfg.domain[dom]['active'] = 1 list = cfg.servers.keys() for ip in list: if cfg.servers[ip]['sub'] == prim: p = ip if cfg.servers[ip]['sub'] == sec: s = ip # force setting of s and p if not found, there must be at least one server! try: p except: p = list[0] try: s except: s = list[0] cfg.domain[dom]['server'] = [p, s] if wsid not in cfg.domain[dom]['wsids']: cfg.domain[dom]['wsids'].append(wsid) ga = cfg.atm[wsid]['gasock'] if ga and cfg.atm[wsid]['gastate'] == '=': # tell bnmroutc ip = cfg.domain[dom]['server'][cfg.domain[dom]['active']] if cfg.servers[ip]['routc']: cfg.servers[ip]['routc'].routcEvt(routc.atmConnect(dom, wsid)) if ga.tcpip: cfg.servers[ip]['routc'].routcEvt(routc.ipAddr(dom, wsid, ga.peer_ip)) else: cfg.servers[ip]['routc'].routcEvt(routc.x25Addr(dom, wsid, ga.pvc)) #--------------- cfg.atm[wsid]['gasock'].initevent()
def handle_connect(self): self.keepalive() log.l.LogIt('RBC003', 'I', 'bnmroutc %s connected on port %s', (self.ip, self.getsockname()[1])) cfg.servers[self.ip]['routc'] = self self.msgbuf = [] self.msgbuf.append(routc.heartBeat()) # send all connected and status messages to this bnmroutc atms = cfg.atm.keys() for i in atms: dom = cfg.atm[i]['domain'] if cfg.atm[i]['gastate'] == '=' or cfg.atm[i]['gastate'] == 'o' and \ dom != '': ip = cfg.domain[dom]['server'][cfg.domain[dom]['active']] if ip == self.ip: cfg.servers[ip]['routc'].routcEvt(routc.atmConnect(dom, i)) ga = cfg.atm[i]['gasock'] if ga.tcpip: self.routcEvt(routc.ipAddr(dom, i, ga.peer_ip)) else: self.routcEvt(routc.x25Addr(dom, i, ga.pvc)) self.routcEvt(routc.x25Status(dom, i, ga.pvc, '%x'%(cfg.snaid[ga.pvc]['status'] & ~0x800))) if cfg.atm[i]['bnmstate'] == 'o': self.routcEvt(routc.bnmConnect(dom, i))