@Override public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) { final TcpPortCriterion tcpPortCriterion = (TcpPortCriterion) criterion; root.put(CriterionCodec.TCP_PORT, tcpPortCriterion.tcpPort().toInt()); root.put(CriterionCodec.TCP_MASK, tcpPortCriterion.mask().toInt()); return root; } }
@Override public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) { final UdpPortCriterion udpPortCriterion = (UdpPortCriterion) criterion; root.put(CriterionCodec.UDP_PORT, udpPortCriterion.udpPort().toInt()); root.put(CriterionCodec.UDP_MASK, udpPortCriterion.mask().toInt()); return root; } }
@Override public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) { final TcpPortCriterion tcpPortCriterion = (TcpPortCriterion) criterion; return root.put(CriterionCodec.TCP_PORT, tcpPortCriterion.tcpPort().toInt()); } }
@Override public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) { final SctpPortCriterion sctpPortCriterion = (SctpPortCriterion) criterion; return root.put(CriterionCodec.SCTP_PORT, sctpPortCriterion.sctpPort().toInt()); } }
@Override public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) { final UdpPortCriterion udpPortCriterion = (UdpPortCriterion) criterion; return root.put(CriterionCodec.UDP_PORT, udpPortCriterion.udpPort().toInt()); } }
@Override public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) { final SctpPortCriterion sctpPortCriterion = (SctpPortCriterion) criterion; root.put(CriterionCodec.SCTP_PORT, sctpPortCriterion.sctpPort().toInt()); root.put(CriterionCodec.SCTP_MASK, sctpPortCriterion.mask().toInt()); return root; } }
private void connectRetry(IpAddress ip, TpPort port, ChannelFutureListener listener) { try { Bootstrap b = new Bootstrap(); b.group(workerGroup) .channel(NioSocketChannel.class) .option(ChannelOption.TCP_NODELAY, true) .handler(new ChannelInitializer<SocketChannel>() { @Override protected void initChannel(SocketChannel channel) throws Exception { ChannelPipeline p = channel.pipeline(); p.addLast(new MessageDecoder(), new StringEncoder(CharsetUtil.UTF_8), new IdleStateHandler(IDLE_TIMEOUT_SEC, 0, 0), new ConnectionHandler()); } }); b.remoteAddress(ip.toString(), port.toInt()); b.connect().addListener(listener); } catch (Exception e) { log.warn("Connection to the ovsdb server {}:{} failed", ip.toString(), port.toString()); } }
/** * Encode a L4 modification instruction. * * @param result json node that the instruction attributes are added to */ private void encodeL4(ObjectNode result) { L4ModificationInstruction l4Instruction = (L4ModificationInstruction) instruction; result.put(InstructionCodec.SUBTYPE, l4Instruction.subtype().name()); switch (l4Instruction.subtype()) { case TCP_DST: case TCP_SRC: final L4ModificationInstruction.ModTransportPortInstruction modTcpPortInstruction = (L4ModificationInstruction.ModTransportPortInstruction) l4Instruction; result.put(InstructionCodec.TCP_PORT, modTcpPortInstruction.port().toInt()); break; case UDP_DST: case UDP_SRC: final L4ModificationInstruction.ModTransportPortInstruction modUdpPortInstruction = (L4ModificationInstruction.ModTransportPortInstruction) l4Instruction; result.put(InstructionCodec.UDP_PORT, modUdpPortInstruction.port().toInt()); break; default: log.info("Cannot convert L4 subtype of {}", l4Instruction.subtype()); break; } }
@Override public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { UdpPortCriterion c = (UdpPortCriterion) criterion; ImmutableByteSequence value = copyFrom(c.udpPort().toInt()); if (c.mask() == null) { initAsExactMatch(value, bitWidth); } else { ImmutableByteSequence mask = copyFrom(c.mask().toInt()); initAsTernaryMatch(value, mask, bitWidth); } } }
@Override public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { SctpPortCriterion c = (SctpPortCriterion) criterion; ImmutableByteSequence value = copyFrom(c.sctpPort().toInt()); if (c.mask() == null) { initAsExactMatch(value, bitWidth); } else { ImmutableByteSequence mask = copyFrom(c.mask().toInt()); initAsTernaryMatch(value, mask, bitWidth); } } }
@Override public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { TcpPortCriterion c = (TcpPortCriterion) criterion; ImmutableByteSequence value = copyFrom(c.tcpPort().toInt()); if (c.mask() == null) { initAsExactMatch(value, bitWidth); } else { ImmutableByteSequence mask = copyFrom(c.mask().toInt()); initAsTernaryMatch(value, mask, bitWidth); } } }
initConnection(); isisChannelHandler.sentConfigPacket(configPacket); InetSocketAddress connectToSocket = new InetSocketAddress(IsisConstants.SHOST, isisPort.toInt()); try { peerBootstrap.connect(connectToSocket).addListener(new ChannelFutureListener() {
initConnection(); ospfChannelHandler.sentConfigPacket(configPacket); InetSocketAddress connectToSocket = new InetSocketAddress(OspfUtil.SHOST, isisPort.toInt()); try { peerBootstrap.connect(connectToSocket).addListener(new ChannelFutureListener() {
initConnection(); isisChannelHandler.sentConfigPacket(configPacket); InetSocketAddress connectToSocket = new InetSocketAddress(IsisConstants.SHOST, isisPort.toInt()); try { peerBootstrap.connect(connectToSocket).addListener(new ChannelFutureListener() {
private OFAction buildL4Modification(Instruction i) { L4ModificationInstruction l4m = (L4ModificationInstruction) i; ModTransportPortInstruction tp; OFOxm<?> oxm = null; switch (l4m.subtype()) { case TCP_SRC: tp = (ModTransportPortInstruction) l4m; oxm = factory().oxms().tcpSrc(TransportPort.of(tp.port().toInt())); break; case TCP_DST: tp = (ModTransportPortInstruction) l4m; oxm = factory().oxms().tcpDst(TransportPort.of(tp.port().toInt())); break; case UDP_SRC: tp = (ModTransportPortInstruction) l4m; oxm = factory().oxms().udpSrc(TransportPort.of(tp.port().toInt())); break; case UDP_DST: tp = (ModTransportPortInstruction) l4m; oxm = factory().oxms().udpDst(TransportPort.of(tp.port().toInt())); break; default: log.warn("Unimplemented action type {}.", l4m.subtype()); break; } if (oxm != null) { return factory().actions().buildSetField().setField(oxm).build(); } return null; }
private Collection<FlowRule> processVersatile(ForwardingObjective forwardingObjective) { log.debug("Processing versatile forwarding objective"); FlowRule.Builder ruleBuilder = DefaultFlowRule.builder() .forDevice(deviceId) .withSelector(forwardingObjective.selector()) .withTreatment(forwardingObjective.treatment()) .withPriority(forwardingObjective.priority()) .fromApp(forwardingObjective.appId()); if (forwardingObjective.permanent()) { ruleBuilder.makePermanent(); } else { ruleBuilder.makeTemporary(TIME_OUT); } //ARP & DHCP Rule EthTypeCriterion ethCriterion = (EthTypeCriterion) forwardingObjective.selector().getCriterion(Criterion.Type.ETH_TYPE); UdpPortCriterion udpPortCriterion = (UdpPortCriterion) forwardingObjective .selector().getCriterion(Criterion.Type.UDP_DST); if (ethCriterion != null) { if (ethCriterion.ethType().toShort() == Ethernet.TYPE_ARP || ethCriterion.ethType().toShort() == Ethernet.TYPE_LLDP) { ruleBuilder.forTable(VNI_TABLE); return Collections.singletonList(ruleBuilder.build()); } else if (udpPortCriterion != null && udpPortCriterion.udpPort().toInt() == DHCP_SERVER_PORT) { ruleBuilder.forTable(VNI_TABLE); return Collections.singletonList(ruleBuilder.build()); } } return Collections.emptySet(); }
tcpPortCriterion = (TcpPortCriterion) c; mBuilder.setExact(MatchField.TCP_SRC, TransportPort.of(tcpPortCriterion.tcpPort().toInt())); break; case TCP_DST: tcpPortCriterion = (TcpPortCriterion) c; mBuilder.setExact(MatchField.TCP_DST, TransportPort.of(tcpPortCriterion.tcpPort().toInt())); break; case UDP_SRC: udpPortCriterion = (UdpPortCriterion) c; mBuilder.setExact(MatchField.UDP_SRC, TransportPort.of(udpPortCriterion.udpPort().toInt())); break; case UDP_DST: udpPortCriterion = (UdpPortCriterion) c; mBuilder.setExact(MatchField.UDP_DST, TransportPort.of(udpPortCriterion.udpPort().toInt())); break; case SCTP_SRC: sctpPortCriterion = (SctpPortCriterion) c; mBuilder.setExact(MatchField.SCTP_SRC, TransportPort.of(sctpPortCriterion.sctpPort().toInt())); break; case SCTP_DST: sctpPortCriterion = (SctpPortCriterion) c; mBuilder.setExact(MatchField.SCTP_DST, TransportPort.of(sctpPortCriterion.sctpPort().toInt())); break;