Deleted Added
full compact
dumptab.c (13573) dumptab.c (18471)
1/*
2 * dumptab.c - handles dumping the database
1/*
2 * dumptab.c - handles dumping the database
3 *
4 * $Id$
3 */
4
5#include <sys/types.h>
6#include <netinet/in.h>
7#include <arpa/inet.h> /* inet_ntoa */
8
9#include <stdio.h>
10#include <stdlib.h>
11#include <syslog.h>
12#include <time.h>
13
14#ifndef USE_BFUNCS
15#include <memory.h>
16/* Yes, memcpy is OK here (no overlapped copies). */
17#define bcopy(a,b,c) memcpy(b,a,c)
18#define bzero(p,l) memset(p,0,l)
19#define bcmp(a,b,c) memcmp(a,b,c)
20#endif
21
22#include "bootp.h"
23#include "hash.h"
24#include "hwaddr.h"
25#include "report.h"
26#include "patchlevel.h"
27#include "bootpd.h"
28
29#ifdef __STDC__
30#define P(args) args
31#else
32#define P(args) ()
33#endif
34
35static void dump_generic P((FILE *, struct shared_bindata *));
36static void dump_host P((FILE *, struct host *));
37static void list_ipaddresses P((FILE *, struct in_addr_list *));
38
39#undef P
40
41#ifndef DEBUG
42void
43dumptab(filename)
44 char *filename;
45{
46 report(LOG_INFO, "No dumptab support!");
47}
48
49#else /* DEBUG */
50
51/*
52 * Dump the internal memory database to bootpd_dump.
53 */
54
55void
56dumptab(filename)
57 char *filename;
58{
59 int n;
60 struct host *hp;
61 FILE *fp;
62 long t;
63 /* Print symbols in alphabetical order for reader's convenience. */
64 static char legend[] = "#\n# Legend:\t(see bootptab.5)\n\
65#\tfirst field -- hostname (not indented)\n\
66#\tbf -- bootfile\n\
67#\tbs -- bootfile size in 512-octet blocks\n\
68#\tcs -- cookie servers\n\
69#\tdf -- dump file name\n\
70#\tdn -- domain name\n\
71#\tds -- domain name servers\n\
72#\tef -- extension file\n\
73#\tex -- exec file (YORK_EX_OPTION)\n\
74#\tgw -- gateways\n\
75#\tha -- hardware address\n\
76#\thd -- home directory for bootfiles\n\
77#\thn -- host name set for client\n\
78#\tht -- hardware type\n\
79#\tim -- impress servers\n\
80#\tip -- host IP address\n\
81#\tlg -- log servers\n\
82#\tlp -- LPR servers\n\
83#\tms -- message size\n\
84#\tmw -- min wait (secs)\n\
85#\tns -- IEN-116 name servers\n\
86#\tnt -- NTP servers (RFC 1129)\n\
87#\tra -- reply address override\n\
88#\trl -- resource location protocol servers\n\
89#\trp -- root path\n\
90#\tsa -- boot server address\n\
91#\tsm -- subnet mask\n\
92#\tsw -- swap server\n\
93#\ttc -- template host (points to similar host entry)\n\
94#\ttd -- TFTP directory\n\
95#\tto -- time offset (seconds)\n\
96#\tts -- time servers\n\
97#\tvm -- vendor magic number\n\
98#\tyd -- YP (NIS) domain\n\
99#\tys -- YP (NIS) servers\n\
100#\tTn -- generic option tag n\n\
101\n";
102
103 /*
104 * Open bootpd.dump file.
105 */
106 if ((fp = fopen(filename, "w")) == NULL) {
107 report(LOG_ERR, "error opening \"%s\": %s",
108 filename, get_errmsg());
109 exit(1);
110 }
111 t = time(NULL);
112 fprintf(fp, "\n# %s %s.%d\n", progname, VERSION, PATCHLEVEL);
113 fprintf(fp, "# %s: dump of bootp server database.\n", filename);
114 fprintf(fp, "# Dump taken %s", ctime(&t));
115 fwrite(legend, 1, sizeof(legend) - 1, fp);
116
117 n = 0;
118 for (hp = (struct host *) hash_FirstEntry(nmhashtable); hp != NULL;
119 hp = (struct host *) hash_NextEntry(nmhashtable)) {
120 dump_host(fp, hp);
121 fprintf(fp, "\n");
122 n++;
123 }
124 fclose(fp);
125
126 report(LOG_INFO, "dumped %d entries to \"%s\".", n, filename);
127}
128
129
130
131/*
132 * Dump all the available information on the host pointed to by "hp".
133 * The output is sent to the file pointed to by "fp".
134 */
135
136static void
137dump_host(fp, hp)
138 FILE *fp;
139 struct host *hp;
140{
141 /* Print symbols in alphabetical order for reader's convenience. */
142 if (hp) {
143 fprintf(fp, "%s:", (hp->hostname ?
144 hp->hostname->string : "?"));
145 if (hp->flags.bootfile) {
146 fprintf(fp, "\\\n\t:bf=%s:", hp->bootfile->string);
147 }
148 if (hp->flags.bootsize) {
149 fprintf(fp, "\\\n\t:bs=");
150 if (hp->flags.bootsize_auto) {
151 fprintf(fp, "auto:");
152 } else {
153 fprintf(fp, "%d:", hp->bootsize);
154 }
155 }
156 if (hp->flags.cookie_server) {
157 fprintf(fp, "\\\n\t:cs=");
158 list_ipaddresses(fp, hp->cookie_server);
159 fprintf(fp, ":");
160 }
161 if (hp->flags.dump_file) {
162 fprintf(fp, "\\\n\t:df=%s:", hp->dump_file->string);
163 }
164 if (hp->flags.domain_name) {
165 fprintf(fp, "\\\n\t:dn=%s:", hp->domain_name->string);
166 }
167 if (hp->flags.domain_server) {
168 fprintf(fp, "\\\n\t:ds=");
169 list_ipaddresses(fp, hp->domain_server);
170 fprintf(fp, ":");
171 }
172 if (hp->flags.exten_file) {
173 fprintf(fp, "\\\n\t:ef=%s:", hp->exten_file->string);
174 }
175 if (hp->flags.exec_file) {
176 fprintf(fp, "\\\n\t:ex=%s:", hp->exec_file->string);
177 }
178 if (hp->flags.gateway) {
179 fprintf(fp, "\\\n\t:gw=");
180 list_ipaddresses(fp, hp->gateway);
181 fprintf(fp, ":");
182 }
183 /* FdC: swap_server (see below) */
184 if (hp->flags.homedir) {
185 fprintf(fp, "\\\n\t:hd=%s:", hp->homedir->string);
186 }
187 /* FdC: dump_file (see above) */
188 /* FdC: domain_name (see above) */
189 /* FdC: root_path (see below) */
190 if (hp->flags.name_switch && hp->flags.send_name) {
191 fprintf(fp, "\\\n\t:hn:");
192 }
193 if (hp->flags.htype) {
194 int hlen = haddrlength(hp->htype);
195 fprintf(fp, "\\\n\t:ht=%u:", (unsigned) hp->htype);
196 if (hp->flags.haddr) {
197 fprintf(fp, "ha=\"%s\":",
198 haddrtoa(hp->haddr, hlen));
199 }
200 }
201 if (hp->flags.impress_server) {
202 fprintf(fp, "\\\n\t:im=");
203 list_ipaddresses(fp, hp->impress_server);
204 fprintf(fp, ":");
205 }
206 /* NetBSD: swap_server (see below) */
207 if (hp->flags.iaddr) {
208 fprintf(fp, "\\\n\t:ip=%s:", inet_ntoa(hp->iaddr));
209 }
210 if (hp->flags.log_server) {
211 fprintf(fp, "\\\n\t:lg=");
212 list_ipaddresses(fp, hp->log_server);
213 fprintf(fp, ":");
214 }
215 if (hp->flags.lpr_server) {
216 fprintf(fp, "\\\n\t:lp=");
217 list_ipaddresses(fp, hp->lpr_server);
218 fprintf(fp, ":");
219 }
220 if (hp->flags.msg_size) {
221 fprintf(fp, "\\\n\t:ms=%d:", hp->msg_size);
222 }
223 if (hp->flags.min_wait) {
224 fprintf(fp, "\\\n\t:mw=%d:", hp->min_wait);
225 }
226 if (hp->flags.name_server) {
227 fprintf(fp, "\\\n\t:ns=");
228 list_ipaddresses(fp, hp->name_server);
229 fprintf(fp, ":");
230 }
231 if (hp->flags.ntp_server) {
232 fprintf(fp, "\\\n\t:nt=");
233 list_ipaddresses(fp, hp->ntp_server);
234 fprintf(fp, ":");
235 }
236 if (hp->flags.reply_addr) {
237 fprintf(fp, "\\\n\t:ra=%s:", inet_ntoa(hp->reply_addr));
238 }
239 if (hp->flags.rlp_server) {
240 fprintf(fp, "\\\n\t:rl=");
241 list_ipaddresses(fp, hp->rlp_server);
242 fprintf(fp, ":");
243 }
244 if (hp->flags.root_path) {
245 fprintf(fp, "\\\n\t:rp=%s:", hp->root_path->string);
246 }
247 if (hp->flags.bootserver) {
248 fprintf(fp, "\\\n\t:sa=%s:", inet_ntoa(hp->bootserver));
249 }
250 if (hp->flags.subnet_mask) {
251 fprintf(fp, "\\\n\t:sm=%s:", inet_ntoa(hp->subnet_mask));
252 }
253 if (hp->flags.swap_server) {
254 fprintf(fp, "\\\n\t:sw=%s:", inet_ntoa(hp->subnet_mask));
255 }
256 if (hp->flags.tftpdir) {
257 fprintf(fp, "\\\n\t:td=%s:", hp->tftpdir->string);
258 }
259 /* NetBSD: rootpath (see above) */
260 /* NetBSD: domainname (see above) */
261 /* NetBSD: dumpfile (see above) */
262 if (hp->flags.time_offset) {
263 fprintf(fp, "\\\n\t:to=%ld:", hp->time_offset);
264 }
265 if (hp->flags.time_server) {
266 fprintf(fp, "\\\n\t:ts=");
267 list_ipaddresses(fp, hp->time_server);
268 fprintf(fp, ":");
269 }
270 if (hp->flags.vm_cookie) {
271 fprintf(fp, "\\\n\t:vm=");
272 if (!bcmp(hp->vm_cookie, vm_rfc1048, 4)) {
273 fprintf(fp, "rfc1048:");
274 } else if (!bcmp(hp->vm_cookie, vm_cmu, 4)) {
275 fprintf(fp, "cmu:");
276 } else {
277 fprintf(fp, "%d.%d.%d.%d:",
278 (int) ((hp->vm_cookie)[0]),
279 (int) ((hp->vm_cookie)[1]),
280 (int) ((hp->vm_cookie)[2]),
281 (int) ((hp->vm_cookie)[3]));
282 }
283 }
284 if (hp->flags.nis_domain) {
285 fprintf(fp, "\\\n\t:yd=%s:",
286 hp->nis_domain->string);
287 }
288 if (hp->flags.nis_server) {
289 fprintf(fp, "\\\n\t:ys=");
290 list_ipaddresses(fp, hp->nis_server);
291 fprintf(fp, ":");
292 }
293 /*
294 * XXX - Add new tags here (or above,
295 * so they print in alphabetical order).
296 */
297
298 if (hp->flags.generic) {
299 dump_generic(fp, hp->generic);
300 }
301 }
302}
303
304
305static void
306dump_generic(fp, generic)
307 FILE *fp;
308 struct shared_bindata *generic;
309{
310 u_char *bp = generic->data;
311 u_char *ep = bp + generic->length;
312 u_char tag;
313 int len;
314
315 while (bp < ep) {
316 tag = *bp++;
317 if (tag == TAG_PAD)
318 continue;
319 if (tag == TAG_END)
320 return;
321 len = *bp++;
322 if (bp + len > ep) {
323 fprintf(fp, " #junk in generic! :");
324 return;
325 }
326 fprintf(fp, "\\\n\t:T%d=", tag);
327 while (len) {
328 fprintf(fp, "%02X", *bp);
329 bp++;
330 len--;
331 if (len)
332 fprintf(fp, ".");
333 }
334 fprintf(fp, ":");
335 }
336}
337
338
339
340/*
341 * Dump an entire struct in_addr_list of IP addresses to the indicated file.
342 *
343 * The addresses are printed in standard ASCII "dot" notation and separated
344 * from one another by a single space. A single leading space is also
345 * printed before the first adddress.
346 *
347 * Null lists produce no output (and no error).
348 */
349
350static void
351list_ipaddresses(fp, ipptr)
352 FILE *fp;
353 struct in_addr_list *ipptr;
354{
355 unsigned count;
356 struct in_addr *addrptr;
357
358 if (ipptr) {
359 count = ipptr->addrcount;
360 addrptr = ipptr->addr;
361 while (count > 0) {
362 fprintf(fp, "%s", inet_ntoa(*addrptr++));
363 count--;
364 if (count)
365 fprintf(fp, ", ");
366 }
367 }
368}
369
370#endif /* DEBUG */
371
372/*
373 * Local Variables:
374 * tab-width: 4
375 * c-indent-level: 4
376 * c-argdecl-indent: 4
377 * c-continued-statement-offset: 4
378 * c-continued-brace-offset: -4
379 * c-label-offset: -4
380 * c-brace-offset: 0
381 * End:
382 */
5 */
6
7#include <sys/types.h>
8#include <netinet/in.h>
9#include <arpa/inet.h> /* inet_ntoa */
10
11#include <stdio.h>
12#include <stdlib.h>
13#include <syslog.h>
14#include <time.h>
15
16#ifndef USE_BFUNCS
17#include <memory.h>
18/* Yes, memcpy is OK here (no overlapped copies). */
19#define bcopy(a,b,c) memcpy(b,a,c)
20#define bzero(p,l) memset(p,0,l)
21#define bcmp(a,b,c) memcmp(a,b,c)
22#endif
23
24#include "bootp.h"
25#include "hash.h"
26#include "hwaddr.h"
27#include "report.h"
28#include "patchlevel.h"
29#include "bootpd.h"
30
31#ifdef __STDC__
32#define P(args) args
33#else
34#define P(args) ()
35#endif
36
37static void dump_generic P((FILE *, struct shared_bindata *));
38static void dump_host P((FILE *, struct host *));
39static void list_ipaddresses P((FILE *, struct in_addr_list *));
40
41#undef P
42
43#ifndef DEBUG
44void
45dumptab(filename)
46 char *filename;
47{
48 report(LOG_INFO, "No dumptab support!");
49}
50
51#else /* DEBUG */
52
53/*
54 * Dump the internal memory database to bootpd_dump.
55 */
56
57void
58dumptab(filename)
59 char *filename;
60{
61 int n;
62 struct host *hp;
63 FILE *fp;
64 long t;
65 /* Print symbols in alphabetical order for reader's convenience. */
66 static char legend[] = "#\n# Legend:\t(see bootptab.5)\n\
67#\tfirst field -- hostname (not indented)\n\
68#\tbf -- bootfile\n\
69#\tbs -- bootfile size in 512-octet blocks\n\
70#\tcs -- cookie servers\n\
71#\tdf -- dump file name\n\
72#\tdn -- domain name\n\
73#\tds -- domain name servers\n\
74#\tef -- extension file\n\
75#\tex -- exec file (YORK_EX_OPTION)\n\
76#\tgw -- gateways\n\
77#\tha -- hardware address\n\
78#\thd -- home directory for bootfiles\n\
79#\thn -- host name set for client\n\
80#\tht -- hardware type\n\
81#\tim -- impress servers\n\
82#\tip -- host IP address\n\
83#\tlg -- log servers\n\
84#\tlp -- LPR servers\n\
85#\tms -- message size\n\
86#\tmw -- min wait (secs)\n\
87#\tns -- IEN-116 name servers\n\
88#\tnt -- NTP servers (RFC 1129)\n\
89#\tra -- reply address override\n\
90#\trl -- resource location protocol servers\n\
91#\trp -- root path\n\
92#\tsa -- boot server address\n\
93#\tsm -- subnet mask\n\
94#\tsw -- swap server\n\
95#\ttc -- template host (points to similar host entry)\n\
96#\ttd -- TFTP directory\n\
97#\tto -- time offset (seconds)\n\
98#\tts -- time servers\n\
99#\tvm -- vendor magic number\n\
100#\tyd -- YP (NIS) domain\n\
101#\tys -- YP (NIS) servers\n\
102#\tTn -- generic option tag n\n\
103\n";
104
105 /*
106 * Open bootpd.dump file.
107 */
108 if ((fp = fopen(filename, "w")) == NULL) {
109 report(LOG_ERR, "error opening \"%s\": %s",
110 filename, get_errmsg());
111 exit(1);
112 }
113 t = time(NULL);
114 fprintf(fp, "\n# %s %s.%d\n", progname, VERSION, PATCHLEVEL);
115 fprintf(fp, "# %s: dump of bootp server database.\n", filename);
116 fprintf(fp, "# Dump taken %s", ctime(&t));
117 fwrite(legend, 1, sizeof(legend) - 1, fp);
118
119 n = 0;
120 for (hp = (struct host *) hash_FirstEntry(nmhashtable); hp != NULL;
121 hp = (struct host *) hash_NextEntry(nmhashtable)) {
122 dump_host(fp, hp);
123 fprintf(fp, "\n");
124 n++;
125 }
126 fclose(fp);
127
128 report(LOG_INFO, "dumped %d entries to \"%s\".", n, filename);
129}
130
131
132
133/*
134 * Dump all the available information on the host pointed to by "hp".
135 * The output is sent to the file pointed to by "fp".
136 */
137
138static void
139dump_host(fp, hp)
140 FILE *fp;
141 struct host *hp;
142{
143 /* Print symbols in alphabetical order for reader's convenience. */
144 if (hp) {
145 fprintf(fp, "%s:", (hp->hostname ?
146 hp->hostname->string : "?"));
147 if (hp->flags.bootfile) {
148 fprintf(fp, "\\\n\t:bf=%s:", hp->bootfile->string);
149 }
150 if (hp->flags.bootsize) {
151 fprintf(fp, "\\\n\t:bs=");
152 if (hp->flags.bootsize_auto) {
153 fprintf(fp, "auto:");
154 } else {
155 fprintf(fp, "%d:", hp->bootsize);
156 }
157 }
158 if (hp->flags.cookie_server) {
159 fprintf(fp, "\\\n\t:cs=");
160 list_ipaddresses(fp, hp->cookie_server);
161 fprintf(fp, ":");
162 }
163 if (hp->flags.dump_file) {
164 fprintf(fp, "\\\n\t:df=%s:", hp->dump_file->string);
165 }
166 if (hp->flags.domain_name) {
167 fprintf(fp, "\\\n\t:dn=%s:", hp->domain_name->string);
168 }
169 if (hp->flags.domain_server) {
170 fprintf(fp, "\\\n\t:ds=");
171 list_ipaddresses(fp, hp->domain_server);
172 fprintf(fp, ":");
173 }
174 if (hp->flags.exten_file) {
175 fprintf(fp, "\\\n\t:ef=%s:", hp->exten_file->string);
176 }
177 if (hp->flags.exec_file) {
178 fprintf(fp, "\\\n\t:ex=%s:", hp->exec_file->string);
179 }
180 if (hp->flags.gateway) {
181 fprintf(fp, "\\\n\t:gw=");
182 list_ipaddresses(fp, hp->gateway);
183 fprintf(fp, ":");
184 }
185 /* FdC: swap_server (see below) */
186 if (hp->flags.homedir) {
187 fprintf(fp, "\\\n\t:hd=%s:", hp->homedir->string);
188 }
189 /* FdC: dump_file (see above) */
190 /* FdC: domain_name (see above) */
191 /* FdC: root_path (see below) */
192 if (hp->flags.name_switch && hp->flags.send_name) {
193 fprintf(fp, "\\\n\t:hn:");
194 }
195 if (hp->flags.htype) {
196 int hlen = haddrlength(hp->htype);
197 fprintf(fp, "\\\n\t:ht=%u:", (unsigned) hp->htype);
198 if (hp->flags.haddr) {
199 fprintf(fp, "ha=\"%s\":",
200 haddrtoa(hp->haddr, hlen));
201 }
202 }
203 if (hp->flags.impress_server) {
204 fprintf(fp, "\\\n\t:im=");
205 list_ipaddresses(fp, hp->impress_server);
206 fprintf(fp, ":");
207 }
208 /* NetBSD: swap_server (see below) */
209 if (hp->flags.iaddr) {
210 fprintf(fp, "\\\n\t:ip=%s:", inet_ntoa(hp->iaddr));
211 }
212 if (hp->flags.log_server) {
213 fprintf(fp, "\\\n\t:lg=");
214 list_ipaddresses(fp, hp->log_server);
215 fprintf(fp, ":");
216 }
217 if (hp->flags.lpr_server) {
218 fprintf(fp, "\\\n\t:lp=");
219 list_ipaddresses(fp, hp->lpr_server);
220 fprintf(fp, ":");
221 }
222 if (hp->flags.msg_size) {
223 fprintf(fp, "\\\n\t:ms=%d:", hp->msg_size);
224 }
225 if (hp->flags.min_wait) {
226 fprintf(fp, "\\\n\t:mw=%d:", hp->min_wait);
227 }
228 if (hp->flags.name_server) {
229 fprintf(fp, "\\\n\t:ns=");
230 list_ipaddresses(fp, hp->name_server);
231 fprintf(fp, ":");
232 }
233 if (hp->flags.ntp_server) {
234 fprintf(fp, "\\\n\t:nt=");
235 list_ipaddresses(fp, hp->ntp_server);
236 fprintf(fp, ":");
237 }
238 if (hp->flags.reply_addr) {
239 fprintf(fp, "\\\n\t:ra=%s:", inet_ntoa(hp->reply_addr));
240 }
241 if (hp->flags.rlp_server) {
242 fprintf(fp, "\\\n\t:rl=");
243 list_ipaddresses(fp, hp->rlp_server);
244 fprintf(fp, ":");
245 }
246 if (hp->flags.root_path) {
247 fprintf(fp, "\\\n\t:rp=%s:", hp->root_path->string);
248 }
249 if (hp->flags.bootserver) {
250 fprintf(fp, "\\\n\t:sa=%s:", inet_ntoa(hp->bootserver));
251 }
252 if (hp->flags.subnet_mask) {
253 fprintf(fp, "\\\n\t:sm=%s:", inet_ntoa(hp->subnet_mask));
254 }
255 if (hp->flags.swap_server) {
256 fprintf(fp, "\\\n\t:sw=%s:", inet_ntoa(hp->subnet_mask));
257 }
258 if (hp->flags.tftpdir) {
259 fprintf(fp, "\\\n\t:td=%s:", hp->tftpdir->string);
260 }
261 /* NetBSD: rootpath (see above) */
262 /* NetBSD: domainname (see above) */
263 /* NetBSD: dumpfile (see above) */
264 if (hp->flags.time_offset) {
265 fprintf(fp, "\\\n\t:to=%ld:", hp->time_offset);
266 }
267 if (hp->flags.time_server) {
268 fprintf(fp, "\\\n\t:ts=");
269 list_ipaddresses(fp, hp->time_server);
270 fprintf(fp, ":");
271 }
272 if (hp->flags.vm_cookie) {
273 fprintf(fp, "\\\n\t:vm=");
274 if (!bcmp(hp->vm_cookie, vm_rfc1048, 4)) {
275 fprintf(fp, "rfc1048:");
276 } else if (!bcmp(hp->vm_cookie, vm_cmu, 4)) {
277 fprintf(fp, "cmu:");
278 } else {
279 fprintf(fp, "%d.%d.%d.%d:",
280 (int) ((hp->vm_cookie)[0]),
281 (int) ((hp->vm_cookie)[1]),
282 (int) ((hp->vm_cookie)[2]),
283 (int) ((hp->vm_cookie)[3]));
284 }
285 }
286 if (hp->flags.nis_domain) {
287 fprintf(fp, "\\\n\t:yd=%s:",
288 hp->nis_domain->string);
289 }
290 if (hp->flags.nis_server) {
291 fprintf(fp, "\\\n\t:ys=");
292 list_ipaddresses(fp, hp->nis_server);
293 fprintf(fp, ":");
294 }
295 /*
296 * XXX - Add new tags here (or above,
297 * so they print in alphabetical order).
298 */
299
300 if (hp->flags.generic) {
301 dump_generic(fp, hp->generic);
302 }
303 }
304}
305
306
307static void
308dump_generic(fp, generic)
309 FILE *fp;
310 struct shared_bindata *generic;
311{
312 u_char *bp = generic->data;
313 u_char *ep = bp + generic->length;
314 u_char tag;
315 int len;
316
317 while (bp < ep) {
318 tag = *bp++;
319 if (tag == TAG_PAD)
320 continue;
321 if (tag == TAG_END)
322 return;
323 len = *bp++;
324 if (bp + len > ep) {
325 fprintf(fp, " #junk in generic! :");
326 return;
327 }
328 fprintf(fp, "\\\n\t:T%d=", tag);
329 while (len) {
330 fprintf(fp, "%02X", *bp);
331 bp++;
332 len--;
333 if (len)
334 fprintf(fp, ".");
335 }
336 fprintf(fp, ":");
337 }
338}
339
340
341
342/*
343 * Dump an entire struct in_addr_list of IP addresses to the indicated file.
344 *
345 * The addresses are printed in standard ASCII "dot" notation and separated
346 * from one another by a single space. A single leading space is also
347 * printed before the first adddress.
348 *
349 * Null lists produce no output (and no error).
350 */
351
352static void
353list_ipaddresses(fp, ipptr)
354 FILE *fp;
355 struct in_addr_list *ipptr;
356{
357 unsigned count;
358 struct in_addr *addrptr;
359
360 if (ipptr) {
361 count = ipptr->addrcount;
362 addrptr = ipptr->addr;
363 while (count > 0) {
364 fprintf(fp, "%s", inet_ntoa(*addrptr++));
365 count--;
366 if (count)
367 fprintf(fp, ", ");
368 }
369 }
370}
371
372#endif /* DEBUG */
373
374/*
375 * Local Variables:
376 * tab-width: 4
377 * c-indent-level: 4
378 * c-argdecl-indent: 4
379 * c-continued-statement-offset: 4
380 * c-continued-brace-offset: -4
381 * c-label-offset: -4
382 * c-brace-offset: 0
383 * End:
384 */