Ejemplo n.º 1
0
        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)
Ejemplo n.º 2
0
        options associated with this Softwire46 Lightweight 4over6 domain.

    The encapsulated-options field conveys options specific to the
    OPTION_S46_CONT_LW option. Currently, there are two options
    specified: OPTION_S46_V4V6BIND and OPTION_S46_BR. There MUST be at
    most one OPTION_S46_V4V6BIND option and at least one OPTION_S46_BR
    option.
    """

    option_type = OPTION_S46_CONT_LW


# Register where these options may occur
SolicitMessage.add_may_contain(S46ContainerOption)
AdvertiseMessage.add_may_contain(S46ContainerOption)
RequestMessage.add_may_contain(S46ContainerOption)
ConfirmMessage.add_may_contain(S46ContainerOption)
RenewMessage.add_may_contain(S46ContainerOption)
RebindMessage.add_may_contain(S46ContainerOption)
ReleaseMessage.add_may_contain(S46ContainerOption)
ReplyMessage.add_may_contain(S46ContainerOption)

S46RuleOption.add_may_contain(S46PortParametersOption)

S46V4V6BindingOption.add_may_contain(S46PortParametersOption)

S46MapEContainerOption.add_may_contain(S46RuleOption, min_occurrence=1)
S46MapEContainerOption.add_may_contain(S46BROption, min_occurrence=1)
S46MapEContainerOption.add_may_contain(S46PortParametersOption)

S46MapTContainerOption.add_may_contain(S46RuleOption, min_occurrence=1)
Ejemplo n.º 3
0
        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)
Ejemplo n.º 4
0
        """
        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)
Ejemplo n.º 5
0
        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)
Ejemplo n.º 6
0
    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)
request_message = RequestMessage(
    transaction_id=bytes.fromhex('f350d6'),
    options=[
        ElapsedTimeOption(elapsed_time=104),
        ClientIdOption(duid=LinkLayerDUID(hardware_type=1,
                                          link_layer_address=bytes.fromhex(
                                              '3431c43cb2f1'))),
        ServerIdOption(duid=LinkLayerTimeDUID(hardware_type=1,
                                              time=488458703,
                                              link_layer_address=bytes.fromhex(
                                                  '00137265ca42'))),
        IANAOption(iaid=bytes.fromhex('c43cb2f1'),
                   options=[
                       IAAddressOption(
                           address=IPv6Address('2001:db8:ffff:1:c::e09c'),
                           preferred_lifetime=375,
                           valid_lifetime=600),
                   ]),
        IAPDOption(iaid=bytes.fromhex('c43cb2f1'),
                   options=[
                       IAPrefixOption(
                           prefix=IPv6Network('2001:db8:ffcc:fe00::/56'),
                           preferred_lifetime=375,
                           valid_lifetime=600),
                   ]),
        ReconfigureAcceptOption(),
        OptionRequestOption(requested_options=[
            OPTION_DNS_SERVERS,
            OPTION_NTP_SERVER,
            OPTION_SNTP_SERVERS,
            OPTION_IA_PD,
            OPTION_IA_NA,
            OPTION_VENDOR_OPTS,
            OPTION_SOL_MAX_RT,
            OPTION_INF_MAX_RT,
        ]),
        VendorClassOption(enterprise_number=872),
    ],
)
Ejemplo n.º 8
0
        options associated with this Softwire46 Lightweight 4over6 domain.

    The encapsulated-options field conveys options specific to the
    OPTION_S46_CONT_LW option. Currently, there are two options
    specified: OPTION_S46_V4V6BIND and OPTION_S46_BR. There MUST be at
    most one OPTION_S46_V4V6BIND option and at least one OPTION_S46_BR
    option.
    """

    option_type = OPTION_S46_CONT_LW


# Register where these options may occur
SolicitMessage.add_may_contain(S46ContainerOption)
AdvertiseMessage.add_may_contain(S46ContainerOption)
RequestMessage.add_may_contain(S46ContainerOption)
ConfirmMessage.add_may_contain(S46ContainerOption)
RenewMessage.add_may_contain(S46ContainerOption)
RebindMessage.add_may_contain(S46ContainerOption)
ReleaseMessage.add_may_contain(S46ContainerOption)
ReplyMessage.add_may_contain(S46ContainerOption)

S46RuleOption.add_may_contain(S46PortParametersOption)

S46V4V6BindingOption.add_may_contain(S46PortParametersOption)

S46MapEContainerOption.add_may_contain(S46RuleOption, min_occurrence=1)
S46MapEContainerOption.add_may_contain(S46BROption, min_occurrence=1)
S46MapEContainerOption.add_may_contain(S46PortParametersOption)

S46MapTContainerOption.add_may_contain(S46RuleOption, min_occurrence=1)
Ejemplo n.º 9
0
        :return: The buffer with the data from this element
        """
        options_buffer = bytearray()
        for option in self.options:
            options_buffer.extend(option.save())

        buffer = bytearray()
        buffer.extend(
            pack('!HHIIB', self.option_type,
                 len(options_buffer) + 25, self.preferred_lifetime,
                 self.valid_lifetime, self.prefix.prefixlen))
        buffer.extend(self.prefix.network_address.packed)
        buffer.extend(options_buffer)
        return buffer


# Register where these options may occur
SolicitMessage.add_may_contain(IAPDOption)
AdvertiseMessage.add_may_contain(IAPDOption)
RequestMessage.add_may_contain(IAPDOption)
ConfirmMessage.add_may_contain(IAPDOption)
RenewMessage.add_may_contain(IAPDOption)
RebindMessage.add_may_contain(IAPDOption)
ReleaseMessage.add_may_contain(IAPDOption)
ReplyMessage.add_may_contain(IAPDOption)

IAPDOption.add_may_contain(IAPrefixOption)
IAPDOption.add_may_contain(StatusCodeOption, 0, 1)

IAPrefixOption.add_may_contain(StatusCodeOption, 0, 1)
Ejemplo n.º 10
0
        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)
Ejemplo n.º 11
0
        :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('!HHIIB', self.option_type, len(options_buffer) + 25,
                           self.preferred_lifetime, self.valid_lifetime, self.prefix.prefixlen))
        buffer.extend(self.prefix.network_address.packed)
        buffer.extend(options_buffer)
        return buffer


# Register where these options may occur
SolicitMessage.add_may_contain(IAPDOption)
AdvertiseMessage.add_may_contain(IAPDOption)
RequestMessage.add_may_contain(IAPDOption)
RenewMessage.add_may_contain(IAPDOption)
RebindMessage.add_may_contain(IAPDOption)
ReleaseMessage.add_may_contain(IAPDOption)
ReplyMessage.add_may_contain(IAPDOption)

IAPDOption.add_may_contain(IAPrefixOption)
IAPDOption.add_may_contain(StatusCodeOption, 0, 1)

IAPrefixOption.add_may_contain(StatusCodeOption, 0, 1)
Ejemplo n.º 12
0
        max_offset = option_len + header_offset  # The option_len field counts bytes *after* the header fields
        domain_name_len, self.domain_name = parse_domain_bytes(buffer, offset=offset + my_offset, length=option_len - 1,
                                                               allow_relative=True)
        my_offset += domain_name_len

        if my_offset != max_offset:
            raise ValueError('Option length does not match the combined length of the included domain name')

        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
        """
        domain_buffer = encode_domain(self.domain_name)

        buffer = bytearray()
        buffer.extend(pack('!HHB', self.option_type, 1 + len(domain_buffer), self.flags))
        buffer.extend(domain_buffer)
        return buffer


SolicitMessage.add_may_contain(ClientFQDNOption, 0, 1)
AdvertiseMessage.add_may_contain(ClientFQDNOption, 0, 1)
RequestMessage.add_may_contain(ClientFQDNOption, 0, 1)
RenewMessage.add_may_contain(ClientFQDNOption, 0, 1)
RebindMessage.add_may_contain(ClientFQDNOption, 0, 1)
ReplyMessage.add_may_contain(ClientFQDNOption, 0, 1)
Ejemplo n.º 13
0
        """
        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)
Ejemplo n.º 14
0
        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)