ebind Subroutine

Purpose

Binds a name to a socket. Also binds a socket to the specific Sensitivity Level (SL) that is passed as a parameter.

Library

Standard C Library (libc.a)

Syntax

#include <sys/socket.h>
#include <sys/mac.h>
int ebind ( Socket, Name, NameLength, Label)
int Socket;
const struct sockaddr *Name;
socklen_t NameLength;
sec_labels_t *Label;

Description

The ebind subroutine assigns a Name parameter to an unnamed socket. Sockets created by the socket subroutine are unnamed; they are identified only by their address family. Subroutines that connect sockets either assign names or use unnamed sockets.

When a NULL pointer is passed to the Label parameter, then a normal multi-level port is created. However, when a valid label is passed to the Label parameter, a port at the specified Sensitivity Level (SL) is created. This means that only those incoming connections at the specified SL are able to connect. This also means that multiple sockets can be bound to the same port at different SLs. It is possible to create a multi-level port as well as several specific-level ports. If none of the specific SLs matches the incoming packet, then the packet port is a default multi-level port.

Parameters

Item Description
Socket Specifies the socket descriptor of the socket to be bound. The socket descriptor is an integer,
Name Points to an address structure that specifies the address to which the socket should be bound. The /usr/include/sys/socket.h file defines the sockaddr address structure. The sockaddr structure contains an identifier specific to the address format and protocol provided in the socket subroutine.
NameLength Specifies the length of the socket address structure.
Label Specifies the Sensitivity Label associated with the socket.

Return Values

Item Description
Successful 0
Unsuccessful -1

Error Codes

The ebind subroutine is unsuccessful if any of the following errors occurs:

Value Description
EACCES The requested address is protected, and the current user does not have permission to access it.
EADDRINUSE The specified address is already in use.
EADDRNOTAVAIL The specified address is not available from the local machine.
EAFNOSUPPORT The specified address is not a valid address for the address family of the specified socket.
EBADF The Socket parameter is not valid.
EDESTADDRREQ The address argument is a null pointer.
EFAULT The Address parameter is not in a writable part of the user address space.
EINVAL The socket is already bound to an address.
ENOBUF Insufficient buffer space available.
ENODEV The specified device does not exist.
ENOTSOCK The Socket parameter refers to a file, not a socket.
EOPNOTSUPP The socket referenced by the Socket parameter does not support address binding.