Exemple #1
0
  private static void printHubDetails(int indent, Device dev) {
    try {
      Hub h = new Hub(dev);
      int ports = h.getNumPorts();

      indentLine(indent, (h.isRootHub() ? "Root " : "") + "Hub, " + ports + " ports");
      indentLine(indent, "overcurrent protection: " + h.getOverCurrentMode());
      indentLine(indent, "power switching: " + h.getPowerSwitchingMode());
      if (h.isCompound()) indentLine(indent, "Part of a compound device");

      // not showing POTPGT, or hub's own current draw

      indent -= 4;
      indentLine(indent, "");
      for (int i = 1; i <= ports; i++) {
        Device child = dev.getChild(i);

        if (child == null) continue;

        indentLine(indent, "<!-- Port " + i + (h.isRemovable(i) ? "" : " is built-in.") + " -->");
        printDevice(indent, child);
      }

    } catch (IOException e) {
      e.printStackTrace(System.out);
    }
  }
Exemple #2
0
  public Context(Hub hub, IInjector injector) {
    _hub = hub;

    _injector = (injector != null ? injector : new Injector());

    _mediatorMap = new MediatorMap(_injector);

    _commandMap = new CommandMap(_injector);

    if (!_injector.hasClassMapping(Context.class)) _injector.mapClassInstance(Context.class, this);
    if (!_injector.hasClassMapping(this.getClass()))
      _injector.mapClassInstance(this.getClass(), this);

    if (!_injector.hasClassMapping(Hub.class)) _injector.mapClassInstance(Hub.class, _hub);
    if (!_injector.hasClassMapping(hub.getClass()))
      _injector.mapClassInstance(hub.getClass(), _hub);

    if (!_injector.hasClassMapping(IInjector.class))
      _injector.mapClassInstance(IInjector.class, _injector);
  }
Exemple #3
0
  @Before
  public void setUp() throws Exception {
    super.setUp();

    mockFloodlightProvider = getMockFloodlightProvider();
    hub = new Hub();
    mockFloodlightProvider.addOFMessageListener(OFType.PACKET_IN, hub);
    hub.setFloodlightProvider(mockFloodlightProvider);

    // Build our test packet
    this.testPacket =
        new Ethernet()
            .setDestinationMACAddress("00:11:22:33:44:55")
            .setSourceMACAddress("00:44:33:22:11:00")
            .setEtherType(Ethernet.TYPE_IPv4)
            .setPayload(
                new IPv4()
                    .setTtl((byte) 128)
                    .setSourceAddress("192.168.1.1")
                    .setDestinationAddress("192.168.1.2")
                    .setPayload(
                        new UDP()
                            .setSourcePort((short) 5000)
                            .setDestinationPort((short) 5001)
                            .setPayload(new Data(new byte[] {0x01}))));
    this.testPacketSerialized = testPacket.serialize();

    // Build the PacketIn
    this.packetIn =
        ((OFPacketIn) mockFloodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_IN))
            .setBufferId(-1)
            .setInPort((short) 1)
            .setPacketData(this.testPacketSerialized)
            .setReason(OFPacketInReason.NO_MATCH)
            .setTotalLength((short) this.testPacketSerialized.length);
  }