Deleted Added
full compact
rbootd.c (68894) rbootd.c (90377)
1/*
2 * Copyright (c) 1988, 1992 The University of Utah and the Center
3 * for Software Science (CSS).
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * the Center for Software Science of the University of Utah Computer

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

50 The Regents of the University of California. All rights reserved.\n";
51#endif /* not lint */
52
53#ifndef lint
54#if 0
55static const char sccsid[] = "@(#)rbootd.c 8.1 (Berkeley) 6/4/93";
56#endif
57static const char rcsid[] =
1/*
2 * Copyright (c) 1988, 1992 The University of Utah and the Center
3 * for Software Science (CSS).
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * the Center for Software Science of the University of Utah Computer

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

50 The Regents of the University of California. All rights reserved.\n";
51#endif /* not lint */
52
53#ifndef lint
54#if 0
55static const char sccsid[] = "@(#)rbootd.c 8.1 (Berkeley) 6/4/93";
56#endif
57static const char rcsid[] =
58 "$FreeBSD: head/libexec/rbootd/rbootd.c 68894 2000-11-19 10:52:10Z kris $";
58 "$FreeBSD: head/libexec/rbootd/rbootd.c 90377 2002-02-07 23:57:01Z imp $";
59#endif /* not lint */
60
61#include <sys/param.h>
62#include <sys/time.h>
63#include <ctype.h>
64#include <err.h>
65#include <errno.h>
66#include <fcntl.h>
67#include <signal.h>
68#include <stdio.h>
69#include <stdlib.h>
70#include <string.h>
71#include <syslog.h>
72#include <unistd.h>
73#include "defs.h"
74
59#endif /* not lint */
60
61#include <sys/param.h>
62#include <sys/time.h>
63#include <ctype.h>
64#include <err.h>
65#include <errno.h>
66#include <fcntl.h>
67#include <signal.h>
68#include <stdio.h>
69#include <stdlib.h>
70#include <string.h>
71#include <syslog.h>
72#include <unistd.h>
73#include "defs.h"
74
75static void usage __P((void));
75static void usage(void);
76
77int
76
77int
78main(argc, argv)
79 int argc;
80 char *argv[];
78main(int argc, char *argv[])
81{
82 int c, fd, omask, maxfds;
83 fd_set rset;
84
85 /*
86 * Close any open file descriptors.
87 * Temporarily leave stdin & stdout open for `-d',
88 * and stderr open for any pre-syslog error messages.

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

284
285 (void) sigsetmask(omask);
286 }
287 }
288 }
289}
290
291static void
79{
80 int c, fd, omask, maxfds;
81 fd_set rset;
82
83 /*
84 * Close any open file descriptors.
85 * Temporarily leave stdin & stdout open for `-d',
86 * and stderr open for any pre-syslog error messages.

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

282
283 (void) sigsetmask(omask);
284 }
285 }
286 }
287}
288
289static void
292usage()
290usage(void)
293{
294 fprintf(stderr, "usage: rbootd [-ad] [-i interface] [config_file]\n");
295 exit (1);
296}
297
298/*
299** DoTimeout -- Free any connections that have timed out.
300**
301** Parameters:
302** None.
303**
304** Returns:
305** Nothing.
306**
307** Side Effects:
308** - Timed out connections in `RmpConns' will be freed.
309*/
310void
291{
292 fprintf(stderr, "usage: rbootd [-ad] [-i interface] [config_file]\n");
293 exit (1);
294}
295
296/*
297** DoTimeout -- Free any connections that have timed out.
298**
299** Parameters:
300** None.
301**
302** Returns:
303** Nothing.
304**
305** Side Effects:
306** - Timed out connections in `RmpConns' will be freed.
307*/
308void
311DoTimeout()
309DoTimeout(void)
312{
313 RMPCONN *rtmp;
314 struct timeval now;
315
316 (void) gettimeofday(&now, (struct timezone *)0);
317
318 /*
319 * For each active connection, if RMP_TIMEOUT seconds have passed

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

340** None.
341**
342** Warnings:
343** - This routine must be called with SIGHUP blocked since
344** a reconfigure can invalidate the information returned.
345*/
346
347CLIENT *
310{
311 RMPCONN *rtmp;
312 struct timeval now;
313
314 (void) gettimeofday(&now, (struct timezone *)0);
315
316 /*
317 * For each active connection, if RMP_TIMEOUT seconds have passed

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

338** None.
339**
340** Warnings:
341** - This routine must be called with SIGHUP blocked since
342** a reconfigure can invalidate the information returned.
343*/
344
345CLIENT *
348FindClient(rconn)
349 RMPCONN *rconn;
346FindClient(RMPCONN *rconn)
350{
351 CLIENT *ctmp;
352
353 for (ctmp = Clients; ctmp != NULL; ctmp = ctmp->next)
354 if (bcmp((char *)&rconn->rmp.hp_hdr.saddr[0],
355 (char *)&ctmp->addr[0], RMP_ADDRLEN) == 0)
356 break;
357

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

366**
367** Returns:
368** Does not return.
369**
370** Side Effects:
371** - This process ceases to exist.
372*/
373void
347{
348 CLIENT *ctmp;
349
350 for (ctmp = Clients; ctmp != NULL; ctmp = ctmp->next)
351 if (bcmp((char *)&rconn->rmp.hp_hdr.saddr[0],
352 (char *)&ctmp->addr[0], RMP_ADDRLEN) == 0)
353 break;
354

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

363**
364** Returns:
365** Does not return.
366**
367** Side Effects:
368** - This process ceases to exist.
369*/
370void
374Exit(sig)
375 int sig;
371Exit(int sig)
376{
377 if (sig > 0)
378 syslog(LOG_ERR, "going down on signal %d", sig);
379 else
380 syslog(LOG_ERR, "going down with fatal error");
381 BpfClose();
382 exit(1);
383}

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

395** - All active connections are dropped.
396** - List of boot-able files is changed.
397** - List of clients is changed.
398**
399** Warnings:
400** - This routine must be called with SIGHUP blocked.
401*/
402void
372{
373 if (sig > 0)
374 syslog(LOG_ERR, "going down on signal %d", sig);
375 else
376 syslog(LOG_ERR, "going down with fatal error");
377 BpfClose();
378 exit(1);
379}

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

391** - All active connections are dropped.
392** - List of boot-able files is changed.
393** - List of clients is changed.
394**
395** Warnings:
396** - This routine must be called with SIGHUP blocked.
397*/
398void
403ReConfig(signo)
404 int signo;
399ReConfig(int signo)
405{
406 syslog(LOG_NOTICE, "reconfiguring boot server");
407
408 FreeConns();
409
410 if (GetBootFiles() == 0)
411 Exit(0);
412

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

422**
423** Returns:
424** Nothing.
425**
426** Side Effects:
427** - Debug file is closed.
428*/
429void
400{
401 syslog(LOG_NOTICE, "reconfiguring boot server");
402
403 FreeConns();
404
405 if (GetBootFiles() == 0)
406 Exit(0);
407

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

417**
418** Returns:
419** Nothing.
420**
421** Side Effects:
422** - Debug file is closed.
423*/
424void
430DebugOff(signo)
431 int signo;
425DebugOff(int signo)
432{
433 if (DbgFp != NULL)
434 (void) fclose(DbgFp);
435
436 DbgFp = NULL;
437}
438
439/*

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

445** Returns:
446** Nothing.
447**
448** Side Effects:
449** - Debug file is opened/truncated if not already opened,
450** otherwise do nothing.
451*/
452void
426{
427 if (DbgFp != NULL)
428 (void) fclose(DbgFp);
429
430 DbgFp = NULL;
431}
432
433/*

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

439** Returns:
440** Nothing.
441**
442** Side Effects:
443** - Debug file is opened/truncated if not already opened,
444** otherwise do nothing.
445*/
446void
453DebugOn(signo)
454 int signo;
447DebugOn(int signo)
455{
456 if (DbgFp == NULL) {
457 if ((DbgFp = fopen(DbgFile, "w")) == NULL)
458 syslog(LOG_ERR, "can't open debug file (%s)", DbgFile);
459 }
460}
448{
449 if (DbgFp == NULL) {
450 if ((DbgFp = fopen(DbgFile, "w")) == NULL)
451 syslog(LOG_ERR, "can't open debug file (%s)", DbgFile);
452 }
453}