Пример #1
0
void configure_wimax(void)
{
	char *mode = "0";
	char *dev = "ofdm";

	if (nvram_match("ofdm_duplex", "TDD"))
		mode = "0";
	if (nvram_match("ofdm_duplex", "H-FDD"))
		mode = "1";
	if (nvram_match("ofdm_mode", "disabled"))
		return;
	char width[32];

	sprintf(width, "%smhz", nvram_safe_get("ofdm_width"));
	eval("/sub/lm_scripts/go_ss", width, "0", mode);
	if (!nvram_match("ofdm_mode", "sta")) {
		char bridged[32];

		sprintf(bridged, "%s_bridged", dev);
		if (nvram_default_match(bridged, "1", "1")) {
			eval("ifconfig", dev, "0.0.0.0", "up");
			br_add_interface(getBridge(dev), dev);
			eval("ifconfig", dev, "0.0.0.0", "up");
		} else {
			eval("ifconfig", dev, nvram_nget("%s_ipaddr", dev), "netmask", nvram_nget("%s_netmask", dev), "up");
		}
	} else {
		char bridged[32];

		sprintf(bridged, "%s_bridged", dev);
		if (nvram_default_match(bridged, "0", "1")) {
			eval("ifconfig", dev, nvram_nget("%s_ipaddr", dev), "netmask", nvram_nget("%s_netmask", dev), "up");
		}
	}
}
bool MovementAdapterWorkerDiscrete::injectMouseMove(const MouseMotion& motion, bool& freezeMouse)
{
	//this will move the entity instead of the mouse

	Vector<3> direction;
	direction.zero();
	direction.x() = -motion.xRelativeMovement;
	direction.y() = motion.yRelativeMovement;
	direction = direction * mMovementSpeed;
	//hard coded to allow the shift button to increase the speed
	// 	if (Input::getSingleton().isKeyDown(SDLK_RSHIFT) || Input::getSingleton().isKeyDown(SDLK_LSHIFT)) {
	// 		direction = direction * 5;
	// 	}

	Quaternion orientation = Convert::toWF(getCamera().getOrientation());

	//We need to constraint the orientation to only around the z axis.
	WFMath::Vector<3> rotator(1.0, 0.0, 0.0);
	rotator.rotate(orientation);
	WFMath::Quaternion adjustedOrientation;
	adjustedOrientation.fromRotMatrix(WFMath::RotMatrix<3>().rotationZ(atan2(rotator.y(), rotator.x())));

	orientation = adjustedOrientation;

	//move it relative to the camera
	direction = direction.rotate(orientation);

	getBridge()->move(direction);//move the entity a fixed distance for each mouse movement.

	//we don't want to move the cursor
	freezeMouse = true;

	return false;

}
void MovementAdapterWorkerTerrainCursor::updatePosition(bool forceUpdate)
{
	const Ogre::Vector3* position(0);
	if (getCamera().getTerrainCursor().getTerrainCursorPosition(&position) || forceUpdate) {
		getBridge()->setPosition(Convert::toWF<WFMath::Point<3>>(*position));
	}
}
Пример #4
0
 void View::drawAsChild()
 {
     getBridge().setTransform(getRootTransform());
     draw();
 }
Пример #5
0
void setupSupplicant(char *prefix)
{
	char akm[16];

	sprintf(akm, "%s_akm", prefix);
	char wmode[16];

	sprintf(wmode, "%s_mode", prefix);
	if (nvram_match(akm, "wep")) {
		char key[16];
		int cnt = 1;
		int i;
		char bul[8];

		for (i = 1; i < 5; i++) {
			sprintf(key, "%s_key%d", prefix, i);
			char *athkey = nvram_safe_get(key);

			if (athkey != NULL && strlen(athkey) > 0) {
				sprintf(bul, "[%d]", cnt++);
				eval("iwconfig", prefix, "key", bul, athkey);	// setup wep
				// encryption 
				// key
			}
		}
		sprintf(key, "%s_key", prefix);
		sprintf(bul, "[%s]", nvram_safe_get(key));
		eval("iwconfig", prefix, "key", bul);
		// eval ("iwpriv", prefix, "authmode", "2");
	} else if (nvram_match(akm, "psk") || nvram_match(akm, "psk2") || nvram_match(akm, "psk psk2")) {
		char fstr[64];
		char psk[16];

		sprintf(fstr, "/tmp/%s_wpa_supplicant.conf", prefix);
		FILE *fp = fopen(fstr, "wb");

#ifdef HAVE_MAKSAT
		fprintf(fp, "ap_scan=1\n");
#elif HAVE_NEWMEDIA
		fprintf(fp, "ap_scan=1\n");
#else
		fprintf(fp, "ap_scan=2\n");
#endif
		fprintf(fp, "fast_reauth=1\n");
		fprintf(fp, "eapol_version=1\n");
		// fprintf (fp, "ctrl_interface_group=0\n");
		// fprintf (fp, "ctrl_interface=/var/run/wpa_supplicant\n");

		fprintf(fp, "network={\n");
		sprintf(psk, "%s_ssid", prefix);
		fprintf(fp, "\tssid=\"%s\"\n", nvram_safe_get(psk));
		// fprintf (fp, "\tmode=0\n");
		fprintf(fp, "\tscan_ssid=1\n");
		fprintf(fp, "\tkey_mgmt=WPA-PSK\n");

		sprintf(psk, "%s_crypto", prefix);
		if (nvram_match(psk, "aes")) {
#if 1
			fprintf(fp, "\tpairwise=CCMP\n");
			fprintf(fp, "\tgroup=CCMP TKIP\n");
#else
			fprintf(fp, "\tpairwise=CCMP\n");
			fprintf(fp, "\tgroup=CCMP\n");
#endif
		}
		if (nvram_match(psk, "tkip")) {
			fprintf(fp, "\tpairwise=TKIP\n");
			fprintf(fp, "\tgroup=TKIP\n");
		}
		if (nvram_match(psk, "tkip+aes")) {
			fprintf(fp, "\tpairwise=CCMP TKIP\n");
			fprintf(fp, "\tgroup=CCMP TKIP\n");
		}
		if (nvram_match(akm, "psk"))
			fprintf(fp, "\tproto=WPA\n");
		if (nvram_match(akm, "psk2"))
			fprintf(fp, "\tproto=RSN\n");
		if (nvram_match(akm, "psk psk2"))
			fprintf(fp, "\tproto=WPA RSN\n");

		sprintf(psk, "%s_wpa_psk", prefix);
		fprintf(fp, "\tpsk=\"%s\"\n", nvram_safe_get(psk));
		fprintf(fp, "}\n");
		fclose(fp);
		if (!strcmp(prefix, "wl0"))
			sprintf(psk, "-i%s", nvram_safe_get("wl0_ifname"));
		else if (!strcmp(prefix, "wl1"))
			sprintf(psk, "-i%s", nvram_safe_get("wl1_ifname"));
		else
			sprintf(psk, "-i%s", prefix);

		if (nvram_match(wmode, "wdssta") || nvram_match(wmode, "wet"))
			eval("wpa_supplicant", "-b", getBridge(prefix), "-B", "-Dwext", psk, "-c", fstr);
		else
			eval("wpa_supplicant", "-B", "-Dwext", psk, "-c", fstr);
	} else if (nvram_match(akm, "8021X")) {
		char fstr[32];
		char psk[64];
		char ath[64];

		sprintf(fstr, "/tmp/%s_wpa_supplicant.conf", prefix);
		FILE *fp = fopen(fstr, "wb");

		fprintf(fp, "ap_scan=1\n");
		fprintf(fp, "fast_reauth=1\n");
		fprintf(fp, "eapol_version=1\n");
		// fprintf (fp, "ctrl_interface_group=0\n");
		// fprintf (fp, "ctrl_interface=/var/run/wpa_supplicant\n");
		fprintf(fp, "network={\n");
		sprintf(psk, "%s_ssid", prefix);
		fprintf(fp, "\tssid=\"%s\"\n", nvram_safe_get(psk));
		fprintf(fp, "\tscan_ssid=1\n");
		if (nvram_prefix_match("8021xtype", prefix, "tls")) {
// -> added habeIchVergessen
			char *keyExchng = nvram_nget("%s_tls8021xkeyxchng", prefix);
			char *wpaOpts[40];
			if (strlen(keyExchng) == 0)
				nvram_nset("wep", "%s_tls8021xkeyxchng", prefix);
			sprintf(wpaOpts, "");
			keyExchng = nvram_nget("%s_tls8021xkeyxchng", prefix);
			if (strcmp("wpa2", keyExchng) == 0)
				sprintf(wpaOpts, "\tpairwise=CCMP\n\tgroup=CCMP\n");
			if (strcmp("wpa2mixed", keyExchng) == 0)
				sprintf(wpaOpts, "\tpairwise=CCMP TKIP\n\tgroup=CCMP TKIP\n");
			if (strcmp("wpa", keyExchng) == 0)
				sprintf(wpaOpts, "\tpairwise=TKIP\n\tgroup=TKIP\n");
			fprintf(fp, "\tkey_mgmt=%s\n%s", (strlen(wpaOpts) == 0 ? "IEEE8021X" : "WPA-EAP"), wpaOpts);
// <- added habeIchVergessen
			fprintf(fp, "\teap=TLS\n");
			fprintf(fp, "\tidentity=\"%s\"\n", nvram_prefix_get("tls8021xuser", prefix));
			sprintf(psk, "/tmp/%s", prefix);
			mkdir(psk, 0700);
			sprintf(psk, "/tmp/%s/ca.pem", prefix);
			sprintf(ath, "%s_tls8021xca", prefix);
			write_nvram(psk, ath);
			sprintf(psk, "/tmp/%s/user.pem", prefix);
			sprintf(ath, "%s_tls8021xpem", prefix);
			write_nvram(psk, ath);

			sprintf(psk, "/tmp/%s/user.prv", prefix);
			sprintf(ath, "%s_tls8021xprv", prefix);
			write_nvram(psk, ath);
			fprintf(fp, "\tca_cert=/tmp/%s/ca.pem\n", prefix);
			fprintf(fp, "\tclient_cert=/tmp/%s/user.pem\n", prefix);
			fprintf(fp, "\tprivate_key=/tmp/%s/user.prv\n", prefix);
			fprintf(fp, "\tprivate_key_passwd=\"%s\"\n", nvram_prefix_get("tls8021xpasswd", prefix));
			fprintf(fp, "\teapol_flags=3\n");
			if (strlen(nvram_nget("%s_tls8021xphase2", prefix)) > 0) {
				fprintf(fp, "\tphase2=\"%s\"\n", nvram_nget("%s_tls8021xphase2", prefix));
			}
			if (strlen(nvram_nget("%s_tls8021xanon", prefix)) > 0) {
				fprintf(fp, "\tanonymous_identity=\"%s\"\n", nvram_nget("%s_tls8021xanon", prefix));
			}
			if (strlen(nvram_nget("%s_tls8021xaddopt", prefix)) > 0) {
				sprintf(ath, "%s_tls8021xaddopt", prefix);
				fprintf(fp, "\t");	// tab
				fwritenvram(ath, fp);
				fprintf(fp, "\n");	// extra new line at the end
			}
		}
		if (nvram_prefix_match("8021xtype", prefix, "peap")) {
			fprintf(fp, "\tkey_mgmt=WPA-EAP\n");
			fprintf(fp, "\teap=PEAP\n");
			fprintf(fp, "\tpairwise=CCMP TKIP\n");
			fprintf(fp, "\tgroup=CCMP TKIP\n");
			fprintf(fp, "\tphase1=\"peapver=0\"\n");
			fprintf(fp, "\tidentity=\"%s\"\n", nvram_prefix_get("peap8021xuser", prefix));
			fprintf(fp, "\tpassword=\"%s\"\n", nvram_prefix_get("peap8021xpasswd", prefix));
			sprintf(psk, "/tmp/%s", prefix);
			mkdir(psk, 0700);
			sprintf(psk, "/tmp/%s/ca.pem", prefix);
			sprintf(ath, "%s_peap8021xca", prefix);
			if (!nvram_match(ath, "")) {
				write_nvram(psk, ath);
				fprintf(fp, "\tca_cert=\"/tmp/%s/ca.pem\"\n", prefix);
			}
			if (strlen(nvram_nget("%s_peap8021xphase2", prefix)) > 0) {
				fprintf(fp, "\tphase2=\"%s\"\n", nvram_nget("%s_peap8021xphase2", prefix));
			}
			if (strlen(nvram_nget("%s_peap8021xanon", prefix)) > 0) {
				fprintf(fp, "\tanonymous_identity=\"%s\"\n", nvram_nget("%s_peap8021xanon", prefix));
			}
			if (strlen(nvram_nget("%s_peap8021xaddopt", prefix)) > 0) {
				sprintf(ath, "%s_peap8021xaddopt", prefix);
				fprintf(fp, "\t");	// tab
				fwritenvram(ath, fp);
				fprintf(fp, "\n");	// extra new line at the end
			}
		}
		if (nvram_prefix_match("8021xtype", prefix, "ttls")) {
			fprintf(fp, "\tkey_mgmt=WPA-EAP\n");
			fprintf(fp, "\teap=TTLS\n");
			fprintf(fp, "\tpairwise=CCMP TKIP\n");
			fprintf(fp, "\tgroup=CCMP TKIP\n");
			fprintf(fp, "\tidentity=\"%s\"\n", nvram_prefix_get("ttls8021xuser", prefix));
			fprintf(fp, "\tpassword=\"%s\"\n", nvram_prefix_get("ttls8021xpasswd", prefix));
			if (strlen(nvram_nget("%s_ttls8021xca", prefix)) > 0) {
				sprintf(psk, "/tmp/%s", prefix);
				mkdir(psk, 0700);
				sprintf(psk, "/tmp/%s/ca.pem", prefix);
				sprintf(ath, "%s_ttls8021xca", prefix);
				write_nvram(psk, ath);
				fprintf(fp, "\tca_cert=\"/tmp/%s/ca.pem\"\n", prefix);
			}
			if (strlen(nvram_nget("%s_ttls8021xphase2", prefix)) > 0) {
				fprintf(fp, "\tphase2=\"%s\"\n", nvram_nget("%s_ttls8021xphase2", prefix));
			}
			if (strlen(nvram_nget("%s_ttls8021xanon", prefix)) > 0) {
				fprintf(fp, "\tanonymous_identity=\"%s\"\n", nvram_nget("%s_ttls8021xanon", prefix));
			}
			if (strlen(nvram_nget("%s_ttls8021xaddopt", prefix)) > 0) {
				sprintf(ath, "%s_ttls8021xaddopt", prefix);
				fprintf(fp, "\t");	// tab
				fwritenvram(ath, fp);
				fprintf(fp, "\n");	// extra new line at the end
			}
		}
		if (nvram_prefix_match("8021xtype", prefix, "leap")) {
			fprintf(fp, "\tkey_mgmt=WPA-EAP\n");
			fprintf(fp, "\teap=LEAP\n");
			fprintf(fp, "\tauth_alg=LEAP\n");
			fprintf(fp, "\tproto=WPA RSN\n");
			fprintf(fp, "\tpairwise=CCMP TKIP\n");
			fprintf(fp, "\tgroup=CCMP TKIP\n");
			fprintf(fp, "\tidentity=\"%s\"\n", nvram_prefix_get("leap8021xuser", prefix));
			fprintf(fp, "\tpassword=\"%s\"\n", nvram_prefix_get("leap8021xpasswd", prefix));
			if (strlen(nvram_nget("%s_leap8021xphase2", prefix)) > 0) {
				fprintf(fp, "\tphase2=\"%s\"\n", nvram_nget("%s_leap8021xphase2", prefix));
			}
			if (strlen(nvram_nget("%s_leap8021xanon", prefix)) > 0) {
				fprintf(fp, "\tanonymous_identity=\"%s\"\n", nvram_nget("%s_leap8021xanon", prefix));
			}
			if (strlen(nvram_nget("%s_leap8021xaddopt", prefix)) > 0) {
				sprintf(ath, "%s_leap8021xaddopt", prefix);
				fprintf(fp, "\t");	// tab
				fwritenvram(ath, fp);
				fprintf(fp, "\n");	// extra new line at the end
			}
		}

		fprintf(fp, "}\n");
		fclose(fp);
		if (!strcmp(prefix, "wl0"))
			sprintf(psk, "-i%s", nvram_safe_get("wl0_ifname"));
		else if (!strcmp(prefix, "wl1"))
			sprintf(psk, "-i%s", nvram_safe_get("wl1_ifname"));
		else
			sprintf(psk, "-i%s", prefix);

		char bvar[32];

		sprintf(bvar, "%s_bridged", prefix);
		if (nvram_match(bvar, "1")
		    && (nvram_match(wmode, "wdssta")
			|| nvram_match(wmode, "wet")))
			eval("wpa_supplicant", "-b", nvram_safe_get("lan_ifname"), "-B", "-Dwext", psk, "-c", fstr);
		else
			eval("wpa_supplicant", "-B", "-Dwext", psk, "-c", fstr);
	} else {
		eval("iwconfig", prefix, "key", "off");
		// eval ("iwpriv", prefix, "authmode", "0");
	}

}
Пример #6
0
void writeMatchDOT(
		ostream & s, 
		HashGraph * G1, 
		OrthologInfoList* pOrthinfolist1, 
		int** D1, 
		HashGraph * G2, 
		OrthologInfoList* pOrthinfolist2, 
		int** D2, 
		GraphMatch & M
		)
{
	s<<"graph G {\n";
	//the query graph
	s<<"\tsubgraph cluster0 {\n";
	s<<"\t\tlabel=\"query: "<<G1->getGraphAttrs()->find("name")->second.value<<"\";\n";
	s<<"\t\tcolor=blue;\n";
	
	NodeMappingSet::iterator iter, iter1, iter2;
	
	hash_set<int> qnmset, dbnmset;
	
	for(iter=M.mappings.begin(); iter!=M.mappings.end(); iter++)
	{
		qnmset.insert(iter->source);
		dbnmset.insert(iter->target);
	}
	
	for(int i=0; i<G1->n(); i++)
	{
		if(qnmset.find(i)!=qnmset.end())
			s<< "\t\tq"<<i<<" [label=\""<<G1->getNodeAttrs(i)->find("name")->second.value<<"\" shape=box style=filled fillcolor=lightblue color=blue];\n";
		else
			s<< "\t\tq"<<i<<" [label=\""<<G1->getNodeAttrs(i)->find("name")->second.value<<"\" shape=box];\n";
	}
	
	char arrow[3];
	strcpy(arrow, "--");
	
	//non-important edges
	for(int i=0; i<G1->n(); i++)
		for(int j=i+1; j<G1->n(); j++)
		{
			if(G1->isEdge(i,j) && (qnmset.find(i)==qnmset.end() || qnmset.find(j)==qnmset.end()) )
			{
				s<< "\t\tq"<<i<<" "<<arrow<<" q"<<j<<";\n";
			}
		}
	
	//important edges
	for(iter1=M.mappings.begin(); iter1!=M.mappings.end(); iter1++)
	{
		iter2=iter1;
		iter2++;
		for(; iter2!=M.mappings.end(); iter2++)
		{
			if(G1->isEdge(iter1->source, iter2->source))
			{ 
				if(G2->isEdge(iter1->target, iter2->target))
					s<< "\t\tq"<<iter1->source<<" "<<arrow<<" q"<<iter2->source<<" [style=\"bold\" color=blue];\n";
				else
					s<< "\t\tq"<<iter1->source<<" "<<arrow<<" q"<<iter2->source<<";\n";
			}
		}
	}
	
	s<< "\t}\n";
	//the database graph
		
	s<< "\tsubgraph cluster1 {\n";
	
	s<< "\t\tlabel=\"DB graph: "<<G2->getGraphAttrs()->find("name")->second.value<<"\";\n";
	
	s<< "\t\tcolor=blue;\n";
	
	set<int> vset;
	set<int>::iterator p1, p2;
	for(iter1=M.mappings.begin(); iter1!=M.mappings.end(); iter1++)
	{
		iter2=iter1;
		iter2++;
		for(; iter2!=M.mappings.end(); iter2++)
		{
			int dist=D2[iter1->target][iter2->target];
			getBridge(G2, iter1->target, iter2->target, dist, vset);
		}
	}
	
	set<int> another(vset);

	//db graph vertices
	vector<string> nodes;
	for(iter=M.mappings.begin(); iter!=M.mappings.end(); iter++)
	{
		another.erase(iter->target);
		s<< "\t\tdb"<<iter->target<<" [label=\""<<G2->getNodeAttrs(iter->source)->find("name")->second.value
			<<"\" shape=box style=filled fillcolor=lightblue color=blue];\n";
			
	}

		
	for(p1=another.begin(); p1!=another.end(); p1++)
	{
		s<< "\t\tdb"<< (*p1)<<" [label=\""<<G2->getNodeAttrs(iter->source)->find("name")->second.value<<"\" shape=box];\n";
	}
	//non important edges
	for(p1=vset.begin(); p1!=vset.end(); p1++)
	{
		p2=p1;
		p2++;
		for(; p2!=vset.end(); p2++)
		{
			if( (dbnmset.find((*p1))==dbnmset.end() || dbnmset.find((*p2))==dbnmset.end()) && G2->isEdge((*p1), (*p2)))
			{
				
				s<< "\t\tdb"<<(*p1)<<" "<<arrow<<" db"<<(*p2)<<";\n";
			}
		}
	}
	
	
	//important edges
	for(iter1=M.mappings.begin(); iter1!=M.mappings.end(); iter1++)
	{
		iter2=iter1;
		iter2++;
		for(; iter2!=M.mappings.end(); iter2++)
		{
			if(G2->isEdge(iter1->target, iter2->target))
			{
				if(G1->isEdge(iter1->source,iter2->source))
				{
					s<< "\t\tdb"<<iter1->target<<" "<<arrow<<" db"<<iter2->target<<" [style=\"bold\" color=blue];\n";
				}
				else
				{
					s<< "\t\tdb"<<iter1->target<<" "<<arrow<<" db"<<iter2->target<<";\n";
				}
			}
		}
	}
	
	s<< "\t}\n";

	//emphasize the mapping
	for(iter=M.mappings.begin(); iter!=M.mappings.end(); iter++)
		s<< "\tq"<<iter->source<<" -- db"<<iter->target<<" [color=red]\n";
	s<< "}\n";	
}
Пример #7
0
/* Collect information about networks */
int xenstat_collect_networks(xenstat_node * node)
{
	/* Helper variables for parseNetDevLine() function defined above */
	int i;
	char line[512] = { 0 }, iface[16] = { 0 }, devBridge[16] = { 0 }, devNoBridge[16] = { 0 };
	unsigned long long rxBytes, rxPackets, rxErrs, rxDrops, txBytes, txPackets, txErrs, txDrops;

	struct priv_data *priv = get_priv_data(node->handle);

	if (priv == NULL) {
		perror("Allocation error");
		return 0;
	}

	/* Open and validate /proc/net/dev if we haven't already */
	if (priv->procnetdev == NULL) {
		char header[sizeof(PROCNETDEV_HEADER)];
		priv->procnetdev = fopen("/proc/net/dev", "r");
		if (priv->procnetdev == NULL) {
			perror("Error opening /proc/net/dev");
			return 0;
		}

		/* Validate the format of /proc/net/dev */
		if (fread(header, sizeof(PROCNETDEV_HEADER) - 1, 1,
			  priv->procnetdev) != 1) {
			perror("Error reading /proc/net/dev header");
			return 0;
		}
		header[sizeof(PROCNETDEV_HEADER) - 1] = '\0';
		if (strcmp(header, PROCNETDEV_HEADER) != 0) {
			fprintf(stderr,
				"Unexpected /proc/net/dev format\n");
			return 0;
		}
	}

	/* Fill in networks */
	/* FIXME: optimize this */
	fseek(priv->procnetdev, sizeof(PROCNETDEV_HEADER) - 1,
	      SEEK_SET);

	/* We get the bridge devices for use with bonding interface to get bonding interface stats */
	getBridge("vir", devBridge, sizeof(devBridge));
	snprintf(devNoBridge, 16, "p%s", devBridge);

	while (fgets(line, 512, priv->procnetdev)) {
		xenstat_domain *domain;
		xenstat_network net;
		unsigned int domid;

		parseNetDevLine(line, iface, &rxBytes, &rxPackets, &rxErrs, &rxDrops, NULL, NULL, NULL,
				NULL, &txBytes, &txPackets, &txErrs, &txDrops, NULL, NULL, NULL, NULL);

		/* If the device parsed is network bridge and both tx & rx packets are zero, we are most */
		/* likely using bonding so we alter the configuration for dom0 to have bridge stats */
		if ((strstr(iface, devBridge) != NULL) &&
		    (strstr(iface, devNoBridge) == NULL) &&
		    ((domain = xenstat_node_domain(node, 0)) != NULL)) {
			for (i = 0; i < domain->num_networks; i++) {
				if ((domain->networks[i].id != 0) ||
				    (domain->networks[i].tbytes != 0) ||
				    (domain->networks[i].rbytes != 0))
					continue;
				domain->networks[i].tbytes = txBytes;
				domain->networks[i].tpackets = txPackets;
				domain->networks[i].terrs = txErrs;
				domain->networks[i].tdrop = txDrops;
				domain->networks[i].rbytes = rxBytes;
				domain->networks[i].rpackets = rxPackets;
				domain->networks[i].rerrs = rxErrs;
				domain->networks[i].rdrop = rxDrops;
			}
		}
		else /* Otherwise we need to preserve old behaviour */
		if (get_iface_domid_network(iface, &domid, &net.id)) {

			net.tbytes = txBytes;
			net.tpackets = txPackets;
			net.terrs = txErrs;
			net.tdrop = txDrops;
			net.rbytes = rxBytes;
			net.rpackets = rxPackets;
			net.rerrs = rxErrs;
			net.rdrop = rxDrops;

		/* FIXME: this does a search for the domid */
		  domain = xenstat_node_domain(node, domid);
		  if (domain == NULL) {
			fprintf(stderr,
				"Found interface vif%u.%u but domain %u"
				" does not exist.\n", domid, net.id,
				domid);
			continue;
		  }
		  if (domain->networks == NULL) {
			domain->num_networks = 1;
			domain->networks = malloc(sizeof(xenstat_network));
		  } else {
			struct xenstat_network *tmp;
			domain->num_networks++;
			tmp = realloc(domain->networks,
				      domain->num_networks *
				      sizeof(xenstat_network));
			if (tmp == NULL)
				free(domain->networks);
			domain->networks = tmp;
		  }
		  if (domain->networks == NULL)
			return 0;
		  domain->networks[domain->num_networks - 1] = net;
          }
        }

	return 1;
}