File: bootp.tex

package info (click to toggle)
oskit 0.97.20000202-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 58,008 kB
  • ctags: 172,612
  • sloc: ansic: 832,827; asm: 7,640; sh: 3,920; yacc: 3,664; perl: 1,457; lex: 427; makefile: 337; csh: 141; awk: 78
file content (265 lines) | stat: -rw-r--r-- 8,772 bytes parent folder | download
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
%
% Copyright (c) 1997-1998 University of Utah and the Flux Group.
% All rights reserved.
% 
% The University of Utah grants you the right to copy and reproduce this
% document or portions thereof for academic, research, evaluation, and
% personal use only, provided that (1) the title page appears prominently,
% and (2) these copyright and permission notices are retained in all copies.
% To arrange for alternate terms, contact the University of Utah at
% csl-dist@cs.utah.edu or +1-801-585-3271.
%
\label{bootp}

\newcommand{\bootp}{BOOTP}

\section{Introduction}

The \oskit{} provides a small library that allows \oskit{} clients to
contact a \bootp{} server to obtain the information necessary to 
configure their network parameters, such as IP address or hostname.
The implementation is based on RFC 1048/1533.

\section{External Dependencies}

The current implementation requires the user to provide an
implementation of the \texttt{oskit_etherdev} interface. Such interfaces
are supported by the \oskit{}'s device driver components.
It also requires access to the system clock. The library obtains 
access to the system clock by calling 
\texttt{oskit_clock_init}	% name might change
It releases its reference after the \bootp{} protocol has finished.
Additionally, \texttt{bootp_dump} uses \texttt{printf}.

\section{API reference}

The following sections describe the functions exported by the \bootp{}
library in detail.
All of these functions, as well as the types necessary to use them,
are declared in the header file {\tt <oskit/net/bootp.h>}.

\api{bootp_net_info}{\bootp{} protocol information structures}
\begin{apisyn}
\begin{codefrag}
\small
\begin{verbatim}
struct bootp_addr_array {
        struct in_addr *addr;   /* array of addresses */
        int             len;    /* number of addresses */
};

struct bootp_net_info {
        oskit_u32_t    flags;           /* which fields are valid */
        struct in_addr ip;              /* client IP address */
        struct in_addr netmask;         /* subnet mask */
        struct in_addr server;          /* server that replied  */
        struct bootp_addr_array gateway;        /* gateways */
        struct bootp_addr_array dns_server;     /* DNS server address  */
        struct bootp_addr_array time_server;    /* time server address  */
        struct bootp_addr_array log_server;     /* log server address  */
        struct bootp_addr_array lpr_server;     /* LPR server address  */
        oskit_s32_t    time_offset;     /* offset from UTC */
        char *hostname;                 /* client hostname */
        char *server_name;              /* name of replying server */
        char *bootfile_name;            /* boot file name */
        char *domainname;               /* domain name */
        unsigned char server_hwaddr[ETHER_ADDR_SIZE];   /* server address */
};
\end{verbatim}
\end{codefrag}
\end{apisyn}
\begin{apidesc}
	The first field of the \texttt{struct bootp_net_info} structure, 
	\emph{flags},
	denotes which of the other fields are valid.
	\emph{flags} is an ORed combination of the flag values below.
	Each flag corresponds to a field in the structure
	with the same name (in lower case).

	All other fields are of one of three types:
	\begin{enumerate}
	\item An IP address encoded as a 
		\texttt{struct in_addr},
	\item A string encoded as a \texttt{char *},
	\item A list of IP addresses encoded in a
		\texttt{struct bootp_addr_array}.
	\end{enumerate}

	The following table gives an overview of the flags that
	are currently supported and the types of the corresponding
	fields.

	\begin{tabular}{|l|l|l|}
	\hline
	Field & Type & Function \\
	\hline
	\texttt{BOOTP_NET_IP}		& IP address & IP address \\
	\texttt{BOOTP_NET_NETMASK}	& IP address & netmask \\
	\texttt{BOOTP_NET_GATEWAY}	& IP address & gateway \\
	\texttt{BOOTP_NET_SERVER}	& IP address & 
		server that answered \bootp{} request \\
	\texttt{BOOTP_NET_DNS_SERVER}	& List of IP addrs &
		domain name servers \\
	\texttt{BOOTP_NET_TIME_SERVER}	& List of IP addrs &
		time servers \\
	\texttt{BOOTP_NET_LOG_SERVER}	& List of IP addrs &
		log servers \\
	\texttt{BOOTP_NET_LPR_SERVER}	& List of IP addrs &
		LPR servers \\
	\texttt{BOOTP_NET_TIME_OFFSET}	& unsigned int & see below \\
	\texttt{BOOTP_NET_HOSTNAME}	& string & hostname \\
	\texttt{BOOTP_NET_SERVER_NAME}	& string & 
		name of the \bootp{} server \\
	\texttt{BOOTP_NET_BOOTFILE_NAME}& string &
		bootfile name \\
	\texttt{BOOTP_NET_DOMAINNAME}	& string &
		DNS domain name \\
	\texttt{BOOTP_NET_SERVER_ADDR}  & unsigned char[6] &
		Ethernet MAC address of \bootp{} server \\
	\hline
	\end{tabular}

	The \emph{time_offset} field
	specifies the time offset of the local subnet in seconds
	from Coordinated Universal Time (UTC). 
	It is a signed 32-bit integer,
        positive numbers indicate west of the Prime Meridian.
	% and it even works on our subnet, thanks to Bart!
\end{apidesc}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% bootp
%
\api{bootp_gen}{Generate a \bootp{} protocol request}
\begin{apisyn}
	\cinclude{oskit/net/bootp.h}

	\funcproto int bootp_gen(oskit_etherdev_t *dev, 
		\inoutparam struct~bootp_net_info *info,
		int retries, int timeout);
\end{apisyn}
\begin{apidesc}
	This function broadcasts \emph{retries} \bootp{} request packets,  
	waiting \emph{timeout} milliseconds for a reply.

	The only field of \emph{info} that is used as input for the request
	is the \emph{ip} field corresponding to \texttt{BOOTP_NET_IP}.
	See RFC 1048 for more explanation. Users should set this
	field if they know their IP address; \texttt{BOOTP_NET_IP}
	needs to be set in \emph{flags} if this is the case.

	Lists of IP addresses and strings are dynamically
	allocated as needed, users of \texttt{boopt_gen}
	should pass the \emph{info} struct to 
	\texttt{bootp_free} to deallocate them.
\end{apidesc}
\begin{apiparm}
	\item[dev]
		A pointer to an \texttt{oskit_etherdev} device interface.

	\item[info]
		The \bootp{} info to be used. 

	\item[retries]
		Number of \bootp{} request packets that are sent.

	\item[timeout]
		Timeout in milliseconds.
\end{apiparm}
\begin{apiret}
	Returns zero on success, \texttt{OSKIT_ETIMEDOUT} if the
	operation timed out, or another error code as specified in
	{\tt <oskit/error.h>}
\end{apiret}
\begin{apirel}
	\texttt{bootp_net_info}
\end{apirel}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% bootp
%
\api{bootp}{Generate a \bootp{} protocol request (simple interface)}
\begin{apisyn}
	\cinclude{oskit/net/bootp.h}

	\funcproto int bootp(oskit_etherdev_t *dev, 
		\inoutparam struct~bootp_net_info *info);
\end{apisyn}
\begin{apidesc}
	This function performs a \bootp{} request with
	a timeout of 200 milliseconds (1/5 of a second) with five retries
	using \texttt{bootp_gen}.

	The only field of \emph{info} that is used as input for the request
	is the \emph{ip} field corresponding to \texttt{BOOTP_NET_IP}.
	See RFC 1048 for more explanation. Users should set this
	field if they know their IP address; \texttt{BOOTP_NET_IP}
	needs to be set in \emph{flags} if this is the case.

	Lists of IP addresses and strings are dynamically
	allocated as needed, users of \texttt{boopt_gen}
	should pass the \emph{info} struct to 
	\texttt{bootp_free} to deallocate them.
\end{apidesc}
\begin{apiparm}
	\item[dev]
		A pointer to an \texttt{oskit_etherdev} device interface.
	\item[info]
		The \bootp{} info to be used.
\end{apiparm}
\begin{apiret}
	Returns zero on success, or an error code specified in
	{\tt <oskit/error.h>} on error.
\end{apiret}
\begin{apirel}
	\texttt{bootp_net_info}
\end{apirel}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% bootp_free
%
\api{bootp_free}{Free the result of a \bootp{} request}
\begin{apisyn}
	\cinclude{oskit/net/bootp.h}

	\funcproto void bootp_free(\inoutparam struct~bootp_net_info *info);
\end{apisyn}
\begin{apidesc}
	The function frees data structures that were allocated
	during a call to \texttt{bootp_gen}.
\end{apidesc}
\begin{apiparm}
	\item[info]
		The \bootp{} info to be freed.
\end{apiparm}
\begin{apirel}
	\texttt{bootp_gen},
	\texttt{bootp_net_info}
\end{apirel}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% bootp_dump
%
\api{bootp_dump}{Dump the result of a \bootp{} via printf}
\begin{apisyn}
	\cinclude{oskit/net/bootp.h}

	\funcproto void bootp_dump(struct~bootp_net_info *info);
\end{apisyn}
\begin{apidesc}
	This function prints the contents stored in a
	\texttt{bootp_net_info} structure to via \texttt{printf}.
\end{apidesc}
\begin{apiparm}
	\item[info]
		The \bootp{} info to be printed.
\end{apiparm}
\begin{apirel}
	\texttt{bootp_net_info},
	\texttt{printf}
\end{apirel}