Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

678 lines
20 KiB

  1. //============================================================================
  2. // Copyright(c) 1996, Microsoft Corporation
  3. //
  4. // File: ipxfltr.cpp
  5. //
  6. // History:
  7. // 08/30/96 Ram Cherala Created
  8. //
  9. // Implementation of IPX Filter dialog code
  10. //============================================================================
  11. #include "stdafx.h"
  12. #include "rtrfiltr.h"
  13. #include "ipxfltr.h"
  14. #include "datafmt.h"
  15. #include "ipxadd.h"
  16. #include <ipxrtdef.h>
  17. #include <ipxtfflt.h>
  18. extern "C" {
  19. #include <winsock.h>
  20. }
  21. #include "rtradmin.hm"
  22. #include "listctrl.h"
  23. #ifdef _DEBUG
  24. #define new DEBUG_NEW
  25. #undef THIS_FILE
  26. static char THIS_FILE[] = __FILE__;
  27. #endif
  28. #if 1
  29. static UINT uStringIdTable[] = { IDS_COL_SOURCENETWORK,
  30. IDS_COL_SOURCEMASK,
  31. IDS_COL_SOURCENODE,
  32. IDS_COL_SOURCESOCKET,
  33. IDS_COL_DESTNETWORK,
  34. IDS_COL_DESTMASK,
  35. IDS_COL_DESTNODE,
  36. IDS_COL_DESTSOCKET,
  37. IDS_COL_PACKETTYPE
  38. } ;
  39. #else
  40. static UINT uStringIdTable[] = { IDS_COL_SOURCEADDRESS,
  41. IDS_COL_DESTADDRESS,
  42. IDS_COL_PACKETTYPE
  43. } ;
  44. #endif
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CIpxFilter dialog
  47. CIpxFilter::CIpxFilter(CWnd* pParent /*=NULL*/,
  48. IInfoBase * pInfoBase,
  49. DWORD dwFilterType)
  50. : CBaseDialog( (dwFilterType == FILTER_INBOUND ? CIpxFilter::IDD_INBOUND : CIpxFilter::IDD_OUTBOUND), pParent),
  51. m_pParent(pParent),
  52. m_dwFilterType(dwFilterType)
  53. {
  54. //{{AFX_DATA_INIT(CIpxFilter)
  55. // NOTE: the ClassWizard will add member initialization here
  56. //}}AFX_DATA_INIT
  57. m_spInfoBase.Set(pInfoBase);
  58. // SetHelpMap(m_dwHelpMap);
  59. }
  60. CIpxFilter::~CIpxFilter()
  61. {
  62. while (!m_filterList.IsEmpty()) {
  63. delete (FilterListEntry*)m_filterList.RemoveHead();
  64. }
  65. }
  66. void CIpxFilter::DoDataExchange(CDataExchange* pDX)
  67. {
  68. CBaseDialog::DoDataExchange(pDX);
  69. //{{AFX_DATA_MAP(CIpxFilter)
  70. DDX_Control(pDX, IDC_IPX_FILTER_LIST, m_listCtrl);
  71. //}}AFX_DATA_MAP
  72. }
  73. BEGIN_MESSAGE_MAP(CIpxFilter, CBaseDialog)
  74. //{{AFX_MSG_MAP(CIpxFilter)
  75. ON_NOTIFY(NM_DBLCLK, IDC_IPX_FILTER_LIST, OnDblclkIpxFilterList)
  76. ON_BN_CLICKED(IDC_IPX_FILTER_ADD, OnIpxFilterAdd)
  77. ON_BN_CLICKED(IDC_IPX_FILTER_EDIT, OnIpxFilterEdit)
  78. ON_BN_CLICKED(IDC_IPX_FILTER_DELETE, OnIpxFilterDelete)
  79. ON_NOTIFY(LVN_GETDISPINFO, IDC_IPX_FILTER_LIST, OnGetdispinfoIpxFilterList)
  80. ON_NOTIFY(LVN_ITEMCHANGED, IDC_IPX_FILTER_LIST, OnNotifyListItemChanged)
  81. //}}AFX_MSG_MAP
  82. END_MESSAGE_MAP()
  83. DWORD CIpxFilter::m_dwHelpMap[] =
  84. {
  85. // IDC_IPX_PERMIT, HIDC_IPX_PERMIT,
  86. // IDC_IPX_DENY, HIDC_IPX_DENY,
  87. // IDC_IPX_FILTER_LIST, HIDC_IPX_FILTER_LIST,
  88. // IDC_IPX_FILTER_ADD, HIDC_IPX_FILTER_ADD,
  89. // IDC_IPX_FILTER_EDIT, HIDC_IPX_FILTER_EDIT,
  90. // IDC_IPX_FILTER_DELETE, HIDC_IPX_FILTER_DELETE,
  91. 0,0
  92. };
  93. /////////////////////////////////////////////////////////////////////////////
  94. // CIpxFilter message handlers
  95. //------------------------------------------------------------------------------
  96. // Function: CIpxFilter::OnInitDialog
  97. //
  98. // Handles 'WM_INITDIALOG' notification from the dialog
  99. //------------------------------------------------------------------------------
  100. BOOL CIpxFilter::OnInitDialog()
  101. {
  102. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  103. CBaseDialog::OnInitDialog();
  104. ASSERT( m_dwFilterType == FILTER_INBOUND || m_dwFilterType == FILTER_OUTBOUND );
  105. InfoBlock * pBlock;
  106. IPX_TRAFFIC_FILTER_GLOBAL_INFO * pIpxGlobal;
  107. IPX_TRAFFIC_FILTER_INFO * pIpxInfo;
  108. CRect rcDlg, rc;
  109. CString sCol;
  110. DWORD dwErr = NO_ERROR;
  111. HRESULT hr = hrOK;
  112. m_stAny.LoadString(IDS_ANY);
  113. // initialize rectangle for list control display
  114. GetClientRect(rcDlg);
  115. // insert columns
  116. m_listCtrl.GetClientRect(&rc);
  117. UINT i;
  118. for ( i = 0; i < IPX_NUM_COLUMNS; i++ ) {
  119. sCol.LoadString(uStringIdTable[i]);
  120. m_listCtrl.InsertColumn(i, sCol);
  121. AdjustColumnWidth(m_listCtrl, i, sCol);
  122. }
  123. // set extended attributes
  124. ListView_SetExtendedListViewStyle( m_listCtrl.m_hWnd, LVS_EX_FULLROWSELECT );
  125. hr = m_spInfoBase->GetBlock((m_dwFilterType == FILTER_INBOUND) ?
  126. IPX_IN_TRAFFIC_FILTER_GLOBAL_INFO_TYPE :
  127. IPX_OUT_TRAFFIC_FILTER_GLOBAL_INFO_TYPE,
  128. &pBlock, 0);
  129. // The filter was previously defined
  130. // Windows NT Bug : 267091
  131. // We may get a NULL block (one that has 0 data), so we need
  132. // to check for that case also.
  133. if (FHrSucceeded(hr) && (pBlock->pData != NULL))
  134. {
  135. pIpxGlobal = ( IPX_TRAFFIC_FILTER_GLOBAL_INFO * ) pBlock->pData;
  136. SetFilterActionButtonsAndText(m_dwFilterType, pIpxGlobal->FilterAction);
  137. }
  138. else
  139. {
  140. SetFilterActionButtonsAndText(m_dwFilterType, IPX_TRAFFIC_FILTER_ACTION_DENY);
  141. }
  142. DWORD dwCount;
  143. hr = m_spInfoBase->GetBlock( (m_dwFilterType == FILTER_INBOUND) ?
  144. IPX_IN_TRAFFIC_FILTER_INFO_TYPE :
  145. IPX_OUT_TRAFFIC_FILTER_INFO_TYPE, &pBlock,
  146. 0);
  147. if (FHrSucceeded(hr))
  148. {
  149. dwCount = pBlock->dwCount;
  150. pIpxInfo = ( PIPX_TRAFFIC_FILTER_INFO ) pBlock->pData;
  151. if (pIpxInfo)
  152. {
  153. for ( i = 0; i < dwCount; i++, pIpxInfo++ ) {
  154. FilterListEntry* pfle = new FilterListEntry;
  155. if (!pfle) { dwErr = ERROR_NOT_ENOUGH_MEMORY; break; }
  156. CopyMemory(pfle, pIpxInfo, sizeof(IPX_TRAFFIC_FILTER_INFO));
  157. pfle->pos = m_filterList.AddTail(pfle);
  158. INT item = m_listCtrl.InsertItem( LVIF_TEXT|LVIF_PARAM, i, LPSTR_TEXTCALLBACK,
  159. 0,0,0, (LPARAM)pfle);
  160. if(item != -1) {m_listCtrl.SetItemData( item, (DWORD_PTR)pfle); }
  161. }
  162. }
  163. }
  164. // select the first item in the list if list is not empty, else
  165. // disable the radio controls and set sate to Allow
  166. if( m_listCtrl.GetItemCount())
  167. {
  168. m_listCtrl.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
  169. m_listCtrl.SetFocus();
  170. GetDlgItem(IDC_IPX_FILTER_DELETE)->EnableWindow(TRUE);
  171. GetDlgItem(IDC_IPX_FILTER_EDIT)->EnableWindow(TRUE);
  172. }
  173. else
  174. {
  175. SetFilterActionButtonsAndText(m_dwFilterType, IPX_TRAFFIC_FILTER_ACTION_DENY, FALSE);
  176. GetDlgItem(IDC_IPX_FILTER_DELETE)->EnableWindow(FALSE);
  177. GetDlgItem(IDC_IPX_FILTER_EDIT)->EnableWindow(FALSE);
  178. }
  179. #if 0
  180. if ( dwErr != NO_ERROR ) {
  181. // report construction error and return
  182. ::AfxMessageBox(IDS_CONSTRUCTION_ERROR);
  183. }
  184. #endif
  185. return FALSE; // return TRUE unless you set the focus to a control
  186. // EXCEPTION: OCX Property Pages should return FALSE
  187. }
  188. //------------------------------------------------------------------------------
  189. // Function: CIpxFilter::OnDblclkIpxFilterList
  190. // `
  191. // Handles 'NM_DBLCLK' notification from the Filter list control
  192. //------------------------------------------------------------------------------
  193. void CIpxFilter::OnDblclkIpxFilterList(NMHDR* pNMHDR, LRESULT* pResult)
  194. {
  195. OnIpxFilterEdit();
  196. *pResult = 0;
  197. }
  198. //------------------------------------------------------------------------------
  199. // Function: CIpxFilter::OnIpxFilterAdd
  200. // `
  201. // Handles 'NM_DBLCLK' notification from the Filter list control
  202. //------------------------------------------------------------------------------
  203. void CIpxFilter::OnIpxFilterAdd()
  204. {
  205. // Display the IP filter Add/Edit dialog
  206. //
  207. FilterListEntry* pfle = NULL;
  208. CIpxAddEdit dlg( this, (FilterListEntry**)&pfle);
  209. if ( dlg.DoModal() != IDOK ) { return; }
  210. // Add the newly configured filter to our list and update list control
  211. pfle->pos = m_filterList.AddTail( pfle );
  212. int item = m_listCtrl.InsertItem( LVIF_TEXT|LVIF_PARAM, 0, LPSTR_TEXTCALLBACK,
  213. 0,0,0, (LPARAM)pfle);
  214. if(item != -1) {m_listCtrl.SetItemData( item, (DWORD_PTR)pfle); }
  215. // enable radio controls when the first item is added to list
  216. m_listCtrl.SetItemState(item, LVIS_SELECTED, LVIS_SELECTED);
  217. m_listCtrl.SetFocus();
  218. }
  219. //------------------------------------------------------------------------------
  220. // Function: CIpxFilter::OnIpxFilterEdit
  221. // `
  222. // Handles 'NM_DBLCLK' notification from the Filter list control
  223. //------------------------------------------------------------------------------
  224. void CIpxFilter::OnIpxFilterEdit()
  225. {
  226. // Get the current list selection
  227. // get the corresponding itemdata
  228. // pass it down to the CIpFltrAddEdit dialog
  229. //
  230. // Get the selected item
  231. //
  232. int i = m_listCtrl.GetNextItem(-1, LVNI_SELECTED);
  233. if (i == -1) { return ; }
  234. //
  235. // Get the interface for the selected item
  236. //
  237. FilterListEntry* pfle = (FilterListEntry*)m_listCtrl.GetItemData(i);
  238. CIpxAddEdit dlg( this, (FilterListEntry**)&pfle );
  239. if ( dlg.DoModal() != IDOK ) { return; }
  240. m_listCtrl.Update(i);
  241. m_listCtrl.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
  242. m_listCtrl.SetFocus();
  243. }
  244. //------------------------------------------------------------------------------
  245. // Function: CIpxFilter::OnIpxFilterDelete
  246. // `
  247. // Handles 'NM_DBLCLK' notification from the Filter list control
  248. //------------------------------------------------------------------------------
  249. void CIpxFilter::OnIpxFilterDelete()
  250. {
  251. // Get the current list selection
  252. // delete it from our private list
  253. // delete the item from the list or just refresh the list view
  254. //
  255. // Get the selected item
  256. //
  257. int i = m_listCtrl.GetNextItem(-1, LVNI_SELECTED);
  258. if (i == -1) { return ; }
  259. //
  260. // Get the interface for the selected item
  261. //
  262. FilterListEntry* pfle = (FilterListEntry*)m_listCtrl.GetItemData(i);
  263. //
  264. // delete it
  265. m_listCtrl.DeleteItem(i);
  266. m_filterList.RemoveAt(pfle->pos);
  267. delete pfle;
  268. //
  269. // select the next available list item
  270. //
  271. // disable radio controls if all items in list are deleted
  272. // they will be reenabled when the first filter is added to list
  273. if( !m_listCtrl.GetItemCount())
  274. {
  275. SetFilterActionButtonsAndText(m_dwFilterType, IPX_TRAFFIC_FILTER_ACTION_DENY, FALSE);
  276. }
  277. else if (m_listCtrl.GetItemCount() == i)
  278. m_listCtrl.SetItemState((i == 0? i: i-1), LVIS_SELECTED, LVIS_SELECTED);
  279. else
  280. m_listCtrl.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
  281. m_listCtrl.SetFocus();
  282. }
  283. //------------------------------------------------------------------------------
  284. // Function: CIpxFilter::OnOK
  285. // `
  286. // Handles 'NM_DBLCLK' notification from the Filter list control
  287. //------------------------------------------------------------------------------
  288. void CIpxFilter::OnOK()
  289. {
  290. // If the filters information changed, write this to registry
  291. // and return
  292. DWORD dwSize, dwCount, dwErr;
  293. HRESULT hr = hrOK;
  294. dwCount = (DWORD) m_filterList.GetCount();
  295. if (!dwCount && IsDlgButtonChecked(IDC_IPX_DENY) )
  296. {
  297. if (m_dwFilterType == FILTER_INBOUND)
  298. AfxMessageBox(IDS_RECEIVE_NO_FILTER, MB_OK);
  299. else
  300. AfxMessageBox(IDS_TRANSMIT_NO_FILTER, MB_OK);
  301. return;
  302. }
  303. if(dwCount)
  304. {
  305. InfoBlock * pBlock = new InfoBlock;
  306. // First Set the global information
  307. if (!pBlock) { // display an error message for no memory
  308. AfxMessageBox(IDS_ERROR_NO_MEMORY);
  309. return;
  310. };
  311. dwSize = pBlock->dwSize = sizeof( IPX_TRAFFIC_FILTER_GLOBAL_INFO );
  312. pBlock->dwType = (m_dwFilterType == FILTER_INBOUND) ?
  313. IPX_IN_TRAFFIC_FILTER_GLOBAL_INFO_TYPE :
  314. IPX_OUT_TRAFFIC_FILTER_GLOBAL_INFO_TYPE,
  315. pBlock->dwCount = 1;
  316. pBlock->pData = new BYTE[dwSize];
  317. if(!pBlock->pData) { // display an error message for no memory
  318. delete pBlock;
  319. AfxMessageBox(IDS_ERROR_NO_MEMORY);
  320. return;
  321. }
  322. IPX_TRAFFIC_FILTER_GLOBAL_INFO * pIpxGlobal = (IPX_TRAFFIC_FILTER_GLOBAL_INFO*)pBlock->pData;
  323. pIpxGlobal->FilterAction = IsDlgButtonChecked(IDC_IPX_PERMIT) ? IPX_TRAFFIC_FILTER_ACTION_DENY : IPX_TRAFFIC_FILTER_ACTION_PERMIT;
  324. if( FHrOK(m_spInfoBase->BlockExists(
  325. (m_dwFilterType == FILTER_INBOUND)?
  326. IPX_IN_TRAFFIC_FILTER_GLOBAL_INFO_TYPE :
  327. IPX_OUT_TRAFFIC_FILTER_GLOBAL_INFO_TYPE )))
  328. {
  329. hr = m_spInfoBase->SetBlock(
  330. (m_dwFilterType == FILTER_INBOUND)?
  331. IPX_IN_TRAFFIC_FILTER_GLOBAL_INFO_TYPE :
  332. IPX_OUT_TRAFFIC_FILTER_GLOBAL_INFO_TYPE ,
  333. pBlock, 0);
  334. }
  335. else
  336. {
  337. hr = m_spInfoBase->AddBlock(
  338. (m_dwFilterType == FILTER_INBOUND)?
  339. IPX_IN_TRAFFIC_FILTER_GLOBAL_INFO_TYPE :
  340. IPX_OUT_TRAFFIC_FILTER_GLOBAL_INFO_TYPE,
  341. dwSize,
  342. pBlock->pData,
  343. 1, FALSE);
  344. }
  345. delete[] pBlock->pData;
  346. // now set the filter information
  347. pBlock->dwType = (m_dwFilterType == FILTER_INBOUND) ? IPX_IN_TRAFFIC_FILTER_INFO_TYPE : IPX_OUT_TRAFFIC_FILTER_INFO_TYPE ;
  348. // dwCount -1 because FILTER_DESCRIPTOR already has room for one FILTER_INFO structure
  349. pBlock->dwSize = sizeof(IPX_TRAFFIC_FILTER_INFO);
  350. dwSize = sizeof (IPX_TRAFFIC_FILTER_INFO) * dwCount;
  351. pBlock->dwCount = dwCount;
  352. pBlock->pData = new BYTE[dwSize];
  353. if(!pBlock->pData) { // display an error message for no memory
  354. delete pBlock;
  355. AfxMessageBox(IDS_ERROR_NO_MEMORY);
  356. return;
  357. }
  358. IPX_TRAFFIC_FILTER_INFO * pIPXfInfo;
  359. pIPXfInfo = (IPX_TRAFFIC_FILTER_INFO*)pBlock->pData;
  360. POSITION pos;
  361. pos = m_filterList.GetHeadPosition();
  362. while(pos) {
  363. FilterListEntry* pfle = (FilterListEntry*)m_filterList.GetNext(pos);
  364. CopyMemory(pIPXfInfo, pfle, sizeof(IPX_TRAFFIC_FILTER_INFO));
  365. pIPXfInfo++;
  366. }
  367. if( FHrOK(m_spInfoBase->BlockExists(m_dwFilterType == FILTER_INBOUND?IPX_IN_TRAFFIC_FILTER_INFO_TYPE:IPX_OUT_TRAFFIC_FILTER_INFO_TYPE)))
  368. {
  369. hr = m_spInfoBase->SetBlock(
  370. (m_dwFilterType == FILTER_INBOUND) ? IPX_IN_TRAFFIC_FILTER_INFO_TYPE : IPX_OUT_TRAFFIC_FILTER_INFO_TYPE,
  371. pBlock, 0);
  372. }
  373. else
  374. {
  375. hr = m_spInfoBase->AddBlock(
  376. (m_dwFilterType == FILTER_INBOUND) ? IPX_IN_TRAFFIC_FILTER_INFO_TYPE : IPX_OUT_TRAFFIC_FILTER_INFO_TYPE,
  377. pBlock->dwSize,
  378. pBlock->pData,
  379. pBlock->dwCount,
  380. FALSE);
  381. }
  382. if (!FHrSucceeded(hr))
  383. {
  384. AfxMessageBox(IDS_ERROR_SETTING_BLOCK);
  385. }
  386. delete[] pBlock->pData;
  387. delete pBlock;
  388. }
  389. else
  390. {
  391. // remove any previously defined filters
  392. hr = m_spInfoBase->AddBlock((m_dwFilterType == FILTER_INBOUND) ?
  393. IPX_IN_TRAFFIC_FILTER_GLOBAL_INFO_TYPE :
  394. IPX_OUT_TRAFFIC_FILTER_GLOBAL_INFO_TYPE,
  395. 0, NULL, 0, TRUE);
  396. hr = m_spInfoBase->AddBlock((m_dwFilterType == FILTER_INBOUND) ?
  397. IPX_IN_TRAFFIC_FILTER_INFO_TYPE :
  398. IPX_OUT_TRAFFIC_FILTER_INFO_TYPE,
  399. 0, NULL, 0, TRUE);
  400. }
  401. CBaseDialog::OnOK();
  402. }
  403. //------------------------------------------------------------------------------
  404. // Function: CIpxFilter::OnCancel
  405. // `
  406. // Handles 'NM_DBLCLK' notification from the Filter list control
  407. //------------------------------------------------------------------------------
  408. void CIpxFilter::OnCancel()
  409. {
  410. // TODO: Add extra cleanup here
  411. CBaseDialog::OnCancel();
  412. }
  413. //------------------------------------------------------------------------------
  414. // Function: CIpxFilter::SetFilterActionButtonsAndText
  415. //
  416. // Called to set the 'Filter Action' radio-buttons and corresponding text
  417. // Enables/Disables controls based on 'bEnable' value - defaults to enable
  418. //------------------------------------------------------------------------------
  419. VOID
  420. CIpxFilter::SetFilterActionButtonsAndText(
  421. DWORD dwFilterType,
  422. DWORD dwAction,
  423. BOOL bEnable
  424. )
  425. {
  426. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  427. CheckDlgButton( IDC_IPX_PERMIT, dwAction == IPX_TRAFFIC_FILTER_ACTION_DENY );
  428. CheckDlgButton( IDC_IPX_DENY, dwAction == IPX_TRAFFIC_FILTER_ACTION_PERMIT );
  429. CString sItem;
  430. // GetDlgItem(IDC_IPX_PERMIT)->EnableWindow(bEnable);
  431. // GetDlgItem(IDC_IPX_DENY)->EnableWindow(bEnable);
  432. // sItem.LoadString( dwFilterType == FILTER_INBOUND? IDS_RECEIVE : IDS_TRANSMIT );
  433. // SetDlgItemText( IDC_IPX_PERMIT, sItem );
  434. // sItem.LoadString( IDS_DROP );
  435. // SetDlgItemText( IDC_IPX_DENY, sItem );
  436. }
  437. #if 1
  438. enum {
  439. SRC_NETWORK=0,
  440. SRC_MASK,
  441. SRC_NODE,
  442. SRC_SOCKET,
  443. DEST_NETWORK,
  444. DEST_MASK,
  445. DEST_NODE,
  446. DEST_SOCKET,
  447. PACKET_TYPE
  448. };
  449. #else
  450. enum {
  451. SRC_ADDRESS=0,
  452. DEST_ADDRESS,
  453. PACKET_TYPE
  454. };
  455. #endif
  456. //------------------------------------------------------------------------------
  457. // Function: CIpxFilter::OnGetdispinfoIpxFilterList
  458. //
  459. // Handles 'LVN_GETDISPINFO' notification from the list control
  460. //------------------------------------------------------------------------------
  461. void CIpxFilter::OnGetdispinfoIpxFilterList(NMHDR* pNMHDR, LRESULT* pResult)
  462. {
  463. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  464. WCHAR buffer[32];
  465. LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
  466. CString cStr;
  467. BOOL bFilter;
  468. FilterListEntry * pfle = (FilterListEntry*)pDispInfo->item.lParam;
  469. // Setup some default
  470. pDispInfo->item.pszText = (LPTSTR) (LPCTSTR) m_stAny;
  471. switch( pDispInfo->hdr.code )
  472. {
  473. case LVN_GETDISPINFO:
  474. switch( pDispInfo->item.iSubItem )
  475. {
  476. case SRC_NETWORK:
  477. if (pfle->FilterDefinition & IPX_TRAFFIC_FILTER_ON_SRCNET)
  478. pfle->stSourceNetwork << CIPX_NETWORK(pfle->SourceNetwork);
  479. else
  480. pfle->stSourceNetwork = m_stAny;
  481. pDispInfo->item.pszText = (LPTSTR) (LPCTSTR) pfle->stSourceNetwork;
  482. break;
  483. case SRC_MASK:
  484. if (pfle->FilterDefinition & IPX_TRAFFIC_FILTER_ON_SRCNET)
  485. pfle->stSourceNetworkMask << CIPX_NETWORK(pfle->SourceNetworkMask);
  486. else
  487. pfle->stSourceNetworkMask = m_stAny;
  488. pDispInfo->item.pszText = (LPTSTR) (LPCTSTR) pfle->stSourceNetworkMask;
  489. break;
  490. case SRC_NODE:
  491. if (pfle->FilterDefinition & IPX_TRAFFIC_FILTER_ON_SRCNODE)
  492. pfle->stSourceNode << CIPX_NODE(pfle->SourceNode);
  493. else
  494. pfle->stSourceNode = m_stAny;
  495. pDispInfo->item.pszText = (LPTSTR) (LPCTSTR) pfle->stSourceNode;
  496. break;
  497. case SRC_SOCKET:
  498. if (pfle->FilterDefinition & IPX_TRAFFIC_FILTER_ON_SRCSOCKET)
  499. pfle->stSourceSocket << CIPX_SOCKET(pfle->SourceSocket);
  500. else
  501. pfle->stSourceSocket = m_stAny;
  502. pDispInfo->item.pszText = (LPTSTR) (LPCTSTR) pfle->stSourceSocket;
  503. break;
  504. case DEST_NETWORK:
  505. if (pfle->FilterDefinition & IPX_TRAFFIC_FILTER_ON_DSTNET)
  506. pfle->stDestinationNetwork << CIPX_NETWORK(pfle->DestinationNetwork);
  507. else
  508. pfle->stDestinationNetwork = m_stAny;
  509. pDispInfo->item.pszText = (LPTSTR) (LPCTSTR) pfle->stDestinationNetwork;
  510. break;
  511. case DEST_MASK:
  512. if (pfle->FilterDefinition & IPX_TRAFFIC_FILTER_ON_DSTNET)
  513. pfle->stDestinationNetworkMask << CIPX_NETWORK(pfle->DestinationNetworkMask);
  514. else
  515. pfle->stDestinationNetworkMask = m_stAny;
  516. pDispInfo->item.pszText = (LPTSTR) (LPCTSTR) pfle->stDestinationNetworkMask;
  517. break;
  518. case DEST_NODE:
  519. if (pfle->FilterDefinition & IPX_TRAFFIC_FILTER_ON_DSTNODE)
  520. pfle->stDestinationNode << CIPX_NODE(pfle->DestinationNode);
  521. else
  522. pfle->stDestinationNode = m_stAny;
  523. pDispInfo->item.pszText = (LPTSTR) (LPCTSTR) pfle->stDestinationNode;
  524. break;
  525. case DEST_SOCKET:
  526. if (pfle->FilterDefinition & IPX_TRAFFIC_FILTER_ON_DSTSOCKET)
  527. pfle->stDestinationSocket << CIPX_SOCKET(pfle->DestinationSocket);
  528. else
  529. pfle->stDestinationSocket = m_stAny;
  530. pDispInfo->item.pszText = (LPTSTR) (LPCTSTR) pfle->stDestinationSocket;
  531. break;
  532. case PACKET_TYPE:
  533. if (pfle->FilterDefinition & IPX_TRAFFIC_FILTER_ON_PKTTYPE)
  534. pfle->stPacketType << CIPX_PACKET_TYPE(pfle->PacketType);
  535. else
  536. pfle->stPacketType = m_stAny;
  537. pDispInfo->item.pszText = (LPTSTR) (LPCTSTR) pfle->stPacketType;
  538. break;
  539. default:
  540. break;
  541. }
  542. }
  543. *pResult = 0;
  544. }
  545. void CIpxFilter::OnNotifyListItemChanged(NMHDR *pNmHdr, LRESULT *pResult)
  546. {
  547. BOOL fSelected;
  548. fSelected = (m_listCtrl.GetNextItem(-1, LVNI_SELECTED) != -1);
  549. GetDlgItem(IDC_IPX_FILTER_DELETE)->EnableWindow(fSelected);
  550. GetDlgItem(IDC_IPX_FILTER_EDIT)->EnableWindow(fSelected);
  551. }