FireWall1View.cpp
上传用户:heseme
上传日期:2009-12-23
资源大小:228k
文件大小:34k
开发平台:

Visual C++

  1. // FireWall1View.cpp : implementation of the CFireWall1View class
  2. //
  3. #include "stdafx.h"
  4. #include "FireWall1.h"
  5. #include "Struct.h"
  6. #include "ip.h"
  7. #include "global.h"
  8. #include "config.h"
  9. #include "outnat.h"
  10. //#include "ipfilter.h"
  11. #include "authentication.h"
  12. #include "OptionDlg.h"
  13. #include "LogDlg.h"
  14. #include "Propsheet.h"
  15. #include "FireWall1Doc.h"
  16. #include "FireWall1View.h"
  17. #include "page1.h"
  18. #include "page3.h"
  19. #include "page4.h"
  20. #include "page5.h"
  21. #include "page6.h"
  22. #ifdef _DEBUG
  23. #define new DEBUG_NEW
  24. #undef THIS_FILE
  25. static char THIS_FILE[] = __FILE__;
  26. #endif
  27.  BOOL iiii=TRUE;
  28. BOOL isFirst=TRUE;
  29. HWND myhWnd1;
  30. extern char tmpin[5];//用于存取网卡设备号
  31. extern char tmpout[5];
  32. extern char tmpdm[5];
  33. extern BYTE INNO;
  34. extern BYTE OUTNO;
  35. extern BYTE DMNO;
  36. CDataConvert gDataConvert;
  37. extern  VOID SetFilterInitReq(struct FireWallConfig  mycfg);
  38. extern  VOID SetFilterlogMask();
  39. extern  int SetFilterRejTab(CPtrList &listRejIp);
  40. extern  int SetFilterAcceptTab(CPtrList &listRejIp);
  41. extern  VOID SetFilterAddrTree(struct IpaddrRange iprange,USHORT group);
  42. extern  VOID SetFilterPortList(struct  HostList* phostlist,UCHAR type,unsigned short group);
  43. extern  VOID SetFilterCfg(struct FireWallConfig  mycfg,struct GlobalFlags myflags);
  44. extern  VOID StartFilter();
  45. extern  USHORT treeLookup (addrTreeNode *tbl, ULONG addr, unsigned short max_group);
  46. extern  VOID mysearch();
  47. extern  VOID clearipfilter();
  48. extern  int SetDmIpTab(CPtrList &listRejIp,UCHAR type);
  49. extern  VOID GetStatisticsInfo(Statistics* StatisticInfo);
  50. extern  VOID ClearStatisticsInfo();
  51. extern void ClearNatUseResoure();
  52. extern void NatCfg();
  53. extern LogManage MyLogManage;
  54. LogManage TheLogManage;
  55. extern UserVerifyData MyUserVerifyData;
  56. UserVerifyData TheUserVerifyData;
  57. extern DefaultSetData TheDefaultSetData;
  58. extern ServiceManageData MyServiceManageData;
  59. ServiceManageData TheServiceManageData;
  60. BOOL CloseAll;//用于表示程序要关闭
  61. DWORD dwThreadId_in;
  62. DWORD dwThreadId_out;
  63. DWORD dwThreadId_write;
  64. HANDLE global_handle,global_handle1;
  65. BOOL Read_Open;
  66. HANDLE mythread_in;
  67. HANDLE mythread_out;
  68. HANDLE mythread_write;
  69. extern NATTABLE_ITEM*     nattable;
  70. extern NetCardProp myNetCardProp[8]; 
  71. struct  NAT_Cfg pnatcfg;
  72. in_addr_t OutGlobalAddr;
  73. BOOL m_binit=FALSE;
  74. BOOL bAppClose=FALSE;
  75. BOOL bPropsheetOpen=FALSE;
  76. //extern FILE *hlogFile;
  77. USHORT logType=0;
  78. USHORT StoplogType=0;
  79. /////////////////////////////////////////////////////////////////////////////
  80. // CFireWall1View
  81. extern BYTE INNO;
  82. extern BYTE OUTNO;
  83. extern BYTE DMNO;
  84. BOOL flag = FALSE;
  85. int number=-1;
  86. #define MAXITEMNUMBER 20
  87. LV_ITEM lvItem;
  88. LV_ITEM lvItem1;
  89. //   CListCtrl m_listView;
  90.  //   CListCtrl m_listView1;
  91. FILE * pfoutDeviceInit;
  92. FILE * pfoutServiceInit;
  93. FILE * pfoutUserverInit;
  94. FILE * pfoutLogsetInit;
  95. FILE * pfoutDefaultInit;
  96. IMPLEMENT_DYNCREATE(CFireWall1View, CScrollView)
  97. char NETMASK[20];//内网子网眼吗
  98. extern IPAddr    mask;//
  99. BEGIN_MESSAGE_MAP(CFireWall1View, CScrollView)
  100. //{{AFX_MSG_MAP(CFireWall1View)
  101. ON_COMMAND(ID_OPTION, OnOption)
  102. ON_WM_CREATE()
  103. ON_WM_DESTROY()
  104. ON_COMMAND(ID_STARTFILTER, OnStartfilter)
  105. ON_COMMAND(ID_SEARCH, OnSearch)
  106. ON_COMMAND(ID_CLOSEFILTER, OnClosefilter)
  107. ON_COMMAND(ID_SETDATA, OnSetdata)
  108. ON_COMMAND(ID_STARTFIREWALL, OnStartfirewall)
  109. ON_UPDATE_COMMAND_UI(ID_STARTFIREWALL, OnUpdateStartfirewall)
  110. ON_UPDATE_COMMAND_UI(ID_STARTFILTER, OnUpdateStartfilter)
  111. ON_COMMAND(ID_SHUTDOWNFIREWALL, OnShutdownfirewall)
  112. ON_UPDATE_COMMAND_UI(ID_SHUTDOWNFIREWALL, OnUpdateShutdownfirewall)
  113. ON_COMMAND(ID_TOOL_LOG, OnToolLog)
  114. ON_UPDATE_COMMAND_UI(ID_TOOL_LOG, OnUpdateToolLog)
  115. ON_COMMAND(ID_PROTLOG, OnProtlog)
  116. ON_UPDATE_COMMAND_UI(ID_PROTLOG, OnUpdateProtlog)
  117. ON_UPDATE_COMMAND_UI(ID_OPTION, OnUpdateOption)
  118. ON_COMMAND(ID_FILTERLOG, OnFilterlog)
  119. ON_UPDATE_COMMAND_UI(ID_FILTERLOG, OnUpdateFilterlog)
  120. ON_UPDATE_COMMAND_UI(ID_EXIT, OnUpdateExit)
  121. ON_UPDATE_COMMAND_UI(ID_CLOSEFILTER, OnUpdateClosefilter)
  122. ON_UPDATE_COMMAND_UI(ID_APP_EXIT, OnUpdateAppExit)
  123. ON_COMMAND(ID_STOP_LOG, OnStopLog)
  124. //}}AFX_MSG_MAP
  125. ON_MESSAGE(M_LOGVIEW,OnLogView)
  126. END_MESSAGE_MAP()
  127. /////////////////////////////////////////////////////////////////////////////
  128. // CFireWall1View construction/destruction
  129. CFireWall1View::CFireWall1View()
  130. {
  131. // TODO: add construction code here
  132. memset(NETMASK,0,20);
  133. if(!m_binit)
  134. {
  135. Read_Open=FALSE;
  136.     memset(&adapter,0,sizeof(CONTROL_BLOCK));
  137. // pnatcfg=new struct NAT_Cfg;
  138. bCfgOpen=FALSE;
  139. }
  140. CloseAll=FALSE;
  141. memset(tmpin,0,5);
  142. memset(tmpout,0,5);
  143. memset(tmpdm,0,5);
  144. }
  145. CFireWall1View::~CFireWall1View()
  146. {
  147. if(!bAppClose)
  148. {
  149. if(m_bStartFirewall)
  150. {
  151.       if((DWORD)pnatcfg.StaticTable.item!=NULL)
  152.       delete []pnatcfg.StaticTable.item;
  153.   ClearNatUseResoure();
  154.   bAppClose=TRUE;
  155. }
  156. }
  157. }
  158. BOOL CFireWall1View::PreCreateWindow(CREATESTRUCT& cs)
  159. {
  160. // TODO: Modify the Window class or styles here by modifying
  161. //  the CREATESTRUCT cs
  162. return CScrollView::PreCreateWindow(cs);
  163. }
  164. /////////////////////////////////////////////////////////////////////////////
  165. // CFireWall1View drawing
  166. void CFireWall1View::OnDraw(CDC* pDC)
  167. {
  168. CFireWall1Doc* pDoc = GetDocument();
  169. ASSERT_VALID(pDoc);
  170. // TODO: add draw code for native data here
  171. }
  172. /////////////////////////////////////////////////////////////////////////////
  173. // CFireWall1View diagnostics
  174. #ifdef _DEBUG
  175. void CFireWall1View::AssertValid() const
  176. {
  177. CScrollView::AssertValid();
  178. }
  179. void CFireWall1View::Dump(CDumpContext& dc) const
  180. {
  181. CScrollView::Dump(dc);
  182. }
  183. CFireWall1Doc* CFireWall1View::GetDocument() // non-debug version is inline
  184. {
  185. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CFireWall1Doc)));
  186. return (CFireWall1Doc*)m_pDocument;
  187. }
  188. #endif //_DEBUG
  189. /////////////////////////////////////////////////////////////////////////////
  190. // CFireWall1View message handlers
  191. void CFireWall1View::OnOption() 
  192.     bCfgOpen=TRUE;
  193. CPropSheet propSheet("防火墙设置", this, 0);
  194.     int result = propSheet.DoModal();
  195.     if (result == IDOK)
  196.     {
  197. // memcpy((void *)&TheLogManage,(void *)&MyLogManage,sizeof(LogManage));
  198.       OnCfgnat();
  199.   UserToKernel();
  200.   clearipfilter();
  201.       m_bStartFilter=FALSE;
  202.       Startfilter();
  203.       m_bStartFilter=TRUE;
  204.     }
  205. bCfgOpen=FALSE;
  206. }
  207. int CFireWall1View::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  208. {
  209. if (CScrollView::OnCreate(lpCreateStruct) == -1)
  210. return -1;
  211. GetInitDataFromFile();
  212. if(!m_binit)
  213. {
  214.     m_bStartFirewall=FALSE;
  215.     m_bStartFilter=FALSE;
  216. //从文件中读取配置
  217. gDataConvert.ReadFromFile();
  218. //转换到主机结构中
  219.     gDataConvert.InitHostList();
  220. //转换到firewall与全局结构中
  221.     gDataConvert.InitFireWall();
  222. OutGlobalAddr.ss_addr=gDataConvert.m_firewallconfig.nOutsideIp;
  223. CEdit noused;
  224.     gDataConvert.AddIpTable(INITALLOWIPTAB,noused);
  225. gDataConvert.AddIpTable(INITREJIPTAB,noused);
  226. gDataConvert.AddIpTable(INITOUTDMTAB,noused);
  227. gDataConvert.AddIpTable(INITINDMTAB,noused);
  228.     bCfgOpen=TRUE;
  229. CPropSheet propSheet("防火墙设置", this, 0);
  230.     int result = propSheet.DoModal();
  231. //    myhWnd1=m_hWnd;
  232. //    if (result == IDOK)
  233. //    {
  234.   UserToKernel();
  235.       OnOpensys();
  236.   SetNetData();//以后写在配置命令发生器
  237. //      gDataConvert.SetNatCfg(&pnatcfg);
  238.       OnCfgnat();
  239.   NatCfg();
  240.   ::CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)TimeBeginThread,NULL,0,NULL);
  241.   OnReadsys();
  242.       Startfilter();
  243.       m_bStartFirewall=TRUE;
  244.       m_bStartFilter=TRUE; 
  245. // }
  246. bCfgOpen=FALSE; 
  247. m_binit=TRUE;
  248. myhWnd1=m_hWnd;
  249. }
  250. return 0;
  251. }
  252. void CFireWall1View::OnDestroy() 
  253. {
  254.   CScrollView::OnDestroy();
  255.   if(!bAppClose)
  256.   {
  257.    gDataConvert.WriteToFile();
  258.    clearipfilter();
  259.   }
  260. }
  261. void CFireWall1View::OnStartfilter() 
  262. {
  263.    Startfilter();
  264.    m_bStartFilter=TRUE;
  265. }
  266. void CFireWall1View::OnSearch() 
  267. {
  268. //  mysearch();
  269. // USHORT RET=ntohs(0xFF1F);
  270. }
  271. void CFireWall1View::OnInitialUpdate() 
  272. {
  273. CScrollView::OnInitialUpdate();
  274. CSize sizeTotal;
  275. // TODO: calculate the total size of this view
  276. sizeTotal.cx = 100;
  277. sizeTotal.cy = 300;
  278. SetScrollSizes(MM_TEXT, sizeTotal);
  279. CreateListView();
  280. }
  281. void CFireWall1View::CreateListView()
  282. {
  283. m_smallImageList.Create(16,16,FALSE,1,0);
  284. m_largeImageList.Create(32,32,FALSE,1,0);
  285. HICON hIcon = ::LoadIcon(AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON1));
  286. m_smallImageList.Add(hIcon);
  287. hIcon = ::LoadIcon(AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON2));
  288. m_largeImageList.Add(hIcon);
  289. RECT rect;
  290. GetClientRect(&rect);
  291. rect.bottom = 768;
  292. rect.right = 1024;
  293. int row = 0,col = 0;
  294. lvItem.mask = LVIF_TEXT|LVIF_IMAGE|LVIF_STATE;
  295. lvItem.state = 0;
  296. lvItem.stateMask = 0;
  297. lvItem.iImage = 0;
  298. lvItem.iItem = -1;
  299. lvItem.iSubItem = 0;
  300. row = 0,col=0;
  301. m_listView1.Create(WS_CHILD|WS_VISIBLE|LVS_REPORT,
  302. rect,this/*m_wndSplitter.GetActivePane(&row,&col)*/,IDC_LISTVIEW);
  303. m_listView1.SetImageList(&m_smallImageList,LVSIL_SMALL);
  304. m_listView1.SetImageList(&m_largeImageList,LVSIL_NORMAL);
  305. //Create the column
  306. LV_COLUMN lvColumn1;
  307. lvColumn1.mask = LVCF_FMT|LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM;
  308. lvColumn1.fmt = LVCFMT_CENTER;
  309. lvColumn1.cx = 135;
  310. lvColumn1.pszText = "时间";
  311. m_listView1.InsertColumn(0,&lvColumn1);
  312. lvColumn1.pszText = "协议";
  313. m_listView1.InsertColumn(1,&lvColumn1);
  314. lvColumn1.pszText = "源地址(:端口)";
  315. m_listView1.InsertColumn(2,&lvColumn1);
  316. lvColumn1.pszText = "目的地址(:端口)";
  317. m_listView1.InsertColumn(3,&lvColumn1);
  318. lvColumn1.pszText = "说明";
  319. m_listView1.InsertColumn(4,&lvColumn1);
  320. lvColumn1.pszText = "ICMP类型";
  321. m_listView1.InsertColumn(5,&lvColumn1);
  322. lvItem1.mask = LVIF_TEXT|LVIF_IMAGE|LVIF_STATE;   
  323. }
  324. void CFireWall1View::OnOpensys() 
  325. {
  326. // TODO: Add your command handler code here
  327. GetAdpaterName(adapter.AdapterName);
  328. //上一句调用可以省略,应为他获得适配器的符号连接
  329. adapter.BufferSize = MAX_PACKET_SIZE;
  330. AollocateReadBuffer();
  331.     adapter.hFile = OpenAdapter(adapter.AdapterName);
  332. }
  333. void CFireWall1View::GetAdpaterName(LPTSTR pStr)
  334. {
  335.     HKEY            SystemKey;
  336.     HKEY            ControlSetKey;
  337.     HKEY            ServicesKey;
  338.     HKEY            NdisPerfKey;
  339.     HKEY            LinkageKey;
  340.     LONG            Status;
  341.     DWORD           RegType;
  342.     ULONG BufferSize;
  343. BufferSize=256;//128;
  344.     Status = RegOpenKeyEx(
  345.             HKEY_LOCAL_MACHINE,
  346.             TEXT("SYSTEM"),
  347.             0,
  348.             KEY_READ,
  349.             &SystemKey
  350.             );
  351.     if (Status == ERROR_SUCCESS)
  352.     {
  353.         Status = RegOpenKeyEx(
  354.                 SystemKey,
  355.                 TEXT("CurrentControlSet"),
  356.                 0,
  357.                 KEY_READ,
  358.                 &ControlSetKey
  359.                 );
  360.         if (Status == ERROR_SUCCESS)
  361.         {
  362.             Status = RegOpenKeyEx(
  363.                     ControlSetKey,
  364.                     TEXT("Services"),
  365.                     0,
  366.                     KEY_READ,
  367.                     &ServicesKey
  368.                     );
  369.             if (Status == ERROR_SUCCESS)
  370.             {
  371.                 Status = RegOpenKeyEx(
  372.                         ServicesKey,
  373.                         TEXT("ImSamp"),
  374.                         0,
  375.                         KEY_READ,
  376.                         &NdisPerfKey
  377.                         );
  378.                 if (Status == ERROR_SUCCESS)
  379.                 {
  380.                     Status = RegOpenKeyEx(
  381.                             NdisPerfKey,
  382.                             TEXT("Linkage"),
  383.                             0,
  384.                             KEY_READ,
  385.                             &LinkageKey
  386.                             );
  387.                     if (Status == ERROR_SUCCESS)
  388.                     {
  389.                         Status = RegQueryValueEx(
  390.                                 LinkageKey,
  391.                                 TEXT("Export"),
  392.                                 NULL,
  393.                                 &RegType,
  394.                                 (LPBYTE) pStr,
  395.                                 &BufferSize
  396.                                 );
  397.                         RegCloseKey(LinkageKey);
  398.                     }
  399.                     RegCloseKey(NdisPerfKey);
  400.                 }
  401.                 RegCloseKey(ServicesKey);
  402.             }
  403.             RegCloseKey(ControlSetKey);
  404.         }
  405.         RegCloseKey(SystemKey);
  406.     }
  407.     return ;
  408. }
  409. HANDLE CFireWall1View::OpenAdapter(LPTSTR name)
  410. {
  411.            LPADAPTER       lpAdapter;
  412.     ULONG           Error;
  413.     TRACE(_T("OpenAdaptern"));
  414.     HGLOBAL hMem = GlobalAlloc(
  415.             GMEM_MOVEABLE | GMEM_ZEROINIT,
  416.             sizeof(ADAPTER));
  417.     lpAdapter=(LPADAPTER) GlobalLock(hMem);
  418.     if (lpAdapter == NULL)
  419.     {
  420.         AfxMessageBox(_T("OpenAdapter GlobalAlloc Failedn"));
  421.         return NULL;
  422.     }
  423. memset(name,0,128);
  424. // wcscpy(name,_T("\Device\ImSamp"));
  425.     memcpy(name,_T("\Device\ImSamp"),40);
  426. //因为在SYS中符号连接指明为“\Device\ImSamp”
  427.     wsprintf(
  428.             lpAdapter->SymbolicLink,
  429.             TEXT("\\.\%s"),
  430.             &name[8]);
  431.     
  432.     lpAdapter->hFile = CreateFile(lpAdapter->SymbolicLink,
  433.             GENERIC_WRITE | GENERIC_READ,
  434.             0,
  435.             NULL,
  436.             OPEN_EXISTING,
  437.             FILE_FLAG_OVERLAPPED,
  438.             0);
  439. global_handle1=lpAdapter->hFile;
  440. BOOL DUP=DuplicateHandle(GetCurrentProcess(),
  441. lpAdapter->hFile,
  442. GetCurrentProcess(),
  443. &global_handle,
  444. NULL,
  445. FALSE,
  446. DUPLICATE_SAME_ACCESS);
  447. DWORD aa=GetLastError();
  448.     if (lpAdapter->hFile != INVALID_HANDLE_VALUE)
  449. {
  450.     return lpAdapter;
  451. }
  452.     Error = GetLastError();
  453.     AfxMessageBox(_T("OpenAdapter Could not open adaptern"));
  454.     
  455. GlobalUnlock(lpAdapter);
  456.     GlobalFree(lpAdapter);
  457.     return NULL;
  458. }
  459. void CFireWall1View::OnReadsys() 
  460. {       
  461. // TODO: Add your command handler code here
  462. CloseAll=0;
  463. pReadBuffer->Buffer=adapter.PacketBuffer;
  464.     pReadBuffer->Length=adapter.BufferSize;
  465. mythread_in=::CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)ReadInThread,NULL,0,&dwThreadId_in);//(LPTHREAD_START_ROUTINE)
  466. mythread_out=::CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)ReadOutThread,NULL,0,&dwThreadId_out);//(LPTHREAD_START_ROUTINE)
  467. mythread_write=::CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)WriteThread,NULL,0,&dwThreadId_write);
  468. SetThreadPriority(mythread_write,THREAD_PRIORITY_ABOVE_NORMAL);
  469. if((mythread_in!=NULL)&&(mythread_out!=NULL))Read_Open=TRUE;
  470. TRACE(_T("BGING"));
  471. }
  472. void CFireWall1View::CloseSys(LPADAPTER lpAdapter)
  473. {
  474. if(lpAdapter)
  475. {
  476.       if(lpAdapter->hFile)
  477.   {  
  478.   BOOL ok=CloseHandle(lpAdapter->hFile);
  479.         
  480.       GlobalUnlock(lpAdapter);
  481.           GlobalFree(lpAdapter);
  482.   }
  483. }
  484. }
  485. LPPACKET CFireWall1View::AollocateReadBuffer()
  486. {
  487.     //LPPACKET buffer;     
  488.     HGLOBAL hMem  = GlobalAlloc(
  489.             GMEM_MOVEABLE | GMEM_ZEROINIT,
  490.             sizeof(PACKET));
  491. int a=sizeof(PACKET);
  492.     pReadBuffer=(LPPACKET)GlobalLock(hMem);
  493.     if (pReadBuffer == NULL)
  494.     {
  495.         AfxMessageBox(_T("AllocatePacket: GlobalAlloc Failedn"));
  496.         return NULL;
  497.     }
  498.     pReadBuffer->OverLappedread.hEvent = CreateEvent(
  499.             NULL,
  500.             TRUE,
  501.             FALSE,
  502.             NULL);
  503.     #if defined _DEBUG
  504.     ULONG err=GetLastError();
  505.     #endif
  506.     if (pReadBuffer->OverLappedread.hEvent == NULL)
  507.     {
  508.         AfxMessageBox(_T("AllocatePacket: CreateEvent Failedn"));
  509.         
  510. GlobalUnlock(pReadBuffer);
  511.         GlobalFree(pReadBuffer);
  512.         return NULL;
  513.     }
  514.  pReadBuffer->OverLappedwrite.hEvent = CreateEvent(
  515.             NULL,
  516.             TRUE,
  517.             FALSE,
  518.             NULL);
  519.     #if defined _DEBUG
  520.     err=GetLastError();
  521.     #endif
  522.     if (pReadBuffer->OverLappedwrite.hEvent == NULL)
  523.     {
  524.         AfxMessageBox(_T("AllocatePacket: CreateEvent Failedn"));
  525.         
  526. GlobalUnlock(pReadBuffer);
  527.         GlobalFree(pReadBuffer);
  528.         return NULL;
  529.     }
  530.      
  531.     return pReadBuffer;
  532. }
  533. VOID CFireWall1View::FreeReadBuffer(PVOID buffer)
  534. {
  535.     CloseHandle(((LPPACKET)buffer)->OverLappedread.hEvent);
  536. CloseHandle(((LPPACKET)buffer)->OverLappedwrite.hEvent);
  537.     GlobalFree(buffer);
  538. }
  539. BOOL CFireWall1View::PacketReceiveBuffer(LPADAPTER AdapterObject, LPPACKET lpPacket, BOOLEAN Sync, PULONG BytesReceived)
  540. {
  541.      
  542.     lpPacket->OverLappedread.Offset = 0;
  543.     lpPacket->OverLappedread.OffsetHigh = 0;
  544. /*
  545.     if (!ResetEvent(lpPacket->OverLappedread.hEvent))
  546.     {
  547.         #if defined _DEBUG
  548.         ULONG err=GetLastError();
  549.         #endif
  550.         return FALSE;
  551.     }
  552. */  
  553. /*
  554.     Result = ReadFile(
  555.             AdapterObject->hFile,
  556.             lpPacket->Buffer,
  557.             lpPacket->Length,
  558.             BytesReceived,
  559.             &lpPacket->OverLappedread);
  560.     #if defined _DEBUG
  561.     ULONG err=GetLastError();
  562.     #endif 
  563.     if (Sync)
  564.     {
  565.         Result = GetOverlappedResult(
  566.                 AdapterObject->hFile,
  567.                 &lpPacket->OverLappedread,
  568.                 BytesReceived,
  569.                 TRUE);
  570.         
  571. #if defined _DEBUG
  572.         ULONG err=GetLastError();
  573.         #endif
  574.         TRACE(_T("RECIEVE OK"));
  575.     }
  576.     else
  577.     {
  578.         Result = TRUE;
  579.     }
  580. */
  581.     return TRUE;
  582. }
  583. BOOL CFireWall1View::PacketWriteBuffer(LPADAPTER AdapterObject, LPPACKET lpPacket, BOOLEAN Sync, PULONG BytesWrited)
  584. {
  585. BOOL            Result;
  586.     lpPacket->OverLappedwrite.Offset = 0;
  587.     lpPacket->OverLappedwrite.OffsetHigh = 0;
  588.     if (!ResetEvent(lpPacket->OverLappedwrite.hEvent))
  589.     {
  590.         #if defined _DEBUG
  591.         ULONG err=GetLastError();
  592.         #endif
  593.         return FALSE;
  594.     }
  595.     Result = WriteFile(
  596.             AdapterObject->hFile,
  597.             lpPacket->Buffer,
  598.             lpPacket->Length,
  599.             BytesWrited,
  600.             &lpPacket->OverLappedwrite);
  601.     #if defined _DEBUG
  602.     ULONG err=GetLastError();
  603.     #endif 
  604.     if (Sync)
  605.     {
  606.         Result = GetOverlappedResult(
  607.                 AdapterObject->hFile,
  608.                 &lpPacket->OverLappedwrite,
  609.                 BytesWrited,
  610.                 TRUE);
  611.         
  612. #if defined _DEBUG
  613.         ULONG err=GetLastError();
  614.         #endif
  615. //        TRACE(_T("Write OK"));
  616.     }
  617.     else
  618.     {
  619.         Result = TRUE;
  620.     }
  621.     return Result;
  622.    
  623. }
  624. void CFireWall1View::OnClosethread() 
  625. {
  626. // TODO: Add your command handler code here
  627. CloseAll=TRUE;   
  628. //CloseSys((ADAPTER* )adapter.hFile);
  629. }
  630. void CFireWall1View::OnClosesys() 
  631. {
  632. // TODO: Add your command handler code here
  633. BOOL ok;
  634. CloseSys((ADAPTER* )adapter.hFile);
  635. ok=CloseHandle(global_handle);
  636. }
  637. void CFireWall1View::OnClosefilter() 
  638. {
  639. clearipfilter();
  640.     m_bStartFilter=FALSE;
  641. }
  642. void CFireWall1View::OnSetdata() 
  643. {
  644. // TODO: Add your command handler code here
  645. ULONG           BytesReturned;
  646. BYTE  temp[40];
  647. memset(temp,0,40);
  648. int no;
  649. for(int i=0;i<8;i++)
  650. {
  651. no=myNetCardProp[i].DeviceNo;
  652. if(no)
  653. {
  654. if(myNetCardProp[i].Flag==0)
  655. {
  656. if(gDataConvert.globalFlags.bCheckInNetAttack)
  657. temp[no]=1;
  658. }
  659. if(myNetCardProp[i].Flag==1)
  660. {
  661. if(gDataConvert.globalFlags.bCheckOutNetAccack)
  662. temp[no]=3;
  663. }
  664. if(myNetCardProp[i].Flag==2)
  665. {
  666. // if(gDataConvert.globalFlags.bCheckDmAccack)
  667. // temp[no]=3;
  668. }
  669. }
  670. }
  671. /* temp[0] = 0;
  672. temp[1] = 0;
  673. temp[2] = 0;
  674. temp[3] = 3;
  675. temp[4] = 0;
  676. temp[5] = 3;
  677. temp[6] = 0;
  678. temp[7] = 0;
  679. */
  680. BOOL ok = DeviceIoControl(
  681.             global_handle,
  682.             0x8000,
  683.             temp,
  684.             8,
  685.             NULL,
  686.             0,
  687.             &BytesReturned,
  688.             NULL
  689.             );
  690. if(ok)
  691. TRACE(_T("OKOKOKOKOKOKOKOKOKn"));
  692. }
  693. void CFireWall1View::OnCfgnat() 
  694. {
  695. // if(pnatcfg)
  696. // {
  697. if((DWORD)pnatcfg.StaticTable.item!=NULL)
  698. {
  699.           delete []pnatcfg.StaticTable.item;
  700.           pnatcfg.StaticTable.item=NULL;
  701. }
  702.     memset(&pnatcfg,0,sizeof(struct NAT_Cfg));
  703. // }
  704.     gDataConvert.SetNatCfg(&pnatcfg);
  705. }
  706. void CFireWall1View::OnStartfirewall() 
  707. {
  708. // TODO: Add your command handler code here
  709. /*   OnOpensys();
  710. gDataConvert.SetNatCfg(&pnatcfg);
  711. SetNetData();//以后写在配置命令发生器
  712. NatCfg();
  713. OnReadsys();
  714.     Startfilter();//add
  715. */
  716. SetNetData();//以后写在配置命令发生器
  717.     m_bStartFirewall=TRUE;
  718. }
  719. void CFireWall1View::OnUpdateStartfirewall(CCmdUI* pCmdUI) 
  720. {
  721. // TODO: Add your command update UI handler code here
  722. pCmdUI->Enable(!m_bStartFirewall);
  723. }
  724. void CFireWall1View::OnUpdateStartfilter(CCmdUI* pCmdUI) 
  725. {
  726. // TODO: Add your command update UI handler code here
  727.     pCmdUI->Enable((!m_bStartFilter)||(!m_bStartFirewall));
  728. }
  729. void CFireWall1View::OnShutdownfirewall() 
  730. {
  731. // TODO: Add your command handler code here
  732. /* clearipfilter();
  733.     OnClosethread();
  734.     OnClosesys();
  735. // ClearNatUseResoure();
  736. // if(pnatcfg)
  737. // {
  738.       if((DWORD)pnatcfg.StaticTable.item!=NULL)
  739.       delete []pnatcfg.StaticTable.item;
  740. //      delete []pnatcfg;
  741. // }
  742.     */
  743. m_bStartFirewall=FALSE;
  744. char temp[10];
  745. memset(temp,0,10);
  746. DWORD BytesReturned;
  747. BOOL ok = DeviceIoControl(
  748.             global_handle,
  749.             0x8000,
  750.             temp,
  751.             8,
  752.             NULL,
  753.             0,
  754.             &BytesReturned,
  755.             NULL
  756.             );
  757. if(ok)
  758. TRACE(_T("OKOKOKOKOKOKOKOKOKn"));
  759. }
  760. void CFireWall1View::OnUpdateShutdownfirewall(CCmdUI* pCmdUI) 
  761. {
  762. // TODO: Add your command update UI handler code here
  763. pCmdUI->Enable(m_bStartFirewall);
  764. }
  765. void CFireWall1View::OnToolLog() 
  766. {
  767. logType=1;
  768. }
  769. void CFireWall1View::OnUpdateToolLog(CCmdUI* pCmdUI) 
  770. {
  771. // TODO: Add your command update UI handler code here
  772. }
  773. void CFireWall1View::OnProtlog() 
  774. {
  775. // TODO: Add your command handler code here
  776. }
  777. void CFireWall1View::OnUpdateProtlog(CCmdUI* pCmdUI) 
  778. {
  779. // TODO: Add your command update UI handler code here
  780. }
  781. void CFireWall1View::OnUpdateOption(CCmdUI* pCmdUI) 
  782. {
  783. // TODO: Add your command update UI handler code here
  784. pCmdUI->Enable(!bCfgOpen);
  785. }
  786. void CFireWall1View::OnFilterlog() 
  787. {
  788. // TODO: Add your command handler code here
  789. }
  790. void CFireWall1View::OnUpdateFilterlog(CCmdUI* pCmdUI) 
  791. {
  792. // TODO: Add your command update UI handler code here
  793. }
  794. void CFireWall1View::OnUpdateExit(CCmdUI* pCmdUI) 
  795. {
  796. // TODO: Add your command update UI handler code here
  797. }
  798. void CFireWall1View::OnUpdateClosefilter(CCmdUI* pCmdUI) 
  799. {
  800. // TODO: Add your command update UI handler code here
  801.     pCmdUI->Enable((m_bStartFilter)&&(m_bStartFirewall));
  802. }
  803. void CFireWall1View::Startfilter()
  804. {
  805.     int group=1;
  806.     SetFilterInitReq(gDataConvert.m_firewallconfig);
  807. SetFilterCfg(gDataConvert.m_firewallconfig,gDataConvert.globalFlags);
  808. POSITION pos;
  809. pos=gDataConvert.m_ptrlistHostPort.GetHeadPosition();
  810. // struct HostList *phostlist;
  811. while(pos!=NULL)
  812. {
  813. struct HostList *phostlist=(struct HostList *)gDataConvert.m_ptrlistHostPort.GetNext(pos);
  814.         SetFilterAddrTree(phostlist->sIpRange,group);
  815. for(int i=0;i<10;i++)
  816. {
  817.      SetFilterPortList(phostlist,i,group);
  818. }
  819. group++;
  820. }
  821.  //   SetFilterAddrTree();
  822. SetFilterAcceptTab(gDataConvert.m_ptrlistAllowIp);
  823.     SetFilterRejTab(gDataConvert.m_ptrlistRejectIp);
  824. SetDmIpTab(gDataConvert.m_listInHttp,T_INDM);
  825. SetDmIpTab(gDataConvert.m_listOutHttp,T_OUTDM);
  826.     StartFilter();
  827. }
  828. void CFireWall1View::OnMenuitem32816() 
  829. {
  830.   
  831. }
  832. void CFireWall1View::OnUpdateAppExit(CCmdUI* pCmdUI) 
  833. {
  834. // TODO: Add your command update UI handler code here
  835. pCmdUI->Enable(!bPropsheetOpen);
  836. }
  837. void CFireWall1View::SetNetData()
  838. {
  839. ULONG           BytesReturned;
  840. BYTE  temp[40];
  841. memset(temp,0,40);
  842. int no;
  843. for(int i=0;i<8;i++)
  844. {
  845. no=myNetCardProp[i].DeviceNo;
  846. if(no)
  847. {
  848. if(no==(INNO-0x30))temp[no]=1;
  849. else temp[no]=3;
  850. /* if(myNetCardProp[i].Flag==0)
  851. {
  852. if(gDataConvert.globalFlags.bCheckInNetAttack)
  853. temp[no]=1;
  854. }
  855. if(myNetCardProp[i].Flag==1)
  856. {
  857. if(gDataConvert.globalFlags.bCheckOutNetAccack)
  858. temp[no]=3;
  859. }
  860. if(myNetCardProp[i].Flag==2)
  861. {
  862. // if(gDataConvert.globalFlags.bCheckDmAccack)
  863. // temp[no]=3;
  864. }
  865. */
  866. }
  867. }
  868. /*
  869. temp[0] = 0;
  870. temp[1] = 0;
  871. temp[2] = 0;
  872. temp[3] = 0;
  873. temp[4] = 3;
  874. temp[5] = 0;
  875. temp[6] = 0;
  876. temp[7] = 0;
  877. */
  878. BOOL ok = DeviceIoControl(
  879.             global_handle,
  880.             0x8000,
  881.             temp,
  882.             8,
  883.             NULL,
  884.             0,
  885.             &BytesReturned,
  886.             NULL
  887.             );
  888. if(ok)
  889. TRACE(_T("OKOKOKOKOKOKOKOKOKn"));
  890. else
  891. {
  892. int iiii=GetLastError();
  893. }
  894. }
  895. void CFireWall1View::OnStopLog() 
  896. {
  897.      logType=0;
  898. }
  899. LRESULT CFireWall1View:: OnLogView(WPARAM wParam,LPARAM lParam)
  900. {
  901.             ++number;
  902.         if(number>MAXITEMNUMBER)
  903. {
  904.       flag = TRUE;
  905. }
  906.        lvItem.iItem = number;
  907.        if(flag)
  908.    {
  909.      m_listView1.DeleteItem(0);
  910.      lvItem.iItem = MAXITEMNUMBER;
  911.    }
  912.        lvItem.iSubItem = 0;
  913.    if(lParam==111)
  914.    {
  915.      struct LogView *logview=(struct LogView*)wParam;
  916.  lvItem.pszText = logview->time;
  917.          m_listView1.InsertItem(&lvItem);
  918.          m_listView1.SetItemText(lvItem.iItem,1,logview->prot);
  919.          m_listView1.SetItemText(lvItem.iItem,2,logview->src);
  920.      m_listView1.SetItemText(lvItem.iItem,3,logview->dst);
  921.      m_listView1.SetItemText(lvItem.iItem,4,logview->demo);
  922.  m_listView1.Update(lvItem.iItem);
  923.    }
  924.    if(lParam==112)
  925.    {
  926.      struct LogViewIcmp *logviewIcmp=(struct LogViewIcmp*)wParam;
  927.  lvItem.pszText = logviewIcmp->time;
  928.          m_listView1.InsertItem(&lvItem);
  929.          m_listView1.SetItemText(lvItem.iItem,1,logviewIcmp->prot);
  930.          m_listView1.SetItemText(lvItem.iItem,2,logviewIcmp->src);
  931.      m_listView1.SetItemText(lvItem.iItem,3,logviewIcmp->dst);
  932.      m_listView1.SetItemText(lvItem.iItem,4,logviewIcmp->demo);
  933.      m_listView1.SetItemText(lvItem.iItem,5,logviewIcmp->type);
  934.    }
  935. return 1L;
  936. }
  937. void CFireWall1View::CommandCon()
  938. {
  939. OptMyConfig();//优化数据
  940. UserToKernel();
  941. }
  942. void CFireWall1View::OptMyConfig()
  943. {
  944. return;
  945. }
  946. void CFireWall1View::UserToKernel()
  947. {
  948. memcpy((void *)&TheServiceManageData,(void *)&MyServiceManageData,sizeof(ServiceManageData));
  949. memcpy((void *)&TheUserVerifyData,(void *)&MyUserVerifyData,sizeof(UserVerifyData));
  950. memcpy((void *)&TheLogManage,(void *)&MyLogManage,sizeof(LogManage));
  951. char cc;
  952. sscanf(NETMASK,"%d%c%d%c%d%c%d",&mask.AddrByte[0],&cc,
  953. &mask.AddrByte[1],&cc,
  954. &mask.AddrByte[2],&cc,
  955. &mask.AddrByte[3]);
  956. ProtoManInit();
  957. }
  958. WORD CFireWall1View::GetInitDataFromFile()
  959. {
  960. memset((void *)&MyServiceManageData,0,sizeof(ServiceManageData));
  961. memset((void *)&MyUserVerifyData,0,sizeof(UserVerifyData));
  962. memset((void *)&MyLogManage,0,sizeof(LogManage));
  963. GetDataFromPage1();
  964. GetDataFromPage3();
  965. GetDataFromPage4();
  966. GetDataFromPage5();
  967. GetDataFromPage6();
  968. return 0;
  969. }
  970. WORD CFireWall1View::GetDataFromPage1()
  971. {
  972. char command[40];
  973. memset(command,0,40);
  974. char *pbuf;
  975. pfoutDeviceInit=fopen("device.txt","r");
  976. if(pfoutDeviceInit==NULL)return 0;
  977. while(feof(pfoutDeviceInit)==0)
  978. {
  979. ReadCommand(pfoutDeviceInit,command);
  980. switch(GetCommand(command,1))
  981. {
  982. case INNET:
  983. ReadCommand(pfoutDeviceInit,command);
  984. strcpy(tmpin,command);
  985. INNO=tmpin[0];
  986. // TRACE(tmpin);
  987. break;
  988. case OUTNET:
  989. ReadCommand(pfoutDeviceInit,command);
  990. strcpy(tmpout,command);
  991. OUTNO=tmpout[0];
  992. break;
  993. case DM:
  994. ReadCommand(pfoutDeviceInit,command);
  995. strcpy(tmpdm,command);
  996. DMNO=tmpdm[0];
  997. break;
  998. case INNETMASK:
  999. ReadCommand(pfoutDeviceInit,command);
  1000. strcpy(NETMASK,command);
  1001. break;
  1002. }
  1003. }
  1004. if(pfoutDeviceInit)int errrr=fclose(pfoutDeviceInit);
  1005. return 1;
  1006. }
  1007. void CFireWall1View::ReadCommand(FILE *pf, char *pbuf)
  1008. {
  1009. while(feof(pf)==0) {
  1010. *pbuf=fgetc(pf);
  1011. if(*pbuf=='n') break;
  1012. pbuf++;
  1013. }
  1014. *pbuf--=0;
  1015. if(*pbuf=='r')*pbuf=0;
  1016. }
  1017. DWORD CFireWall1View::GetCommand(char *pbuf, int i)
  1018. {
  1019. char buf[50];
  1020. if(*pbuf==0) return INITIAL_END_SEGMENT;
  1021. sscanf(pbuf,"%s",buf);
  1022. if(i==1)
  1023. {
  1024. if(strstr(buf,"[InNet]")!=NULL) return INNET;
  1025. else if(strstr(buf,"[OutNet]")!=NULL) return OUTNET;
  1026. else if(strstr(buf,"[DM]")!=NULL)return DM;
  1027. else if(buf[0]=='#') return COMMENT;
  1028. else if(strstr(buf,"[jl]")!=NULL) return INITIAL_END_SEGMENT;
  1029. else return COMMAND_UNKNOWN;
  1030. }
  1031. if(i==4)
  1032. {
  1033. if(strstr(buf,"[NoFilterURL]")!=NULL) return NOFILTERURL;
  1034. else if(strstr(buf,"[FilterAndBlock]")!=NULL) return FILTERANDBLOCK;
  1035. else if(strstr(buf,"[TranProtocal]")!=NULL)return TRANPROTOCAL;
  1036. else if(strstr(buf,"[Port]")!=NULL) return PORT;
  1037. else if(strstr(buf,"[FilterKeyWords]")!=NULL) return FILTERKEYWORDS;
  1038. else if(strstr(buf,"[TCPFilterBit]")!=NULL) return TCPFILTERBIT;
  1039. else if(strstr(buf,"[BlockUrl]")!=NULL)return BLOCKURL;
  1040. else if(buf[0]=='#') return COMMENT;
  1041. else if(strstr(buf,"[jl]")!=NULL) return INITIAL_END_SEGMENT;
  1042. else return COMMAND_UNKNOWN;
  1043. }
  1044. if(i==5)
  1045. {
  1046. if(strstr(buf,"[isUserVerify]")!=NULL) return ISUSERVERIFY;
  1047. else if(strstr(buf,"[TIME]")!=NULL) return TIME;
  1048. else if(strstr(buf,"[UserNameandPasswd]")!=NULL)return USERNAMEANDPASSWD;
  1049. else if(strstr(buf,"[jl]")!=NULL) return INITIAL_END_SEGMENT;
  1050. else return COMMAND_UNKNOWN;
  1051. }
  1052. if(i==6)
  1053. {
  1054. if(strstr(buf,"[RequireLog]")!=NULL) return REQUIRELOG;
  1055. else if(strstr(buf,"[isLogIp]")!=NULL) return ISLOGIP;
  1056. else if(strstr(buf,"[ipOptions]")!=NULL)return IPOPTIONS;
  1057. else if(strstr(buf,"[isLogProtocal]")!=NULL)return ISLOGPROTOCAL;
  1058. else if(strstr(buf,"[proOptions]")!=NULL)return PROOPTIONS;
  1059. else if(strstr(buf,"[jl]")!=NULL) return INITIAL_END_SEGMENT;
  1060. else return COMMAND_UNKNOWN;
  1061. }
  1062. }
  1063. WORD CFireWall1View::GetDataFromPage4()
  1064. {
  1065. int keywordcopy=0;
  1066. int nofilterurlcopy=0;
  1067. int blockurlcopy=0;
  1068. int totlen=0;
  1069. int len;
  1070. char command[40];
  1071. char *pbuf;
  1072. pfoutServiceInit=fopen("service.txt","r");
  1073. if(pfoutServiceInit==NULL)return 0;
  1074. while(feof(pfoutServiceInit)==0)
  1075. {
  1076. ReadCommand(pfoutServiceInit,command);
  1077. switch(GetCommand(command,4))
  1078. {
  1079. case FILTERANDBLOCK:
  1080. ReadCommand(pfoutServiceInit,command);
  1081. sscanf(command,"%d",&MyServiceManageData.FilterAndBlock);
  1082. break;
  1083. case TRANPROTOCAL:
  1084. ReadCommand(pfoutServiceInit,command);
  1085. sscanf(command,"%d",&MyServiceManageData.TranProtocal);
  1086. break;
  1087. case PORT:
  1088. ReadCommand(pfoutServiceInit,command);
  1089. sscanf(command,"%d",&MyServiceManageData.Port);
  1090. break;
  1091. case FILTERKEYWORDS:
  1092. ReadCommand(pfoutServiceInit,command);
  1093. while(GetCommand(command,4)!=INITIAL_END_SEGMENT) {
  1094. if(keywordcopy++==0)
  1095. strcpy(MyServiceManageData.FilterKeyWord,command);
  1096. else strcat(MyServiceManageData.FilterKeyWord,command);
  1097. strcat(MyServiceManageData.FilterKeyWord,"rn");
  1098. ReadCommand(pfoutServiceInit,command);
  1099. }
  1100. break;
  1101. case TCPFILTERBIT:
  1102. ReadCommand(pfoutServiceInit,command);
  1103. sscanf(command,"%d",&MyServiceManageData.TCPFilterBit);
  1104. break;
  1105. case BLOCKURL:
  1106. ReadCommand(pfoutServiceInit,command);
  1107. while(GetCommand(command,4)!=INITIAL_END_SEGMENT) {
  1108. if(blockurlcopy++==0)
  1109. strcpy(MyServiceManageData.BlockURLList,command);
  1110. else strcat(MyServiceManageData.BlockURLList,command);
  1111. strcat(MyServiceManageData.BlockURLList,"rn");
  1112. ReadCommand(pfoutServiceInit,command);
  1113. }
  1114. //AfxMessageBox(MyServiceManageData.BlockURLList);
  1115. break;
  1116. case NOFILTERURL:
  1117. ReadCommand(pfoutServiceInit,command);
  1118. while(GetCommand(command,4)!=INITIAL_END_SEGMENT) {
  1119. if(nofilterurlcopy++==0)
  1120. strcpy(MyServiceManageData.NoFilterURLList,command);
  1121. else strcat(MyServiceManageData.NoFilterURLList,command);
  1122. strcat(MyServiceManageData.NoFilterURLList,"rn");
  1123. ReadCommand(pfoutServiceInit,command);
  1124. }
  1125. break;
  1126. }
  1127. }
  1128. if(pfoutServiceInit)fclose(pfoutServiceInit);
  1129. return 1;
  1130. }
  1131. WORD CFireWall1View::GetDataFromPage5()
  1132. {
  1133. int iiii=0;
  1134. char command[40];
  1135. char *pbuf;
  1136. pfoutUserverInit=fopen("userverify.txt","r");
  1137. if(pfoutUserverInit==NULL)return 0;
  1138. while(feof(pfoutUserverInit)==0)
  1139. {
  1140. ReadCommand(pfoutUserverInit,command);
  1141. switch(GetCommand(command,5))
  1142. {
  1143. case ISUSERVERIFY:
  1144. ReadCommand(pfoutUserverInit,command);
  1145. sscanf(command,"%d",&MyUserVerifyData.IsVerify);
  1146. break;
  1147. case TIME:
  1148. ReadCommand(pfoutUserverInit,command);
  1149. sscanf(command,"%d",&MyUserVerifyData.timeRefesh);
  1150. break;
  1151. case USERNAMEANDPASSWD:
  1152. ReadCommand(pfoutUserverInit,command);
  1153. while(GetCommand(command,5)!=INITIAL_END_SEGMENT) {
  1154. if(iiii++==0)strcpy(MyUserVerifyData.UserList,command);
  1155. else strcat(MyUserVerifyData.UserList,command);
  1156. strcat(MyUserVerifyData.UserList,"rn");
  1157. ReadCommand(pfoutUserverInit,command);
  1158. }
  1159. break;
  1160. }
  1161. }
  1162. if(pfoutUserverInit)fclose(pfoutUserverInit);
  1163. return 1;
  1164. }
  1165. WORD CFireWall1View::GetDataFromPage6()
  1166. {
  1167. char command[40];
  1168. char *pbuf;
  1169. pfoutLogsetInit=fopen("logset.txt","r");
  1170. if(pfoutLogsetInit==NULL)return 0;
  1171. while(feof(pfoutLogsetInit)==0)
  1172. {
  1173. ReadCommand(pfoutLogsetInit,command);
  1174. switch(GetCommand(command,6))
  1175. {
  1176. case REQUIRELOG:
  1177. ReadCommand(pfoutLogsetInit,command);
  1178. sscanf(command,"%d",&MyLogManage.RequireLog);
  1179. break;
  1180. case ISLOGIP:
  1181. ReadCommand(pfoutLogsetInit,command);
  1182. sscanf(command,"%d",&MyLogManage.TheIpFilter.isLogIp);
  1183. break;
  1184. case IPOPTIONS:
  1185. ReadCommand(pfoutLogsetInit,command);
  1186. sscanf(command,"%d",&MyLogManage.TheIpFilter.Options);
  1187. break;
  1188. case ISLOGPROTOCAL:
  1189. ReadCommand(pfoutLogsetInit,command);
  1190. sscanf(command,"%d",&MyLogManage.TheProCommentsLog.isLogProtocal);
  1191. break;
  1192. case PROOPTIONS:
  1193. ReadCommand(pfoutLogsetInit,command);
  1194. sscanf(command,"%d",&MyLogManage.TheProCommentsLog.Options);
  1195. break;
  1196. }
  1197. }
  1198. if(pfoutLogsetInit)fclose(pfoutLogsetInit);
  1199. return 1;
  1200. }
  1201. WORD CFireWall1View::GetDataFromPage3()
  1202. {
  1203. char command[40];
  1204. char *pbuf;
  1205. pfoutDefaultInit=fopen("default.txt","r");
  1206. if(pfoutDefaultInit==NULL)return 0;
  1207. while(feof(pfoutDefaultInit)==0)
  1208. {
  1209. ReadCommand(pfoutDefaultInit,command);
  1210. switch(GetCommand(command,3))
  1211. {
  1212. case PRIORITY:
  1213. ReadCommand(pfoutDefaultInit,command);
  1214. sscanf(command,"%d",&TheDefaultSetData.Priority);
  1215. break;
  1216. case CHECKINOROUTNETCARD:
  1217. break;
  1218. case PRO:
  1219. break;
  1220. case TCPPROTOCAL:
  1221. break;
  1222. case PORTOCALCOMMENTS:
  1223. break;
  1224. case UDPPROTOCAL:
  1225. break;
  1226. }
  1227. }
  1228. return 1;
  1229. }