class VirtualNetworkFilter implements IFloodlightModule, IVirtualNetworkService, IOFMessageListener {

	@Override
	public void createNetwork(String guid, String network, IPv4Address gateway) {
		if (log.isDebugEnabled()) {
			String gw = null;
			try {
				gw = gateway.toString();
			} catch (Exception e) {
				// fail silently
			}
			log.debug("Creating network {} with ID {} and gateway {}",
					new Object[] {network, guid, gw});
		}

		if (!nameToGuid.isEmpty()) {
			// We have to iterate all the networks to handle name/gateway changes
			for (Entry<String, String> entry : nameToGuid.entrySet()) {
				if (entry.getValue().equals(guid)) {
					nameToGuid.remove(entry.getKey());
					break;
				}
			}
		}
		if(network != null)
			nameToGuid.put(network, guid);
		if (vNetsByGuid.containsKey(guid))
			vNetsByGuid.get(guid).setName(network); //network already exists, just updating name
		else
			vNetsByGuid.put(guid, new VirtualNetwork(network, guid)); //new network

		// If they don't specify a new gateway the old one will be preserved
		if ((gateway != null) && (gateway.getInt() != 0)) {
			addGateway(guid, gateway);
			if (vNetsByGuid.get(guid) != null)
				vNetsByGuid.get(guid).setGateway(gateway.toString());
		}
	}

}