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.

161 lines
9.4 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. BYTE 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. } DHCP_OPTION , *LPDHCP_OPTION , *PDHCP_OPTION ;
  26. typedef struct _DHCP_OPTION_DEF {
  27. LIST_ENTRY OptionDefList; // list of option definitions
  28. BYTE OptionId; // the option id
  29. BOOL IsVendor; // is this vendor specific?
  30. LPBYTE ClassName; // the class this belongs to
  31. DWORD ClassLen; // the size of above in bytes
  32. LPWSTR RegSendLoc; // where is the info about sending this out
  33. LPWSTR RegSaveLoc; // where is this option going to be stored?
  34. DWORD RegValueType; // as what value should this be stored?
  35. } DHCP_OPTION_DEF, *LPDHCP_OPTION_DEF, *PDHCP_OPTION_DEF;
  36. //================================================================================
  37. // exported functions classes
  38. //================================================================================
  39. //--------------------------------------------------------------------------------
  40. // In all of the following functions, ClassesList is unprotected within the fn.
  41. // Caller has to take a lock on it.
  42. //--------------------------------------------------------------------------------
  43. LPBYTE // data bytes, or NULL (no mem)
  44. DhcpAddClass( // add a new class
  45. IN OUT PLIST_ENTRY ClassesList, // list to add to
  46. IN LPBYTE Data, // input class name
  47. IN DWORD Len // # of bytes of above
  48. ); // Add the new class into the list or bump up ref count if already there
  49. DWORD // status (FILE_NOT_FOUND => no such class)
  50. DhcpDelClass( // de-refernce a class
  51. IN OUT PLIST_ENTRY ClassesList, // the list to delete off
  52. IN LPBYTE Data, // the data ptr
  53. IN DWORD Len // the # of bytes of above
  54. ); // decrease refcount in the list and if becomes zero, free the struct
  55. VOID // always succeeds
  56. DhcpFreeAllClasses( // free each elt of the list
  57. IN OUT PLIST_ENTRY ClassesList // input list of classes
  58. ); // free every class in the list
  59. //--------------------------------------------------------------------------------
  60. // In all the following functions, OptionsList is unprotected within the fn.
  61. // Caller has to take a lock on it.
  62. //--------------------------------------------------------------------------------
  63. PDHCP_OPTION // the reqd structure or NULL
  64. DhcpFindOption( // find a specific option
  65. IN OUT PLIST_ENTRY OptionsList, // the list of options to search
  66. IN BYTE OptionId, // the option id to search for
  67. IN BOOL IsVendor, // is it vendor specific?
  68. IN LPBYTE ClassName, // is there a class associated?
  69. IN DWORD ClassLen // # of bytes of above parameter
  70. ); // search for the required option in the list, return NULL if not found
  71. DWORD // status or ERROR_FILE_NOT_FOUND
  72. DhcpDelOption( // remove a particular option
  73. IN PDHCP_OPTION Option2Delete // delete this option
  74. ); // delete an existing option in the list, and free up space used
  75. DWORD // status
  76. DhcpAddOption( // add a new option
  77. IN OUT PLIST_ENTRY OptionsList, // list to add to
  78. IN BYTE OptionId, // option id to add
  79. IN BOOL IsVendor, // is it vendor specific?
  80. IN LPBYTE ClassName, // what is the class?
  81. IN DWORD ClassLen, // size of above in bytes
  82. IN LPBYTE Data, // data for this option
  83. IN DWORD DataLen, // # of bytes of above
  84. IN time_t ExpiryTime // when the option expires
  85. ); // replace or add new option to the list. fail if not enough memory
  86. VOID // always succeeds
  87. DhcpFreeAllOptions( // frees all the options
  88. IN OUT PLIST_ENTRY OptionsList // input list of options
  89. ); // free every option in the list
  90. time_t // 0 || time for next expiry (absolute)
  91. DhcpGetExpiredOptions( // delete all expired options
  92. IN OUT PLIST_ENTRY OptionsList, // list to search frm
  93. OUT PLIST_ENTRY ExpiredOptions // o/p list of expired options
  94. ); // move expired options between lists and return timer. 0 => switch off timer.
  95. //--------------------------------------------------------------------------------
  96. // In all the following functions, OptionsDefList is unprotected. Caller has
  97. // to take a lock on it.
  98. //--------------------------------------------------------------------------------
  99. DWORD // status
  100. DhcpAddOptionDef( // add a new option definition
  101. IN OUT PLIST_ENTRY OptionDefList, // input list of options to add to
  102. IN BYTE OptionId, // option to add
  103. IN BOOL IsVendor, // is it vendor specific
  104. IN LPBYTE ClassName, // name of class it belongs to
  105. IN DWORD ClassLen, // the size of above in bytes
  106. IN LPWSTR RegSendLoc, // where to get info about sending this out
  107. IN LPWSTR RegSaveLoc, // where to get info about saving this
  108. IN DWORD ValueType // what is the type when saving it?
  109. );
  110. PDHCP_OPTION_DEF // NULL, or requested option def
  111. DhcpFindOptionDef( // search for a particular option
  112. IN PLIST_ENTRY OptionDefList, // list to search in
  113. IN BYTE OptionId, // the option id to search for
  114. IN BOOL IsVendor, // is it vendor specific
  115. IN LPBYTE ClassName, // the class, if one exists
  116. IN DWORD ClassLen // # of bytes of class name
  117. );
  118. DWORD // status
  119. DhcpDelOptionDef( // delete a particular option def
  120. IN PLIST_ENTRY OptionDefList, // list to delete from
  121. IN BYTE OptionId, // the option id to delete
  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. VOID
  127. DhcpFreeAllOptionDefs( // free each element of a list
  128. IN OUT PLIST_ENTRY OptionDefList, // the list to free
  129. IN OUT PLIST_ENTRY ClassesList // classes to de-ref off
  130. );
  131. BOOL // TRUE==>found..
  132. DhcpOptionsFindDomain( // find the domain name option values
  133. IN OUT PDHCP_CONTEXT DhcpContext, // for this adapter
  134. OUT LPBYTE *Data, // fill this ptr up
  135. OUT LPDWORD DataLen
  136. );
  137. #endif OPTIONS_H