Check if the current settings conform to the RFC and fix where possible

def sanitize(self):
        '''
        Check if the current settings conform to the RFC and fix where possible
        '''
        # Let the parent do its stuff
        super(IPv6Packet, self).sanitize()

        # Check the version
        if self.version != 6:
            raise ValueError("Protocol version must be 6")

        # Treat traffic class as an 8-bit unsigned integer. Future versions of
        # this code may implement methods to treat it as DSCP+ECN
        if not isinstance(self.traffic_class, numbers.Integral) \
        or self.traffic_class < 0 \
        or self.traffic_class >= 2 ** 8:
            raise ValueError('Invalid traffic class')

        # Treat flow label as a 20-bit unsigned integer. Future versions of
        # this code may do more once the IETF figures out what a flow label
        # means ;-)
        if not isinstance(self.flow_label, numbers.Integral) \
        or self.flow_label < 0 \
        or self.flow_label >= 2 ** 20:
            raise ValueError('Invalid flow label')

        # Check that the hop-limit is correct
        if not isinstance(self.hop_limit, numbers.Integral) \
        or self.hop_limit < 0 \
        or self.hop_limit >= 2 ** 8:
            raise ValueError('Invalid hop limit')

        # Check the source and destination addresses
        if not isinstance(self.source, IPv6Address):
            raise ValueError('Source address must be IPv6')

        if not isinstance(self.destination, IPv6Address):
            raise ValueError('Destination address must be IPv6')