Dhcp_server.Input
The logic for handling a DHCP input packet is pure, the module does not perform any IO, it only returns a possible reply packet or event to be logged.
A typical server main loop would do its own IO for receiving a packet, then input with Input.input_pkt
and send out the resulting reply.
type result =
| Silence
Input packet didn't belong to us, normal nop event.
*)| Update of Lease.database
Lease database update.
*)| Reply of Dhcp_wire.pkt * Lease.database
Reply packet to be sent back and the corresponding lease database to be used in case the sent of the reply pkt is successfull
*)| Warning of string
An odd event, could be logged.
*)| Error of string
Input packet is invalid, or some other error ocurred.
*)The result of input_pkt
.
val for_us : Config.t -> Dhcp_wire.pkt -> bool
Check the packet headers, true if the packet is destined for us.
val input_pkt : Config.t -> Lease.database -> Dhcp_wire.pkt -> int32 -> result
input_pkt config lease_db pkt time
Inputs packet pkt
, lease_db is the current lease database state, the resulting action should be performed by the caller, normally a Reply
packet is returned and should be sent back. time
is a int32 representing time as monotonic seconds.
val collect_replies_test :
Config.t ->
Macaddr.t ->
Dhcp_wire.option_code list ->
Dhcp_wire.dhcp_option list
Internal function exported for regression tests. Don't use this.