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 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 |
75static void usage(void); |
76 77int |
78main(int argc, char *argv[]) |
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 |
290usage(void) |
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 |
309DoTimeout(void) |
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 * |
346FindClient(RMPCONN *rconn) |
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 |
371Exit(int sig) |
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 |
399ReConfig(int signo) |
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 |
425DebugOff(int signo) |
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 |
447DebugOn(int signo) |
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} |