]>
git.saurik.com Git - apple/network_cmds.git/blob - rbootd.tproj/defs.h
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.0 (the 'License'). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
25 * Copyright (c) 1988, 1992 The University of Utah and the Center
26 * for Software Science (CSS).
27 * Copyright (c) 1992, 1993
28 * The Regents of the University of California. All rights reserved.
30 * This code is derived from software contributed to Berkeley by
31 * the Center for Software Science of the University of Utah Computer
32 * Science Department. CSS requests users of this software to return
33 * to css-dist@cs.utah.edu any improvements that they make and grant
34 * CSS redistribution rights.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 * 3. All advertising materials mentioning features or use of this software
45 * must display the following acknowledgement:
46 * This product includes software developed by the University of
47 * California, Berkeley and its contributors.
48 * 4. Neither the name of the University nor the names of its contributors
49 * may be used to endorse or promote products derived from this software
50 * without specific prior written permission.
52 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
53 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
55 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
56 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
57 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
58 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
59 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
60 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
61 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 * @(#)defs.h 8.1 (Berkeley) 6/4/93
66 * Utah $Hdr: defs.h 3.1 92/07/06$
67 * Author: Jeff Forys, University of Utah CSS
74 ** Common #define's and external variables. All other files should
79 * This may be defined in <sys/param.h>, if not, it's defined here.
81 #ifndef MAXHOSTNAMELEN
82 #define MAXHOSTNAMELEN 64
86 * SIGUSR1 and SIGUSR2 are defined in <signal.h> for 4.3BSD systems.
89 #define SIGUSR1 SIGEMT
92 #define SIGUSR2 SIGFPE
96 * These can be faster & more efficient than strcmp()/strncmp()...
98 #define STREQN(s1,s2) ((*s1 == *s2) && (strcmp(s1,s2) == 0))
99 #define STRNEQN(s1,s2,n) ((*s1 == *s2) && (strncmp(s1,s2,n) == 0))
102 * Configuration file limitations.
104 #define C_MAXFILE 10 /* max number of boot-able files */
105 #define C_LINELEN 1024 /* max length of line */
108 * Direction of packet (used as argument to DispPkt).
115 * These need not be functions, so...
117 #define FreeStr(str) free(str)
118 #define FreeClient(cli) free(cli)
119 #define GenSessID() (++SessionID ? SessionID: ++SessionID)
122 * Converting an Ethernet address to a string is done in many routines.
123 * Using `rmp.hp_hdr.saddr' works because this field is *never* changed;
124 * it will *always* contain the source address of the packet.
126 #define EnetStr(rptr) GetEtherAddr(&(rptr)->rmp.hp_hdr.saddr[0])
129 * Every machine we can boot will have one of these allocated for it
130 * (unless there are no restrictions on who we can boot).
132 typedef struct client_s
{
133 u_char addr
[RMP_ADDRLEN
]; /* addr of machine */
134 char *files
[C_MAXFILE
]; /* boot-able files */
135 struct client_s
*next
; /* ptr to next */
139 * Every active connection has one of these allocated for it.
141 typedef struct rmpconn_s
{
142 struct rmp_packet rmp
; /* RMP packet */
143 int rmplen
; /* length of packet */
144 struct timeval tstamp
; /* last time active */
145 int bootfd
; /* open boot file */
146 struct rmpconn_s
*next
; /* ptr to next */
150 * All these variables are defined in "conf.c".
152 extern char *ProgName
; /* path-stripped argv[0] */
153 extern char MyHost
[]; /* this hosts' name */
154 extern int MyPid
; /* this processes' ID */
155 extern int DebugFlg
; /* set true if debugging */
156 extern int BootAny
; /* set true if we can boot anyone */
158 extern char *ConfigFile
; /* configuration file */
159 extern char *DfltConfig
; /* default configuration file */
160 extern char *DbgFile
; /* debug output file */
161 extern char *PidFile
; /* file containing pid of server */
162 extern char *BootDir
; /* directory w/boot files */
164 extern FILE *DbgFp
; /* debug file pointer */
165 extern char *IntfName
; /* interface we are attached to */
167 extern u_short SessionID
; /* generated session ID */
169 extern char *BootFiles
[]; /* list of boot files */
171 extern CLIENT
*Clients
; /* list of addrs we'll accept */
172 extern RMPCONN
*RmpConns
; /* list of active connections */
174 extern char RmpMcastAddr
[]; /* RMP multicast address */
176 void AddConn
__P((RMPCONN
*));
177 int BootDone
__P((RMPCONN
*));
178 void BpfClose
__P((void));
179 char *BpfGetIntfName
__P((char **));
180 int BpfOpen
__P((void));
181 int BpfRead
__P((RMPCONN
*, int));
182 int BpfWrite
__P((RMPCONN
*));
183 void DebugOff
__P((int));
184 void DebugOn
__P((int));
185 void DispPkt
__P((RMPCONN
*, int));
186 void DoTimeout
__P((void));
187 void DspFlnm
__P((u_int
, char *));
188 void Exit
__P((int));
189 CLIENT
*FindClient
__P((RMPCONN
*));
190 RMPCONN
*FindConn
__P((RMPCONN
*));
191 void FreeClients
__P((void));
192 void FreeConn
__P((RMPCONN
*));
193 void FreeConns
__P((void));
194 int GetBootFiles
__P((void));
195 char *GetEtherAddr
__P((u_char
*));
196 CLIENT
*NewClient
__P((u_char
*));
197 RMPCONN
*NewConn
__P((RMPCONN
*));
198 char *NewStr
__P((char *));
199 u_char
*ParseAddr
__P((char *));
200 int ParseConfig
__P((void));
201 void ProcessPacket
__P((RMPCONN
*, CLIENT
*));
202 void ReConfig
__P((int));
203 void RemoveConn
__P((RMPCONN
*));
204 int SendBootRepl
__P((struct rmp_packet
*, RMPCONN
*, char *[]));
205 int SendFileNo
__P((struct rmp_packet
*, RMPCONN
*, char *[]));
206 int SendPacket
__P((RMPCONN
*));
207 int SendReadRepl
__P((RMPCONN
*));
208 int SendServerID
__P((RMPCONN
*));