Example #1
0
 def _validateMailbox(self, mailbox, mailboxIndex):
     chkStart = MAILBOX_SIZE-CHECKSUM_BYTES
     chk = misc.checksum(mailbox[0 : chkStart], CHECKSUM_BYTES)
     pChk = struct.pack('<l',chk) # Assumes CHECKSUM_BYTES equals 4!!!
     if pChk != mailbox[chkStart : chkStart+CHECKSUM_BYTES]:
         self.log.error("SPM_MailMonitor: mailbox %s checksum failed, not clearing mailbox, clearing newMail.", str(mailboxIndex))
         return False
     elif pChk == pZeroChecksum: return False  # Ignore messages of empty mailbox
     return True
Example #2
0
 def _sendMail(self):
     self.log.info("HSM_MailMonitor sending mail to SPM - " +
                   str(self._outCmd))
     chk = misc.checksum(
         self._outgoingMail[0:MAILBOX_SIZE - CHECKSUM_BYTES],
         CHECKSUM_BYTES)
     pChk = struct.pack('<l', chk)  # Assumes CHECKSUM_BYTES equals 4!!!
     self._outgoingMail = \
         self._outgoingMail[0:MAILBOX_SIZE - CHECKSUM_BYTES] + pChk
     _mboxExecCmd(self._outCmd, data=self._outgoingMail)
Example #3
0
 def _sendMail(self):
     self.log.info("HSM_MailMonitor sending mail to SPM - " +
                   str(self._outCmd))
     chk = misc.checksum(
         self._outgoingMail[0:MAILBOX_SIZE - CHECKSUM_BYTES],
         CHECKSUM_BYTES)
     pChk = struct.pack('<l', chk)  # Assumes CHECKSUM_BYTES equals 4!!!
     self._outgoingMail = \
         self._outgoingMail[0:MAILBOX_SIZE - CHECKSUM_BYTES] + pChk
     _mboxExecCmd(self._outCmd, data=self._outgoingMail)
Example #4
0
 def _validateMailbox(self, mailbox, mailboxIndex):
     chkStart = MAILBOX_SIZE - CHECKSUM_BYTES
     chk = misc.checksum(mailbox[0:chkStart], CHECKSUM_BYTES)
     pChk = struct.pack('<l', chk)  # Assumes CHECKSUM_BYTES equals 4!!!
     if pChk != mailbox[chkStart:chkStart + CHECKSUM_BYTES]:
         self.log.error(
             "SPM_MailMonitor: mailbox %s checksum failed, not "
             "clearing mailbox, clearing newMail.", str(mailboxIndex))
         return False
     elif pChk == pZeroChecksum:
         return False  # Ignore messages of empty mailbox
     return True
Example #5
0
MAILBOX_SIZE = 4096
PACKED_UUID_SIZE = 16
VOLUME_MAX_SIZE = 0xFFFFFFFF # 64 bit unsigned max size
SIZE_CHARS = 16
MESSAGE_VERSION = "1"
MESSAGE_SIZE = 64
CLEAN_MESSAGE = "\1" * MESSAGE_SIZE
EXTEND_CODE = "xtnd"
BLOCK_SIZE = 512
REPLY_OK = 1
EMPTYMAILBOX = MAILBOX_SIZE * "\0"
BLOCKS_PER_MAILBOX = int(MAILBOX_SIZE/BLOCK_SIZE)
SLOTS_PER_MAILBOX = int(MAILBOX_SIZE / MESSAGE_SIZE)
MESSAGES_PER_MAILBOX = SLOTS_PER_MAILBOX - 1 # Last message slot is reserved for metadata (checksum, extendable mailbox, etc)

_zeroCheck = misc.checksum(EMPTYMAILBOX, CHECKSUM_BYTES)
pZeroChecksum = struct.pack('<l',_zeroCheck) # Assumes CHECKSUM_BYTES equals 4!!!

def dec2hex(n):
    return "%x" % n


def runTask(args):
    if type(args) == tuple:
        cmd = args[0]
        args = args[1:]
    else:
        cmd = args
        args = None
    ctask = task.Task(id=None, name=cmd)
    vars.task = ctask
Example #6
0
VOLUME_MAX_SIZE = 0xFFFFFFFF  # 64 bit unsigned max size
SIZE_CHARS = 16
MESSAGE_VERSION = "1"
MESSAGE_SIZE = 64
CLEAN_MESSAGE = "\1" * MESSAGE_SIZE
EXTEND_CODE = "xtnd"
BLOCK_SIZE = 512
REPLY_OK = 1
EMPTYMAILBOX = MAILBOX_SIZE * "\0"
BLOCKS_PER_MAILBOX = int(MAILBOX_SIZE / BLOCK_SIZE)
SLOTS_PER_MAILBOX = int(MAILBOX_SIZE / MESSAGE_SIZE)
# Last message slot is reserved for metadata (checksum, extendable mailbox,
# etc)
MESSAGES_PER_MAILBOX = SLOTS_PER_MAILBOX - 1

_zeroCheck = misc.checksum(EMPTYMAILBOX, CHECKSUM_BYTES)
# Assumes CHECKSUM_BYTES equals 4!!!
pZeroChecksum = struct.pack('<l', _zeroCheck)


def dec2hex(n):
    return "%x" % n


def runTask(args):
    if type(args) == tuple:
        cmd = args[0]
        args = args[1:]
    else:
        cmd = args
        args = None