Commit 5a3e8201 authored by Tomas Hlavacek's avatar Tomas Hlavacek

Fix BIRD IPv6 prefix annotation.

Fix IPv6 prefix annotation in show route all ... command in BIRD
command decorator.
parent e197c49a
......@@ -42,6 +42,9 @@ import whois
IPV4_ANNOTATE_REGEXP = '([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(/[0-9]{1,2})?)'
ipv4_annotate_regexp = re.compile(IPV4_ANNOTATE_REGEXP)
IPV6_ANNOTATE_REGEXP = '(([0-9a-fA-F]{1,4}:|:){2,7}([0-9a-fA-F]{1,4}|:)(/[0-9]{1,2})?)'
ipv6_annotate_regexp = re.compile(IPV6_ANNOTATE_REGEXP)
### CGI output handler
class Session(object):
......@@ -329,7 +332,7 @@ class DecoratorHelper:
def decoratePrefix(self,ip):
return self.mwin(self.getWhoisURL(ip,'IP'),ip)
def annotatePrefixes(self,line):
def annotatePrefixes4(self,line):
s=0
r=''
for m in ipv4_annotate_regexp.finditer(line):
......@@ -338,7 +341,7 @@ class DecoratorHelper:
s = m.end()
return r + line[s:]
def annotateIPs(self,line):
def annotateIPs4(self,line):
s=0
r=''
for m in ipv4_annotate_regexp.finditer(line):
......@@ -346,7 +349,32 @@ class DecoratorHelper:
r = r + self.decoratePrefix(line[m.start():m.end()])
s = m.end()
return r + line[s:]
def annotatePrefixes6(self,line):
s=0
r=''
for m in ipv6_annotate_regexp.finditer(line):
r = r + line[s:m.start()]
r = r + self.decoratePrefix(line[m.start():m.end()])
s = m.end()
return r + line[s:]
def annotateIPs6(self,line):
s=0
r=''
for m in ipv6_annotate_regexp.finditer(line):
r = r + line[s:m.start()]
r = r + self.decoratePrefix(line[m.start():m.end()])
s = m.end()
return r + line[s:]
def annotatePrefixes(self,line):
# return self.annotatePrefixes4(line)
return self.annotatePrefixes6(self.annotatePrefixes4(line))
def annotateIPs(self,line):
# return self.annotateIPs4(line)
return self.annotateIPs6(self.annotatePrefixes4(line))
class ULGCgi:
......
......@@ -637,8 +637,8 @@ class BirdRouterRemote(ulgmodel.RemoteRouter,BirdRouter):
return self.routing_tables
def savePersistentInfo(self):
key_bgp = self.getHost() + self.PS_KEY_BGP
key_rt = self.getHost() + self.PS_KEY_RT
key_bgp = self.getHost() + self.getName() + self.PS_KEY_BGP
key_rt = self.getHost() + self.getName() + self.PS_KEY_RT
ps = ulgmodel.PersistentStorage.load()
......@@ -647,8 +647,8 @@ class BirdRouterRemote(ulgmodel.RemoteRouter,BirdRouter):
ps.save()
def loadPersistentInfo(self):
key_bgp = self.getHost() + self.PS_KEY_BGP
key_rt = self.getHost() + self.PS_KEY_RT
key_bgp = self.getHost() + self.getName() + self.PS_KEY_BGP
key_rt = self.getHost() + self.getName() + self.PS_KEY_RT
ps = ulgmodel.PersistentStorage.load()
self.bgp_peers = ps.get(key_bgp)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment