Ejemplo n.º 1
0
//! Initialisierungsroutine
void MainWindow::init()
{
  //! Signal-Slots verbinden
  //! Slot für die Überwachung verbinden
  connect(ui->acMonitoring, SIGNAL(triggered()), this, SLOT(acControling()));

  //! Slot für die Gebietsbehandlung verbinden
  connect(ui->acAreaHandling, SIGNAL(triggered()), this, SLOT(acAreaHandling()));

  //! Slot für die Disposition verbinden
  connect(ui->acAreaDispo, SIGNAL(triggered()), this, SLOT(acAreaDispo()));

  //! Slot für die Definition von Gebieten verbinden
  connect(ui->acDefArea, SIGNAL(triggered()), this, SLOT(acDefArea()));

  //! Slot für die Definition von Teilgebieten verbinden
  connect(ui->acDefAreaPart, SIGNAL(triggered()), this, SLOT(acDefAreaPart()));

  //! Slot für die Definition von Verkündigern verbinden
  connect(ui->acDefProphet, SIGNAL(triggered()), this, SLOT(acDefProphet()));

  //! Slot für die Suche verbinden
  connect(ui->acSearch, SIGNAL(triggered()), this, SLOT(acSearch()));

  //! Slot für das Beenden verbinden
  connect(ui->acExit, SIGNAL(triggered()), this, SLOT(acExit()));

  //! Slot für das Drucken von Gebieten
  connect(ui->acPrintArea, SIGNAL(triggered()), this, SLOT(acPrintArea()));

  //! Slot für das Definieren von Kompanien
  connect(ui->acDefCompany, SIGNAL(triggered()), this, SLOT(acCompanyWidget()));

  //! Slot für das Anzeigen von Informationen
  connect(ui->acInfo, SIGNAL(triggered()), this, SLOT(acInfoWidget()));

  //! Slot für das Anzeigen von Problemen
  connect(ui->acProblem, SIGNAL(triggered()), this, SLOT(acProblemWidget()));


  //! Zeiger auf NULL legen
  _AreaWidget = NULL;
  _AreaPartWidget = NULL;
  _AreaHandlingWidget = NULL;
  _AreaDispoWidget = NULL;
  _ProphetWidget = NULL;
  _ControlWidget = NULL;
  _SearchWidget = NULL;
  _PrintWidget = NULL;
  _CompanyWidget = NULL;
  _InfoWidget = NULL;
  _ProblemWidget = NULL;

  //! Fensterüberschrift setzen
  setWindowTitle(tr("Gebietsbearbeitung"));

  //! Statusleiste initialisieren
  setStatusBar();
}
Ejemplo n.º 2
0
void my_callback(u_char *useless,const struct pcap_pkthdr* pkthdr,const u_char*
        packet)
{
	packet_num++;
	packet_len+=pkthdr->caplen;

    	static   int count = 0;
	//static int nn=0;
	static int i;
	static unsigned short eth_type;
	static int vlan_flag=0;
		//sem_getvalue(&shmp[i]->sem,&semnum);
		//printf("sem:%d\n",semnum);		
	//usleep(1000);
	static int semnum;
//	sem_getvalue(&bin_sem,&semnum);
	//	printf("sem:%d\n",semnum);
		//printf("mmmmmmmmmmmmmm\n");
		if(exitflag)
		{
			/*for(i=0;i<snortnum;++i)
			{
				memcpy(shmp[i]->data[shmp[i]->tail],"########",strlen("########"));
				shmp[i]->tail=(shmp[i]->tail+1)%shmp[i]->looplen;
				my_lock_release(shmp[i]);
			}
		
				sleep(4);

			for(i=0;i<snortnum;++i)
			{
				destroy_loop(shmp[i]);
				DeleteShm(shmid[i]);
			}*/
			for(i=0;i<PRO_MAX+2;++i)
			{
	
				printf("%s:%lld\n",pro_map[i],pronum[i]);
		  	 }
		   	printf("losepacket=%lld\n",losepacket);
			//sem_post(&bin_sem);
			 NS_TIME_END(time);
	
			speed1(NS_GET_TIMEP(time),packet_num,packet_len);

			printf("count=%d,\nfind_pro=%lld\n",count,find_pro);
	
				printf("exit\n");
			del_HB(&hb);
		
			acsmFree (acsm);
		//	exitflag=0;
			exit(0);
		} 
//return;
		 mac=(struct ether_header*)packet;
		 eth_type=ntohs(mac->ether_type);
		
		 if((eth_type==0x8100))
		 {
		 	vlan_flag=1;
		 	//msg("W:****0X%04X\n",eth_type);
		 	eth_type=(packet[16])*256+packet[17];
		 }
		 else
		 	vlan_flag=0;
		
		// msg("W:0X%04X\n",eth_type);
		 if((eth_type!=0x0800))//不是ip数据报
		       	return;
		 if(vlan_flag)
		 	ip=(struct ip*)(packet+size_mac+4);
	 	 else
 			ip=(struct ip*)(packet+size_mac);

		
		/*char ipdotdecs[20]={0};
	       char ipdotdecc[20]={0};
		inet_ntop(AF_INET,(void*)&(ip->ip_src),ipdotdecs,16);
			inet_ntop(AF_INET,(void*)&(ip->ip_dst),ipdotdecc,16);*/
//printf("%s-->%s: len:%d\n",ipdotdecs,ipdotdecc,pkthdr->caplen);

			
		if((ip->ip_p==6))//tcp
		{
		//	msg("EIStcp\n");
			//tcp=(struct fniff_tcp*)(packet+size_mac+size_ip);
			tcp=(struct fniff_tcp*)((char*)ip+size_ip);
			sd.b_ip=(ip->ip_src.s_addr);
			sd.l_ip=(ip->ip_dst.s_addr);
			if(sd.b_ip>sd.l_ip)
			{
				sd.b_port=ntohs(tcp->th_sport);
				sd.l_port=ntohs(tcp->th_dport);
			}
			else
			{
				sd.b_ip^=sd.l_ip;
				sd.l_ip^=sd.b_ip;
				sd.b_ip^=sd.l_ip;
			
				sd.b_port=ntohs(tcp->th_dport);
				sd.l_port=ntohs(tcp->th_sport);					
			}			
			hash=hash_HB(sd.b_ip,sd.b_port,sd.l_ip,sd.l_port);
		
			tcplen=ntohs(ip->ip_len)-(ip->ip_hl*4)-(tcp->th_off*4);
	
		//	msg("EIStcp11111111111\n");
		//	printf("ntohs(ip->ip_len)=%d\n",ntohs(ip->ip_len)+14);
			// packet.tcp_URG=tcp->th_flags&TH_URG;
			  ack=tcp->th_flags&TH_ACK;
			 // packet.tcp_PSH=tcp->th_flags&TH_PUSH;
			  rst=tcp->th_flags&TH_RST;
			  syn=tcp->th_flags&TH_SYN;
			  fin=tcp->th_flags&TH_FIN;
			 datalen=pkthdr->caplen;
		   
			ptcp=(unsigned char*)tcp+(tcp->th_off*4);     	

			temp=find_node(hb[hash].virtual_sn,&sd);  
		  
			if(temp==NULL&&syn&&!ack&&tcplen==0)//not find
		      	{
		      		//msg("E no\n");
		      		SN* q=get_node();
		      		q->sdipport=sd;
		      		q->state=1;
				insert_node(&(hb[hash].virtual_sn),q);
				hb[hash].virtual_sn_num++;
				//msg("**********=%ld\n",hb[hash].virtual_sn_num);
				#if 0				
				if(sd.b_port==21||sd.l_port==21)
				{
					q->state=10;			
					pronum[FTP]++;
				}
				else if(sd.b_port==80||sd.l_port==80)
				{
					q->state=10;
					pronum[HTTP]++;
				}
				memcpy(fortest,packet,pkthdr->caplen);
				#endif
		
		      	}
		      	else if(temp!=NULL)
		      	{
		      		// printf("state:%d\n",temp->state);
		      	
		      		if((temp->state==1)&&syn&&ack&&(tcplen==0))
		      		{
		      			//msg("W:my ooooooooooooooooooo\n");
		      			temp->state=2;
		      		}
		      		else if(temp->state==2&&ack&&!syn&&tcplen==0)
		      		{
		      			temp->state=3;
		      			//msg("W:its ===============================static\n");
		      				//msg("W:my hash:%u\n",hash);
		      		}
		      		else if(temp->state>=3&&temp->state<9)
		      		{
		      			//if(tcplen==0)
		      			//	return;
		      			//msg("W:my hash:%u\n",hash);
		      			//msg("+++++\n");
					//msg("ttttttttttttt\n");
		      			p=get_BC_node();
					//msg("mmmmmmmmm\n");
					if(p==NULL)
						{msg("EISget bc node error\n");exit(0);}
		      			
		      			p->datalen=pkthdr->caplen;
		      			p->tcplen=tcplen;
					//msg("tcplen=%d,pkthdr->caplen=%d\n",tcplen,pkthdr->caplen);
					if(tcplen<0)
					{
						msg("EIS tcp<0\n");
						exit(0);
					}				
		      			p->next=NULL;
		      			memcpy(p->buf,packet,pkthdr->caplen);
					p->ptcp=(unsigned char*)(p->buf)+(tcp->th_off*4)+((unsigned char*)tcp-(unsigned char*)mac);//ptcp;
		      			temp->tcp_content_len+=tcplen;			
		      			if(temp->bc_head==NULL)
		      			{
		      				temp->bc_head=temp->bc_tail=p;
		      			}
		      			else
		      			{
		      				temp->bc_tail->next=p;
		      				temp->bc_tail=p;
		      			}
		      			temp->state++;
		      			if((temp->state==9)||rst||fin||(temp->tcp_content_len>150))
		      			{
		      				//msg("EIS static\n");
						#if 0
		      				p=temp->bc_head;
		      				while(p!=NULL)
		      				{				
							if(p->tcplen!=0)
							acsmSearch(acsm,p->ptcp,p->tcplen,PrintMatch);
		      					p=p->next;
		      				}
						#else
						acSearch(acsm,temp->bc_head);
		      				acSearch(acsm,temp->bc_head);
						#endif
		      				i=getSummary(acsm->acsmPatterns,feature_num); 
						    		
		      				pronum[i]++;
						temp->proto=i;
		      				if(rst||fin)
		      				{
							temp->state=10;
							resume_BC_node(temp->bc_head);
		      					resume_node(temp);
		      					hb[hash].virtual_sn_num--;
		      					
							//msg("*********=%ld\n",hb[hash].virtual_sn_num);
							if(hb[hash].virtual_sn_num==0)
								hb[hash].virtual_sn=NULL;
		      					return;
		      				}
		      				temp->state=10;
		      				resume_BC_node(temp->bc_head);
			      			temp->bc_head=NULL;
			      			temp->bc_tail=NULL;
		      			}
		      			
		      		}
		      		else if(temp->state>=10)
		      		{	

		      			if(rst||fin)
					{
						//resume_node(temp);
						move_node(&(hb[hash].virtual_sn),temp);
						hb[hash].virtual_sn_num--;
						//msg("**************=%ld\n",hb[hash].virtual_sn_num);
						if(hb[hash].virtual_sn_num==0)
							hb[hash].virtual_sn=NULL;
						return;
					}
		      		} 
				else
				{
					msg("ggggggggggg\n");
				}
		      		
		      	}     	
			
			    
	     }//tcp
	     else if(ip->ip_p==1)//icmp
	     {
		//printf("2222\n");
	     	//static char pro_map[PRO_MAX+2][20]={"HTTP","FTP","POP3","SMTP","UNKOWN","UDP","ICMP"};
	 	pronum[PRO_MAX+1]++;
	    }
	    else if(ip->ip_p==17)//udp
	    	{
			//printf("1111111\n");
	    		pronum[PRO_MAX]++;
	    	}   
		else
		{
			printf("no\n");
		}
}