| Copyright | (c) Michael Steele, 2014 | 
|---|---|
| License | BSD3 | 
| Maintainer | mikesteele81@gmail.com | 
| Stability | experimental | 
| Portability | Windows | 
| Safe Haskell | None | 
| Language | Haskell2010 | 
System.Win32.DHCP
Contents
Description
- data DhcpApi
 - loadDHCP :: IO DhcpApi
 - data Context = Context {
- contextServer :: !Text
 - contextSubnet :: !Ip
 
 - data ClientType
- = Unspecified
 - | Dhcp
 - | Bootp
 - | Both
 - | ReservationFlag
 - | None
 
 - data DATE_TIME = DATE_TIME !DWORD !DWORD
 - data HOST_INFO = HOST_INFO !Ip (Maybe String) (Maybe String)
 - data SEARCH_INFO
 - data Client = Client {}
 - enumClients :: DhcpApi -> Context -> IO [Client]
 - lookupClient :: DhcpApi -> Text -> SEARCH_INFO -> IO (Maybe Client)
 - deleteClient :: DhcpApi -> Text -> SEARCH_INFO -> IO ()
 - data Mapping = Mapping {
- mappingMac :: !Mac
 - mappingIp :: !Ip
 
 - data Reservation = Reservation {}
 - addReservation :: DhcpApi -> Context -> Mapping -> IO ()
 - enumReservations :: DhcpApi -> Context -> IO [Reservation]
 - removeReservation :: DhcpApi -> Context -> Mapping -> ClientType -> Bool -> IO ()
 
Documentation
In an effort to avoid potential compile-time linker errors this package
 uses runtime dynamic linking. Internally a DhcpApi is a dictionary of
 dynamically bound foreign calls. Most actions require one to be passed.
 Simply call loadDhcp to obtain one.
Calling this function performs runtime dynamic linking for every internal
 foreign call into the Dhcp Server Management Api. It is safe to call this
 action multiple times. I recommend calling this function once as the part
 of a process's initialization, and then pass the returned DhcpApi to
 functions that need it.
General Types
A Context defines which server and scope within that server a command refers to. Microsoft's DHCP server supports multiple scopes. This allows different configurations to be sent to devices based on their hardware (MAC) address. Scopes are identified by their network address.
Constructors
| Context | |
Fields 
  | |
data ClientType Source
Microsoft's DHCP server supports DHCP and BOOTP. Both protocols server
 similar purposes, but DHCP is more widely used. Lease and reservation
 records contain a flag field indicating which protocol the record is valid
 for. In most cases this flag will be Both, because that is the default
 behavior.
Constructors
| Unspecified | |
| Dhcp | |
| Bootp | |
| Both | |
| ReservationFlag | |
| None | 
Instances
The number of ticks (100-nanosecond increments) since 12:00 midnight, January 1, 1 C.E. in the Gregorian calendar.
Microsoft does not provide any functions I know of for converting this value into something more convenient to work with.
typedef struct _DATE_TIME {
    DWORD dwLowDateTime;
    DWORD dwHighDateTime;
} DATE_TIME,*PDATE_TIME, *LPDATE_TIME;data SEARCH_INFO Source
Filter criteria used in actions that look up reservation or lease records.
typedef struct _DHCP_CLIENT_SEARCH_INFO {
  DHCP_SEARCH_INFO_TYPE SearchType;
  union {
    DHCP_IP_ADDRESS ClientIpAddress;
    DHCP_CLIENT_UID ClientHardwareAddress;
    LPWSTR          ClientName;
  } SearchInfo;
} DHCP_SEARCH_INFO, *LPDHCP_SEARCH_INFO;Constructors
| ClientIpAddress !Ip | Search based on an IP address. All scopes are searched. It should not be possible for multiple records to exist.  | 
| ClientHardwareAddress !Mac | Search based on a subnet and MAC address. This method of searching has not been tested.  | 
| ClientName !String | Search based on a client's name. Multiple records may exist, and what happens in that case will depend on the function being called. This method of searching has not been tested.  | 
Instances
Leases
Information about an active lease. This type corresponds to MSDN's DHCP_CLIENT_INFO_V4 structure.
typedef struct _DHCP_CLIENT_INFO_V4 {
  DHCP_IP_ADDRESS ClientIpAddress;
  DHCP_IP_MASK    SubnetMask;
  DHCP_CLIENT_UID ClientHardwareAddress;
  LPWSTR          ClientName;
  LPWSTR          ClientComment;
  DATE_TIME       ClientLeaseExpires;
  DHCP_HOST_INFO  OwnerHost;
  BYTE            bClientType;
} DHCP_CLIENT_INFO_V4, *LPDHCP_CLIENT_INFO_V4;Constructors
| Client | |
Fields 
  | |
Arguments
| :: DhcpApi | |
| -> Context | Specify which server and scope to search for client leases.  | 
| -> IO [Client] | The empty list means that no client records exist for the provided
 subnet. This function will throw an  
  | 
Perform a lookup operation for all client lease records within a scope. This action corresponds to MSDN's DhcpEnumSubnetClientsV4 function.
Arguments
| :: DhcpApi | |
| -> Text | According to MSDN this must specify the IP address of the server. Other functions (including this one) may or may not also accept a Unicode host name.  | 
| -> SEARCH_INFO | Define how to lookup a client. Only searching based on an IP addresses has been tested.  | 
| -> IO (Maybe Client) | A  
  | 
Search the DHCP server for a lease matching the given search criteria.
 Nothing is returned when no lease was found. This corresponds to MSDN's
 DhcpGetClientInfoV4 function.
Arguments
| :: DhcpApi | |
| -> Text | String which specifies the IP address or hostname of the DHCP server.  | 
| -> SEARCH_INFO | Define how to lookup a client to delete. Only deleting based on IP addresses have been tested.  | 
| -> IO () | This function will throw an  
  | 
Delete an active DHCP lease from the server.
 The SEARCH_INFO argument determines which search criteria
 to use. Searching by name will delete all active leases
 with that name. This action corresponds to MSDN's DhcpDeleteClientInfoV4
 function.
Reservations
A mapping between an IP and a MAC address. Each IP number may map to only one MAC address, and each MAC address may map to only one IP number.
This is a separate type from Reservation for practical reasons. When
 writing software to work with a DHCP server, Reservation's
 ClientType field is often not important. Without the Mapping type
 defined here it would often be necessary to define a custom type in
 each project.
Constructors
| Mapping | |
Fields 
  | |
data Reservation Source
A Reservation guarantees that a device with a given Mac address will always be assigned to a particular IP address. A reservation is not the same thing as a lease, and there are separate calls to work with both objects.
This type corresponds to MSDN's DHCP_IP_RESERVATION_V4 structure.
typedef struct _DHCP_IP_RESERVATION_V4 {
  DHCP_IP_ADDRESS ReservedIpAddress;
  DHCP_CLIENT_UID *ReservedForClient;
  BYTE            bAllowedClientTypes;
} DHCP_IP_RESERVATION_V4, *LPDHCP_IP_RESERVATION_V4;Constructors
| Reservation | |
Fields  | |
Instances
Arguments
| :: DhcpApi | |
| -> Context | |
| -> Mapping | |
| -> IO () | This function will throw an  
  | 
enumReservations :: DhcpApi -> Context -> IO [Reservation] Source
Arguments
| :: DhcpApi | |
| -> Context | |
| -> Mapping | |
| -> ClientType | Specify a DHCP reservation, BOOTP reservation, or both. This is untested.  | 
| -> Bool | Specify whether any active leases for the reservation should be removed as well.  | 
| -> IO () | This function will throw an  
  | 
Remove a reservation from the server