Esempio n. 1
0
SetUpRouters()
  {
   extern int macfilefind(), macfileprint(), macfilegetc(), macfileungetc(); 
   int macexit();
  
   add_router("macexit",60,NULL,NULL,NULL,NULL,macexit);
   add_router("macstdout",10,macfilefind,macfileprint,macfilegetc,macfileungetc,NULL);
  }    
Esempio n. 2
0
void init_routers(){
    Router proxyrt;
    proxyrt.preg = ".*";
    proxyrt.func = proxy_router;
    add_router(proxyrt);

    Router rewritert;
    rewritert.preg = ".*";
    rewritert.func = rewrite_router;
    add_router(rewritert);

    Router authrt;
    authrt.preg = ".*";
    authrt.func = auth_router;
    add_router(authrt);

    Router dirrt;
    dirrt.preg = ".*";
    dirrt.func = dir_router;
    add_router(dirrt);

    Router fastcgirt;
    fastcgirt.preg = "/([^/]+/)*[^/]+\\.php";
    fastcgirt.func = fastcgi_router;
    add_router(fastcgirt);

    //--- FILO
    Router httprt;
    httprt.preg = ".*";
    httprt.func = http_router;
    add_router(httprt);
    //---
}
Esempio n. 3
0
void findRoute(){
	printf("--------------start of findRoute--------------\n");
	int i;
	int j;
	int k;
	char father[256];
	int L[256];

	int LTable[256][256];

	char used[256];


	for (i=1; i<256; i++){
      for (j=i; j<256; j++){
	  	  LTable[i][j] = LTable[j][i]=1000000;
          if (neighborTable[i][j]<1000000){
             printf("%d->%d:%d    ",i,j,neighborTable[i][j]);
          }
		  if (neighborTable[j][i]<1000000){
             printf("%d->%d:%d",j,i,neighborTable[j][i]);
          }
		  if (neighborTable[i][j]<1000000 || neighborTable[j][i]<1000000){
		  	 printf("\n");
		  }
		  tmpTable[i][j] = tmpTable[j][i] = MAX(neighborTable[i][j],neighborTable[j][i]);
      }
 	}

	int minV,minI;
	
	//calculate the length of route from each my neighbor to others
	for (k=1; k<256; k++){
		if (neighborTable[HOSTID][k]<1000000){
			memset(used,0,sizeof(used));
			for(i=1;i<256;i++){
				father[i]=0;
				L[i]=1000000;
			}
			
			father[k]=k;
			L[k]=tmpTable[HOSTID][k];

	
			minV = 1;
			while( minV<1000000 ){
				minV = 1000000;
				for(i=1; i<256; i++){
					if(used[i]==0 && L[i]<minV){
						minV=L[i];
						minI=i;
					}
				}

				if(minV<1000000){
				  used[minI] = 1;
					for(i=1; i<256; i++){
						j = tmpTable[minI][i];
						if( j+minV < L[i] ){
							L[i] = j + minV;
							father[i] = father[minI];
						}
					}
				}
			}
			for(i=1;i<256;i++){
				LTable[k][i]=L[i];
			}
		}
	}

    //calculate the length of route from my to others
	memset(used,0,sizeof(used));
	for(i=1;i<256;i++){
		father[i]=0;
		L[i]=1000000;
	}
	for (k=1; k<256; k++){
		if (neighborTable[HOSTID][k]<1000000){
			father[k]=k;
			L[k]=tmpTable[HOSTID][k];
		}
	}
	minV = 1;
	while( minV<1000000 ){
		minV = 1000000;
		for(i=1; i<256; i++){
			if(used[i]==0 && L[i]<minV){
				minV=L[i];
				minI=i;
			}
		}

		if(minV<1000000){
		  used[minI] = 1;
			for(i=1; i<256; i++){
				j = tmpTable[minI][i];
				if( j+minV < L[i] ){
					L[i] = j + minV;
					father[i] = father[minI];
				}
			}
		}
	}
	
	
	for( i=1; i<256; i++){
		if(L[i]<1000000 && i!=HOSTID){
			j = get_gw(i);
			printf("%d---->%d father=%d L=%d\n",HOSTID,i,father[i],L[i]);
			if( (j==0) || ((j!=father[i]) && (LTable[j][i]+neighborTable[HOSTID][j])>(L[i]*1.4)) ){
				add_router(i, father[i]);
				//printf("after add_router\n");
			}
		}
	}
	printf("---------------End of findRoute---------------\n");
}
Esempio n. 4
0
void parse_routers()
{
        xmlDoc *doc = NULL;
        xmlNode *root_element = NULL;
        xmlNode *current = NULL;
        char* c;

	/*parse the file and get the DOM */
        doc = xmlReadFile(config_path, NULL, 0);	

	/*Get the root element node */
        root_element = xmlDocGetRootElement(doc);
        current = root_element->children;

	request ="/config_ndpmon/actions_low_pri/sendmail/text()";
	xmlobject = xmlXPathEval ((xmlChar*)request, xpctxt);
	if ((xmlobject->nodesetval!=NULL) || (strcmp("1", (char*)xmlobject->nodesetval->nodeTab[0]->content)!=0)) action_low_pri.sendmail=0;
	else action_low_pri.sendmail=1; 
	xmlXPathFreeObject (xmlobject);


	while(current != NULL)
	{
		if (current->type == XML_ELEMENT_NODE)
		{
			if( !STRCMP(current->name,"routers") )
			{
				xmlNode *router = current->children;
				while(router != NULL)
				{
					if (router->type == XML_ELEMENT_NODE)
					{
						if( !STRCMP(router->name,"router") )
						{
							struct ether_addr mac;
							struct in6_addr lla;
							uint8_t  param_curhoplimit=0;
							uint8_t  param_flags_reserved=0;
							uint16_t param_router_lifetime=0;
							uint32_t param_reachable_timer=0;
							uint32_t param_retrans_timer=0;
							xmlNode *param = router->children;
							while(param != NULL)
							{
								if (param->type == XML_ELEMENT_NODE)
								{
									if( !STRCMP(param->name,"mac") )
									{
										memcpy(&mac,ether_aton((char *)XML_GET_CONTENT(param->children)),sizeof(struct ether_addr));
									}
									else if( !STRCMP(param->name,"lla") )
									{
										inet_pton(AF_INET6,(char *)XML_GET_CONTENT(param->children), &lla);
									}
									else if( !STRCMP(param->name,"param_curhoplimit") )
									{
										char* text = (char*)XML_GET_CONTENT(param->children);
										param_curhoplimit = atoi(text!=NULL?text:"0");
									}
									else if( !STRCMP(param->name,"param_flags_reserved") )
									{
										char* text = (char*)XML_GET_CONTENT(param->children);
										param_flags_reserved = atoi(text!=NULL?text:"0");
									}
									else if( !STRCMP(param->name,"param_router_lifetime") )
									{
										char* text = (char*)XML_GET_CONTENT(param->children);
										param_router_lifetime = atoi(text!=NULL?text:"0");
									}
									else if( !STRCMP(param->name,"param_reachable_timer") )
									{
										char* text = (char*)XML_GET_CONTENT(param->children);
										param_reachable_timer = atoi(text!=NULL?text:"0");
									}
									else if( !STRCMP(param->name,"param_retrans_timer") )
									{
										char* text = (char*)XML_GET_CONTENT(param->children);
										param_retrans_timer = atoi(text!=NULL?text:"0");
										add_router(&routers, &mac, &lla, param_curhoplimit, param_flags_reserved, param_router_lifetime, param_reachable_timer, param_retrans_timer);
									}
									else if( !STRCMP(param->name,"addresses") )
									{
										xmlNode *address = param->children;
										while(address != NULL)
										{
											if (address->type == XML_ELEMENT_NODE)
											{
												if( !STRCMP(address->name,"address") )
												{
													struct in6_addr addr;
													inet_pton(AF_INET6,(char *)XML_GET_CONTENT(address->children), &addr);
													add_router_address(&routers, mac, addr);
												}
											}
											address = address->next;
										}
									}
									else if( !STRCMP(param->name,"prefixes") )
									{
										xmlNode *prefix = param->children;
										while(prefix != NULL)
										{
											if (prefix->type == XML_ELEMENT_NODE)
											{
												if( !STRCMP(prefix->name,"prefix") )
												{
													struct in6_addr addr;
													int mask=0;
													char buffer[INET6_ADDRSTRLEN];
													struct _xmlAttr *attr = prefix->properties;

													while(attr != NULL)
													{
														if (attr->type == XML_ATTRIBUTE_NODE)
														{
															if( !STRCMP(attr->name,"mask") )
															{
																c=(char *)XML_GET_CONTENT(attr->children);
																mask = atoi(c);
/*																mask = atoi((char *)XML_GET_CONTENT(attr->children));  */
															}
														}
														attr = attr->next;
													}

													c=(char *)XML_GET_CONTENT(prefix->children);
													strncpy(buffer,c, INET6_ADDRSTRLEN);
/*													strcpy(buffer,(char *)XML_GET_CONTENT(prefix->children));	*/
													inet_pton(AF_INET6,buffer, &addr);

													add_prefix(&routers, lla, mac, addr,mask);
												}
											}
											prefix = prefix->next;
										}
									}
								}
								param = param->next;
							}
						}
					}
					router = router->next;
				}
			}
		}
		current = current->next;
	}

	xmlFreeDoc(doc);
	return;
}