home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / netds / ras / winnt / rassapi / admindll.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-10-09  |  41.3 KB  |  927 lines

  1. /******************************************************************************
  2. *       This is a part of the Microsoft Source Code Samples. 
  3. *       Copyright 1992 - 1997 Microsoft Corporation.
  4. *       All rights reserved. 
  5. *       This source code is only intended as a supplement to 
  6. *       RasAdmin API usage and  is meant to help user with
  7. *       RasAdmin API Calling convention. Use this code at your own risk. 
  8. *       Microsoft disclaims any implied warranty. This sample code can
  9. *       be copied and distributed.
  10.  
  11. ******************************************************************************/
  12.  
  13. /********************************************************************
  14. *  admindll.c -- Sample program demonstrating the use of RasAdmin
  15. *                     CallOut API's
  16. *                                                                    
  17. *****************************************************************************/
  18. /***************************************************************************
  19. *  Functions:
  20. *        Init(void);
  21. *        Init2(void);
  22. *****************************************************************************/
  23.  
  24. #include <windows.h>
  25. #include <stdlib.h>
  26. #include <string.h>
  27. #include <stdlib.h>
  28. #include <lm.h>
  29. #include <stdio.h>
  30. #include <time.h>
  31. #include <rassapi.h>
  32. #include <memory.h>
  33. WCHAR*
  34. StrDupWFromA(
  35.     CHAR* psz );
  36.  
  37.  
  38.  
  39. #define Number_Of_Flags 6
  40. #define Num_Ip_Address 256
  41. #define ConstIpAddress 0x010A0F0E
  42. HANDLE IPFile = NULL;
  43. HANDLE ConDisFile = NULL;
  44. HANDLE ErrLogFile = NULL;
  45. HANDLE ErrLogFileIP = NULL;
  46. BOOL IPFileInValid = FALSE;
  47. BOOL ConnectDisconnectInValid = FALSE;
  48. BOOL ErrorLogInValid = FALSE;
  49. BOOL ErrLogIPInValid = FALSE;
  50. VOID File_Print(RAS_PORT_1 *            pRasPort1,
  51.     RAS_PORT_STATISTICS *   pRasStats,
  52.     RAS_PARAMETERS *        pRasParams
  53. );
  54. VOID Debug_Print(RAS_PORT_1 *            pRasPort1,
  55.     RAS_PORT_STATISTICS *   pRasStats,
  56.     RAS_PARAMETERS *        pRasParams
  57. );
  58. VOID Init(void);
  59. VOID Init2(void);
  60. typedef struct Static_IP_Database
  61.     {
  62.     WCHAR wszUserName[UNLEN+1];
  63.     WCHAR wszPortName[RASSAPI_MAX_PORT_NAME];
  64.     DWORD IpAddress;
  65.     } Static_IP_Database;
  66. Static_IP_Database  Static_IP[Num_Ip_Address];
  67.  
  68. typedef struct Static_Statistic{
  69.           BOOL bTaken;
  70.     WCHAR wszUserName[UNLEN+1];
  71.     WCHAR wszPortName[RASSAPI_MAX_PORT_NAME];
  72.     DWORD NumMediaParms;
  73.     DWORD SizeMediaParms;
  74.     DWORD dwStartSessionTime;
  75.     RAS_PORT_STATISTICS  pRasStats;
  76.           RAS_PARAMETERS        pRasParams;
  77.     } Static_Statistic;
  78.  
  79. Static_Statistic  Static_Check_Stats[Num_Ip_Address];
  80. BOOL First_Call = TRUE;
  81.  
  82. WCHAR*
  83. StrDupWFromA(
  84.     CHAR* psz )
  85.  
  86.     /* Returns heap block containing a copy of 0-terminated string 'psz' or
  87.     ** NULL on error or if 'psz' is NULL.  The output string is converted to
  88.     ** UNICODE.  It is caller's responsibility to Free the returned string.
  89.     */
  90. {
  91.     WCHAR* pszNew = NULL;
  92.  
  93.     if (psz)
  94.     {
  95.     DWORD cb;
  96.  
  97.     cb = MultiByteToWideChar( CP_ACP, 0, psz, -1, NULL, 0 );
  98.  
  99.     pszNew = malloc( cb * sizeof(TCHAR) );
  100.     if (!pszNew)
  101.     {
  102.         return NULL;
  103.     }
  104.  
  105.     cb = MultiByteToWideChar( CP_ACP, 0, psz, -1, pszNew, cb );
  106.     if (cb == 0)
  107.     {
  108.         free( pszNew );
  109.         return NULL;
  110.     }
  111.     }
  112.  
  113.     return pszNew;
  114. }
  115.  
  116.  
  117.  
  118.  
  119. // Format and write debug information to OutputDebugString
  120. ULONG
  121. _cdecl
  122. DbgPrint(
  123.     PCH Format,
  124.     ...
  125.     )
  126. {   
  127.     CHAR szbuffer[255];
  128.     WCHAR buffer[255];
  129.     WCHAR *temp=NULL;
  130.     LPINT lpResult=0;
  131.     va_list marker;
  132.     va_start (marker,Format);
  133.     if (IsTextUnicode(Format, sizeof(marker),lpResult))
  134.     {
  135.     temp=StrDupWFromA(Format);
  136.          wvsprintfW (buffer,temp, marker);
  137.          OutputDebugString (buffer);
  138.           free(temp);
  139.     }
  140.     else
  141.     {
  142.          wvsprintfA (szbuffer,Format, marker);
  143.          temp=StrDupWFromA(szbuffer);
  144.          OutputDebugString (temp);
  145.          free(temp);
  146.          }
  147.     return TRUE;
  148. }
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156. //Called from RasAdminGetIpAddressForUser which in trun gets called by RasMan
  157. VOID Init(void)
  158. {
  159. INT i=0;
  160.           
  161.          IPFile = CreateFile(TEXT("IpAddress.log"),
  162.                 GENERIC_READ|GENERIC_WRITE,
  163.                 FILE_SHARE_READ,
  164.                 (LPSECURITY_ATTRIBUTES) NULL,
  165.                 CREATE_ALWAYS,
  166.                 0,
  167.                    (HANDLE) NULL);
  168.          if (IPFile== INVALID_HANDLE_VALUE) {
  169.         IPFileInValid = TRUE;
  170.         }
  171.          ErrLogFileIP = CreateFile(TEXT("IpAddError.log"),
  172.                 GENERIC_READ|GENERIC_WRITE,
  173.                 FILE_SHARE_READ,
  174.                 (LPSECURITY_ATTRIBUTES) NULL,
  175.                 CREATE_ALWAYS,
  176.                 0,
  177.                    (HANDLE) NULL);
  178.          if (ErrLogFileIP== INVALID_HANDLE_VALUE) {
  179.         ErrLogIPInValid = TRUE;
  180.         }
  181.         
  182. //First call initialize my Stats Database, I Fill out the struct if Call is Accepted the call.
  183.     First_Call=FALSE;
  184. }
  185. //Called by RasAdminAcceptNewConnection which in trun gets called by RAS Server (Rassrv)
  186. VOID Init2(void)
  187. {
  188. INT i=0;
  189.          ConDisFile = CreateFile(TEXT("ConDis.log"),
  190.                 GENERIC_READ|GENERIC_WRITE,
  191.                 FILE_SHARE_READ,
  192.                 (LPSECURITY_ATTRIBUTES) NULL,
  193.                 OPEN_ALWAYS,
  194.                 0,
  195.                    (HANDLE) NULL);
  196.          if (ConDisFile== INVALID_HANDLE_VALUE) {
  197.           ConnectDisconnectInValid = TRUE;        
  198.         }
  199.          ErrLogFile = CreateFile(TEXT("AdminErr.log"),
  200.                 GENERIC_READ|GENERIC_WRITE,
  201.                 FILE_SHARE_READ,
  202.                 (LPSECURITY_ATTRIBUTES) NULL,
  203.                 OPEN_ALWAYS,
  204.                 0,
  205.                    (HANDLE) NULL);
  206.          if (ErrLogFile == INVALID_HANDLE_VALUE) {
  207.         ErrorLogInValid = TRUE;
  208.         }
  209.     for (i=0;i < Num_Ip_Address; i++);
  210.       Static_Check_Stats[i].bTaken=FALSE;
  211. }
  212.  
  213.  
  214. DWORD
  215. APIENTRY
  216. RasAdminGetIpAddressForUser(
  217.     IN WCHAR *      lpwszUserName,
  218.     IN WCHAR *      lpwszPortName,
  219.     IN OUT IPADDR * pIpAddress,
  220.     OUT BOOL *      pfNotifyDLL
  221. )
  222. {
  223. DWORD i=0;
  224. DWORD dwBytesWritten=0;
  225. CHAR buf[120];
  226. //to check if the call is first rasman call out. If yes, call Initialize routine
  227.     if (First_Call) Init();
  228.     DbgPrint("First_Call  %d\n",First_Call);
  229.     DbgPrint("\nGetIpAddressForUser called UserName=%ws,Port=%ws,IpAddress=%d\n",
  230.           lpwszUserName,lpwszPortName,(DWORD)*pIpAddress );
  231.  
  232.     for (i=1;i < Num_Ip_Address;i++)
  233.     {
  234.     if (Static_IP[i].IpAddress != 1)
  235.         {
  236.          Static_IP[i].IpAddress = 1;
  237.          wcscpy(Static_IP[i].wszUserName, lpwszUserName);
  238.          wcscpy(Static_IP[i].wszPortName, lpwszPortName);
  239.          *pIpAddress = i + ConstIpAddress;
  240.           break;
  241.         }
  242.     }
  243.     if (IPFileInValid)
  244.      {
  245.      DbgPrint("GetIpAddressForUser setting IpAddress=%d\n",(DWORD)*pIpAddress );
  246.      }
  247.     else
  248.     {
  249.      sprintf(buf,"GetIpAddressForUser setting IpAddress=%d\n",(DWORD)*pIpAddress );
  250.            WriteFile(IPFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  251.     
  252.           } 
  253.     *pfNotifyDLL = TRUE;
  254.     
  255.     return( NO_ERROR );
  256. }
  257.  
  258.  
  259. VOID
  260. APIENTRY
  261. RasAdminReleaseIpAddress(
  262.     IN WCHAR *      lpwszUserName,
  263.     IN WCHAR *      lpwszPortName,
  264.     IN OUT IPADDR * pIpAddress
  265. )
  266. {
  267. DWORD dwBytesWritten=0;
  268. CHAR buf[120];
  269.     DbgPrint( "\nReleaseIpAddressr called UserName=%ws,Port=%ws,IpAddress=%d\n",
  270.           lpwszUserName,lpwszPortName,(DWORD)*pIpAddress );
  271.      if (wcscmp(Static_IP[(DWORD)*pIpAddress-ConstIpAddress].wszUserName,lpwszUserName) == 0)
  272.      {
  273.       if (wcscmp(Static_IP[(DWORD)*pIpAddress-ConstIpAddress].wszPortName,lpwszPortName) == 0)
  274.           {
  275.            Static_IP[(DWORD)*pIpAddress-ConstIpAddress].IpAddress = 0;
  276.           }
  277.           else
  278.           {
  279.            DbgPrint("ERROR ReleaseIP PortName Incorrect, Cannot free IP Address       %ws\n",Static_IP[(DWORD)*pIpAddress-ConstIpAddress].wszPortName);
  280.            if (!(ErrLogIPInValid))
  281.                 {
  282.          sprintf(buf,"ERROR ReleaseIP PortName Incorrect, Cannot free IP Address       %ws\n",Static_IP[(DWORD)*pIpAddress-ConstIpAddress].wszPortName);
  283.                 WriteFile(ErrLogFileIP, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  284.                 }
  285.           }
  286.      }
  287.      else
  288.      {
  289.      DbgPrint("ERROR ReleaseIP UserName Incorrect, Cannot free IP Address       %ws\n",Static_IP[(DWORD)*pIpAddress-ConstIpAddress].wszUserName);
  290.      if (!(ErrLogIPInValid))
  291.            {
  292.          sprintf(buf,"ERROR ReleaseIP UserName Incorrect, Cannot free IP Address       %ws\n",Static_IP[(DWORD)*pIpAddress-ConstIpAddress].wszUserName);
  293.            WriteFile(ErrLogFileIP, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  294.            }
  295.      } 
  296. }
  297.  
  298.  
  299. BOOL
  300. APIENTRY
  301. RasAdminAcceptNewConnection(
  302.     RAS_PORT_1 *            pRasPort1,
  303.     RAS_PORT_STATISTICS *   pRasStats,
  304.     RAS_PARAMETERS *        pRasParams
  305. )
  306. {
  307. INT i=0;
  308. DWORD dwResult;
  309. WCHAR szUserAccountServer[UNLEN+1];
  310. PRAS_USER_0 ppRasUser0;
  311. RAS_USER_0 RasUser0;
  312. WCHAR Buf[512];
  313. WCHAR *lpszString;
  314. DWORD dwBytesWritten=0;
  315. CHAR szBuf[120];
  316. WCHAR lpszServerName[50];
  317. DWORD Permission;
  318. lpszString = &Buf[0];
  319. ppRasUser0 = &RasUser0;
  320.  
  321. //to check if the call is first rassrv call out. If yes, call Initialize routine
  322.  
  323. if (First_Call) {Init2(); First_Call = FALSE;}
  324. DbgPrint("ConnectDisconnect   %d\n",ConDisFile);
  325. DbgPrint("ConnectDisconnectInValid %d\n",ConnectDisconnectInValid);
  326. DbgPrint("ErrorLogFile   %d\n",ErrLogFile);
  327. DbgPrint("ErrorLogInValid %d\n",ErrorLogInValid);
  328. if (ConnectDisconnectInValid)
  329.    {
  330.     DbgPrint( "\nRasAdminAcceptNewConnection called \n" );
  331.     Debug_Print( pRasPort1, pRasStats, pRasParams);
  332.   }
  333. else
  334.   {
  335.     sprintf(szBuf, "\nRasAdminAcceptNewConnection called \n" );
  336.     WriteFile(ConDisFile, (LPSTR)szBuf, strlen(szBuf), &dwBytesWritten, NULL);
  337.     File_Print( pRasPort1, pRasStats, pRasParams);
  338.   }
  339.    if (pRasPort1->rasport0.fAdvancedServer > 0){
  340.   dwResult = RasAdminGetUserAccountServer(pRasPort1->rasport0.wszLogonDomain, NULL, &szUserAccountServer[0]);}
  341.   else {  
  342.       lstrcpy(lpszServerName, TEXT("\\\\"));
  343.       lstrcat(&lpszServerName[0], pRasPort1->rasport0.wszLogonDomain);
  344.       DbgPrint("%ws\n",lpszServerName);
  345.       dwResult = RasAdminGetUserAccountServer(NULL, &lpszServerName[0], &szUserAccountServer[0]);
  346.       }
  347.  
  348.   if (dwResult == ERROR_SUCCESS)
  349.      {
  350.      DbgPrint("UserAccount Succeeded\n");
  351.      dwResult = RasAdminUserGetInfo(szUserAccountServer, pRasPort1->rasport0.wszUserName, ppRasUser0);
  352.      if (dwResult == ERROR_SUCCESS)
  353.      {
  354.            DbgPrint("AdminUserGetInfo Succeeded");
  355.            DbgPrint(" Priviledge   %d\n",ppRasUser0->bfPrivilege);
  356.            Permission = ppRasUser0->bfPrivilege - (ppRasUser0->bfPrivilege & RASPRIV_DialinPrivilege);
  357.            DbgPrint("Permission %d\n",Permission);
  358.      if (Permission == RASPRIV_AdminSetCallback || Permission == RASPRIV_CallerSetCallback)
  359.         {
  360.         DbgPrint ("Don't Accept Call\n");
  361.         return (FALSE);
  362.         }
  363.      }
  364.      else
  365.     {
  366.           DbgPrint("RasAdminUserGetInfo     %d\n",dwResult);
  367.         dwResult = RasAdminGetErrorString((UINT) dwResult, lpszString, 512);
  368.     if (dwResult == ERROR_SUCCESS)
  369.         {
  370.         DbgPrint("ERROR  RasAdminUserGetInfo      %s\n",lpszString);
  371.          sprintf(szBuf, "ERROR  RasAdminUserGetInfo      %s\n",lpszString);     
  372.           WriteFile(ErrLogFile, (LPSTR)szBuf, strlen(szBuf), &dwBytesWritten, NULL);
  373.         }
  374.      else
  375.         {
  376.         DbgPrint("ERROR  RasAdminGetErrorString      %d\n",dwResult);
  377.         sprintf(szBuf, "ERROR  RasAdminGetErrorString      %d\n",dwResult);     
  378.           WriteFile(ErrLogFile, (LPSTR)szBuf, strlen(szBuf), &dwBytesWritten, NULL);
  379.         }
  380.      }
  381.     }
  382.   else
  383.     {
  384.     DbgPrint("RasAdminGetUserAccountServer     %d\n",dwResult);
  385.     dwResult = RasAdminGetErrorString((UINT)dwResult, lpszString, 512);
  386.      if (dwResult == ERROR_SUCCESS)
  387.       {
  388.       DbgPrint("ERROR  RasAdminUserAccountServer      %s\n",lpszString);
  389.       sprintf(szBuf, "ERROR  RasAdminUserAccountServer      %s\n",lpszString);     
  390.         WriteFile(ErrLogFile, (LPSTR)szBuf, strlen(szBuf), &dwBytesWritten, NULL);
  391.       }
  392.       else
  393.         {
  394.         DbgPrint("ERROR  RasAdminGetErrorString      %d\n",dwResult);
  395.         sprintf(szBuf, "ERROR  RasAdminGetErrorString      %d\n",dwResult);     
  396.           WriteFile(ErrLogFile, (LPSTR)szBuf, strlen(szBuf), &dwBytesWritten, NULL);
  397.         }
  398.     }
  399.  
  400.   if (( lstrcmp( pRasPort1->rasport0.wszUserName, TEXT("Administrator") ) ) == 0)
  401.        {
  402.     DbgPrint("Do not Accept Connection\n");
  403.           FlushFileBuffers(ErrLogFile);
  404.           FlushFileBuffers(ConDisFile);
  405.     return( FALSE );
  406.        }
  407.     else
  408.        {
  409.       for (i=0;i < Num_Ip_Address; i++)
  410.          if (!(Static_Check_Stats[i].bTaken))
  411.           {
  412.            wcscpy(Static_Check_Stats[i].wszUserName, pRasPort1->rasport0.wszUserName);
  413.            wcscpy(Static_Check_Stats[i].wszPortName, pRasPort1->rasport0.wszPortName);
  414.                    Static_Check_Stats[i].bTaken = TRUE;
  415.            Static_Check_Stats[i].NumMediaParms = pRasPort1->NumMediaParms;
  416.            Static_Check_Stats[i].SizeMediaParms = pRasPort1->SizeMediaParms;
  417.            Static_Check_Stats[i].dwStartSessionTime = pRasPort1->rasport0.dwStartSessionTime;
  418.            memcpy(&Static_Check_Stats[i].pRasStats,pRasStats, sizeof(RAS_PORT_STATISTICS));
  419.            memcpy(&Static_Check_Stats[i].pRasParams,pRasParams, sizeof(pRasParams));
  420.            break;
  421.           }
  422.        DbgPrint("Accept Connection\n");
  423.        FlushFileBuffers(ErrLogFile);
  424.        FlushFileBuffers(ConDisFile);
  425.        return( TRUE );
  426.        }
  427. }
  428.  
  429. VOID
  430. APIENTRY
  431. RasAdminConnectionHangupNotification(
  432.     RAS_PORT_1 *            pRasPort1,
  433.     RAS_PORT_STATISTICS *   pRasStats,
  434.     RAS_PARAMETERS *        pRasParams
  435. )
  436. {
  437. INT i=0;
  438. DWORD dwBytesWritten=0;
  439. CHAR buf[120];
  440. //if (First_Call) Init2();
  441. if (ConnectDisconnectInValid)
  442.    {
  443.     DbgPrint( "\nRasAdminConnectionHangupNotification called \n" );
  444.     Debug_Print( pRasPort1, pRasStats, pRasParams);
  445.   }
  446. else
  447.   {
  448.     sprintf(buf, "\nRasAdminConnectionHangupNotification called \n" );
  449.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  450.     File_Print( pRasPort1, pRasStats, pRasParams);
  451.   }
  452.  
  453.  
  454. //Sanity checks
  455.       for (i=0; i < Num_Ip_Address; i++)
  456.        {
  457.     if (Static_Check_Stats[i].bTaken)
  458.          {
  459.           if (wcscmp(Static_Check_Stats[i].wszPortName,pRasPort1->rasport0.wszPortName) == 0)
  460.           {
  461.             if (ErrorLogInValid)
  462.            {       
  463.            if (wcscmp(Static_Check_Stats[i].wszUserName,pRasPort1->rasport0.wszUserName) != 0)
  464.             DbgPrint("ERROR User Name Differs    %ws ->Passed,   %ws ->Stored\n",pRasPort1->rasport0.wszUserName,Static_Check_Stats[i].wszUserName);
  465.                    Static_Check_Stats[i].bTaken = FALSE;
  466.            if (Static_Check_Stats[i].NumMediaParms != pRasPort1->NumMediaParms)
  467.              DbgPrint("ERROR NumMediaParm    %d ->Passed,   %d  ->Stored\n",Static_Check_Stats[i].NumMediaParms != pRasPort1->NumMediaParms);
  468.            if (Static_Check_Stats[i].SizeMediaParms != pRasPort1->SizeMediaParms)
  469.              DbgPrint("ERROR SizeMediaParm    %d ->Passed,   %d  ->Stored\n",Static_Check_Stats[i].SizeMediaParms != pRasPort1->SizeMediaParms);
  470.            if (Static_Check_Stats[i].dwStartSessionTime != pRasPort1->rasport0.dwStartSessionTime)
  471.              DbgPrint("ERROR StartSessionTime    %d ->Passed,   %d  ->Stored\n",Static_Check_Stats[i].dwStartSessionTime, pRasPort1->rasport0.dwStartSessionTime);
  472.            if (pRasStats->dwBytesXmited < Static_Check_Stats[i].pRasStats.dwBytesXmited) 
  473.               DbgPrint( "ERROR dwBytesXmited Passed=%d   , dwBytesXmited Stored=%d\n", pRasStats->dwBytesXmited,Static_Check_Stats[i].pRasStats.dwBytesXmited);
  474.            if (pRasStats->dwBytesRcved < Static_Check_Stats[i].pRasStats.dwBytesRcved) 
  475.               DbgPrint( "ERROR dwBytesRcved Passed=%d    , dwBytesRcved Stored=%d\n", pRasStats->dwBytesRcved,Static_Check_Stats[i].pRasStats.dwBytesRcved );
  476.            if (pRasStats->dwFramesXmited < Static_Check_Stats[i].pRasStats.dwFramesXmited) 
  477.              DbgPrint( "ERROR dwFramesXmited Passed=%d , dwFramesXmited Stored=%d\n", pRasStats->dwFramesXmited,Static_Check_Stats[i].pRasStats.dwFramesXmited );
  478.            if (pRasStats->dwFramesRcved < Static_Check_Stats[i].pRasStats.dwFramesRcved) 
  479.              DbgPrint( "ERROR dwFramesRcved Passed=%d , dwFramesRcved Stored=%d\n", pRasStats->dwFramesRcved,Static_Check_Stats[i].pRasStats.dwFramesRcved);
  480.            if (pRasStats->dwCrcErr < Static_Check_Stats[i].pRasStats.dwCrcErr) 
  481.             DbgPrint( "ERROR dwCrcErr Passed=%d , dwCrcErr Stored=%d\n", pRasStats->dwCrcErr,Static_Check_Stats[i].pRasStats.dwCrcErr);
  482.            if (pRasStats->dwTimeoutErr < Static_Check_Stats[i].pRasStats.dwTimeoutErr) 
  483.             DbgPrint( "ERROR dwTimeoutErr Passed=%d  , dwTimeoutErr Stored=%d\n", pRasStats->dwTimeoutErr,Static_Check_Stats[i].pRasStats.dwTimeoutErr);
  484.            if (pRasStats->dwAlignmentErr < Static_Check_Stats[i].pRasStats.dwAlignmentErr) 
  485.             DbgPrint( "ERROR dwAlignmentErr Passed=%d , dwAlignmentErr Stored=%d\n", pRasStats->dwAlignmentErr,Static_Check_Stats[i].pRasStats.dwAlignmentErr);
  486.            if (pRasStats->dwHardwareOverrunErr < Static_Check_Stats[i].pRasStats.dwHardwareOverrunErr) 
  487.             DbgPrint( "ERROR dwHardwareOverrunErr Passed=%d  , dwHardwareOverrunErr Stored=%d\n", pRasStats->dwHardwareOverrunErr,Static_Check_Stats[i].pRasStats.dwHardwareOverrunErr);
  488.            if (pRasStats->dwFramingErr < Static_Check_Stats[i].pRasStats.dwFramingErr) 
  489.                DbgPrint( "ERROR dwFramingErr Passed=%d , dwFramingErr Stored=%d\n", pRasStats->dwFramingErr,Static_Check_Stats[i].pRasStats.dwFramingErr);
  490.            if (pRasStats->dwBufferOverrunErr < Static_Check_Stats[i].pRasStats.dwBufferOverrunErr) 
  491.                DbgPrint( "ERROR dwBufferOverrunErr Passed=%d , dwBufferOverrunErr Stored=%d\n", pRasStats->dwBufferOverrunErr,Static_Check_Stats[i].pRasStats.dwBufferOverrunErr);
  492.            if (pRasStats->dwBytesXmitedUncompressed < Static_Check_Stats[i].pRasStats.dwBytesXmitedUncompressed) 
  493.                DbgPrint( "ERROR dwBytesXmitedUncompressed Passed=%d   ,  dwBytesXmitedUncompressed Stored=%d\n",
  494.                     pRasStats->dwBytesXmitedUncompressed,Static_Check_Stats[i].pRasStats.dwBytesXmitedUncompressed);
  495.            if (pRasStats->dwBytesRcvedUncompressed < Static_Check_Stats[i].pRasStats.dwBytesRcvedUncompressed) 
  496.                DbgPrint( "ERROR dwBytesRcvedUncompressed  Passed=%d    ,dwBytesRcvedUncompressed Stored=%d\n",
  497.                     pRasStats->dwBytesRcvedUncompressed,Static_Check_Stats[i].pRasStats.dwBytesRcvedUncompressed);
  498.            if (pRasStats->dwBytesXmitedCompressed < Static_Check_Stats[i].pRasStats.dwBytesXmitedCompressed) 
  499.                DbgPrint( "ERROR dwBytesXmitedCompressed Passed=%d   ,dwBytesXmitedCompressed Stored=%d\n",
  500.                     pRasStats->dwBytesXmitedCompressed,Static_Check_Stats[i].pRasStats.dwBytesXmitedCompressed);
  501.            if (pRasStats->dwBytesRcvedCompressed < Static_Check_Stats[i].pRasStats.dwBytesRcvedCompressed) 
  502.               DbgPrint( "ERROR dwBytesRcvedCompressed Passed=%d    ,dwBytesRcvedCompressed Stored=%d\n",
  503.                     pRasStats->dwBytesRcvedCompressed,Static_Check_Stats[i].pRasStats.dwBytesRcvedCompressed);
  504.                   if (memcmp(&Static_Check_Stats[i].pRasParams,pRasParams, sizeof(pRasParams)) != 0)
  505.               DbgPrint( "ERROR RASParams Passed   &  RASParasms Stored are different\n");
  506.              }
  507.              else
  508.              {
  509.            if (wcscmp(Static_Check_Stats[i].wszUserName,pRasPort1->rasport0.wszUserName) != 0)
  510.             {sprintf(buf,"ERROR User Name Differs    %ws ->Passed,   %ws ->Stored\n",pRasPort1->rasport0.wszUserName,Static_Check_Stats[i].wszUserName);
  511.                        WriteFile(ErrLogFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  512.                       }
  513.                    Static_Check_Stats[i].bTaken = FALSE;
  514.            if (Static_Check_Stats[i].NumMediaParms != pRasPort1->NumMediaParms)
  515.              {sprintf(buf,"ERROR NumMediaParm    %d ->Passed,   %d  ->Stored\n",Static_Check_Stats[i].NumMediaParms != pRasPort1->NumMediaParms);
  516.                        WriteFile(ErrLogFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  517.                       }
  518.            if (Static_Check_Stats[i].SizeMediaParms != pRasPort1->SizeMediaParms)
  519.              {sprintf(buf,"ERROR SizeMediaParm    %d ->Passed,   %d  ->Stored\n",Static_Check_Stats[i].SizeMediaParms != pRasPort1->SizeMediaParms);
  520.                        WriteFile(ErrLogFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  521.                       }
  522.            if (Static_Check_Stats[i].dwStartSessionTime != pRasPort1->rasport0.dwStartSessionTime)
  523.              {sprintf(buf,"ERROR StartSessionTime    %d ->Passed,   %d  ->Stored\n",Static_Check_Stats[i].dwStartSessionTime != pRasPort1->rasport0.dwStartSessionTime);
  524.                        WriteFile(ErrLogFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  525.                       }
  526.            if (pRasStats->dwBytesXmited < Static_Check_Stats[i].pRasStats.dwBytesXmited) 
  527.              { sprintf(buf, "ERROR dwBytesXmited Passed=%d   , dwBytesXmited Stored=%d\n", pRasStats->dwBytesXmited,Static_Check_Stats[i].pRasStats.dwBytesXmited);
  528.                        WriteFile(ErrLogFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  529.                       }
  530.            if (pRasStats->dwBytesRcved < Static_Check_Stats[i].pRasStats.dwBytesRcved) 
  531.              { sprintf(buf, "ERROR dwBytesRcved Passed=%d    , dwBytesRcved Stored=%d\n", pRasStats->dwBytesRcved,Static_Check_Stats[i].pRasStats.dwBytesRcved );
  532.                        WriteFile(ErrLogFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  533.                       }
  534.            if (pRasStats->dwFramesXmited < Static_Check_Stats[i].pRasStats.dwFramesXmited) 
  535.              {sprintf(buf, "ERROR dwFramesXmited Passed=%d , dwFramesXmited Stored=%d\n", pRasStats->dwFramesXmited,Static_Check_Stats[i].pRasStats.dwFramesXmited );
  536.                        WriteFile(ErrLogFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  537.                       }
  538.            if (pRasStats->dwFramesRcved < Static_Check_Stats[i].pRasStats.dwFramesRcved) 
  539.              {sprintf(buf, "ERROR dwFramesRcved Passed=%d , dwFramesRcved Stored=%d\n", pRasStats->dwFramesRcved,Static_Check_Stats[i].pRasStats.dwFramesRcved);
  540.                        WriteFile(ErrLogFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  541.                       }
  542.            if (pRasStats->dwCrcErr < Static_Check_Stats[i].pRasStats.dwCrcErr) 
  543.             {sprintf(buf, "ERROR dwCrcErr Passed=%d , dwCrcErr Stored=%d\n", pRasStats->dwCrcErr,Static_Check_Stats[i].pRasStats.dwCrcErr);
  544.                        WriteFile(ErrLogFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  545.                       }
  546.            if (pRasStats->dwTimeoutErr < Static_Check_Stats[i].pRasStats.dwTimeoutErr) 
  547.             {sprintf(buf, "ERROR dwTimeoutErr Passed=%d  , dwTimeoutErr Stored=%d\n", pRasStats->dwTimeoutErr,Static_Check_Stats[i].pRasStats.dwTimeoutErr);
  548.                        WriteFile(ErrLogFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  549.                       }
  550.            if (pRasStats->dwAlignmentErr < Static_Check_Stats[i].pRasStats.dwAlignmentErr) 
  551.             {sprintf(buf, "ERROR dwAlignmentErr Passed=%d , dwAlignmentErr Stored=%d\n", pRasStats->dwAlignmentErr,Static_Check_Stats[i].pRasStats.dwAlignmentErr);
  552.                        WriteFile(ErrLogFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  553.                       }
  554.            if (pRasStats->dwHardwareOverrunErr < Static_Check_Stats[i].pRasStats.dwHardwareOverrunErr) 
  555.             {sprintf(buf, "ERROR dwHardwareOverrunErr Passed=%d  , dwHardwareOverrunErr Stored=%d\n", pRasStats->dwHardwareOverrunErr,Static_Check_Stats[i].pRasStats.dwHardwareOverrunErr);
  556.                        WriteFile(ErrLogFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  557.                       }
  558.            if (pRasStats->dwFramingErr < Static_Check_Stats[i].pRasStats.dwFramingErr) 
  559.                   {sprintf(buf, "ERROR dwFramingErr Passed=%d , dwFramingErr Stored=%d\n", pRasStats->dwFramingErr,Static_Check_Stats[i].pRasStats.dwFramingErr);
  560.                        WriteFile(ErrLogFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  561.                       }
  562.            if (pRasStats->dwBufferOverrunErr < Static_Check_Stats[i].pRasStats.dwBufferOverrunErr) 
  563.                   {sprintf(buf, "ERROR dwBufferOverrunErr Passed=%d , dwBufferOverrunErr Stored=%d\n", pRasStats->dwBufferOverrunErr,Static_Check_Stats[i].pRasStats.dwBufferOverrunErr);
  564.                        WriteFile(ErrLogFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  565.                       }
  566.            if (pRasStats->dwBytesXmitedUncompressed < Static_Check_Stats[i].pRasStats.dwBytesXmitedUncompressed) 
  567.                  { sprintf(buf, "ERROR dwBytesXmitedUncompressed Passed=%d   ,  dwBytesXmitedUncompressed Stored=%d\n",
  568.                     pRasStats->dwBytesXmitedUncompressed,Static_Check_Stats[i].pRasStats.dwBytesXmitedUncompressed);
  569.                        WriteFile(ErrLogFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  570.                       }
  571.            if (pRasStats->dwBytesRcvedUncompressed < Static_Check_Stats[i].pRasStats.dwBytesRcvedUncompressed) 
  572.                   {sprintf(buf, "ERROR dwBytesRcvedUncompressed  Passed=%d    ,dwBytesRcvedUncompressed Stored=%d\n",
  573.                     pRasStats->dwBytesRcvedUncompressed,Static_Check_Stats[i].pRasStats.dwBytesRcvedUncompressed);
  574.                        WriteFile(ErrLogFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  575.                       }
  576.            if (pRasStats->dwBytesXmitedCompressed < Static_Check_Stats[i].pRasStats.dwBytesXmitedCompressed) 
  577.                   {sprintf(buf, "ERROR dwBytesXmitedCompressed Passed=%d   ,dwBytesXmitedCompressed Stored=%d\n",
  578.                     pRasStats->dwBytesXmitedCompressed,Static_Check_Stats[i].pRasStats.dwBytesXmitedCompressed);
  579.                        WriteFile(ErrLogFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  580.                       }
  581.            if (pRasStats->dwBytesRcvedCompressed < Static_Check_Stats[i].pRasStats.dwBytesRcvedCompressed) 
  582.                 { sprintf(buf, "ERROR dwBytesRcvedCompressed Passed=%d    ,dwBytesRcvedCompressed Stored=%d\n",
  583.                     pRasStats->dwBytesRcvedCompressed,Static_Check_Stats[i].pRasStats.dwBytesRcvedCompressed);
  584.                        WriteFile(ErrLogFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  585.                              }
  586.                   if (memcmp(&Static_Check_Stats[i].pRasParams,pRasParams, sizeof(pRasParams)) != 0)
  587.                 { sprintf(buf, "ERROR RASParams Passed   &  RASParasms Stored are different\n");
  588.                    WriteFile(ErrLogFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  589.                          }
  590.  
  591.               }
  592.                   break;
  593.             }
  594.          else
  595.           {       if (i == 255){
  596.                   if (ErrorLogInValid) 
  597.                {DbgPrint("ERROR Port Name  Differs    %ws ->Passed,   %ws ->Stored\n",pRasPort1->rasport0.wszPortName,Static_Check_Stats[i].wszPortName);}
  598.              else
  599.                {sprintf(buf,"ERROR Port Name  Differs    %ws ->Passed,   %ws ->Stored\n",pRasPort1->rasport0.wszPortName,Static_Check_Stats[i].wszPortName);
  600.                        WriteFile(ErrLogFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  601.                       }
  602.               }
  603.          }
  604.            }
  605.      }
  606.     FlushFileBuffers(ErrLogFile);
  607.     FlushFileBuffers(ConDisFile);
  608.  
  609. }
  610.  
  611. VOID Debug_Print(RAS_PORT_1 *            pRasPort1,
  612.     RAS_PORT_STATISTICS *   pRasStats,
  613.     RAS_PARAMETERS *        pRasParams
  614. )
  615. {
  616. WCHAR *Media_Name[] = {TEXT("MEDIA_UNKNOWN"),TEXT( "MEDIA_SERIAL"),
  617.           TEXT("MEDIA_RAS10_SERIAL"),TEXT( "MEDIA_ISDN")};
  618. WCHAR *Flag_Name[] = {TEXT("USER_AUTHENTICATED"),TEXT( "MESSENGER_PRESENT"),
  619.          TEXT("PPP_CLIENT"),TEXT("GATEWAY_ACTIVE"),TEXT("REMOTE_LISTEN"),TEXT("PORT_MULTILINKED")};
  620. WCHAR *Line_Condition[]={TEXT("RAS_PORT_NON_OPERATIONAL"),TEXT("RAS_PORT_DISCONNECTED"),
  621.           TEXT("RAS_PORT_CALLING_BACK"),TEXT("RAS_PORT_LISTENING"),TEXT("RAS_PORT_AUTHENTICATING"),
  622.           TEXT("RAS_PORT_AUTHENTICATED"),TEXT("RAS_PORT_INITIALIZING")};
  623. WCHAR *Hdw_Error[]={TEXT("RAS_MODEM_OPERATIONAL"),TEXT("RAS_MODEM_NOT_RESPONDING"),TEXT("RAS_MODEM_HARDWARE_FAILURE"),
  624.           TEXT("RAS_MODEM_INCORRECT_RESPONSE"),TEXT("RAS_MODEM_UNKNOWN")};
  625. INT  i=0;
  626. INT temp = 0;
  627. INT temp1 =0;
  628. DWORD dwsize=0;
  629. CHAR szBuf[100];
  630.     DbgPrint( "\nRasAdminAcceptNewConnection called \n" );
  631.     DbgPrint( "pRasPort1->rasport0.wszPortName=%ws\n",
  632.         pRasPort1->rasport0.wszPortName );
  633.     DbgPrint( "pRasPort1->rasport0.wszDeviceType=%ws\n",
  634.             pRasPort1->rasport0.wszDeviceType );
  635.     DbgPrint( "pRasPort1->rasport0.wszDeviceName=%ws\n",
  636.             pRasPort1->rasport0.wszDeviceName );
  637.     DbgPrint( "pRasPort1->rasport0.wszMediaName=%ws\n",
  638.         pRasPort1->rasport0.wszMediaName );
  639.     DbgPrint( "pRasPort1->rasport0.reserved=%d\n",
  640.             pRasPort1->rasport0.reserved );
  641.     DbgPrint("                 %ws\n",Media_Name[pRasPort1->rasport0.reserved]);
  642.     DbgPrint( "pRasPort1->rasport0.Flags=%d\n",
  643.             pRasPort1->rasport0.Flags );
  644. //printing Flags
  645.     temp1 = 1;
  646.     for (i=0; i <= Number_Of_Flags; i++)
  647.      {
  648.      temp = (pRasPort1->rasport0.Flags & temp1);
  649.      if (temp)
  650.          {
  651.            DbgPrint("Flag       %ws   \n",Flag_Name[i]);
  652.          }
  653.       temp1 = temp1*2;
  654.      }
  655.     DbgPrint( "pRasPort1->rasport0.wszUserName=%ws\n",
  656.             pRasPort1->rasport0.wszUserName );
  657.     DbgPrint( "pRasPort1->rasport0.wszComputer=%ws\n",
  658.             pRasPort1->rasport0.wszComputer );
  659.     DbgPrint( "pRasPort1->rasport0.dwStartSessionTime;=%d\n",
  660.             pRasPort1->rasport0.dwStartSessionTime );
  661.     DbgPrint("Formatted session start time/date :  %s\n",ctime(&pRasPort1->rasport0.dwStartSessionTime));
  662.     DbgPrint( "pRasPort1->rasport0.wszLogonDomain=%ws\n",
  663.             pRasPort1->rasport0.wszLogonDomain );
  664.     DbgPrint( "pRasPort1->rasport0.fAdvancedServer=%d\n",
  665.             pRasPort1->rasport0.fAdvancedServer );
  666.     DbgPrint( "pRasPort1->LineCondition=%d\n", pRasPort1->LineCondition );
  667.     DbgPrint("                     %ws\n",Line_Condition[pRasPort1->LineCondition-1]);
  668.     DbgPrint( "pRasPort1->HardwareCondition=%d\n",pRasPort1->HardwareCondition);
  669.     DbgPrint("                     %ws\n",Hdw_Error[pRasPort1->HardwareCondition-1]);
  670.     DbgPrint( "pRasPort1->LineSpeed=%d   bits/sec\n",pRasPort1->LineSpeed);
  671.     DbgPrint( "pRasPort1->NumStatistics=%d\n",pRasPort1->NumStatistics);
  672.     DbgPrint( "pRasPort1->NumMediaParms=%d\n",pRasPort1->NumMediaParms);
  673.     DbgPrint( "pRasPort1->SizeMediaParms=%d\n",pRasPort1->SizeMediaParms);
  674.     DbgPrint( "\npRasPort1->ProjResult.nbf.dwError=%d\n",
  675.                     pRasPort1->ProjResult.nbf.dwError );
  676.     if (pRasPort1->ProjResult.nbf.dwError == NO_ERROR)
  677.        {
  678.     DbgPrint( "pRasPort1->ProjResult.nbf.dwNetBiosError=%d\n",
  679.                 pRasPort1->ProjResult.nbf.dwNetBiosError );
  680.     DbgPrint( "pRasPort1->ProjResult.nbf.szName=%s\n", 
  681.                     pRasPort1->ProjResult.nbf.szName );
  682.     DbgPrint( "pRasPort1->ProjResult.nbf.wszWksta=%ws\n",
  683.                     pRasPort1->ProjResult.nbf.wszWksta );
  684.       }
  685.    DbgPrint( "pRasPort1->ProjResult.ip.dwError=%d\n", 
  686.                     pRasPort1->ProjResult.ip.dwError );
  687.    if (pRasPort1->ProjResult.ip.dwError == NO_ERROR)
  688.       { 
  689.     DbgPrint( "pRasPort1->ProjResult.ip.wszAddress=%ws\n",
  690.                 pRasPort1->ProjResult.ip.wszAddress );
  691.        }
  692.     DbgPrint( "pRasPort1->ProjResult.ipx.dwError=%d\n",
  693.                 pRasPort1->ProjResult.ipx.dwError );
  694.     if (pRasPort1->ProjResult.ipx.dwError == NO_ERROR)
  695.       {
  696.          DbgPrint( "pRasPort1->ProjResult.ipx.wszAddress=%ws\n",
  697.             pRasPort1->ProjResult.ipx.wszAddress );
  698.       }
  699.     DbgPrint( "pRasPort1->ProjResult.at.dwError=%d\n",
  700.                 pRasPort1->ProjResult.at.dwError );
  701.     if (pRasPort1->ProjResult.at.dwError == NO_ERROR)
  702.       {
  703.           DbgPrint( "pRasPort1->ProjResult.at.wszAddress=%ws\n",
  704.             pRasPort1->ProjResult.at.wszAddress );
  705.        }
  706.     DbgPrint( "\ndwBytesXmited=%d\n", pRasStats->dwBytesXmited );
  707.     DbgPrint( "dwBytesRcved=%d\n", pRasStats->dwBytesRcved );
  708.     DbgPrint( "dwFramesXmited=%d\n", pRasStats->dwFramesXmited );
  709.     DbgPrint( "dwFramesRcved=%d\n", pRasStats->dwFramesRcved);
  710.     DbgPrint( "dwCrcErr=%d\n", pRasStats->dwCrcErr);
  711.     DbgPrint( "dwTimeoutErr=%d\n", pRasStats->dwTimeoutErr);
  712.     DbgPrint( "dwAlignmentErr=%d\n", pRasStats->dwAlignmentErr);
  713.     DbgPrint( "dwHardwareOverrunErr=%d\n", pRasStats->dwHardwareOverrunErr);
  714.     DbgPrint( "dwFramingErr=%d\n", pRasStats->dwFramingErr);
  715.     DbgPrint( "dwBufferOverrunErr=%d\n", pRasStats->dwBufferOverrunErr);
  716.     DbgPrint( "dwBytesXmitedUncompressed=%d\n", 
  717.                     pRasStats->dwBytesXmitedUncompressed);
  718.     DbgPrint( "dwBytesRcvedUncompressed=%d\n", 
  719.                     pRasStats->dwBytesRcvedUncompressed);
  720.     DbgPrint( "dwBytesXmitedCompressed=%d\n", 
  721.                     pRasStats->dwBytesXmitedCompressed);
  722.     DbgPrint( "dwBytesRcvedCompressed=%d\n", 
  723.                     pRasStats->dwBytesRcvedCompressed);
  724.     for (i=0; i<pRasPort1->NumMediaParms;i++)
  725.       {
  726.       DbgPrint( "pRasParams->P_Key= %s\n",pRasParams[i].P_Key);
  727.       DbgPrint( "pRasParams->P_Type= %d\n",pRasParams[i].P_Type);
  728.       if (pRasParams[i].P_Type == 1)
  729.       {
  730.       DbgPrint("pRasParams->P_Value.Length=%d\n",pRasParams[i].P_Value.String.Length);
  731.       sprintf(szBuf,"                                                                \n");
  732.       strncpy(szBuf, pRasParams[i].P_Value.String.Data, pRasParams[i].P_Value.String.Length);
  733.       DbgPrint("pRasParams->P_Value.Data= %s\n",szBuf);
  734.       }
  735.       if (pRasParams[i].P_Type == 0)
  736.      {
  737.      DbgPrint("pRasParams->P_Value.Number=%d\n", pRasParams[i].P_Value.Number);
  738.      }
  739.       DbgPrint( "pRasParams->P_Attributes= %d\n",pRasParams[i].P_Attributes);
  740.       }
  741. }
  742.  
  743.  
  744.  
  745. VOID File_Print(RAS_PORT_1 *            pRasPort1,
  746.     RAS_PORT_STATISTICS *   pRasStats,
  747.     RAS_PARAMETERS *        pRasParams
  748. )
  749. {
  750. char *Media_Name[] = {"MEDIA_UNKNOWN", "MEDIA_SERIAL",
  751.           "MEDIA_RAS10_SERIAL", "MEDIA_ISDN"};
  752. char *Flag_Name[] = {"USER_AUTHENTICATED", "MESSENGER_PRESENT",
  753.          "PPP_CLIENT","GATEWAY_ACTIVE","REMOTE_LISTEN","PORT_MULTILINKED"};
  754. char *Line_Condition[]={"RAS_PORT_NON_OPERATIONAL","RAS_PORT_DISCONNECTED",
  755.           "RAS_PORT_CALLING_BACK","RAS_PORT_LISTENING","RAS_PORT_AUTHENTICATING",
  756.           "RAS_PORT_AUTHENTICATED","RAS_PORT_INITIALIZING"};
  757. char *Hdw_Error[]={"RAS_MODEM_OPERATIONAL","RAS_MODEM_NOT_RESPONDING","RAS_MODEM_HARDWARE_FAILURE",
  758.           "RAS_MODEM_INCORRECT_RESPONSE","RAS_MODEM_UNKNOWN"};
  759. INT  i=0;
  760. INT temp = 0;
  761. INT temp1 =0;
  762. DWORD dwsize=0;
  763. CHAR szBuf[50];
  764. CHAR buf[120];
  765. DWORD dwBytesWritten=0;
  766.     sprintf(buf, "pRasPort1->rasport0.wszPortName=%ws\n",
  767.         pRasPort1->rasport0.wszPortName );
  768.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  769.     sprintf(buf,"pRasPort1->rasport0.wszDeviceType=%ws\n",
  770.             pRasPort1->rasport0.wszDeviceType );
  771.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  772.     sprintf(buf,"pRasPort1->rasport0.wszDeviceName=%ws\n",
  773.             pRasPort1->rasport0.wszDeviceName );
  774.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  775.     sprintf(buf, "pRasPort1->rasport0.wszMediaName=%ws\n",
  776.         pRasPort1->rasport0.wszMediaName );
  777.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  778.     sprintf(buf,"pRasPort1->rasport0.reserved=%d\n",
  779.             pRasPort1->rasport0.reserved );
  780.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  781.     sprintf(buf,"                 %s\n",Media_Name[pRasPort1->rasport0.reserved]);
  782.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  783.     sprintf(buf, "pRasPort1->rasport0.Flags=%d\n",
  784.             pRasPort1->rasport0.Flags );
  785.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  786. //printing Flags
  787.     temp1 = 1;
  788.     for (i=0; i <= Number_Of_Flags; i++)
  789.      {
  790.      temp = (pRasPort1->rasport0.Flags & temp1);
  791.      if (temp)
  792.          {
  793.            sprintf(buf,"Flag       %s   \n",Flag_Name[i]);
  794.              WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  795.          }
  796.       temp1 = temp1*2;
  797.      }
  798.     sprintf(buf, "pRasPort1->rasport0.wszUserName=%ws\n",
  799.             pRasPort1->rasport0.wszUserName );
  800.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  801.     sprintf(buf, "pRasPort1->rasport0.wszComputer=%ws\n",
  802.             pRasPort1->rasport0.wszComputer );
  803.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  804.     sprintf(buf, "pRasPort1->rasport0.dwStartSessionTime;=%d\n",
  805.             pRasPort1->rasport0.dwStartSessionTime );
  806.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  807.     sprintf(buf,"Formatted session start time/date :  %s\n",ctime(&pRasPort1->rasport0.dwStartSessionTime));
  808.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  809.     sprintf(buf, "pRasPort1->rasport0.wszLogonDomain=%ws\n",
  810.             pRasPort1->rasport0.wszLogonDomain );
  811.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  812.     sprintf(buf, "pRasPort1->rasport0.fAdvancedServer=%d\n",
  813.             pRasPort1->rasport0.fAdvancedServer );
  814.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  815.     sprintf(buf, "pRasPort1->LineCondition=%d\n", pRasPort1->LineCondition );
  816.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  817.     sprintf(buf,"                     %s\n",Line_Condition[pRasPort1->LineCondition-1]);
  818.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  819.     sprintf(buf, "pRasPort1->HardwareCondition=%d\n",pRasPort1->HardwareCondition);
  820.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  821.     sprintf(buf,"                     %s\n",Hdw_Error[pRasPort1->HardwareCondition-1]);
  822.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  823.     sprintf(buf, "pRasPort1->LineSpeed=%d   bits/sec\n",pRasPort1->LineSpeed);
  824.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  825.     sprintf(buf, "pRasPort1->NumStatistics=%d\n",pRasPort1->NumStatistics);
  826.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  827.     sprintf(buf, "pRasPort1->NumMediaParms=%d\n",pRasPort1->NumMediaParms);
  828.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  829.     sprintf(buf, "pRasPort1->SizeMediaParms=%d\n",pRasPort1->SizeMediaParms);
  830.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  831.     sprintf(buf, "\npRasPort1->ProjResult.nbf.dwError=%d\n",
  832.                     pRasPort1->ProjResult.nbf.dwError );
  833.     if (pRasPort1->ProjResult.nbf.dwError == NO_ERROR)
  834.        {
  835.     sprintf(buf, "pRasPort1->ProjResult.nbf.dwNetBiosError=%d\n",
  836.                 pRasPort1->ProjResult.nbf.dwNetBiosError );
  837.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  838.     sprintf(buf, "pRasPort1->ProjResult.nbf.szName=%s\n", 
  839.                     pRasPort1->ProjResult.nbf.szName );
  840.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  841.     sprintf(buf, "pRasPort1->ProjResult.nbf.wszWksta=%ws\n",
  842.                     pRasPort1->ProjResult.nbf.wszWksta );
  843.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  844.       }
  845.    sprintf(buf, "pRasPort1->ProjResult.ip.dwError=%d\n", 
  846.                     pRasPort1->ProjResult.ip.dwError );
  847.    WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  848.    if (pRasPort1->ProjResult.ip.dwError == NO_ERROR)
  849.       { 
  850.     sprintf(buf, "pRasPort1->ProjResult.ip.wszAddress=%ws\n",
  851.                 pRasPort1->ProjResult.ip.wszAddress );
  852.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  853.        }
  854.     sprintf(buf, "pRasPort1->ProjResult.ipx.dwError=%d\n",
  855.                 pRasPort1->ProjResult.ipx.dwError );
  856.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  857.     if (pRasPort1->ProjResult.ipx.dwError == NO_ERROR)
  858.       {
  859.          sprintf(buf, "pRasPort1->ProjResult.ipx.wszAddress=%ws\n",
  860.             pRasPort1->ProjResult.ipx.wszAddress );
  861.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  862.       }
  863.     sprintf(buf, "pRasPort1->ProjResult.at.dwError=%d\n",
  864.                 pRasPort1->ProjResult.at.dwError );
  865.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  866.     if (pRasPort1->ProjResult.at.dwError == NO_ERROR)
  867.       {
  868.           sprintf(buf, "pRasPort1->ProjResult.at.wszAddress=%ws\n",
  869.             pRasPort1->ProjResult.at.wszAddress );
  870.        }
  871.     sprintf(buf, "\ndwBytesXmited=%d\n", pRasStats->dwBytesXmited );
  872.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  873.     sprintf(buf, "dwBytesRcved=%d\n", pRasStats->dwBytesRcved );
  874.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  875.     sprintf(buf, "dwFramesXmited=%d\n", pRasStats->dwFramesXmited );
  876.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  877.     sprintf(buf, "dwFramesRcved=%d\n", pRasStats->dwFramesRcved);
  878.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  879.     sprintf(buf, "dwCrcErr=%d\n", pRasStats->dwCrcErr);
  880.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  881.     sprintf(buf, "dwTimeoutErr=%d\n", pRasStats->dwTimeoutErr);
  882.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  883.     sprintf(buf, "dwAlignmentErr=%d\n", pRasStats->dwAlignmentErr);
  884.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  885.     sprintf(buf, "dwHardwareOverrunErr=%d\n", pRasStats->dwHardwareOverrunErr);
  886.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  887.     sprintf(buf, "dwFramingErr=%d\n", pRasStats->dwFramingErr);
  888.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  889.     sprintf(buf, "dwBufferOverrunErr=%d\n", pRasStats->dwBufferOverrunErr);
  890.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  891.     sprintf(buf, "dwBytesXmitedUncompressed=%d\n", 
  892.                     pRasStats->dwBytesXmitedUncompressed);
  893.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  894.     sprintf(buf, "dwBytesRcvedUncompressed=%d\n", 
  895.                     pRasStats->dwBytesRcvedUncompressed);
  896.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  897.     sprintf(buf, "dwBytesXmitedCompressed=%d\n", 
  898.                     pRasStats->dwBytesXmitedCompressed);
  899.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  900.     sprintf(buf, "dwBytesRcvedCompressed=%d\n", 
  901.                     pRasStats->dwBytesRcvedCompressed);
  902.     WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  903.     for (i=0; i<pRasPort1->NumMediaParms;i++)
  904.       {
  905.       sprintf(buf, "pRasParams->P_Key= %s\n",pRasParams[i].P_Key);
  906.       WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  907.       sprintf(buf, "pRasParams->P_Type= %d\n",pRasParams[i].P_Type);
  908.       WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  909.       if (pRasParams[i].P_Type == 1)
  910.       {
  911.       sprintf(buf,"pRasParams->P_Value.Length=%d\n",pRasParams[i].P_Value.String.Length);
  912.         WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  913.       sprintf(szBuf,"                                                                \n");
  914.       strncpy(szBuf, pRasParams[i].P_Value.String.Data, pRasParams[i].P_Value.String.Length);
  915.       sprintf(buf,"pRasParams->P_Value.Data= %s\n",szBuf);
  916.            WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  917.       }
  918.       if (pRasParams[i].P_Type == 0)
  919.      {
  920.      sprintf(buf,"pRasParams->P_Value.Number=%d\n", pRasParams[i].P_Value.Number);
  921.           WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  922.      }
  923.       sprintf(buf, "pRasParams->P_Attributes= %d\n",pRasParams[i].P_Attributes);
  924.       WriteFile(ConDisFile, (LPSTR)buf, strlen(buf), &dwBytesWritten, NULL);
  925.       }
  926. }
  927.