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.

194 lines
10 KiB

  1. //================================================================================
  2. // Copyright (C) Microsoft Corporation 1997.
  3. // Author: RameshV
  4. // Date: 09-Sep-97 06:20
  5. // Description: Manages the class-id and options information
  6. //================================================================================
  7. #ifndef OPTIONS_H
  8. #define OPTIONS_H
  9. #define MAX_DATA_LEN 255 // atmost 255 bytes for an option
  10. typedef struct _DHCP_CLASSES { // common pool of class names
  11. LIST_ENTRY ClassList; // global list of classes
  12. LPBYTE ClassName; // name of the class
  13. DWORD ClassLen; // # of bytes in class name
  14. DWORD RefCount; // # of references to this
  15. } DHCP_CLASSES, *LPDHCP_CLASSES, *PDHCP_CLASSES;
  16. typedef struct _DHCP_OPTION { // list of options
  17. LIST_ENTRY OptionList; // the fwd/back ptrs
  18. DWORD OptionId; // the option value
  19. BOOL IsVendor; // is this vendor specific
  20. LPBYTE ClassName; // the class of this option
  21. DWORD ClassLen; // the length of above option
  22. time_t ExpiryTime; // when this option expires
  23. LPBYTE Data; // the data value for this option
  24. DWORD DataLen; // the # of bytes of above
  25. DWORD ServerId; // the server from which the option came
  26. OPTION_VERSION OptionVer; // specifies the format of the options
  27. } DHCP_OPTION , *LPDHCP_OPTION , *PDHCP_OPTION ;
  28. typedef struct _DHCP_OPTION_DEF {
  29. LIST_ENTRY OptionDefList; // list of option definitions
  30. DWORD OptionId; // the option id
  31. BOOL IsVendor; // is this vendor specific?
  32. LPBYTE ClassName; // the class this belongs to
  33. DWORD ClassLen; // the size of above in bytes
  34. LPWSTR RegSendLoc; // where is the info about sending this out
  35. LPWSTR RegSaveLoc; // where is this option going to be stored?
  36. DWORD RegValueType; // as what value should this be stored?
  37. } DHCP_OPTION_DEF, *LPDHCP_OPTION_DEF, *PDHCP_OPTION_DEF;
  38. //================================================================================
  39. // exported functions classes
  40. //================================================================================
  41. //--------------------------------------------------------------------------------
  42. // In all of the following functions, ClassesList is unprotected within the fn.
  43. // Caller has to take a lock on it.
  44. //--------------------------------------------------------------------------------
  45. LPBYTE // data bytes, or NULL (no mem)
  46. DhcpAddClass( // add a new class
  47. IN OUT PLIST_ENTRY ClassesList, // list to add to
  48. IN LPBYTE Data, // input class name
  49. IN DWORD Len // # of bytes of above
  50. ); // Add the new class into the list or bump up ref count if already there
  51. DWORD // status (FILE_NOT_FOUND => no such class)
  52. DhcpDelClass( // de-refernce a class
  53. IN OUT PLIST_ENTRY ClassesList, // the list to delete off
  54. IN LPBYTE Data, // the data ptr
  55. IN DWORD Len // the # of bytes of above
  56. ); // decrease refcount in the list and if becomes zero, free the struct
  57. VOID // always succeeds
  58. DhcpFreeAllClasses( // free each elt of the list
  59. IN OUT PLIST_ENTRY ClassesList // input list of classes
  60. ); // free every class in the list
  61. //--------------------------------------------------------------------------------
  62. // In all the following functions, OptionsList is unprotected within the fn.
  63. // Caller has to take a lock on it.
  64. //--------------------------------------------------------------------------------
  65. PDHCP_OPTION // the reqd structure or NULL
  66. DhcpFindOption( // find a specific option
  67. IN OUT PLIST_ENTRY OptionsList, // the list of options to search
  68. IN DWORD OptionId, // the option id to search for
  69. IN BOOL IsVendor, // is it vendor specific?
  70. IN LPBYTE ClassName, // is there a class associated?
  71. IN DWORD ClassLen, // # of bytes of above parameter
  72. IN DWORD ServerId // match serverid also if not 0
  73. ); // search for the required option in the list, return NULL if not found
  74. DWORD // status or ERROR_FILE_NOT_FOUND
  75. DhcpDelOption( // remove a particular option
  76. IN PDHCP_OPTION Option2Delete // delete this option
  77. ); // delete an existing option in the list, and free up space used
  78. DWORD // status
  79. DhcpAddOption( // add a new option
  80. IN OUT PLIST_ENTRY OptionsList, // list to add to
  81. IN DWORD OptionId, // option id to add
  82. IN BOOL IsVendor, // is it vendor specific?
  83. IN LPBYTE ClassName, // what is the class?
  84. IN DWORD ClassLen, // size of above in bytes
  85. IN DWORD ServerId, // server which gave this option
  86. IN LPBYTE Data, // data for this option
  87. IN DWORD DataLen, // # of bytes of above
  88. IN time_t ExpiryTime // when the option expires
  89. ); // replace or add new option to the list. fail if not enough memory
  90. PDHCP_OPTION // pointer to the duplicated option
  91. DhcpDuplicateOption( // creates a copy of the source option
  92. IN PDHCP_OPTION SrcOption // source option
  93. );
  94. VOID // always succeeds
  95. DhcpFreeAllOptions( // frees all the options
  96. IN OUT PLIST_ENTRY OptionsList // input list of options
  97. ); // free every option in the list
  98. time_t // 0 || time for next expiry (absolute)
  99. DhcpGetExpiredOptions( // delete all expired options
  100. IN OUT PLIST_ENTRY OptionsList, // list to search frm
  101. OUT PLIST_ENTRY ExpiredOptions // o/p list of expired options
  102. ); // move expired options between lists and return timer. 0 => switch off timer.
  103. //--------------------------------------------------------------------------------
  104. // In all the following functions, OptionsDefList is unprotected. Caller has
  105. // to take a lock on it.
  106. //--------------------------------------------------------------------------------
  107. DWORD // status
  108. DhcpAddOptionDef( // add a new option definition
  109. IN OUT PLIST_ENTRY OptionDefList, // input list of options to add to
  110. IN DWORD OptionId, // option to add
  111. IN BOOL IsVendor, // is it vendor specific
  112. IN LPBYTE ClassName, // name of class it belongs to
  113. IN DWORD ClassLen, // the size of above in bytes
  114. IN LPWSTR RegSendLoc, // where to get info about sending this out
  115. IN LPWSTR RegSaveLoc, // where to get info about saving this
  116. IN DWORD ValueType // what is the type when saving it?
  117. );
  118. PDHCP_OPTION_DEF // NULL, or requested option def
  119. DhcpFindOptionDef( // search for a particular option
  120. IN PLIST_ENTRY OptionDefList, // list to search in
  121. IN DWORD OptionId, // the option id to search for
  122. IN BOOL IsVendor, // is it vendor specific
  123. IN LPBYTE ClassName, // the class, if one exists
  124. IN DWORD ClassLen // # of bytes of class name
  125. );
  126. DWORD // status
  127. DhcpDelOptionDef( // delete a particular option def
  128. IN PLIST_ENTRY OptionDefList, // list to delete from
  129. IN DWORD OptionId, // the option id to delete
  130. IN BOOL IsVendor, // is it vendor specific
  131. IN LPBYTE ClassName, // the class, if one exists
  132. IN DWORD ClassLen // # of bytes of class name
  133. );
  134. VOID
  135. DhcpFreeAllOptionDefs( // free each element of a list
  136. IN OUT PLIST_ENTRY OptionDefList, // the list to free
  137. IN OUT PLIST_ENTRY ClassesList // classes to de-ref off
  138. );
  139. BOOL // TRUE==>found..
  140. DhcpOptionsFindDomain( // find the domain name option values
  141. IN OUT PDHCP_CONTEXT DhcpContext, // for this adapter
  142. OUT LPBYTE *Data, // fill this ptr up
  143. OUT LPDWORD DataLen
  144. );
  145. BOOL
  146. DhcpFindDwordOption(
  147. IN PDHCP_CONTEXT DhcpContext,
  148. IN ULONG OptId,
  149. IN BOOL fVendor,
  150. OUT PDWORD Result
  151. );
  152. BOOL
  153. DhcpFindByteOption(
  154. IN PDHCP_CONTEXT DhcpContext,
  155. IN ULONG OptId,
  156. IN BOOL fVendor,
  157. OUT PBYTE Result
  158. );
  159. BOOL
  160. RetreiveGatewaysList(
  161. IN PDHCP_CONTEXT DhcpContext,
  162. IN OUT ULONG *nGateways,
  163. IN OUT DHCP_IP_ADDRESS UNALIGNED **Gateways
  164. );
  165. #endif OPTIONS_H