Commit e311a79f authored by Kevin Bracey's avatar Kevin Bracey
Browse files

Added err_set_silent() to unixlib err() functions.

Added strdup() to unixlib.
Added sysctlbyname() to inetlib.
All the header file changes for Internet 5.31.

Version 5.25. Tagged as 'TCPIPLibs-5_25'
parent 96377d96
Acorn TCP/IP libraries version 5.19
Acorn TCP/IP libraries version 5.25
-----------------------------------
These libraries are an update to the libraries described in chapter 123 of the PRM
......@@ -828,6 +828,7 @@ void vwarnx(const char *fmt, va_list args);
void err_set_file(void *fp);
void err_set_exit(void (*exitf)(int));
void err_set_silent(int silent);
The err family of functions display a formatted error message on the standard
error output, or on another file specified using the err_set_file function.
......@@ -848,6 +849,10 @@ of the argument eval. The err_set_exit function can be used to specify a
function which is called before exit(), to perform any necessary cleanup;
passing a null function pointer for exitf resets the hook to do nothing.
For "silent" operation, call err_set_silent() with a non-zero parameter. Then
the warn functions will do nothing, and the err functions will set the system
variable Inet$Error, instead of printing to stderr.
Examples
--------
Display the current errno information string and exit:
......@@ -1506,6 +1511,29 @@ New prototypes: char *index(const char *s, int c);
int strcasecmp(const char *s1, const char *s2);
int strncasecmp(const char *s1, const char *s2, unsigned int n);
STRDUP
======
Name
----
strdup - save a copy of a string
Synopsis
--------
char *strdup(const char *str);
Description
-----------
The strdup function allocates sufficient memory for a copy of the string str,
does the copy, and returns a pointer to it. The pointer may subsequently be
used as an argument to the function free.
If insufficient memory is available, NULL is returned.
Exported by
-----------
UnixLib
STRSEP
======
......@@ -1563,43 +1591,61 @@ sysctl - get or set system information
Synopsis
--------
#include "sys/sysctl.h"
#include <sys/types.h>
#include <sys/sysctl.h>
int sysctl(int *name, u_int namelen, void *oldp, size_t oldlenp, void *newp,
size_t newlen);
int sysctlbyname(const char *name, void *oldp, size_t *oldlenp, void *newp,
size_t newlen)
int sysctl(int *name, u_int namelen, void *oldp, size_t oldlenp, void *newp, size_t newlen);
Description
-----------
The sysctl function retrieves system information and allows processes with appropriate
privileges to set system information. The information available from sysctl consists of
integers, strings, and tables. Information may be retrieved and set from the command
interface using the SysCtl utility. Normal applications should not alter any variables
using sysctl, as these variables affect the whole system and you could cause problems
in other programs.
The state is described using a 'Management Information Base' (MIB) style name, listed 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 and after a call that returns with the error code ENOMEM.
If the amount of data available is greater than the size of the buffer supplied, the call
supplies as much data as fits in the buffer provided and returns with the error code ENOMEM.
If the old value is not desired, oldp and oldlenp should be set to NULL.
The size of the available data can be determined by calling sysctl with a NULL parameter for
oldp. The size of the available data will be returned 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 set a new value, newp is set to point to a buffer of length newlen from which the
requested value is to be taken. If a new value is not to be set, newp should be set to NULL
and newlen set to 0.
The top level names are defined with a CTL_ prefix in "sys/sysctl.h", and are as follows.
The next and subsequent levels down are found in the include files listed here, and
described in separate sections below. However, only CTL_NET is provided by the Internet
module.
The sysctl function retrieves system information and allows processes with
appropriate privileges to set system information. The information available
from sysctl consists of integers, strings, and tables. Information may be
retrieved and set from the command interface using the SysCtl utility. Normal
applications should not alter any variables using sysctl, as these variables
affect the whole system and you could cause problems in other programs.
Unless explicitly noted below, sysctl() returns a consistent snapshot of the
data requested. Consistency is obtained by locking the destination buffer
into memory so that the data may be copied out without blocking. Calls to
sysctl() are serialized to avoid deadlock.
The state is described using a 'Management Information Base' (MIB) style
name, listed in name, which is a namelen length array of integers.
The sysctlbyname() function accepts an ascii representation of the name and
internally looks up the integer name vector. Apart from that, it behaves the
same as the standard sysctl() function.
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 and
after a call that returns with the error code ENOMEM. If the amount of data
available is greater than the size of the buffer supplied, the call supplies
as much data as fits in the buffer provided and returns with the error code
ENOMEM. If the old value is not desired, oldp and oldlenp should be set to
NULL.
The size of the available data can be determined by calling sysctl with a
NULL parameter for oldp. The size of the available data will be returned 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 set a new value, newp is set to point to a buffer of length newlen from
which the requested value is to be taken. If a new value is not to be set,
newp should be set to NULL and newlen set to 0.
The top level names are defined with a CTL_ prefix in "sys/sysctl.h", and are
as follows. The next and subsequent levels down are found in the include
files listed here, and described in separate sections below. However, only
CTL_NET is provided by the Internet module.
Name Next level names Description
CTL_DEBUG sys/sysctl.h Debugging
......@@ -1611,7 +1657,8 @@ module.
CTL_USER sys/sysctl.h User-level
CTL_VM vm/vm_param.h Virtual memory
For example, the following retrieves the default TTL for outgoing network packets:
For example, the following retrieves the default TTL for outgoing network
packets:
int mib[4], maxproc;
size_t len;
......@@ -1625,20 +1672,23 @@ For example, the following retrieves the default TTL for outgoing network packet
CTL_NET
-------
The string 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.
The string 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_ROUTE routing messages no
PF_INET internet values yes
PF_ROUTE Return the entire routing table or a subset of it. The data is returned as
a sequence of routing messages (see route for the header file, format and
meaning). The length of each message is contained in the message header.
PF_ROUTE Return the entire routing table or a subset of it. The data is
returned as a sequence of routing messages (see route for the header
file, format and meaning). The length of each message is contained in
the message header.
The third level name is a protocol number, which is currently always 0.
The fourth level name is an address family, which may be set to 0 to
select all address families. The fifth and sixth level names are as follows:
select all address families. The fifth and sixth level names are as
follows:
Fifth level name Sixth level is:
NET_RT_FLAGS rtflags
......@@ -1646,8 +1696,8 @@ PF_ROUTE Return the entire routing table or a subset of it. The data is returned
NET_RT_IFLIST None
PF_INET Get or set various global information about the internet protocols.
The third level name is the protocol. The fourth level name is the variable
name. The currently defined protocols and names are:
The third level name is the protocol. The fourth level name is the
variable name. The currently defined protocols and names are:
Protocol name Variable name Type Changeable
ip forwarding integer yes
......@@ -1684,35 +1734,42 @@ PF_INET Get or set various global information about the internet protocols.
ip.forwarding Returns 1 when IP forwarding is enabled for the host,
meaning that the host is acting as a router.
ip.redirect Returns 1 when ICMP redirects may be sent by the host.
This option is ignored unless the host is routing IP packets,
and should normally be enabled on all systems.
ip.redirect Returns 1 when ICMP redirects may be sent by the
host. This option is ignored unless the host is
routing IP packets, and should normally be enabled
on all systems.
ip.ttl The default time-to-live (hop count) value for an IP packet
sourced by the system. This value applies to normal transport
protocols, not to ICMP.
ip.ttl The default time-to-live (hop count) value for an IP
packet sourced by the system. This value applies to
normal transport protocols, not to ICMP.
icmp.maskrepl Returns 1 if ICMP network mask requests are to be answered.
icmp.maskrepl Returns 1 if ICMP network mask requests are to be
answered.
igmp.forceleave Suppresses IGMPv2 'leave' optimisation.
udp.checksum Returns 1 when UDP checksums are being computed and checked.
Disabling UDP checksums is strongly discouraged.
udp.checksum Returns 1 when UDP checksums are being computed and
checked. Disabling UDP checksums is strongly
discouraged.
Files
-----
"sys/sysctl.h" definitions for top level identifiers, second level kernel and
hardware identifiers, and user level identifiers
"sys/sysctl.h" definitions for top level identifiers, second level kernel
and hardware identifiers, and user level identifiers
"sys/socket.h" definitions for second level network identifiers
"netinet/in.h" definitions for third level Internet identifiers and fourth level IP
identifiers
"netinet/in.h" definitions for third level Internet identifiers and
fourth level IP identifiers
"netinet/icmp_var.h" definitions for fourth level ICMP identifiers
"netinet/udp_var.h" definitions for fourth level UDP identifiers
History
-------
The sysctl function first appeared in Internet 5.00.
The sysctlbyname function first appeared in Internet 5.31.
Exported by
-----------
Socklib (sysctl), Inetlib (sysctlbyname)
UNLINK
======
......
/* (5.24)
/* (5.25)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 5.24
#define Module_MajorVersion_CMHG 5.25
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 08 Jul 1999
#define Module_Date_CMHG 13 Jul 1999
#define Module_MajorVersion "5.24"
#define Module_Version 524
#define Module_MajorVersion "5.25"
#define Module_Version 525
#define Module_MinorVersion ""
#define Module_Date "08 Jul 1999"
#define Module_Date "13 Jul 1999"
#define Module_FullVersion "5.24"
#define Module_FullVersion "5.25"
......@@ -60,15 +60,18 @@ struct icmpstat {
*/
#define ICMPCTL_MASKREPL 1 /* allow replies to netmask requests */
#define ICMPCTL_STATS 2 /* statistics (read-only) */
#define ICMPCTL_MAXID 3
#define ICMPCTL_ICMPLIM 3
#define ICMPCTL_MAXID 4
#define ICMPCTL_NAMES { \
{ 0, 0 }, \
{ "maskrepl", CTLTYPE_INT }, \
{ "stats", CTLTYPE_STRUCT }, \
{ "icmplim", CTLTYPE_INT }, \
}
#ifdef KERNEL
SYSCTL_DECL(_net_inet_icmp);
extern struct icmpstat icmpstat;
#endif
......
......@@ -61,10 +61,6 @@ struct igmpstat {
};
#ifdef KERNEL
extern struct igmpstat igmpstat;
extern int igmp_forceleave;
#define IGMP_RANDOM_DELAY(X) (rand() % (X) + 1)
/*
......@@ -94,6 +90,9 @@ void igmp_leavegroup(struct in_multi *);
void igmp_fasttimo(void);
void igmp_slowtimo(void);
int igmp_sysctl(int *, u_int, void *, size_t *, void *, size_t);
SYSCTL_DECL(_net_inet_igmp);
#endif
/*
......
......@@ -65,13 +65,47 @@ struct inpcb {
u_char inp_ip_p; /* protocol proto */
u_char pad[1]; /* alignment */
struct ip_moptions *inp_moptions; /* IP multicast options */
LIST_ENTRY(inpcb) inp_portlist; /* list for this PCB's local port */
struct inpcbport *inp_phd; /* head of this list */
inp_gen_t inp_gencnt; /* generation count of this instance */
};
/*
* Interface exported to userland by various protocols which use
* inpcbs. Hack alert -- only define if struct xsocket is in scope.
*/
#ifdef _SYS_SOCKETVAR_H_
struct xinpcb {
size_t xi_len; /* length of this structure */
struct inpcb xi_inp;
struct xsocket xi_socket;
u_quad_t xi_alignment_hack;
};
struct xinpgen {
size_t xig_len; /* length of this structure */
u_int xig_count; /* number of PCBs at this time */
inp_gen_t xig_gen; /* generation count at this time */
so_gen_t xig_sogen; /* socket generation count at this time */
};
#endif /* _SYS_SOCKETVAR_H_ */
struct inpcbport {
LIST_ENTRY(inpcbport) phd_hash;
struct inpcbhead phd_pcblist;
u_short phd_port;
};
struct inpcbinfo {
struct inpcbhead *listhead;
struct inpcbhead *hashbase;
u_long hashmask;
struct inpcbporthead *porthashbase;
u_long porthashmask;
struct inpcbhead *listhead;
unsigned long hashsize;
unsigned short lastport;
u_int ipi_count; /* number of pcbs in this list */
u_quad_t ipi_gencnt; /* current generation count */
};
/* flags in inp_flags: */
......
......@@ -86,9 +86,6 @@ extern struct in_ifaddr *in_ifaddr;
extern struct ifqueue ipintrq; /* ip packet input queue */
extern struct in_addr zeroin_addr;
extern u_char inetctlerrmap[];
extern int rtq_reallyold; /* XXX */
extern int rtq_minreallyold; /* XXX */
extern int rtq_toomany; /* XXX */
/*
* Macro for finding the interface (ifnet structure) corresponding to one
......@@ -160,6 +157,12 @@ struct in_multi {
};
#ifdef KERNEL
#ifdef SYSCTL_DECL
SYSCTL_DECL(_net_inet_ip);
SYSCTL_DECL(_net_inet_raw);
#endif
/*
* Structure used by macros below to remember position when stepping through
* all of the in_multi records.
......
......@@ -89,8 +89,8 @@
#define TCPTV_MSL ( 30*PR_SLOWHZ) /* max seg lifetime (hah!) */
#define TCPTV_SRTTBASE 0 /* base roundtrip time;
if 0, no idea yet */
#define TCPTV_SRTOBASE ( 3*PR_SLOWHZ) /* base retransmit timeout
if no info */
#define TCPTV_RTOBASE ( 3*PR_SLOWHZ) /* assumed RTO if no info */
#define TCPTV_SRTTDFLT ( 3*PR_SLOWHZ) /* assumed RTT if no info */
#define TCPTV_PERSMIN ( 5*PR_SLOWHZ) /* retransmit persistence */
#define TCPTV_PERSMAX ( 60*PR_SLOWHZ) /* maximum persist interval */
......@@ -126,8 +126,8 @@ static char *tcptimers[] =
}
#ifdef KERNEL
extern int tcp_keepinit; /* time to establish connection */
extern int tcp_keepidle; /* time before keepalive probes begin */
extern int tcp_keepintvl; /* time between keepalive probes */
extern int tcp_maxidle; /* time to drop after starting probes */
extern int tcp_ttl; /* time to live for TCP segs */
extern int tcp_backoff[];
......
......@@ -295,6 +295,21 @@ struct tcpstat {
u_long tcps_listendrop; /* listen queue overflows */
};
/*
* TCB structure exported to user-land via sysctl(3).
* Evil hack: declare only if in_pcb.h and sys/socketvar.h have been
* included. Not all of our clients do.
*/
#if defined(_NETINET_IN_PCB_H_) && defined(_SYS_SOCKETVAR_H_)
struct xtcpcb {
size_t xt_len;
struct inpcb xt_inp;
struct tcpcb xt_tp;
struct xsocket xt_socket;
u_quad_t xt_alignment_hack;
};
#endif
/*
* Names for TCP sysctl objects
*/
......@@ -309,8 +324,7 @@ struct tcpstat {
#define TCPCTL_RECVSPACE 9 /* receive buffer space */
#define TCPCTL_KEEPINIT 10 /* receive buffer space */
#define TCPCTL_PCBLIST 11 /* list of all outstanding PCBs */
#define TCPCTL_PATH_MTU_DISC 12 /* do path MTU discovery */
#define TCPCTL_MAXID 13
#define TCPCTL_MAXID 12
#define TCPCTL_NAMES { \
{ 0, 0 }, \
......@@ -325,18 +339,18 @@ struct tcpstat {
{ "recvspace", CTLTYPE_INT }, \
{ "keepinit", CTLTYPE_INT }, \
{ "pcblist", CTLTYPE_STRUCT }, \
{ "path_mtu_discovery", CTLTYPE_INT }, \
}
#ifdef KERNEL
#ifdef SYSCTL_DECL
SYSCTL_DECL(_net_inet_tcp);
#endif
extern struct inpcbhead tcb; /* head of queue of active tcpcb's */
extern struct inpcbinfo tcbinfo;
extern struct tcpstat tcpstat; /* tcp statistics */
extern int tcp_do_rfc1323; /* XXX */
extern int tcp_do_rfc1644; /* XXX */
extern int tcp_mssdflt; /* XXX */
extern u_long tcp_now; /* for RFC 1323 timestamps */
extern int tcp_rttdflt; /* XXX */
extern u_short tcp_lastport; /* last assigned port */
void tcp_canceltimers(struct tcpcb *);
......
......@@ -76,7 +76,8 @@ struct udpstat {
#define UDPCTL_STATS 2 /* statistics (read-only) */
#define UDPCTL_MAXDGRAM 3 /* max datagram size */
#define UDPCTL_RECVSPACE 4 /* default receive buffer space */
#define UDPCTL_MAXID 5
#define UDPCTL_PCBLIST 5 /* list of PCBs for UDP sockets */
#define UDPCTL_MAXID 6
#define UDPCTL_NAMES { \
{ 0, 0 }, \
......@@ -84,9 +85,12 @@ struct udpstat {
{ "stats", CTLTYPE_STRUCT }, \
{ "maxdgram", CTLTYPE_INT }, \
{ "recvspace", CTLTYPE_INT }, \
{ "pcblist", CTLTYPE_STRUCT }, \
}
#ifdef KERNEL
SYSCTL_DECL(_net_inet_udp);
extern struct inpcbhead udb;
extern struct inpcbinfo udbinfo;
extern struct udpstat udpstat;
......
#ifndef _SYS__POSIX_H_
#define _SYS__POSIX_H_
/*-
* Copyright (c) 1998 HD Associates, Inc.
* All rights reserved.
* contact: dufault@hda.com
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
*/
/*
* This is a stand alone header file to set up for feature specification
* defined to take place before the inclusion of any standard header.
* It should only handle pre-processor defines.
*
* See section B.2.7 of 1003.1b-1993
*
*/
#ifdef KERNEL
#if !defined(KLD_MODULE)
#include "opt_posix.h"
#endif
/* Only kern_mib.c uses _POSIX_VERSION. Introduce a kernel
* one to avoid other pieces of the kernel getting dependant
* on that.
* XXX Complain if you think this dumb.
*/
/* Make P1003 structures visible for the kernel if
* the P1003_1B option is in effect.
*/
#ifdef P1003_1B
#define _P1003_1B_VISIBLE
#ifndef _KPOSIX_VERSION
#define _KPOSIX_VERSION 199309L
#endif
#endif
#ifndef _KPOSIX_VERSION
#define _KPOSIX_VERSION 199009L
#endif
#define _P1003_1B_VISIBLE_HISTORICALLY
#else
#ifndef __riscos
/* Default to existing user space version.
*/
#ifndef _POSIX_VERSION
#define _POSIX_VERSION 199009L
#endif
/* Test for visibility of P1003.1B features:
* If _POSIX_SOURCE and POSIX_C_SOURCE are completely undefined
* they show up.
*
* If they specify a version including P1003.1B then they show up.
*
* (Two macros are added to permit hiding new extensions while
* keeping historic BSD features - that is not done now)
*
*/
#if (!defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)) || \
(_POSIX_VERSION >= 199309L && defined(_POSIX_C_SOURCE) && \
_POSIX_C_SOURCE >= 199309L)
#define _P1003_1B_VISIBLE
#define _P1003_1B_VISIBLE_HISTORICALLY
#endif
#endif /* not __riscos */
#endif /* not KERNEL */
#endif /* _SYS__POSIX_H_ */
......@@ -41,6 +41,8 @@
#ifndef _SYS_CALLOUT_H_
#define _SYS_CALLOUT_H_
#include <sys/queue.h>
struct callout {
struct callout *c_next; /* next callout in queue */
void *c_arg; /* function argument */
......
......@@ -41,6 +41,9 @@
#ifndef _SYS_KERNEL_H_
#define _SYS_KERNEL_H_
#include <sys/linker_set.h>
#ifdef KERNEL
/* Global variables for the kernel. */
/* 1.1 */
......@@ -70,20 +73,7 @@ extern int lbolt; /* once a second sleep address */
extern int tickdelta;
extern long timedelta;
/*
* The following macros are used to declare global sets of objects, which
* are collected by the linker into a `struct linker_set' as defined below.
*
* NB: the constants defined below must match those defined in
* ld/ld.h. Since their calculation requires arithmetic, we
* can't name them symbolically (e.g., 23 is N_SETT | N_EXT).
*/
#define MAKE_SET(set, sym, type) \
asm(".stabs \"_" #set "\", " #type ", 0, 0, _" #sym)
#define TEXT_SET(set, sym) MAKE_SET(set, sym, 23)
#define DATA_SET(set, sym) MAKE_SET(set, sym, 25)
#define BSS_SET(set, sym) MAKE_SET(set, sym, 27)
#define ABS_SET(set, sym) MAKE_SET(set, sym, 21)
#endif /* KERNEL */
#ifdef PSEUDO_LKM
#include <sys/conf.h>
......@@ -108,11 +98,6 @@ extern long timedelta;
#endif /* PSEUDO_LKM */
struct linker_set {
int ls_length;
caddr_t ls_items[1]; /* really ls_length of them, trailing NULL */
};
extern const struct linker_set execsw_set;
#endif