#include <SocketInternals.h>\r
\r
\r
+/**\r
+ File system interface for the socket layer.\r
+\r
+ This data structure defines the routines for the various\r
+ file system functions associated with the socket layer.\r
+**/\r
const struct fileops SocketOperations = {\r
BslSocketClose, // close\r
BslSocketRead, // read\r
address for the file\r
@param [in] pErrno Address of the errno variable\r
\r
- @return A pointer to the socket protocol structure or NULL if\r
+ @return A pointer to the EFI_SOCKET_PROTOCOL structure or NULL if\r
an invalid file descriptor was passed in.\r
\r
**/\r
//\r
// Get the descriptor for the file\r
//\r
- pDescriptor = &gMD->fdarray [ s ];\r
+ pDescriptor = &gMD->fdarray[ s ];\r
\r
//\r
// Validate that the descriptor is associated with sockets\r
// Locate a file descriptor\r
//\r
FileDescriptor = FindFreeFD ( VALID_CLOSED );\r
- if( FileDescriptor < 0 ) {\r
+ if ( FileDescriptor < 0 ) {\r
//\r
// All available FDs are in use\r
//\r
//\r
// Initialize the file descriptor\r
//\r
- pDescriptor = &gMD->fdarray [ FileDescriptor ];\r
+ pDescriptor = &gMD->fdarray[ FileDescriptor ];\r
pDescriptor->f_offset = 0;\r
pDescriptor->f_flag = 0;\r
pDescriptor->f_iflags = DTYPE_SOCKET;\r
pDescriptor->MyFD = (UINT16)FileDescriptor;\r
- pDescriptor->Oflags = 0;\r
+ pDescriptor->Oflags = O_RDWR;\r
pDescriptor->Omode = S_ACC_READ | S_ACC_WRITE;\r
pDescriptor->RefCount = 1;\r
FILE_SET_MATURE ( pDescriptor );\r
/**\r
Creates an endpoint for network communication.\r
\r
- The ::Socket routine initializes the communication endpoint by providing\r
- the support for the socket library function ::socket. The\r
+ The socket routine initializes the communication endpoint and returns a\r
+ file descriptor.\r
+\r
+ The\r
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/socket.html">POSIX</a>\r
- documentation for the socket routine is available online for reference.\r
+ documentation is available online.\r
\r
@param [in] domain Select the family of protocols for the client or server\r
- application.\r
+ application. The supported values are:\r
+ <ul>\r
+ <li>AF_INET - Version 4 UEFI network stack</li>\r
+ </ul>\r
\r
@param [in] type Specifies how to make the network connection. The following values\r
are supported:\r
<ul>\r
<li>\r
- SOCK_STREAM - Connect to TCP, provides a byte stream\r
- that is manipluated by read, recv, send and write.\r
+ SOCK_DGRAM - Connect to UDP, provides a datagram service that is\r
+ manipulated by recvfrom and sendto.\r
</li>\r
<li>\r
- SOCK_SEQPACKET - Connect to TCP, provides sequenced packet stream\r
- that is manipulated by read, recv, send and write.\r
+ SOCK_STREAM - Connect to TCP, provides a byte stream\r
+ that is manipluated by read, recv, send and write.\r
</li>\r
<li>\r
- SOCK_DGRAM - Connect to UDP, provides a datagram service that is\r
- manipulated by recvfrom and sendto.\r
+ SOCK_RAW - Connect to IP, provides a datagram service that\r
+ is manipulated by recvfrom and sendto.\r
</li>\r
</ul>\r
\r
<ul>\r
<li>IPPROTO_TCP</li> - This value must be combined with SOCK_STREAM.</li>\r
<li>IPPROTO_UDP</li> - This value must be combined with SOCK_DGRAM.</li>\r
+ <li>0 - 254</li> - An assigned\r
+ <a href="http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml">protocol number</a>\r
+ is combined with SOCK_RAW.\r
+ </li>\r
</ul>\r
\r
- @return This routine returns a file descriptor for the socket.\r
+ @return This routine returns a file descriptor for the socket. If an error\r
+ occurs -1 is returned and ::errno contains more details.\r
\r
**/\r
INT32\r
type,\r
protocol,\r
&errno );\r
- if ( !EFI_ERROR ( Status ))\r
- {\r
+ if ( !EFI_ERROR ( Status )) {\r
//\r
// Build the file descriptor for the socket\r
//\r
\r
@param [in] pErrno Address of the errno variable\r
\r
- @return A pointer to the socket protocol structure or NULL if\r
+ @return A pointer to the EFI_SOCKET_PROTOCOL structure or NULL if\r
an invalid file descriptor was passed in.\r
\r
**/\r