]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.sbin/pim6sd/trace.h
This commit was generated by cvs2svn to compensate for changes in r76238,
[FreeBSD/FreeBSD.git] / usr.sbin / pim6sd / 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/09 15:47:11 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 #ifndef TRACE_H
79 #define TRACE_H
80
81 /*
82  * The packet format for a traceroute request.
83  */
84 struct tr6_query {
85     struct in6_addr  tr_src;            /* traceroute source */
86     struct in6_addr  tr_dst;            /* traceroute destination */
87     struct in6_addr  tr_raddr;          /* traceroute response address */
88 #if defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN)
89     struct {
90         u_int32_t qid : 24;     /* traceroute query id */
91         u_int32_t rhlim : 8;    /* traceroute response ttl */
92     } q;
93 #else
94     struct {
95         u_int32_t rhlim : 8;    /* traceroute response ttl */
96         u_int32_t qid : 24;     /* traceroute query id */
97     } q;
98 #endif /* BYTE_ORDER */
99 };
100
101 #define tr_rhlim q.rhlim
102 #define tr_qid  q.qid
103
104 /*
105  * Traceroute response format.  A traceroute response has a tr_query at the
106  * beginning, followed by one tr_resp for each hop taken.
107  */
108 struct tr6_resp {
109         u_int32_t tr_qarr;      /* query arrival time */
110 #if 0
111         struct in6_addr tr_inaddr; /* incoming interface address */
112         struct in6_addr tr_outaddr; /* outgoing interface address */
113 #endif
114         u_int32_t tr_inifid;    /* incoming interface identifier */
115         u_int32_t tr_outifid;   /* outgoing interface identifier */
116         struct in6_addr tr_lcladdr; /* router's address(must have largest scope) */
117         struct in6_addr tr_rmtaddr; /* parent address in source tree */
118         u_int32_t tr_vifin;     /* input packet count on interface */
119         u_int32_t tr_vifout;    /* output packet count on interface */
120         u_int32_t tr_pktcnt;    /* total incoming packets for src-grp */
121         u_char  tr_rproto;      /* routing protocol deployed on router */
122 #if 0
123         u_char  tr_fhlim;       /* hop limit required to forward on outvif */
124 #endif
125         u_char  tr_flags;       /* flags */
126         u_char  tr_plen;        /* prefix length for src addr */
127         u_char  tr_rflags;      /* forwarding error codes */
128 };
129
130 /* defs within mtrace */
131 #define QUERY   1
132 #define RESP    2
133 #define QLEN    sizeof(struct tr6_query)
134 #define RLEN    sizeof(struct tr6_resp)
135
136 /* fields for tr_inifid and tr_outifid */
137 #define TR_NO_VIF       0xffffffff/* interface can't be determined */
138
139 /* fields for tr_rflags (forwarding error codes) */
140 #define TR_NO_ERR       0       /* No error */
141 #define TR_WRONG_IF     1       /* traceroute arrived on non-oif */
142 #define TR_PRUNED       2       /* router has sent a prune upstream */
143 #define TR_OPRUNED      3       /* stop forw. after request from next hop rtr*/
144 #define TR_SCOPED       4       /* group adm. scoped at this hop */
145 #define TR_NO_RTE       5       /* no route for the source */
146 #define TR_NO_LHR       6       /* not the last-hop router */
147 #define TR_NO_FWD       7       /* not forwarding for this (S,G). Reason = ? */
148 #define TR_RP           8       /* I am the RP/Core */
149 #define TR_IIF          9       /* request arrived on the iif */
150 #define TR_NO_MULTI     0x0a    /* multicast disabled on that interface */
151 #define TR_NO_SPACE     0x81    /* no space to insert responce data block */
152 #define TR_OLD_ROUTER   0x82    /* previous hop does not support traceroute */
153 #define TR_ADMIN_PROHIB 0x83    /* traceroute adm. prohibited */
154
155 /* fields for tr_flags */
156 #define TR_SUBNET_COUNT 0x80    /* pkt count for (S,G) is for source network */
157
158 /* fields for r_plen */
159 #define TR_GROUP_ONLY   0xff    /* forwarding solely on group state */
160
161 /* fields for packets count */
162 #define TR_CANT_COUNT   0xffffffff  /* no count can be reported */
163
164 /* fields for tr_rproto (routing protocol) */
165 #define PROTO_DVMRP        1
166 #define PROTO_MOSPF        2
167 #define PROTO_PIM          3
168 #define PROTO_CBT          4
169 #define PROTO_PIM_SPECIAL  5
170 #define PROTO_PIM_STATIC   6
171 #define PROTO_DVMRP_STATIC 7
172
173 #define MASK_TO_VAL(x, i) { \
174                         u_int32_t _x = ntohl(x); \
175                         (i) = 1; \
176                         while ((_x) <<= 1) \
177                                 (i)++; \
178                         };
179
180 #define VAL_TO_MASK(x, i) { \
181                         x = htonl(~((1 << (32 - (i))) - 1)); \
182                         };
183
184 #define MASKLEN_TO_MASK6(masklen, mask6) \
185         do {\
186                 u_char maskarray[8] = \
187                 {0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff}; \
188                 int bytelen, bitlen, i; \
189                 memset(&(mask6), 0, sizeof(mask6));\
190                 bytelen = (masklen) / 8;\
191                 bitlen = (masklen) % 8;\
192                 for (i = 0; i < bytelen; i++) \
193                         (mask6).s6_addr[i] = 0xff;\
194                 if (bitlen) \
195                         (mask6).s6_addr[bytelen] = maskarray[bitlen - 1]; \
196         }while(0);
197
198 /* obnoxious gcc gives an extraneous warning about this constant... */
199 #if defined(__STDC__) || defined(__GNUC__)
200 #define JAN_1970        2208988800UL    /* 1970 - 1900 in seconds */
201 #else
202 #define JAN_1970        2208988800L     /* 1970 - 1900 in seconds */
203 #define const           /**/
204 #endif
205
206 #define NBR_VERS(n)     (((n)->al_pv << 8) + (n)->al_mv)
207
208 void accept_mtrace __P((struct sockaddr_in6 *, struct in6_addr *,
209                         struct in6_addr *, int, char *, u_int, int));
210 #endif /* TRACE_H */