xref: /openbsd/usr.sbin/dvmrpd/dvmrp.h (revision bb071648)
1 /*	$OpenBSD: dvmrp.h,v 1.3 2009/03/14 15:32:55 michele Exp $ */
2 
3 /*
4  * Copyright (c) 2005, 2006 Esben Norby <norby@openbsd.org>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /* DVMRP protocol definitions */
20 
21 #ifndef _DVMRP_H_
22 #define _DVMRP_H_
23 
24 /* misc */
25 #define IPPROTO_DVMRP			2
26 #define AllDVMRPRouters			"224.0.0.4"
27 
28 #define DEFAULT_PROBE_INTERVAL		10
29 #define NBR_TMOUT			35
30 #define MIN_FLASH_UPDATE_INTERVAL	5
31 #define ROUTE_REPORT_INTERVAL		60
32 #define ROUTE_EXPIRATION_TIME		140
33 #define ROUTE_HOLD_DOWN			2 * ROUTE_REPORT_INTERVAL
34 #define MAX_PRUNE_LIFETIME		2 * 3600	/* 2 hours */
35 #define PRUNE_RETRANS_TIME		3		/* with exp. back off */
36 #define GRAFT_RETRANS_TIME		5		/* with exp. back off */
37 
38 #define DEFAULT_CACHE_LIFETIME		300
39 
40 #define DEFAULT_METRIC			1
41 #define MIN_METRIC			1
42 #define MAX_METRIC			31
43 #define INFINITY_METRIC			31
44 
45 #define LAST_MASK			0x80		/* route reports */
46 #define METRIC_MASK			~LAST_MASK	/* route reports */
47 
48 #define DVMRP_MAJOR_VERSION		3
49 #define DVMRP_MINOR_VERSION		255
50 
51 /* DVMRP packet types */
52 #define PKT_TYPE_DVMRP			0x13
53 
54 #define DVMRP_CODE_PROBE		0x01
55 #define DVMRP_CODE_REPORT		0x02
56 #define DVMRP_CODE_ASK_NBRS		0x03	/* obsolete */
57 #define DVMRP_CODE_NBRS			0x04	/* obsolete */
58 #define DVMRP_CODE_ASK_NBRS2		0x05
59 #define DVMRP_CODE_NBRS2		0x06
60 #define DVMRP_CODE_PRUNE		0x07
61 #define DVMRP_CODE_GRAFT		0x08
62 #define DVMRP_CODE_GRAFT_ACK		0x09
63 
64 /* DVMRP command types */
65 #define DVMRP_CMD_NULL			0
66 #define DVMRP_CMD_AF_INDICATOR		2
67 #define DVMRP_CMD_SUBNETMASK		3
68 #define DVMRP_CMD_METRIC		4
69 #define DVMRP_CMD_FLAGS0		5
70 #define DVMRP_CMD_INFINITY		6
71 #define DVMRP_CMD_DEST_ADDR		7
72 #define DVMRP_CMD_REQ_DEST_ADDR		8
73 #define DVMRP_CMD_NON_MEM_REPORT	9
74 #define DVMRP_CMD_NON_MEM_CANCEL	10
75 
76 /* DVMRP capabilities */
77 #define DVMRP_CAP_LEAF			0x01
78 #define DVMRP_CAP_PRUNE			0x02
79 #define DVMRP_CAP_GENID			0x04
80 #define DVMRP_CAP_MTRACE		0x08
81 #define DVMRP_CAP_SNMP			0x10
82 #define DVMRP_CAP_NETMASK		0x20
83 #define DVMRP_CAP_DEFAULT		(DVMRP_CAP_PRUNE | DVMRP_CAP_GENID | \
84 					    DVMRP_CAP_MTRACE)
85 
86 /* DVMRP header */
87 struct dvmrp_hdr {
88 	u_int8_t		type;
89 	u_int8_t		code;
90 	u_int16_t		chksum;
91 	u_int8_t		dummy;
92 	u_int8_t		capabilities;
93 	u_int8_t		minor_version;
94 	u_int8_t		major_version;
95 };
96 
97 /* Prune header */
98 struct prune_hdr {
99 	u_int32_t		src_host_addr;
100 	u_int32_t		group_addr;
101 	u_int32_t		lifetime;
102 	u_int32_t		src_netmask;
103 };
104 #define	PRUNE_MIN_LEN			12
105 
106 /* Graft and Graft Ack header */
107 struct graft_hdr {
108 	u_int32_t		src_host_addr;
109 	u_int32_t		group_addr;
110 	u_int32_t		src_netmask;
111 };
112 
113 struct igmpmsg {
114 	u_int32_t unused1;
115 	u_int32_t unused2;
116 	u_int8_t  im_msgtype;		/* what type of message */
117 #define	IGMPMSG_NOCACHE		1	/* no MFC in the kernel		    */
118 #define	IGMPMSG_WRONGVIF	2	/* packet came from wrong interface */
119 #define	IGMPMSG_WHOLEPKT	3	/* PIM pkt for user level encap.    */
120 #define	IGMPMSG_BW_UPCALL	4	/* BW monitoring upcall		    */
121 	u_int8_t  im_mbz;		/* must be zero */
122 	u_int8_t  im_vif;		/* vif rec'd on */
123 	u_int8_t  unused3;
124 	struct	  in_addr im_src, im_dst;
125 };
126 
127 #endif /* !_DVMRP_H_ */
128