summaryrefslogtreecommitdiff
path: root/usr.sbin/dvmrpd/dvmrp.h
blob: cae149187da6b2078276bf4bf1843eefc6df7085 (plain)
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
/*	$OpenBSD: dvmrp.h,v 1.3 2009/03/14 15:32:55 michele Exp $ */

/*
 * Copyright (c) 2005, 2006 Esben Norby <norby@openbsd.org>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

/* DVMRP protocol definitions */

#ifndef _DVMRP_H_
#define _DVMRP_H_

/* misc */
#define IPPROTO_DVMRP			2
#define AllDVMRPRouters			"224.0.0.4"

#define DEFAULT_PROBE_INTERVAL		10
#define NBR_TMOUT			35
#define MIN_FLASH_UPDATE_INTERVAL	5
#define ROUTE_REPORT_INTERVAL		60
#define ROUTE_EXPIRATION_TIME		140
#define ROUTE_HOLD_DOWN			2 * ROUTE_REPORT_INTERVAL
#define MAX_PRUNE_LIFETIME		2 * 3600	/* 2 hours */
#define PRUNE_RETRANS_TIME		3		/* with exp. back off */
#define GRAFT_RETRANS_TIME		5		/* with exp. back off */

#define DEFAULT_CACHE_LIFETIME		300

#define DEFAULT_METRIC			1
#define MIN_METRIC			1
#define MAX_METRIC			31
#define INFINITY_METRIC			31

#define LAST_MASK			0x80		/* route reports */
#define METRIC_MASK			~LAST_MASK	/* route reports */

#define DVMRP_MAJOR_VERSION		3
#define DVMRP_MINOR_VERSION		255

/* DVMRP packet types */
#define PKT_TYPE_DVMRP			0x13

#define DVMRP_CODE_PROBE		0x01
#define DVMRP_CODE_REPORT		0x02
#define DVMRP_CODE_ASK_NBRS		0x03	/* obsolete */
#define DVMRP_CODE_NBRS			0x04	/* obsolete */
#define DVMRP_CODE_ASK_NBRS2		0x05
#define DVMRP_CODE_NBRS2		0x06
#define DVMRP_CODE_PRUNE		0x07
#define DVMRP_CODE_GRAFT		0x08
#define DVMRP_CODE_GRAFT_ACK		0x09

/* DVMRP command types */
#define DVMRP_CMD_NULL			0
#define DVMRP_CMD_AF_INDICATOR		2
#define DVMRP_CMD_SUBNETMASK		3
#define DVMRP_CMD_METRIC		4
#define DVMRP_CMD_FLAGS0		5
#define DVMRP_CMD_INFINITY		6
#define DVMRP_CMD_DEST_ADDR		7
#define DVMRP_CMD_REQ_DEST_ADDR		8
#define DVMRP_CMD_NON_MEM_REPORT	9
#define DVMRP_CMD_NON_MEM_CANCEL	10

/* DVMRP capabilities */
#define DVMRP_CAP_LEAF			0x01
#define DVMRP_CAP_PRUNE			0x02
#define DVMRP_CAP_GENID			0x04
#define DVMRP_CAP_MTRACE		0x08
#define DVMRP_CAP_SNMP			0x10
#define DVMRP_CAP_NETMASK		0x20
#define DVMRP_CAP_DEFAULT		(DVMRP_CAP_PRUNE | DVMRP_CAP_GENID | \
					    DVMRP_CAP_MTRACE)

/* DVMRP header */
struct dvmrp_hdr {
	u_int8_t		type;
	u_int8_t		code;
	u_int16_t		chksum;
	u_int8_t		dummy;
	u_int8_t		capabilities;
	u_int8_t		minor_version;
	u_int8_t		major_version;
};

/* Prune header */
struct prune_hdr {
	u_int32_t		src_host_addr;
	u_int32_t		group_addr;
	u_int32_t		lifetime;
	u_int32_t		src_netmask;
};
#define	PRUNE_MIN_LEN			12

/* Graft and Graft Ack header */
struct graft_hdr {
	u_int32_t		src_host_addr;
	u_int32_t		group_addr;
	u_int32_t		src_netmask;
};

struct igmpmsg {
	u_int32_t unused1;
	u_int32_t unused2;
	u_int8_t  im_msgtype;		/* what type of message */
#define	IGMPMSG_NOCACHE		1	/* no MFC in the kernel		    */
#define	IGMPMSG_WRONGVIF	2	/* packet came from wrong interface */
#define	IGMPMSG_WHOLEPKT	3	/* PIM pkt for user level encap.    */
#define	IGMPMSG_BW_UPCALL	4	/* BW monitoring upcall		    */
	u_int8_t  im_mbz;		/* must be zero */
	u_int8_t  im_vif;		/* vif rec'd on */
	u_int8_t  unused3;
	struct	  in_addr im_src, im_dst;
};

#endif /* !_DVMRP_H_ */