Ejemplo n.º 1
0
def path_information(tokeniser):
    try:
        pi = tokeniser()
        if pi.isdigit():
            return PathInfo(integer=int(pi))
        return PathInfo(ip=pi)
    except ValueError:
        raise ValueError('invaluid path-information')
Ejemplo n.º 2
0
 def unpack(cls, afi, safi, data, addpath, nexthop, action):
     labels, rd, path_identifier, mask, size, prefix, left = NLRI._nlri(
         afi, safi, data, action, addpath)
     nlri = cls(afi, safi, prefix, mask, nexthop, action)
     if path_identifier:
         nlri.path_info = PathInfo(None, None, path_identifier)
     return len(data) - len(left), nlri
Ejemplo n.º 3
0
    def unpack(cls, afi, safi, bgp, addpath, nexthop, action):
        labels, rd, path_identifier, mask, size, prefix, left = NLRI._nlri(
            afi, safi, bgp, action, addpath)

        nlri = cls(afi, safi, prefix, mask, nexthop, action)
        if labels: nlri.labels = Labels(labels)
        if rd: nlri.rd = RouteDistinguisher(rd)
        if path_identifier:
            nlri.path_info = PathInfo(None, None, path_identifier)

        return len(bgp) - len(left), nlri
Ejemplo n.º 4
0
    def unpack(cls, afi, safi, data, addpath, nexthop, action):
        if addpath:
            path_identifier = PathInfo(None, None, data[:4])
            data = data[4:]
            length = 4
        else:
            path_identifier = None
            length = 0

        labels, rd, mask, size, prefix, left = NLRI._nlri(
            afi, safi, data, action)
        nlri = cls(afi, safi, prefix, mask, nexthop, action)
        if addpath:
            nlri.path_info = path_identifier
        return length + len(data) - len(left), nlri