Exemple #1
0
def mark(tokeniser):
    value = tokeniser()

    if not value.isdigit():
        raise ValueError('dscp is not a number')

    dscp_value = int(value)

    if dscp_value < 0 or dscp_value > 0b111111:
        raise ValueError('dscp is not a valid number')

    return ExtendedCommunities().add(TrafficMark(dscp_value))
Exemple #2
0
    def mark(self, scope, name, command, tokens):
        try:
            dscp = int(tokens.pop(0))

            if dscp < 0 or dscp > 0b111111:
                return self.error.set(self.syntax)

            change = scope[-1]['announce'][-1]
            change.attributes[Attribute.CODE.EXTENDED_COMMUNITY].add(
                TrafficMark(dscp))
            return True

        except (IndexError, ValueError):
            return self.error.set(self.syntax)