]>
git.proxmox.com Git - mirror_edk2.git/blob - StdLib/BsdSocketLib/bind.c
2 Implement the bind API.
4 Copyright (c) 2011, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. 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.
15 #include <SocketInternals.h>
19 Bind a name to a socket.
21 The ::bind routine connects a name to a socket on the local machine. The
22 <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/bind.html">POSIX</a>
23 documentation for the bind routine is available online for reference.
25 @param[in] s Socket file descriptor returned from ::socket.
27 @param[in] name Address of a sockaddr structure that contains the
28 connection point on the local machine. An IPv4 address
29 of INADDR_ANY specifies that the connection is made to
30 all of the network stacks on the platform. Specifying a
31 specific IPv4 address restricts the connection to the
32 network stack supporting that address. Specifying zero
33 for the port causes the network layer to assign a port
34 number from the dynamic range. Specifying a specific
35 port number causes the network layer to use that port.
37 @param[in] namelen Specifies the length in bytes of the sockaddr structure.
39 @return The bind routine returns zero (0) if successful and -1 upon failure.
45 IN
const struct sockaddr
* name
,
50 EFI_SOCKET_PROTOCOL
* pSocketProtocol
;
54 // Locate the context for this socket
56 pSocketProtocol
= BslFdToSocketProtocol ( s
, NULL
, &errno
);
57 if ( NULL
!= pSocketProtocol
) {
61 Status
= pSocketProtocol
->pfnBind ( pSocketProtocol
,
68 // Return the operation stauts
70 BindStatus
= ( 0 == errno
) ? 0 : -1;