Deleted Added
full compact
bootp_subr.c (26581) bootp_subr.c (28270)
1/* $Id: bootp_subr.c,v 1.3 1997/05/14 01:31:54 tegge Exp $ */
1/* $Id: bootp_subr.c,v 1.4 1997/06/12 14:08:20 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;
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;
263 struct sockaddr_in *sin, sa;
264 struct mbuf *m;
265 struct uio auio;
266 struct iovec aio;
267 int error, rcvflg, timo, secs, len;
268 u_int tport;
269
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 */
270 /*
271 * Create socket and set its recieve timeout.
272 */
273 if ((error = socreate(AF_INET, &so, SOCK_DGRAM, 0,procp)))
274 goto out;
275
276 m = m_get(M_WAIT, MT_SOOPTS);
277 if (m == NULL) {

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

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

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

344 auio.uio_iov = &aio;
345 auio.uio_iovcnt = 1;
346 auio.uio_segflg = UIO_SYSSPACE;
347 auio.uio_rw = UIO_WRITE;
348 auio.uio_offset = 0;
349 auio.uio_resid = sizeof(*call);
350 auio.uio_procp = procp;
351
362 error = sosend(so, nam, &auio, NULL, NULL, 0);
352 error = sosend(so, (struct sockaddr *)sin, &auio, NULL,
353 NULL, 0, procp);
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:
354 if (error) {
355 printf("bootpc_call: sosend: %d\n", error);
356 goto out;
357 }
358
359 /* Determine new timeout. */
360 if (timo < MAX_RESEND_DELAY)
361 timo++;

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

413 } /* while secs */
414 } /* forever send/receive */
415
416 error = ETIMEDOUT;
417 goto out;
418
419 gotreply:
420 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 ---
421 soclose(so);
422 return error;
423}
424
425int
426bootpc_fakeup_interface(struct ifreq *ireq,struct socket *so,
427 struct proc *procp)
428{

--- 827 unchanged lines hidden ---