]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.sbin/pim6dd/trace.h
unfinished sblive driver, playback/mixer only for now - not enabled in
[FreeBSD/FreeBSD.git] / usr.sbin / pim6dd / trace.h
1 /*
2  * Copyright (C) 1999 WIDE Project.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the project nor the names of its contributors
14  *    may be used to endorse or promote products derived from this software
15  *    without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29 /*
30  *  Copyright (c) 1998 by the University of Southern California.
31  *  All rights reserved.
32  *
33  *  Permission to use, copy, modify, and distribute this software and
34  *  its documentation in source and binary forms for lawful
35  *  purposes and without fee is hereby granted, provided
36  *  that the above copyright notice appear in all copies and that both
37  *  the copyright notice and this permission notice appear in supporting
38  *  documentation, and that any documentation, advertising materials,
39  *  and other materials related to such distribution and use acknowledge
40  *  that the software was developed by the University of Southern
41  *  California and/or Information Sciences Institute.
42  *  The name of the University of Southern California may not
43  *  be used to endorse or promote products derived from this software
44  *  without specific prior written permission.
45  *
46  *  THE UNIVERSITY OF SOUTHERN CALIFORNIA DOES NOT MAKE ANY REPRESENTATIONS
47  *  ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE.  THIS SOFTWARE IS
48  *  PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
49  *  INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
50  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND
51  *  NON-INFRINGEMENT.
52  *
53  *  IN NO EVENT SHALL USC, OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY
54  *  SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, WHETHER IN CONTRACT,
55  *  TORT, OR OTHER FORM OF ACTION, ARISING OUT OF OR IN CONNECTION WITH,
56  *  THE USE OR PERFORMANCE OF THIS SOFTWARE.
57  *
58  *  Other copyrights might apply to parts of this software and are so
59  *  noted when applicable.
60  */
61 /*
62  *  Questions concerning this software should be directed to
63  *  Pavlin Ivanov Radoslavov (pavlin@catarina.usc.edu)
64  *
65  *  $Id: trace.h,v 1.2 1999/09/12 17:00:10 jinmei Exp $
66  */
67 /*
68  * Part of this program has been derived from mrouted.
69  * The mrouted program is covered by the license in the accompanying file
70  * named "LICENSE.mrouted".
71  *
72  * The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
73  * Leland Stanford Junior University.
74  *
75  * $FreeBSD$
76  */
77
78
79 /*
80  * The packet format for a traceroute request.
81  */
82 struct tr6_query {
83     struct in6_addr  tr_src;            /* traceroute source */
84     struct in6_addr  tr_dst;            /* traceroute destination */
85     struct in6_addr  tr_raddr;          /* traceroute response address */
86 #if defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN)
87     struct {
88         u_int32_t qid : 24;     /* traceroute query id */
89         u_int32_t rhlim : 8;    /* traceroute response ttl */
90     } q;
91 #else
92     struct {
93         u_int32_t rhlim : 8;    /* traceroute response ttl */
94         u_int32_t qid : 24;     /* traceroute query id */
95     } q;
96 #endif /* BYTE_ORDER */
97 };
98
99 #define tr_rhlim q.rhlim
100 #define tr_qid  q.qid
101
102 /*
103  * Traceroute response format.  A traceroute response has a tr_query at the
104  * beginning, followed by one tr_resp for each hop taken.
105  */
106 struct tr6_resp {
107         u_int32_t tr_qarr;      /* query arrival time */
108 #if 0
109         struct in6_addr tr_inaddr; /* incoming interface address */
110         struct in6_addr tr_outaddr; /* outgoing interface address */
111 #endif
112         u_int32_t tr_inifid;    /* incoming interface identifier */
113         u_int32_t tr_outifid;   /* outgoing interface identifier */
114         struct in6_addr tr_lcladdr; /* router's address(must have largest scope) */
115         struct in6_addr tr_rmtaddr; /* parent address in source tree */
116         u_int32_t tr_vifin;     /* input packet count on interface */
117         u_int32_t tr_vifout;    /* output packet count on interface */
118         u_int32_t tr_pktcnt;    /* total incoming packets for src-grp */
119         u_char  tr_rproto;      /* routing protocol deployed on router */
120 #if 0
121         u_char  tr_fhlim;       /* hop limit required to forward on outvif */
122 #endif
123         u_char  tr_flags;       /* flags */
124         u_char  tr_plen;        /* prefix length for src addr */
125         u_char  tr_rflags;      /* forwarding error codes */
126 };
127
128 /* defs within mtrace */
129 #define QUERY   1
130 #define RESP    2
131 #define QLEN    sizeof(struct tr6_query)
132 #define RLEN    sizeof(struct tr6_resp)
133
134 /* fields for tr_inifid and tr_outifid */
135 #define TR_NO_VIF       0xffffffff/* interface can't be determined */
136
137 /* fields for tr_rflags (forwarding error codes) */
138 #define TR_NO_ERR       0       /* No error */
139 #define TR_WRONG_IF     1       /* traceroute arrived on non-oif */
140 #define TR_PRUNED       2       /* router has sent a prune upstream */
141 #define TR_OPRUNED      3       /* stop forw. after request from next hop rtr*/
142 #define TR_SCOPED       4       /* group adm. scoped at this hop */
143 #define TR_NO_RTE       5       /* no route for the source */
144 #define TR_NO_LHR       6       /* not the last-hop router */
145 #define TR_NO_FWD       7       /* not forwarding for this (S,G). Reason = ? */
146 #define TR_RP           8       /* I am the RP/Core */
147 #define TR_IIF          9       /* request arrived on the iif */
148 #define TR_NO_MULTI     0x0a    /* multicast disabled on that interface */
149 #define TR_NO_SPACE     0x81    /* no space to insert responce data block */
150 #define TR_OLD_ROUTER   0x82    /* previous hop does not support traceroute */
151 #define TR_ADMIN_PROHIB 0x83    /* traceroute adm. prohibited */
152
153 /* fields for tr_flags */
154 #define TR_SUBNET_COUNT 0x80    /* pkt count for (S,G) is for source network */
155
156 /* fields for r_plen */
157 #define TR_GROUP_ONLY   0xff    /* forwarding solely on group state */
158
159 /* fields for packets count */
160 #define TR_CANT_COUNT   0xffffffff  /* no count can be reported */
161
162 /* fields for tr_rproto (routing protocol) */
163 #define PROTO_DVMRP        1
164 #define PROTO_MOSPF        2
165 #define PROTO_PIM          3
166 #define PROTO_CBT          4
167 #define PROTO_PIM_SPECIAL  5
168 #define PROTO_PIM_STATIC   6
169 #define PROTO_DVMRP_STATIC 7
170
171 #define MASK_TO_VAL(x, i) { \
172                         u_int32_t _x = ntohl(x); \
173                         (i) = 1; \
174                         while ((_x) <<= 1) \
175                                 (i)++; \
176                         };
177
178 #define VAL_TO_MASK(x, i) { \
179                         x = htonl(~((1 << (32 - (i))) - 1)); \
180                         };
181
182 #define MASKLEN_TO_MASK6(masklen, mask6) \
183         do {\
184                 u_char maskarray[8] = \
185                 {0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff}; \
186                 int bytelen, bitlen, i; \
187                 memset(&(mask6), 0, sizeof(mask6));\
188                 bytelen = (masklen) / 8;\
189                 bitlen = (masklen) % 8;\
190                 for (i = 0; i < bytelen; i++) \
191                         (mask6).s6_addr[i] = 0xff;\
192                 if (bitlen) \
193                         (mask6).s6_addr[bytelen] = maskarray[bitlen - 1]; \
194         }while(0);
195
196 /* obnoxious gcc gives an extraneous warning about this constant... */
197 #if defined(__STDC__) || defined(__GNUC__)
198 #define JAN_1970        2208988800UL    /* 1970 - 1900 in seconds */
199 #else
200 #define JAN_1970        2208988800L     /* 1970 - 1900 in seconds */
201 #define const           /**/
202 #endif
203
204 #define NBR_VERS(n)     (((n)->al_pv << 8) + (n)->al_mv)