OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [net/] [tcpip/] [v2_0/] [include/] [net/] [route.h] - Blame information for rev 773

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//      include/net/route.h
4
//
5
//      
6
//
7
//==========================================================================
8
//####BSDCOPYRIGHTBEGIN####
9
//
10
// -------------------------------------------
11
//
12
// Portions of this software may have been derived from OpenBSD or other sources,
13
// and are covered by the appropriate copyright disclaimers included herein.
14
//
15
// -------------------------------------------
16
//
17
//####BSDCOPYRIGHTEND####
18
//==========================================================================
19
//#####DESCRIPTIONBEGIN####
20
//
21
// Author(s):    gthomas
22
// Contributors: gthomas
23
// Date:         2000-01-10
24
// Purpose:      
25
// Description:  
26
//              
27
//
28
//####DESCRIPTIONEND####
29
//
30
//==========================================================================
31
 
32
 
33
/*      $OpenBSD: route.h,v 1.7 1999/12/08 06:50:18 itojun Exp $        */
34
/*      $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $       */
35
 
36
/*
37
 * Copyright (c) 1980, 1986, 1993
38
 *      The Regents of the University of California.  All rights reserved.
39
 *
40
 * Redistribution and use in source and binary forms, with or without
41
 * modification, are permitted provided that the following conditions
42
 * are met:
43
 * 1. Redistributions of source code must retain the above copyright
44
 *    notice, this list of conditions and the following disclaimer.
45
 * 2. Redistributions in binary form must reproduce the above copyright
46
 *    notice, this list of conditions and the following disclaimer in the
47
 *    documentation and/or other materials provided with the distribution.
48
 * 3. All advertising materials mentioning features or use of this software
49
 *    must display the following acknowledgement:
50
 *      This product includes software developed by the University of
51
 *      California, Berkeley and its contributors.
52
 * 4. Neither the name of the University nor the names of its contributors
53
 *    may be used to endorse or promote products derived from this software
54
 *    without specific prior written permission.
55
 *
56
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
57
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
59
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
60
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
61
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
62
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
64
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
65
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
66
 * SUCH DAMAGE.
67
 *
68
 *      @(#)route.h     8.3 (Berkeley) 4/19/94
69
 */
70
 
71
#ifndef _NET_ROUTE_H_
72
#define _NET_ROUTE_H_
73
 
74
#include <sys/queue.h>
75
 
76
/*
77
 * Kernel resident routing tables.
78
 *
79
 * The routing tables are initialized when interface addresses
80
 * are set by making entries for all directly connected interfaces.
81
 */
82
 
83
/*
84
 * A route consists of a destination address and a reference
85
 * to a routing entry.  These are often held by protocols
86
 * in their control blocks, e.g. inpcb.
87
 */
88
struct route {
89
        struct  rtentry *ro_rt;
90
        struct  sockaddr ro_dst;
91
};
92
 
93
/*
94
 * These numbers are used by reliable protocols for determining
95
 * retransmission behavior and are included in the routing structure.
96
 */
97
struct rt_metrics {
98
        u_long  rmx_locks;      /* Kernel must leave these values alone */
99
        u_long  rmx_mtu;        /* MTU for this path */
100
        u_long  rmx_hopcount;   /* max hops expected */
101
        u_long  rmx_expire;     /* lifetime for route, e.g. redirect */
102
        u_long  rmx_recvpipe;   /* inbound delay-bandwith product */
103
        u_long  rmx_sendpipe;   /* outbound delay-bandwith product */
104
        u_long  rmx_ssthresh;   /* outbound gateway buffer limit */
105
        u_long  rmx_rtt;        /* estimated round trip time */
106
        u_long  rmx_rttvar;     /* estimated rtt variance */
107
        u_long  rmx_pksent;     /* packets sent using this route */
108
};
109
 
110
/*
111
 * rmx_rtt and rmx_rttvar are stored as microseconds;
112
 * RTTTOPRHZ(rtt) converts to a value suitable for use
113
 * by a protocol slowtimo counter.
114
 */
115
#define RTM_RTTUNIT     1000000 /* units for rtt, rttvar, as units per sec */
116
#define RTTTOPRHZ(r)    ((r) / (RTM_RTTUNIT / PR_SLOWHZ))
117
 
118
/*
119
 * We distinguish between routes to hosts and routes to networks,
120
 * preferring the former if available.  For each route we infer
121
 * the interface to use from the gateway address supplied when
122
 * the route was entered.  Routes that forward packets through
123
 * gateways are marked so that the output routines know to address the
124
 * gateway rather than the ultimate destination.
125
 */
126
#ifndef RNF_NORMAL
127
#include <net/radix.h>
128
#endif
129
struct rtentry {
130
        struct  radix_node rt_nodes[2]; /* tree glue, and other values */
131
#define rt_key(r)       ((struct sockaddr *)((r)->rt_nodes->rn_key))
132
#define rt_mask(r)      ((struct sockaddr *)((r)->rt_nodes->rn_mask))
133
        struct  sockaddr *rt_gateway;   /* value */
134
        u_int   rt_flags;               /* up/down?, host/net */
135
        short   rt_refcnt;              /* # held references */
136
        short   rt_filler;              /* XXX */
137
        u_long  rt_use;                 /* raw # packets forwarded */
138
        struct  ifnet *rt_ifp;          /* the answer: interface to use */
139
        struct  ifaddr *rt_ifa;         /* the answer: interface to use */
140
        struct  sockaddr *rt_genmask;   /* for generation of cloned routes */
141
        caddr_t rt_llinfo;              /* pointer to link level info cache */
142
        struct  rt_metrics rt_rmx;      /* metrics used by rx'ing protocols */
143
        struct  rtentry *rt_gwroute;    /* implied entry for gatewayed routes */
144
        struct  rtentry *rt_parent;     /* If cloned, parent of this route. */
145
        LIST_HEAD(, rttimer) rt_timer;  /* queue of timeouts for misc funcs */
146
};
147
#define rt_use  rt_rmx.rmx_pksent
148
 
149
#ifdef __ECOS
150
/*
151
 * This structure modelled after the Linux 'route' functions
152
 * Used by the SIOCADDRT and SIOCDELRT calls
153
 */
154
struct ecos_rtentry
155
  {
156
    struct sockaddr rt_dst;             /* Target address.  */
157
    struct sockaddr rt_gateway;         /* Gateway addr (RTF_GATEWAY).  */
158
    struct sockaddr rt_genmask;         /* Target network mask (IP).  */
159
    unsigned short int rt_flags;
160
    unsigned char rt_tos;
161
    unsigned char rt_class;
162
    short int rt_metric;                /* +1 for binary compatibility!  */
163
    char *rt_dev;                       /* Forcing the device at add.  */
164
    unsigned long int rt_mtu;           /* Per route MTU/Window.  */
165
    unsigned long int rt_window;        /* Window clamping.  */
166
    unsigned short int rt_irtt;         /* Initial RTT.  */
167
  };
168
/* Compatibility hack.  */
169
#define rt_mss  rt_mtu
170
#endif
171
 
172
/*
173
 * Following structure necessary for 4.3 compatibility;
174
 * We should eventually move it to a compat file.
175
 */
176
struct ortentry {
177
        u_int32_t rt_hash;              /* to speed lookups */
178
        struct sockaddr rt_dst;         /* key */
179
        struct sockaddr rt_gateway;     /* value */
180
        int16_t   rt_flags;             /* up/down?, host/net */
181
        int16_t   rt_refcnt;            /* # held references */
182
        u_int32_t rt_ouse;              /* raw # packets forwarded (was: rt_use) */
183
        struct ifnet *rt_ifp;           /* the answer: interface to use */
184
};
185
 
186
#define RTF_UP          0x1             /* route usable */
187
#define RTF_GATEWAY     0x2             /* destination is a gateway */
188
#define RTF_HOST        0x4             /* host entry (net otherwise) */
189
#define RTF_REJECT      0x8             /* host or net unreachable */
190
#define RTF_DYNAMIC     0x10            /* created dynamically (by redirect) */
191
#define RTF_MODIFIED    0x20            /* modified dynamically (by redirect) */
192
#define RTF_DONE        0x40            /* message confirmed */
193
#define RTF_MASK        0x80            /* subnet mask present */
194
#define RTF_CLONING     0x100           /* generate new routes on use */
195
#define RTF_XRESOLVE    0x200           /* external daemon resolves name */
196
#define RTF_LLINFO      0x400           /* generated by ARP or ESIS */
197
#define RTF_STATIC      0x800           /* manually added */
198
#define RTF_BLACKHOLE   0x1000          /* just discard pkts (during updates) */
199
#define RTF_PROTO3      0x2000          /* protocol specific routing flag */
200
#define RTF_PROTO2      0x4000          /* protocol specific routing flag */
201
#define RTF_PROTO1      0x8000          /* protocol specific routing flag */
202
 
203
/*
204
 * New IPv6 routing flags.
205
 *
206
 * PROTO1 and PROTO2 are used, and defined in netinet6/ipv6_var.h.
207
 */
208
#define RTF_TUNNEL      0x100000        /* Tunnelling bit. */
209
 
210
/*
211
 * Routing statistics.
212
 */
213
struct  rtstat {
214
        u_int32_t rts_badredirect;      /* bogus redirect calls */
215
        u_int32_t rts_dynamic;          /* routes created by redirects */
216
        u_int32_t rts_newgateway;               /* routes modified by redirects */
217
        u_int32_t rts_unreach;          /* lookups which failed */
218
        u_int32_t rts_wildcard;         /* lookups satisfied by a wildcard */
219
};
220
 
221
/*
222
 * Structures for routing messages.
223
 */
224
struct rt_msghdr {
225
        u_short rtm_msglen;     /* to skip over non-understood messages */
226
        u_char  rtm_version;    /* future binary compatibility */
227
        u_char  rtm_type;       /* message type */
228
        u_short rtm_index;      /* index for associated ifp */
229
        int     rtm_flags;      /* flags, incl. kern & message, e.g. DONE */
230
        int     rtm_addrs;      /* bitmask identifying sockaddrs in msg */
231
        pid_t   rtm_pid;        /* identify sender */
232
        int     rtm_seq;        /* for sender to identify action */
233
        int     rtm_errno;      /* why failed */
234
        int     rtm_use;        /* from rtentry */
235
        u_long  rtm_inits;      /* which metrics we are initializing */
236
        struct  rt_metrics rtm_rmx; /* metrics themselves */
237
};
238
 
239
#define RTM_VERSION     3       /* Up the ante and ignore older versions */
240
 
241
#define RTM_ADD         0x1     /* Add Route */
242
#define RTM_DELETE      0x2     /* Delete Route */
243
#define RTM_CHANGE      0x3     /* Change Metrics or flags */
244
#define RTM_GET         0x4     /* Report Metrics */
245
#define RTM_LOSING      0x5     /* Kernel Suspects Partitioning */
246
#define RTM_REDIRECT    0x6     /* Told to use different route */
247
#define RTM_MISS        0x7     /* Lookup failed on this address */
248
#define RTM_LOCK        0x8     /* fix specified metrics */
249
#define RTM_OLDADD      0x9     /* caused by SIOCADDRT */
250
#define RTM_OLDDEL      0xa     /* caused by SIOCDELRT */
251
#define RTM_RESOLVE     0xb     /* req to resolve dst to LL addr */
252
#define RTM_NEWADDR     0xc     /* address being added to iface */
253
#define RTM_DELADDR     0xd     /* address being removed from iface */
254
#define RTM_IFINFO      0xe     /* iface going up/down etc. */
255
 
256
#define RTV_MTU         0x1     /* init or lock _mtu */
257
#define RTV_HOPCOUNT    0x2     /* init or lock _hopcount */
258
#define RTV_EXPIRE      0x4     /* init or lock _hopcount */
259
#define RTV_RPIPE       0x8     /* init or lock _recvpipe */
260
#define RTV_SPIPE       0x10    /* init or lock _sendpipe */
261
#define RTV_SSTHRESH    0x20    /* init or lock _ssthresh */
262
#define RTV_RTT         0x40    /* init or lock _rtt */
263
#define RTV_RTTVAR      0x80    /* init or lock _rttvar */
264
 
265
/*
266
 * Bitmask values for rtm_addr.
267
 */
268
#define RTA_DST         0x1     /* destination sockaddr present */
269
#define RTA_GATEWAY     0x2     /* gateway sockaddr present */
270
#define RTA_NETMASK     0x4     /* netmask sockaddr present */
271
#define RTA_GENMASK     0x8     /* cloning mask sockaddr present */
272
#define RTA_IFP         0x10    /* interface name sockaddr present */
273
#define RTA_IFA         0x20    /* interface addr sockaddr present */
274
#define RTA_AUTHOR      0x40    /* sockaddr for author of redirect */
275
#define RTA_BRD         0x80    /* for NEWADDR, broadcast or p-p dest addr */
276
 
277
/*
278
 * Index offsets for sockaddr array for alternate internal encoding.
279
 */
280
#define RTAX_DST        0        /* destination sockaddr present */
281
#define RTAX_GATEWAY    1       /* gateway sockaddr present */
282
#define RTAX_NETMASK    2       /* netmask sockaddr present */
283
#define RTAX_GENMASK    3       /* cloning mask sockaddr present */
284
#define RTAX_IFP        4       /* interface name sockaddr present */
285
#define RTAX_IFA        5       /* interface addr sockaddr present */
286
#define RTAX_AUTHOR     6       /* sockaddr for author of redirect */
287
#define RTAX_BRD        7       /* for NEWADDR, broadcast or p-p dest addr */
288
#define RTAX_MAX        8       /* size of array to allocate */
289
 
290
struct rt_addrinfo {
291
        int     rti_addrs;
292
        struct  sockaddr *rti_info[RTAX_MAX];
293
};
294
 
295
struct route_cb {
296
        int     ip_count;
297
        int     ip6_count;
298
        int     ns_count;
299
        int     iso_count;
300
        int     any_count;
301
};
302
 
303
/*
304
 * This structure, and the prototypes for the rt_timer_{init,remove_all,
305
 * add,timer} functions all used with the kind permission of BSDI.
306
 * These allow functions to be called for routes at specific times.
307
 */
308
 
309
struct rttimer {
310
        TAILQ_ENTRY(rttimer)    rtt_next;  /* entry on timer queue */
311
        LIST_ENTRY(rttimer)     rtt_link;  /* multiple timers per rtentry */
312
        struct rttimer_queue    *rtt_queue;/* back pointer to queue */
313
        struct rtentry          *rtt_rt;   /* Back pointer to the route */
314
        void                    (*rtt_func) __P((struct rtentry *,
315
                                                 struct rttimer *));
316
        time_t                  rtt_time; /* When this timer was registered */
317
};
318
 
319
struct rttimer_queue {
320
        long                            rtq_timeout;
321
        TAILQ_HEAD(, rttimer)           rtq_head;
322
        LIST_ENTRY(rttimer_queue)       rtq_link;
323
};
324
 
325
#ifdef _KERNEL
326
#define RTFREE(rt) do { \
327
        if ((rt)->rt_refcnt <= 1) \
328
                rtfree(rt); \
329
        else \
330
                (rt)->rt_refcnt--; \
331
} while (0)
332
 
333
/*
334
 * Values for additional argument to rtalloc_noclone() and rtalloc2()
335
 */
336
#define ALL_CLONING 0
337
#define ONNET_CLONING 1
338
#define NO_CLONING 2
339
 
340
struct  route_cb route_cb;
341
struct  rtstat  rtstat;
342
struct  radix_node_head *rt_tables[AF_MAX+1];
343
 
344
struct  socket;
345
void     route_init __P((void));
346
int      route_output __P((struct mbuf *, ...));
347
int      route_usrreq __P((struct socket *, int, struct mbuf *,
348
                           struct mbuf *, struct mbuf *));
349
void     rt_ifmsg __P((struct ifnet *));
350
void     rt_maskedcopy __P((struct sockaddr *,
351
            struct sockaddr *, struct sockaddr *));
352
void     rt_missmsg __P((int, struct rt_addrinfo *, int, int));
353
void     rt_newaddrmsg __P((int, struct ifaddr *, int, struct rtentry *));
354
int      rt_setgate __P((struct rtentry *, struct sockaddr *,
355
                         struct sockaddr *));
356
void     rt_setmetrics __P((u_long, struct rt_metrics *, struct rt_metrics *));
357
int      rt_timer_add __P((struct rtentry *,
358
             void(*)(struct rtentry *, struct rttimer *),
359
             struct rttimer_queue *));
360
void     rt_timer_init __P((void));
361
struct rttimer_queue *
362
         rt_timer_queue_create __P((u_int));
363
void     rt_timer_queue_change __P((struct rttimer_queue *, long));
364
void     rt_timer_queue_destroy __P((struct rttimer_queue *, int));
365
void     rt_timer_remove_all __P((struct rtentry *));
366
void     rt_timer_timer __P((void *));
367
void     rtable_init __P((void **));
368
void     rtalloc __P((struct route *));
369
struct rtentry *
370
         rtalloc1 __P((struct sockaddr *, int));
371
void     rtalloc_noclone __P((struct route *, int));
372
struct rtentry *
373
         rtalloc2 __P((struct sockaddr *, int, int));
374
void     rtfree __P((struct rtentry *));
375
int      rtinit __P((struct ifaddr *, int, int));
376
int      rtioctl __P((u_long, caddr_t, struct proc *));
377
void     rtredirect __P((struct sockaddr *, struct sockaddr *,
378
                         struct sockaddr *, int, struct sockaddr *,
379
                         struct rtentry **));
380
int      rtrequest __P((int, struct sockaddr *,
381
                        struct sockaddr *, struct sockaddr *, int,
382
                        struct rtentry **));
383
void     ipv4_tunnelsetup __P((struct rtentry *));
384
#endif /* _KERNEL */
385
 
386
#endif // _NET_ROUTE_H_

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.