@Override public Optional<MatchBuilder> process(@Nonnull TcpDstCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) { final MatchBuilder matchBuilder = data.getMatchBuilder(); final TcpMatchBuilder tcpMatchBuilder = data.getTcpMatchBuilder(); TcpDst tcpDst = source.getTcpDst(); PortNumber portNumber = tcpDst.getPort(); if (portNumber != null) { tcpMatchBuilder.setTcpDestinationPort(portNumber); matchBuilder.setLayer4Match(tcpMatchBuilder.build()); } return Optional.of(matchBuilder); } }
public static void addMatchDstTcpPort(MatchBuilder match, int portNum) { PortNumber port = new PortNumber(portNum); TcpMatchBuilder tcpMatch = new TcpMatchBuilder(); tcpMatch.setTcpDestinationPort(port); match.setLayer4Match(tcpMatch.build()); }
private Set<TcpMatch> createTcpMatches(TcpMatch tcpMatch, Set<Long> sPorts, Set<Long> dPorts) { Set<TcpMatch> tcpMatches = new HashSet<>(); if (!sPorts.isEmpty() && dPorts.isEmpty()) { for (Long srcPort : sPorts) { equalOrNotSetValidation(tcpMatch.getTcpSourcePort(), srcPort.longValue()); tcpMatches .add(new TcpMatchBuilder(tcpMatch).setTcpSourcePort(new PortNumber(srcPort.intValue())).build()); } } else if (sPorts.isEmpty() && !dPorts.isEmpty()) { for (Long dstPort : dPorts) { equalOrNotSetValidation(tcpMatch.getTcpDestinationPort(), dstPort.longValue()); tcpMatches.add(new TcpMatchBuilder(tcpMatch).setTcpDestinationPort(new PortNumber(dstPort.intValue())) .build()); } } else if (!sPorts.isEmpty() && !dPorts.isEmpty()) { for (Long srcPort : sPorts) { for (Long dstPort : dPorts) { equalOrNotSetValidation(tcpMatch.getTcpSourcePort(), srcPort.longValue()); equalOrNotSetValidation(tcpMatch.getTcpDestinationPort(), dstPort.longValue()); tcpMatches.add(new TcpMatchBuilder(tcpMatch).setTcpSourcePort(new PortNumber(srcPort.intValue())) .setTcpDestinationPort(new PortNumber(dstPort.intValue())) .build()); } } } return tcpMatches; }
private static Layer4Match Layer4MatchAsTcp(final Match sourceMatch) { TcpMatchBuilder tcpMatchBuilder = new TcpMatchBuilder(); Integer sourcePort = transportPort(sourceMatch, MatchType.TP_SRC); Integer destinationPort = transportPort(sourceMatch, MatchType.TP_DST); if (sourcePort != null) { tcpMatchBuilder.setTcpSourcePort(new PortNumber(sourcePort)); } if (destinationPort != null) { tcpMatchBuilder.setTcpDestinationPort(new PortNumber( destinationPort)); } if(sourcePort != null || destinationPort != null) { return tcpMatchBuilder.build(); } return null; }
/** * {@inheritDoc} */ @Override public void setMatch(MatchBuilder builder, IpVersion ver) { TcpMatchBuilder tmatch; VTNPortRange src = getSourcePort(); if (src == null) { tmatch = null; } else { tmatch = create((TcpMatchBuilder)null). setTcpSourcePort(src.getPortNumberFrom()); } VTNPortRange dst = getDestinationPort(); if (dst != null) { tmatch = create(tmatch). setTcpDestinationPort(dst.getPortNumberFrom()); } if (tmatch != null) { builder.setLayer4Match(tmatch.build()); } }
/** * Create Set Destination TCP Port Instruction * * @param ib Map InstructionBuilder without any instructions * @param tcpport Integer representing a source TCP port * @return ib Map InstructionBuilder with instructions */ public static InstructionBuilder createSetDstTCPPort(InstructionBuilder ib, PortNumber tcpport) { List<Action> actionList = new ArrayList<>(); ActionBuilder ab = new ActionBuilder(); SetFieldBuilder setFieldBuilder = new SetFieldBuilder(); // Build the Destination TCP Port PortNumber tcpdstport = new PortNumber(tcpport); TcpMatchBuilder tcpmatch = new TcpMatchBuilder(); tcpmatch.setTcpDestinationPort(tcpdstport); setFieldBuilder.setLayer4Match(tcpmatch.build()); ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build()); ab.setOrder(0); ab.setKey(new ActionKey(0)); actionList.add(ab.build()); ApplyActionsBuilder aab = new ApplyActionsBuilder(); aab.setAction(actionList); ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build()); return ib; }
/** * Create Set Destination TCP Port Instruction * * @param ib Map InstructionBuilder without any instructions * @param tcpport Integer representing a source TCP port * @return ib Map InstructionBuilder with instructions */ public static InstructionBuilder createSetDstTCPPort(InstructionBuilder ib, PortNumber tcpport) { List<Action> actionList = Lists.newArrayList(); ActionBuilder ab = new ActionBuilder(); SetFieldBuilder setFieldBuilder = new SetFieldBuilder(); // Build the Destination TCP Port PortNumber tcpdstport = new PortNumber(tcpport); TcpMatchBuilder tcpmatch = new TcpMatchBuilder(); tcpmatch.setTcpDestinationPort(tcpdstport); setFieldBuilder.setLayer4Match(tcpmatch.build()); ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build()); ab.setOrder(0); ab.setKey(new ActionKey(0)); actionList.add(ab.build()); ApplyActionsBuilder aab = new ApplyActionsBuilder(); aab.setAction(actionList); ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build()); return ib; }
/** * Create Destination TCP Port Match * * @param matchBuilder MatchBuilder Object without a match yet * @param tcpDstPort Integer representing a destination TCP port * @return matchBuilder Map MatchBuilder Object with a match */ public static MatchBuilder createSetDstTcpMatch(MatchBuilder matchBuilder, PortNumber tcpDstPort) { EthernetMatchBuilder ethType = new EthernetMatchBuilder(); EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(0x0800L)); ethType.setEthernetType(ethTypeBuilder.build()); matchBuilder.setEthernetMatch(ethType.build()); IpMatchBuilder ipmatch = new IpMatchBuilder(); ipmatch.setIpProtocol((short) 6); matchBuilder.setIpMatch(ipmatch.build()); TcpMatchBuilder tcpmatch = new TcpMatchBuilder(); tcpmatch.setTcpDestinationPort(tcpDstPort); matchBuilder.setLayer4Match(tcpmatch.build()); return matchBuilder; }
/** * Create Destination TCP Port Match * * @param matchBuilder MatchBuilder Object without a match yet * @param tcpDstPort Integer representing a destination TCP port * @return matchBuilder Map MatchBuilder Object with a match */ public static MatchBuilder createSetDstTcpMatch(MatchBuilder matchBuilder, PortNumber tcpDstPort) { EthernetMatchBuilder ethType = new EthernetMatchBuilder(); EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(IPV4_LONG)); ethType.setEthernetType(ethTypeBuilder.build()); matchBuilder.setEthernetMatch(ethType.build()); IpMatchBuilder ipmatch = new IpMatchBuilder(); ipmatch.setIpProtocol((short) 6); matchBuilder.setIpMatch(ipmatch.build()); TcpMatchBuilder tcpmatch = new TcpMatchBuilder(); tcpmatch.setTcpDestinationPort(tcpDstPort); matchBuilder.setLayer4Match(tcpmatch.build()); return matchBuilder; }
final TcpMatchBuilder tcpmatch1 = new TcpMatchBuilder(); tcpmatch.setTcpSourcePort(tcpsrcport); tcpmatch1.setTcpDestinationPort(tcpdstport); setFieldBuilder.setLayer4Match(tcpmatch.build()); ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
/** * Create Destination TCP Port Match * * @param matchBuilder MatchBuilder Object without a match yet * @param tcpDstPort Integer representing a destination TCP port * @return matchBuilder Map MatchBuilder Object with a match */ public static MatchBuilder createSetDstTcpMatch(MatchBuilder matchBuilder, PortNumber tcpDstPort) { EthernetMatchBuilder ethType = new EthernetMatchBuilder(); EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(IPV4_LONG)); ethType.setEthernetType(ethTypeBuilder.build()); matchBuilder.setEthernetMatch(ethType.build()); IpMatchBuilder ipmatch = new IpMatchBuilder(); ipmatch.setIpProtocol((short) 6); matchBuilder.setIpMatch(ipmatch.build()); TcpMatchBuilder tcpmatch = new TcpMatchBuilder(); tcpmatch.setTcpDestinationPort(tcpDstPort); matchBuilder.setLayer4Match(tcpmatch.build()); return matchBuilder; }
/** * @return */ private static MatchBuilder createL4TCPMatch() { final MatchBuilder match = new MatchBuilder(); final EthernetMatchBuilder eth = new EthernetMatchBuilder(); final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(0x0800L)); eth.setEthernetType(ethTypeBuilder.build()); match.setEthernetMatch(eth.build()); final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version ipmatch.setIpProtocol((short) 6); match.setIpMatch(ipmatch.build()); final PortNumber srcport = new PortNumber(1213); final PortNumber dstport = new PortNumber(646); final TcpMatchBuilder tcpmatch = new TcpMatchBuilder(); // tcp match tcpmatch.setTcpSourcePort(srcport); tcpmatch.setTcpDestinationPort(dstport); match.setLayer4Match(tcpmatch.build()); return match; }
tcpMatch.setTcpDestinationPort(dstPort); matchBuilder.setLayer4Match(tcpMatch.build());
tcpMatch.setTcpDestinationPort(dstPort); matchBuilder.setLayer4Match(tcpMatch.build());
tcpMatch.setTcpDestinationPort(dstPort); matchBuilder.setLayer4Match(tcpMatch.build());
tcpMatch.setTcpDestinationPort(dstPort); matchBuilder.setLayer4Match(tcpMatch.build());
tcpMatch.setTcpDestinationPort(dstPort); matchBuilder.setLayer4Match(tcpMatch.build());
tcpMatch.setTcpDestinationPort(dstPort); matchBuilder.setLayer4Match(tcpMatch.build());
tcpMatch.setTcpDestinationPort(dstPort); match.setLayer4Match(tcpMatch.build());
tcpMatch.setTcpDestinationPort(dstPort); matchBuilder.setLayer4Match(tcpMatch.build());