structured element is parsed. This data is ignored. :param buffer: The buffer to read data from :param offset: The offset in the buffer where to start reading :param length: The amount of data we are allowed to read from the buffer :return: The number of bytes used from the buffer """ my_offset, option_len = self.parse_option_header( buffer, offset, length) self.subscriber_id = buffer[offset + my_offset:offset + my_offset + option_len] my_offset += option_len 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 """ return pack('!HH', self.option_type, len( self.subscriber_id)) + self.subscriber_id RelayForwardMessage.add_may_contain(SubscriberIdOption) # The RFC says there is no requirement for servers to include this option in replies, but it is not forbidden RelayReplyMessage.add_may_contain(SubscriberIdOption)
:param buffer: The buffer to read data from :param offset: The offset in the buffer where to start reading :param length: The amount of data we are allowed to read from the buffer :return: The number of bytes used from the buffer """ my_offset, option_len = self.parse_option_header(buffer, offset, length) self.enterprise_number = unpack_from('!I', buffer, offset=offset + my_offset)[0] my_offset += 4 remote_id_length = option_len - 4 self.remote_id = buffer[offset + my_offset:offset + my_offset + remote_id_length] my_offset += remote_id_length 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 """ return pack('!HHI', self.option_type, len(self.remote_id) + 4, self.enterprise_number) + self.remote_id RelayForwardMessage.add_may_contain(RemoteIdOption) # The RFC says there is no requirement for servers to include this option in replies, but it is not forbidden RelayReplyMessage.add_may_contain(RemoteIdOption)
my_offset, option_len = self.parse_option_header( buffer, offset, length) self.enterprise_number = unpack_from('!I', buffer, offset=offset + my_offset)[0] my_offset += 4 remote_id_length = option_len - 4 self.remote_id = buffer[offset + my_offset:offset + my_offset + remote_id_length] my_offset += remote_id_length 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 """ return pack('!HHI', self.option_type, len(self.remote_id) + 4, self.enterprise_number) + self.remote_id RelayForwardMessage.add_may_contain(RemoteIdOption) # The RFC says there is no requirement for servers to include this option in replies, but it is not forbidden RelayReplyMessage.add_may_contain(RemoteIdOption)
def load_from(self, buffer: bytes, offset: int = 0, length: int = None) -> int: """ Load the internal state of this object from the given buffer. The buffer may contain more data after the structured element is parsed. This data is ignored. :param buffer: The buffer to read data from :param offset: The offset in the buffer where to start reading :param length: The amount of data we are allowed to read from the buffer :return: The number of bytes used from the buffer """ my_offset, option_len = self.parse_option_header(buffer, offset, length) self.subscriber_id = buffer[offset + my_offset : offset + my_offset + option_len] my_offset += option_len 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 """ return pack("!HH", self.option_type, len(self.subscriber_id)) + self.subscriber_id RelayForwardMessage.add_may_contain(SubscriberIdOption) # The RFC says there is no requirement for servers to include this option in replies, but it is not forbidden RelayReplyMessage.add_may_contain(SubscriberIdOption)