[Previous] [Contents] [Index] [Next]

Caution: 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 );


An array of integers that specifies the Management Information Base (MIB) stylename of the item that you want to set or get; see below.
The length of the name.
NULL, or a pointer to a buffer where the function can store the old value.
NULL, or a pointer to a location that initially specifies the size of the oldp buffer. The function changes the value in this location to be the size of the old information stored in the oldp buffer
NULL, or a pointer to a buffer that holds the new value.
The size of the new value.



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;
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:

Returns 1 when IP forwarding is enabled for the host, meaning that the host is acting as a router.
Returns 1 when ICMP redirects may be sent by the host. This option is ignored unless the host is routing IP packets. Normally, this option should be enabled on all systems.
The maximum time-to-live (hop count) value for an IP packet sourced by the system. This value applies to normal transport protocols, not to ICMP.
Returns 1 when forwarding of source-routed packets is enabled for the host. This value may be changed only if the kernel security level is less than 1.
Returns 1 if directed-broadcast behavior is enabled for the host.
Returns 1 if the host accepts source-routed packets.
Returns 1 if subnets are to be considered local addresses.
Returns 1 if path MTU discovery is enabled.
Returns the maximum number of fragmented IP packets in the IP reassembly queue.
Returns 1 if source check for received packets is enabled.
Returns the time interval when IP source address verification messages are logged. A value of zero disables the logging.
Returns 1 if ICMP network mask requests are to be answered.
Returns 1 if RFC1323 extensions to TCP are enabled.
Returns the default TCP send buffer size.
Returns the default TCP receive buffer size.
Returns the default TCP maximum segment size.
Returns the maximum number of entries allowed in the TCP compressed state engine.
Returns the maximum number of entries allowed per hash bucket in the TCP compressed state engine.
Returns the TCP compressed state engine's timer interval.
Returns 1 when UDP checksums are being computed and checked.
Note: Disabling UDP checksums is strongly discouraged.

Returns the default UDP send buffer size.
Returns the default UDP receive buffer size.


An error occurred (errno is set).


The buffers: name, oldp, newp, or the length pointer oldlenp contains an invalid address.
The name array is less than two or greater than CTL_MAXNAME; or a non-NULL newp is given and its specified length in newlen is too large or too small.
The length pointed to by oldlenp is too short to hold the requested value.
The name array specifies an intermediate rather than terminal name.
The name array specifies an unknown value.
An attempt was made to set a read-only value; a process, without appropriate privilege, attempts to set or change a value protected by the current system security level.



Cancellation point Yes
Interrupt handler No
Signal handler No
Thread Yes

See also:

ROUTE protocol

sysctl in the Utilities Reference

[Previous] [Contents] [Index] [Next]