void CopyTo(AAAAvpContainerList &cl)
  {
    DiameterAvpContainerManager cm;
    AAAAvpContainer *c;
    if (TunnelType.IsSet())
      {
	c = cm.acquire("Tunnel-Type");
	TunnelType.CopyTo(*c, AAA_AVP_ENUM_TYPE);
	cl.add(c);
      }
    if (TunnelMediumType.IsSet())
      {
	c = cm.acquire("Tunnel-Medium-Type");
	TunnelMediumType.CopyTo(*c, AAA_AVP_ENUM_TYPE);
	cl.add(c);
      }
    if (TunnelClientEndpoint.IsSet())
      {
	c = cm.acquire("Tunnel-Client-Endpoint");
	TunnelClientEndpoint.CopyTo(*c, AAA_AVP_UTF8_STRING_TYPE);
	cl.add(c);
      }
    if (TunnelServerEndpoint.IsSet())
      {
	c = cm.acquire("Tunnel-Server-Endpoint");
	TunnelServerEndpoint.CopyTo(*c, AAA_AVP_UTF8_STRING_TYPE);
	cl.add(c);
      }
    if (TunnelPreference.IsSet())
      {
	c = cm.acquire("Tunnel-Preference");
	TunnelPreference.CopyTo(*c, AAA_AVP_UINTEGER32_TYPE);
	cl.add(c);
      }
    if (TunnelClientAuthId.IsSet())
      {
	c = cm.acquire("Tunnel-Client-Auth-Id");
	TunnelClientAuthId.CopyTo(*c, AAA_AVP_UINTEGER32_TYPE);
	cl.add(c);
      }
    if (TunnelServerAuthId.IsSet())
      {
	c = cm.acquire("Tunnel-Server-Auth-Id");
	TunnelServerAuthId.CopyTo(*c, AAA_AVP_UINTEGER32_TYPE);
	cl.add(c);
      }
    if (TunnelPassword.IsSet())
      {
	c = cm.acquire("Tunnel-Password");
	TunnelPassword.CopyTo(*c, AAA_AVP_STRING_TYPE);
	cl.add(c);
      }
    if (TunnelPrivateGroupId.IsSet())
      {
	c = cm.acquire("Tunnel-Private-Group-Id");
	TunnelPrivateGroupId.CopyTo(*c, AAA_AVP_UTF8_STRING_TYPE);
	cl.add(c);
      }
  }
  void CopyFrom(AAAAvpContainerList &cl)
  {
    AAAAvpContainer *c;
    if ((c = cl.search("Proxy-Host")))
      {
	ProxyHost.CopyFrom(*c);
      }
    if ((c = cl.search("Proxy-State")))
      {
	ProxyState.CopyFrom(*c);
      }
    if ((c = cl.search("AVP")))
      {
	Avp.CopyFrom(*c);
      }
  }	  
示例#3
0
文件: test2.cpp 项目: xkmld419/crawl
void GetAllAvp(AAAAvpContainerList *orig_acl, std::vector<string>& sAvpName)
{
  AAAAvpContainerList *acl = orig_acl, *acl1;
  AAAAvpContainerList::iterator itor;
  AAAAvpContainer *c;	
  char tmp_buf[20];
  std::string tmp;
  int i;
  for (itor = acl->begin(); itor != acl->end(); itor ++ ) 
  {
  	
  	c = *itor;
	  for( i = 0 ; i < c->size() ; i ++ ) 
	  {
			
		  if( ((*c)[i]->dataType()) == AAA_AVP_GROUPED_TYPE ) 
  		{
			  if( c->size() > 1 ) 
			  {
//				cout << "\n\t[" << i << "]\n";
          sprintf(tmp_buf, "[%d]", i );
				  tmp = c->getAvpName() +std::string(tmp_buf);
				  sAvpName.push_back(tmp);
			  }
			  else 
			  {
				  sAvpName.push_back(c->getAvpName());
//				cout << ".";
			  }
			  acl1 = ((*c)[i])->dataPtr(Type2Type<AAAAvpContainerList>());
  			GetAllAvp(acl1, sAvpName);
  			sAvpName.pop_back();
  		}
  		else 
  		{
//  			sTp += ":";
//  			cout << ":" ;
			  sAvpName.push_back(c->getAvpName());
		  	GetAvpData((*c)[i], i, c->size(), sAvpName);
			  sAvpName.pop_back();
		  	
  		}
  	}
  }
}
示例#4
0
文件: test2.cpp 项目: xkmld419/crawl
int GetGroupedAvpNums(AAAAvpContainerList *acl1, char *avp_name)
{
   AAAAvpContainer* c;
   char tp_name[300], *p;
   int i , flag ;
   AAAAvpContainerList *acl = acl1;
   for( i = 0, flag = 0; ; i ++  ) 
   {
   	if( (p = (char *) strstr(avp_name, ".")) )
   	{
        		memset(tp_name, 0, 200);
        		memcpy(tp_name, avp_name, p - avp_name);
        		strcpy(avp_name, tp_name);
       			if( (c = acl->search(tp_name)) )
			{
 				if( ((*c)[0]->dataType()) == AAA_AVP_GROUPED_TYPE ) 
				{
					acl = ((*c)[0])->dataPtr(Type2Type<AAAAvpContainerList>());
					strcpy(tp_name, p+1);
					strcpy(avp_name, tp_name);
				}

			}
	}
	else 
   	{
       		if( (c = acl->search(avp_name)) )
		{
			if( ((*c)[0]->dataType()) == AAA_AVP_GROUPED_TYPE ) 
			{
				return c->size();		
			}
		}

		break;
    	}
   }
   return 0;	   	
}
  void CopyTo(AAAAvpContainerList &cl)
  {
    DiameterAvpContainerManager cm;
    AAAAvpContainer *c;
    if (ProxyHost.IsSet())
      {
	c = cm.acquire("Proxy-Host");
	ProxyHost.CopyTo(*c, AAA_AVP_DIAMID_TYPE);
	cl.add(c);
      }
    if (ProxyState.IsSet())
      {
	c = cm.acquire("Proxy-State");
	ProxyState.CopyTo(*c, AAA_AVP_STRING_TYPE);
	cl.add(c);
      }
    if (Avp.IsSet())
      {
	c = cm.acquire("AVP");
	Avp.CopyTo(*c, AAA_AVP_CUSTOM_TYPE);
	cl.add(c);
      }
  }
  void CopyFrom(AAAAvpContainerList &cl)
  {
    AAAAvpContainer *c;
	  
    if ((c = cl.search("Tunnel-Type")))
      {
	TunnelType.CopyFrom(*c);
      }
    if ((c = cl.search("Tunnel-Medium-Type")))
      {
	TunnelMediumType.CopyFrom(*c);
      }
    if ((c = cl.search("Tunnel-Client-Endpoint")))
      {
	TunnelClientEndpoint.CopyFrom(*c);
      }
    if ((c = cl.search("Tunnel-Server-Endpoint")))
      {
	TunnelServerEndpoint.CopyFrom(*c);
      }
    if ((c = cl.search("Tunnel-Preference")))
      {
	TunnelPreference.CopyFrom(*c);
      }
    if ((c = cl.search("Tunnel-Client-Auth-Id")))
      {
	TunnelClientAuthId.CopyFrom(*c);
      }
    if ((c = cl.search("Tunnel-Server-Auth-Id")))
      {
	TunnelServerAuthId.CopyFrom(*c);
      }
    if ((c = cl.search("Tunnel-Password")))
      {
	TunnelPassword.CopyFrom(*c);
      }
    if ((c = cl.search("Tunnel-Private-Group-Id")))
      {
	TunnelPrivateGroupId.CopyFrom(*c);
      }
  }
示例#7
0
文件: test2.cpp 项目: xkmld419/crawl
int deleteAvpValue(AAAAvpContainerList* acl1, char *avp_name1)
{
   AAAAvpContainer* c;
   int quit_flag = 0;
   std::string::size_type pos, start_pos ;
   std::string avpName, avp_name = std::string(avp_name1);
   std::string::size_type pos1, pos2, pos3;
   AAAAvpContainerList* acl = acl1;
	for( pos = 0, start_pos = 0; !quit_flag ;  )
  {
   	pos1 = avp_name.find(".", start_pos);
		if( pos1 != std::string::npos )
		{
			avpName =  avp_name.substr(start_pos, pos1-start_pos);
			pos2 = avpName.find("[", 0);
			if( pos2 != std::string::npos)
			{
				pos3 = avpName.find("]", pos2);
				if( pos3 != std::string::npos)
					pos = atoi(avpName.substr(pos2+1, pos3-pos2-1).c_str());
				avpName.erase(pos2, 10);
			}
			start_pos = pos1+1;
		}
		else
		{
		  pos2 = avp_name.find("[", start_pos);
		  if( pos2 != std::string::npos )
		  {
		    pos3 = avp_name.find("]", pos2);
			  if( pos3 != std::string::npos)
			    pos = atoi(avp_name.substr(pos2+1, pos3-pos2-1).c_str());
    	  avpName = avp_name.substr(start_pos, pos2-start_pos);;
		  }
		  else
      {
        avpName = avp_name.substr(start_pos, 500);
      }
			quit_flag = 1 ;
		}

//	printf("avpName:[%s]\n", avpName.c_str());
  	if( (c = acl->search(avpName.c_str())) )
  	{
			if( c->size() > pos )
			{
				if( ((*c)[pos]->dataType()) == AAA_AVP_GROUPED_TYPE )
				{
					acl = ((*c)[pos])->dataPtr(Type2Type<AAAAvpContainerList>());
					printf("1.avpName=%s,size:[%d],pos:[%d],dataType:[%d],acl releaseContainers\n", avpName.c_str(), c->size(), pos, (*c)[pos]->dataType());
					acl->releaseContainers();
					pos = 0;
					c->resize(0);
				}
				else
				{
					printf("2.avpName=%s,size:[%d],pos:[%d],dataType:[%d],c releaseEntries\n", avpName.c_str(),c->size(), pos, (*c)[pos]->dataType());
					c->releaseEntries();
					c->resize(0);
//					GET_DATA_REF(T, tmp, (*c)[pos]);
//					data = tmp;
					pos = 0;
					return 1;
				}
   		}
   		else
   		{
#ifdef DEBUG_DISP
   			printf("pos[%d] is large size[%d]\n", pos, c->size());
#endif
				return -1;
			}
   	}
   	else
		{
#ifdef DEBUG_DISP
			printf("avpName[%s] not found\n", avpName.c_str());
#endif
   		return -1;
  	}
  }
  return 0;

}
示例#8
0
文件: test2.cpp 项目: xkmld419/crawl
int SetAvpValue(AAAAvpContainerList *acl1, char *avp_name1, T &data, AAA_AVPDataType t)
{
  AAAAvpContainerManager cm;
  AAAAvpContainerEntryManager em;
  AAAAvpContainerEntry *e;
  int quit_flag = 0, ret = 0, pos, start_pos, flag, set_flag ; 
  std::string avpName, avp_name = std::string(avp_name1);
  int pos1, pos2, pos3;
  AAAAvpContainerList *acl = acl1;
  AAAAvpContainerList *tp_list = NULL;
  AAAAvpContainer* c;
  for( pos = 0, start_pos = 0, flag = 0, set_flag = 0; !quit_flag ;  ) 
  {
   	pos1 = avp_name.find(".", start_pos);
    if( pos1 != std::string::npos ) 
    {
    	avpName =  avp_name.substr(start_pos, pos1-start_pos); 
    	pos2 = avpName.find("[", 0);
    	if( pos2 != std::string::npos)
    	{
    		pos3 = avpName.find("]", pos2);
    		if( pos3 != std::string::npos)
    			pos = atoi(avpName.substr(pos2+1, pos3-pos2-1).c_str());
    		avpName.erase(pos2, 10);
    	}
    	start_pos = pos1+1;
    }
    else 
    {
		  pos2 = avp_name.find("[", start_pos);
		  if( pos2 != std::string::npos ) 
		  {
			  pos3 = avp_name.find("]", pos2);
			  if( pos3 != std::string::npos)
				  pos = atoi(avp_name.substr(pos2+1, pos3-pos2-1).c_str());
    	  avpName = avp_name.substr(start_pos, pos2-start_pos);;
		  }
		  else 
    	{
    	  avpName = avp_name.substr(start_pos, 500);
    	}
    	quit_flag = 1 ;
    }	
//    printf("avpName:[%s]\n", avpName.c_str());
    if( !flag && (c = acl->search(avpName.c_str()) ) )
    {
//    	printf("1.avpName:[%s]\n", avpName.c_str());
      if( c->size() > pos ) 
      {
    	  if( ((*c)[pos]->dataType()) == AAA_AVP_GROUPED_TYPE ) 
    	  {
    		  acl = ((*c)[pos])->dataPtr(Type2Type<AAAAvpContainerList>());
    		  pos = 0;
    		  set_flag = 1 ;
//    			printf("2.avpName:[%s],set_flag=1\n", avpName.c_str());
    	  }
    	  else 
    	  {
//    			printf("3.avpName:[%s],set_value\n", avpName.c_str());
    		  GET_DATA_REF(T, tmp, (*c)[pos]);
    		  pos = 0;
    		  tmp = data;
    		  return 1;
    	  }
      }
      else 
      {
//    		printf("avpName=%s,pos[%d] is large size, [%d]\n", avpName.c_str(), pos, c->size());
        if( !quit_flag ) 
    	  {
//    		printf("11.avpName:[%s],set_flag\n", avpName.c_str());
    		  e = em.acquire(AAA_AVP_GROUPED_TYPE);
    		  acl = e->dataPtr(Type2Type<diameter_grouped_t>());
    	    c->add(e);
    	  }
    	  else 
    	  {
    		  e = em.acquire(t);
    		  GET_DATA_REF(T, tp, e);
      	  c->add(e);
     	    tp = data;
    		  ret = 1;
    	  }
    	  flag = 1 ;
      }
    }
    else 
    {
//    	printf("2.avpName:[%s]\n", avpName.c_str());
      c = cm.acquire(avpName.c_str());
      if( !quit_flag ) 
      {
//    		printf("5.avpName:[%s],set_flag\n", avpName.c_str());
    	  e = em.acquire(AAA_AVP_GROUPED_TYPE);
    	  tp_list = e->dataPtr(Type2Type<diameter_grouped_t>());
    	  c->add(e);
     	}
      else 
      {
//    		printf("4.avpName:[%s],set_value\n", avpName.c_str());
//    		cout << "data:t" << t << ":" << data << endl;
    	  e = em.acquire(t);
    	  GET_DATA_REF(T, tp, e);
      	c->add(e);
     	  tp = data;
//    		cout << "data:" << data << ":" << tp << endl;
    	  ret = 1;
      }
      	      	
      if( acl ) 
      {
//        printf("2.acl add\n");
        acl->add(c);
    	}
      acl = tp_list;
    	flag = 1 ;
    }
    
  }	
  return ret;	   	
   
}
示例#9
0
文件: test2.cpp 项目: xkmld419/crawl
int GetAvpValue(AAAAvpContainerList* acl1, char *avp_name1, T &data)
{
   AAAAvpContainer* c;
   int quit_flag = 0, pos, start_pos ; 
   std::string avpName, avp_name = std::string(avp_name1);
   int pos1, pos2, pos3;
   AAAAvpContainerList* acl = acl1;
  for( pos = 0, start_pos = 0; !quit_flag ;  ) 
  {
   	pos1 = avp_name.find(".", start_pos);
	  if( pos1 != std::string::npos ) 
	  {
		  avpName =  avp_name.substr(start_pos, pos1-start_pos); 
		  pos2 = avpName.find("[", 0);
		  if( pos2 != std::string::npos)
		  {
			  pos3 = avpName.find("]", pos2);
			  if( pos3 != std::string::npos)
			    pos = atoi(avpName.substr(pos2+1, pos3-pos2-1).c_str());
			  avpName.erase(pos2, 10);
		  }
      start_pos = pos1+1;
	  }
	  else 
	  {
		  pos2 = avp_name.find("[", start_pos);
		  if( pos2 != std::string::npos )
		  {
			  pos3 = avp_name.find("]", pos2);
			  if( pos3 != std::string::npos)
				  pos = atoi(avp_name.substr(pos2+1, pos3-pos2-1).c_str());
    	  avpName = avp_name.substr(start_pos, pos2-start_pos);;
		  }
		  else 
    	  avpName = avp_name.substr(start_pos, 500);;

//      avpName = avp_name.substr(start_pos, 500);;
      quit_flag = 1 ;
	  }	
	
//	printf("avpName:[%s]\n", avpName.c_str());
    if( (c = acl->search(avpName.c_str())) )
    {
		  if( c->size() > pos ) 
		  {
			  if( ((*c)[pos]->dataType()) == AAA_AVP_GROUPED_TYPE ) 
			  {
				  acl = ((*c)[pos])->dataPtr(Type2Type<AAAAvpContainerList>());
				  pos = 0;
			  }
			  else 
			  {
				  GET_DATA_REF(T, tmp, (*c)[pos]);
					data = tmp;
				  pos = 0;
				  return 1;
			  }
   	  }
   	  else 
   	  {
   			printf("pos[%d] is large size[%d]\n", pos, c->size());
			  return -1;
	  	}
   	}
   	else 
   	{
   		printf("avpName[%s] not found\n", avpName.c_str());
   		return -1;
    }
  }	
  return 0;	   	
   
}