Super User's BSD Cross Reference: /OpenBSD/usr.sbin/rbootd/defs.h

1 /* $OpenBSD: defs.h,v 1.10 2015年01月19日 07:41:01 deraadt Exp $ */
2 /* $NetBSD: defs.h,v 1.5 1995年10月06日 05:12:14 thorpej Exp $ */
3
4 /*
5 * Copyright (c) 1988, 1992 The University of Utah and the Center
6 * for Software Science (CSS).
7 * Copyright (c) 1992, 1993
8 * The Regents of the University of California. All rights reserved.
9 *
10 * This code is derived from software contributed to Berkeley by
11 * the Center for Software Science of the University of Utah Computer
12 * Science Department. CSS requests users of this software to return
13 * to css-dist@cs.utah.edu any improvements that they make and grant
14 * CSS redistribution rights.
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 * 3. Neither the name of the University nor the names of its contributors
25 * may be used to endorse or promote products derived from this software
26 * without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE.
39 *
40 * from: @(#)defs.h 8.1 (Berkeley) 6/4/93
41 *
42 * From: Utah Hdr: defs.h 3.1 92/07/06
43 * Author: Jeff Forys, University of Utah CSS
44 */
45
46#include "rmp.h"
47#include "rmp_var.h"
48
49 /*
50** Common #define's and external variables. All other files should
51** include this.
52*/
53
54 /*
55 * These can be faster & more efficient than strcmp()/strncmp()...
56 */
57#define STREQN(s1,s2) ((*s1 == *s2) && (strcmp(s1,s2) == 0))
58#define STRNEQN(s1,s2,n) ((*s1 == *s2) && (strncmp(s1,s2,n) == 0))
59
60 /*
61 * Configuration file limitations.
62 */
63#define C_MAXFILE 100 /* max number of bootable files */
64#define C_LINELEN 1024 /* max length of line */
65
66 /*
67 * Direction of packet (used as argument to DispPkt).
68 */
69#define DIR_RCVD 0
70#define DIR_SENT 1
71#define DIR_NONE 2
72
73 /*
74 * These need not be functions, so...
75 */
76#define FreeStr(str) free(str)
77#define FreeClient(cli) free(cli)
78#define GenSessID() (++SessionID ? SessionID: ++SessionID)
79
80 /*
81 * Converting an Ethernet address to a string is done in many routines.
82 * Using `rmp.hp_hdr.saddr' works because this field is *never* changed;
83 * it will *always* contain the source address of the packet.
84 */
85#define EnetStr(rptr) GetEtherAddr(&(rptr)->rmp.hp_hdr.saddr[0])
86
87 /*
88 * Every machine we can boot will have one of these allocated for it
89 * (unless there are no restrictions on who we can boot).
90 */
91 typedef struct client_s {
92 u_int8_t addr[RMP_ADDRLEN]; /* addr of machine */
93 char *files[C_MAXFILE]; /* bootable files */
94 struct client_s *next; /* ptr to next */
95} CLIENT;
96
97 /*
98 * Every active connection has one of these allocated for it.
99 */
100 typedef struct rmpconn_s {
101 struct rmp_packet rmp; /* RMP packet */
102 int rmplen; /* length of packet */
103 struct timeval tstamp; /* last time active */
104 int bootfd; /* open boot file */
105 struct rmpconn_s *next; /* ptr to next */
106} RMPCONN;
107
108 /*
109 * All these variables are defined in "conf.c".
110 */
111 extern char MyHost[]; /* this hosts' name */
112 extern int DebugFlg; /* set true if debugging */
113 extern int BootAny; /* set true if we can boot anyone */
114
115 extern char *ConfigFile; /* configuration file */
116 extern char *DfltConfig; /* default configuration file */
117 extern char *DbgFile; /* debug output file */
118 extern char *BootDir; /* directory w/boot files */
119
120 extern FILE *DbgFp; /* debug file pointer */
121 extern char *IntfName; /* interface we are attached to */
122
123 extern u_int16_t SessionID; /* generated session ID */
124
125 extern char *BootFiles[]; /* list of boot files */
126
127 extern CLIENT *Clients; /* list of addrs we'll accept */
128 extern RMPCONN *RmpConns; /* list of active connections */
129
130 extern u_int8_t RmpMcastAddr[]; /* RMP multicast address */
131
132 void AddConn(RMPCONN *);
133 int BootDone(RMPCONN *);
134 char *BpfGetIntfName(char **);
135 int BpfOpen(void);
136 int BpfRead(RMPCONN *, int);
137 int BpfWrite(RMPCONN *);
138 void DispPkt(RMPCONN *, int);
139 void DoExit(void);
140 void DspFlnm(u_int, char *);
141 RMPCONN *FindConn(RMPCONN *);
142 void FreeClients(void);
143 void FreeConn(RMPCONN *);
144 void FreeConns(void);
145 int GetBootFiles(void);
146 char *GetEtherAddr(u_int8_t *);
147 CLIENT *NewClient(u_int8_t *);
148 RMPCONN *NewConn(RMPCONN *);
149 char *NewStr(char *);
150 u_int8_t *ParseAddr(char *);
151 int ParseConfig(void);
152 void ProcessPacket(RMPCONN *, CLIENT *);
153 void RemoveConn(RMPCONN *);
154 int SendBootRepl(struct rmp_packet *, RMPCONN *, char *[]);
155 int SendFileNo(struct rmp_packet *, RMPCONN *, char *[]);
156 int SendPacket(RMPCONN *);
157 int SendReadRepl(RMPCONN *);
158 int SendServerID(RMPCONN *);
159 

AltStyle によって変換されたページ (->オリジナル) /