\section{DHCP server} % Short description/overview of module functions \subsection{pico\_dhcp\_server\_initiate} \subsubsection*{Description} This function starts a simple DHCP server. \subsubsection*{Function prototype} \texttt{int pico\_dhcp\_server\_initiate(struct pico\_dhcpd\_settings *settings);} \subsubsection*{Parameters} \begin{itemize}[noitemsep] \item \texttt{settings} - a pointer to a struct \texttt{pico\_dhcpd\_settings}, in which the following members matter to the user : \begin{itemize}[noitemsep] \item \texttt{struct pico\_ip4 my\_ip} - the IP address of the device performing DHCP. Only IPs of this network will be served. \item \texttt{uint32\_t pool\_start} - the lowest host number that may be assigned, defaults to 100 if not provided. \item \texttt{uint32\_t pool\_end} - the highest host number that may be assigned, defaults to 254 if not provided. \item \texttt{uint32\_t lease\_time} - the advertised lease time in seconds, defaults to 120 if not provided. \end{itemize} \end{itemize} \subsubsection*{Return value} On successful startup of the dhcp server, 0 is returned. On error, -1 is returned, and \texttt{pico$\_$err} is set appropriately. \subsubsection*{Errors} \begin{itemize}[noitemsep] %everything from : %pico_socket_open \item PICO$\_$ERR$\_$EPROTONOSUPPORT - protocol not supported \item PICO$\_$ERR$\_$ENETUNREACH - network unreachable %pico_socket_bind \item PICO$\_$ERR$\_$EINVAL - invalid argument \item PICO$\_$ERR$\_$ENXIO - no such device or address \end{itemize} \subsection{pico\_dhcp\_server\_destroy} \subsubsection*{Description} This function stops a previously started DHCP server on the given device. \subsubsection*{Function prototype} \texttt{int pico\_dhcp\_server\_destroy(struct pico\_device *dev);} \subsubsection*{Parameters} \begin{itemize}[noitemsep] \item \texttt{dev} - a pointer to a struct \texttt{pico\_device}, to identify a previously started DHCP server that must be terminated. \end{itemize} \subsubsection*{Return value} On success, 0 is returned. On error, -1 is returned, and \texttt{pico$\_$err} is set appropriately. \subsubsection*{Errors} \begin{itemize}[noitemsep] \item PICO$\_$ERR$\_$ENOENT - there was no DHCP server running on the given device. \end{itemize} \subsubsection*{Example} \begin{verbatim} struct pico_dhcpd_settings s = { }; s.my_ip.addr = long_be(0x0a280001); /* 10.40.0.1 */ pico_dhcp_server_initiate(&s); \end{verbatim}