use of org.opendaylight.genius.mdsalutil.actions.ActionSetTcpDestinationPort 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;
}
Aggregations