Java 类net.floodlightcontroller.core.IFloodlightProviderService 实例源码

项目:iTAP-controller    文件:TopologyManager.java   
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);
    }
}
项目:iTAP-controller    文件:TopologyManager.java   
@Override
public void init(FloodlightModuleContext context)
        throws FloodlightModuleException {
    linkDiscoveryService = context.getServiceImpl(ILinkDiscoveryService.class);
    threadPoolService = context.getServiceImpl(IThreadPoolService.class);
    floodlightProviderService = context.getServiceImpl(IFloodlightProviderService.class);
    switchService = context.getServiceImpl(IOFSwitchService.class);
    restApiService = context.getServiceImpl(IRestApiService.class);
    debugCounterService = context.getServiceImpl(IDebugCounterService.class);
    debugEventService = context.getServiceImpl(IDebugEventService.class);

    switchPorts = new HashMap<DatapathId, Set<OFPort>>();
    switchPortLinks = new HashMap<NodePortTuple, Set<Link>>();
    directLinks = new HashMap<NodePortTuple, Set<Link>>();
    portBroadcastDomainLinks = new HashMap<NodePortTuple, Set<Link>>();
    tunnelPorts = new HashSet<NodePortTuple>();
    topologyAware = new ArrayList<ITopologyListener>();
    ldUpdates = new LinkedBlockingQueue<LDUpdate>();
    haListener = new HAListenerDelegate();
    registerTopologyDebugCounters();
    registerTopologyDebugEvents();
}
项目:open-kilda    文件:PathVerificationFlowTest.java   
@Before
public void setUp() throws Exception {
    logger = LoggerFactory.getLogger(PathVerificationFlowTest.class);
    cntx = new FloodlightContext();
    FloodlightModuleContext fmc = new FloodlightModuleContext();
    fmc.addService(IFloodlightProviderService.class, mockFloodlightProvider);

    swDescription = factory.buildDescStatsReply().build();
    swFeatures = factory.buildFeaturesReply().setNBuffers(1000).build();

    sw = EasyMock.createMock(IOFSwitch.class);
    expect(sw.getId()).andReturn(swDpid).anyTimes();
    expect(sw.getOFFactory()).andReturn(factory).anyTimes();
    expect(sw.getBuffers()).andReturn(swFeatures.getNBuffers()).anyTimes();
    expect(sw.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_TABLE)).andReturn(true).anyTimes();
    expect(sw.getSwitchDescription()).andReturn(new SwitchDescription(swDescription)).anyTimes();
    expect(sw.isActive()).andReturn(true).anyTimes();
    expect(sw.getLatency()).andReturn(U64.of(10L)).anyTimes();
    replay(sw);

    pvs = new PathVerificationService();
}
项目:iTAP-controller    文件:LoadBalancer.java   
@Override
public Collection<Class<? extends IFloodlightService>>
        getModuleDependencies() {
    Collection<Class<? extends IFloodlightService>> l = 
            new ArrayList<Class<? extends IFloodlightService>>();
    l.add(IFloodlightProviderService.class);
    l.add(IRestApiService.class);
    l.add(IOFSwitchService.class);
    l.add(IDeviceService.class);
    l.add(IDebugCounterService.class);
    l.add(ITopologyService.class);
    l.add(IRoutingService.class);
    l.add(IStaticFlowEntryPusherService.class);

    return l;
}
项目:fresco_floodlight    文件:MockFloodlightProvider.java   
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);
  }
项目:fresco_floodlight    文件:FP_LibFloodlight.java   
@Override
public int getSrcIP(FPContext cntx) {
    FloodlightContext flCntx = cntx.getFlowContext();

    Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
    IPv4Address srcIP;

    if(eth.getEtherType() == EthType.IPv4)
    {       
        IPv4 ipv4 = (IPv4) eth.getPayload();
        srcIP = ipv4.getSourceAddress();

        return srcIP.getInt();
    }
    else if (eth.getEtherType() == EthType.ARP){
        ARP arp = (ARP) eth.getPayload();
        srcIP = arp.getSenderProtocolAddress();

        return srcIP.getInt();
    }

    //for other packets without source IP information   
    return 0;

}
项目:fresco_floodlight    文件:FP_LibFloodlight.java   
@Override
public int getDstIP(FPContext cntx) {
    FloodlightContext flCntx = cntx.getFlowContext();

    Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
    IPv4Address dstIP;

    if(eth.getEtherType() == EthType.IPv4)
    {       
        IPv4 ipv4 = (IPv4) eth.getPayload();
        dstIP = ipv4.getDestinationAddress();
        return dstIP.getInt();
    }
    else if (eth.getEtherType() == EthType.ARP){
        ARP arp = (ARP) eth.getPayload();

        dstIP = arp.getTargetProtocolAddress();

        return dstIP.getInt();
    }

    //for other packets without destination IP information
    return 0;

}
项目:fresco_floodlight    文件:FP_LibFloodlight.java   
@Override
public long getARPTargetMAC(FPContext cntx){
    FloodlightContext flCntx = cntx.getFlowContext();

    Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
    MacAddress senderMAC;

    if (eth.getEtherType() == EthType.ARP){
        ARP arp = (ARP) eth.getPayload();

        senderMAC = arp.getTargetHardwareAddress();

        return senderMAC.getLong();
    }

    //for other non-arp packets
    return 0;
}
项目:iTAP-controller    文件:FlowReconcileManager.java   
@Override
public void init(FloodlightModuleContext context)
        throws FloodlightModuleException {
    floodlightProviderService = context.getServiceImpl(IFloodlightProviderService.class);
    threadPoolService = context.getServiceImpl(IThreadPoolService.class);
    debugCounterService = context.getServiceImpl(IDebugCounterService.class);
    flowQueue = new PriorityPendingQueue<OFMatchReconcile>();
    flowReconcileListeners = new ListenerDispatcher<OFType, IFlowReconcileListener>();

    Map<String, String> configParam = context.getConfigParams(this);
    String enableValue = configParam.get(EnableConfigKey);
    registerFlowReconcileManagerDebugCounters();
    // Set flowReconcile default to true
    flowReconcileEnabled = true;
    if (enableValue != null &&
            enableValue.equalsIgnoreCase("false")) {
        flowReconcileEnabled = false;
    }
    flowReconcileThreadRunCount = new AtomicInteger(0);
    lastReconcileTime = new Date(0);
    logger.debug("FlowReconcile is {}", flowReconcileEnabled);
}
项目:iTAP-controller    文件:VirtualNetworkFilter.java   
@Override
public void init(FloodlightModuleContext context)
        throws FloodlightModuleException {
    floodlightProviderService = context.getServiceImpl(IFloodlightProviderService.class);
    restApiService = context.getServiceImpl(IRestApiService.class);
    deviceService = context.getServiceImpl(IDeviceService.class);

    vNetsByGuid = new ConcurrentHashMap<String, VirtualNetwork>();
    nameToGuid = new ConcurrentHashMap<String, String>();
    guidToGateway = new ConcurrentHashMap<String, IPv4Address>();
    gatewayToGuid = new ConcurrentHashMap<IPv4Address, Set<String>>();
    macToGuid = new ConcurrentHashMap<MacAddress, String>();
    portToMac = new ConcurrentHashMap<String, MacAddress>();
    macToGateway = new ConcurrentHashMap<MacAddress, IPv4Address>();
    deviceListener = new DeviceListenerImpl();

}
项目:iTAP-controller    文件:ObfuscationTopologyManager.java   
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)));
            }
        }
    }
}
项目:fresco_floodlight    文件:TopologyManager.java   
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);
    }
}
项目:fresco_floodlight    文件:TopologyInstanceTest.java   
@Before 
public void SetUp() throws Exception {
    fmc = new FloodlightModuleContext();
    linkDiscovery = EasyMock.createMock(ILinkDiscoveryService.class);
    mockFloodlightProvider = new MockFloodlightProvider();
    fmc.addService(IFloodlightProviderService.class, mockFloodlightProvider);
    fmc.addService(IOFSwitchService.class, new MockSwitchManager());
    fmc.addService(ILinkDiscoveryService.class, linkDiscovery);
    fmc.addService(IDebugCounterService.class, new MockDebugCounterService());
    fmc.addService(IDebugEventService.class, new MockDebugEventService());
    MockThreadPoolService tp = new MockThreadPoolService();
    topologyManager = new TopologyManager();
    fmc.addService(IThreadPoolService.class, tp);
    topologyManager.init(fmc);
    tp.init(fmc);
    tp.startUp(fmc);
}
项目:floodlight-simple-multicast    文件:Multicast.java   
@Override
public Collection<Class<? extends IFloodlightService>> getModuleDependencies() {
    Collection<Class<? extends IFloodlightService>> l = new ArrayList<Class<? extends IFloodlightService>>();
    l.add(IFloodlightProviderService.class);
    l.add(IRestApiService.class);
    l.add(IRoutingService.class);
    return l;
}
项目:floodlight-simple-multicast    文件:Multicast.java   
@Override
public void init(FloodlightModuleContext context) throws FloodlightModuleException {
    floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
    restApiService = context.getServiceImpl(IRestApiService.class);
    routingService = context.getServiceImpl(IRoutingService.class);
    // create an empty db
    groupDb = new MulticastDb();
    log.info("Startup MULTICAST module");
}
项目:open-kilda    文件:SwitchManager.java   
/**
 * {@inheritDoc}
 */
@Override
public Collection<Class<? extends IFloodlightService>> getModuleDependencies() {
    Collection<Class<? extends IFloodlightService>> services = new ArrayList<>(3);
    services.add(IFloodlightProviderService.class);
    services.add(IOFSwitchService.class);
    services.add(IRestApiService.class);
    return services;
}
项目:iTAP-controller    文件:VirtualNetworkFilterTest.java   
@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);
}
项目:open-kilda    文件:PathVerificationService.java   
@VisibleForTesting
void initServices(FloodlightModuleContext context)
{
    floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
    switchService = context.getServiceImpl(IOFSwitchService.class);
    restApiService = context.getServiceImpl(IRestApiService.class);
}
项目:iTAP-controller    文件:PortDownReconciliation.java   
@Override
public Collection<Class<? extends IFloodlightService>>
        getModuleDependencies() {
    Collection<Class<? extends IFloodlightService>> l = new ArrayList<Class<? extends IFloodlightService>>();
    l.add(IFloodlightProviderService.class);
    l.add(ITopologyService.class);
    l.add(IFlowReconcileService.class);
    l.add(ILinkDiscoveryService.class);
    return l;
}
项目:open-kilda    文件:PathVerificationPacketSignTest.java   
@Before
public void setUp() throws Exception {

    super.setUp();

    OFPacketOut packetOut = pvs.generateVerificationPacket(sw1, OFPort.of(1));

    ofPacketIn = EasyMock.createMock(OFPacketIn.class);

    context = new FloodlightContext();

    expect(ofPacketIn.getType()).andReturn(OFType.PACKET_IN).anyTimes();
    expect(ofPacketIn.getXid()).andReturn(0L).anyTimes();
    expect(ofPacketIn.getVersion()).andReturn(packetOut.getVersion()).anyTimes();

    Match match = EasyMock.createMock(Match.class);
    expect(match.get(MatchField.IN_PORT)).andReturn(OFPort.of(1)).anyTimes();
    replay(match);
    expect(ofPacketIn.getMatch()).andReturn(match).anyTimes();
    replay(ofPacketIn);

    IPacket expected = new Ethernet().deserialize(packetOut.getData(), 0,
            packetOut.getData().length);

    context.getStorage().put(IFloodlightProviderService.CONTEXT_PI_PAYLOAD, expected);

    HashMap<DatapathId, IOFSwitch> switches = new HashMap<>();
    switches.put(sw1.getId(), sw1);
    switches.put(sw2.getId(), sw2);
    mockSwitchManager.setSwitches(switches);

    reset(producer);

    pvs.setKafkaProducer(producer);
}
项目:open-kilda    文件:PathVerificationPacketSignTest.java   
@Test
public void testSignPacketMissedSign() throws PacketParsingException, FloodlightModuleException {
    OFPacketOut noSignPacket = pvs.generateVerificationPacket(sw1, OFPort.of(1), null, false);
    IPacket noSignPacketData = new Ethernet().deserialize(noSignPacket.getData(), 0,
            noSignPacket.getData().length);
    context.getStorage().put(IFloodlightProviderService.CONTEXT_PI_PAYLOAD, noSignPacketData);
    expect(producer.send(anyObject())).andThrow(new AssertionFailedError()).anyTimes();
    replay(producer);
    assertEquals(Command.STOP, pvs.receive(sw2, ofPacketIn, context));
    verify(producer);
}
项目:open-kilda    文件:PathVerificationPacketOutTest.java   
@Before
public void setUp() throws Exception {
    super.setUp();
    cntx = new FloodlightContext();
    FloodlightModuleContext fmc = new FloodlightModuleContext();
    fmc.addService(IFloodlightProviderService.class, mockFloodlightProvider);
    fmc.addService(IOFSwitchService.class, getMockSwitchService());
    swDescription = factory.buildDescStatsReply().build();
    pvs = new PathVerificationService();
    pvs.initAlgorithm("secret");
    srcIpTarget = new InetSocketAddress("192.168.10.1", 200);
    dstIpTarget = new InetSocketAddress("192.168.10.101", 100);
    sw1HwAddrTarget = "11:22:33:44:55:66";
    sw2HwAddrTarget = "AA:BB:CC:DD:EE:FF";

    OFPortDesc sw1Port1 = EasyMock.createMock(OFPortDesc.class);
    expect(sw1Port1.getHwAddr()).andReturn(MacAddress.of(sw1HwAddrTarget)).anyTimes();
    OFPortDesc sw2Port1 = EasyMock.createMock(OFPortDesc.class);
    expect(sw2Port1.getHwAddr()).andReturn(MacAddress.of(sw2HwAddrTarget)).anyTimes();
    replay(sw1Port1);
    replay(sw2Port1);

    sw1 = buildMockIOFSwitch(1L, sw1Port1, factory, swDescription, srcIpTarget);
    sw2 = buildMockIOFSwitch(2L, sw2Port1, factory, swDescription, dstIpTarget);
    replay(sw1);
    replay(sw2);
}
项目:iTAP-controller    文件:FirewallTest.java   
protected void setPacketIn(IPacket packet) {
    byte[] serializedPacket = packet.serialize();
    // Build the PacketIn
    this.packetIn = OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
            .setBufferId(OFBufferId.NO_BUFFER)
            .setMatch(OFFactories.getFactory(OFVersion.OF_13).buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build())
            .setData(serializedPacket)
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    // Add the packet to the context store
    IFloodlightProviderService.bcStore.
    put(cntx,
            IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
            (Ethernet)packet);
}
项目:open-kilda    文件:MockFloodlightProvider.java   
@Override
public Collection<Class<? extends IFloodlightService>> getModuleServices() {
    Collection<Class<? extends IFloodlightService>> services =
            new ArrayList<Class<? extends IFloodlightService>>(1);
    services.add(IFloodlightProviderService.class);
    return services;
}
项目:iTAP-controller    文件:ObfuscationSwitchStateManager.java   
@Override
public void init(FloodlightModuleContext context)
        throws FloodlightModuleException {
    floodlightProvider = context .getServiceImpl(IFloodlightProviderService.class);
    switchStates = new HashMap<IOFSwitch,ObfuscationSwitchState>();
    oMaskManager = context.getServiceImpl(IObfuscationMaskManager.class);

}
项目:fresco_floodlight    文件:testSecurityKernel.java   
@Override
public Collection<Class<? extends IFloodlightService>> getModuleDependencies() {
    Collection<Class<? extends IFloodlightService>> l = new ArrayList<Class<? extends IFloodlightService>>();
    l.add(IFloodlightProviderService.class);
    l.add(IStaticFlowEntryPusherService.class);
    l.add(IOFSwitchService.class);
    return l;
}
项目:fresco_floodlight    文件:FP_LibFloodlight.java   
@Override
public boolean isIPv4(FPContext cntx) {
    FloodlightContext flCntx = cntx.getFlowContext();

    Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
    if(eth.getEtherType() == EthType.IPv4)
    {       
        return true;
    }
    else
    {
        return false;
    }
}
项目:fresco_floodlight    文件:FP_LibFloodlight.java   
@Override
public boolean isICMP(FPContext cntx) {
    FloodlightContext flCntx = cntx.getFlowContext();

    Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
    if(eth.getEtherType() == EthType.IPv4)
    {   
        IPv4 ipv4 = (IPv4) eth.getPayload();
        return (ipv4.getProtocol() == IpProtocol.ICMP);
    }
    else
    {
        return false;
    }
}
项目:iTAP-controller    文件:DeviceManagerImpl.java   
@Override
public void init(FloodlightModuleContext fmc) throws FloodlightModuleException {
    this.perClassIndices =
            new HashSet<EnumSet<DeviceField>>();
    addIndex(true, EnumSet.of(DeviceField.IPV4));

    this.deviceListeners = new ListenerDispatcher<String, IDeviceListener>();
    this.suppressAPs = Collections.newSetFromMap(
            new ConcurrentHashMap<SwitchPort, Boolean>());

    this.floodlightProvider =
            fmc.getServiceImpl(IFloodlightProviderService.class);
    this.storageSource =
            fmc.getServiceImpl(IStorageSourceService.class);
    this.topology =
            fmc.getServiceImpl(ITopologyService.class);
    this.restApi = fmc.getServiceImpl(IRestApiService.class);
    this.threadPool = fmc.getServiceImpl(IThreadPoolService.class);
    this.entityClassifier = fmc.getServiceImpl(IEntityClassifierService.class);
    this.debugCounters = fmc.getServiceImpl(IDebugCounterService.class);
    this.debugEventService = fmc.getServiceImpl(IDebugEventService.class);
    this.syncService = fmc.getServiceImpl(ISyncService.class);
    this.deviceSyncManager = new DeviceSyncManager();
    this.haListenerDelegate = new HAListenerDelegate();
    registerDeviceManagerDebugCounters();
    registerDeviceManagerDebugEvents();
    this.addListener(new DeviceDebugEventLogger());
}
项目:iTAP-controller    文件:LearningSwitch.java   
@Override
public void init(FloodlightModuleContext context) throws FloodlightModuleException {
    macVlanToSwitchPortMap = new ConcurrentHashMap<IOFSwitch, Map<MacVlanPair, OFPort>>();
    floodlightProviderService = context.getServiceImpl(IFloodlightProviderService.class);
    debugCounterService = context.getServiceImpl(IDebugCounterService.class);
    restApiService = context.getServiceImpl(IRestApiService.class);
}
项目:iTAP-controller    文件:SystemUptimeResource.java   
@Get("json")
public UptimeRest retrieve() {
    IFloodlightProviderService floodlightProvider =
        (IFloodlightProviderService)getContext().getAttributes().
        get(IFloodlightProviderService.class.getCanonicalName());

    UptimeRest uptime = new UptimeRest();
    uptime.systemUptimeMsec = floodlightProvider.getUptime();

    return (uptime);
}
项目:fresco_floodlight    文件:FP_LibFloodlight.java   
@Override
public int getSrcPort(FPContext cntx) {
    FloodlightContext flCntx = cntx.getFlowContext();

    Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
    if(eth.getEtherType() == EthType.IPv4)
    {       
        IPv4 ipv4 = (IPv4) eth.getPayload();
        if( isTCP(cntx) )
        {
            TCP tcp = (TCP) ipv4.getPayload();
            return tcp.getSourcePort().getPort();   
        }
        else if ( isUDP(cntx) )
        {
            UDP udp = (UDP) ipv4.getPayload();
            return udp.getSourcePort().getPort();
        }
        else
        {
            return 0;
        }
    }
    else
    {
        return 0;
    }
}
项目:iTAP-controller    文件:VirtualNetworkFilterTest.java   
@Test
public void testDefaultGateway() {
    testAddHost();
    IOFMessageListener listener = getVirtualNetworkListener();
    cntx = new FloodlightContext();
    IFloodlightProviderService.bcStore.put(cntx,
                       IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
                           (Ethernet)mac1ToGwPacketIntestPacket);
    deviceService.learnEntity(((Ethernet)mac1ToGwPacketIntestPacket).getDestinationMACAddress().getLong(),
            null, IPv4.toIPv4Address(gw1), null, null);
    Command ret = listener.receive(sw1, mac1ToGwPacketIn, cntx);
    assertTrue(ret == Command.CONTINUE);
}
项目:iTAP-controller    文件:ObfuscationController.java   
private void handleARP(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
    Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);

    if (! (eth.getPayload() instanceof ARP)) // not an ARP packet
        return;

    ARP arpRequest = (ARP) eth.getPayload();

    if (arpRequest.getOpCode() == ARP.OP_REPLY) { // is a reply
        oTopologyManager.updateTopologyMappings(sw, pi, cntx);

        for (ARP pendingArpRequest : arpRequestBuffer.getPendingRequests(IPv4Address.of(arpRequest.getSenderProtocolAddress()))) {              
            if (oTopologyManager.knowSwitchForIp(IPv4Address.of(pendingArpRequest.getSenderProtocolAddress()))) {
                SwitchHostInfo dstSwitchPort = oTopologyManager.getSwitchForIp(IPv4Address.of(pendingArpRequest.getSenderProtocolAddress()));
                sendArpReply(MacAddress.of(arpRequest.getSenderHardwareAddress()), IPv4Address.of(arpRequest.getSenderProtocolAddress()), MacAddress.of(pendingArpRequest.getSenderHardwareAddress()), IPv4Address.of(pendingArpRequest.getSenderProtocolAddress()), dstSwitchPort.getSwitch(), dstSwitchPort.getPort());
                arpRequestBuffer.removeRequest(pendingArpRequest);
            }
            else
                log.warn("answering pending ARP request failed because dst switch/port is not known. {}",pendingArpRequest);
        }
    }
    else { // is a request
        if (IPv4Address.of(arpRequest.getSenderProtocolAddress()).toString().contentEquals("10.0.0.111")) // ignore crafted requests from switches
            return;

        if (oTopologyManager.knowMacForIp(IPv4Address.of(arpRequest.getTargetProtocolAddress()))) {
            MacAddress senderMac = oTopologyManager.getMacForIp(IPv4Address.of(arpRequest.getTargetProtocolAddress()));
            sendArpReply(senderMac, IPv4Address.of(arpRequest.getTargetProtocolAddress()), MacAddress.of(arpRequest.getSenderHardwareAddress()), IPv4Address.of(arpRequest.getSenderProtocolAddress()), sw, pi.getMatch().get(MatchField.IN_PORT));
        }
        else {
            arpRequestBuffer.addRequest(arpRequest);
            for (DatapathId swi : switchService.getAllSwitchDpids())
                floodArpRequest(switchService.getSwitch(swi),IPv4Address.of(arpRequest.getTargetProtocolAddress()));
        }
    }
}
项目:fresco_floodlight    文件:FP_FloodlightRTE.java   
@Override
public Collection<Class<? extends IFloodlightService>> getModuleDependencies() {
     Collection<Class<? extends IFloodlightService>> l =
                new ArrayList<Class<? extends IFloodlightService>>();
        l.add(IFloodlightProviderService.class);
        return l;
}
项目:iTAP-controller    文件:ObfuscationController.java   
@Override
public Collection<Class<? extends IFloodlightService>> getModuleDependencies() {
    Collection<Class<? extends IFloodlightService>> l = new ArrayList<Class<? extends IFloodlightService>>();
    l.add(IFloodlightProviderService.class);
    l.add(IObfuscationSwitchStateManager.class);
    l.add(IObfuscationLinkStateManager.class);
    l.add(IObfuscationRoutingService.class);
    l.add(IObfuscationMaskManager.class);
    l.add(ILinkDiscoveryService.class);
    l.add(IOFSwitchService.class);
    return l;
}
项目:fresco_floodlight    文件:PktInProcessingTime.java   
@Override
public void init(FloodlightModuleContext context)
                                         throws FloodlightModuleException {
    floodlightProvider = context
            .getServiceImpl(IFloodlightProviderService.class);
    restApi = context.getServiceImpl(IRestApiService.class);
}
项目:fresco_floodlight    文件:DeviceManagerImpl.java   
@Override
public Collection<Class<? extends IFloodlightService>> getModuleDependencies() {
    Collection<Class<? extends IFloodlightService>> l =
            new ArrayList<Class<? extends IFloodlightService>>();
    l.add(IFloodlightProviderService.class);
    l.add(IStorageSourceService.class);
    l.add(ITopologyService.class);
    l.add(IRestApiService.class);
    l.add(IThreadPoolService.class);
    l.add(IEntityClassifierService.class);
    l.add(ISyncService.class);
    return l;
}
项目:fresco_floodlight    文件:Hub.java   
@Override
public Collection<Class<? extends IFloodlightService>>
        getModuleDependencies() {
    Collection<Class<? extends IFloodlightService>> l = 
            new ArrayList<Class<? extends IFloodlightService>>();
    l.add(IFloodlightProviderService.class);
    return l;
}
项目:iTAP-controller    文件:LinkDiscoveryManager.java   
@Override
public Collection<Class<? extends IFloodlightService>> getModuleDependencies() {
    Collection<Class<? extends IFloodlightService>> l =
            new ArrayList<Class<? extends IFloodlightService>>();
    l.add(IFloodlightProviderService.class);
    l.add(IStorageSourceService.class);
    l.add(IThreadPoolService.class);
    l.add(IRestApiService.class);
    l.add(IShutdownService.class);
    return l;
}