Examples of OFMessage


Examples of org.flowforwarding.warp.protocol.ofp.avro.OFMessage

         case STARTED:
            ByteString in = ((Received) msg).data();
            provider = factory.getMessageProvider(in.toArray());

            builder = new org.flowforwarding.warp.protocol.ofp.avro.OFMessage.OFMessageBuilder(in.toArray());           
            OFMessage inMsg = builder.value(in.toArray()).build();

            if ((provider != null) && (inMsg != null)) {
                if (inMsg.type().equals("OFPT_HELLO")) {
                  log.info ("IN: Hello");
                    swRef.setVersion(builder.version());
//                    getSender().tell(TcpMessage.write(ByteString.fromArray(builder.type("ofp_hello").set("header.xid", "0xabba").build().binary())), getSelf());
                    OFMessage helloMsg = builder.type("ofp_hello").build();
                    byte[] v = {127,127,127,127};
                    helloMsg.get("header").get("xid").set(v);

                    //getSender().tell(TcpMessage.write(ByteString.fromArray(builder.type("ofp_hello").build().binary())), getSelf());
                    getSender().tell(TcpMessage.write(ByteString.fromArray(helloMsg.binary())), getSelf());
                    this.state = State.CONNECTED;
                    log.info ("STATE: Connected to OF Switch version "+ builder.version());
//                    getSender().tell(TcpMessage.write(ByteString.fromArray(builder.type("ofp_switch_features_request").set("xid", "0xabba").build().binary())), getSelf());
                    getSender().tell(TcpMessage.write(ByteString.fromArray(builder.type("ofp_switch_features_request").build().binary())), getSelf());

                    // TODO REMOVE THIS:
                    provider.init();
                    tcpChannel = getSender();
                }
            }
           
            break;
         case CONNECTED:  
            in = ((Received) msg).data();
            inMsg = builder.value(in.toArray()).build();
          
            if (inMsg.type().equals("OFPT_FEATURES_REPLY")) {
               log.info("IN: Features Reply");
               byte[] DPID = inMsg.field("datapath_id");
               swRef.setDpid(Convert.toLong(DPID));
               log.info("INFO: Switch DPID is " + Long.toHexString(Convert.toLong(DPID)).toUpperCase());
            
               state = State.HANDSHAKED;
               ofSessionHandler.tell(new OFEventHandshaked(swRef), getSelf());

               getSender().tell(TcpMessage.write(ByteString.fromArray(builder.type("ofp_get_config_request").build().binary())), getSelf());
            }
           
            break;
           
         case HANDSHAKED:
            in = ((Received) msg).data();
            inMsg = builder.value(in.toArray()).build();
           
            if (inMsg.type().equals("OFPT_GET_CONFIG_REPLY")) {
               log.info("IN: Config Reply from Switch " + Long.toHexString(swRef.getDpid().longValue()));
              
               OFMessage flowMod = builder.type("ofp_flow_mod").build();
/*               OFItemRef matchInPort = itemBuilder.type("oxm_tlv_ingress_port").build();
               matchInPort.set("tlv", "4");
               OFItemRef tlv = itemBuilder.type("oxm_tlv").build();
               tlv.add("match", matchInPort);
              
View Full Code Here

Examples of org.openflow.protocol.OFMessage

     */
    public void clearFlowMods(IOFSwitch sw, Short outPort) {
        // Delete all pre-existing flows with the same output action port or
        // outPort
        OFMatch match = new OFMatch().setWildcards(OFMatch.OFPFW_ALL);
        OFMessage fm = ((OFFlowMod) floodlightProvider.getOFMessageFactory()
                                                      .getMessage(OFType.FLOW_MOD)).setMatch(match)
                                                                                   .setCommand(OFFlowMod.OFPFC_DELETE)
                                                                                   .setOutPort(outPort)
                                                                                   .setLength(U16.t(OFFlowMod.MINIMUM_LENGTH));
        try {
View Full Code Here

Examples of org.openflow.protocol.OFMessage

     */
    public void clearFlowMods(IOFSwitch sw, OFMatch match, Short outPort) {
        // Delete pre-existing flows with the same match, and output action port
        // or outPort
        match.setWildcards(OFMatch.OFPFW_ALL);
        OFMessage fm = ((OFFlowMod) floodlightProvider.getOFMessageFactory()
                                                      .getMessage(OFType.FLOW_MOD)).setMatch(match)
                                                                                   .setCommand(OFFlowMod.OFPFC_DELETE)
                                                                                   .setOutPort(outPort)
                                                                                   .setLength(U16.t(OFFlowMod.MINIMUM_LENGTH));
        try {
View Full Code Here

Examples of org.openflow.protocol.OFMessage

        if (channel == null || !isConnected())
            return;
        // Delete all pre-existing flows
        log.info("Clearing all flows on switch {}", this);
        OFMatch match = new OFMatch().setWildcards(OFMatch.OFPFW_ALL);
        OFMessage fm = ((OFFlowMod) floodlightProvider.getOFMessageFactory()
            .getMessage(OFType.FLOW_MOD))
                .setMatch(match)
            .setCommand(OFFlowMod.OFPFC_DELETE)
            .setOutPort(OFPort.OFPP_NONE)
            .setLength(U16.t(OFFlowMod.MINIMUM_LENGTH));
        fm.setXid(getNextTransactionId());
        OFMessage barrierMsg = floodlightProvider.getOFMessageFactory().getMessage(
                OFType.BARRIER_REQUEST);
        barrierMsg.setXid(getNextTransactionId());
        List<OFMessage> msglist = new ArrayList<OFMessage>(2);
        msglist.add(fm);
        msglist.add(barrierMsg);
        channel.write(msglist);
    }
View Full Code Here

Examples of org.openflow.protocol.OFMessage

    }

    @Override
    public Future<OFFeaturesReply> querySwitchFeaturesReply()
            throws IOException {
        OFMessage request =
                floodlightProvider.getOFMessageFactory().
                    getMessage(OFType.FEATURES_REQUEST);
        request.setXid(getNextTransactionId());
        OFFeaturesReplyFuture future =
                new OFFeaturesReplyFuture(threadPool, this, request.getXid());
        this.featuresFutureMap.put(request.getXid(), future);
        List<OFMessage> msglist = new ArrayList<OFMessage>(1);
        msglist.add(request);
        this.write(msglist);
        return future;
    }
View Full Code Here

Examples of org.openflow.protocol.OFMessage

    }

    @Override
    public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e)
            throws Exception {
        OFMessage m = BasicFactory.getInstance().getMessage(OFType.ECHO_REQUEST);
        e.getChannel().write(Collections.singletonList(m));
    }
View Full Code Here

Examples of org.openflow.protocol.OFMessage

     * Send a message to the switch using the handshake transactions ids.
     * @throws IOException
     */
    private void sendHandShakeMessage(OFType type) throws IOException {
        // Send initial Features Request
        OFMessage m = BasicFactory.getInstance().getMessage(type);
        m.setXid(handshakeTransactionIds--);
        channel.write(Collections.singletonList(m));
    }
View Full Code Here

Examples of org.openflow.protocol.OFMessage

        // Verify the replay matched our expectations
        verify(mockSwitch);
       
        assertTrue(wc1.hasCaptured());
        OFMessage m = wc1.getValue();
        assertEquals(po, m);
    }
View Full Code Here

Examples of org.openflow.protocol.OFMessage

        // Verify the replay matched our expectations
        verify(mockSwitch);
       
        assertTrue(wc1.hasCaptured());
        OFMessage m = wc1.getValue();
        assertEquals(po, m);
    }
View Full Code Here

Examples of org.openflow.protocol.OFMessage

        assertEquals(Role.SLAVE, sw.getHARole());
    }

    @Test
    public void testSubHandshake() {
        OFMessage m = BasicFactory.getInstance().getMessage(OFType.VENDOR);
        // test execptions before handshake is started
        try {
            sw.processDriverHandshakeMessage(m);
            fail("expected exception not thrown");
        } catch (SwitchDriverSubHandshakeNotStarted e) { /* expected */ }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.