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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [bsd_tcpip/] [current/] [include/] [sys/] [protosw.h] - Blame information for rev 808

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

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      include/sys/protosw.h
4
//
5
//==========================================================================
6
// ####BSDCOPYRIGHTBEGIN####                                    
7
// -------------------------------------------                  
8
// This file is part of eCos, the Embedded Configurable Operating System.
9
//
10
// Portions of this software may have been derived from FreeBSD 
11
// or other sources, and if so are covered by the appropriate copyright
12
// and license included herein.                                 
13
//
14
// Portions created by the Free Software Foundation are         
15
// Copyright (C) 2002 Free Software Foundation, Inc.            
16
// -------------------------------------------                  
17
// ####BSDCOPYRIGHTEND####                                      
18
//==========================================================================
19
 
20
/*-
21
 * Copyright (c) 1982, 1986, 1993
22
 *      The Regents of the University of California.  All rights reserved.
23
 *
24
 * Redistribution and use in source and binary forms, with or without
25
 * modification, are permitted provided that the following conditions
26
 * are met:
27
 * 1. Redistributions of source code must retain the above copyright
28
 *    notice, this list of conditions and the following disclaimer.
29
 * 2. Redistributions in binary form must reproduce the above copyright
30
 *    notice, this list of conditions and the following disclaimer in the
31
 *    documentation and/or other materials provided with the distribution.
32
 * 3. All advertising materials mentioning features or use of this software
33
 *    must display the following acknowledgement:
34
 *      This product includes software developed by the University of
35
 *      California, Berkeley and its contributors.
36
 * 4. Neither the name of the University nor the names of its contributors
37
 *    may be used to endorse or promote products derived from this software
38
 *    without specific prior written permission.
39
 *
40
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
41
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
44
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
45
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
46
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
48
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
49
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50
 * SUCH DAMAGE.
51
 *
52
 *      @(#)protosw.h   8.1 (Berkeley) 6/2/93
53
 * $FreeBSD: src/sys/sys/protosw.h,v 1.28.2.2 2001/07/03 11:02:01 ume Exp $
54
 */
55
 
56
#ifndef _SYS_PROTOSW_H_
57
#define _SYS_PROTOSW_H_
58
 
59
/* Forward declare these structures referenced from prototypes below. */
60
struct mbuf;
61
struct proc;
62
struct sockaddr;
63
struct socket;
64
struct sockopt;
65
 
66
/*#ifdef _KERNEL*/
67
/*
68
 * Protocol switch table.
69
 *
70
 * Each protocol has a handle initializing one of these structures,
71
 * which is used for protocol-protocol and system-protocol communication.
72
 *
73
 * A protocol is called through the pr_init entry before any other.
74
 * Thereafter it is called every 200ms through the pr_fasttimo entry and
75
 * every 500ms through the pr_slowtimo for timer based actions.
76
 * The system will call the pr_drain entry if it is low on space and
77
 * this should throw away any non-critical data.
78
 *
79
 * Protocols pass data between themselves as chains of mbufs using
80
 * the pr_input and pr_output hooks.  Pr_input passes data up (towards
81
 * the users) and pr_output passes it down (towards the interfaces); control
82
 * information passes up and down on pr_ctlinput and pr_ctloutput.
83
 * The protocol is responsible for the space occupied by any the
84
 * arguments to these entries and must dispose it.
85
 *
86
 * In retrospect, it would be a lot nicer to use an interface
87
 * similar to the vnode VOP interface.
88
 */
89
struct protosw {
90
        short   pr_type;                /* socket type used for */
91
        struct  domain *pr_domain;      /* domain protocol a member of */
92
        short   pr_protocol;            /* protocol number */
93
        short   pr_flags;               /* see below */
94
/* protocol-protocol hooks */
95
        void    (*pr_input) __P((struct mbuf *, int len));
96
                                        /* input to protocol (from below) */
97
        int     (*pr_output)    __P((struct mbuf *m, struct socket *so));
98
                                        /* output to protocol (from above) */
99
        void    (*pr_ctlinput)__P((int, struct sockaddr *, void *));
100
                                        /* control input (from below) */
101
        int     (*pr_ctloutput)__P((struct socket *, struct sockopt *));
102
                                        /* control output (from above) */
103
/* user-protocol hook */
104
        void    *pr_ousrreq;
105
/* utility hooks */
106
        void    (*pr_init) __P((void)); /* initialization hook */
107
        void    (*pr_fasttimo) __P((void));
108
                                        /* fast timeout (200ms) */
109
        void    (*pr_slowtimo) __P((void));
110
                                        /* slow timeout (500ms) */
111
        void    (*pr_drain) __P((void));
112
                                        /* flush any excess space possible */
113
        struct  pr_usrreqs *pr_usrreqs; /* supersedes pr_usrreq() */
114
};
115
/*#endif*/
116
 
117
#define PR_SLOWHZ       2               /* 2 slow timeouts per second */
118
#define PR_FASTHZ       5               /* 5 fast timeouts per second */
119
 
120
/*
121
 * Values for pr_flags.
122
 * PR_ADDR requires PR_ATOMIC;
123
 * PR_ADDR and PR_CONNREQUIRED are mutually exclusive.
124
 * PR_IMPLOPCL means that the protocol allows sendto without prior connect,
125
 *      and the protocol understands the MSG_EOF flag.  The first property is
126
 *      is only relevant if PR_CONNREQUIRED is set (otherwise sendto is allowed
127
 *      anyhow).
128
 */
129
#define PR_ATOMIC       0x01            /* exchange atomic messages only */
130
#define PR_ADDR         0x02            /* addresses given with messages */
131
#define PR_CONNREQUIRED 0x04            /* connection required by protocol */
132
#define PR_WANTRCVD     0x08            /* want PRU_RCVD calls */
133
#define PR_RIGHTS       0x10            /* passes capabilities */
134
#define PR_IMPLOPCL     0x20            /* implied open/close */
135
#define PR_LASTHDR      0x40            /* enforce ipsec policy; last header */
136
 
137
/*
138
 * The arguments to usrreq are:
139
 *      (*protosw[].pr_usrreq)(up, req, m, nam, opt);
140
 * where up is a (struct socket *), req is one of these requests,
141
 * m is a optional mbuf chain containing a message,
142
 * nam is an optional mbuf chain containing an address,
143
 * and opt is a pointer to a socketopt structure or nil.
144
 * The protocol is responsible for disposal of the mbuf chain m,
145
 * the caller is responsible for any space held by nam and opt.
146
 * A non-zero return from usrreq gives an
147
 * UNIX error number which should be passed to higher level software.
148
 */
149
#define PRU_ATTACH              0        /* attach protocol to up */
150
#define PRU_DETACH              1       /* detach protocol from up */
151
#define PRU_BIND                2       /* bind socket to address */
152
#define PRU_LISTEN              3       /* listen for connection */
153
#define PRU_CONNECT             4       /* establish connection to peer */
154
#define PRU_ACCEPT              5       /* accept connection from peer */
155
#define PRU_DISCONNECT          6       /* disconnect from peer */
156
#define PRU_SHUTDOWN            7       /* won't send any more data */
157
#define PRU_RCVD                8       /* have taken data; more room now */
158
#define PRU_SEND                9       /* send this data */
159
#define PRU_ABORT               10      /* abort (fast DISCONNECT, DETATCH) */
160
#define PRU_CONTROL             11      /* control operations on protocol */
161
#define PRU_SENSE               12      /* return status into m */
162
#define PRU_RCVOOB              13      /* retrieve out of band data */
163
#define PRU_SENDOOB             14      /* send out of band data */
164
#define PRU_SOCKADDR            15      /* fetch socket's address */
165
#define PRU_PEERADDR            16      /* fetch peer's address */
166
#define PRU_CONNECT2            17      /* connect two sockets */
167
/* begin for protocols internal use */
168
#define PRU_FASTTIMO            18      /* 200ms timeout */
169
#define PRU_SLOWTIMO            19      /* 500ms timeout */
170
#define PRU_PROTORCV            20      /* receive from below */
171
#define PRU_PROTOSEND           21      /* send to below */
172
/* end for protocol's internal use */
173
#define PRU_SEND_EOF            22      /* send and close */
174
#define PRU_NREQ                22
175
 
176
#ifdef PRUREQUESTS
177
char *prurequests[] = {
178
        "ATTACH",       "DETACH",       "BIND",         "LISTEN",
179
        "CONNECT",      "ACCEPT",       "DISCONNECT",   "SHUTDOWN",
180
        "RCVD",         "SEND",         "ABORT",        "CONTROL",
181
        "SENSE",        "RCVOOB",       "SENDOOB",      "SOCKADDR",
182
        "PEERADDR",     "CONNECT2",     "FASTTIMO",     "SLOWTIMO",
183
        "PROTORCV",     "PROTOSEND",
184
        "SEND_EOF",
185
};
186
#endif
187
 
188
#ifdef  _KERNEL                 /* users shouldn't see this decl */
189
 
190
struct ifnet;
191
struct stat;
192
struct ucred;
193
struct uio;
194
 
195
/*
196
 * If the ordering here looks odd, that's because it's alphabetical.
197
 * Having this structure separated out from the main protoswitch is allegedly
198
 * a big (12 cycles per call) lose on high-end CPUs.  We will eventually
199
 * migrate this stuff back into the main structure.
200
 */
201
struct pr_usrreqs {
202
        int     (*pru_abort) __P((struct socket *so));
203
        int     (*pru_accept) __P((struct socket *so, struct sockaddr **nam));
204
        int     (*pru_attach) __P((struct socket *so, int proto,
205
                                   struct proc *p));
206
        int     (*pru_bind) __P((struct socket *so, struct sockaddr *nam,
207
                                 struct proc *p));
208
        int     (*pru_connect) __P((struct socket *so, struct sockaddr *nam,
209
                                    struct proc *p));
210
        int     (*pru_connect2) __P((struct socket *so1, struct socket *so2));
211
        int     (*pru_control) __P((struct socket *so, u_long cmd, caddr_t data,
212
                                    struct ifnet *ifp, struct proc *p));
213
        int     (*pru_detach) __P((struct socket *so));
214
        int     (*pru_disconnect) __P((struct socket *so));
215
        int     (*pru_listen) __P((struct socket *so, struct proc *p));
216
        int     (*pru_peeraddr) __P((struct socket *so,
217
                                     struct sockaddr **nam));
218
        int     (*pru_rcvd) __P((struct socket *so, int flags));
219
        int     (*pru_rcvoob) __P((struct socket *so, struct mbuf *m,
220
                                   int flags));
221
        int     (*pru_send) __P((struct socket *so, int flags, struct mbuf *m,
222
                                 struct sockaddr *addr, struct mbuf *control,
223
                                 struct proc *p));
224
#define PRUS_OOB        0x1
225
#define PRUS_EOF        0x2
226
#define PRUS_MORETOCOME 0x4
227
        int     (*pru_sense) __P((struct socket *so, struct stat *sb));
228
        int     (*pru_shutdown) __P((struct socket *so));
229
        int     (*pru_sockaddr) __P((struct socket *so,
230
                                     struct sockaddr **nam));
231
 
232
        /*
233
         * These three added later, so they are out of order.  They are used
234
         * for shortcutting (fast path input/output) in some protocols.
235
         * XXX - that's a lie, they are not implemented yet
236
         * Rather than calling sosend() etc. directly, calls are made
237
         * through these entry points.  For protocols which still use
238
         * the generic code, these just point to those routines.
239
         */
240
        int     (*pru_sosend) __P((struct socket *so, struct sockaddr *addr,
241
                                   struct uio *uio, struct mbuf *top,
242
                                   struct mbuf *control, int flags,
243
                                   struct proc *p));
244
        int     (*pru_soreceive) __P((struct socket *so,
245
                                      struct sockaddr **paddr,
246
                                      struct uio *uio, struct mbuf **mp0,
247
                                      struct mbuf **controlp, int *flagsp));
248
        int     (*pru_sopoll) __P((struct socket *so, int events,
249
                                     struct ucred *cred, struct proc *p));
250
};
251
 
252
int     pru_accept_notsupp __P((struct socket *so, struct sockaddr **nam));
253
int     pru_connect_notsupp __P((struct socket *so, struct sockaddr *nam,
254
                                 struct proc *p));
255
int     pru_connect2_notsupp __P((struct socket *so1, struct socket *so2));
256
int     pru_control_notsupp __P((struct socket *so, u_long cmd, caddr_t data,
257
                                 struct ifnet *ifp, struct proc *p));
258
int     pru_listen_notsupp __P((struct socket *so, struct proc *p));
259
int     pru_rcvd_notsupp __P((struct socket *so, int flags));
260
int     pru_rcvoob_notsupp __P((struct socket *so, struct mbuf *m, int flags));
261
int     pru_sense_null __P((struct socket *so, struct stat *sb));
262
 
263
#endif /* _KERNEL */
264
 
265
/*
266
 * The arguments to the ctlinput routine are
267
 *      (*protosw[].pr_ctlinput)(cmd, sa, arg);
268
 * where cmd is one of the commands below, sa is a pointer to a sockaddr,
269
 * and arg is a `void *' argument used within a protocol family.
270
 */
271
#define PRC_IFDOWN              0        /* interface transition */
272
#define PRC_ROUTEDEAD           1       /* select new route if possible ??? */
273
#define PRC_IFUP                2       /* interface has come back up */
274
#define PRC_QUENCH2             3       /* DEC congestion bit says slow down */
275
#define PRC_QUENCH              4       /* some one said to slow down */
276
#define PRC_MSGSIZE             5       /* message size forced drop */
277
#define PRC_HOSTDEAD            6       /* host appears to be down */
278
#define PRC_HOSTUNREACH         7       /* deprecated (use PRC_UNREACH_HOST) */
279
#define PRC_UNREACH_NET         8       /* no route to network */
280
#define PRC_UNREACH_HOST        9       /* no route to host */
281
#define PRC_UNREACH_PROTOCOL    10      /* dst says bad protocol */
282
#define PRC_UNREACH_PORT        11      /* bad port # */
283
/* was  PRC_UNREACH_NEEDFRAG    12         (use PRC_MSGSIZE) */
284
#define PRC_UNREACH_SRCFAIL     13      /* source route failed */
285
#define PRC_REDIRECT_NET        14      /* net routing redirect */
286
#define PRC_REDIRECT_HOST       15      /* host routing redirect */
287
#define PRC_REDIRECT_TOSNET     16      /* redirect for type of service & net */
288
#define PRC_REDIRECT_TOSHOST    17      /* redirect for tos & host */
289
#define PRC_TIMXCEED_INTRANS    18      /* packet lifetime expired in transit */
290
#define PRC_TIMXCEED_REASS      19      /* lifetime expired on reass q */
291
#define PRC_PARAMPROB           20      /* header incorrect */
292
#define PRC_UNREACH_ADMIN_PROHIB        21      /* packet administrativly prohibited */
293
 
294
#define PRC_NCMDS               22
295
 
296
#define PRC_IS_REDIRECT(cmd)    \
297
        ((cmd) >= PRC_REDIRECT_NET && (cmd) <= PRC_REDIRECT_TOSHOST)
298
 
299
#ifdef PRCREQUESTS
300
char    *prcrequests[] = {
301
        "IFDOWN", "ROUTEDEAD", "IFUP", "DEC-BIT-QUENCH2",
302
        "QUENCH", "MSGSIZE", "HOSTDEAD", "#7",
303
        "NET-UNREACH", "HOST-UNREACH", "PROTO-UNREACH", "PORT-UNREACH",
304
        "#12", "SRCFAIL-UNREACH", "NET-REDIRECT", "HOST-REDIRECT",
305
        "TOSNET-REDIRECT", "TOSHOST-REDIRECT", "TX-INTRANS", "TX-REASS",
306
        "PARAMPROB", "ADMIN-UNREACH"
307
};
308
#endif
309
 
310
/*
311
 * The arguments to ctloutput are:
312
 *      (*protosw[].pr_ctloutput)(req, so, level, optname, optval, p);
313
 * req is one of the actions listed below, so is a (struct socket *),
314
 * level is an indication of which protocol layer the option is intended.
315
 * optname is a protocol dependent socket option request,
316
 * optval is a pointer to a mbuf-chain pointer, for value-return results.
317
 * The protocol is responsible for disposal of the mbuf chain *optval
318
 * if supplied,
319
 * the caller is responsible for any space held by *optval, when returned.
320
 * A non-zero return from usrreq gives an
321
 * UNIX error number which should be passed to higher level software.
322
 */
323
#define PRCO_GETOPT     0
324
#define PRCO_SETOPT     1
325
 
326
#define PRCO_NCMDS      2
327
 
328
#ifdef PRCOREQUESTS
329
char    *prcorequests[] = {
330
        "GETOPT", "SETOPT",
331
};
332
#endif
333
 
334
#ifdef _KERNEL
335
void    pfctlinput __P((int, struct sockaddr *));
336
void    pfctlinput2 __P((int, struct sockaddr *, void *));
337
struct protosw *pffindproto __P((int family, int protocol, int type));
338
struct protosw *pffindtype __P((int family, int type));
339
#endif
340
 
341
#endif

powered by: WebSVN 2.1.0

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