]>
git.proxmox.com Git - mirror_edk2.git/blob - StdLib/BsdSocketLib/bind.c
2 Implement the bind API.
4 Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 #include <SocketInternals.h>
16 /** Bind a name to a socket.
18 The bind routine connects a name (network address) to a socket on the local machine.
21 <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/bind.html">POSIX</a>
22 documentation is available online.
24 @param[in] s Socket file descriptor returned from ::socket.
26 @param[in] name Address of a sockaddr structure that contains the
27 connection point on the local machine. An IPv4 address
28 of INADDR_ANY specifies that the connection is made to
29 all of the network stacks on the platform. Specifying a
30 specific IPv4 address restricts the connection to the
31 network stack supporting that address. Specifying zero
32 for the port causes the network layer to assign a port
33 number from the dynamic range. Specifying a specific
34 port number causes the network layer to use that port.
36 @param[in] namelen Specifies the length in bytes of the sockaddr structure.
38 @return The bind routine returns zero (0) if successful and -1 upon failure.
39 In the case of an error, ::errno contains more information.
44 IN
const struct sockaddr
* name
,
49 EFI_SOCKET_PROTOCOL
* pSocketProtocol
;
51 // Locate the context for this socket
52 pSocketProtocol
= BslFdToSocketProtocol ( s
, NULL
, &errno
);
53 if ( NULL
!= pSocketProtocol
) {
56 (void) pSocketProtocol
->pfnBind ( pSocketProtocol
,
62 // Return the operation stauts
63 BindStatus
= ( 0 == errno
) ? 0 : -1;