xref: /openbsd/usr.sbin/mrouted/rsrr.h (revision 3a50f0a9)
1 /*	$NetBSD: rsrr.h,v 1.2 1995/10/09 03:51:57 thorpej Exp $	*/
2 
3 /*
4  * Copyright (c) 1993, 1998-2001.
5  * The University of Southern California/Information Sciences Institute.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. Neither the name of the project nor the names of its contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  */
32 
33 #define RSRR_SERV_PATH "/tmp/.rsrr_svr"
34 /* Note this needs to be 14 chars for 4.3 BSD compatibility */
35 #define RSRR_CLI_PATH "/tmp/.rsrr_cli"
36 
37 #define RSRR_MAX_LEN 2048
38 #define RSRR_HEADER_LEN (sizeof(struct rsrr_header))
39 #define RSRR_RQ_LEN (RSRR_HEADER_LEN + sizeof(struct rsrr_rq))
40 #define RSRR_RR_LEN (RSRR_HEADER_LEN + sizeof(struct rsrr_rr))
41 #define RSRR_VIF_LEN (sizeof(struct rsrr_vif))
42 
43 /* Current maximum number of vifs. */
44 #define RSRR_MAX_VIFS 32
45 
46 /* Maximum acceptable version */
47 #define RSRR_MAX_VERSION 1
48 
49 /* RSRR message types */
50 #define RSRR_ALL_TYPES     0
51 #define RSRR_INITIAL_QUERY 1
52 #define RSRR_INITIAL_REPLY 2
53 #define RSRR_ROUTE_QUERY   3
54 #define RSRR_ROUTE_REPLY   4
55 
56 /* RSRR Initial Reply (Vif) Status bits
57  * Each definition represents the position of the bit from right to left.
58  *
59  * Right-most bit is the disabled bit, set if the vif is administratively
60  * disabled.
61  */
62 #define RSRR_DISABLED_BIT 0
63 /* All other bits are zeroes */
64 
65 /* RSRR Route Query/Reply flag bits
66  * Each definition represents the position of the bit from right to left.
67  *
68  * Right-most bit is the Route Change Notification bit, set if the
69  * reservation protocol wishes to receive notification of
70  * a route change for the source-destination pair listed in the query.
71  * Notification is in the form of an unsolicited Route Reply.
72  */
73 #define RSRR_NOTIFICATION_BIT 0
74 /* Next bit indicates an error returning the Route Reply. */
75 #define RSRR_ERROR_BIT 1
76 /* All other bits are zeroes */
77 
78 /* Definition of an RSRR message header.
79  * An Initial Query uses only the header, and an Initial Reply uses
80  * the header and a list of vifs.
81  */
82 struct rsrr_header {
83     u_char version;			/* RSRR Version, currently 1 */
84     u_char type;			/* type of message, as defined above */
85     u_char flags;			/* flags; defined by type */
86     u_char num;				/* number; defined by type */
87 };
88 
89 /* Definition of a vif as seen by the reservation protocol.
90  *
91  * Routing gives the reservation protocol a list of vifs in the
92  * Initial Reply.
93  *
94  * We explicitly list the ID because we can't assume that all routing
95  * protocols will use the same numbering scheme.
96  *
97  * The status is a bitmask of status flags, as defined above.  It is the
98  * responsibility of the reservation protocol to perform any status checks
99  * if it uses the MULTICAST_VIF socket option.
100  *
101  * The threshold indicates the ttl an outgoing packet needs in order to
102  * be forwarded. The reservation protocol must perform this check itself if
103  * it uses the MULTICAST_VIF socket option.
104  *
105  * The local address is the address of the physical interface over which
106  * packets are sent.
107  */
108 struct rsrr_vif {
109     u_char id;				/* vif id */
110     u_char threshold;			/* vif threshold ttl */
111     u_short status;			/* vif status bitmask */
112     struct in_addr local_addr;		/* vif local address */
113 };
114 
115 /* Definition of an RSRR Route Query.
116  *
117  * The query asks routing for the forwarding entry for a particular
118  * source and destination.  The query ID uniquely identifies the query
119  * for the reservation protocol.  Thus, the combination of the client's
120  * address and the query ID forms a unique identifier for routing.
121  * Flags are defined above.
122  */
123 struct rsrr_rq {
124     struct in_addr dest_addr;		/* destination */
125     struct in_addr source_addr;		/* source */
126     u_long query_id;			/* query ID */
127 };
128 
129 /* Definition of an RSRR Route Reply.
130  *
131  * Routing uses the reply to give the reservation protocol the
132  * forwarding entry for a source-destination pair.  Routing copies the
133  * query ID from the query and fills in the incoming vif and a bitmask
134  * of the outgoing vifs.
135  * Flags are defined above.
136  */
137 struct rsrr_rr {
138     struct in_addr dest_addr;		/* destination */
139     struct in_addr source_addr;		/* source */
140     u_long query_id;			/* query ID */
141     u_short in_vif;			/* incoming vif */
142     u_short reserved;			/* reserved */
143     u_long out_vif_bm;			/* outgoing vif bitmask */
144 };
145