home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / rassapi.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  11KB  |  393 lines

  1. /******************************************************************\
  2. *                     Microsoft Windows NT                         *
  3. *               Copyright(c) Microsoft Corp., 1992-1997            *
  4. \******************************************************************/
  5.  
  6. /*++
  7.  
  8. Module Name:
  9.  
  10.     RASSAPI.H
  11.  
  12. Description:
  13.  
  14.     This file contains the RASADMIN structures, defines and
  15.     function prototypes for the following APIs and they can
  16.     be imported from RASSAPI.DLL:
  17.  
  18.      RasAdminServerGetInfo
  19.      RasAdminGetUserAccountServer
  20.      RasAdminUserSetInfo
  21.      RasAdminUserGetInfo
  22.      RasAdminPortEnum
  23.      RasAdminPortGetInfo
  24.      RasAdminPortClearStatistics
  25.      RasAdminPortDisconnect
  26.      RasAdminFreeBuffer
  27.  
  28. Note:
  29.  
  30.     This header file and the sources containing the APIs will work
  31.     only with UNICODE strings.
  32.  
  33. --*/
  34.  
  35.  
  36. #ifndef _RASSAPI_H_
  37. #define _RASSAPI_H_
  38.  
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42.  
  43. #ifndef UNLEN
  44. #include <lmcons.h>
  45. #endif
  46.  
  47. #define RASSAPI_MAX_PHONENUMBER_SIZE     128
  48. #define RASSAPI_MAX_MEDIA_NAME             16
  49. #define RASSAPI_MAX_PORT_NAME                16
  50. #define RASSAPI_MAX_DEVICE_NAME          128
  51. #define RASSAPI_MAX_DEVICETYPE_NAME       16
  52. #define RASSAPI_MAX_PARAM_KEY_SIZE        32
  53.  
  54. // Bits indicating user's Remote Access privileges and mask to isolate
  55. // call back privilege.
  56. //
  57. // Note: Bit 0 MUST represent NoCallback due to a quirk of the "userparms"
  58. //       storage method.  When a new LAN Manager user is created, bit 0 of the
  59. //       userparms field is set to 1 and all other bits are 0.  These bits are
  60. //       arranged so this "no Dial-In info" state maps to the "default Dial-In
  61. //       privilege" state.
  62.  
  63. #define RASPRIV_NoCallback        0x01
  64. #define RASPRIV_AdminSetCallback  0x02
  65. #define RASPRIV_CallerSetCallback 0x04
  66. #define RASPRIV_DialinPrivilege   0x08
  67.  
  68. #define RASPRIV_CallbackType (RASPRIV_AdminSetCallback \
  69.                               | RASPRIV_CallerSetCallback \
  70.                               | RASPRIV_NoCallback)
  71.  
  72. //
  73. // Modem condition codes
  74. //
  75. #define    RAS_MODEM_OPERATIONAL         1    // No modem errors.
  76. #define    RAS_MODEM_NOT_RESPONDING     2
  77. #define    RAS_MODEM_HARDWARE_FAILURE   3
  78. #define    RAS_MODEM_INCORRECT_RESPONSE 4
  79. #define    RAS_MODEM_UNKNOWN             5
  80. //
  81. // Line condition codes
  82. //
  83. #define    RAS_PORT_NON_OPERATIONAL 1
  84. #define    RAS_PORT_DISCONNECTED     2
  85. #define    RAS_PORT_CALLING_BACK    3
  86. #define    RAS_PORT_LISTENING        4
  87. #define    RAS_PORT_AUTHENTICATING  5
  88. #define    RAS_PORT_AUTHENTICATED     6
  89. #define    RAS_PORT_INITIALIZING     7
  90.  
  91. // The following three structures are same as the ones
  92. // defined in rasman.h and have been renamed to prevent
  93. // redefinitions when both header files are included.
  94.  
  95. enum RAS_PARAMS_FORMAT {
  96.  
  97.     ParamNumber        = 0,
  98.  
  99.     ParamString        = 1
  100.  
  101. } ;
  102. typedef enum RAS_PARAMS_FORMAT    RAS_PARAMS_FORMAT ;
  103.  
  104. union RAS_PARAMS_VALUE {
  105.  
  106.     DWORD    Number ;
  107.  
  108.     struct    {
  109.         DWORD    Length ;
  110.         PCHAR    Data ;
  111.         } String ;
  112. } ;
  113. typedef union RAS_PARAMS_VALUE    RAS_PARAMS_VALUE ;
  114.  
  115. struct RAS_PARAMETERS {
  116.  
  117.     CHAR    P_Key    [RASSAPI_MAX_PARAM_KEY_SIZE] ;
  118.  
  119.     RAS_PARAMS_FORMAT    P_Type ;
  120.  
  121.     BYTE    P_Attributes ;
  122.  
  123.     RAS_PARAMS_VALUE    P_Value ;
  124.  
  125. } ;
  126. typedef struct RAS_PARAMETERS    RAS_PARAMETERS ;
  127.  
  128. // structures used by the RASADMIN APIs
  129.  
  130. typedef struct _RAS_USER_0
  131. {
  132.     BYTE bfPrivilege;
  133.     WCHAR szPhoneNumber[ RASSAPI_MAX_PHONENUMBER_SIZE + 1];
  134. } RAS_USER_0, *PRAS_USER_0;
  135.  
  136. typedef struct _RAS_PORT_0
  137. {
  138.     WCHAR wszPortName[RASSAPI_MAX_PORT_NAME];
  139.     WCHAR wszDeviceType[RASSAPI_MAX_DEVICETYPE_NAME];
  140.     WCHAR wszDeviceName[RASSAPI_MAX_DEVICE_NAME];
  141.     WCHAR wszMediaName[RASSAPI_MAX_MEDIA_NAME];
  142.     DWORD reserved;
  143.     DWORD Flags;
  144.     WCHAR wszUserName[UNLEN + 1];
  145.     WCHAR wszComputer[NETBIOS_NAME_LEN];
  146.     DWORD dwStartSessionTime;          // seconds from 1/1/1970
  147.     WCHAR wszLogonDomain[DNLEN + 1];
  148.     BOOL fAdvancedServer;
  149. } RAS_PORT_0, *PRAS_PORT_0;
  150.  
  151.  
  152. // Possible values for MediaId
  153.  
  154. #define MEDIA_UNKNOWN       0
  155. #define MEDIA_SERIAL        1
  156. #define MEDIA_RAS10_SERIAL  2
  157. #define MEDIA_X25           3
  158. #define MEDIA_ISDN          4
  159.  
  160.  
  161. // Possible bits set in Flags field
  162.  
  163. #define USER_AUTHENTICATED    0x0001
  164. #define MESSENGER_PRESENT     0x0002
  165. #define PPP_CLIENT            0x0004
  166. #define GATEWAY_ACTIVE        0x0008
  167. #define REMOTE_LISTEN         0x0010
  168. #define PORT_MULTILINKED      0x0020
  169.  
  170.  
  171. typedef ULONG IPADDR;
  172.  
  173. // The following PPP structures are same as the ones
  174. // defined in rasppp.h and have been renamed to prevent
  175. // redefinitions when both header files are included
  176. // in a module.
  177.  
  178. /* Maximum length of address string, e.g. "255.255.255.255" for IP.
  179. */
  180. #define RAS_IPADDRESSLEN  15
  181. #define RAS_IPXADDRESSLEN 22
  182. #define RAS_ATADDRESSLEN  32
  183.  
  184. typedef struct _RAS_PPP_NBFCP_RESULT
  185. {
  186.     DWORD dwError;
  187.     DWORD dwNetBiosError;
  188.     CHAR  szName[ NETBIOS_NAME_LEN + 1 ];
  189.     WCHAR wszWksta[ NETBIOS_NAME_LEN + 1 ];
  190. } RAS_PPP_NBFCP_RESULT;
  191.  
  192. typedef struct _RAS_PPP_IPCP_RESULT
  193. {
  194.     DWORD dwError;
  195.     WCHAR wszAddress[ RAS_IPADDRESSLEN + 1 ];
  196. } RAS_PPP_IPCP_RESULT;
  197.  
  198. typedef struct _RAS_PPP_IPXCP_RESULT
  199. {
  200.     DWORD dwError;
  201.     WCHAR wszAddress[ RAS_IPXADDRESSLEN + 1 ];
  202. } RAS_PPP_IPXCP_RESULT;
  203.  
  204. typedef struct _RAS_PPP_ATCP_RESULT
  205. {
  206.     DWORD dwError;
  207.     WCHAR wszAddress[ RAS_ATADDRESSLEN + 1 ];
  208. } RAS_PPP_ATCP_RESULT;
  209.  
  210. typedef struct _RAS_PPP_PROJECTION_RESULT
  211. {
  212.     RAS_PPP_NBFCP_RESULT nbf;
  213.     RAS_PPP_IPCP_RESULT  ip;
  214.     RAS_PPP_IPXCP_RESULT ipx;
  215.     RAS_PPP_ATCP_RESULT  at;
  216. } RAS_PPP_PROJECTION_RESULT;
  217.  
  218. typedef struct _RAS_PORT_1
  219. {
  220.     RAS_PORT_0                 rasport0;
  221.     DWORD                      LineCondition;
  222.     DWORD                      HardwareCondition;
  223.     DWORD                      LineSpeed;        // in bits/second
  224.     WORD                       NumStatistics;
  225.     WORD                       NumMediaParms;
  226.     DWORD                      SizeMediaParms;
  227.     RAS_PPP_PROJECTION_RESULT  ProjResult;
  228. } RAS_PORT_1, *PRAS_PORT_1;
  229.  
  230. typedef struct _RAS_PORT_STATISTICS
  231. {
  232.     // The connection statistics are followed by port statistics
  233.     // A connection is across multiple ports.
  234.     DWORD   dwBytesXmited;
  235.     DWORD   dwBytesRcved;
  236.     DWORD   dwFramesXmited;
  237.     DWORD   dwFramesRcved;
  238.     DWORD   dwCrcErr;
  239.     DWORD   dwTimeoutErr;
  240.     DWORD   dwAlignmentErr;
  241.     DWORD   dwHardwareOverrunErr;
  242.     DWORD   dwFramingErr;
  243.     DWORD   dwBufferOverrunErr;
  244.     DWORD   dwBytesXmitedUncompressed;
  245.     DWORD   dwBytesRcvedUncompressed;
  246.     DWORD   dwBytesXmitedCompressed;
  247.     DWORD   dwBytesRcvedCompressed;
  248.  
  249.     // the following are the port statistics
  250.     DWORD   dwPortBytesXmited;
  251.     DWORD   dwPortBytesRcved;
  252.     DWORD   dwPortFramesXmited;
  253.     DWORD   dwPortFramesRcved;
  254.     DWORD   dwPortCrcErr;
  255.     DWORD   dwPortTimeoutErr;
  256.     DWORD   dwPortAlignmentErr;
  257.     DWORD   dwPortHardwareOverrunErr;
  258.     DWORD   dwPortFramingErr;
  259.     DWORD   dwPortBufferOverrunErr;
  260.     DWORD   dwPortBytesXmitedUncompressed;
  261.     DWORD   dwPortBytesRcvedUncompressed;
  262.     DWORD   dwPortBytesXmitedCompressed;
  263.     DWORD   dwPortBytesRcvedCompressed;
  264.  
  265. } RAS_PORT_STATISTICS, *PRAS_PORT_STATISTICS;
  266.  
  267. //
  268. // Server version numbers
  269. //
  270. #define RASDOWNLEVEL       10    // identifies a LM RAS 1.0 server
  271. #define RASADMIN_35        35    // Identifies a NT RAS 3.5 server or client
  272. #define RASADMIN_CURRENT   40    // Identifies a NT RAS 4.0 server or client
  273.  
  274.  
  275. typedef struct _RAS_SERVER_0
  276. {
  277.     WORD TotalPorts;             // Total ports configured on the server
  278.     WORD PortsInUse;             // Ports currently in use by remote clients
  279.     DWORD RasVersion;            // version of RAS server
  280. } RAS_SERVER_0, *PRAS_SERVER_0;
  281.  
  282.  
  283. //
  284. // function prototypes
  285. //
  286.  
  287. DWORD APIENTRY RasAdminServerGetInfo(
  288.     IN const WCHAR *  lpszServer,
  289.     OUT PRAS_SERVER_0 pRasServer0
  290.     );
  291.  
  292. DWORD APIENTRY RasAdminGetUserAccountServer(
  293.     IN const WCHAR * lpszDomain,
  294.     IN const WCHAR * lpszServer,
  295.     OUT LPWSTR       lpszUserAccountServer
  296.     );
  297.  
  298. DWORD APIENTRY RasAdminUserGetInfo(
  299.     IN const WCHAR   * lpszUserAccountServer,
  300.     IN const WCHAR   * lpszUser,
  301.     OUT PRAS_USER_0    pRasUser0
  302.     );
  303.  
  304. DWORD APIENTRY RasAdminUserSetInfo(
  305.     IN const WCHAR       * lpszUserAccountServer,
  306.     IN const WCHAR       * lpszUser,
  307.     IN const PRAS_USER_0   pRasUser0
  308.     );
  309.  
  310. DWORD APIENTRY RasAdminPortEnum(
  311.     IN  const WCHAR * lpszServer,
  312.     OUT PRAS_PORT_0 * ppRasPort0,
  313.     OUT WORD *        pcEntriesRead
  314.     );
  315.  
  316. DWORD APIENTRY RasAdminPortGetInfo(
  317.     IN const WCHAR *            lpszServer,
  318.     IN const WCHAR *            lpszPort,
  319.     OUT RAS_PORT_1 *            pRasPort1,
  320.     OUT RAS_PORT_STATISTICS *   pRasStats,
  321.     OUT RAS_PARAMETERS **       ppRasParams
  322.     );
  323.  
  324. DWORD APIENTRY RasAdminPortClearStatistics(
  325.     IN const WCHAR * lpszServer,
  326.     IN const WCHAR * lpszPort
  327.     );
  328.  
  329. DWORD APIENTRY RasAdminPortDisconnect(
  330.     IN const WCHAR * lpszServer,
  331.     IN const WCHAR * lpszPort
  332.     );
  333.  
  334. DWORD APIENTRY RasAdminFreeBuffer(
  335.     PVOID Pointer
  336.     );
  337.  
  338. DWORD APIENTRY RasAdminGetErrorString(
  339.     IN  UINT    ResourceId,
  340.     OUT WCHAR * lpszString,
  341.     IN  DWORD   InBufSize );
  342.  
  343. BOOL APIENTRY RasAdminAcceptNewConnection (
  344.     IN         RAS_PORT_1 *              pRasPort1,
  345.     IN      RAS_PORT_STATISTICS *   pRasStats,
  346.     IN      RAS_PARAMETERS *        pRasParams
  347.     );
  348.  
  349. VOID APIENTRY RasAdminConnectionHangupNotification (
  350.     IN         RAS_PORT_1 *              pRasPort1,
  351.     IN      RAS_PORT_STATISTICS *   pRasStats,
  352.     IN      RAS_PARAMETERS *        pRasParams
  353.     );
  354.  
  355. DWORD APIENTRY RasAdminGetIpAddressForUser (
  356.     IN         WCHAR  *        lpszUserName,
  357.     IN         WCHAR  *        lpszPortName,
  358.     IN OUT     IPADDR *       pipAddress,
  359.     OUT        BOOL     *    bNotifyRelease
  360.     );
  361.  
  362. VOID APIENTRY RasAdminReleaseIpAddress (
  363.     IN         WCHAR  *        lpszUserName,
  364.     IN         WCHAR  *        lpszPortName,
  365.     IN         IPADDR *       pipAddress
  366.     );
  367.  
  368. // The following two APIs are used to get/set
  369. // RAS user permissions in to a UsrParms buffer
  370. // obtained by a call to NetUserGetInfo.
  371. //
  372. // Note that RasAdminUserGetInfo and RasAdminUserSetInfo
  373. // are the APIs you should be using for getting and
  374. // setting RAS permissions.
  375.  
  376. DWORD APIENTRY RasAdminGetUserParms(
  377.     IN  WCHAR          * lpszParms,
  378.     OUT PRAS_USER_0      pRasUser0
  379.     );
  380.  
  381. DWORD APIENTRY RasAdminSetUserParms(
  382.     IN OUT   WCHAR    * lpszParms,
  383.     IN DWORD          cchNewParms,
  384.     IN PRAS_USER_0    pRasUser0
  385.     );
  386.  
  387. #ifdef __cplusplus
  388. }
  389. #endif
  390.  
  391. #endif // _RASSAPI_H_
  392.  
  393.