Java Code Examples for net.floodlightcontroller.core.IFloodlightProviderService

The following are top voted examples for showing how to use net.floodlightcontroller.core.IFloodlightProviderService. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: iTAP-controller   File: TopologyManager.java   View source code 6 votes vote down vote up
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);
	}
}
 
Example 2
Project: iTAP-controller   File: TopologyManager.java   View source code 6 votes vote down vote up
@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();
}
 
Example 3
Project: open-kilda   File: PathVerificationFlowTest.java   View source code 6 votes vote down vote up
@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();
}
 
Example 4
Project: iTAP-controller   File: LoadBalancer.java   View source code 6 votes vote down vote up
@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;
}
 
Example 5
Project: fresco_floodlight   File: MockFloodlightProvider.java   View source code 6 votes vote down vote up
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);
  }
 
Example 6
Project: fresco_floodlight   File: FP_LibFloodlight.java   View source code 6 votes vote down vote up
@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;
	
}
 
Example 7
Project: fresco_floodlight   File: FP_LibFloodlight.java   View source code 6 votes vote down vote up
@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;
	
}
 
Example 8
Project: fresco_floodlight   File: FP_LibFloodlight.java   View source code 6 votes vote down vote up
@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;
}
 
Example 9
Project: iTAP-controller   File: FlowReconcileManager.java   View source code 6 votes vote down vote up
@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);
}
 
Example 10
Project: iTAP-controller   File: VirtualNetworkFilter.java   View source code 6 votes vote down vote up
@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();

}
 
Example 11
Project: iTAP-controller   File: ObfuscationTopologyManager.java   View source code 6 votes vote down vote up
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)));
			}
		}
	}
}
 
Example 12
Project: fresco_floodlight   File: TopologyManager.java   View source code 6 votes vote down vote up
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);
	}
}
 
Example 13
Project: fresco_floodlight   File: TopologyInstanceTest.java   View source code 6 votes vote down vote up
@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);
}
 
Example 14
Project: floodlight-simple-multicast   File: Multicast.java   View source code 5 votes vote down vote up
@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;
}
 
Example 15
Project: floodlight-simple-multicast   File: Multicast.java   View source code 5 votes vote down vote up
@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");
}
 
Example 16
Project: open-kilda   File: SwitchManager.java   View source code 5 votes vote down vote up
/**
 * {@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;
}
 
Example 17
Project: iTAP-controller   File: VirtualNetworkFilterTest.java   View source code 5 votes vote down vote up
@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);
}
 
Example 18
Project: open-kilda   File: PathVerificationService.java   View source code 5 votes vote down vote up
@VisibleForTesting
void initServices(FloodlightModuleContext context)
{
    floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
    switchService = context.getServiceImpl(IOFSwitchService.class);
    restApiService = context.getServiceImpl(IRestApiService.class);
}
 
Example 19
Project: iTAP-controller   File: PortDownReconciliation.java   View source code 5 votes vote down vote up
@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;
}
 
Example 20
Project: open-kilda   File: PathVerificationPacketSignTest.java   View source code 5 votes vote down vote up
@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);
}
 
Example 21
Project: open-kilda   File: PathVerificationPacketSignTest.java   View source code 5 votes vote down vote up
@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);
}
 
Example 22
Project: open-kilda   File: PathVerificationPacketOutTest.java   View source code 5 votes vote down vote up
@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);
}
 
Example 23
Project: iTAP-controller   File: FirewallTest.java   View source code 5 votes vote down vote up
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);
}
 
Example 24
Project: open-kilda   File: MockFloodlightProvider.java   View source code 5 votes vote down vote up
@Override
public Collection<Class<? extends IFloodlightService>> getModuleServices() {
    Collection<Class<? extends IFloodlightService>> services =
            new ArrayList<Class<? extends IFloodlightService>>(1);
    services.add(IFloodlightProviderService.class);
    return services;
}
 
Example 25
Project: iTAP-controller   File: ObfuscationSwitchStateManager.java   View source code 5 votes vote down vote up
@Override
public void init(FloodlightModuleContext context)
		throws FloodlightModuleException {
	floodlightProvider = context .getServiceImpl(IFloodlightProviderService.class);
	switchStates = new HashMap<IOFSwitch,ObfuscationSwitchState>();
	oMaskManager = context.getServiceImpl(IObfuscationMaskManager.class);
	
}
 
Example 26
Project: fresco_floodlight   File: testSecurityKernel.java   View source code 5 votes vote down vote up
@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;
}
 
Example 27
Project: fresco_floodlight   File: FP_LibFloodlight.java   View source code 5 votes vote down vote up
@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;
	}
}
 
Example 28
Project: fresco_floodlight   File: FP_LibFloodlight.java   View source code 5 votes vote down vote up
@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;
	}
}
 
Example 29
Project: iTAP-controller   File: DeviceManagerImpl.java   View source code 5 votes vote down vote up
@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());
}
 
Example 30
Project: iTAP-controller   File: LearningSwitch.java   View source code 5 votes vote down vote up
@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);
}
 
Example 31
Project: iTAP-controller   File: SystemUptimeResource.java   View source code 5 votes vote down vote up
@Get("json")
public UptimeRest retrieve() {
    IFloodlightProviderService floodlightProvider =
        (IFloodlightProviderService)getContext().getAttributes().
        get(IFloodlightProviderService.class.getCanonicalName());

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

    return (uptime);
}
 
Example 32
Project: fresco_floodlight   File: FP_LibFloodlight.java   View source code 5 votes vote down vote up
@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;
	}
}
 
Example 33
Project: iTAP-controller   File: VirtualNetworkFilterTest.java   View source code 5 votes vote down vote up
@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);
}
 
Example 34
Project: iTAP-controller   File: ObfuscationController.java   View source code 5 votes vote down vote up
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()));
		}
	}
}
 
Example 35
Project: fresco_floodlight   File: FP_FloodlightRTE.java   View source code 5 votes vote down vote up
@Override
public Collection<Class<? extends IFloodlightService>> getModuleDependencies() {
	 Collection<Class<? extends IFloodlightService>> l =
                new ArrayList<Class<? extends IFloodlightService>>();
        l.add(IFloodlightProviderService.class);
        return l;
}
 
Example 36
Project: iTAP-controller   File: ObfuscationController.java   View source code 5 votes vote down vote up
@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;
}
 
Example 37
Project: fresco_floodlight   File: PktInProcessingTime.java   View source code 5 votes vote down vote up
@Override
public void init(FloodlightModuleContext context)
                                         throws FloodlightModuleException {
	floodlightProvider = context
            .getServiceImpl(IFloodlightProviderService.class);
    restApi = context.getServiceImpl(IRestApiService.class);
}
 
Example 38
Project: fresco_floodlight   File: DeviceManagerImpl.java   View source code 5 votes vote down vote up
@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;
}
 
Example 39
Project: fresco_floodlight   File: Hub.java   View source code 5 votes vote down vote up
@Override
public Collection<Class<? extends IFloodlightService>>
        getModuleDependencies() {
    Collection<Class<? extends IFloodlightService>> l = 
            new ArrayList<Class<? extends IFloodlightService>>();
    l.add(IFloodlightProviderService.class);
    return l;
}
 
Example 40
Project: iTAP-controller   File: LinkDiscoveryManager.java   View source code 5 votes vote down vote up
@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;
}