This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs. |
Get or set information about the socket manager
#include <sys/param.h> #include <sys/sysctl.h> int sysctl( int * name, u_int namelen, void * oldp, size_t * oldlenp, void * newp, size_t newlen );
libsocket
Use the -l socket option to qcc to link against this library.
The sysctl() function retrieves information about the socket manager and allows processes with appropriate privileges to set this information. The data available from sysctl() consists of integers and tables. You can also get or set data using the sysctl utility at the command line.
The state is described using a Management Information Base (MIB) stylename, specified in name, which is a namelen length array of integers.
The information is copied into the buffer specified by oldp. The size of the buffer is given by the location specified by oldlenp before the call, and that location gives the amount of data copied after a successful call. If the amount of data available is greater than the size of the buffer supplied, the call delivers as much data as fits in the buffer provided and returns with the error code ENOMEM. If you don't need the old value, you can set oldp and oldlenp to NULL.
You can determine the size of the available data by calling sysctl() with a NULL parameter for oldp. The function stores the size of the available data in the location pointed to by oldlenp. For some operations, the amount of space may change often. For these operations, the system attempts to round up, so that the returned size is large enough for a call to return the data shortly thereafter.
To specify a new value, set newp to point to a buffer of length newlen from which the requested value is to be taken. If you're not setting a new value, set newp to NULL and newlen to 0.
The top-level names are defined with a CTL_ prefix in <sys/sysctl.h>. QNX 4 supports CTL_NET only. The next and subsequent levels down are found in the following header files:
This header file | Contains definitions for |
---|---|
<sys/sysctl.h> | Top-level identifiers |
<sys/socket.h> | Second-level network identifiers |
<netinet/in.h> | Third-level Internet identifiers and fourth-level IP identifiers |
<netinet/icmp_var.h> | Fourth-level ICMP identifiers |
<netinet/tcp_var.h> | Fourth-level TCP identifiers |
<netinet/udp_var.h> | Fourth-level UDP identifiers |
The following code fragment checks whether the UDP packets checksum is enabled:
int mib[5], val; size_t len; mib[0] = CTL_NET; mib[1] = AF_INET; mib[2] = IPPROTO_UDP; mib[3] = UDPCTL_CHECKSUM; len = sizeof(val); sysctl(mib, 4, &val, &len, NULL, 0);
The table and integer information available for the CTL_NET level is detailed below. The Changeable column shows whether a process with appropriate privilege may change the value.
Second-level name | Type | Changeable |
---|---|---|
PF_INET | internet values | yes |
PF_INET gets or sets global information about internet protocols.
The third-level name is the protocol. The fourth-level name is the variable name. Here are the currently defined protocols and names:
Protocol name | Variable name | Type | Changeable |
---|---|---|---|
ip | forwarding | Integer | Yes |
redirect | Integer | Yes | |
ttl | Integer | Yes | |
forwsrcrt | Integer | Yes | |
directed-broadcast | Integer | Yes | |
allowsrcrt | Integer | Yes | |
subnetsarelocal | Integer | Yes | |
mtudisc | Integer | Yes | |
maxfragpackets | Integer | Yes | |
sourcecheck | Integer | Yes | |
sourcecheck_logint | Integer | Yes | |
icmp | maskrepl | Integer | Yes |
tcp | rfc1323 | Integer | Yes |
sendspace | Integer | Yes | |
recvspace | Integer | Yes | |
mssdflt | Integer | Yes | |
syn_cache_limit | Integer | Yes | |
syn_bucket_limit | Integer | Yes | |
syn_cache_interval | Integer | Yes | |
udp | checksum | Integer | Yes |
sendspace | Integer | Yes | |
recvspace | Integer | Yes |
The variables are as follows:
Disabling UDP checksums is strongly discouraged. |
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
ROUTE protocol
sysctl in the Utilities Reference