1 <!-- Copyright (C) 2003 Red Hat, Inc. -->
2 <!-- This material may be distributed only subject to the terms -->
3 <!-- and conditions set forth in the Open Publication License, v1.0 -->
4 <!-- or later (the latest version is presently available at -->
5 <!-- http://www.opencontent.org/openpub/). -->
6 <!-- Distribution of the work or derivative of the work in any -->
7 <!-- standard (paper) book form is prohibited unless prior -->
8 <!-- permission is obtained from the copyright holder. -->
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="eCos Reference Manual"
20 HREF="ecos-ref.html"><LINK
22 TITLE="File System Support Infrastructure"
23 HREF="fileio.html"><LINK
25 TITLE="Initialization and Mounting"
26 HREF="fileio-mounting.html"><LINK
29 HREF="fileio-select.html"></HEAD
40 SUMMARY="Header navigation table"
49 >eCos Reference Manual</TH
57 HREF="fileio-mounting.html"
71 HREF="fileio-select.html"
84 NAME="FILEIO-SOCKETS">Chapter 26. Sockets</H1
86 >If a network stack is present, then the FILEIO infrastructure also
87 provides access to the standard BSD socket calls.</P
89 >The netstack table contains entries which describe the network
90 protocol stacks that are in the system image. Each resident stack
91 should export an entry to this table using the
97 >Each table entry has the following structure:</P
105 CLASS="PROGRAMLISTING"
106 >struct cyg_nstab_entry
108 cyg_bool valid; // true if stack initialized
109 cyg_uint32 syncmode; // synchronization protocol
110 char *name; // stack name
111 char *devname; // hardware device name
112 CYG_ADDRWORD data; // private data value
114 int (*init)( cyg_nstab_entry *nste );
115 int (*socket)( cyg_nstab_entry *nste, int domain, int type,
116 int protocol, cyg_file *file );
122 >This table is analogous to a combination of the filesystem and mount
138 function returned successfully and the
147 >CYG_SYNCMODE_SOCK_*</TT
148 > bits described above.</P
155 > field contains the name of the
163 > field names the device that the stack is using. This may
164 reference a device under "/dev", or may be a name that is only
165 meaningful to the stack itself.</P
170 > function pointer is called during
171 system initialization to start the protocol stack running. If it
172 returns non-zero the <TT
178 false and the stack will be ignored subsequently.</P
183 > function is called to attempt to create a socket in the
187 > API function is called the netstack table is
188 scanned and for each valid entry the <TT
192 function pointer is called. If
193 this returns non-zero then the scan continues to the next valid stack,
194 or terminates with an error if the end of the table is reached.</P
196 >The result of a successful socket call is an initialized file object
202 > field pointing to the
203 following structure:</P
211 CLASS="PROGRAMLISTING"
214 int (*bind) ( cyg_file *fp, const sockaddr *sa, socklen_t len );
215 int (*connect) ( cyg_file *fp, const sockaddr *sa, socklen_t len );
216 int (*accept) ( cyg_file *fp, cyg_file *new_fp,
217 struct sockaddr *name, socklen_t *anamelen );
218 int (*listen) ( cyg_file *fp, int len );
219 int (*getname) ( cyg_file *fp, sockaddr *sa, socklen_t *len, int peer );
220 int (*shutdown) ( cyg_file *fp, int flags );
221 int (*getsockopt)( cyg_file *fp, int level, int optname,
222 void *optval, socklen_t *optlen);
223 int (*setsockopt)( cyg_file *fp, int level, int optname,
224 const void *optval, socklen_t optlen);
225 int (*sendmsg) ( cyg_file *fp, const struct msghdr *m,
226 int flags, ssize_t *retsize );
227 int (*recvmsg) ( cyg_file *fp, struct msghdr *m,
228 socklen_t *namelen, ssize_t *retsize );
234 >It should be obvious from the names of these functions which API calls
235 they provide support for. The <TT
239 pointer provides support for both <TT
254 function pointers provide support for <TT
282 SUMMARY="Footer navigation table"
293 HREF="fileio-mounting.html"
311 HREF="fileio-select.html"
321 >Initialization and Mounting</TD