daemon/core/netns/nodes.py
def tolinkmsgs(self, flags):
        ''' Build CORE API TLVs for a point-to-point link. One Link message
            describes this network.
        '''
        tlvdata = ""
        if len(self._netif) != 2:
            return tlvdata
        (if1, if2) = self._netif.items()
        if1 = if1[1]
        if2 = if2[1]
        tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_N1NUMBER,
                                            if1.node.objid)
        tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_N2NUMBER,
                                            if2.node.objid)
        uni = False
        if if1.getparams() != if2.getparams():
            uni = True
        tlvdata += self.netifparamstolink(if1)
        tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_TYPE,
                                            self.linktype)
        if uni:
            tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_UNI, 1)

        tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_IF1NUM, \
                                            if1.node.getifindex(if1))
        if if1.hwaddr:
            tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_IF1MAC,
                                                if1.hwaddr)
        for addr in if1.addrlist:
            (ip, sep, mask)  = addr.partition('/')
            mask = int(mask)
            if isIPv4Address(ip):
                family = AF_INET
                tlvtypeip = coreapi.CORE_TLV_LINK_IF1IP4
                tlvtypemask = coreapi.CORE_TLV_LINK_IF1IP4MASK
            else:
                family = AF_INET6
                tlvtypeip = coreapi.CORE_TLV_LINK_IF1IP6
                tlvtypemask = coreapi.CORE_TLV_LINK_IF1IP6MASK
            ipl = socket.inet_pton(family, ip)
            tlvdata += coreapi.CoreLinkTlv.pack(tlvtypeip,
                                                IPAddr(af=family, addr=ipl))
            tlvdata += coreapi.CoreLinkTlv.pack(tlvtypemask, mask)

        tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_IF2NUM, \
                                            if2.node.getifindex(if2))
        if if2.hwaddr:
            tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_IF2MAC,
                                                if2.hwaddr)
        for addr in if2.addrlist:
            (ip, sep, mask)  = addr.partition('/')
            mask = int(mask)
            if isIPv4Address(ip):
                family = AF_INET
                tlvtypeip = coreapi.CORE_TLV_LINK_IF2IP4
                tlvtypemask = coreapi.CORE_TLV_LINK_IF2IP4MASK
            else:
                family = AF_INET6
                tlvtypeip = coreapi.CORE_TLV_LINK_IF2IP6
                tlvtypemask = coreapi.CORE_TLV_LINK_IF2IP6MASK
            ipl = socket.inet_pton(family, ip)
            tlvdata += coreapi.CoreLinkTlv.pack(tlvtypeip,
                                                IPAddr(af=family, addr=ipl))
            tlvdata += coreapi.CoreLinkTlv.pack(tlvtypemask, mask)
        msg = coreapi.CoreLinkMessage.pack(flags, tlvdata)
        if not uni:
            return [msg,]
        # build a 2nd link message for the upstream link parameters
        # (swap if1 and if2)
        tlvdata = ""
        tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_N1NUMBER,
                                            if2.node.objid)
        tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_N2NUMBER,
                                            if1.node.objid)
        tlvdata += self.netifparamstolink(if2)
        tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_UNI, 1)
        tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_IF1NUM, \
                                            if2.node.getifindex(if2))
        tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_IF2NUM, \
                                            if1.node.getifindex(if1))
        msg2 = coreapi.CoreLinkMessage.pack(0, tlvdata)
        return [msg, msg2]
 Build CORE API TLVs for a point-to-point link. One Link message
            describes this network.
        
Build CORE API TLVs for a point-to-point link. One Link message
describes this network.
Build CORE API TLVs for a point - to - point link . One Link message describes this network .
def tolinkmsgs(self, flags):
        tlvdata = ""
        if len(self._netif) != 2:
            return tlvdata
        (if1, if2) = self._netif.items()
        if1 = if1[1]
        if2 = if2[1]
        tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_N1NUMBER,
                                            if1.node.objid)
        tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_N2NUMBER,
                                            if2.node.objid)
        uni = False
        if if1.getparams() != if2.getparams():
            uni = True
        tlvdata += self.netifparamstolink(if1)
        tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_TYPE,
                                            self.linktype)
        if uni:
            tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_UNI, 1)
        tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_IF1NUM, \
                                            if1.node.getifindex(if1))
        if if1.hwaddr:
            tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_IF1MAC,
                                                if1.hwaddr)
        for addr in if1.addrlist:
            (ip, sep, mask)  = addr.partition('/')
            mask = int(mask)
            if isIPv4Address(ip):
                family = AF_INET
                tlvtypeip = coreapi.CORE_TLV_LINK_IF1IP4
                tlvtypemask = coreapi.CORE_TLV_LINK_IF1IP4MASK
            else:
                family = AF_INET6
                tlvtypeip = coreapi.CORE_TLV_LINK_IF1IP6
                tlvtypemask = coreapi.CORE_TLV_LINK_IF1IP6MASK
            ipl = socket.inet_pton(family, ip)
            tlvdata += coreapi.CoreLinkTlv.pack(tlvtypeip,
                                                IPAddr(af=family, addr=ipl))
            tlvdata += coreapi.CoreLinkTlv.pack(tlvtypemask, mask)
        tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_IF2NUM, \
                                            if2.node.getifindex(if2))
        if if2.hwaddr:
            tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_IF2MAC,
                                                if2.hwaddr)
        for addr in if2.addrlist:
            (ip, sep, mask)  = addr.partition('/')
            mask = int(mask)
            if isIPv4Address(ip):
                family = AF_INET
                tlvtypeip = coreapi.CORE_TLV_LINK_IF2IP4
                tlvtypemask = coreapi.CORE_TLV_LINK_IF2IP4MASK
            else:
                family = AF_INET6
                tlvtypeip = coreapi.CORE_TLV_LINK_IF2IP6
                tlvtypemask = coreapi.CORE_TLV_LINK_IF2IP6MASK
            ipl = socket.inet_pton(family, ip)
            tlvdata += coreapi.CoreLinkTlv.pack(tlvtypeip,
                                                IPAddr(af=family, addr=ipl))
            tlvdata += coreapi.CoreLinkTlv.pack(tlvtypemask, mask)
        msg = coreapi.CoreLinkMessage.pack(flags, tlvdata)
        if not uni:
            return [msg,]
        tlvdata = ""
        tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_N1NUMBER,
                                            if2.node.objid)
        tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_N2NUMBER,
                                            if1.node.objid)
        tlvdata += self.netifparamstolink(if2)
        tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_UNI, 1)
        tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_IF1NUM, \
                                            if2.node.getifindex(if2))
        tlvdata += coreapi.CoreLinkTlv.pack(coreapi.CORE_TLV_LINK_IF2NUM, \
                                            if1.node.getifindex(if1))
        msg2 = coreapi.CoreLinkMessage.pack(0, tlvdata)
        return [msg, msg2]
def tolinkmsgs ( self , flags ) : tlvdata = "" if len ( self . _netif ) != 2 : return tlvdata ( if1 , if2 ) = self . _netif . items ( ) if1 = if1 [ 1 ] if2 = if2 [ 1 ] tlvdata += coreapi . CoreLinkTlv . pack ( coreapi . CORE_TLV_LINK_N1NUMBER , if1 . node . objid ) tlvdata += coreapi . CoreLinkTlv . pack ( coreapi . CORE_TLV_LINK_N2NUMBER , if2 . node . objid ) uni = False if if1 . getparams ( ) != if2 . getparams ( ) : uni = True tlvdata += self . netifparamstolink ( if1 ) tlvdata += coreapi . CoreLinkTlv . pack ( coreapi . CORE_TLV_LINK_TYPE , self . linktype ) if uni : tlvdata += coreapi . CoreLinkTlv . pack ( coreapi . CORE_TLV_LINK_UNI , 1 ) tlvdata += coreapi . CoreLinkTlv . pack ( coreapi . CORE_TLV_LINK_IF1NUM , if1 . node . getifindex ( if1 ) ) if if1 . hwaddr : tlvdata += coreapi . CoreLinkTlv . pack ( coreapi . CORE_TLV_LINK_IF1MAC , if1 . hwaddr ) for addr in if1 . addrlist : ( ip , sep , mask ) = addr . partition ( '/' ) mask = int ( mask ) if isIPv4Address ( ip ) : family = AF_INET tlvtypeip = coreapi . CORE_TLV_LINK_IF1IP4 tlvtypemask = coreapi . CORE_TLV_LINK_IF1IP4MASK else : family = AF_INET6 tlvtypeip = coreapi . CORE_TLV_LINK_IF1IP6 tlvtypemask = coreapi . CORE_TLV_LINK_IF1IP6MASK ipl = socket . inet_pton ( family , ip ) tlvdata += coreapi . CoreLinkTlv . pack ( tlvtypeip , IPAddr ( af = family , addr = ipl ) ) tlvdata += coreapi . CoreLinkTlv . pack ( tlvtypemask , mask ) tlvdata += coreapi . CoreLinkTlv . pack ( coreapi . CORE_TLV_LINK_IF2NUM , if2 . node . getifindex ( if2 ) ) if if2 . hwaddr : tlvdata += coreapi . CoreLinkTlv . pack ( coreapi . CORE_TLV_LINK_IF2MAC , if2 . hwaddr ) for addr in if2 . addrlist : ( ip , sep , mask ) = addr . partition ( '/' ) mask = int ( mask ) if isIPv4Address ( ip ) : family = AF_INET tlvtypeip = coreapi . CORE_TLV_LINK_IF2IP4 tlvtypemask = coreapi . CORE_TLV_LINK_IF2IP4MASK else : family = AF_INET6 tlvtypeip = coreapi . CORE_TLV_LINK_IF2IP6 tlvtypemask = coreapi . CORE_TLV_LINK_IF2IP6MASK ipl = socket . inet_pton ( family , ip ) tlvdata += coreapi . CoreLinkTlv . pack ( tlvtypeip , IPAddr ( af = family , addr = ipl ) ) tlvdata += coreapi . CoreLinkTlv . pack ( tlvtypemask , mask ) msg = coreapi . CoreLinkMessage . pack ( flags , tlvdata ) if not uni : return [ msg , ] tlvdata = "" tlvdata += coreapi . CoreLinkTlv . pack ( coreapi . CORE_TLV_LINK_N1NUMBER , if2 . node . objid ) tlvdata += coreapi . CoreLinkTlv . pack ( coreapi . CORE_TLV_LINK_N2NUMBER , if1 . node . objid ) tlvdata += self . netifparamstolink ( if2 ) tlvdata += coreapi . CoreLinkTlv . pack ( coreapi . CORE_TLV_LINK_UNI , 1 ) tlvdata += coreapi . CoreLinkTlv . pack ( coreapi . CORE_TLV_LINK_IF1NUM , if2 . node . getifindex ( if2 ) ) tlvdata += coreapi . CoreLinkTlv . pack ( coreapi . CORE_TLV_LINK_IF2NUM , if1 . node . getifindex ( if1 ) ) msg2 = coreapi . CoreLinkMessage . pack ( 0 , tlvdata ) return [ msg , msg2 ]
Build CORE API TLVs for a point-to-point link.
Build CORE API TLVs for a point - to - point link .
''' Build CORE API TLVs for a point-to-point link. One Link message
            describes this network.
        ''' # build a 2nd link message for the upstream link parameters # (swap if1 and if2)
self
flags