Example #1
0
void ShowAddCommunityPage(char *m,int add_flag,char *old_name,char *ComID,struct list *lpublic,struct list *lsnmpd)
{    
  char IsSubmit[5] = { 0 };
  int i = 0,limit = 0;     
  int cllection_mode = 0;/*0表示关闭分板采集,1表示开启分板采集*/  
  char select_slotid[10] = { 0 };
  char temp[10] = { 0 };
  unsigned int slot_id = 0;
  DBusConnection *select_connection = NULL;
  instance_parameter *paraHead = NULL,*paraNode = NULL;
  char *endptr = NULL;	
  int ret = AC_MANAGE_DBUS_ERROR;
  STCommunity *community_array = NULL;
  unsigned int community_num = 0;
  int community_id = 0;
  char *tem = NULL;
  char ip1[5] = { 0 };
  char ip2[5] = { 0 };
  char ip3[5] = { 0 };
  char ip4[5] = { 0 };
  char mask1[5] = { 0 };
  char mask2[5] = { 0 };
  char mask3[5] = { 0 };
  char mask4[5] = { 0 };
  char CommunityName[25] = { 0 };
  int AddMod_ret = 0;

  cgiHeaderContentType("text/html");
  fprintf(cgiOut,"<html xmlns=\"http://www.w3.org/1999/xhtml\"><head>");
  fprintf(cgiOut,"<meta http-equiv=Content-Type content=text/html; charset=gb2312>");
  fprintf(cgiOut,"<title>SNMP</title>");
  fprintf(cgiOut,"<link rel=stylesheet href=/style.css type=text/css>"\
  "<style type=text/css>"\
  	".a3{width:30;border:0; text-align:center}"\
  "</style>"\
  "</head>"\
  "<script src=/slotid_onchange.js>"\
  "</script>"\
  "<script src=/ip.js>"\
  "</script>"\
  "<body>");
  memset(select_slotid,0,sizeof(select_slotid));
  cgiFormStringNoNewlines( "SLOT_ID", select_slotid, 10 );
  list_instance_parameter(&paraHead, SNMPD_SLOT_CONNECT);
  if(strcmp(select_slotid,"")==0)
  { 
	if(paraHead)
	{
		snprintf(select_slotid,sizeof(select_slotid)-1,"%d",paraHead->parameter.slot_id);
	} 
  }  

  if(snmp_cllection_mode(ccgi_dbus_connection))
  {
	cllection_mode = 1;
  }
  else
  {
	cllection_mode = 0;
  }	
  if(1 == cllection_mode)/*开启分板采集*/
  {
  	  slot_id=strtoul(select_slotid,&endptr,10);
	  get_slot_dbus_connection(slot_id,&select_connection,SNMPD_INSTANCE_MASTER_V3);
  }
  if(0 == add_flag)/*修改共同体*/
  {
	  community_id=strtoul(ComID,&endptr,10);
  }

  memset(IsSubmit,0,sizeof(IsSubmit));  
  cgiFormStringNoNewlines("SubmitFlag", IsSubmit, 5);
  if((cgiFormSubmitClicked("add_mod_community_apply") == cgiFormSuccess)&&(strcmp(IsSubmit,"")))
  {
  	 AddMod_ret = AddorModifyCommunity(cllection_mode,add_flag,select_connection,old_name,lpublic,lsnmpd);
  }
  fprintf(cgiOut,"<form method=post>"\
  "<div align=center>"\
  "<table width=976 border=0 cellpadding=0 cellspacing=0>"\
  "<tr>"\
    "<td width=8 align=left valign=top background=/images/di22.jpg><img src=/images/youce4.jpg width=8 height=30/></td>"\
    "<td width=51 align=left valign=bottom background=/images/di22.jpg><img src=/images/youce33.jpg width=37 height=24/></td>"\
    "<td width=153 align=left valign=bottom id=titleen background=/images/di22.jpg>SNMP</td>"\
    "<td width=690 align=right valign=bottom background=/images/di22.jpg>");        
	 
    	  fprintf(cgiOut,"<table width=155 border=0 cellspacing=0 cellpadding=0>"\
          "<tr>"\
          "<td width=62 align=center><input id=but type=submit name=add_mod_community_apply style=background-image:url(/images/%s) value=""></td>",search(lpublic,"img_ok"));		  
          fprintf(cgiOut,"<td width=62 align=center><a href=wp_snmp.cgi?UN=%s target=mainFrame><img src=/images/%s border=0 width=62 height=20/></a></td>",m,search(lpublic,"img_cancel"));
		  fprintf(cgiOut,"</tr>"\
          "</table>");
				
				
      fprintf(cgiOut,"</td>"\
    "<td width=74 align=right valign=top background=/images/di22.jpg><img src=/images/youce3.jpg width=31 height=30/></td>"\
  "</tr>"\
  "<tr>"\
    "<td colspan=5 align=center valign=middle><table width=976 border=0 cellpadding=0 cellspacing=0 bgcolor=#f0eff0>"\
      "<tr>"\
        "<td width=12 align=left valign=top background=/images/di888.jpg>&nbsp;</td>"\
        "<td width=948><table width=947 border=0 cellspacing=0 cellpadding=0>"\
            "<tr height=4 valign=bottom>"\
              "<td width=120>&nbsp;</td>"\
              "<td width=827 valign=bottom><img src=/images/bottom_05.gif width=827 height=4/></td>"\
            "</tr>"\
            "<tr>"\
              "<td><table width=120 border=0 cellspacing=0 cellpadding=0>"\
                   "<tr height=25>"\
                    "<td id=tdleft>&nbsp;</td>"\
                  "</tr>");              
				  fprintf(cgiOut,"<tr height=25>"\
					"<td align=left id=tdleft><a href=wp_snmp_summary.cgi?UN=%s target=mainFrame class=top><font id=yingwen_san>SNMP</font><font id=%s> %s</font></a></td>",m,search(lpublic,"menu_san"),search(lpublic,"info")); 					  
				  fprintf(cgiOut,"</tr>");
				  fprintf(cgiOut,"<tr height=25>"\
					"<td align=left id=tdleft><a href=wp_snmp_config.cgi?UN=%s target=mainFrame class=top><font id=%s>%s</font><font id=yingwen_san> SNMP</font></a></td>",m,search(lpublic,"menu_san"),search(lpublic,"config"));                       
                  fprintf(cgiOut,"</tr>");				  
				  fprintf(cgiOut,"<tr height=25>"\
					"<td align=left id=tdleft><a href=wp_community_list.cgi?UN=%s target=mainFrame class=top><font id=%s>%s</font></a></td>",m,search(lpublic,"menu_san"),search(lsnmpd,"community_list"));                       
                  fprintf(cgiOut,"</tr>");
				  fprintf(cgiOut,"<tr height=26>");
				  	if(1 == add_flag)
                      fprintf(cgiOut,"<td align=left id=tdleft background=/images/bottom_bg.gif style=\"border-right:0\"><font id=%s>%s</font></td>",search(lpublic,"menu_san"),search(lsnmpd,"add_community"));   /*突出显示*/
					else
					  fprintf(cgiOut,"<td align=left id=tdleft background=/images/bottom_bg.gif style=\"border-right:0\"><font id=%s>%s</font></td>",search(lpublic,"menu_san"),search(lsnmpd,"mod_community"));   /*突出显示*/
                  fprintf(cgiOut,"</tr>");	 

				  ret = AC_MANAGE_DBUS_ERROR;
				  if(1 == cllection_mode)
			      {
			      	ret = ac_manage_show_snmp_community(select_connection, &community_array, &community_num);
					limit = 3;
				  }
				  else
				  {
				  	ret = ac_manage_show_snmp_community(ccgi_dbus_connection, &community_array, &community_num);
				  	limit = 2;
				  }

				  if(0 == add_flag)
				  {
					memset(CommunityName,0,sizeof(CommunityName));
					cgiFormStringNoNewlines("community_name", CommunityName, 25);
				  }

				  for(i=0;i<limit;i++)
	              {
  				    fprintf(cgiOut,"<tr height=25>"\
                      "<td id=tdleft>&nbsp;</td>"\
                    "</tr>");
	              }			    
                fprintf(cgiOut,"</table>"\
              "</td>"\
              "<td align=left valign=top style=\"background-color:#ffffff; border-right:1px solid #707070; padding-left:30px; padding-top:10px\">"\
	"<table width=760 border=0 cellspacing=0 cellpadding=0>");
		if(1 == cllection_mode)/*开启分板采集*/
	    {
		  fprintf(cgiOut,"<tr height=30>"\
			  "<td>SLOT ID:</td>"\
			  "<td colspan=2>"\
				  "<select name=slot_id id=slot_id style=width:55px onchange=slotid_change(this,\"wp_community_add.cgi\",\"%s\")>",m);
				  for(paraNode = paraHead; paraNode; paraNode = paraNode->next)
				  {
					 memset(temp,0,sizeof(temp));
					 snprintf(temp,sizeof(temp)-1,"%d",paraNode->parameter.slot_id);
		  
					 if(strcmp(select_slotid,temp) == 0)
					   fprintf(cgiOut,"<option value='%s' selected=selected>%s",temp,temp);
					 else
					   fprintf(cgiOut,"<option value='%s'>%s",temp,temp);
				  } 		  
				  fprintf(cgiOut,"</select>"\
			  "</td>"\
		  "</tr>");
	    }
		fprintf(cgiOut,"<tr height=30>"\
			"<td width=60>%s:</td>",search(lsnmpd,"community_name"));
			if(1 == add_flag)
			{
				fprintf(cgiOut,"<td width=100><input name=community_name size=21 maxLength=20></td>");
			}
			else
			{
				if(1 == AddMod_ret)
					fprintf(cgiOut,"<td width=100><input name=community_name size=21 maxLength=20 value=%s></td>",CommunityName);
				else
					fprintf(cgiOut,"<td width=100><input name=community_name size=21 maxLength=20 value=%s></td>",old_name);
			}
			fprintf(cgiOut,"<td width=600><font color=red>(%s)</font></td>",search(lsnmpd,"community_name_range"));
		fprintf(cgiOut,"</tr>"\
		"<tr height=30>"\
			"<td>IP %s:</td>",search(lpublic,"addr"));
			fprintf(cgiOut,"<td colspan=2>"\
				"<div style=\"border-width:1;border-color:#a5acb2;border-style:solid;width:140;font-size:9pt\">");
				if(1 == add_flag)
				{
					fprintf(cgiOut,"<input type=text name='comm_ip1' maxlength=3 class=a3 onKeyUp=\"mask(this,%s)\" onbeforepaste=mask_c()>.",search(lpublic,"ip_error"));
					fprintf(cgiOut,"<input type=text name='comm_ip2' maxlength=3 class=a3 onKeyUp=\"mask(this,%s)\" onbeforepaste=mask_c()>.",search(lpublic,"ip_error"));
					fprintf(cgiOut,"<input type=text name='comm_ip3' maxlength=3 class=a3 onKeyUp=\"mask(this,%s)\" onbeforepaste=mask_c()>.",search(lpublic,"ip_error"));
					fprintf(cgiOut,"<input type=text name='comm_ip4' maxlength=3 class=a3 onKeyUp=\"mask(this,%s)\" onbeforepaste=mask_c()>",search(lpublic,"ip_error"));
				}
				else
				{
					memset(ip1,0,sizeof(ip1));
					memset(ip2,0,sizeof(ip2));
					memset(ip3,0,sizeof(ip3));
					memset(ip4,0,sizeof(ip4));
					i=0;
					if((AC_MANAGE_SUCCESS == ret)&&(community_array))
					{
						tem = strtok(community_array[community_id].ip_addr,".");
						while(tem != NULL)
						{
						  i++;
						  if(i==1)
							  strncpy(ip1,tem,sizeof(ip1)-1);
						  else if(i ==2 )
							  strncpy(ip2,tem,sizeof(ip2)-1);
						  else if(i==3)
							  strncpy(ip3,tem,sizeof(ip3)-1);
						  else if(i==4)
							  strncpy(ip4,tem,sizeof(ip4)-1);
						  tem = strtok(NULL,".");	  
						}				   
					}
					fprintf(cgiOut,"<input type=text name='comm_ip1' maxlength=3 class=a3 onKeyUp=\"mask(this,%s)\" onbeforepaste=mask_c() value=%s>.",search(lpublic,"ip_error"),ip1);
					fprintf(cgiOut,"<input type=text name='comm_ip2' maxlength=3 class=a3 onKeyUp=\"mask(this,%s)\" onbeforepaste=mask_c() value=%s>.",search(lpublic,"ip_error"),ip2);
					fprintf(cgiOut,"<input type=text name='comm_ip3' maxlength=3 class=a3 onKeyUp=\"mask(this,%s)\" onbeforepaste=mask_c() value=%s>.",search(lpublic,"ip_error"),ip3);
					fprintf(cgiOut,"<input type=text name='comm_ip4' maxlength=3 class=a3 onKeyUp=\"mask(this,%s)\" onbeforepaste=mask_c() value=%s>",search(lpublic,"ip_error"),ip4);
				}
				fprintf(cgiOut,"</div>"\
			"</td>"\
		"</tr>"\
		"<tr height=30>"\
			"<td>%s:</td>",search(lpublic,"netmask"));
			fprintf(cgiOut,"<td colspan=2>"\
				"<div style=\"border-width:1;border-color:#a5acb2;border-style:solid;width:140;font-size:9pt\">");
				if(1 == add_flag)
				{
					fprintf(cgiOut,"<input type=text name='comm_mask1' maxlength=3 class=a3 onKeyUp=\"mask(this,%s)\" onbeforepaste=mask_c()>.",search(lpublic,"ip_error"));
					fprintf(cgiOut,"<input type=text name='comm_mask2' maxlength=3 class=a3 onKeyUp=\"mask(this,%s)\" onbeforepaste=mask_c()>.",search(lpublic,"ip_error"));
					fprintf(cgiOut,"<input type=text name='comm_mask3' maxlength=3 class=a3 onKeyUp=\"mask(this,%s)\" onbeforepaste=mask_c()>.",search(lpublic,"ip_error"));
					fprintf(cgiOut,"<input type=text name='comm_mask4' maxlength=3 class=a3 onKeyUp=\"mask(this,%s)\" onbeforepaste=mask_c()>",search(lpublic,"ip_error"));
				}
				else
				{
					memset(mask1,0,sizeof(mask1));
					memset(mask2,0,sizeof(mask2));
					memset(mask3,0,sizeof(mask3));
					memset(mask4,0,sizeof(mask4));
					i=0;
					if((AC_MANAGE_SUCCESS == ret)&&(community_array))
					{
						tem = strtok(community_array[community_id].ip_mask,".");
						while(tem != NULL)
						{
						  i++;
						  if(i==1)
							  strncpy(mask1,tem,sizeof(mask1)-1);
						  else if(i ==2 )
							  strncpy(mask2,tem,sizeof(mask2)-1);
						  else if(i==3)
							  strncpy(mask3,tem,sizeof(mask3)-1);
						  else if(i==4)
							  strncpy(mask4,tem,sizeof(mask4)-1);
						  tem = strtok(NULL,".");	  
						}				
					}
					fprintf(cgiOut,"<input type=text name='comm_mask1' maxlength=3 class=a3 onKeyUp=\"mask(this,%s)\" onbeforepaste=mask_c() value=%s>.",search(lpublic,"ip_error"),mask1);
					fprintf(cgiOut,"<input type=text name='comm_mask2' maxlength=3 class=a3 onKeyUp=\"mask(this,%s)\" onbeforepaste=mask_c() value=%s>.",search(lpublic,"ip_error"),mask2);
					fprintf(cgiOut,"<input type=text name='comm_mask3' maxlength=3 class=a3 onKeyUp=\"mask(this,%s)\" onbeforepaste=mask_c() value=%s>.",search(lpublic,"ip_error"),mask3);
					fprintf(cgiOut,"<input type=text name='comm_mask4' maxlength=3 class=a3 onKeyUp=\"mask(this,%s)\" onbeforepaste=mask_c() value=%s>",search(lpublic,"ip_error"),mask4);
				}
				fprintf(cgiOut,"</div>"\
			"</td>"\
		"</tr>"\
		"<tr height=30>"\
			"<td>%s:</td>",search(lsnmpd,"access_mode"));
			fprintf(cgiOut,"<td colspan=2><select name=access_mode id=access_mode style=width:55px>");
				if(1 == add_flag)
				{
					fprintf(cgiOut,"<option value=>"\
					"<option value=ro>%s",search(lsnmpd,"read_only"));
					fprintf(cgiOut,"<option value=rw>%s",search(lsnmpd,"read_write"));
				}
				else
				{
					if((AC_MANAGE_SUCCESS == ret)&&(community_array)&&(community_array[community_id].access_mode))
					{
						fprintf(cgiOut,"<option value=ro>%s",search(lsnmpd,"read_only"));
						fprintf(cgiOut,"<option value=rw selected=selected>%s",search(lsnmpd,"read_write"));
					}
					else
					{
						fprintf(cgiOut,"<option value=ro selected=selected>%s",search(lsnmpd,"read_only"));
						fprintf(cgiOut,"<option value=rw>%s",search(lsnmpd,"read_write"));
					}
				}
			fprintf(cgiOut,"</select></td>"\
		"</tr>"\
		"<tr height=30>"\
			"<td>%s:</td>",search(lsnmpd,"status"));
			fprintf(cgiOut,"<td colspan=2><select name=status id=status style=width:55px>");
				if(1 == add_flag)
				{
					fprintf(cgiOut,"<option value=>"\
					"<option value=enable>%s",search(lpublic,"version_enable"));
					fprintf(cgiOut,"<option value=disable>%s",search(lpublic,"version_disable"));
				}
				else
				{
					if((AC_MANAGE_SUCCESS == ret)&&(community_array)&&(community_array[community_id].status))
					{
						fprintf(cgiOut,"<option value=enable selected=selected>%s",search(lpublic,"version_enable"));
						fprintf(cgiOut,"<option value=disable>%s",search(lpublic,"version_disable"));
					}
					else
					{
						fprintf(cgiOut,"<option value=enable>%s",search(lpublic,"version_enable"));
						fprintf(cgiOut,"<option value=disable selected=selected>%s",search(lpublic,"version_disable"));
					}
				}
			fprintf(cgiOut,"</select></td>"\
		"</tr>"\
		"<tr>"\
		 	"<td><input type=hidden name=encry_add_community value=%s></td>",m);
			fprintf(cgiOut,"<td><input type=hidden name=SubmitFlag value=%d></td>",1);
			fprintf(cgiOut,"<td><input type=hidden name=AddFlag value=%d></td>",add_flag);
		fprintf(cgiOut,"</tr>"\
		"<tr>"\
		 	"<td colspan=3><input type=hidden name=SLOT_ID value=%s></td>",select_slotid);
		fprintf(cgiOut,"</tr>");
		if(0 == add_flag)
		{
			fprintf(cgiOut,"<tr>");
			if(1 == AddMod_ret)
				fprintf(cgiOut,"<td><input type=hidden name=old_name value=%s></td>",CommunityName);
			else
				fprintf(cgiOut,"<td><input type=hidden name=old_name value=%s></td>",old_name);
			fprintf(cgiOut,"<td colspan=2><input type=hidden name=ComID value=%d></td>",community_id);
			fprintf(cgiOut,"</tr>");
		}
	fprintf(cgiOut,"</table>"\
              "</td>"\
            "</tr>"\
            "<tr height=4 valign=top>"\
              "<td width=120 height=4 align=right valign=top><img src=/images/bottom_07.gif width=1 height=10/></td>"\
              "<td width=827 height=4 valign=top bgcolor=#FFFFFF><img src=/images/bottom_06.gif width=827 height=15/></td>"\
            "</tr>"\
          "</table>"\
        "</td>"\
        "<td width=15 background=/images/di999.jpg>&nbsp;</td>"\
      "</tr>"\
    "</table></td>"\
  "</tr>"\
  "<tr>"\
    "<td colspan=3 align=left valign=top background=/images/di777.jpg><img src=/images/di555.jpg width=61 height=62/></td>"\
    "<td align=left valign=top background=/images/di777.jpg>&nbsp;</td>"\
    "<td align=left valign=top background=/images/di777.jpg><img src=/images/di666.jpg width=74 height=62/></td>"\
  "</tr>"\
"</table>"\
"</div>"\
"</form>"\
"</body>"\
"</html>");
if(AC_MANAGE_SUCCESS == ret)
{
	FREE_OBJECT(community_array);
}
free_instance_parameter_list(&paraHead);
}
Example #2
0
/*ifname的长度要小于16 */
int create_ac_ip_list_cmd(int instance_id,char *ID,char *ifname)/*返回0表示失败,返回1表示成功,返回-1表示unknown id format*/
																   /*返回-2表示id should be 1 to ACIPLIST_NUM-1,返回-3表示ifname is too long,out of the limit of 16*/
																   /*返回-4表示id exist,返回-5表示error,返回-6表示interface has be binded in other hansi*/
{
	if((NULL == ID)||(NULL == ifname))
		return 0;
	
	int ret,len;
	unsigned char isAdd;	
	unsigned char id;
	char *name;
	DBusMessage *query, *reply;	
	DBusMessageIter	 iter;
	DBusError err;
	isAdd = 1;
	int retu;
	
	ret = parse_char_ID((char*)ID, &id);
	if(ret != WID_DBUS_SUCCESS){
		return -1;
	}	
	if(id >= ACIPLIST_NUM || id == 0){
		return -2;
	}
	len = strlen(ifname);
	if(len > 16){		
		return -3;
	}
	name = (char*)malloc(strlen(ifname)+1);
	if(NULL == name)
		return 0;
	memset(name, 0, strlen(ifname)+1);
	memcpy(name, ifname, strlen(ifname));		
	
	int index;
	char BUSNAME[PATH_LEN];
	char OBJPATH[PATH_LEN];
	char INTERFACE[PATH_LEN];
	/*if(vty->node == CONFIG_NODE){
		index = 0;
	}else if(vty->node == HANSI_NODE){
		index = vty->index;
	}*/
	index = instance_id;
	
	ReInitDbusPath(index,WID_DBUS_BUSNAME,BUSNAME);
	ReInitDbusPath(index,WID_DBUS_ACIPLIST_OBJPATH,OBJPATH);
	ReInitDbusPath(index,WID_DBUS_ACIPLIST_INTERFACE,INTERFACE);
	query = dbus_message_new_method_call(BUSNAME,OBJPATH,INTERFACE,WID_DBUS_ACIPLIST_METHOD_ADD_AC_IP_LIST_GROUP);

/*	query = dbus_message_new_method_call(WID_DBUS_BUSNAME,WID_DBUS_ACIPLIST_OBJPATH,\
						WID_DBUS_ACIPLIST_INTERFACE,WID_DBUS_ACIPLIST_METHOD_ADD_AC_IP_LIST_GROUP);*/
	dbus_error_init(&err);

	dbus_message_append_args(query,
						DBUS_TYPE_BYTE,&id,
						DBUS_TYPE_STRING,&name,
						DBUS_TYPE_INVALID);

	reply = dbus_connection_send_with_reply_and_block (ccgi_dbus_connection,query,-1, &err);
	
	dbus_message_unref(query);
	
	if (NULL == reply) {
		if (dbus_error_is_set(&err)) {
			dbus_error_free(&err);
		}
		if(name)
		{
			free(name);
			name = NULL;
		}
		return 0;
	}
	dbus_message_iter_init(reply,&iter);
	dbus_message_iter_get_basic(&iter,&ret);

	if(ret == 0)
		retu = 1;
	else if(ret == WLAN_ID_BE_USED)
		retu = -4;
	else if(ret == IF_BINDING_FLAG)
		retu = -6;
	else
		retu = -5;

	dbus_message_unref(reply);
	FREE_OBJECT(name);
	return retu;	
}
Example #3
0
CUIEdit::~CUIEdit()
{
	FREE_OBJECT(m_hFont);
}
Example #4
0
void CUIEdit::Destroy()
{
	super::Destroy();

	FREE_OBJECT(m_hFont);
}
int
handle_CFServerAddr(netsnmp_mib_handler *handler,
                          netsnmp_handler_registration *reginfo,
                          netsnmp_agent_request_info   *reqinfo,
                          netsnmp_request_info         *requests)
{
    /* We are never called for a GETNEXT if it's registered as a
       "instance", as it's "magically" handled for us.  */

    /* a instance handler also only hands us one request at a time, so
       we don't need to loop over a list of requests; we'll only get one. */
    snmp_log(LOG_DEBUG, "enter handle_CFServerAddr\n");

    switch(reqinfo->mode) {

        case MODE_GET:
		{
			char CFServerAddr[CFSERADDR_LEN];
			memset(CFServerAddr,0,sizeof(CFServerAddr));
			
			snmp_log(LOG_DEBUG, "enter get_dhcp_node_attr\n");
			get_dhcp_node_attr(CONFIGURATIONFILE_XMLPATH,"ConfigurationFile","CF","1","CFServerAddr",CFServerAddr);
			snmp_log(LOG_DEBUG, "exit get_dhcp_node_attr, CFServerAddr=%s\n",CFServerAddr);
			
            snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR,
                                     (u_char *)CFServerAddr,
                                     strlen(CFServerAddr));

        }
             break;

        /*
         * SET REQUEST
         *
         * multiple states in the transaction.  See:
         * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg
         */
        case MODE_SET_RESERVE1:
			#if 0
            if (/* XXX: check incoming data in requests->requestvb->val.XXX for failures, like an incorrect type or an illegal value or ... */) {
                netsnmp_set_request_error(reqinfo, requests, /* XXX: set error code depending on problem (like SNMP_ERR_WRONGTYPE or SNMP_ERR_WRONGVALUE or ... */);
            }
			#endif
            break;

        case MODE_SET_RESERVE2:
			#if 0
            /* XXX malloc "undo" storage buffer */
            if (/* XXX if malloc, or whatever, failed: */) {
                netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_RESOURCEUNAVAILABLE);
            }
			#endif
            break;

        case MODE_SET_FREE:
            /* XXX: free resources allocated in RESERVE1 and/or
               RESERVE2.  Something failed somewhere, and the states
               below won't be called. */
            break;

        case MODE_SET_ACTION:
		{
			char * input_string = (char *)malloc(requests->requestvb->val_len+1);
			if(NULL == input_string)
			    break;
			    
			memset(input_string,0,requests->requestvb->val_len+1);
			strncpy(input_string,requests->requestvb->val.string,requests->requestvb->val_len);
			
			add_dhcp_node_attr(CONFIGURATIONFILE_XMLPATH,"ConfigurationFile","CF","1");
			mod_dhcp_node(CONFIGURATIONFILE_XMLPATH,"ConfigurationFile","CF","1","CFServerAddr",input_string);

			FREE_OBJECT(input_string);
        }
             break;

        case MODE_SET_COMMIT:
			#if 0
            /* XXX: delete temporary storage */
            if (/* XXX: error? */) {
                /* try _really_really_ hard to never get to this point */
                netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_COMMITFAILED);
            }
			#endif
            break;

        case MODE_SET_UNDO:
			#if 0
            /* XXX: UNDO and return to previous value for the object */
            if (/* XXX: error? */) {
                /* try _really_really_ hard to never get to this point */
                netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_UNDOFAILED);
            }
			#endif
            break;

        default:
            /* we should never get here, so this is a really bad error */
            snmp_log(LOG_ERR, "unknown mode (%d) in handle_CFServerAddr\n", reqinfo->mode );
            return SNMP_ERR_GENERR;
    }

	snmp_log(LOG_DEBUG, "exit handle_CFServerAddr\n");
    return SNMP_ERR_NOERROR;
}
void do_Fano_subplanes(translation_plane &T, INT order, INT verbose_level)
{
	INT f_v = (verbose_level >= 1);
	INT i, j;
	BYTE fname[1000];

	if (f_v) {
		cout << "do_Fano_subplanes" << endl;
		}
	cout << "T.target_size = " << T.target_size << endl;
	
	T.compute(T.target_size, verbose_level);

	sprintf(fname, "%s_lvl_%ld", T.gen->fname_base, T.target_size);
	//T.gen->A->read_file_and_print_representatives(fname, FALSE);

	


	INT *Reps;
	BYTE **Aut_ascii;
	INT nb_reps, size;
			
	cout << "Reading spreads from file " << fname << endl;
	T.gen->A->read_representatives_and_strong_generators(fname, Reps, Aut_ascii, nb_reps, size, 0 /* verbose_level */);
	cout << "Read spreads from file " << fname << endl;


	translation_plane_via_andre_model *TP;
	INT *Nb_subplanes;
	//INT **Subplanes;

	TP = new translation_plane_via_andre_model[nb_reps];


	Nb_subplanes = NEW_INT(nb_reps);
	//Subplanes = NEW_PINT(nb_reps);
	//INT depth = 4;
	INT depth = 7;
			
	for (i = 0; i < nb_reps; i++) {
		cout << endl;
		cout << endl;
		cout << endl;
		cout << endl;
		cout << endl;
		cout << endl;
		cout << "Making translation plane from representative " << i << ":" << endl;

		vector_ge *gens;
		INT *tl;
				
		T.gen->A->get_generators_from_ascii_coding(Aut_ascii[i], gens, tl, verbose_level - 2);



		TP[i].init(Reps + i * T.target_size, T.q, T.k, T.F, gens, tl, verbose_level);

		BYTE prefix[1000];

		sprintf(prefix, "TP_%ld_", i);

		//TP[i].classify_arcs(prefix, depth, verbose_level);
		TP[i].classify_subplanes(prefix, verbose_level);

		Nb_subplanes[i] = TP[i].arcs->number_of_orbits_at_depth(depth);


		FREE_OBJECT(gens);
		FREE_INT(tl);
		}

	for (i = 0; i < nb_reps; i++) {
		cout << "Translation plane " << i << ":" << endl;
		TP[i].arcs->print_orbit_numbers(depth);
		}


#if 0
	for (i = 0; i < nb_reps; i++) {
		cout << "Translation plane " << i << ":" << endl;
		BYTE fname[1000];
		INT *Quadrangles;
		INT nb_quadrangles;
		INT size;

		sprintf(fname, "%s_lvl_%ld", TP[i].arcs->fname_base, depth);
		TP[i].An1->read_representatives(fname, Quadrangles, nb_quadrangles, size, verbose_level);
		Nb_subplanes[i] = 0;
		Subplanes[i] = NEW_INT(nb_quadrangles * 7);
		cout << "Found " << nb_quadrangles << " quadrangles, testing for subplanes" << endl;
		for (j = 0; j < nb_quadrangles; j++) {
			if (TP[i].check_if_quadrangle_defines_a_subplane(Quadrangles + j * 4, Subplanes[i] + 7 * Nb_subplanes[i], verbose_level)) {
				Nb_subplanes[i]++;
				}
			}
		}
	for (i = 0; i < nb_reps; i++) {
		cout << "Translation plane " << i << " has " << Nb_subplanes[i] << " quadrangles that span subplanes" << endl;
		cout << "The subplanes are:" << endl;
		INT_matrix_print(Subplanes[i], Nb_subplanes[i], 7);
		}


	for (i = 0; i < nb_reps; i++) {
		cout << "Translation plane " << i << " has " << Nb_subplanes[i] << " quadrangles that span subplanes" << endl;
		}
#endif
	for (i = 0; i < nb_reps; i++) {
		cout << "Translation plane " << i << " has " << Nb_subplanes[i] << " orbits of Fano subplanes" << endl;
		TP[i].arcs->compute_and_print_automorphism_group_orders(depth, cout);


		if (i == 4 || i == 5) {
			INT fst, node, size;
			INT *set;

			set = NEW_INT(depth);
			fst = TP[i].arcs->first_oracle_node_at_level[depth];
			for (j = 0; j < Nb_subplanes[i]; j++) {
				longinteger_object stab_order;
				node = fst + j;
				TP[i].arcs->stabilizer_order(node, stab_order);
				if ((stab_order.as_INT() % 14) == 0) {
					cout << "orbit " << j << " has stabilizer of order " << stab_order << " which is divisible by 14" << endl;
					TP[i].arcs->get_set(node, set, size);
					if (size != depth) {
						cout << "size != depth" << endl;
						exit(1);
						}
					cout << "The subplane is : ";
					INT_vec_print(cout, set, depth);
					cout << endl;


					vector_ge *stab_gens;
					INT *stab_tl;
							
					stab_gens = new vector_ge;
					stab_tl = NEW_INT(TP[i].An1->base_len);

					TP[i].arcs->get_stabilizer(stab_gens, stab_tl, depth, j, 0 /*verbose_level */);
					sims *S;
					longinteger_object Sgo;

					S = create_sims_from_generators_with_target_group_order_factorized(TP[i].An1, 
						stab_gens, stab_tl, TP[i].An1->base_len, 0 /* verbose_level */);
					S->group_order(Sgo);
					cout << "created group of order " << Sgo << endl;

					delete S;
					delete stab_gens;
					FREE_INT(stab_tl);
					}
				}
			FREE_INT(set);
			}

		cout << endl;
		}

	delete [] TP;
	FREE_INT(Nb_subplanes);

#if 0
	for (i = 0; i < nb_reps; i++) {
		FREE_INT(Subplanes[i]);
		}
	FREE_PINT(Subplanes);
#endif

	FREE_INT(Reps);
	for (i = 0; i < nb_reps; i++) {
		FREE_BYTE(Aut_ascii[i]);
		}
	FREE_PBYTE(Aut_ascii);
		
	if (f_v) {
		cout << "do_Fano_subplanes done" << endl;
		}

}
Example #7
0
/**
 * Parses a JSON encoded value to a JSONValue object
 *
 * @access protected
 *
 * @param wchar_t** data Pointer to a wchar_t* that contains the data
 *
 * @return JSONValue* Returns a pointer to a JSONValue object on success, NULL on error
 */
JSONValue *JSONValue::Parse(const wchar_t **data)
{
	// Is it a string?
	if (**data == '"')
	{
		std::wstring str;
		if (!JSON::ExtractString(&(++(*data)), str))
			return NULL;
		else
			return new JSONValue(str);
	}

	// Is it a boolean?
	else if ((simplejson_wcsnlen(*data, 4) && wcsncasecmp(*data, L"true", 4) == 0) || (simplejson_wcsnlen(*data, 5) && wcsncasecmp(*data, L"false", 5) == 0))
	{
		bool value = wcsncasecmp(*data, L"true", 4) == 0;
		(*data) += value ? 4 : 5;
		return new JSONValue(value);
	}

	// Is it a null?
	else if (simplejson_wcsnlen(*data, 4) && wcsncasecmp(*data, L"null", 4) == 0)
	{
		(*data) += 4;
		return new JSONValue();
	}

	// Is it a number?
	else if (**data == L'-' || (**data >= L'0' && **data <= L'9'))
	{
		// Negative?
		bool neg = **data == L'-';
		if (neg) (*data)++;

		double number = 0.0;

		// Parse the whole part of the number - only if it wasn't 0
		if (**data == L'0')
			(*data)++;
		else if (**data >= L'1' && **data <= L'9')
			number = JSON::ParseInt(data);
		else
			return NULL;

		// Could be a decimal now...
		if (**data == '.')
		{
			(*data)++;

			// Not get any digits?
			if (!(**data >= L'0' && **data <= L'9'))
				return NULL;

			// Find the decimal and sort the decimal place out
			// Use ParseDecimal as ParseInt won't work with decimals less than 0.1
			// thanks to Javier Abadia for the report & fix
			double decimal = JSON::ParseDecimal(data);

			// Save the number
			number += decimal;
		}

		// Could be an exponent now...
		if (**data == L'E' || **data == L'e')
		{
			(*data)++;

			// Check signage of expo
			bool neg_expo = false;
			if (**data == L'-' || **data == L'+')
			{
				neg_expo = **data == L'-';
				(*data)++;
			}

			// Not get any digits?
			if (!(**data >= L'0' && **data <= L'9'))
				return NULL;

			// Sort the expo out
			double expo = JSON::ParseInt(data);
			for (double i = 0.0; i < expo; i++)
				number = neg_expo ? (number / 10.0) : (number * 10.0);
		}

		// Was it neg?
		if (neg) number *= -1;

		return new JSONValue(number);
	}

	// An object?
	else if (**data == L'{')
	{
		JSONObject object;

		(*data)++;

		while (**data != 0)
		{
			// Whitespace at the start?
			if (!JSON::SkipWhitespace(data))
			{
				FREE_OBJECT(object);
				return NULL;
			}

			// Special case - empty object
			if (object.size() == 0 && **data == L'}')
			{
				(*data)++;
				return new JSONValue(object);
			}

			// We want a string now...
			std::wstring name;
			if (!JSON::ExtractString(&(++(*data)), name))
			{
				FREE_OBJECT(object);
				return NULL;
			}

			// More whitespace?
			if (!JSON::SkipWhitespace(data))
			{
				FREE_OBJECT(object);
				return NULL;
			}

			// Need a : now
			if (*((*data)++) != L':')
			{
				FREE_OBJECT(object);
				return NULL;
			}

			// More whitespace?
			if (!JSON::SkipWhitespace(data))
			{
				FREE_OBJECT(object);
				return NULL;
			}

			// The value is here			
			JSONValue *value = Parse(data);
			if (value == NULL)
			{
				FREE_OBJECT(object);
				return NULL;
			}

			// Add the name:value
			if (object.find(name) != object.end())
				delete object[name];
			object[name] = value;

			// More whitespace?
			if (!JSON::SkipWhitespace(data))
			{
				FREE_OBJECT(object);
				return NULL;
			}

			// End of object?
			if (**data == L'}')
			{
				(*data)++;
				return new JSONValue(object);
			}

			// Want a , now
			if (**data != L',')
			{
				FREE_OBJECT(object);
				return NULL;
			}

			(*data)++;
		}

		// Only here if we ran out of data
		FREE_OBJECT(object);
		return NULL;
	}

	// An array?
	else if (**data == L'[')
	{
		JSONArray array;

		(*data)++;

		while (**data != 0)
		{
			// Whitespace at the start?
			if (!JSON::SkipWhitespace(data))
			{
				FREE_ARRAY(array);
				return NULL;
			}

			// Special case - empty array
			if (array.size() == 0 && **data == L']')
			{
				(*data)++;
				return new JSONValue(array);
			}

			// Get the value
			JSONValue *value = Parse(data);
			if (value == NULL)
			{
				FREE_ARRAY(array);
				return NULL;
			}

			// Add the value
			array.push_back(value);

			// More whitespace?
			if (!JSON::SkipWhitespace(data))
			{
				FREE_ARRAY(array);
				return NULL;
			}

			// End of array?
			if (**data == L']')
			{
				(*data)++;
				return new JSONValue(array);
			}

			// Want a , now
			if (**data != L',')
			{
				FREE_ARRAY(array);
				return NULL;
			}

			(*data)++;
		}

		// Only here if we ran out of data
		FREE_ARRAY(array);
		return NULL;
	}

	// Ran out of possibilites, it's bad!
	else
	{
		return NULL;
	}
}
Example #8
0
void CUIWaveform3::Destroy()
{
	super::Destroy();

	FREE_OBJECT(m_hBitmapWaveform);
}
void dot11WtpWlanFaultTable_load()
{
	snmp_log(LOG_DEBUG, "enter dot11WtpWlanFaultTable_load\n");

	struct dot11WtpWlanFaultTable_entry *temp = NULL;

	while( dot11WtpWlanFaultTable_head ) {
		temp=dot11WtpWlanFaultTable_head->next;
		dot11WtpWlanFaultTable_removeEntry(dot11WtpWlanFaultTable_head);
		dot11WtpWlanFaultTable_head=temp;
	}

    char temp_mac[20] = { 0 };
    
    snmpd_dbus_message *messageHead = NULL, *messageNode = NULL;
    
    snmp_log(LOG_DEBUG, "enter list_connection_call_dbus_method:show_wtp_list_by_mac_cmd_func\n");
    messageHead = list_connection_call_dbus_method(show_wtp_list_by_mac_cmd_func, SHOW_ALL_WTP_TABLE_METHOD);
	snmp_log(LOG_DEBUG, "exit list_connection_call_dbus_method:show_wtp_list_by_mac_cmd_func,messageHead=%p\n", messageHead);
	
	if(messageHead)
	{
		for(messageNode = messageHead; NULL != messageNode; messageNode = messageNode->next)
		{
		    DCLI_WTP_API_GROUP_ONE *head = messageNode->message;
		    if((head)&&(head->WTP_INFO))
			{
			    void *connection = NULL;
	            if(SNMPD_DBUS_ERROR == get_slot_dbus_connection(messageNode->parameter.slot_id, &connection, SNMPD_INSTANCE_MASTER_V3))
                    continue;
			    int i = 0;
			    WID_WTP *q = NULL;
				for(i = 0,q = head->WTP_INFO->WTP_LIST; (i < head->WTP_INFO->list_len)&&(NULL != q); i++,q=q->next)
				{
            		int ret_one = 0;
            		DCLI_WTP_API_GROUP_ONE *wtp = NULL;
            		
					memset(temp_mac,0,20);
					if(q->WTPMAC)
					{
						snprintf(temp_mac,sizeof(temp_mac)-1,
								 "%02X:%02X:%02X:%02X:%02X:%02X",
								 q->WTPMAC[0],q->WTPMAC[1],
								 q->WTPMAC[2],q->WTPMAC[3],
								 q->WTPMAC[4],q->WTPMAC[5]);
					}

					ret_one = show_wtp_one(messageNode->parameter, connection,q->WTPID,&wtp);
					if(ret_one == 1)
					{
						if((wtp->WTP[0]))
						{
							int j = 0;
							for(j=0;j<wtp->WTP[0]->apply_wlan_num;j++)
							{	
								unsigned long wlanid = local_to_global_ID(messageNode->parameter, wtp->WTP[0]->apply_wlanid[j], WIRELESS_MAX_NUM);
								
								dot11WtpWlanFaultTable_createEntry(messageNode->parameter,
																   q->WTPID,
																   temp_mac,
																   wtp->WTP[0]->apply_wlanid[j],
																   wlanid,
																   0,
																   0,
																   0,
																   0);
							}
						}
						Free_one_wtp_head(wtp);
					}
					else if(SNMPD_CONNECTION_ERROR == ret_one) {
                        close_slot_dbus_connection(messageNode->parameter.slot_id);
            	    }
					FREE_OBJECT(q->WTPMAC);
				}
			}
		}
        free_dbus_message_list(&messageHead, Free_wtp_list_by_mac_head);
	}	
	snmp_log(LOG_DEBUG, "exit dot11WtpWlanFaultTable_load\n");
}