java类org.projectfloodlight.openflow.protocol.OFPacketIn的实例源码

PacketFactory.java 文件源码 项目:open-kilda 阅读 27 收藏 0 点赞 0 评论 0
/**
 * Generates a DHCP request OFPacketIn.
 * @param hostMac The host MAC address of for the request.
 * @return An OFPacketIn that contains a DHCP request packet.
 */
public static OFPacketIn DhcpDiscoveryRequestOFPacketIn(IOFSwitch sw,
        MacAddress hostMac) {
    byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
    OFFactory factory = sw.getOFFactory();
    OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
    if (factory.getVersion() == OFVersion.OF_10) {
        packetInBuilder
            .setInPort(OFPort.of(1))
            .setData(serializedPacket)
            .setReason(OFPacketInReason.NO_MATCH);
    } else {
        packetInBuilder
        .setMatch(factory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build())
        .setData(serializedPacket)
        .setReason(OFPacketInReason.NO_MATCH);
    }
    return packetInBuilder.build();
}
MockFloodlightProvider.java 文件源码 项目:open-kilda 阅读 31 收藏 0 点赞 0 评论 0
public void dispatchMessage(IOFSwitch sw, OFMessage msg, FloodlightContext bc) {
      List<IOFMessageListener> theListeners = listeners.get(msg.getType()).getOrderedListeners();
      if (theListeners != null) {
          Command result = Command.CONTINUE;
          Iterator<IOFMessageListener> it = theListeners.iterator();
          if (OFType.PACKET_IN.equals(msg.getType())) {
              OFPacketIn pi = (OFPacketIn)msg;
              Ethernet eth = new Ethernet();
              eth.deserialize(pi.getData(), 0, pi.getData().length);
              IFloodlightProviderService.bcStore.put(bc,
                      IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
                      eth);
          }
          while (it.hasNext() && !Command.STOP.equals(result)) {
              result = it.next().receive(sw, msg, bc);
          }
      }
// paag
      for (IControllerCompletionListener listener:completionListeners)
        listener.onMessageConsumed(sw, msg, bc);
  }
PacketFactory.java 文件源码 项目:iTAP-controller 阅读 27 收藏 0 点赞 0 评论 0
/**
 * Generates a DHCP request OFPacketIn.
 * @param hostMac The host MAC address of for the request.
 * @return An OFPacketIn that contains a DHCP request packet.
 */
public static OFPacketIn DhcpDiscoveryRequestOFPacketIn(IOFSwitch sw,
        MacAddress hostMac) {
    byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
    OFFactory factory = sw.getOFFactory();
    OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
    if (factory.getVersion() == OFVersion.OF_10) {
        packetInBuilder
            .setInPort(OFPort.of(1))
            .setData(serializedPacket)
            .setReason(OFPacketInReason.NO_MATCH);
    } else {
        packetInBuilder
        .setMatch(factory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build())
        .setData(serializedPacket)
        .setReason(OFPacketInReason.NO_MATCH);
    }
    return packetInBuilder.build();
}
Hub.java 文件源码 项目:fresco_floodlight 阅读 35 收藏 0 点赞 0 评论 0
private OFMessage createHubPacketOut(IOFSwitch sw, OFMessage msg) {
    OFPacketIn pi = (OFPacketIn) msg;
    OFPacketOut.Builder pob = sw.getOFFactory().buildPacketOut();
    pob.setBufferId(pi.getBufferId()).setXid(pi.getXid()).setInPort((pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)));

    // set actions
    OFActionOutput.Builder actionBuilder = sw.getOFFactory().actions().buildOutput();
    actionBuilder.setPort(OFPort.FLOOD);
    pob.setActions(Collections.singletonList((OFAction) actionBuilder.build()));

    // set data if it is included in the packetin
    if (pi.getBufferId() == OFBufferId.NO_BUFFER) {
        byte[] packetData = pi.getData();
        pob.setData(packetData);
    }
    return pob.build();  
}
LinkDiscoveryManagerTest.java 文件源码 项目:iTAP-controller 阅读 36 收藏 0 点赞 0 评论 0
private OFPacketIn createPacketIn(String srcMAC, String dstMAC,
                                  String srcIp, String dstIp, short vlan) {
    IPacket testPacket = new Ethernet()
    .setDestinationMACAddress(dstMAC)
    .setSourceMACAddress(srcMAC)
    .setVlanID(vlan)
    .setEtherType(EthType.IPv4)
    .setPayload(
            new IPv4()
            .setTtl((byte) 128)
            .setSourceAddress(srcIp)
            .setDestinationAddress(dstIp)
            .setPayload(new UDP()
            .setSourcePort((short) 5000)
            .setDestinationPort((short) 5001)
            .setPayload(new Data(new byte[] {0x01}))));
    byte[] testPacketSerialized = testPacket.serialize();
    OFPacketIn pi;
    // build out input packet
    pi = OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
            .setBufferId(OFBufferId.NO_BUFFER)
            .setData(testPacketSerialized)
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    return pi;
}
TopologyManager.java 文件源码 项目:fresco_floodlight 阅读 34 收藏 0 点赞 0 评论 0
/**
 * If the packet-in switch port is disabled for all data traffic, then
 * the packet will be dropped.  Otherwise, the packet will follow the
 * normal processing chain.
 * @param sw
 * @param pi
 * @param cntx
 * @return
 */
protected Command dropFilter(DatapathId sw, OFPacketIn pi,
        FloodlightContext cntx) {
    Command result = Command.CONTINUE;
    OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT));

    // If the input port is not allowed for data traffic, drop everything.
    // BDDP packets will not reach this stage.
    if (isAllowed(sw, inPort) == false) {
        if (log.isTraceEnabled()) {
            log.trace("Ignoring packet because of topology " +
                    "restriction on switch={}, port={}", sw.getLong(), inPort.getPortNumber());
            result = Command.STOP;
        }
    }
    return result;
}
TopologyManager.java 文件源码 项目:fresco_floodlight 阅读 36 收藏 0 点赞 0 评论 0
protected Command processPacketInMessage(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
    // get the packet-in switch.
    Ethernet eth =
            IFloodlightProviderService.bcStore.
            get(cntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);

    if (eth.getPayload() instanceof BSN) {
        BSN bsn = (BSN) eth.getPayload();
        if (bsn == null) return Command.STOP;
        if (bsn.getPayload() == null) return Command.STOP;

        // It could be a packet other than BSN LLDP, therefore
        // continue with the regular processing.
        if (bsn.getPayload() instanceof LLDP == false)
            return Command.CONTINUE;

        doFloodBDDP(sw.getId(), pi, cntx);
        return Command.STOP;
    } else {
        return dropFilter(sw.getId(), pi, cntx);
    }
}
Firewall.java 文件源码 项目:fresco_floodlight 阅读 36 收藏 0 点赞 0 评论 0
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    if (!this.enabled) {
        return Command.CONTINUE;
    }

    switch (msg.getType()) {
    case PACKET_IN:
        IRoutingDecision decision = null;
        if (cntx != null) {
            decision = IRoutingDecision.rtStore.get(cntx, IRoutingDecision.CONTEXT_DECISION);
            return this.processPacketInMessage(sw, (OFPacketIn) msg, decision, cntx);
        }
        break;
    default:
        break;
    }

    return Command.CONTINUE;
}
MockFloodlightProvider.java 文件源码 项目:iTAP-controller 阅读 68 收藏 0 点赞 0 评论 0
public void dispatchMessage(IOFSwitch sw, OFMessage msg, FloodlightContext bc) {
    List<IOFMessageListener> theListeners = listeners.get(msg.getType()).getOrderedListeners();
    if (theListeners != null) {
        Command result = Command.CONTINUE;
        Iterator<IOFMessageListener> it = theListeners.iterator();
        if (OFType.PACKET_IN.equals(msg.getType())) {
            OFPacketIn pi = (OFPacketIn)msg;
            Ethernet eth = new Ethernet();
            eth.deserialize(pi.getData(), 0, pi.getData().length);
            IFloodlightProviderService.bcStore.put(bc,
                    IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
                    eth);
        }
        while (it.hasNext() && !Command.STOP.equals(result)) {
            result = it.next().receive(sw, msg, bc);
        }
    }
}
LinkDiscoveryManagerTest.java 文件源码 项目:fresco_floodlight 阅读 31 收藏 0 点赞 0 评论 0
private OFPacketIn createPacketIn(String srcMAC, String dstMAC,
                                  String srcIp, String dstIp, short vlan) {
    IPacket testPacket = new Ethernet()
    .setDestinationMACAddress(dstMAC)
    .setSourceMACAddress(srcMAC)
    .setVlanID(vlan)
    .setEtherType(EthType.IPv4)
    .setPayload(
            new IPv4()
            .setTtl((byte) 128)
            .setSourceAddress(srcIp)
            .setDestinationAddress(dstIp)
            .setPayload(new UDP()
            .setSourcePort((short) 5000)
            .setDestinationPort((short) 5001)
            .setPayload(new Data(new byte[] {0x01}))));
    byte[] testPacketSerialized = testPacket.serialize();
    OFPacketIn pi;
    // build out input packet
    pi = OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
            .setBufferId(OFBufferId.NO_BUFFER)
            .setData(testPacketSerialized)
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    return pi;
}
OFSwitchHandlerTestBase.java 文件源码 项目:fresco_floodlight 阅读 37 收藏 0 点赞 0 评论 0
/**
 * Test dispatch of messages while in MASTER role
 */
@Test
public void testMessageDispatchMaster() throws Exception {
    testInitialMoveToMasterWithRole();

    // Send packet in. expect dispatch
    OFPacketIn pi = factory.buildPacketIn()
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    reset(switchManager);
    switchManager.handleMessage(sw, pi, null);
    expectLastCall().once();
    replay(switchManager);
    switchHandler.processOFMessage(pi);

    // TODO: many more to go
}
PacketFactory.java 文件源码 项目:fresco_floodlight 阅读 26 收藏 0 点赞 0 评论 0
/**
 * Generates a DHCP request OFPacketIn.
 * @param hostMac The host MAC address of for the request.
 * @return An OFPacketIn that contains a DHCP request packet.
 */
public static OFPacketIn DhcpDiscoveryRequestOFPacketIn(IOFSwitch sw,
        MacAddress hostMac) {
    byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
    OFFactory factory = sw.getOFFactory();
    OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
    if (factory.getVersion() == OFVersion.OF_10) {
        packetInBuilder
            .setInPort(OFPort.of(1))
            .setData(serializedPacket)
            .setReason(OFPacketInReason.NO_MATCH);
    } else {
        packetInBuilder
        .setMatch(factory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build())
        .setData(serializedPacket)
        .setReason(OFPacketInReason.NO_MATCH);
    }
    return packetInBuilder.build();
}
MockFloodlightProvider.java 文件源码 项目:fresco_floodlight 阅读 44 收藏 0 点赞 0 评论 0
public void dispatchMessage(IOFSwitch sw, OFMessage msg, FloodlightContext bc) {
      List<IOFMessageListener> theListeners = listeners.get(msg.getType()).getOrderedListeners();
      if (theListeners != null) {
          Command result = Command.CONTINUE;
          Iterator<IOFMessageListener> it = theListeners.iterator();
          if (OFType.PACKET_IN.equals(msg.getType())) {
              OFPacketIn pi = (OFPacketIn)msg;
              Ethernet eth = new Ethernet();
              eth.deserialize(pi.getData(), 0, pi.getData().length);
              IFloodlightProviderService.bcStore.put(bc,
                      IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
                      eth);
          }
          while (it.hasNext() && !Command.STOP.equals(result)) {
              result = it.next().receive(sw, msg, bc);
          }
      }
// paag
      for (IControllerCompletionListener listener:completionListeners)
        listener.onMessageConsumed(sw, msg, bc);
  }
ObfuscationTopologyManager.java 文件源码 项目:iTAP-controller 阅读 35 收藏 0 点赞 0 评论 0
public void updateTopologyMappings(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
    Ethernet eth = IFloodlightProviderService.bcStore.get(cntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);

    if (eth.getPayload() instanceof IPv4) {
        IPv4 ip_pkt = (IPv4) eth.getPayload();

        if (ip_pkt.getSourceAddress().getInt() > 0) {
            IpToMac.put(ip_pkt.getSourceAddress(), eth.getSourceMACAddress());
            IpToSwitch.put(ip_pkt.getSourceAddress(),new SwitchHostInfo(sw,pi.getMatch().get(MatchField.IN_PORT)));
        }
    }
    else if (eth.getPayload() instanceof ARP) {
        ARP arp_pkt = (ARP) eth.getPayload();

        if (IPv4Address.of(arp_pkt.getSenderProtocolAddress()).getInt() > 0) {

            if (!IPv4Address.of(arp_pkt.getSenderProtocolAddress()).toString().contentEquals("10.0.0.111")) {// ignore crafted requests from switches 
                IpToMac.put(IPv4Address.of(arp_pkt.getSenderProtocolAddress()), eth.getSourceMACAddress());
                IpToSwitch.put(IPv4Address.of(arp_pkt.getSenderProtocolAddress()),new SwitchHostInfo(sw,pi.getMatch().get(MatchField.IN_PORT)));
            }
        }
    }
}
ObfuscationController.java 文件源码 项目:iTAP-controller 阅读 39 收藏 0 点赞 0 评论 0
@Override
public net.floodlightcontroller.core.IListener.Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    Ethernet eth = IFloodlightProviderService.bcStore.get(cntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
    oTopologyManager.updateTopologyMappings(sw, (OFPacketIn) msg, cntx);

    //log.debug("receive {}",eth);

    if ((eth.getPayload() instanceof ARP)) {
        handleARP(sw, (OFPacketIn) msg, cntx);
    }
    else if (eth.getPayload() instanceof IPv4) {
        handleIP(sw, (OFPacketIn) msg, cntx);
    }
    else {
        //handleCbench(sw, (OFPacketIn) msg, cntx);
        //log.warn("could not handle packet {}",eth.toString());
    }
    return Command.CONTINUE;
}
Hub.java 文件源码 项目:iTAP-controller 阅读 28 收藏 0 点赞 0 评论 0
private OFMessage createHubPacketOut(IOFSwitch sw, OFMessage msg) {
    OFPacketIn pi = (OFPacketIn) msg;
    OFPacketOut.Builder pob = sw.getOFFactory().buildPacketOut();
    pob.setBufferId(pi.getBufferId()).setXid(pi.getXid()).setInPort((pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT)));

    // set actions
    OFActionOutput.Builder actionBuilder = sw.getOFFactory().actions().buildOutput();
    actionBuilder.setPort(OFPort.FLOOD);
    pob.setActions(Collections.singletonList((OFAction) actionBuilder.build()));

    // set data if it is included in the packetin
    if (pi.getBufferId() == OFBufferId.NO_BUFFER) {
        byte[] packetData = pi.getData();
        pob.setData(packetData);
    }
    return pob.build();  
}
LearningSwitch.java 文件源码 项目:iTAP-controller 阅读 33 收藏 0 点赞 0 评论 0
/**
 * Writes an OFPacketOut message to a switch.
 * @param sw The switch to write the PacketOut to.
 * @param packetInMessage The corresponding PacketIn.
 * @param egressPort The switchport to output the PacketOut.
 */
private void writePacketOutForPacketIn(IOFSwitch sw, OFPacketIn packetInMessage, OFPort egressPort) {
    OFPacketOut.Builder pob = sw.getOFFactory().buildPacketOut();

    // Set buffer_id, in_port, actions_len
    pob.setBufferId(packetInMessage.getBufferId());
    pob.setInPort(packetInMessage.getVersion().compareTo(OFVersion.OF_12) < 0 ? packetInMessage.getInPort() : packetInMessage.getMatch().get(MatchField.IN_PORT));

    // set actions
    List<OFAction> actions = new ArrayList<OFAction>(1);
    actions.add(sw.getOFFactory().actions().buildOutput().setPort(egressPort).setMaxLen(0xffFFffFF).build());
    pob.setActions(actions);

    // set data - only if buffer_id == -1
    if (packetInMessage.getBufferId() == OFBufferId.NO_BUFFER) {
        byte[] packetData = packetInMessage.getData();
        pob.setData(packetData);
    }

    // and write it out
    counterPacketOut.increment();
    sw.write(pob.build());

}
TopologyManager.java 文件源码 项目:iTAP-controller 阅读 33 收藏 0 点赞 0 评论 0
/**
 * If the packet-in switch port is disabled for all data traffic, then
 * the packet will be dropped.  Otherwise, the packet will follow the
 * normal processing chain.
 * @param sw
 * @param pi
 * @param cntx
 * @return
 */
protected Command dropFilter(DatapathId sw, OFPacketIn pi,
        FloodlightContext cntx) {
    Command result = Command.CONTINUE;
    OFPort inPort = (pi.getVersion().compareTo(OFVersion.OF_12) < 0 ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT));

    // If the input port is not allowed for data traffic, drop everything.
    // BDDP packets will not reach this stage.
    if (isAllowed(sw, inPort) == false) {
        if (log.isTraceEnabled()) {
            log.trace("Ignoring packet because of topology " +
                    "restriction on switch={}, port={}", sw.getLong(), inPort.getPortNumber());
            result = Command.STOP;
        }
    }
    return result;
}
TopologyManager.java 文件源码 项目:iTAP-controller 阅读 36 收藏 0 点赞 0 评论 0
protected Command processPacketInMessage(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
    // get the packet-in switch.
    Ethernet eth =
            IFloodlightProviderService.bcStore.
            get(cntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);

    if (eth.getPayload() instanceof BSN) {
        BSN bsn = (BSN) eth.getPayload();
        if (bsn == null) return Command.STOP;
        if (bsn.getPayload() == null) return Command.STOP;

        // It could be a packet other than BSN LLDP, therefore
        // continue with the regular processing.
        if (bsn.getPayload() instanceof LLDP == false)
            return Command.CONTINUE;

        doFloodBDDP(sw.getId(), pi, cntx);
        return Command.STOP;
    } else {
        return dropFilter(sw.getId(), pi, cntx);
    }
}
OFSwitchHandlerTestBase.java 文件源码 项目:iTAP-controller 阅读 32 收藏 0 点赞 0 评论 0
/**
 * Test dispatch of messages while in MASTER role
 */
@Test
public void testMessageDispatchMaster() throws Exception {
    testInitialMoveToMasterWithRole();

    // Send packet in. expect dispatch
    OFPacketIn pi = factory.buildPacketIn()
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    reset(switchManager);
    switchManager.handleMessage(sw, pi, null);
    expectLastCall().once();
    replay(switchManager);
    switchHandler.processOFMessage(pi);

    // TODO: many more to go
}
OFSwitchHandshakeHandler.java 文件源码 项目:iTAP-controller 阅读 34 收藏 0 点赞 0 评论 0
@Override
@LogMessageDoc(level="WARN",
message="Received PacketIn from switch {} while" +
        "being slave. Reasserting slave role.",
        explanation="The switch has receive a PacketIn despite being " +
                "in slave role indicating inconsistent controller roles",
                recommendation="This situation can occurs transiently during role" +
                        " changes. If, however, the condition persists or happens" +
                        " frequently this indicates a role inconsistency. " +
                        LogMessageDoc.CHECK_CONTROLLER )
void processOFPacketIn(OFPacketIn m) {
    // we don't expect packetIn while slave, reassert we are slave
    switchManagerCounters.packetInWhileSwitchIsSlave.increment();
    log.warn("Received PacketIn from switch {} while" +
            "being slave. Reasserting slave role.", sw);
    reassertRole(OFControllerRole.ROLE_SLAVE);
}
VirtualNetworkFilterTest.java 文件源码 项目:iTAP-controller 阅读 40 收藏 0 点赞 0 评论 0
@Test
public void testDhcp() {
    IOFMessageListener listener = getVirtualNetworkListener();
    Ethernet dhcpPacket = PacketFactory.DhcpDiscoveryRequestEthernet(mac1);
    OFPacketIn dhcpPacketOf = PacketFactory.DhcpDiscoveryRequestOFPacketIn(sw1, mac1);
    cntx = new FloodlightContext();
    IFloodlightProviderService.bcStore.put(cntx,
                       IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
                       dhcpPacket);
    Command ret = listener.receive(sw1, dhcpPacketOf, cntx);
    assertTrue(ret == Command.CONTINUE);
}
PathVerificationService.java 文件源码 项目:open-kilda 阅读 35 收藏 0 点赞 0 评论 0
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext context) {
    switch (msg.getType()) {
        case PACKET_IN:
            return handlePacketIn(sw, (OFPacketIn) msg, context);
        default:
            break;
    }
    return Command.CONTINUE;
}
FloodlightTestCase.java 文件源码 项目:iTAP-controller 阅读 33 收藏 0 点赞 0 评论 0
public static FloodlightContext parseAndAnnotate(FloodlightContext bc, OFMessage m) {
    if (OFType.PACKET_IN.equals(m.getType())) {
        OFPacketIn pi = (OFPacketIn)m;
        Ethernet eth = new Ethernet();
        eth.deserialize(pi.getData(), 0, pi.getData().length);
        IFloodlightProviderService.bcStore.put(bc,
                IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
                eth);
    }
    return bc;
}
FloodlightTestCase.java 文件源码 项目:open-kilda 阅读 36 收藏 0 点赞 0 评论 0
public static FloodlightContext parseAndAnnotate(FloodlightContext bc, OFMessage m) {
    if (OFType.PACKET_IN.equals(m.getType())) {
        OFPacketIn pi = (OFPacketIn)m;
        Ethernet eth = new Ethernet();
        eth.deserialize(pi.getData(), 0, pi.getData().length);
        IFloodlightProviderService.bcStore.put(bc,
                IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
                eth);
    }
    return bc;
}
OFChannelHandler.java 文件源码 项目:athena 阅读 33 收藏 0 点赞 0 评论 0
@Override
            void processOFPacketIn(OFChannelHandler h, OFPacketIn m) {
//                OFPacketOut out =
//                        h.sw.factory().buildPacketOut()
//                                .setXid(m.getXid())
//                                .setBufferId(m.getBufferId()).build();
//                h.sw.sendMsg(out);
                h.dispatchMessage(m);
            }
OpenFlowPacketProviderTest.java 文件源码 项目:athena 阅读 29 收藏 0 点赞 0 评论 0
@Test
public void handlePacket() {
    OFPacketIn pkt = sw.factory().buildPacketIn()
            .setBufferId(OFBufferId.NO_BUFFER)
            .setInPort(OFPort.NO_MASK)
            .setReason(OFPacketInReason.INVALID_TTL)
            .build();

    controller.processPacket(null, pkt);
    assertNotNull("message unprocessed", registry.ctx);

}
OpenFlowPacketProviderTest.java 文件源码 项目:athena 阅读 32 收藏 0 点赞 0 评论 0
@Override
public void processPacket(Dpid dpid, OFMessage msg) {
    OpenFlowPacketContext pktCtx =
            DefaultOpenFlowPacketContext.
            packetContextFromPacketIn(sw, (OFPacketIn) msg);
    pktListener.handlePacket(pktCtx);
}
FeatureCollectorProvider.java 文件源码 项目:athena 阅读 27 收藏 0 点赞 0 评论 0
@Override
        public void packetInProcess(Dpid dpid, OFPacketIn packetIn, OpenFlowPacketContext pktCtx) {
            //exclude abnormal packet -- Jinwoo Kim
            //only store ipv4 packet to DB
            try {
                short etherType = convertPacketContextToInboundPacket(pktCtx).parsed().getEtherType();
                if (etherType != 2048) {
                    return;
                }
            } catch (Exception e) {
                log.error(e.toString());
            }

            InboundPacket ip = convertPacketContextToInboundPacket(pktCtx);
            PacketInFeature pif = new PacketInFeature();
            UnitPacketInInformation ufii;
            Date date = new java.sql.Timestamp(Calendar.getInstance().getTime().getTime());

            if (packetIn.getVersion() == OFVersion.OF_13) {
                FeatureIndex pfi = matchToFeatureIndex(packetIn.getMatch());
                pfi = extractElementsFromInboundPkt(pfi, ip);
                ufii = new UnitPacketInInformation(packetIn.getTotalLen(),
                        packetIn.getReason().ordinal(), pfi);
                // in case of OF_10, just store dummy match value
                // Jinwoo kim
            } else {
                ufii = new UnitPacketInInformation();
//                return;
            }
            ufii.setDate(date);

            FeatureIndex fi = new FeatureIndex();
            fi.setSwitchDatapathId(dpid.value());
            fi.setSwitchPortId(toIntExact(ip.receivedFrom().port().toLong()));

            pif.addFeatureData(fi, ufii);

            providerService.packetInFeatureHandler(pif);
        }
DeviceManagerImpl.java 文件源码 项目:fresco_floodlight 阅读 28 收藏 0 点赞 0 评论 0
@Override
public Command receive(IOFSwitch sw, OFMessage msg,
        FloodlightContext cntx) {
    switch (msg.getType()) {
    case PACKET_IN:
        cntIncoming.increment();
        return this.processPacketInMessage(sw, (OFPacketIn) msg, cntx);
    default:
        break;
    }
    return Command.CONTINUE;
}


问题


面经


文章

微信
公众号

扫码关注公众号