示例#1
0
    def convert_offer_to_request_select(self):
        """
        На основании последнего полученного пакета Offer создает Request Select

        :return: None
        :exception: AttributeError если еще не было Offer
        """
        packet = self._get_last_offer()
        if not packet:
            self._raise_no_packet_exception()
        self._current_packet_send = PacketUtils.convert_offer_to_request_select(self._get_last_offer())
        logging.info(
            "Last Offer packet with xid = %s converted to Request Select and ready to send", self.get_xid_send()
        )
示例#2
0
    def convert_request_select_to_release(self):
        """
        На основании последнего отправленного пакета Request Select создает Release

        :return: None
        :exception: AttributeError если еще не было Release
        """
        packet = self._get_last_request_select()
        if not packet:
            self._raise_no_packet_exception()
        self._current_packet_send = PacketUtils.convert_request_select_to_release(packet)
        logging.info(
            "Last Request Select packet with xid = %s converted to Release and ready to send", self.get_xid_send()
        )
示例#3
0
    def get_last_offer_lease_time(self):
        """
        Возвращает Lease time последнего полученного пакета Offer

        :return: Lease time в сек.
        :exception: AttributeError если еще не было Offer
        """
        packet = self._get_last_offer()
        if not packet:
            self._raise_no_packet_exception()
        lt = packet.GetOption("ip_address_lease_time")
        lt_str = int(PacketUtils.convert_32bit_to_str(lt))
        logging.info("Last Offer receive Lease time = %s", lt_str)
        return lt_str
示例#4
0
    def get_last_offer_lease_time(self):
        """
        Возвращает Lease time последнего полученного пакета Offer

        :return: Lease time в сек.
        :exception: AttributeError если еще не было Offer
        """
        packet = self._get_last_offer()
        if not packet:
            self._raise_no_packet_exception()
        lt = packet.GetOption('ip_address_lease_time')
        lt_str = int(PacketUtils.convert_32bit_to_str(lt))
        logging.info('Last Offer receive Lease time = %s', lt_str)
        return lt_str
示例#5
0
    def convert_offer_to_request_select(self):
        """
        На основании последнего полученного пакета Offer создает Request Select

        :return: None
        :exception: AttributeError если еще не было Offer
        """
        packet = self._get_last_offer()
        if not packet:
            self._raise_no_packet_exception()
        self._current_packet_send = PacketUtils.convert_offer_to_request_select(
            self._get_last_offer())
        logging.info(
            'Last Offer packet with xid = %s converted to Request Select and ready to send',
            self.get_xid_send())
示例#6
0
    def convert_request_select_to_release(self):
        """
        На основании последнего отправленного пакета Request Select создает Release

        :return: None
        :exception: AttributeError если еще не было Release
        """
        packet = self._get_last_request_select()
        if not packet:
            self._raise_no_packet_exception()
        self._current_packet_send = PacketUtils.convert_request_select_to_release(
            packet)
        logging.info(
            'Last Request Select packet with xid = %s converted to Release and ready to send',
            self.get_xid_send())
示例#7
0
 def set_packet_chaddr(self, value, log=True):
     self._current_packet_send.SetOption("chaddr", PacketUtils._convert_chaddr_from_str(value))
     if log:
         logging.info('Set option "chaddr" as = "%s"', value)
示例#8
0
 def set_packet_opt82(self, value, log=True):
     self._current_packet_send.SetOption("relay_agent", PacketUtils.convert_opt82_from_str(value))
     if log:
         logging.info('Set option "option 82" as = "%s"', value)
示例#9
0
 def get_xid_send(self):
     return PacketUtils.convert_ipv4_to_str(self._current_packet_send.GetOption("xid"))
示例#10
0
 def get_xid_received(self):
     return PacketUtils.convert_ipv4_to_str(self.get_current_packet_receive().GetOption("xid"))
示例#11
0
 def set_packet_chaddr(self, value, log=True):
     self._current_packet_send.SetOption(
         "chaddr", PacketUtils._convert_chaddr_from_str(value))
     if log:
         logging.info('Set option "chaddr" as = "%s"', value)
示例#12
0
 def set_packet_opt82(self, value, log=True):
     self._current_packet_send.SetOption(
         "relay_agent", PacketUtils.convert_opt82_from_str(value))
     if log:
         logging.info('Set option "option 82" as = "%s"', value)
示例#13
0
 def get_xid_send(self):
     return PacketUtils.convert_ipv4_to_str(
         self._current_packet_send.GetOption('xid'))
示例#14
0
 def get_xid_received(self):
     return PacketUtils.convert_ipv4_to_str(
         self.get_current_packet_receive().GetOption('xid'))