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