Search in sources :

Example 1 with ActionSetUdpDestinationPort

use of org.opendaylight.genius.mdsalutil.actions.ActionSetUdpDestinationPort in project netvirt by opendaylight.

the class NaptEventHandler method buildAndGetSetActionInstructionInfo.

private static List<InstructionInfo> buildAndGetSetActionInstructionInfo(String ipAddress, int port, long segmentId, long vpnId, short tableId, NAPTEntryEvent.Protocol protocol, String extGwMacAddress) {
    ActionInfo ipActionInfo = null;
    ActionInfo macActionInfo = null;
    ActionInfo portActionInfo = null;
    ArrayList<ActionInfo> listActionInfo = new ArrayList<>();
    ArrayList<InstructionInfo> instructionInfo = new ArrayList<>();
    switch(tableId) {
        case NwConstants.OUTBOUND_NAPT_TABLE:
            ipActionInfo = new ActionSetSourceIp(ipAddress);
            // Added External Gateway MAC Address
            macActionInfo = new ActionSetFieldEthernetSource(new MacAddress(extGwMacAddress));
            if (protocol == NAPTEntryEvent.Protocol.TCP) {
                portActionInfo = new ActionSetTcpSourcePort(port);
            } else if (protocol == NAPTEntryEvent.Protocol.UDP) {
                portActionInfo = new ActionSetUdpSourcePort(port);
            }
            // reset the split-horizon bit to allow traffic from tunnel to be sent back to the provider port
            instructionInfo.add(new InstructionWriteMetadata(MetaDataUtil.getVpnIdMetadata(vpnId), MetaDataUtil.METADATA_MASK_VRFID.or(MetaDataUtil.METADATA_MASK_SH_FLAG)));
            break;
        case NwConstants.INBOUND_NAPT_TABLE:
            ipActionInfo = new ActionSetDestinationIp(ipAddress);
            if (protocol == NAPTEntryEvent.Protocol.TCP) {
                portActionInfo = new ActionSetTcpDestinationPort(port);
            } else if (protocol == NAPTEntryEvent.Protocol.UDP) {
                portActionInfo = new ActionSetUdpDestinationPort(port);
            }
            instructionInfo.add(new InstructionWriteMetadata(MetaDataUtil.getVpnIdMetadata(segmentId), MetaDataUtil.METADATA_MASK_VRFID));
            break;
        default:
            LOG.error("buildAndGetSetActionInstructionInfo : Neither OUTBOUND_NAPT_TABLE nor " + "INBOUND_NAPT_TABLE matches with input table id {}", tableId);
            return null;
    }
    listActionInfo.add(ipActionInfo);
    listActionInfo.add(portActionInfo);
    if (macActionInfo != null) {
        listActionInfo.add(macActionInfo);
        LOG.debug("buildAndGetSetActionInstructionInfo : External GW MAC Address {} is found  ", macActionInfo);
    }
    instructionInfo.add(new InstructionApplyActions(listActionInfo));
    instructionInfo.add(new InstructionGotoTable(NwConstants.NAPT_PFIB_TABLE));
    return instructionInfo;
}
Also used : ActionSetUdpSourcePort(org.opendaylight.genius.mdsalutil.actions.ActionSetUdpSourcePort) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) ArrayList(java.util.ArrayList) ActionSetSourceIp(org.opendaylight.genius.mdsalutil.actions.ActionSetSourceIp) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ActionSetTcpSourcePort(org.opendaylight.genius.mdsalutil.actions.ActionSetTcpSourcePort) ActionSetFieldEthernetSource(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetSource) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ActionSetUdpDestinationPort(org.opendaylight.genius.mdsalutil.actions.ActionSetUdpDestinationPort) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata) ActionSetDestinationIp(org.opendaylight.genius.mdsalutil.actions.ActionSetDestinationIp) ActionSetTcpDestinationPort(org.opendaylight.genius.mdsalutil.actions.ActionSetTcpDestinationPort) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Aggregations

ArrayList (java.util.ArrayList)1 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)1 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)1 ActionSetDestinationIp (org.opendaylight.genius.mdsalutil.actions.ActionSetDestinationIp)1 ActionSetFieldEthernetSource (org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetSource)1 ActionSetSourceIp (org.opendaylight.genius.mdsalutil.actions.ActionSetSourceIp)1 ActionSetTcpDestinationPort (org.opendaylight.genius.mdsalutil.actions.ActionSetTcpDestinationPort)1 ActionSetTcpSourcePort (org.opendaylight.genius.mdsalutil.actions.ActionSetTcpSourcePort)1 ActionSetUdpDestinationPort (org.opendaylight.genius.mdsalutil.actions.ActionSetUdpDestinationPort)1 ActionSetUdpSourcePort (org.opendaylight.genius.mdsalutil.actions.ActionSetUdpSourcePort)1 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)1 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)1 InstructionWriteMetadata (org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata)1 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)1