- // Hub implementation
- if (function.equals("hub")) {
- floodPacket(inPkt);
- return PacketResult.CONSUME;
- }
-
- // Switch
- else {
- long srcMAC_val = BitBufferHelper.toNumber(srcMAC);
- long dstMAC_val = BitBufferHelper.toNumber(dstMAC);
-
- Match match = new Match();
- match.setField( new MatchField(MatchType.IN_PORT, incoming_connector) );
- match.setField( new MatchField(MatchType.DL_DST, dstMAC.clone()) );
-
- // Set up the mapping: switch -> src MAC address -> incoming port
- if (this.mac_to_ports.get(incoming_node) == null) {
- this.mac_to_ports.put(incoming_node, new HashMap<Long, NodeConnector>());
- logger.info("Added new node = {} to mac_to_ports", incoming_node);
- }
-
- // Only replace if we don't know the mapping. This
- // saves us from over-writing correct mappings with
- // incorrect ones we get during flooding.
- //
- // TODO: this should never happen..
- if (this.mac_to_ports.get(incoming_node).get(srcMAC_val) == null) {
- this.mac_to_ports.get(incoming_node).put(srcMAC_val, incoming_connector);
- logger.info("Added new learned MAC = {} on incoming connector = {} to mac_to_ports", srcMAC_val, incoming_connector);
- }
-
- NodeConnector dst_connector = this.mac_to_ports.get(incoming_node).get(dstMAC_val);
-
- // Do I know the destination MAC?
- if (dst_connector != null) {
-
- List<Action> actions = new ArrayList<Action>();
- actions.add(new Output(dst_connector));