fib.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:sonic-mgmt 作者: Azure 项目源码 文件源码
def __init__(self, file_path):
        self._ipv4_lpm_dict = LpmDict()
        for ip in EXCLUDE_IPV4_PREFIXES:
            self._ipv4_lpm_dict[ip] = self.NextHop()

        self._ipv6_lpm_dict = LpmDict(ipv4=False)
        for ip in EXCLUDE_IPV6_PREFIXES:
            self._ipv6_lpm_dict[ip] = self.NextHop()

        # filter out empty lines and lines starting with '#'
        pattern = re.compile("^#.*$|^[ \t]*$")

        with open(file_path, 'r') as f:
            for line in f.readlines():
                if pattern.match(line): continue
                entry = line.split(' ', 1)
                prefix = ip_network(unicode(entry[0]))
                next_hop = self.NextHop(entry[1])
                if prefix.version is 4:
                    self._ipv4_lpm_dict[str(prefix)] = next_hop
                elif prefix.version is 6:
                    self._ipv6_lpm_dict[str(prefix)] = next_hop
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号