예제 #1
0
파일: sna_hdlr.py 프로젝트: randix/aprsna
def recover(pvc):
    if cfg.snaid[pvc]["state"] == "close":
        return
    status = cfg.snaid[pvc]["status"] & 0x1FF
    for i in cfg.snarecover:
        if status & i[0]:
            log.l.LogIt("SNA020", "I", "recover: pvc=%s status=%x %x %s", (pvc, status, i[0], i[1]))
            cfg.snaid[pvc]["state"] = "close"
            cfg.snabuf.append((i[1], pvc, ""))  # next step
            break
    gax_close(pvc)
    ga_hdlr.statx25(pvc)
예제 #2
0
파일: sna_hdlr.py 프로젝트: randix/aprsna
 def handle_connect(self):
     log.l.LogIt("SNA003", "I", "snasrv connected, opening pvc's", ())
     for i in range(1, routercfg.MaxPorts + 1):
         for j in range(1, routercfg.MaxPVCs + 1):
             pvc = "%d%02d" % (i, j)
             cfg.snaid[pvc] = {}
             cfg.snaid[pvc]["status"] = 0
             cfg.snaid[pvc]["state"] = "start"
             cfg.snaid[pvc]["sub"] = "-"
             cfg.snaid[pvc]["dom"] = "-"
             cfg.snaid[pvc]["wsid"] = ""
             cfg.snaid[pvc]["polltime"] = 0
             cfg.snaid[pvc]["writetime"] = 0
             cfg.snaid[pvc]["writecnt"] = 0
             ga_hdlr.statx25(pvc)
     cfg.snabuf.append(("VE", "000", ""))
     cfg.snabuf.append(("ST", "000", ""))
예제 #3
0
파일: sna_hdlr.py 프로젝트: randix/aprsna
    def handle_close(self):
        log.l.LogIt("SNA015", "I", "close snasrv: %d: %s", (self.reason, os.strerror(self.reason)))
        list = cfg.snaid.keys()
        list.sort()
        for pvc in list:
            wsid = cfg.snaid[pvc]["wsid"]
            if wsid != "" and cfg.atm.has_key(wsid) and cfg.atm[wsid].has_key("gasock") and cfg.atm[wsid]["gasock"]:
                log.l.LogIt("SNA016", "I", "abruptly closing pvc=%s, wsid=%s", (pvc, wsid))
                cfg.atm[wsid]["gasock"].handle_close()
            cfg.snaid[pvc]["status"] = 0
            ga_hdlr.statx25(pvc)

        self.close()
        cfg.snabuf = []
        cfg.sna_hdlr = None
        list = cfg.snaid.keys()
        for pvc in list:
            del cfg.snaid[pvc]
예제 #4
0
파일: sna_hdlr.py 프로젝트: randix/aprsna
    def handle_read(self):
        cmd, pvc, status, data = self.recvpkt()
        if not cmd:
            return

        # --------------
        if cmd == "CN":
            log.l.LogIt("SNA004", "I", "si: %s %s", (cmd, data))
            return

        # --------------
        if cmd == "VE":
            cfg.snasrv_version = data
            log.l.LogIt("SNA005", "I", "si: %s snasrv %s", (cmd, data))
            return

        # --------------
        if pvc != "000":
            # only report changes
            if (cfg.snaid[pvc]["status"] & 0xFFFFF7FF) != (status & 0xFFFFF7FF):
                cfg.snaid[pvc]["status"] = status
                ga_hdlr.statx25(pvc)
                # record time of achieving status==7
                if status == 7:
                    cfg.snaid[pvc]["polltime"] = time.time()
                # if status == 0xf:                 (what was this? 21.3.02 rhd)
            cfg.snaid[pvc]["status"] = status

        # --------------
        if cmd == "ST":
            log.l.LogIt("SNA006", "I", "si: %s pvc=%s status=%x", (cmd, pvc, status))
            return

        # --------------
        if not self.clean:
            self.clean = 1
            list = cfg.snaid.keys()
            list.sort()
            for i in list:
                if cfg.snaid[i]["status"] & 0x1FF:
                    self.clean = 0
            if self.clean and self.sd_seen:
                snapoll()

        # --------------
        if cmd == "SD":
            self.sd_seen = 1
            log.l.LogIt("SNA007", "I", "si: %s pvc=%s status=%x", (cmd, pvc, status))
            if self.clean:
                snapoll()
            else:
                self.cleanup()
            return

        # --------------
        if pvc == "000":
            log.l.LogIt("SNA008", "I", "si: %s pvc=%s status=%x msg=%s", (cmd, pvc, status, data))
            return

        # --------------
        if cmd == "LT":
            log.l.LogIt("SNA009", "D", "si: %s pvc=%s status=%x", (cmd, pvc, status))
            pbmascii = pbm.ebcdic2ascii(data)
            wsid = pbmascii[9:14]
            if cfg.snaid[pvc]["wsid"] == "":
                cfg.snaid[pvc]["wsid"] = wsid
                ga_hdlr.gax(pvc, wsid, data)
            if cfg.atm.has_key(wsid) and cfg.atm[wsid]["gasock"] and cfg.atm[wsid]["gastate"] != "=":
                cfg.atm[wsid]["gasock"].handle_read(data)
            else:
                log.l.LogIt("SNA109", "D", "si: %s pvc=%s status=%x - discard", (cmd, pvc, status))
            return

        # --------------
        log.l.LogIt(
            "SNA010", "I", "si: %s pvc=%s status=%x state=%s msg=%s", (cmd, pvc, status, cfg.snaid[pvc]["state"], data)
        )

        # ----
        if cmd == "WC":
            # decrement the write count for timeouts
            if cfg.snaid[pvc]["writecnt"] > 0:
                cfg.snaid[pvc]["writecnt"] -= 1

        # ----
        if cmd == "RS":
            cfg.snaid[pvc]["state"] = "open"

        # ----
        if cfg.snaid[pvc]["state"] == "open":
            if cfg.snacon.has_key(cmd):
                cfg.snabuf.append((cfg.snacon[cmd], pvc, ""))  # next step
                return
            if cmd == cfg.snacon["last"]:
                cfg.snaid[pvc]["state"] = "up"
                return

        # ----
        if cfg.snaid[pvc]["state"] == "close":
            if cfg.snadiscon.has_key(cmd):
                cfg.snabuf.append((cfg.snadiscon[cmd], pvc, ""))  # next step
                return
            if cmd == cfg.snadiscon["last"]:
                cfg.snaid[pvc]["wsid"] = ""
                cfg.snaid[pvc]["state"] = "down"
                return

        # --------------
        if cmd in cfg.snalost:
            # log.l.LogIt('SNA011', 'E', 'Gcom_dump started', ())
            # msg = util.dump()
            recover(pvc)
            return
예제 #5
0
파일: evt_hdlr.py 프로젝트: randix/aprsna
def refresh():
  for i in cfg.ips.keys():
    ga_hdlr.statip(i)
  for i in cfg.snaid.keys():
    ga_hdlr.statx25(i)