Deleted Added
sdiff udiff text old ( 26581 ) new ( 28270 )
full compact
1/* $Id: bootp_subr.c,v 1.3 1997/05/14 01:31:54 tegge Exp $ */
2
3/*
4 * Copyright (c) 1995 Gordon Ross, Adam Glass
5 * Copyright (c) 1992 Regents of the University of California.
6 * All rights reserved.
7 *
8 * This software was developed by the Computer Systems Engineering group
9 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and

--- 245 unchanged lines hidden (view full) ---

255
256int
257bootpc_call(call,reply,procp)
258 struct bootp_packet *call;
259 struct bootp_packet *reply; /* output */
260 struct proc *procp;
261{
262 struct socket *so;
263 struct sockaddr_in *sin,sa;
264 struct mbuf *m, *nam;
265 struct uio auio;
266 struct iovec aio;
267 int error, rcvflg, timo, secs, len;
268 u_int tport;
269
270 /* Free at end if not null. */
271 nam = NULL;
272
273 /*
274 * Create socket and set its recieve timeout.
275 */
276 if ((error = socreate(AF_INET, &so, SOCK_DGRAM, 0,procp)))
277 goto out;
278
279 m = m_get(M_WAIT, MT_SOOPTS);
280 if (m == NULL) {

--- 24 unchanged lines hidden (view full) ---

305 *on = 1;
306 if ((error = sosetopt(so, SOL_SOCKET, SO_BROADCAST, m, procp)))
307 goto out;
308 }
309
310 /*
311 * Bind the local endpoint to a bootp client port.
312 */
313 m = m_getclr(M_WAIT, MT_SONAME);
314 sin = mtod(m, struct sockaddr_in *);
315 sin->sin_len = m->m_len = sizeof(*sin);
316 sin->sin_family = AF_INET;
317 sin->sin_addr.s_addr = INADDR_ANY;
318 sin->sin_port = htons(IPPORT_BOOTPC);
319 error = sobind(so, m, procp);
320 m_freem(m);
321 if (error) {
322 printf("bind failed\n");
323 goto out;
324 }
325
326 /*
327 * Setup socket address for the server.
328 */
329 nam = m_get(M_WAIT, MT_SONAME);
330 if (nam == NULL) {
331 error = ENOBUFS;
332 goto out;
333 }
334 sin = mtod(nam, struct sockaddr_in *);
335 sin-> sin_len = sizeof(*sin);
336 sin-> sin_family = AF_INET;
337 sin->sin_addr.s_addr = INADDR_BROADCAST;
338 sin->sin_port = htons(IPPORT_BOOTPS);
339
340 nam->m_len = sizeof(*sin);
341
342 /*
343 * Send it, repeatedly, until a reply is received,
344 * but delay each re-send by an increasing amount.
345 * If the delay hits the maximum, start complaining.
346 */
347 timo = 0;
348 for (;;) {
349 /* Send BOOTP request (or re-send). */

--- 4 unchanged lines hidden (view full) ---

354 auio.uio_iov = &aio;
355 auio.uio_iovcnt = 1;
356 auio.uio_segflg = UIO_SYSSPACE;
357 auio.uio_rw = UIO_WRITE;
358 auio.uio_offset = 0;
359 auio.uio_resid = sizeof(*call);
360 auio.uio_procp = procp;
361
362 error = sosend(so, nam, &auio, NULL, NULL, 0);
363 if (error) {
364 printf("bootpc_call: sosend: %d\n", error);
365 goto out;
366 }
367
368 /* Determine new timeout. */
369 if (timo < MAX_RESEND_DELAY)
370 timo++;

--- 51 unchanged lines hidden (view full) ---

422 } /* while secs */
423 } /* forever send/receive */
424
425 error = ETIMEDOUT;
426 goto out;
427
428 gotreply:
429 out:
430 if (nam) m_freem(nam);
431 soclose(so);
432 return error;
433}
434
435int
436bootpc_fakeup_interface(struct ifreq *ireq,struct socket *so,
437 struct proc *procp)
438{

--- 827 unchanged lines hidden ---