setsockopt(hdlc,lapb,llc2)
NAME
setsockopt − Set socket options
SYNTAX
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <netdnet/dli_var.h>
#include <wdd/hdlc_var.h>
ss = setsockopt (s, level, optname, optval, optlen)
int s, level, optname;
char ∗optval;
int optlen;
DESCRIPTION
The setsockopt() system call allows access to the following services:
∗ Opening a Port
∗ Initializing a Link
∗ Stopping a Link
∗ Closing a Port
∗ Enter Maintenance Mode (LAPB only)
∗ Exit Maintenance Mode (LAPB only)
These services, as well as the required input arguments and diagnostics, are listed and described below.
∗ OPENING A PORT
After creating a socket, issue the setsockopt() system call to open a port to set up an access point to the link.
ARGUMENTS
Input Arguments
s Value returned by the socket() system call
level DLPROTO_HDLC, DLPROTO_LAPB, DLPROTO_LLC2
optname HDLC_OPENPORT
optval Pointer to the hdlcso_open_msg data structure
optlen Size of the hdlcso_open_msg data structure
RETURN VALUE
If the call is successful the value of 0 is returned. If the call fails, a value of -1 is returned and the external variable errno contains error codes which are specified below.
DIAGNOSTICS
[ENOBUFS] No buffer space is available.
[ENODEV] The specified link or station does not exist.
[EMSGSIZE] The specified buffer size is not within the allowable range. This parameter is applicable to unsequenced ports only.
[EADDRINUSE] This protocol id has already been assigned to another port.
[EEXIST] A sequenced port has already been opened. This applies to sequenced ports only.
[EINVAL] Size of the hdlcso_open_msg data structure is not valid.
[EALREADY] A sequenced port has already been allocated on the socket descriptor.
∗ INITIALIZING A LINK
After opening a sequenced port you need to initialize a link. Issue the setsockopt() system call to initialize the link.
ARGUMENTS
Input Arguments
s Value returned by the socket() system call
level DLPROTO_HDLC, DLPROTO_LAPB, DLPROTO_LLC2
optname HDLC_INITLINK
optval Pointer to the hdlccso_init_msg data structure
optlen Size of the hdlcso_init_msg data structure
RETURN VALUE
If the call is successful the value of 0 is returned. Otherwise, -1 is returned and the global variable errno is set to indicate the error.
DIAGNOSTICS
[ENXIO] The specified port does not exist
[ENOPROTOOPT] The link (station) is in maintenance mode
[ENETDOWN] The link and/or station have been disabled by the Network Management. This error also occurs when the link is inoperative, i.e. the physical layer line has been disabled.
[EALREADY] The link has already been initialized
[EPROTOTYPE] The port is not a sequenced port
[EMSGSIZE] The value specified in the pref_max_size does not match the one specified by the link’s maximum and minimum data size characteristics (HDLC only). The value specified in the ui_size of the hdlcso_open_msg data structure is no longer supportable by the device driver (LAPB only).
[EIDRM] The port has not yet been opened or is waiting to be closed by the client. This error occurs if:
1 The client attempts to initialize the link before opening the associated port
2 The link and/or station have been deleted by the Network Management. To initialize the link, the client must close the port and reopen it after the associated link and station have been enabled.
[EPROTONOTSUPORT]
The specified protocol is not supported.
∗ STOPPING A LINK
To terminate the HDLC, LAPB, or LLC2 protocol operation, issue the setsockopt() system call. This procedure stops the protocol operation on the link. This service applies to sequenced ports only.
Prior to stopping the link, make sure that all data has been sent to and received from the remote node. For more information on obtaining the link status, please refer to the getsockopt() system call.
ARGUMENTS
Input Arguments
s Value returned by the socket() system call
level DLPROTO_HDLC, DLPROTO_LAPB, DLPROTO_LLC2
optname HDLC_STOPLINK
optval Null
optlen Null
RETURN VALUE
If the call is successful the value of 0 is returned. If an error occurs, a value of -1 is returned. Additional error detail will be specified in the external variable errno.
DIAGNOSTICS
[EPROTOTYPE] The specified port is not sequenced
[ENXIO] The specified port does not exist
[EIDRM] The port has already been closed or has not been opened
[ENETUNREACH] The link has already been stopped by the client or by the remote station
[ENETDOWN] The line has been disabled. The link has already been in inoperative state, that is, the physical layer line has been disabled.
∗ CLOSING A PORT
After the data has been successfully delivered and the HDLC, LAPB, or LLC2 services are no longer required, issue the setsockopt() system call to close the port.
The link should be stopped before closing a sequenced port. However, an implicit stop link operation will be performed before closing the port.
Before closing the port, the user is responsible for verifying that the data has been sent to or received from the remote node. When the port has been closed, any data that has not yet been delivered to the client will be discarded.
ARGUMENTS
Input Arguments
s Value returned by the socket() system call.
level DLPROTO_HDLC, DLPROTO_LAPB, DLPROTO_LLC2
optname HDLC_CLOSEPORT
optlen Null
optval Null
RETURN VALUE
If the call is successful the value of 0 is returned. Otherwise, -1 is returned and the global variable errno is set to indicate the error.
DIAGNOSTICS
[ENXIO] The specified port does not exist
∗ LAPB MAINTENANCE MODE
In order to make unsequenced services available, you must enter Maintenance Mode. This is done by issuing the setsockopt() system call, specifying the option HDLC_ENTERMAINT.
When unsequenced services are no longer required, you can exit Maintenance Mode by issuing the setsockopt() system call with the HDLC_EXITMAINT option.
ARGUMENTS
Input Arguments
s Value returned by the socket() system call
level DLPROTO_LAPB
optname HDLC_ENTERMAINT or HDLC_EXITMAINT
optval Null
optlen Null
RETURN VALUE
If the call is successful the value of 0 is returned. If the call fails, a value of -1 is returned and the external variable errno contains error codes which are specified below.
DIAGNOSTICS
[ENXIO] The specified port does not exist.