Пример #1
0
 def _send_initial_csm(self):
     my_csm = Message(code=CSM)
     # this is a tad awkward in construction because the options objects
     # were designed under the assumption that the option space is constant
     # for all message codes.
     block_length = optiontypes.UintOption(2, self._my_max_message_size)
     my_csm.opt.add_option(block_length)
     supports_block = optiontypes.UintOption(4, 0)
     my_csm.opt.add_option(supports_block)
     self._send_message(my_csm)
Пример #2
0
 def abort(self, errormessage=None, bad_csm_option=None):
     self.log.warning("Aborting connection: %s", errormessage)
     abort_msg = Message(code=ABORT)
     if errormessage is not None:
         abort_msg.payload = errormessage.encode('utf8')
     if bad_csm_option is not None:
         bad_csm_option_option = optiontypes.UintOption(2, bad_csm_option)
         abort_msg.opt.add_option(bad_csm_option_option)
     self._abort_with(abort_msg)
Пример #3
0
 def abort(self, errormessage=None, bad_csm_option=None):
     self.log.warning("Aborting connection: %s", errormessage)
     abort_msg = Message(code=ABORT)
     if errormessage is not None:
         abort_msg.payload = errormessage.encode('utf8')
     if bad_csm_option is not None:
         bad_csm_option_option = optiontypes.UintOption(2, bad_csm_option)
         abort_msg.opt.add_option(bad_csm_option_option)
     if self._transport is not None:
         self._send_message(abort_msg)
         self._transport.close()
     else:
         # FIXME: find out how this happens; i've only seen it after nmap
         # runs against an aiocoap server and then shutting it down.
         # "poisoning" the object to make sure this can not be exploited to
         # bypass the server shutdown.
         self._ctx = None