1 |
27 |
unneback |
#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/kernel.h>
|
63 |
|
|
#include <pkgconf/io_fileio.h>
|
64 |
|
|
|
65 |
|
|
#include <cyg/infra/cyg_type.h>
|
66 |
|
|
|
67 |
|
|
#include <stddef.h> // NULL, size_t
|
68 |
|
|
#include <limits.h>
|
69 |
|
|
#include <sys/types.h>
|
70 |
|
|
|
71 |
|
|
#include <cyg/fileio/fileio.h>
|
72 |
|
|
|
73 |
|
|
//=============================================================================
|
74 |
|
|
// Forward definitions
|
75 |
|
|
|
76 |
|
|
struct cyg_nstab_entry;
|
77 |
|
|
typedef struct cyg_nstab_entry cyg_nstab_entry;
|
78 |
|
|
|
79 |
|
|
struct cyg_sock_ops;
|
80 |
|
|
typedef struct cyg_sock_ops cyg_sock_ops;
|
81 |
|
|
|
82 |
|
|
struct sockaddr;
|
83 |
|
|
typedef struct sockaddr sockaddr;
|
84 |
|
|
|
85 |
|
|
struct msghdr;
|
86 |
|
|
typedef struct msghdr msghdr;
|
87 |
|
|
|
88 |
|
|
#ifndef CYGPKG_NET
|
89 |
|
|
|
90 |
|
|
typedef cyg_uint32 socklen_t; /* length type for network syscalls */
|
91 |
|
|
|
92 |
|
|
#endif
|
93 |
|
|
|
94 |
|
|
//=============================================================================
|
95 |
|
|
// network stack entry
|
96 |
|
|
|
97 |
|
|
struct cyg_nstab_entry
|
98 |
|
|
{
|
99 |
|
|
cyg_bool valid; // true if stack initialized
|
100 |
|
|
cyg_uint32 syncmode; // synchronization protocol
|
101 |
|
|
char *name; // stack name
|
102 |
|
|
char *devname; // hardware device name
|
103 |
|
|
CYG_ADDRWORD data; // private data value
|
104 |
|
|
|
105 |
|
|
int (*init)( cyg_nstab_entry *nste );
|
106 |
|
|
int (*socket)( cyg_nstab_entry *nste, int domain, int type,
|
107 |
|
|
int protocol, cyg_file *file );
|
108 |
|
|
} CYG_HAL_TABLE_TYPE;
|
109 |
|
|
|
110 |
|
|
#define NSTAB_ENTRY( _l, _syncmode, _name, _devname, _data, _init, _socket ) \
|
111 |
|
|
struct cyg_nstab_entry _l CYG_HAL_TABLE_ENTRY(nstab) = \
|
112 |
|
|
{ \
|
113 |
|
|
false, \
|
114 |
|
|
_syncmode, \
|
115 |
|
|
_name, \
|
116 |
|
|
_devname, \
|
117 |
|
|
_data, \
|
118 |
|
|
_init, \
|
119 |
|
|
_socket \
|
120 |
|
|
};
|
121 |
|
|
|
122 |
|
|
//=============================================================================
|
123 |
|
|
|
124 |
|
|
struct cyg_sock_ops
|
125 |
|
|
{
|
126 |
|
|
int (*bind) ( cyg_file *fp, const sockaddr *sa, socklen_t len );
|
127 |
|
|
int (*connect) ( cyg_file *fp, const sockaddr *sa, socklen_t len );
|
128 |
|
|
int (*accept) ( cyg_file *fp, cyg_file *new_fp,
|
129 |
|
|
struct sockaddr *name, socklen_t *anamelen );
|
130 |
|
|
int (*listen) ( cyg_file *fp, int len );
|
131 |
|
|
int (*getname) ( cyg_file *fp, sockaddr *sa, socklen_t *len, int peer );
|
132 |
|
|
int (*shutdown) ( cyg_file *fp, int flags );
|
133 |
|
|
int (*getsockopt)( cyg_file *fp, int level, int optname,
|
134 |
|
|
void *optval, socklen_t *optlen);
|
135 |
|
|
int (*setsockopt)( cyg_file *fp, int level, int optname,
|
136 |
|
|
const void *optval, socklen_t optlen);
|
137 |
|
|
int (*sendmsg) ( cyg_file *fp, const struct msghdr *m,
|
138 |
|
|
int flags, ssize_t *retsize );
|
139 |
|
|
int (*recvmsg) ( cyg_file *fp, struct msghdr *m,
|
140 |
|
|
socklen_t *namelen, ssize_t *retsize );
|
141 |
|
|
};
|
142 |
|
|
|
143 |
|
|
//-----------------------------------------------------------------------------
|
144 |
|
|
#endif // ifndef CYGONCE_SOCKIO_H
|
145 |
|
|
// End of sockio.h
|