Leaked source code of windows server 2003
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.

153 lines
4.7 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. SessInfo.c
  5. Abstract:
  6. This file contains NetpSessionStructureInfo().
  7. Author:
  8. John Rogers (JohnRo) 18-Oct-1991
  9. Environment:
  10. Portable to any flat, 32-bit environment. (Uses Win32 typedefs.)
  11. Requires ANSI C extensions: slash-slash comments, long external names.
  12. Revision History:
  13. 18-Oct-1991 JohnRo
  14. Implement downlevel NetSession APIs.
  15. 18-Oct-1991 JohnRo
  16. Quiet debug output. sesiX_cname is not a UNC name.
  17. 20-Nov-1991 JohnRo
  18. Removed NT dependencies to reduce recompiles.
  19. --*/
  20. // These must be included first:
  21. #include <windef.h> // IN, DWORD, etc.
  22. #include <lmcons.h> // LM20_ equates, NET_API_STATUS, etc.
  23. #include <rap.h> // LPDESC, needed by <strucinf.h>.
  24. // These may be included in any order:
  25. #include <debuglib.h> // IF_DEBUG().
  26. #include <lmerr.h> // ERROR_ and NERR_ equates.
  27. #include <lmshare.h> // SESSION_INFO_2, etc.
  28. #include <netlib.h> // NetpSetOptionalArg().
  29. #include <netdebug.h> // NetpAssert().
  30. #include <remdef.h> // REM16_, REM32_, REMSmb_ equates.
  31. #include <strucinf.h> // My prototype.
  32. // Level 0.
  33. #define MAX_SESSION_0_STRING_LENGTH \
  34. (MAX_PATH+1)
  35. #define MAX_SESSION_0_STRING_SIZE \
  36. (MAX_SESSION_0_STRING_LENGTH * sizeof(TCHAR))
  37. // Level 1 is superset of 0.
  38. #define MAX_SESSION_1_STRING_LENGTH \
  39. (MAX_SESSION_0_STRING_LENGTH + LM20_UNLEN+1)
  40. #define MAX_SESSION_1_STRING_SIZE \
  41. (MAX_SESSION_1_STRING_LENGTH * sizeof(TCHAR))
  42. // Level 2 is superset of 1.
  43. #define MAX_SESSION_2_STRING_LENGTH \
  44. (MAX_SESSION_1_STRING_LENGTH + CLTYPE_LEN+1)
  45. #define MAX_SESSION_2_STRING_SIZE \
  46. (MAX_SESSION_2_STRING_LENGTH * sizeof(TCHAR))
  47. // Level 10 is unique.
  48. #define MAX_SESSION_10_STRING_LENGTH \
  49. (MAX_PATH+1 + LM20_UNLEN+1)
  50. #define MAX_SESSION_10_STRING_SIZE \
  51. (MAX_SESSION_10_STRING_LENGTH * sizeof(TCHAR))
  52. NET_API_STATUS
  53. NetpSessionStructureInfo (
  54. IN DWORD Level,
  55. IN DWORD ParmNum, // Use PARMNUM_ALL if not applicable.
  56. IN BOOL Native, // Should sizes be native or RAP?
  57. OUT LPDESC * DataDesc16 OPTIONAL,
  58. OUT LPDESC * DataDesc32 OPTIONAL,
  59. OUT LPDESC * DataDescSmb OPTIONAL,
  60. OUT LPDWORD MaxSize OPTIONAL,
  61. OUT LPDWORD FixedSize OPTIONAL,
  62. OUT LPDWORD StringSize OPTIONAL
  63. )
  64. {
  65. DBG_UNREFERENCED_PARAMETER(ParmNum);
  66. NetpAssert( Native );
  67. //
  68. // Decide what to do based on the info level.
  69. //
  70. switch (Level) {
  71. #define SetSizes(fixed,variable) \
  72. { \
  73. NetpSetOptionalArg( MaxSize, (fixed) + (variable) ); \
  74. NetpSetOptionalArg( FixedSize, (fixed) ); \
  75. NetpSetOptionalArg( StringSize, (variable) ); \
  76. }
  77. case 0 :
  78. NetpSetOptionalArg( DataDesc16, REM16_session_info_0 );
  79. NetpSetOptionalArg( DataDesc32, REM32_session_info_0 );
  80. NetpSetOptionalArg( DataDescSmb, REMSmb_session_info_0 );
  81. SetSizes( sizeof(SESSION_INFO_0), MAX_SESSION_0_STRING_SIZE );
  82. break;
  83. case 1 :
  84. NetpSetOptionalArg( DataDesc16, REM16_session_info_1 );
  85. NetpSetOptionalArg( DataDesc32, REM32_session_info_1 );
  86. NetpSetOptionalArg( DataDescSmb, REMSmb_session_info_1 );
  87. SetSizes( sizeof(SESSION_INFO_1), MAX_SESSION_1_STRING_SIZE );
  88. break;
  89. case 2 :
  90. NetpSetOptionalArg( DataDesc16, REM16_session_info_2 );
  91. NetpSetOptionalArg( DataDesc32, REM32_session_info_2 );
  92. NetpSetOptionalArg( DataDescSmb, REMSmb_session_info_2 );
  93. SetSizes( sizeof(SESSION_INFO_2), MAX_SESSION_2_STRING_SIZE );
  94. break;
  95. case 10 :
  96. NetpSetOptionalArg( DataDesc16, REM16_session_info_10 );
  97. NetpSetOptionalArg( DataDesc32, REM32_session_info_10 );
  98. NetpSetOptionalArg( DataDescSmb, REMSmb_session_info_10 );
  99. SetSizes( sizeof(SESSION_INFO_10), MAX_SESSION_10_STRING_SIZE );
  100. break;
  101. default :
  102. return (ERROR_INVALID_LEVEL);
  103. }
  104. IF_DEBUG(STRUCINF) {
  105. if (DataDesc16) {
  106. NetpKdPrint(( "NetpSessionStructureInfo: desc 16 is " FORMAT_LPDESC
  107. ".\n", *DataDesc16 ));
  108. }
  109. if (DataDesc32) {
  110. NetpKdPrint(( "NetpSessionStructureInfo: desc 32 is " FORMAT_LPDESC
  111. ".\n", *DataDesc32 ));
  112. }
  113. if (DataDescSmb) {
  114. NetpKdPrint(( "NetpSessionStructureInfo: desc Smb is " FORMAT_LPDESC
  115. ".\n", *DataDescSmb ));
  116. }
  117. }
  118. return (NERR_Success);
  119. } // NetpSessionStructureInfo