Esempio n. 1
0
static void add_mapping(char *var, char *val, int cumlative)
{
	uint32_t m = 0;

	if (cumlative) {
		uint32_t l = switch_log_str2level(val);
		uint32_t i;

		if (l < 10) {
			for (i = 0; i <= l; i++) {
				m |= (1 << i);
			}
		}
	} else {
		m = switch_log_str2mask(val);
	}

	if (!strcasecmp(var, "all")) {
		all_level = m | switch_log_str2mask("console");
		return;
	}

	del_mapping(var);
	switch_core_hash_insert(log_hash, var, (void *) (intptr_t) m);
}
Esempio n. 2
0
//Main function.
int main(int argc,char *argv[])
{
    struct in_addr saddr;
    struct in6_addr saddr6;
    int index=2,seconds;
    unsigned short pset_index, pset_mask;
    
	if(argc==1)
        use_info();
    while(index<=argc)
    {
      if(strncmp(argv[index-1],"-help",5)==0 || strncmp(argv[index-1],"-h",2)==0)//help info
      {
          use_info();//display info for use interface
          break;
      }
      else if(strncmp(argv[index-1],"-a",2)==0)//set mapping of source4 source6
      /* [pset] set mapping of source6 source4 mask index time*/
      {
         if(index-1+4>=argc) //pset
         {
            printf("sorry,argument is wrong!\n");
            break;
         }
         seconds=atoi(argv[index+4]);//pset
	// pset_index = atoi(argv[index+2]);//pset_index
	// pset_mask = atoi(argv[index+3]);//pset_mask
		pset_index = (unsigned short)strtoul(argv[index + 2], 0, 0);
		pset_mask = (unsigned short)strtoul(argv[index + 3], 0, 0);
//		printf("0x%04x,0x%04x\n",pset_index,pset_mask);
		inet_pton(AF_INET,argv[index+1],&saddr);//source ipv4 address
		inet_pton(AF_INET6,argv[index],&saddr6);//source ipv6 address
		set_mapping(saddr,saddr6,pset_index,pset_mask,seconds);
         break;
      }
      else if(strncmp(argv[index-1],"-b",2)==0)
      {//pset: need modification
  	 printf("argc = %d\n",argc);
         if(index-1+3>=argc)
         {
            printf("sorry,argument is wrong!\n");
            break;
         }
         inet_pton(AF_INET,argv[index],&saddr);
	 pset_index = (unsigned short)strtoul(argv[index+1], 0, 0);
	 pset_mask = (unsigned short)strtoul(argv[index+2], 0, 0);
         del_mapping(saddr, pset_index, pset_mask);
         break;
      }
      else if(strncmp(argv[index-1],"-c",2)==0)
      {
         if(strncmp(argv[index],"eth0",4)==0 || strncmp(argv[index],"eth1",4)==0
            || strncmp(argv[index],"eth2",4)==0)
             set_tunnel_bind_iface(argv[index]);
         break;
      }
      else if(strncmp(argv[index-1],"-s",2)==0)
      {
         get_tunnel_ipv6();
         break;
      }
      else if(strncmp(argv[index-1],"-m",2)==0)//display tc_mapping_table
      {
         display_tc_mapping_table();
         break;
      }
      else if(strncmp(argv[index-1],"-d",2)==0)//del all mapping
      {
          del_all_mapping();
          break;
      }
      else
         break;
   }
   return 0;		
}