Dhcp_server.InputThe 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 = | SilenceInput packet didn't belong to us, normal nop event.
*)| Update of Lease.t option * Lease.databaseLease database update.
*)| Reply of Dhcp_wire.pkt
* (Lease.t * Dhcp_wire.dhcp_option list) option
* Lease.databaseReply 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 stringAn odd event, could be logged.
*)| Error of stringInput packet is invalid, or some other error ocurred.
*)The result of input_pkt.
val for_us : Config.t -> Dhcp_wire.pkt -> boolCheck the packet headers, true if the packet is destined for us.
val input_pkt : Config.t -> Lease.database -> Dhcp_wire.pkt -> int32 -> resultinput_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 listInternal function exported for regression tests. Don't use this.