1 #ifndef CYGONCE_SOCKIO_H
2 #define CYGONCE_SOCKIO_H
3 //=============================================================================
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.
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.
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
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.
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.
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.
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####
46 // Contributors: nickg
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.
53 // #include <sockio.h>
57 //####DESCRIPTIONEND####
59 //=============================================================================
61 #include <pkgconf/hal.h>
62 #include <pkgconf/io_fileio.h>
64 #include <cyg/infra/cyg_type.h>
66 #include <stddef.h> // NULL, size_t
68 #include <sys/types.h>
70 #include <cyg/fileio/fileio.h>
72 //=============================================================================
73 // Forward definitions
75 struct cyg_nstab_entry;
76 typedef struct cyg_nstab_entry cyg_nstab_entry;
79 typedef struct cyg_sock_ops cyg_sock_ops;
82 typedef struct sockaddr sockaddr;
85 typedef struct msghdr msghdr;
89 typedef cyg_uint32 socklen_t; /* length type for network syscalls */
93 //=============================================================================
94 // network stack entry
96 struct cyg_nstab_entry
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
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;
109 #define NSTAB_ENTRY( _l, _syncmode, _name, _devname, _data, _init, _socket ) \
110 struct cyg_nstab_entry _l CYG_HAL_TABLE_ENTRY(nstab) = \
121 //=============================================================================
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 );
142 //-----------------------------------------------------------------------------
143 #endif // ifndef CYGONCE_SOCKIO_H