esend, esendto, or esendmsg Subroutine

Purpose

Allows an application to send messages on a socket with the Sensitivity Level (SL) different from that of its own.

Library

Standard C Library (libc.a)Trusted AIX® Sensitivity Label Library (libmls.a)

Syntax

#include <sys/types.h>
#include <sys/socketvar.h>
#include <sys/mac.h>
#include <sys/socket.h>
int esend (Socket, Message, Length, Flags, Label)
int  Socket;
const void * Message;
size_t  Length;
int  Flags;
sec_labels_t *Label;

int esendmsg ( Socket,  Message,  Flags, Label)
int Socket;
const struct msghdr Message [ ];
int Flags;
sec_labels_t *Label;

int esendto (Socket, Message, Length, Flags, To, ToLength, Label)
int  Socket;
const void * Message;
size_t  Length;
int  Flags;
const struct sockaddr * To;
socklen_t  ToLength;
sec_labels_t *Label;

Description

The esend, esendmsg, and esendto subroutines work exactly like send, sendmsg and sendto subroutines respectively, except that the esend, esendmsg, and esendto subroutines allow applications to associate a Sensitivity Level different from their own to the outgoing data through the Label parameter.

The esend subroutine can be used on connected sockets only. The esendto and esendmsg subroutines can be used with connected or unconnected sockets.

For SOCK_STREAM socket types, when the SL is changed between subsequent send operations, the application is blocked until the pending data on the socket buffer can be flushed. If the socket is marked as nonblocking type and there is pending data on the socket buffer, an error is returned.

Parameters

Item Description
Socket Specifies a unique name for the socket.
Message Points to the address of the message or the msghdr structure containing the message to send.
Length Specifies the length of the message in bytes.
Flags Allows the sender to control the transmission of the message.
MSG_OOB
Processes out-of-band data on sockets that support SOCK_STREAM communication.
MSG_DONTROUTE
Sends without using routing tables.
MSG_MPEG2
Indicates that this block is a MPEG2 block. This value is valid SOCK_CONN_DGRAM socket types only.
To Specifies the destination address for the message. The destination address is a sockaddr structure defined in the /usr/include/sys/socket.h file.
ToLength Specifies the size of the destination address.
Label Specifies the SL to be used on the outgoing data.

Return Values

Upon successful completion, the esend, esendmsg, or esendto subroutine returns the number of characters sent.

If errors occur, the subroutine handler performs the following functions:
  • Returns a value of -1 to the calling program.
  • Moves an error code, indicating the specific error, into the errno global variable.

Error Codes

The esend, esendmsg, or esendto subroutine is unsuccessful if any of the following errors occurs:
Error Description
EACCES Write access to the named socket is denied, or the socket trying to send a broadcast packet does not have broadcast capability, or the MLS MAC check failed.
EADDRNOTAVAIL The specified address is not valid.
EAFNOSUPPORT The specified address is not a valid address for the address family of this socket.
EBADF The Socket parameter is not valid.
ECONNRESET A connection was forcibly closed by a peer.
EDESTADDRREQ The socket is not in connection mode and no peer address is set.
EFAULT The Address parameter is not in a writable part of the user address space.
EHOSTUNREACH The destination host cannot be reached.
EINTR A signal interrupted the esend, esendmsg, or esendto subroutine before any data was transmitted.
EINVAL The Length parameter is not valid.
EISCONN A SOCK_DGRAM socket is already connected.
EMSGSIZE The message is too large to be sent all at once, as the socket requires.
ENETUNREACH The destination network is not reachable.
ENOBUFS Insufficient resources were available in the system to perform the operation.
ENOENT The path name does not contain an existing file, or the path name is an empty string.
ENOMEM The available data space in memory is not large enough to hold group or ACL information.
ENOTSOCK The Socket parameter refers to a file, not a socket.
EOPNOTSUPP The Socket parameter is associated with a socket that does not support one or more of the values set in the Flags parameter.
EPIPE An attempt was made to send on a socket that was connected, but the connection was shut down either by the remote peer or by this side of the connection. If the socket is of type SOCK_STREAM, the SIGPIPE signal is generated for the calling process.
EWOULDBLOCK The socket is marked nonblocking, and no connections are present to be accepted. Or a sending operation was attempted with different SLs while there was pending data on the socket buffer, and the socket was marked nonblocking