]> git.karo-electronics.de Git - karo-tx-redboot.git/blob - packages/io/fileio/v2_0/include/sockio.h
Initial revision
[karo-tx-redboot.git] / packages / io / fileio / v2_0 / include / sockio.h
1 #ifndef CYGONCE_SOCKIO_H
2 #define CYGONCE_SOCKIO_H
3 //=============================================================================
4 //
5 //      sockio.h
6 //
7 //      Socket IO header
8 //
9 //=============================================================================
10 //####ECOSGPLCOPYRIGHTBEGIN####
11 // -------------------------------------------
12 // This file is part of eCos, the Embedded Configurable Operating System.
13 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
14 //
15 // eCos is free software; you can redistribute it and/or modify it under
16 // the terms of the GNU General Public License as published by the Free
17 // Software Foundation; either version 2 or (at your option) any later version.
18 //
19 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
20 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
22 // for more details.
23 //
24 // You should have received a copy of the GNU General Public License along
25 // with eCos; if not, write to the Free Software Foundation, Inc.,
26 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27 //
28 // As a special exception, if other files instantiate templates or use macros
29 // or inline functions from this file, or you compile this file and link it
30 // with other works to produce a work based on this file, this file does not
31 // by itself cause the resulting work to be covered by the GNU General Public
32 // License. However the source code for this file must still be made available
33 // in accordance with section (3) of the GNU General Public License.
34 //
35 // This exception does not invalidate any other reasons why a work based on
36 // this file might be covered by the GNU General Public License.
37 //
38 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
39 // at http://sources.redhat.com/ecos/ecos-license/
40 // -------------------------------------------
41 //####ECOSGPLCOPYRIGHTEND####
42 //=============================================================================
43 //#####DESCRIPTIONBEGIN####
44 //
45 // Author(s):     nickg
46 // Contributors:  nickg
47 // Date:          2000-05-25
48 // Purpose:       Socket IO header
49 // Description:   This header contains the external definitions of the general
50 //                socket IO subsystem for POSIX and EL/IX compatability.
51 //              
52 // Usage:
53 //              #include <sockio.h>
54 //              ...
55 //              
56 //
57 //####DESCRIPTIONEND####
58 //
59 //=============================================================================
60
61 #include <pkgconf/hal.h>
62 #include <pkgconf/io_fileio.h>
63
64 #include <cyg/infra/cyg_type.h>
65
66 #include <stddef.h>             // NULL, size_t
67 #include <limits.h>
68 #include <sys/types.h>
69
70 #include <cyg/fileio/fileio.h>
71
72 //=============================================================================
73 // Forward definitions
74
75 struct cyg_nstab_entry;
76 typedef struct cyg_nstab_entry cyg_nstab_entry;
77
78 struct cyg_sock_ops;
79 typedef struct cyg_sock_ops cyg_sock_ops;
80
81 struct sockaddr;
82 typedef struct sockaddr sockaddr;
83
84 struct msghdr;
85 typedef struct msghdr msghdr;
86
87 #ifndef CYGPKG_NET
88
89 typedef cyg_uint32      socklen_t;      /* length type for network syscalls */
90
91 #endif
92
93 //=============================================================================
94 // network stack entry
95
96 struct cyg_nstab_entry
97 {
98     cyg_bool            valid;          // true if stack initialized
99     cyg_uint32          syncmode;       // synchronization protocol
100     char                *name;          // stack name
101     char                *devname;       // hardware device name
102     CYG_ADDRWORD        data;           // private data value
103
104     int     (*init)( cyg_nstab_entry *nste );
105     int     (*socket)( cyg_nstab_entry *nste, int domain, int type,
106                        int protocol, cyg_file *file );
107 } CYG_HAL_TABLE_TYPE;
108
109 #define NSTAB_ENTRY( _l, _syncmode, _name, _devname, _data, _init, _socket )    \
110 struct cyg_nstab_entry _l CYG_HAL_TABLE_ENTRY(nstab) =                          \
111 {                                                                               \
112     false,                                                                      \
113     _syncmode,                                                                  \
114     _name,                                                                      \
115     _devname,                                                                   \
116     _data,                                                                      \
117     _init,                                                                      \
118     _socket                                                                     \
119 };
120
121 //=============================================================================
122
123 struct cyg_sock_ops
124 {
125     int (*bind)      ( cyg_file *fp, const sockaddr *sa, socklen_t len );
126     int (*connect)   ( cyg_file *fp, const sockaddr *sa, socklen_t len );
127     int (*accept)    ( cyg_file *fp, cyg_file *new_fp,
128                        struct sockaddr *name, socklen_t *anamelen );
129     int (*listen)    ( cyg_file *fp, int len );
130     int (*getname)   ( cyg_file *fp, sockaddr *sa, socklen_t *len, int peer );
131     int (*shutdown)  ( cyg_file *fp, int flags );
132     int (*getsockopt)( cyg_file *fp, int level, int optname,
133                        void *optval, socklen_t *optlen);
134     int (*setsockopt)( cyg_file *fp, int level, int optname,
135                        const void *optval, socklen_t optlen);
136     int (*sendmsg)   ( cyg_file *fp, const struct msghdr *m,
137                        int flags, ssize_t *retsize );
138     int (*recvmsg)   ( cyg_file *fp, struct msghdr *m,
139                        socklen_t *namelen, ssize_t *retsize );
140 };
141
142 //-----------------------------------------------------------------------------
143 #endif // ifndef CYGONCE_SOCKIO_H
144 // End of sockio.h