]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/BsdSocketLib/bind.c
Fix @return Doxygen commands to be singular instead of plural.
[mirror_edk2.git] / StdLib / BsdSocketLib / bind.c
CommitLineData
d7ce7006 1/** @file\r
2 Implement the bind API.\r
3\r
4 Copyright (c) 2011, Intel Corporation\r
5 All rights reserved. This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include <SocketInternals.h>\r
16\r
17\r
18/**\r
19 Bind a name to a socket.\r
20\r
21 The ::bind routine connects a name to a socket on the local machine. The\r
22 <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/bind.html">POSIX</a>\r
23 documentation for the bind routine is available online for reference.\r
24\r
7dc13291 25 @param[in] s Socket file descriptor returned from ::socket.\r
d7ce7006 26\r
7dc13291 27 @param[in] name Address of a sockaddr structure that contains the\r
d7ce7006 28 connection point on the local machine. An IPv4 address\r
29 of INADDR_ANY specifies that the connection is made to\r
30 all of the network stacks on the platform. Specifying a\r
31 specific IPv4 address restricts the connection to the\r
32 network stack supporting that address. Specifying zero\r
33 for the port causes the network layer to assign a port\r
34 number from the dynamic range. Specifying a specific\r
35 port number causes the network layer to use that port.\r
36\r
7dc13291 37 @param[in] namelen Specifies the length in bytes of the sockaddr structure.\r
d7ce7006 38\r
7dc13291 39 @return The bind routine returns zero (0) if successful and -1 upon failure.\r
d7ce7006 40\r
41 **/\r
42int\r
43bind (\r
44 IN int s,\r
45 IN const struct sockaddr * name,\r
46 IN socklen_t namelen\r
47 )\r
48{\r
49 int BindStatus;\r
50 EFI_SOCKET_PROTOCOL * pSocketProtocol;\r
51 EFI_STATUS Status;\r
52\r
53 //\r
54 // Locate the context for this socket\r
55 //\r
56 pSocketProtocol = BslFdToSocketProtocol ( s, NULL, &errno );\r
57 if ( NULL != pSocketProtocol ) {\r
58 //\r
59 // Bind the socket\r
60 //\r
61 Status = pSocketProtocol->pfnBind ( pSocketProtocol,\r
62 name,\r
63 namelen,\r
64 &errno );\r
65 }\r
66\r
67 //\r
68 // Return the operation stauts\r
69 //\r
70 BindStatus = ( 0 == errno ) ? 0 : -1;\r
71 return BindStatus;\r
72}\r