if (startRow > endRow || startCol > endCol) return -1; 
 for (int i = startRow; i <= endRow; i++)  {   for (int j = startCol; j <=endCol; j++)   {    cells [i * cols + j].SetSpan(0,0);   }  }  cells [startRow * cols + startCol].SetSpan(endRow - startRow+1, endCol - startCol+1);  return 0; } 
 
  其"反函数"为: 
int XTable::UnjoinCells (int row, int col) {  if (row < 0 || row >= this->rows) return -1;  if (col < 0 || col >= this->cols) return -1; 
 if (cells [row * cols + col].rowSpan <= 1 && cells [row * cols + col].colSpan <= 1 )   return -1; 
 for (int i = row; i <= row + cells [row * cols + col].rowSpan; i++)  {   for (int j = col; j <= cells [row * cols + col].colSpan; j++)   {    cells[i*cols+j] = defaultCell;    cells [i * cols + j].SetSpan(1,1);   }  }  return 0; } 
 
  程序中的IDC_ADAPTERLIST_COMBO控件用于提供用户选择本地适配器,获得本地适配器列表的代码如下(也处于对话框的初始化函数中): 
char errbuf[PCAP_ERRBUF_SIZE]; /* 取得列表 */ if (pcap_findalldevs(&alldevs, errbuf) == - 1) {  AfxMessageBox("获得网卡列表失败!\n");  GetDlgItem(IDC_STARTSTOP_BUTTON)->EnableWindow(FALSE); } 
/* 输出列表 */ for (d = alldevs; d; d = d->next) {  CString str(d->name);  if (str.Find("\\Device\\NPF_Generic", 0) == - 1)   m_adapterList.AddString(str); } 
 
  给监控IP地址范围内的主机发送ARP请求包并获取反馈,即可获得监控范围内活动机器的IP地址和MAC地址,以进行进一步地管理。 
  发送ARP请求的函数代码: 
void SendArpReq(unsigned long srcIp,unsigned long desIp,UCHAR * srcMac) {  char sendbuf[1024];  ETHDR eth;  ARPHDR arp; 
 memcpy(eth.eh_src,mmac,6);  eth.eh_type=htons(ETH_ARP); 
 arp.arp_hdr=htons(ARP_HARDWARE);  arp.arp_pro=htons(ETH_IP);  arp.arp_hln=6;  arp.arp_pln=4;  arp.arp_opt=htons(ARP_REQUEST);  arp.arp_spa=htonl(srcIp);  arp.arp_tpa=htonl(desIp);  memcpy(arp.arp_sha,srcMac,6); 
 for(int i=0;i<6;i++)  {   eth.eh_dst[i]=0xff; 
 
		      
		      
		      
		      
		      
		      
                       
		      
		        
		      共15页: 上一页 [1] [2] 3 [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] 下一页 
		     |