예제 #1
0
def dec_ip_ttl():
    """Return OpenFlow action to decrement IP TTL.

    Returns:
        ryu.ofproto.ofproto_v1_3_parser.OFPActionDecNwTtl: decrement IP TTL.
    """
    return parser.OFPActionDecNwTtl()
예제 #2
0
def actions_to_ryu(actions, rule):
    """ Converts a list of actions to a list of ryu actions

        This returns both a instruction list and any extra messages that
        are required to install the instructions such as group mod messages.
        Currently this is not smart about reusing groups.

        actions: A iterable list actions such as ActionSet, ActionList,
                 or Bucket.
        rule: The rule being converted
        return: A tuple ([actions], [extra messages])
    """
    ret = []
    extra_messages = []
    for action in actions:
        if action[0] == 'OUTPUT':
            ret.append(parser.OFPActionOutput(action[1]))
        elif action[0] == 'COPY_TTL_OUT':
            ret.append(parser.OFPActionCopyTtlOut())
        elif action[0] == 'COPY_TTL_IN':
            ret.append(parser.OFPActionCopyTtlIn())
        elif action[0] == 'SET_MPLS_TTL':
            ret.append(parser.OFPActionSetMplsTtl(action[1]))
        elif action[0] == 'DEC_MPLS_TTL':
            ret.append(parser.OFPActionDecMplsTtl())
        elif action[0] == 'PUSH_VLAN':
            ret.append(parser.OFPActionPushVlan(action[1]))
        elif action[0] == 'POP_VLAN':
            ret.append(parser.OFPActionPopVlan())
        elif action[0] == 'PUSH_MPLS':
            ret.append(parser.OFPActionPushMpls(action[1]))
        elif action[0] == 'POP_MPLS':
            ret.append(parser.OFPActionPopMpls(action[1]))
        elif action[0] == 'SET_QUEUE':
            ret.append(parser.OFPActionSetQueue(action[1]))
        elif action[0] == 'GROUP':
            if isinstance(action[1], Group):
                group_id, extra = group_to_ryu(action[1], rule)
                ret.append(parser.OFPActionGroup(group_id))
                extra_messages += extra
            else:
                ret.append(parser.OFPActionGroup(action[1]))
        elif action[0] == 'SET_NW_TTL':
            ret.append(parser.OFPActionSetNwTtl(action[1]))
        elif action[0] == 'DEC_NW_TTL':
            ret.append(parser.OFPActionDecNwTtl())
        elif action[0] == 'SET_FIELD':
            set_field = {action[1][0].lower(): action[1][1]}
            ret.append(parser.OFPActionSetField(**set_field))
        elif action[0] == 'PUSH_PBB':
            ret.append(parser.OFPActionPushPbb(action[1]))
        elif action[0] == 'POP_PBB':
            ret.append(parser.OFPActionPopPbb())
        else:
            assert not "GGRR"
    return (ret, extra_messages)