예제 #1
0
파일: tmgr.py 프로젝트: sdn-ixp/iSDX
def inflow (args):
    n = len(args)
    if n < 4 or n & 1 != 0 or args[n-2] != '>':
        log.error('MM:XX' + ' ERROR: USAGE: inflow [-c cookie] [-s srcaddr/prefix] [-d dstaddr/prefix] [-u udpport] [-t tcpport] > edge_router')
        return
    dst = args[n-1]
    asys, router = tlib.host2as_router(dst)
    if asys is None or asys not in participants:
        log.error('MM:XX' + ' ERROR: inbound flow has bad destination')
        return 
    if dst not in bgprouters:
        log.error('MM:XX' + ' ERROR: inbound flow has bad destination')
        return        
    das, dasport = tlib.host2as_router(dst)
    if das is None:
        log.error('MM:XX' + ' ERROR: inbound flow has bad destination')
        return
    if tlib.as2part(das) is None:
        log.error('MM:XX' + ' ERROR: inbound flow has bad participant')
        return
    
    fwd = int(dasport) 
    policy,error = rules(args[0:n-2], fwd)
    if error is not None:
        log.error('MM:XX' + ' ERROR: ' + error)
        return
    #print policy
    
    message = {}   
    policies = []
    message['new_policies'] = {}
    message['new_policies']['inbound'] = policies
    policies.append(policy)
    #print json.dumps(message, indent=4, sort_keys=True)
    genericObjNW(asys, 'FLOW', json.dumps(message))    
예제 #2
0
파일: tmgr.py 프로젝트: huxh10/SGDX
def outflow(args):
    n = len(args)
    if n < 5 or n & 1 != 1 or args[n - 2] != '>':
        log.error(
            'MM:XX' +
            ' ERROR: USAGE: outflow edgerouter [-c cookie] [-s srcaddr/prefix] [-d dstaddr/prefix] [-u udpport] [-t tcpport] > participant'
        )
        return

    src = args[0]
    if src not in bgprouters:
        log.error('MM:XX' + ' ERROR: outbound flow has bad source')
        return
    sas, sasport = tlib.host2as_router(src)
    if sas is None:
        log.error('MM:XX' + ' ERROR: outbound flow has bad source')
        return
    if tlib.as2part(sas) is None:
        log.error('MM:XX' + ' ERROR: outbound flow has bad participant')
        return

    dst = args[n - 1]
    das = dst  # destination is an AS not a host !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    if dst not in participants:
        log.error('MM:XX' + ' ERROR: outbound flow has bad destination')
        return
    if tlib.as2part(das) is None:
        log.error('MM:XX' + ' ERROR: outbound flow has bad destination')
        return
    fwd = int(tlib.as2part(das))

    policy, error = rules(args[1:n - 2], fwd)
    if error is not None:
        log.error('MM:XX' + ' ERROR: ' + error)
        return
    #print policy

    message = {}
    policies = []
    message['new_policies'] = {}
    message['new_policies']['outbound'] = policies
    policies.append(policy)
    #print json.dumps(message, indent=4, sort_keys=True)
    genericObjNW(sas, 'FLOW', json.dumps(message))
예제 #3
0
파일: tmgr.py 프로젝트: sdn-ixp/iSDX
def outflow (args):
    n = len(args)
    if n < 5 or n & 1 != 1 or args[n-2] != '>':
        log.error('MM:XX' + ' ERROR: USAGE: outflow edgerouter [-c cookie] [-s srcaddr/prefix] [-d dstaddr/prefix] [-u udpport] [-t tcpport] > participant')
        return
    
    src = args[0]
    if src not in bgprouters:
        log.error('MM:XX' + ' ERROR: outbound flow has bad source')
        return
    sas, sasport = tlib.host2as_router(src)
    if sas is None:
        log.error('MM:XX' + ' ERROR: outbound flow has bad source')
        return
    if tlib.as2part(sas) is None:
        log.error('MM:XX' + ' ERROR: outbound flow has bad participant')
        return
    
    dst = args[n-1]
    das = dst  # destination is an AS not a host !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    if dst not in participants:
        log.error('MM:XX' + ' ERROR: outbound flow has bad destination')
        return
    if tlib.as2part(das) is None:
        log.error('MM:XX' + ' ERROR: outbound flow has bad destination')
        return
    fwd = int(tlib.as2part(das)) 
    
    policy,error = rules(args[1:n-2], fwd)
    if error is not None:
        log.error('MM:XX' + ' ERROR: ' + error)
        return
    #print policy
    
    message = {}   
    policies = []
    message['new_policies'] = {}
    message['new_policies']['outbound'] = policies
    policies.append(policy)
    #print json.dumps(message, indent=4, sort_keys=True)  
    genericObjNW(sas, 'FLOW', json.dumps(message))       
예제 #4
0
파일: tmgr.py 프로젝트: huxh10/SGDX
def inflow(args):
    n = len(args)
    if n < 4 or n & 1 != 0 or args[n - 2] != '>':
        log.error(
            'MM:XX' +
            ' ERROR: USAGE: inflow [-c cookie] [-s srcaddr/prefix] [-d dstaddr/prefix] [-u udpport] [-t tcpport] > edge_router'
        )
        return
    dst = args[n - 1]
    asys, router = tlib.host2as_router(dst)
    if asys is None or asys not in participants:
        log.error('MM:XX' + ' ERROR: inbound flow has bad destination')
        return
    if dst not in bgprouters:
        log.error('MM:XX' + ' ERROR: inbound flow has bad destination')
        return
    das, dasport = tlib.host2as_router(dst)
    if das is None:
        log.error('MM:XX' + ' ERROR: inbound flow has bad destination')
        return
    if tlib.as2part(das) is None:
        log.error('MM:XX' + ' ERROR: inbound flow has bad participant')
        return

    fwd = int(dasport)
    policy, error = rules(args[0:n - 2], fwd)
    if error is not None:
        log.error('MM:XX' + ' ERROR: ' + error)
        return
    #print policy

    message = {}
    policies = []
    message['new_policies'] = {}
    message['new_policies']['inbound'] = policies
    policies.append(policy)
    #print json.dumps(message, indent=4, sort_keys=True)
    genericObjNW(asys, 'FLOW', json.dumps(message))