my_offset += name_len if my_offset != max_offset: raise ValueError( 'Option length does not match the length of the included fqdn') return my_offset def save(self) -> Union[bytes, bytearray]: """ Save the internal state of this object as a buffer. :return: The buffer with the data from this element """ fqdn_buffer = encode_domain(self.fqdn) buffer = bytearray() buffer.extend(pack('!HH', self.option_type, len(fqdn_buffer))) buffer.extend(fqdn_buffer) return buffer # Update the messages where this option may appear SolicitMessage.add_may_contain(AFTRNameOption, 0, 1) AdvertiseMessage.add_may_contain(AFTRNameOption, 0, 1) RequestMessage.add_may_contain(AFTRNameOption, 0, 1) RenewMessage.add_may_contain(AFTRNameOption, 0, 1) RebindMessage.add_may_contain(AFTRNameOption, 0, 1) InformationRequestMessage.add_may_contain(AFTRNameOption, 0, 1) ReplyMessage.add_may_contain(AFTRNameOption, 0, 1)
return my_offset def save(self) -> bytes: """ Save the internal state of this object as a buffer. :return: The buffer with the data from this element """ self.validate() options_buffer = bytearray() for option in self.options: options_buffer.extend(option.save()) buffer = bytearray() buffer.extend(pack('!HH', self.option_type, len(options_buffer))) buffer.extend(options_buffer) return buffer # Register where these options may occur SolicitMessage.add_may_contain(NTPServersOption) AdvertiseMessage.add_may_contain(NTPServersOption) RequestMessage.add_may_contain(NTPServersOption) RenewMessage.add_may_contain(NTPServersOption) RebindMessage.add_may_contain(NTPServersOption) InformationRequestMessage.add_may_contain(NTPServersOption) ReplyMessage.add_may_contain(NTPServersOption) NTPServersOption.add_may_contain(NTPSubOption, 1)
max_offset = option_len + header_offset # The option_len field counts bytes *after* the header fields while max_offset > my_offset: address = IPv6Address(buffer[offset + my_offset:offset + my_offset + 16]) self.sntp_servers.append(address) my_offset += 16 return my_offset def save(self) -> Union[bytes, bytearray]: """ Save the internal state of this object as a buffer. :return: The buffer with the data from this element """ buffer = bytearray() buffer.extend(pack('!HH', self.option_type, len(self.sntp_servers) * 16)) for address in self.sntp_servers: buffer.extend(address.packed) return buffer # Register where these options may occur SolicitMessage.add_may_contain(SNTPServersOption) AdvertiseMessage.add_may_contain(SNTPServersOption) RequestMessage.add_may_contain(SNTPServersOption) RenewMessage.add_may_contain(SNTPServersOption) RebindMessage.add_may_contain(SNTPServersOption) InformationRequestMessage.add_may_contain(SNTPServersOption) ReplyMessage.add_may_contain(SNTPServersOption)
""" Save the internal state of this object as a buffer. :return: The buffer with the data from this element """ buffer = bytearray() buffer.extend(pack('!HH', self.option_type, len(self.sip_servers) * 16)) for address in self.sip_servers: buffer.extend(address.packed) return buffer # Register where these options may occur SolicitMessage.add_may_contain(SIPServersDomainNameListOption) AdvertiseMessage.add_may_contain(SIPServersDomainNameListOption) RequestMessage.add_may_contain(SIPServersDomainNameListOption) RenewMessage.add_may_contain(SIPServersDomainNameListOption) RebindMessage.add_may_contain(SIPServersDomainNameListOption) InformationRequestMessage.add_may_contain(SIPServersDomainNameListOption) ReplyMessage.add_may_contain(SIPServersDomainNameListOption) SolicitMessage.add_may_contain(SIPServersAddressListOption) AdvertiseMessage.add_may_contain(SIPServersAddressListOption) RequestMessage.add_may_contain(SIPServersAddressListOption) RenewMessage.add_may_contain(SIPServersAddressListOption) RebindMessage.add_may_contain(SIPServersAddressListOption) InformationRequestMessage.add_may_contain(SIPServersAddressListOption) ReplyMessage.add_may_contain(SIPServersAddressListOption)
def save(self) -> Union[bytes, bytearray]: """ Save the internal state of this object as a buffer. :return: The buffer with the data from this element """ domain_buffer = encode_domain_list(self.search_list) buffer = bytearray() buffer.extend(pack('!HH', self.option_type, len(domain_buffer))) buffer.extend(domain_buffer) return buffer # Register where these options may occur SolicitMessage.add_may_contain(RecursiveNameServersOption) AdvertiseMessage.add_may_contain(RecursiveNameServersOption) RequestMessage.add_may_contain(RecursiveNameServersOption) RenewMessage.add_may_contain(RecursiveNameServersOption) RebindMessage.add_may_contain(RecursiveNameServersOption) InformationRequestMessage.add_may_contain(RecursiveNameServersOption) ReplyMessage.add_may_contain(RecursiveNameServersOption) SolicitMessage.add_may_contain(DomainSearchListOption) AdvertiseMessage.add_may_contain(DomainSearchListOption) RequestMessage.add_may_contain(DomainSearchListOption) RenewMessage.add_may_contain(DomainSearchListOption) RebindMessage.add_may_contain(DomainSearchListOption) InformationRequestMessage.add_may_contain(DomainSearchListOption) ReplyMessage.add_may_contain(DomainSearchListOption)
Save the internal state of this object as a buffer. :return: The buffer with the data from this element """ self.validate() buffer = bytearray() buffer.extend(pack('!HH', self.option_type, len(self.sip_servers) * 16)) for address in self.sip_servers: buffer.extend(address.packed) return buffer # Register where these options may occur SolicitMessage.add_may_contain(SIPServersDomainNameListOption) AdvertiseMessage.add_may_contain(SIPServersDomainNameListOption) RequestMessage.add_may_contain(SIPServersDomainNameListOption) RenewMessage.add_may_contain(SIPServersDomainNameListOption) RebindMessage.add_may_contain(SIPServersDomainNameListOption) InformationRequestMessage.add_may_contain(SIPServersDomainNameListOption) ReplyMessage.add_may_contain(SIPServersDomainNameListOption) SolicitMessage.add_may_contain(SIPServersAddressListOption) AdvertiseMessage.add_may_contain(SIPServersAddressListOption) RequestMessage.add_may_contain(SIPServersAddressListOption) RenewMessage.add_may_contain(SIPServersAddressListOption) RebindMessage.add_may_contain(SIPServersAddressListOption) InformationRequestMessage.add_may_contain(SIPServersAddressListOption) ReplyMessage.add_may_contain(SIPServersAddressListOption)
""" Save the internal state of this object as a buffer. :return: The buffer with the data from this element """ self.validate() domain_buffer = encode_domain_list(self.search_list) buffer = bytearray() buffer.extend(pack('!HH', self.option_type, len(domain_buffer))) buffer.extend(domain_buffer) return buffer SolicitMessage.add_may_contain(RecursiveNameServersOption, 0, 1) AdvertiseMessage.add_may_contain(RecursiveNameServersOption, 0, 1) RequestMessage.add_may_contain(RecursiveNameServersOption, 0, 1) RenewMessage.add_may_contain(RecursiveNameServersOption, 0, 1) RebindMessage.add_may_contain(RecursiveNameServersOption, 0, 1) InformationRequestMessage.add_may_contain(RecursiveNameServersOption, 0, 1) ReplyMessage.add_may_contain(RecursiveNameServersOption, 0, 1) SolicitMessage.add_may_contain(DomainSearchListOption, 0, 1) AdvertiseMessage.add_may_contain(DomainSearchListOption, 0, 1) RequestMessage.add_may_contain(DomainSearchListOption, 0, 1) RenewMessage.add_may_contain(DomainSearchListOption, 0, 1) RebindMessage.add_may_contain(DomainSearchListOption, 0, 1) InformationRequestMessage.add_may_contain(DomainSearchListOption, 0, 1) ReplyMessage.add_may_contain(DomainSearchListOption, 0, 1)
return my_offset def save(self) -> Union[bytes, bytearray]: """ Save the internal state of this object as a buffer. :return: The buffer with the data from this element """ buffer = bytearray() buffer.extend(pack('!HH', self.option_type, len(self.timezone))) buffer.extend(self.timezone.encode('ascii')) return buffer SolicitMessage.add_may_contain(PosixTimezoneOption, 0, 1) AdvertiseMessage.add_may_contain(PosixTimezoneOption, 0, 1) RequestMessage.add_may_contain(PosixTimezoneOption, 0, 1) RenewMessage.add_may_contain(PosixTimezoneOption, 0, 1) RebindMessage.add_may_contain(PosixTimezoneOption, 0, 1) InformationRequestMessage.add_may_contain(PosixTimezoneOption, 0, 1) ReplyMessage.add_may_contain(PosixTimezoneOption, 0, 1) SolicitMessage.add_may_contain(TZDBTimezoneOption, 0, 1) AdvertiseMessage.add_may_contain(TZDBTimezoneOption, 0, 1) RequestMessage.add_may_contain(TZDBTimezoneOption, 0, 1) RenewMessage.add_may_contain(TZDBTimezoneOption, 0, 1) RebindMessage.add_may_contain(TZDBTimezoneOption, 0, 1) InformationRequestMessage.add_may_contain(TZDBTimezoneOption, 0, 1) ReplyMessage.add_may_contain(TZDBTimezoneOption, 0, 1)