Example #1
0
def output(self):
  tcpippkt = cfg.atm[self.wsid]['bnmdata'][0]
  ebcdicpkt = tcpippkt[6:]
  now = time.time()
  if cfg.data_hdlr:
    cfg.data_buf.append(1, now, ebcdicpkt)
  pbmascii = pbm.ebcdic2ascii(ebcdicpkt)
  cfg.atm[self.wsid]['go_time'] = now
  log.l.LogIt('RTG007', 'D', 'go: %s', (pbmascii))
  if self.tcpip:
    result = pbm.sendpkt(self, tcpippkt)
  else:
    result = sna_hdlr.send(self.pvc, ebcdicpkt)
  if result:
    cfg.atm[self.wsid]['bnmdata'] = cfg.atm[self.wsid]['bnmdata'][1:]
    #----------------------
    if pbmascii[8] == 'F':
      if pbmascii[9] == 'P':
        cfg.atm[self.wsid]['txcnt'] = cfg.atm[self.wsid]['txcnt'] + 1
      else:
        cfg.atm[self.wsid]['txcnt'] = 0
      if cfg.atm[self.wsid]['txcnt'] == 2:
        log.l.LogIt('RTG008', '1', '%s: tx end', (self.wsid))
        cfg.atm[self.wsid]['tx'] = '-'
        cfg.atm[self.wsid]['txcnt'] = 0
Example #2
0
 def handle_read(self, pbmpkt):
   if pbmpkt == '':
     return
   header = pbm.pbm2header(pbmpkt)
   pbmascii = pbm.ebcdic2ascii(pbmpkt)
   log.l.LogIt('RTG021', 'D', 'gi: %s', (pbmascii))
   wsid = pbmascii[9:14]
   valid = input(self, wsid, pbmascii, header, pbmpkt)
Example #3
0
 def handle_write(self):
   if len(cfg.atm[self.wsid]['gadata']) == 0:
     return
   tcpippkt = cfg.atm[self.wsid]['gadata'][0]
   log.l.LogIt('RTB004', 'D', 'bo: %s',
                                            pbm.ebcdic2ascii(tcpippkt[6:]))
   result = pbm.sendpkt(self, tcpippkt)
   if result:
     cfg.atm[self.wsid]['gadata'] = cfg.atm[self.wsid]['gadata'][1:]
Example #4
0
  def handle_read(self):
    retval = pbm.recvpkt(self)
    if retval == 0:
      return
    if retval == -1:
      handle_close(self)
    header = self.pbmpkt_hdr
    pbmpkt = self.pbmpkt_buf
    self.pbmpkt_hdr = ''
    self.pbmpkt_buf = ''
    self.pbmpkt_len = 0

    pbmascii = pbm.ebcdic2ascii(pbmpkt)
    log.l.LogIt('GAT001', 'D', 'i: %s', (pbmascii))
    self.machine(pbmascii)
Example #5
0
  def handle_read(self):
    retval = pbm.recvpkt(self)
    if retval == 0:
      return
    if retval == -1:
      handle_close(self)
    header = self.pbmpkt_hdr
    pbmpkt = self.pbmpkt_buf
    self.pbmpkt_hdr = ''
    self.pbmpkt_buf = ''
    self.pbmpkt_len = 0

    pbmascii = pbm.ebcdic2ascii(pbmpkt)
    log.l.LogIt('BNH003', 'D', 'i: %s', (pbmascii))
    self.wsid = pbmascii[9:14]
    self.senddata = "%s answer" % self.wsid
    self.writeflag = 1
Example #6
0
  def handle_read(self):
    retval = pbm.recvpkt(self)
    if retval == 0:
      return
    if retval == -1:
      self.handle_close()
      return
    header = self.pbmpkt_hdr
    pbmpkt = self.pbmpkt_buf
    self.pbmpkt_hdr = ''
    self.pbmpkt_buf = ''
    self.pbmpkt_len = 0

    log.l.LogIt('RTB003', 'D', 'bi: %s', pbm.ebcdic2ascii(pbmpkt))
    cfg.atm[self.wsid]['bnmdata'].append(header+pbmpkt)
    if cfg.atm[self.wsid]['x25'] != '-':
      cfg.atm[self.wsid]['gasock'].handle_write()
Example #7
0
 def __init__(self, pvc, wsid, pbmpkt):
   log.l.LogIt('RTG017', 'I', 'ga connect pvc=%s wsid=%s', (pvc, wsid))
   self.pvc = pvc
   self.wsid = wsid
   self.tcpip = 0
   if cfg.atm.has_key(self.wsid) and cfg.atm[self.wsid]['gasock']:
     # second WSID !
     log.l.LogIt('RTG014', 'E', '%s (%s) duplicate wsid - closed',
                                                 (self.wsid, self.pvc))
     # XXX bnmroutc
     sna_hdlr.disconnect(self.pvc)
     return
   gainit(self)
   cfg.atm[self.wsid]['pvc'] = self.pvc
   cfg.atm[self.wsid]['x25port'] = self.pvc[0]
   cfg.atm[self.wsid]['x25'] = self.pvc[1:3]
   header = pbm.pbm2header(pbmpkt)
   pbmascii = pbm.ebcdic2ascii(pbmpkt)
   log.l.LogIt('RTG018', 'D', 'gi: %s', (pbmascii))
   cfg.atm[self.wsid]['event'] = (pbmascii, header, pbmpkt)
   getdomain(self.wsid)
   statx25(pvc)
Example #8
0
  def handle_read(self):
    retval = pbm.recvpkt(self)
    if retval == 0:
      return
    if retval == -1:
      self.handle_close()
      return
    header = self.pbmpkt_hdr
    pbmpkt = self.pbmpkt_buf
    self.pbmpkt_hdr = ''
    self.pbmpkt_buf = ''
    self.pbmpkt_len = 0

    pbmascii = pbm.ebcdic2ascii(pbmpkt)
    log.l.LogIt('RTG012', 'D', 'gi: %s', (pbmascii))
    wsid = pbmascii[9:14]
    #----------------------
    if self.wsid == '0':              # first read on tcp ga
      log.l.LogIt('RTG013', 'I', 'ga connect wsid=%s', (wsid))
      self.wsid = wsid
      self.stat_wsid = wsid
      if cfg.atm.has_key(self.wsid) and cfg.atm[self.wsid]['gasock']:
        # second WSID !
        log.l.LogIt('RTG014', 'E', '%s (%s) duplicate wsid - closed',
                                                  (self.wsid, self.peer_ip))
        # XXX bnmroutc
        self.close()
        return
      gainit(self)
      cfg.atm[self.wsid]['event'] = (pbmascii, header, pbmpkt)
      getdomain(self.wsid)
      for ip in cfg.ips.keys():
        if ip == self.peer_ip:
          cfg.ips[ip]['wsid'] = self.wsid
          cfg.ips[ip]['status'] = '3'
      statip(self.peer_ip)
      return
    #----------------------
    valid = input(self, wsid, pbmascii, header, pbmpkt)
Example #9
0
    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
Example #10
0
  print file+':', why
  sys.exit(1)

#--------------------------------------
record = 0

while 1:
  hdr = f.read(6+15)
  if not hdr:
    break
  if 'PBM' != hdr[0:3]:
    print 'unsynchronized!'
    sys.exit(1)
  l = (ord(hdr[3]) << 8) + ord(hdr[4])
  if hdr[5] == '1': dir = 'go:'
  else: dir = 'gi:'
  timestamp = float(hdr[6:6+15])
  data = f.read(l)
  ascii = ''
  for i in data:
    ascii = ascii + pbm.ebcdic2ascii(i)

  print '%.3f'%timestamp, dir, '%3d'%l, ascii

#--------------------------------------
f.close()
sys.exit(0)

#--------------------------------------
#--------------------------------------