1\section{DHCP server}
2
3% Short description/overview of module functions
4
5
6\subsection{pico\_dhcp\_server\_initiate}
7
8\subsubsection*{Description}
9This function starts a simple DHCP server. 
10
11\subsubsection*{Function prototype}
12\texttt{int pico\_dhcp\_server\_initiate(struct pico\_dhcpd\_settings *settings);}
13
14\subsubsection*{Parameters}
15\begin{itemize}[noitemsep]
16\item \texttt{settings} - a pointer to a struct \texttt{pico\_dhcpd\_settings}, in which the following members matter to the user : 
17\begin{itemize}[noitemsep]
18\item \texttt{struct pico\_ip4 my\_ip} - the IP address of the device performing DHCP. Only IPs of this network will be served.
19\item \texttt{uint32\_t pool\_start} - the lowest host number that may be assigned, defaults to 100 if not provided.
20\item \texttt{uint32\_t pool\_end} - the highest host number that may be assigned, defaults to 254 if not provided.
21\item \texttt{uint32\_t lease\_time} - the advertised lease time in seconds, defaults to 120 if not provided.
22\end{itemize}
23\end{itemize}
24
25\subsubsection*{Return value}
26On successful startup of the dhcp server, 0 is returned.
27On error, -1 is returned, and \texttt{pico$\_$err} is set appropriately.
28
29\subsubsection*{Errors}
30\begin{itemize}[noitemsep]
31%everything from :
32%pico_socket_open
33\item PICO$\_$ERR$\_$EPROTONOSUPPORT - protocol not supported
34\item PICO$\_$ERR$\_$ENETUNREACH - network unreachable 
35%pico_socket_bind
36\item PICO$\_$ERR$\_$EINVAL - invalid argument
37\item PICO$\_$ERR$\_$ENXIO - no such device or address
38\end{itemize}
39
40\subsection{pico\_dhcp\_server\_destroy}
41
42\subsubsection*{Description}
43This function stops a previously started DHCP server on the given device. 
44
45\subsubsection*{Function prototype}
46\texttt{int pico\_dhcp\_server\_destroy(struct pico\_device *dev);}
47
48\subsubsection*{Parameters}
49\begin{itemize}[noitemsep]
50\item \texttt{dev} - a pointer to a struct \texttt{pico\_device}, to identify a previously started DHCP server that must be terminated. 
51\end{itemize}
52
53\subsubsection*{Return value}
54On success, 0 is returned.
55On error, -1 is returned, and \texttt{pico$\_$err} is set appropriately.
56
57\subsubsection*{Errors}
58\begin{itemize}[noitemsep]
59\item PICO$\_$ERR$\_$ENOENT - there was no DHCP server running on the given device.
60\end{itemize}
61
62\subsubsection*{Example}
63\begin{verbatim}
64struct pico_dhcpd_settings s = { };
65
66s.my_ip.addr = long_be(0x0a280001); /* 10.40.0.1 */
67
68pico_dhcp_server_initiate(&s);
69\end{verbatim}
70
71
72