def family(self, tokeniser): data = self.get_section(SectionFamily.name, tokeniser) if data: self.content[Capability.CODE( Capability.CODE.MULTIPROTOCOL)] = MultiProtocol( (afi, safi) for afi in sorted(data) for safi in sorted(data[afi])) else: return False
def enter(self, tokeniser): Section.enter(self, tokeniser) self.content[Capability.CODE(Capability.CODE.FOUR_BYTES_ASN)] = True self.content[Capability.CODE(Capability.CODE.AIGP)] = False self.content[Capability.CODE(Capability.CODE.ADD_PATH)] = 0 self.content[Capability.CODE(Capability.CODE.OPERATIONAL)] = False self.content[Capability.CODE(Capability.CODE.ROUTE_REFRESH)] = False self.content[Capability.CODE(Capability.CODE.MULTISESSION)] = False self.content[Capability.CODE(Capability.CODE.GRACEFUL_RESTART)] = 0
def addpath(self, tokeniser): self._check_duplicate(tokeniser, RaisedCapability) valid_options = ('receive', 'send', 'send/receive', 'disable', 'disabled') ap = tokeniser() if ap not in valid_options: raise RaisedCapability( tokeniser, "%s is not a invalid add-path paramerter, options are %s" % (ap, ', '.join(valid_options))) self.content[Capability.CODE(Capability.CODE.ADD_PATH)] = 0 if ap.endswith('receive'): self.content[Capability.CODE.ADD_PATH] += 1 if ap.startswith('send'): self.content[Capability.CODE.ADD_PATH] += 2
def graceful(self, tokeniser): self._check_duplicate(tokeniser, RaisedCapability) token = tokeniser() if not token.isdigit(): raise RaisedCapability( tokeniser, "%s is not a valid option for graceful-restart, it must be a positive number smaller than 2^16" % token) duration = int(token) if duration < 0: raise RaisedCapability( tokeniser, "%s is not a valid option for graceful-restart, it must be a positive number smaller than 2^16" % token) if duration > pow(2, 16): raise RaisedCapability( tokeniser, "%s is not a valid option for graceful-restart, it must be a positive number smaller than 2^16" % token) self.content[Capability.CODE( Capability.CODE.GRACEFUL_RESTART)] = duration
def aigp(self, tokeniser): self._check_duplicate(tokeniser, RaisedCapability) self.content[Capability.CODE(Capability.CODE.AIGP)] = boolean( tokeniser, False)
def asn4(self, tokeniser): self._check_duplicate(tokeniser, RaisedCapability) self.content[Capability.CODE( Capability.CODE.FOUR_BYTES_ASN)] = boolean(tokeniser, True)
def exit(self, tokeniser): if Capability.CODE(Capability.CODE.MULTIPROTOCOL) not in self.content: self.content[Capability.CODE( Capability.CODE.MULTIPROTOCOL)] = MultiProtocol( known_families())
def multisession(self, tokeniser): self._check_duplicate(tokeniser, RaisedCapability) self.content[Capability.CODE( Capability.CODE.MULTISESSION_CISCO)] = boolean(tokeniser, False)
def refresh(self, tokeniser): self._check_duplicate(tokeniser, RaisedCapability) self.content[Capability.CODE(Capability.CODE.ROUTE_REFRESH)] = boolean( tokeniser, False)
def operational(self, tokeniser): self._check_duplicate(tokeniser, RaisedCapability) self.content[Capability.CODE(Capability.CODE.OPERATIONAL)] = boolean( tokeniser, False)