@Override public Criterion decodeCriterion(ObjectNode json) { TpPort udpPort = TpPort.tpPort(nullIsIllegal(json.get(CriterionCodec.UDP_PORT), CriterionCodec.UDP_PORT + MISSING_MEMBER_MESSAGE).asInt()); TpPort udpMask = TpPort.tpPort(nullIsIllegal(json.get(CriterionCodec.UDP_MASK), CriterionCodec.UDP_MASK + MISSING_MEMBER_MESSAGE).asInt()); return Criteria.matchUdpSrcMasked(udpPort, udpMask); } }
@Override public Criterion decodeCriterion(ObjectNode json) { TpPort tcpPort = TpPort.tpPort(nullIsIllegal(json.get(CriterionCodec.TCP_PORT), CriterionCodec.TCP_PORT + MISSING_MEMBER_MESSAGE).asInt()); TpPort tcpMask = TpPort.tpPort(nullIsIllegal(json.get(CriterionCodec.TCP_MASK), CriterionCodec.TCP_MASK + MISSING_MEMBER_MESSAGE).asInt()); return Criteria.matchTcpSrcMasked(tcpPort, tcpMask); } }
@Override public Criterion decodeCriterion(ObjectNode json) { TpPort tcpPort = TpPort.tpPort(nullIsIllegal(json.get(CriterionCodec.TCP_PORT), CriterionCodec.TCP_PORT + MISSING_MEMBER_MESSAGE).asInt()); TpPort tcpMask = TpPort.tpPort(nullIsIllegal(json.get(CriterionCodec.TCP_MASK), CriterionCodec.TCP_MASK + MISSING_MEMBER_MESSAGE).asInt()); return Criteria.matchTcpDstMasked(tcpPort, tcpMask); } }
@Override public Criterion decodeCriterion(ObjectNode json) { TpPort udpPort = TpPort.tpPort(nullIsIllegal(json.get(CriterionCodec.UDP_PORT), CriterionCodec.UDP_PORT + MISSING_MEMBER_MESSAGE).asInt()); TpPort udpMask = TpPort.tpPort(nullIsIllegal(json.get(CriterionCodec.UDP_MASK), CriterionCodec.UDP_MASK + MISSING_MEMBER_MESSAGE).asInt()); return Criteria.matchUdpDstMasked(udpPort, udpMask); } }
@Override public Criterion decodeCriterion(ObjectNode json) { TpPort sctpPort = TpPort.tpPort(nullIsIllegal(json.get(CriterionCodec.SCTP_PORT), CriterionCodec.SCTP_PORT + MISSING_MEMBER_MESSAGE).asInt()); TpPort sctpMask = TpPort.tpPort(nullIsIllegal(json.get(CriterionCodec.SCTP_MASK), CriterionCodec.SCTP_MASK + MISSING_MEMBER_MESSAGE).asInt()); return Criteria.matchSctpSrcMasked(sctpPort, sctpMask); } }
@Override public Criterion decodeCriterion(ObjectNode json) { TpPort sctpPort = TpPort.tpPort(nullIsIllegal(json.get(CriterionCodec.SCTP_PORT), CriterionCodec.SCTP_PORT + MISSING_MEMBER_MESSAGE).asInt()); TpPort sctpMask = TpPort.tpPort(nullIsIllegal(json.get(CriterionCodec.SCTP_MASK), CriterionCodec.SCTP_MASK + MISSING_MEMBER_MESSAGE).asInt()); return Criteria.matchSctpDstMasked(sctpPort, sctpMask); } }
@Override public Criterion decodeCriterion(ObjectNode json) { TpPort tcpPort = TpPort.tpPort(nullIsIllegal(json.get(CriterionCodec.TCP_PORT), CriterionCodec.TCP_PORT + MISSING_MEMBER_MESSAGE).asInt()); return Criteria.matchTcpSrc(tcpPort); } }
@Override public Criterion decodeCriterion(ObjectNode json) { TpPort sctpPort = TpPort.tpPort(nullIsIllegal(json.get(CriterionCodec.SCTP_PORT), CriterionCodec.SCTP_PORT + MISSING_MEMBER_MESSAGE).asInt()); return Criteria.matchSctpSrc(sctpPort); } }
@Override public Criterion decodeCriterion(ObjectNode json) { TpPort sctpPort = TpPort.tpPort(nullIsIllegal(json.get(CriterionCodec.SCTP_PORT), CriterionCodec.SCTP_PORT + MISSING_MEMBER_MESSAGE).asInt()); return Criteria.matchSctpDst(sctpPort); } }
@Override public Criterion decodeCriterion(ObjectNode json) { TpPort tcpPort = TpPort.tpPort(nullIsIllegal(json.get(CriterionCodec.TCP_PORT), CriterionCodec.TCP_PORT + MISSING_MEMBER_MESSAGE).asInt()); return Criteria.matchTcpDst(tcpPort); } }
@Override public Criterion decodeCriterion(ObjectNode json) { TpPort udpPort = TpPort.tpPort(nullIsIllegal(json.get(CriterionCodec.UDP_PORT), CriterionCodec.UDP_PORT + MISSING_MEMBER_MESSAGE).asInt()); return Criteria.matchUdpSrc(udpPort); } }
@Override public Criterion decodeCriterion(ObjectNode json) { TpPort udpPort = TpPort.tpPort(nullIsIllegal(json.get(CriterionCodec.UDP_PORT), CriterionCodec.UDP_PORT + MISSING_MEMBER_MESSAGE).asInt()); return Criteria.matchUdpDst(udpPort); } }
private void buildMatchPort(TrafficSelector.Builder sBuilder, String protocol, OpenstackSecurityGroupRule.Direction direction, int portMin, int portMax) { if (portMin > 0 && portMax > 0 && portMin == portMax) { if (protocol.toUpperCase().equals(PROTO_TCP)) { if (direction.equals(OpenstackSecurityGroupRule.Direction.EGRESS)) { sBuilder.matchTcpDst(TpPort.tpPort(portMax)); } else { sBuilder.matchTcpSrc(TpPort.tpPort(portMax)); } } else if (protocol.toUpperCase().equals(PROTO_UDP)) { if (direction.equals(OpenstackSecurityGroupRule.Direction.EGRESS)) { sBuilder.matchUdpDst(TpPort.tpPort(portMax)); } else { sBuilder.matchUdpSrc(TpPort.tpPort(portMax)); } } } } }
/** * Decodes a Layer 4 instruction. * * @return instruction object decoded from the JSON * @throws IllegalArgumentException if the JSON is invalid */ private Instruction decodeL4() { String subType = nullIsIllegal(json.get(InstructionCodec.SUBTYPE), InstructionCodec.SUBTYPE + InstructionCodec.ERROR_MESSAGE).asText(); if (subType.equals(L4ModificationInstruction.L4SubType.TCP_DST.name())) { TpPort tcpPort = TpPort.tpPort(nullIsIllegal(json.get(InstructionCodec.TCP_PORT), InstructionCodec.TCP_PORT + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt()); return Instructions.modTcpDst(tcpPort); } else if (subType.equals(L4ModificationInstruction.L4SubType.TCP_SRC.name())) { TpPort tcpPort = TpPort.tpPort(nullIsIllegal(json.get(InstructionCodec.TCP_PORT), InstructionCodec.TCP_PORT + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt()); return Instructions.modTcpSrc(tcpPort); } else if (subType.equals(L4ModificationInstruction.L4SubType.UDP_DST.name())) { TpPort udpPort = TpPort.tpPort(nullIsIllegal(json.get(InstructionCodec.UDP_PORT), InstructionCodec.UDP_PORT + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt()); return Instructions.modUdpDst(udpPort); } else if (subType.equals(L4ModificationInstruction.L4SubType.UDP_SRC.name())) { TpPort udpPort = TpPort.tpPort(nullIsIllegal(json.get(InstructionCodec.UDP_PORT), InstructionCodec.UDP_PORT + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt()); return Instructions.modUdpSrc(udpPort); } throw new IllegalArgumentException("L4 Instruction subtype " + subType + " is not supported"); }
@SuppressWarnings("unchecked") OFOxm<TransportPort> tcpdst = (OFOxm<TransportPort>) oxm; builder.setTcpDst(TpPort.tpPort(tcpdst.getValue().getPort())); break; case TCP_SRC: @SuppressWarnings("unchecked") OFOxm<TransportPort> tcpsrc = (OFOxm<TransportPort>) oxm; builder.setTcpSrc(TpPort.tpPort(tcpsrc.getValue().getPort())); break; case UDP_DST: @SuppressWarnings("unchecked") OFOxm<TransportPort> udpdst = (OFOxm<TransportPort>) oxm; builder.setUdpDst(TpPort.tpPort(udpdst.getValue().getPort())); break; case UDP_SRC: @SuppressWarnings("unchecked") OFOxm<TransportPort> udpsrc = (OFOxm<TransportPort>) oxm; builder.setUdpSrc(TpPort.tpPort(udpsrc.getValue().getPort())); break; case TUNNEL_IPV4_DST:
selector.matchEthType(Ethernet.TYPE_IPV4) .matchIPProtocol(IPv4.PROTOCOL_TCP) .matchTcpSrc(TpPort.tpPort(BGP_PORT)); treatment.punt(); rule = DefaultFlowRule.builder() selector.matchEthType(Ethernet.TYPE_IPV4) .matchIPProtocol(IPv4.PROTOCOL_TCP) .matchTcpDst(TpPort.tpPort(BGP_PORT)); treatment.punt(); rule = DefaultFlowRule.builder()
break; case TCP_SRC: builder.matchTcpSrc(TpPort.tpPort(match.get(MatchField.TCP_SRC).getPort())); break; case TCP_DST: builder.matchTcpDst(TpPort.tpPort(match.get(MatchField.TCP_DST).getPort())); break; case UDP_SRC: builder.matchUdpSrc(TpPort.tpPort(match.get(MatchField.UDP_SRC).getPort())); break; case UDP_DST: builder.matchUdpDst(TpPort.tpPort(match.get(MatchField.UDP_DST).getPort())); break; case MPLS_LABEL: break; case SCTP_SRC: builder.matchSctpSrc(TpPort.tpPort(match.get(MatchField.SCTP_SRC).getPort())); break; case SCTP_DST: builder.matchSctpDst(TpPort.tpPort(match.get(MatchField.SCTP_DST).getPort())); break; case ICMPV4_TYPE: