|
root / base / usr / src / head / protocols
protocols Plain Text 495 lines 15.3 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/* Copyright (c) 1983,1984,1985,1986,1987,1988,1989  AT&T. */
/*	All rights reserved. */

/*
 * Portions of this source code were derived from Berkeley 4.3 BSD
 * under license from the Regents of the University of California.
 */

#ifndef _PROTOCOLS_DUMPRESTORE_H
#define	_PROTOCOLS_DUMPRESTORE_H

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * This header file defines two different versions of the
 * ufsdump/ufsrestore interface.  If the defined constant
 * SUPPORTS_MTB_TAPE_FORMAT is set, the data structures in
 * this header file will support backups of more than 2 terabytes
 * of data.
 *
 * In the old format (the format that only supports dumps
 * of less than 2 terabytes), TP_BSIZE is the size of file blocks
 * on the dump tapes.
 * Note that TP_BSIZE must be a multiple of DEV_BSIZE.
 *
 * In the new format, tp_bsize is used to store the
 * tape block size, which is variable.  The tape block size
 * is like 'fragsize', in that 'c_tapea' in each tape record
 * contains the 'tape block record' number in a signed int.
 * We set TP_BSIZE_MAX to 65536, which will handle 128TB
 * of data.  The new format is indicated by a magic number
 * in the tape header of MTB_MAGIC.  The new format is only
 * used when the size of the backup exceeds 2 TB.  If the
 * backup can be stored in less thatn 2 TB, ufsdump still
 * uses the format indicated by the NFS_MAGIC magic number.
 * Therefore, backups of less than 2 TB are still readable
 * by earlier versions of ufsrestore.
 *
 * NTREC is the number of TP_BSIZE blocks that are written
 * in each tape record. HIGHDENSITYTREC is the number of
 * TP_BSIZE blocks that are written in each tape record on
 * 6250 BPI or higher density tapes.  CARTRIDGETREC is the
 * number of TP_BSIZE (or tp_bsize) blocks that are written
 * in each tape record on cartridge tapes.
 *
 * TP_NINDIR is the number of indirect pointers in a TS_INODE
 * or TS_ADDR record. Note that it must be a power of two.
 *
 */
#define	TP_BSIZE_MAX	65536
#define	TP_BSIZE_MIN	1024
#define	ESIZE_SHIFT_MAX	6	/* shift TP_BSIZE_MIN to TP_BSIZE_MAX */

#ifdef SUPPORTS_MTB_TAPE_FORMAT
#define	TP_BUFSIZE	TP_BSIZE_MAX
extern	int32_t		tp_bsize;
#else
#define	TP_BSIZE	1024
#define	TP_BUFSIZE	TP_BSIZE
#endif /* SUPPORTS_MTB_TAPE_FORMAT */

#define	NTREC		10
#define	HIGHDENSITYTREC	32
#define	CARTRIDGETREC	63
#define	TP_NINDIR	(TP_BSIZE_MIN/2)
#define	TP_NINOS	(TP_NINDIR / sizeof (long))
#define	LBLSIZE		16
#define	NAMELEN		64

#define	OFS_MAGIC	(int)60011
#define	NFS_MAGIC	(int)60012
#define	MTB_MAGIC	(int)60013
#define	CHECKSUM	(int)84446

union u_data {
	char	s_addrs[TP_NINDIR];	/* 1 => data; 0 => hole in inode */
	int32_t	s_inos[TP_NINOS];	/* starting inodes on tape */
};

union u_shadow {
	struct s_nonsh {
		int32_t	c_level;		/* level of this dump */
		char	c_filesys[NAMELEN];	/* dumpped file system name */
		char	c_dev[NAMELEN];		/* name of dumpped device */
		char	c_host[NAMELEN];	/* name of dumpped host */
	} c_nonsh;
	char    c_shadow[1];
};

/* if you change anything here, be sure to change normspcl in byteorder.c */

extern union u_spcl {
	char dummy[TP_BUFSIZE];
	struct	s_spcl {
		int32_t	c_type;		    /* record type (see below) */
		time32_t c_date;	    /* date of previous dump */
		time32_t c_ddate;	    /* date of this dump */
		int32_t	c_volume;	    /* dump volume number */
		daddr32_t c_tapea;	    /* logical block of this record */
		ino32_t	c_inumber;	    /* number of inode */
		int32_t	c_magic;	    /* magic number (see above) */
		int32_t	c_checksum;	    /* record checksum */
		struct	dinode	c_dinode;   /* ownership and mode of inode */
		int32_t	c_count;	    /* number of valid c_addr entries */
		union	u_data c_data;	    /* see union above */
		char	c_label[LBLSIZE];   /* dump label */
		union	u_shadow c_shadow;  /* see union above */
		int32_t	c_flags;	    /* additional information */
		int32_t	c_firstrec;	    /* first record on volume */
#ifdef SUPPORTS_MTB_TAPE_FORMAT
		int32_t	c_tpbsize;	    /* tape block size */
		int32_t	c_spare[31];	    /* reserved for future uses */
#else
		int32_t c_spare[32];
#endif /* SUPPORTS_MTB_TAPE_FORMAT */
	} s_spcl;
} u_spcl;
#define	spcl u_spcl.s_spcl
#define	c_addr c_data.s_addrs
#define	c_inos c_data.s_inos
#define	c_level c_shadow.c_nonsh.c_level
#define	c_filesys c_shadow.c_nonsh.c_filesys
#define	c_dev c_shadow.c_nonsh.c_dev
#define	c_host c_shadow.c_nonsh.c_host

/*
 * special record types
 */
#define	TS_TAPE		1	/* dump tape header */
#define	TS_INODE	2	/* beginning of file record */
#define	TS_ADDR		4	/* continuation of file record */
#define	TS_BITS		3	/* map of inodes on tape */
#define	TS_CLRI		6	/* map of inodes deleted since last dump */
#define	TS_END		5	/* end of volume marker */
#define	TS_EOM		7	/* floppy EOM - restore compat w/ old dump */

/*
 * flag values
 */
#define	DR_NEWHEADER	1	/* new format tape header */
#define	DR_INODEINFO	2	/* header contains starting inode info */
#define	DR_REDUMP	4	/* dump contains recopies of active files */
#define	DR_TRUEINC	8	/* dump is a "true incremental"	*/
#define	DR_HASMETA	16	/* metadata in this header */



#define	DUMPOUTFMT	"%-32s %c %s"		/* for printf */
						/* name, incno, ctime(date) */
#define	DUMPINFMT	"%258s %c %128[^\n]\n"	/* inverse for scanf */

#ifdef __cplusplus
}
#endif

#endif	/* !_PROTOCOLS_DUMPRESTORE_H */
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 1999 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Portions of this source code were derived from Berkeley 4.3 BSD
 * under license from the Regents of the University of California.
 */

/*
 * Routing Information Protocol for IPv6 (RIPng)
 * as specfied by RFC 2080.
 */

#ifndef _PROTOCOLS_RIPNGD_H
#define	_PROTOCOLS_RIPNGD_H

#ifdef	__cplusplus
extern "C" {
#endif

struct netinfo6 {
	struct in6_addr	rip6_prefix;		/* destination prefix */
	uint16_t	rip6_route_tag;		/* route tag */
	uint8_t		rip6_prefix_length;	/* destination prefix length */
	uint8_t		rip6_metric;		/* cost of route */
};

struct rip6 {
	uint8_t		rip6_cmd;		/* request/response */
	uint8_t		rip6_vers;		/* protocol version # */
	uint16_t	rip6_res1;		/* pad to 32-bit boundary */
	struct netinfo6	rip6_nets[1];		/* variable length... */
};

#define	RIPVERSION6		1

/*
 * Packet types.
 */
#define	RIPCMD6_REQUEST		1	/* want info - from suppliers */
#define	RIPCMD6_RESPONSE	2	/* responding to request */

#define	IPPORT_ROUTESERVER6	521

#ifdef	__cplusplus
}
#endif

#endif	/* _PROTOCOLS_RIPNGD_H */
/*
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved	*/

/*
 * Copyright (c) 1983, 1989, 1993
 *	The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgment:
 *	This product includes software developed by the University of
 *	California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

/*
 * Routing Information Protocol
 *
 * Derived from Xerox NS Routing Information Protocol
 * by changing 32-bit net numbers to sockaddr's and
 * padding stuff to 32-bit boundaries.
 */

#ifndef _PROTOCOLS_ROUTED_H
#define	_PROTOCOLS_ROUTED_H

#ifdef	__cplusplus
extern "C" {
#endif

/* The RIPv2 protocol is described in RFC 2453 */

#define	RIPv1		1
#define	RIPv2		2
#ifndef RIPVERSION
#define	RIPVERSION	RIPv1
#endif

#define	RIP_PORT	520

#if RIPVERSION == RIPv1
struct netinfo {
	struct	sockaddr rip_dst;	/* destination net/host */
	uint32_t   rip_metric;		/* cost of route */
};
#else
struct netinfo {
	uint16_t   n_family;
#define	RIP_AF_INET	htons(AF_INET)
#define	    RIP_AF_UNSPEC   0
#define	    RIP_AF_AUTH	    0xffff
	uint16_t   n_tag;		/* optional in RIPv2 */
	uint32_t   n_dst;		/* destination net or host */
#define	    RIP_DEFAULT	    0
	uint32_t   n_mask;		/* netmask in RIPv2 */
	uint32_t   n_nhop;		/* optional next hop in RIPv2 */
	uint32_t   n_metric;		/* cost of route */
};
#endif /* RIPv1 */

/* RIPv2 authentication */
struct netauth {
	uint16_t   a_family;		/* always RIP_AF_AUTH */
	uint16_t   a_type;
#define	RIP_AUTH_NONE		0
#define	RIP_AUTH_TRAILER	htons(1)	/* authentication data */
#define	RIP_AUTH_PW		htons(2)	/* password type */
#define	RIP_AUTH_MD5		htons(3)	/* Keyed MD5 */
	union {
#define	    RIP_AUTH_PW_LEN 16
	    uint8_t    au_pw[RIP_AUTH_PW_LEN];
	    struct a_md5 {
		int16_t	md5_pkt_len;	/* RIP-II packet length */
		int8_t	md5_keyid;	/* key ID and auth data len */
		int8_t	md5_auth_len;	/* 16 */
		uint32_t md5_seqno;	/* sequence number */
		uint32_t rsvd[2];	/* must be 0 */
#define	    RIP_AUTH_MD5_LEN RIP_AUTH_PW_LEN
	    } a_md5;
	} au;
};

struct rip_emetric {
	uint16_t	rip_metric;
	uint16_t	rip_mask;
	uint32_t	rip_token[1];
};

struct rip_sec_entry {
	uint32_t	rip_dst;
	uint32_t	rip_count;
	struct rip_emetric rip_emetric[1];
};

struct rip {
	uint8_t    rip_cmd;		/* request/response */
	uint8_t    rip_vers;		/* protocol version # */
	uint16_t   rip_res1;		/* pad to 32-bit boundary */
	union {				/* variable length... */
	    struct netinfo ru_nets[1];	/* variable length... */
	    char    ru_tracefile[1];	/* ditto ... */
	    struct netauth ru_auth[1];
	    struct {
		uint32_t rip_generation;
		struct rip_sec_entry rip_sec_entry[1];
	    } ru_tsol;
	} ripun;
#define	rip_nets	ripun.ru_nets
#define	rip_tracefile	ripun.ru_tracefile
#define	rip_auths	ripun.ru_auth
#define	rip_tsol	ripun.ru_tsol
};

struct entryinfo {
	struct	sockaddr rtu_dst;
	struct	sockaddr rtu_router;
	short	rtu_flags;
	short	rtu_state;
	int	rtu_timer;
	int	rtu_metric;
	int	int_flags;
	char	int_name[16];
};

typedef struct rdisc_info_s {
	uint_t  info_type;
	uint_t  info_version;
	uint_t	info_num_of_routers;
} rdisc_info_t;

/*
 * Structure that is returned with the default router info.
 */
typedef struct defr_s {
	uint32_t	defr_info_type;
	uint32_t	defr_version;
	struct in_addr	defr_addr;
	uint32_t	defr_index;
	uint32_t	defr_life;
	uint32_t	defr_pref;
} defr_t;


/*
 * Packet types.
 */
#define	RIPCMD_REQUEST		1	/* want info - from suppliers */
#define	RIPCMD_RESPONSE		2	/* responding to request */
#define	RIPCMD_TRACEON		3	/* turn tracing on */
#define	RIPCMD_TRACEOFF		4	/* turn it off */

/*
 * Gated extended RIP to include a "poll" command instead of using
 * RIPCMD_REQUEST with (RIP_AF_UNSPEC, RIP_DEFAULT).  RFC 1058 says
 * command 5 is used by Sun Microsystems for its own purposes.
 */
#define	RIPCMD_POLL		5	/* like request, but anyone answers */
#define	RIPCMD_POLLENTRY	6	/* like poll, but for entire entry */

#define	RIPCMD_SEC_RESPONSE	51	/* response includes E-metrics */
#define	RIPCMD_SEC_T_RESPONSE	52	/* tunneling */

#define	RIPCMD_MAX		7

#define	RDISC_SNMP_SOCKET	"/var/run/in.rdisc_mib"

#define	RDISC_SNMP_INFO_REQ		1
#define	RDISC_SNMP_INFO_RESPONSE	2
#define	RDISC_DEF_ROUTER_INFO		3

#define	RDISC_SNMP_INFO_VER	1
#define	RDISC_DEF_ROUTER_VER	1

#define	HOPCNT_INFINITY		16	/* per Xerox NS */
#define	MAXPACKETSIZE		512	/* max broadcast size */
#define	NETS_LEN ((MAXPACKETSIZE - sizeof (struct rip))	\
	/ sizeof (struct netinfo) +1)

#define	INADDR_RIP_GROUP 0xe0000009U	/* 224.0.0.9 */

/*
 * Timer values used in managing the routing table.
 *
 * Complete tables are broadcast every SUPPLY_INTERVAL seconds.
 * If changes occur between updates, dynamic updates containing only changes
 * may be sent.  When these are sent, a timer is set for a random value
 * between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates
 * are sent until the timer expires.
 *
 * Every update of a routing entry forces an entry's timer to be reset.
 * After EXPIRE_TIME without updates, the entry is marked invalid,
 * but held onto until GARBAGE_TIME so that others may see it, to
 * "poison" the bad route.
 */
#define	TIMER_RATE		30	/* alarm clocks every 30 seconds */

#define	SUPPLY_INTERVAL		30	/* time to supply tables */
#define	MIN_WAITTIME		2	/* min sec until next flash updates */
#define	MAX_WAITTIME		5	/* max sec until flash update */

#define	STALE_TIME		90	/* switch to a new gateway */
#define	EXPIRE_TIME		180	/* time to mark entry invalid */
#define	GARBAGE_TIME		300	/* time to garbage collect */

#ifdef	__cplusplus
}
#endif

#endif	/* _PROTOCOLS_ROUTED_H */