-
Notifications
You must be signed in to change notification settings - Fork 17
/
chap_api_dhcp_d.tex
71 lines (52 loc) · 2.39 KB
/
chap_api_dhcp_d.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
\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}