History log of /openbsd-current/sys/sys/socket.h
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.105 03-Sep-2022 mbuhl

Make recvmmsg and sendmmsg look more alike. change the flag type
to int like other flag parameters, NetBSD uses unsigned int, FreeBSD
and Linux do int.
OK bluhm@


# 1.104 03-Sep-2022 mbuhl

add the sendmmsg syscall that allows sending multiple msghdrs at
once. libc, man page, and regress parts to come.
With input from jca@, bluhm@.
OK bluhm@


# 1.103 02-Sep-2022 mbuhl

add the recvmmsg syscall that allows receiving multiple msghdrs at
once. libc, man page, and regress parts to come.
With input from jca@, guenther@, bluhm@.
OK bluhm@


Revision tags: OPENBSD_7_1_BASE
# 1.102 22-Feb-2022 guenther

pfctlinput() is already declared in <sys/protosw.h>, which is
more specific and appropriate, so delete it here

ok gnezdo@ deraadt@ jsg@ mpi@ millert@


# 1.101 07-Nov-2021 claudio

Fix tpyo of ecma. Reported by Matthew (chohag at jtan dot com)


Revision tags: OPENBSD_7_0_BASE
# 1.100 17-May-2021 claudio

Forgot this directory in last commit for the UNIX-domain socket buffer
change.


Revision tags: OPENBSD_6_9_BASE
# 1.99 29-Oct-2020 denis

Add feature to force the selection of source IP address

Based/previous work on an idea from deraadt@
Input from claudio@, djm@, deraadt@, sthen@

OK deraadt@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.98 22-Jul-2019 robert

implement SO_DOMAIN and SO_PROTOCOL so that the domain and the protocol
can also be retrieved with getsockopt(3)
it looks like these will also be in the next issue of posix:
http://austingroupbugs.net/view.php?id=840#c2263

ok claudio@, sthen@


# 1.97 03-Jul-2019 dlg

prepare sysctl net mib to allow runtime tuning of rx q pressure thresholds

this renames the PF_LINK bit of the mib from "link_layer" to "link".
then it makes it a node that could be used for generic link layer
bits. the first of these is an "ifrxq" node where the "pressure_return"
and "pressure_drop" things go.

ok visa@ deraadt@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.96 08-Apr-2018 guenther

AF_LOCAL was a failed attempt (by POSIX?) to seem less UNIX-specific, but
AF_UNIX is both the historical _and_ standard name, so prefer and recommend
it in the headers, manpages, and kernel.

ok miller@ deraadt@ schwarze@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.95 31-May-2017 markus

new socketoption SO_ZEROIZE: zero out all mbufs sent over socket
ok deraadt bluhm


# 1.94 04-May-2017 bluhm

Introduce sstosa() for converting sockaddr_storage with a type safe
inline function instead of casting it to sockaddr. While there,
use inline instead of __inline for all these conversions. Some
struct sockaddr casts can be avoided completely.
OK dhill@ mpi@


Revision tags: OPENBSD_6_1_BASE
# 1.93 14-Nov-2016 mpi

Automatically create a default lo(4) interface per rdomain.

In order to stop abusing lo0 for all rdomains, a new loopback interface
will be created every time a rdomain is created. The unit number will
be the same as the rdomain, i.e. lo1 will be attached to rdomain 1.

If this loopback interface is already in use it wont be possible to create
the corresponding rdomain.

In order to know which lo(4) interface is attached to a rdomain, its index
is stored in the rtable/rdomain map.

This is a long overdue since the introduction of rtable/rdomain. It also
fixes a recent regression due to resetting the rdomain of an incoming
packet reported by semarie@, Andreas Bartelt and Nils Frohberg.

ok claudio@


# 1.92 28-Sep-2016 jca

Hide RT_TABLEID_MAX behind __BSD_VISIBLE

Alternate define location suggested by deraadt@ and kettenis@, ok kettenis@


# 1.91 12-Sep-2016 guenther

More #include cleanup per POSIX:
- <sys/types.h>: don't pull in <sys/select.h>
- <sys/select.h>: don't pull in <sys/time.h>, but rather declare timeval
and timespec locally
- <sys/time.h>: *do* always pull in <sys/select.h>
- <sys/socket.h>: declare timeval if __BSD_VISIBLE for struct splice

Ports testing and fixed by ajacoutot@
ok deraadt@ millert@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.90 23-Oct-2015 claudio

Introduce a new sysctl NET_RT_IFNAMES that returns only ifnames to ifindex
mappings. This will be used by if_nameindex(3), if_nametoindex(3) and
if_indextoname(3) soon to fix the issues in pledge because of inet6 link
local addressing.
OK mpi@ benno@ deraadt@
The libc version will follow soon so better start updating your kernels


# 1.89 20-Oct-2015 deraadt

At guenther's suggestion replace dnssocket() with a SOCK_DNS flag on
socket(). Without pledge, all other socket behaviours become permitted,
except this one case: connect/send* only works to *:53. In pledge mode,
a very few are further restricted. Some backwards compatibility for
the dnssocket/dnsconnect calls will remain in the tree temporarily so
that people can build through the transition.
ok tedu guenther semarie


Revision tags: OPENBSD_5_8_BASE
# 1.88 17-Jul-2015 guenther

In socketpair(), need to mask the type argument when testing for dgram.

based on jeremy@'s diff
ok jeremy@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.87 21-Jan-2015 guenther

Delete option COMPAT_43: support for pre-sa_len binaries has been obsolete
for a couple decades. Keep the OSIOCGIFCONF ioctl to support COMPAT_LINUX
but move the rest of the Linux-specific ioctl() handling into linux_socket.c
This lets struct osockaddr finally move from sys/socket.h to protocols/talkd.h

ok krw@ deraadt@ mpi@


# 1.86 18-Jan-2015 guenther

Per POSIX, <sys/socket.h> needs to expose struct iovec, and may do so
by pulling in <sys/uio.h>, so do so. Remove some stuff that we can trust
<sys/uio.h> to also provide, like cdefs.h, _types.h, and exposing size_t
and ssize_t

pointed out by naddy@
ok deraadt@


# 1.85 31-Aug-2014 guenther

Add sockatmark()

ok millert@ manpage feedback jmc@


# 1.84 31-Aug-2014 guenther

Add additional kernel interfaces for setting close-on-exec on fds
when creating them: pipe2(), dup3(), accept4(), MSG_CMSG_CLOEXEC,
SOCK_CLOEXEC. Includes SOCK_NONBLOCK support.

ok matthew@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.83 02-Apr-2013 guenther

Use internal types instead of the old BSD u_int#_t types in the
standard portion of the header.

Most of the diff from James Turner (james (at) calminferno.net)


Revision tags: OPENBSD_5_3_BASE
# 1.82 15-Sep-2012 guenther

Improve POSIX/SUS compliance of <netdb.h>, <sys/socket.h>, and <sys/un.h>.

Much ports testing of various versions by naddy@ and jasper@
ok matthew@, miller@


Revision tags: OPENBSD_5_2_BASE
# 1.81 11-Apr-2012 deraadt

tedu struct omsghdr


# 1.80 04-Apr-2012 deraadt

SCM_CREDS can go away, since everything uses the newer APIs.
ports tree checked by naddy


# 1.79 17-Mar-2012 dlg

remove IP_JUMBO, SO_JUMBO, and RTF_JUMBO.

no objection from mcbride@ krw@ markus@ deraadt@


Revision tags: OPENBSD_5_1_BASE
# 1.78 03-Dec-2011 fgsch

add support for MSG_NOSIGNAL.
linux bits compiled on i386 by sebastia@, mikeb@ ok


# 1.77 08-Sep-2011 guenther

Provide namespace-safe alignment macros in <machine/_types.h>, with
compat names kept in <machine/param.h>. In <sys/socket.h>, pull
in <sys/_types.h> instead of the namespace polluting <machine/param.h>
and completely eliminate __CMSG_ALIGN, replaced by _ALIGN

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.76 08-Jul-2011 deraadt

Remove COMPAT_OLDSOCK since no nothing sets MSG_COMPAT anymore.
The song and dance for handling 16-bit af_family on big-endian
machines remains untouched.
ok claudio miod tedu guenther


# 1.75 08-Jul-2011 mikeb

surround splice structure with __BSD_VISIBLE (the right one, noticed by
bluhm, jasper and millert -- an epic fail on my side), style nits from
deraadt, millert, ok guenther, kettenis, millert, ports tests by jasper


# 1.74 08-Jul-2011 yasuoka

this must be included my previous commit.

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.73 04-Jul-2011 mikeb

Implement an idle timeout for the socket splicing. A new `sp_idle'
field of the `splice' structure can be used to specify a period of
inactivity after which splicing will be dissolved. ETIMEDOUT error
retrieved with a SO_ERROR indicates the idle timeout expiration.
With comments from and OK bluhm.


# 1.72 05-Apr-2011 guenther

Push COMPAT_FREEBSD in front of a whale. Buggy, out of date, no
one has been weeding it, and it makes life harder.

Toasts of Brennivin for its passing from many; diff ok henning@


Revision tags: OPENBSD_4_9_BASE
# 1.71 07-Jan-2011 bluhm

Add socket option SO_SPLICE to splice together two TCP sockets.
The data received on the source socket will automatically be sent
on the drain socket. This allows to write relay daemons with zero
data copy.
ok markus@


Revision tags: OPENBSD_4_8_BASE
# 1.70 05-Jul-2010 tedu

remove compat_bsdos support


# 1.69 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.68 02-Jul-2010 tedu

remove support for compat_sunos (and m68k4k). ok deraadt guenther


# 1.67 01-Jul-2010 deraadt

Put SO_PEERCRED into the non-flag area
suggested by guenther


# 1.66 30-Jun-2010 tedu

remove compat_osf1 support from the kernel
ok deraadt miod


# 1.65 30-Jun-2010 deraadt

Add getsockopt SOL_SOCKET SO_PEERCRED support. This behaves similar to
getpeereid(2), but also supplies the remote pid. This is supplied in
a 'struct sockpeercred' (unlike Linux -- they showed how little they
know about real unix by calling theirs 'struct ucred').
ok guenther ajacoutot


# 1.64 29-Jun-2010 guenther

Remove COMPAT_HPUX. No one wanted to support it and its fewmets were
blocking other cleanups
ok miod@


# 1.63 21-Apr-2010 claudio

Implement a way to get information about a rtable. Currently only the rtableid
and rdomainid are returned. This is necessary to know where L2 information
of a table is stored (which will be needed soon by bgpd).
Also while there change the errno for non-existing routing tables to ENOENT.
'Fine' deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.62 27-Nov-2009 guenther

Add setrdomain() and getrdomain() system calls. Committing now to
catch the libc major bump per request from deraadt@

Diff by reyk.

ok guenther@


Revision tags: OPENBSD_4_6_BASE
# 1.61 11-Jun-2009 jsg

tab indent SO_RDOMAIN, like all the other SO_* defines.


# 1.60 05-Jun-2009 claudio

Initial support for routing domains. This allows to bind interfaces to
alternate routing table and separate them from other interfaces in distinct
routing tables. The same network can now be used in any doamin at the same
time without causing conflicts.
This diff is mostly mechanical and adds the necessary rdomain checks accross
net and netinet. L2 and IPv4 are mostly covered still missing pf and IPv6.
input and tested by jsg@, phessler@ and reyk@. "put it in" deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.59 16-Sep-2008 gollo

netstat statistics for pflow(4) via pseudo family

ok cluadio@ henning@


Revision tags: OPENBSD_4_4_BASE
# 1.58 09-May-2008 markus

Add SO_BINDANY socket option from BSD/OS.

The option allows a socket to be bound to addresses which are not
local to the machine. In order to receive packets for these addresses
SO_BINDANY needs to be combined with matching outgoing pf(4) divert
rules, see pf.conf(5).

ok beck@


# 1.57 02-May-2008 ckuethe

Make the SO_TIMESTAMP sockopt work. When set, this allows the user to
get a timestamp of when the datagram was accepted (by udp(4), for
example) rather than having to take a timestamp with gettimeofday(2)
when recv(2) returns - possibly several hundreds of microseconds later.
May be of use to those interested in precision network timing schemes
or QoS for media applications. Tested on alpha, amd64, i386 and sparc64.
manpage suggestions from jmc, ok deraadt


# 1.56 23-Apr-2008 norby

Import MPLS (Multi Protocol Label Switching)

MPLS support partly based on the (abandoned?) AYAME project.
Basic LSR (Label Switch Router) functionality is present, but not fully
functional yet.

It is currently possible to insert entries in the LIB (Label Information Base)
with route(8), but setting the operation type is not supported yet.

Imported to allow more people to work on this in the coming weeks.

ok claudio@ laurent@ dlg@


Revision tags: OPENBSD_4_3_BASE
# 1.55 27-Nov-2007 martynas

typos; ok jmc@
sys/dev/pci/pciide.c from naddy@


# 1.54 24-Sep-2007 henning

updatecomment and manpage toemtion optional seventh level (rtable id)
From: Pierre Riteau <pierre.riteau@free.fr>


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.53 31-Mar-2006 claudio

Add sysctl to retrieve the routing table statisitcs. Will be used by netstat
instead of kvm access. OK henning@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.52 27-May-2005 mcbride

Experimental support for opportunitic use of jumbograms where only some hosts
on the local network support them.

This adds a new socket option, SO_JUMBO, and a new route flag,
RTF_JUMBO. If _both_ the socket option is set and the route for the host
has RTF_JUMBO set, ip_output will fragment the packet to the largest
possible size for the link, ignoring the card's MTU.

The semantics of this feature will be evolving rapidly; talk to us
if you intend to use it.

ok deraadt@ marius@


# 1.51 04-Apr-2005 hshoexer

Add sysctl for dumping the SPD
ok deraadt, ok markus some time ago


# 1.50 22-Mar-2005 henning

fix a typo, don't #define PF_RTIP to something nonmexistant
nothing in our tree uses it (well, would have been spotted then)
netbsd PR kern/29624 via jmc@, agreed on by claudio some time ago


Revision tags: OPENBSD_3_7_BASE
# 1.49 14-Jan-2005 grange

First step in Bluetooth protocol stack support.

The code is adopted from the FreeBSD netgraph-based Bluetooth
implementation by Maksim Yevmenkin <m_evmenkin@yahoo.com> but
all netgraph glue was replaced with usual BSD network stack
hooks. This is a work in progress. Only HCI layer works for now,
L2CAP and RFCOMM are on the way.

Help in testing from many, ok markus@.


# 1.48 26-Nov-2004 markus

add pfkey sysctl subtree; ok deraadt


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.47 24-Feb-2004 tedu

sysctl knob for bpf tunables. some tips from canacar@
ok canacar@ deraadt@ mcbride@


Revision tags: OPENBSD_3_4_BASE
# 1.46 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.45 24-Nov-2002 espie

Explicit unsigned char and unsigned short instead of u_char, u_short.
Make these files usable with -D_POSIX_SOURCE
okay millert@


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.44 10-Sep-2002 deraadt

typo; krapht@secureops.com


Revision tags: OPENBSD_3_1_BASE
# 1.43 15-Mar-2002 itojun

typecast in CMSG_NXTHDR. spotted by hugh@openbsd


# 1.42 14-Mar-2002 millert

First round of __P removal in sys


# 1.41 08-Mar-2002 espie

Make msghdr fields usable from all languages.
ok millert@


# 1.40 10-Jan-2002 itojun

remove duplicated decl of PF_INET6. found by kjc


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.39 07-Sep-2001 itojun

branches: 1.39.4;
just as RFC2292 suggests, validate cmsg_controllen on CMSG_FIRSTHDR.
sync with kame.


# 1.38 26-Jun-2001 dugsong

implement djb's getpeereid(2), to allow local-domain servers to determine client credentials. mostly from superscript.com. deraadt@ ok


# 1.37 22-Jun-2001 deraadt

KNF


# 1.36 28-May-2001 dugsong

add BIOC[GS]HDRCMPLT ioctl for BPF, to disable overwriting of link level source address in forged frames. from NetBSD. art@ok


Revision tags: OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.35 13-Aug-2000 ericj

if COMPAT_OSF1 is defined, define COMPAT_OLDSOCK
and COMPAT_OLDTTY.


# 1.34 02-Jul-2000 fgsch

MSG_COMPAT is needed for COMPAT_BSDOS too.


Revision tags: OPENBSD_2_7_BASE
# 1.33 03-Apr-2000 itojun

hide CMSG_ALIGN from userland, it is not part of RFC2292/Posix.1g.


# 1.32 04-Mar-2000 itojun

to be Posix.1g compliant, fix ancillary message alignment. it will now be
aligned to ALIGNBYTES (arch dependent).
NOTE: the change requires you to recompile IPv6 userland, if you are
on arch that is ALIGNBYTES != sizeof(long) - 1 (sparc seems to be it).
sorry for the mess.


# 1.31 18-Feb-2000 itojun

fix alignment problem in ancillary data (alpha).

only ipv6 tools (which touches ancillary data) are affected.

From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


Revision tags: SMP_BASE kame_19991208
# 1.30 08-Dec-1999 itojun

branches: 1.30.2;
bring in KAME IPv6 code, dated 19991208.
replaces NRL IPv6 layer. reuses NRL pcb layer. no IPsec-on-v6 support.
see sys/netinet6/{TODO,IMPLEMENTATION} for more details.

GENERIC configuration should work fine as before. GENERIC.v6 works fine
as well, but you'll need KAME userland tools to play with IPv6 (will be
bringed into soon).


Revision tags: OPENBSD_2_6_BASE
# 1.29 06-Jun-1999 deraadt

sockaddr_storage; per rfc2553


Revision tags: OPENBSD_2_5_BASE
# 1.28 25-Feb-1999 deraadt

rename sysctl names


# 1.27 25-Feb-1999 deraadt

sockaddr_union cannot be declared here, obviously, or in any other file that i know of


# 1.26 24-Feb-1999 angelos

Changes to socket.h to include union sockaddr_union, temporarily add osdep.h,
until pfkey files are cleaned up.


# 1.25 16-Feb-1999 millert

sendto(2) takes socklen_t for length param


# 1.24 15-Feb-1999 millert

pasto


# 1.23 15-Feb-1999 millert

more uses of socklen_t


# 1.22 15-Feb-1999 millert

Use and document socklen_t


# 1.21 05-Feb-1999 deraadt

support MSG_BCAST and MSG_MCAST


# 1.20 10-Jan-1999 deraadt

add SO_NETPROC and CMSG_{FIRSTHDR,ALIGN,LEN,SPACE}; cmetz


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.19 30-Nov-1997 millert

Move in_addr_t and in_port_t to <sys/types.h> and add sa_family_t
and suseconds_t types for XPG4.2.


# 1.18 16-Nov-1997 deraadt

add SHUT_* values as defined by XPG4.2


Revision tags: OPENBSD_2_2_BASE
# 1.17 14-Jul-1997 angelos

Fix the CTLNET order.


Revision tags: OPENBSD_2_1_BASE
# 1.16 24-Apr-1997 angelos

Added PF_KEY definition.


# 1.15 12-Mar-1997 downsj

Move AF_SIP and put AF_INET6 in the same location as BSD/OS.

I couldn't find any use of AF_SIP in the kernel, didn't check user land.


# 1.14 28-Feb-1997 angelos

Moved everything to netinet/in.h, where they should have been in the
first place.


# 1.13 28-Feb-1997 angelos

Per security-level defaults.


# 1.12 28-Feb-1997 angelos

Can't make up my mind; i think this is final.


# 1.11 28-Feb-1997 angelos

IPsec socket API.


# 1.10 22-Feb-1997 angelos

Preliminaries for IPsec socket API.


# 1.9 20-Feb-1997 deraadt

IPSEC package by John Ioannidis and Angelos D. Keromytis. Written in
Greece. From ftp.funet.fi:/pub/unix/security/net/ip/BSDipsec.tar.gz


# 1.8 12-Dec-1996 mickey

undo last change.


# 1.7 12-Dec-1996 deraadt

wrong place for bindresvport() proto


# 1.6 12-Dec-1996 mickey

struct sockaddr_in; prototype


# 1.5 12-Dec-1996 mickey

int bindresvport __P((int sd, struct sockaddr_in *sin));


Revision tags: OPENBSD_2_0_BASE
# 1.4 03-Jul-1996 chuck

renumber AF_NATM to avoid a conflict with freebsd which put ISDN @ 26.
(i should have checked first)


# 1.3 30-Jun-1996 chuck

add native mode atm socket type


# 1.2 29-Feb-1996 niklas

From NetBSD: Merge with NetBSD 960217


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.104 03-Sep-2022 mbuhl

add the sendmmsg syscall that allows sending multiple msghdrs at
once. libc, man page, and regress parts to come.
With input from jca@, bluhm@.
OK bluhm@


# 1.103 02-Sep-2022 mbuhl

add the recvmmsg syscall that allows receiving multiple msghdrs at
once. libc, man page, and regress parts to come.
With input from jca@, guenther@, bluhm@.
OK bluhm@


Revision tags: OPENBSD_7_1_BASE
# 1.102 22-Feb-2022 guenther

pfctlinput() is already declared in <sys/protosw.h>, which is
more specific and appropriate, so delete it here

ok gnezdo@ deraadt@ jsg@ mpi@ millert@


# 1.101 07-Nov-2021 claudio

Fix tpyo of ecma. Reported by Matthew (chohag at jtan dot com)


Revision tags: OPENBSD_7_0_BASE
# 1.100 17-May-2021 claudio

Forgot this directory in last commit for the UNIX-domain socket buffer
change.


Revision tags: OPENBSD_6_9_BASE
# 1.99 29-Oct-2020 denis

Add feature to force the selection of source IP address

Based/previous work on an idea from deraadt@
Input from claudio@, djm@, deraadt@, sthen@

OK deraadt@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.98 22-Jul-2019 robert

implement SO_DOMAIN and SO_PROTOCOL so that the domain and the protocol
can also be retrieved with getsockopt(3)
it looks like these will also be in the next issue of posix:
http://austingroupbugs.net/view.php?id=840#c2263

ok claudio@, sthen@


# 1.97 03-Jul-2019 dlg

prepare sysctl net mib to allow runtime tuning of rx q pressure thresholds

this renames the PF_LINK bit of the mib from "link_layer" to "link".
then it makes it a node that could be used for generic link layer
bits. the first of these is an "ifrxq" node where the "pressure_return"
and "pressure_drop" things go.

ok visa@ deraadt@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.96 08-Apr-2018 guenther

AF_LOCAL was a failed attempt (by POSIX?) to seem less UNIX-specific, but
AF_UNIX is both the historical _and_ standard name, so prefer and recommend
it in the headers, manpages, and kernel.

ok miller@ deraadt@ schwarze@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.95 31-May-2017 markus

new socketoption SO_ZEROIZE: zero out all mbufs sent over socket
ok deraadt bluhm


# 1.94 04-May-2017 bluhm

Introduce sstosa() for converting sockaddr_storage with a type safe
inline function instead of casting it to sockaddr. While there,
use inline instead of __inline for all these conversions. Some
struct sockaddr casts can be avoided completely.
OK dhill@ mpi@


Revision tags: OPENBSD_6_1_BASE
# 1.93 14-Nov-2016 mpi

Automatically create a default lo(4) interface per rdomain.

In order to stop abusing lo0 for all rdomains, a new loopback interface
will be created every time a rdomain is created. The unit number will
be the same as the rdomain, i.e. lo1 will be attached to rdomain 1.

If this loopback interface is already in use it wont be possible to create
the corresponding rdomain.

In order to know which lo(4) interface is attached to a rdomain, its index
is stored in the rtable/rdomain map.

This is a long overdue since the introduction of rtable/rdomain. It also
fixes a recent regression due to resetting the rdomain of an incoming
packet reported by semarie@, Andreas Bartelt and Nils Frohberg.

ok claudio@


# 1.92 28-Sep-2016 jca

Hide RT_TABLEID_MAX behind __BSD_VISIBLE

Alternate define location suggested by deraadt@ and kettenis@, ok kettenis@


# 1.91 12-Sep-2016 guenther

More #include cleanup per POSIX:
- <sys/types.h>: don't pull in <sys/select.h>
- <sys/select.h>: don't pull in <sys/time.h>, but rather declare timeval
and timespec locally
- <sys/time.h>: *do* always pull in <sys/select.h>
- <sys/socket.h>: declare timeval if __BSD_VISIBLE for struct splice

Ports testing and fixed by ajacoutot@
ok deraadt@ millert@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.90 23-Oct-2015 claudio

Introduce a new sysctl NET_RT_IFNAMES that returns only ifnames to ifindex
mappings. This will be used by if_nameindex(3), if_nametoindex(3) and
if_indextoname(3) soon to fix the issues in pledge because of inet6 link
local addressing.
OK mpi@ benno@ deraadt@
The libc version will follow soon so better start updating your kernels


# 1.89 20-Oct-2015 deraadt

At guenther's suggestion replace dnssocket() with a SOCK_DNS flag on
socket(). Without pledge, all other socket behaviours become permitted,
except this one case: connect/send* only works to *:53. In pledge mode,
a very few are further restricted. Some backwards compatibility for
the dnssocket/dnsconnect calls will remain in the tree temporarily so
that people can build through the transition.
ok tedu guenther semarie


Revision tags: OPENBSD_5_8_BASE
# 1.88 17-Jul-2015 guenther

In socketpair(), need to mask the type argument when testing for dgram.

based on jeremy@'s diff
ok jeremy@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.87 21-Jan-2015 guenther

Delete option COMPAT_43: support for pre-sa_len binaries has been obsolete
for a couple decades. Keep the OSIOCGIFCONF ioctl to support COMPAT_LINUX
but move the rest of the Linux-specific ioctl() handling into linux_socket.c
This lets struct osockaddr finally move from sys/socket.h to protocols/talkd.h

ok krw@ deraadt@ mpi@


# 1.86 18-Jan-2015 guenther

Per POSIX, <sys/socket.h> needs to expose struct iovec, and may do so
by pulling in <sys/uio.h>, so do so. Remove some stuff that we can trust
<sys/uio.h> to also provide, like cdefs.h, _types.h, and exposing size_t
and ssize_t

pointed out by naddy@
ok deraadt@


# 1.85 31-Aug-2014 guenther

Add sockatmark()

ok millert@ manpage feedback jmc@


# 1.84 31-Aug-2014 guenther

Add additional kernel interfaces for setting close-on-exec on fds
when creating them: pipe2(), dup3(), accept4(), MSG_CMSG_CLOEXEC,
SOCK_CLOEXEC. Includes SOCK_NONBLOCK support.

ok matthew@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.83 02-Apr-2013 guenther

Use internal types instead of the old BSD u_int#_t types in the
standard portion of the header.

Most of the diff from James Turner (james (at) calminferno.net)


Revision tags: OPENBSD_5_3_BASE
# 1.82 15-Sep-2012 guenther

Improve POSIX/SUS compliance of <netdb.h>, <sys/socket.h>, and <sys/un.h>.

Much ports testing of various versions by naddy@ and jasper@
ok matthew@, miller@


Revision tags: OPENBSD_5_2_BASE
# 1.81 11-Apr-2012 deraadt

tedu struct omsghdr


# 1.80 04-Apr-2012 deraadt

SCM_CREDS can go away, since everything uses the newer APIs.
ports tree checked by naddy


# 1.79 17-Mar-2012 dlg

remove IP_JUMBO, SO_JUMBO, and RTF_JUMBO.

no objection from mcbride@ krw@ markus@ deraadt@


Revision tags: OPENBSD_5_1_BASE
# 1.78 03-Dec-2011 fgsch

add support for MSG_NOSIGNAL.
linux bits compiled on i386 by sebastia@, mikeb@ ok


# 1.77 08-Sep-2011 guenther

Provide namespace-safe alignment macros in <machine/_types.h>, with
compat names kept in <machine/param.h>. In <sys/socket.h>, pull
in <sys/_types.h> instead of the namespace polluting <machine/param.h>
and completely eliminate __CMSG_ALIGN, replaced by _ALIGN

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.76 08-Jul-2011 deraadt

Remove COMPAT_OLDSOCK since no nothing sets MSG_COMPAT anymore.
The song and dance for handling 16-bit af_family on big-endian
machines remains untouched.
ok claudio miod tedu guenther


# 1.75 08-Jul-2011 mikeb

surround splice structure with __BSD_VISIBLE (the right one, noticed by
bluhm, jasper and millert -- an epic fail on my side), style nits from
deraadt, millert, ok guenther, kettenis, millert, ports tests by jasper


# 1.74 08-Jul-2011 yasuoka

this must be included my previous commit.

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.73 04-Jul-2011 mikeb

Implement an idle timeout for the socket splicing. A new `sp_idle'
field of the `splice' structure can be used to specify a period of
inactivity after which splicing will be dissolved. ETIMEDOUT error
retrieved with a SO_ERROR indicates the idle timeout expiration.
With comments from and OK bluhm.


# 1.72 05-Apr-2011 guenther

Push COMPAT_FREEBSD in front of a whale. Buggy, out of date, no
one has been weeding it, and it makes life harder.

Toasts of Brennivin for its passing from many; diff ok henning@


Revision tags: OPENBSD_4_9_BASE
# 1.71 07-Jan-2011 bluhm

Add socket option SO_SPLICE to splice together two TCP sockets.
The data received on the source socket will automatically be sent
on the drain socket. This allows to write relay daemons with zero
data copy.
ok markus@


Revision tags: OPENBSD_4_8_BASE
# 1.70 05-Jul-2010 tedu

remove compat_bsdos support


# 1.69 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.68 02-Jul-2010 tedu

remove support for compat_sunos (and m68k4k). ok deraadt guenther


# 1.67 01-Jul-2010 deraadt

Put SO_PEERCRED into the non-flag area
suggested by guenther


# 1.66 30-Jun-2010 tedu

remove compat_osf1 support from the kernel
ok deraadt miod


# 1.65 30-Jun-2010 deraadt

Add getsockopt SOL_SOCKET SO_PEERCRED support. This behaves similar to
getpeereid(2), but also supplies the remote pid. This is supplied in
a 'struct sockpeercred' (unlike Linux -- they showed how little they
know about real unix by calling theirs 'struct ucred').
ok guenther ajacoutot


# 1.64 29-Jun-2010 guenther

Remove COMPAT_HPUX. No one wanted to support it and its fewmets were
blocking other cleanups
ok miod@


# 1.63 21-Apr-2010 claudio

Implement a way to get information about a rtable. Currently only the rtableid
and rdomainid are returned. This is necessary to know where L2 information
of a table is stored (which will be needed soon by bgpd).
Also while there change the errno for non-existing routing tables to ENOENT.
'Fine' deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.62 27-Nov-2009 guenther

Add setrdomain() and getrdomain() system calls. Committing now to
catch the libc major bump per request from deraadt@

Diff by reyk.

ok guenther@


Revision tags: OPENBSD_4_6_BASE
# 1.61 11-Jun-2009 jsg

tab indent SO_RDOMAIN, like all the other SO_* defines.


# 1.60 05-Jun-2009 claudio

Initial support for routing domains. This allows to bind interfaces to
alternate routing table and separate them from other interfaces in distinct
routing tables. The same network can now be used in any doamin at the same
time without causing conflicts.
This diff is mostly mechanical and adds the necessary rdomain checks accross
net and netinet. L2 and IPv4 are mostly covered still missing pf and IPv6.
input and tested by jsg@, phessler@ and reyk@. "put it in" deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.59 16-Sep-2008 gollo

netstat statistics for pflow(4) via pseudo family

ok cluadio@ henning@


Revision tags: OPENBSD_4_4_BASE
# 1.58 09-May-2008 markus

Add SO_BINDANY socket option from BSD/OS.

The option allows a socket to be bound to addresses which are not
local to the machine. In order to receive packets for these addresses
SO_BINDANY needs to be combined with matching outgoing pf(4) divert
rules, see pf.conf(5).

ok beck@


# 1.57 02-May-2008 ckuethe

Make the SO_TIMESTAMP sockopt work. When set, this allows the user to
get a timestamp of when the datagram was accepted (by udp(4), for
example) rather than having to take a timestamp with gettimeofday(2)
when recv(2) returns - possibly several hundreds of microseconds later.
May be of use to those interested in precision network timing schemes
or QoS for media applications. Tested on alpha, amd64, i386 and sparc64.
manpage suggestions from jmc, ok deraadt


# 1.56 23-Apr-2008 norby

Import MPLS (Multi Protocol Label Switching)

MPLS support partly based on the (abandoned?) AYAME project.
Basic LSR (Label Switch Router) functionality is present, but not fully
functional yet.

It is currently possible to insert entries in the LIB (Label Information Base)
with route(8), but setting the operation type is not supported yet.

Imported to allow more people to work on this in the coming weeks.

ok claudio@ laurent@ dlg@


Revision tags: OPENBSD_4_3_BASE
# 1.55 27-Nov-2007 martynas

typos; ok jmc@
sys/dev/pci/pciide.c from naddy@


# 1.54 24-Sep-2007 henning

updatecomment and manpage toemtion optional seventh level (rtable id)
From: Pierre Riteau <pierre.riteau@free.fr>


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.53 31-Mar-2006 claudio

Add sysctl to retrieve the routing table statisitcs. Will be used by netstat
instead of kvm access. OK henning@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.52 27-May-2005 mcbride

Experimental support for opportunitic use of jumbograms where only some hosts
on the local network support them.

This adds a new socket option, SO_JUMBO, and a new route flag,
RTF_JUMBO. If _both_ the socket option is set and the route for the host
has RTF_JUMBO set, ip_output will fragment the packet to the largest
possible size for the link, ignoring the card's MTU.

The semantics of this feature will be evolving rapidly; talk to us
if you intend to use it.

ok deraadt@ marius@


# 1.51 04-Apr-2005 hshoexer

Add sysctl for dumping the SPD
ok deraadt, ok markus some time ago


# 1.50 22-Mar-2005 henning

fix a typo, don't #define PF_RTIP to something nonmexistant
nothing in our tree uses it (well, would have been spotted then)
netbsd PR kern/29624 via jmc@, agreed on by claudio some time ago


Revision tags: OPENBSD_3_7_BASE
# 1.49 14-Jan-2005 grange

First step in Bluetooth protocol stack support.

The code is adopted from the FreeBSD netgraph-based Bluetooth
implementation by Maksim Yevmenkin <m_evmenkin@yahoo.com> but
all netgraph glue was replaced with usual BSD network stack
hooks. This is a work in progress. Only HCI layer works for now,
L2CAP and RFCOMM are on the way.

Help in testing from many, ok markus@.


# 1.48 26-Nov-2004 markus

add pfkey sysctl subtree; ok deraadt


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.47 24-Feb-2004 tedu

sysctl knob for bpf tunables. some tips from canacar@
ok canacar@ deraadt@ mcbride@


Revision tags: OPENBSD_3_4_BASE
# 1.46 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.45 24-Nov-2002 espie

Explicit unsigned char and unsigned short instead of u_char, u_short.
Make these files usable with -D_POSIX_SOURCE
okay millert@


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.44 10-Sep-2002 deraadt

typo; krapht@secureops.com


Revision tags: OPENBSD_3_1_BASE
# 1.43 15-Mar-2002 itojun

typecast in CMSG_NXTHDR. spotted by hugh@openbsd


# 1.42 14-Mar-2002 millert

First round of __P removal in sys


# 1.41 08-Mar-2002 espie

Make msghdr fields usable from all languages.
ok millert@


# 1.40 10-Jan-2002 itojun

remove duplicated decl of PF_INET6. found by kjc


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.39 07-Sep-2001 itojun

branches: 1.39.4;
just as RFC2292 suggests, validate cmsg_controllen on CMSG_FIRSTHDR.
sync with kame.


# 1.38 26-Jun-2001 dugsong

implement djb's getpeereid(2), to allow local-domain servers to determine client credentials. mostly from superscript.com. deraadt@ ok


# 1.37 22-Jun-2001 deraadt

KNF


# 1.36 28-May-2001 dugsong

add BIOC[GS]HDRCMPLT ioctl for BPF, to disable overwriting of link level source address in forged frames. from NetBSD. art@ok


Revision tags: OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.35 13-Aug-2000 ericj

if COMPAT_OSF1 is defined, define COMPAT_OLDSOCK
and COMPAT_OLDTTY.


# 1.34 02-Jul-2000 fgsch

MSG_COMPAT is needed for COMPAT_BSDOS too.


Revision tags: OPENBSD_2_7_BASE
# 1.33 03-Apr-2000 itojun

hide CMSG_ALIGN from userland, it is not part of RFC2292/Posix.1g.


# 1.32 04-Mar-2000 itojun

to be Posix.1g compliant, fix ancillary message alignment. it will now be
aligned to ALIGNBYTES (arch dependent).
NOTE: the change requires you to recompile IPv6 userland, if you are
on arch that is ALIGNBYTES != sizeof(long) - 1 (sparc seems to be it).
sorry for the mess.


# 1.31 18-Feb-2000 itojun

fix alignment problem in ancillary data (alpha).

only ipv6 tools (which touches ancillary data) are affected.

From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


Revision tags: SMP_BASE kame_19991208
# 1.30 08-Dec-1999 itojun

branches: 1.30.2;
bring in KAME IPv6 code, dated 19991208.
replaces NRL IPv6 layer. reuses NRL pcb layer. no IPsec-on-v6 support.
see sys/netinet6/{TODO,IMPLEMENTATION} for more details.

GENERIC configuration should work fine as before. GENERIC.v6 works fine
as well, but you'll need KAME userland tools to play with IPv6 (will be
bringed into soon).


Revision tags: OPENBSD_2_6_BASE
# 1.29 06-Jun-1999 deraadt

sockaddr_storage; per rfc2553


Revision tags: OPENBSD_2_5_BASE
# 1.28 25-Feb-1999 deraadt

rename sysctl names


# 1.27 25-Feb-1999 deraadt

sockaddr_union cannot be declared here, obviously, or in any other file that i know of


# 1.26 24-Feb-1999 angelos

Changes to socket.h to include union sockaddr_union, temporarily add osdep.h,
until pfkey files are cleaned up.


# 1.25 16-Feb-1999 millert

sendto(2) takes socklen_t for length param


# 1.24 15-Feb-1999 millert

pasto


# 1.23 15-Feb-1999 millert

more uses of socklen_t


# 1.22 15-Feb-1999 millert

Use and document socklen_t


# 1.21 05-Feb-1999 deraadt

support MSG_BCAST and MSG_MCAST


# 1.20 10-Jan-1999 deraadt

add SO_NETPROC and CMSG_{FIRSTHDR,ALIGN,LEN,SPACE}; cmetz


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.19 30-Nov-1997 millert

Move in_addr_t and in_port_t to <sys/types.h> and add sa_family_t
and suseconds_t types for XPG4.2.


# 1.18 16-Nov-1997 deraadt

add SHUT_* values as defined by XPG4.2


Revision tags: OPENBSD_2_2_BASE
# 1.17 14-Jul-1997 angelos

Fix the CTLNET order.


Revision tags: OPENBSD_2_1_BASE
# 1.16 24-Apr-1997 angelos

Added PF_KEY definition.


# 1.15 12-Mar-1997 downsj

Move AF_SIP and put AF_INET6 in the same location as BSD/OS.

I couldn't find any use of AF_SIP in the kernel, didn't check user land.


# 1.14 28-Feb-1997 angelos

Moved everything to netinet/in.h, where they should have been in the
first place.


# 1.13 28-Feb-1997 angelos

Per security-level defaults.


# 1.12 28-Feb-1997 angelos

Can't make up my mind; i think this is final.


# 1.11 28-Feb-1997 angelos

IPsec socket API.


# 1.10 22-Feb-1997 angelos

Preliminaries for IPsec socket API.


# 1.9 20-Feb-1997 deraadt

IPSEC package by John Ioannidis and Angelos D. Keromytis. Written in
Greece. From ftp.funet.fi:/pub/unix/security/net/ip/BSDipsec.tar.gz


# 1.8 12-Dec-1996 mickey

undo last change.


# 1.7 12-Dec-1996 deraadt

wrong place for bindresvport() proto


# 1.6 12-Dec-1996 mickey

struct sockaddr_in; prototype


# 1.5 12-Dec-1996 mickey

int bindresvport __P((int sd, struct sockaddr_in *sin));


Revision tags: OPENBSD_2_0_BASE
# 1.4 03-Jul-1996 chuck

renumber AF_NATM to avoid a conflict with freebsd which put ISDN @ 26.
(i should have checked first)


# 1.3 30-Jun-1996 chuck

add native mode atm socket type


# 1.2 29-Feb-1996 niklas

From NetBSD: Merge with NetBSD 960217


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.102 22-Feb-2022 guenther

pfctlinput() is already declared in <sys/protosw.h>, which is
more specific and appropriate, so delete it here

ok gnezdo@ deraadt@ jsg@ mpi@ millert@


# 1.101 07-Nov-2021 claudio

Fix tpyo of ecma. Reported by Matthew (chohag at jtan dot com)


Revision tags: OPENBSD_7_0_BASE
# 1.100 17-May-2021 claudio

Forgot this directory in last commit for the UNIX-domain socket buffer
change.


Revision tags: OPENBSD_6_9_BASE
# 1.99 29-Oct-2020 denis

Add feature to force the selection of source IP address

Based/previous work on an idea from deraadt@
Input from claudio@, djm@, deraadt@, sthen@

OK deraadt@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.98 22-Jul-2019 robert

implement SO_DOMAIN and SO_PROTOCOL so that the domain and the protocol
can also be retrieved with getsockopt(3)
it looks like these will also be in the next issue of posix:
http://austingroupbugs.net/view.php?id=840#c2263

ok claudio@, sthen@


# 1.97 03-Jul-2019 dlg

prepare sysctl net mib to allow runtime tuning of rx q pressure thresholds

this renames the PF_LINK bit of the mib from "link_layer" to "link".
then it makes it a node that could be used for generic link layer
bits. the first of these is an "ifrxq" node where the "pressure_return"
and "pressure_drop" things go.

ok visa@ deraadt@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.96 08-Apr-2018 guenther

AF_LOCAL was a failed attempt (by POSIX?) to seem less UNIX-specific, but
AF_UNIX is both the historical _and_ standard name, so prefer and recommend
it in the headers, manpages, and kernel.

ok miller@ deraadt@ schwarze@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.95 31-May-2017 markus

new socketoption SO_ZEROIZE: zero out all mbufs sent over socket
ok deraadt bluhm


# 1.94 04-May-2017 bluhm

Introduce sstosa() for converting sockaddr_storage with a type safe
inline function instead of casting it to sockaddr. While there,
use inline instead of __inline for all these conversions. Some
struct sockaddr casts can be avoided completely.
OK dhill@ mpi@


Revision tags: OPENBSD_6_1_BASE
# 1.93 14-Nov-2016 mpi

Automatically create a default lo(4) interface per rdomain.

In order to stop abusing lo0 for all rdomains, a new loopback interface
will be created every time a rdomain is created. The unit number will
be the same as the rdomain, i.e. lo1 will be attached to rdomain 1.

If this loopback interface is already in use it wont be possible to create
the corresponding rdomain.

In order to know which lo(4) interface is attached to a rdomain, its index
is stored in the rtable/rdomain map.

This is a long overdue since the introduction of rtable/rdomain. It also
fixes a recent regression due to resetting the rdomain of an incoming
packet reported by semarie@, Andreas Bartelt and Nils Frohberg.

ok claudio@


# 1.92 28-Sep-2016 jca

Hide RT_TABLEID_MAX behind __BSD_VISIBLE

Alternate define location suggested by deraadt@ and kettenis@, ok kettenis@


# 1.91 12-Sep-2016 guenther

More #include cleanup per POSIX:
- <sys/types.h>: don't pull in <sys/select.h>
- <sys/select.h>: don't pull in <sys/time.h>, but rather declare timeval
and timespec locally
- <sys/time.h>: *do* always pull in <sys/select.h>
- <sys/socket.h>: declare timeval if __BSD_VISIBLE for struct splice

Ports testing and fixed by ajacoutot@
ok deraadt@ millert@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.90 23-Oct-2015 claudio

Introduce a new sysctl NET_RT_IFNAMES that returns only ifnames to ifindex
mappings. This will be used by if_nameindex(3), if_nametoindex(3) and
if_indextoname(3) soon to fix the issues in pledge because of inet6 link
local addressing.
OK mpi@ benno@ deraadt@
The libc version will follow soon so better start updating your kernels


# 1.89 20-Oct-2015 deraadt

At guenther's suggestion replace dnssocket() with a SOCK_DNS flag on
socket(). Without pledge, all other socket behaviours become permitted,
except this one case: connect/send* only works to *:53. In pledge mode,
a very few are further restricted. Some backwards compatibility for
the dnssocket/dnsconnect calls will remain in the tree temporarily so
that people can build through the transition.
ok tedu guenther semarie


Revision tags: OPENBSD_5_8_BASE
# 1.88 17-Jul-2015 guenther

In socketpair(), need to mask the type argument when testing for dgram.

based on jeremy@'s diff
ok jeremy@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.87 21-Jan-2015 guenther

Delete option COMPAT_43: support for pre-sa_len binaries has been obsolete
for a couple decades. Keep the OSIOCGIFCONF ioctl to support COMPAT_LINUX
but move the rest of the Linux-specific ioctl() handling into linux_socket.c
This lets struct osockaddr finally move from sys/socket.h to protocols/talkd.h

ok krw@ deraadt@ mpi@


# 1.86 18-Jan-2015 guenther

Per POSIX, <sys/socket.h> needs to expose struct iovec, and may do so
by pulling in <sys/uio.h>, so do so. Remove some stuff that we can trust
<sys/uio.h> to also provide, like cdefs.h, _types.h, and exposing size_t
and ssize_t

pointed out by naddy@
ok deraadt@


# 1.85 31-Aug-2014 guenther

Add sockatmark()

ok millert@ manpage feedback jmc@


# 1.84 31-Aug-2014 guenther

Add additional kernel interfaces for setting close-on-exec on fds
when creating them: pipe2(), dup3(), accept4(), MSG_CMSG_CLOEXEC,
SOCK_CLOEXEC. Includes SOCK_NONBLOCK support.

ok matthew@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.83 02-Apr-2013 guenther

Use internal types instead of the old BSD u_int#_t types in the
standard portion of the header.

Most of the diff from James Turner (james (at) calminferno.net)


Revision tags: OPENBSD_5_3_BASE
# 1.82 15-Sep-2012 guenther

Improve POSIX/SUS compliance of <netdb.h>, <sys/socket.h>, and <sys/un.h>.

Much ports testing of various versions by naddy@ and jasper@
ok matthew@, miller@


Revision tags: OPENBSD_5_2_BASE
# 1.81 11-Apr-2012 deraadt

tedu struct omsghdr


# 1.80 04-Apr-2012 deraadt

SCM_CREDS can go away, since everything uses the newer APIs.
ports tree checked by naddy


# 1.79 17-Mar-2012 dlg

remove IP_JUMBO, SO_JUMBO, and RTF_JUMBO.

no objection from mcbride@ krw@ markus@ deraadt@


Revision tags: OPENBSD_5_1_BASE
# 1.78 03-Dec-2011 fgsch

add support for MSG_NOSIGNAL.
linux bits compiled on i386 by sebastia@, mikeb@ ok


# 1.77 08-Sep-2011 guenther

Provide namespace-safe alignment macros in <machine/_types.h>, with
compat names kept in <machine/param.h>. In <sys/socket.h>, pull
in <sys/_types.h> instead of the namespace polluting <machine/param.h>
and completely eliminate __CMSG_ALIGN, replaced by _ALIGN

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.76 08-Jul-2011 deraadt

Remove COMPAT_OLDSOCK since no nothing sets MSG_COMPAT anymore.
The song and dance for handling 16-bit af_family on big-endian
machines remains untouched.
ok claudio miod tedu guenther


# 1.75 08-Jul-2011 mikeb

surround splice structure with __BSD_VISIBLE (the right one, noticed by
bluhm, jasper and millert -- an epic fail on my side), style nits from
deraadt, millert, ok guenther, kettenis, millert, ports tests by jasper


# 1.74 08-Jul-2011 yasuoka

this must be included my previous commit.

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.73 04-Jul-2011 mikeb

Implement an idle timeout for the socket splicing. A new `sp_idle'
field of the `splice' structure can be used to specify a period of
inactivity after which splicing will be dissolved. ETIMEDOUT error
retrieved with a SO_ERROR indicates the idle timeout expiration.
With comments from and OK bluhm.


# 1.72 05-Apr-2011 guenther

Push COMPAT_FREEBSD in front of a whale. Buggy, out of date, no
one has been weeding it, and it makes life harder.

Toasts of Brennivin for its passing from many; diff ok henning@


Revision tags: OPENBSD_4_9_BASE
# 1.71 07-Jan-2011 bluhm

Add socket option SO_SPLICE to splice together two TCP sockets.
The data received on the source socket will automatically be sent
on the drain socket. This allows to write relay daemons with zero
data copy.
ok markus@


Revision tags: OPENBSD_4_8_BASE
# 1.70 05-Jul-2010 tedu

remove compat_bsdos support


# 1.69 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.68 02-Jul-2010 tedu

remove support for compat_sunos (and m68k4k). ok deraadt guenther


# 1.67 01-Jul-2010 deraadt

Put SO_PEERCRED into the non-flag area
suggested by guenther


# 1.66 30-Jun-2010 tedu

remove compat_osf1 support from the kernel
ok deraadt miod


# 1.65 30-Jun-2010 deraadt

Add getsockopt SOL_SOCKET SO_PEERCRED support. This behaves similar to
getpeereid(2), but also supplies the remote pid. This is supplied in
a 'struct sockpeercred' (unlike Linux -- they showed how little they
know about real unix by calling theirs 'struct ucred').
ok guenther ajacoutot


# 1.64 29-Jun-2010 guenther

Remove COMPAT_HPUX. No one wanted to support it and its fewmets were
blocking other cleanups
ok miod@


# 1.63 21-Apr-2010 claudio

Implement a way to get information about a rtable. Currently only the rtableid
and rdomainid are returned. This is necessary to know where L2 information
of a table is stored (which will be needed soon by bgpd).
Also while there change the errno for non-existing routing tables to ENOENT.
'Fine' deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.62 27-Nov-2009 guenther

Add setrdomain() and getrdomain() system calls. Committing now to
catch the libc major bump per request from deraadt@

Diff by reyk.

ok guenther@


Revision tags: OPENBSD_4_6_BASE
# 1.61 11-Jun-2009 jsg

tab indent SO_RDOMAIN, like all the other SO_* defines.


# 1.60 05-Jun-2009 claudio

Initial support for routing domains. This allows to bind interfaces to
alternate routing table and separate them from other interfaces in distinct
routing tables. The same network can now be used in any doamin at the same
time without causing conflicts.
This diff is mostly mechanical and adds the necessary rdomain checks accross
net and netinet. L2 and IPv4 are mostly covered still missing pf and IPv6.
input and tested by jsg@, phessler@ and reyk@. "put it in" deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.59 16-Sep-2008 gollo

netstat statistics for pflow(4) via pseudo family

ok cluadio@ henning@


Revision tags: OPENBSD_4_4_BASE
# 1.58 09-May-2008 markus

Add SO_BINDANY socket option from BSD/OS.

The option allows a socket to be bound to addresses which are not
local to the machine. In order to receive packets for these addresses
SO_BINDANY needs to be combined with matching outgoing pf(4) divert
rules, see pf.conf(5).

ok beck@


# 1.57 02-May-2008 ckuethe

Make the SO_TIMESTAMP sockopt work. When set, this allows the user to
get a timestamp of when the datagram was accepted (by udp(4), for
example) rather than having to take a timestamp with gettimeofday(2)
when recv(2) returns - possibly several hundreds of microseconds later.
May be of use to those interested in precision network timing schemes
or QoS for media applications. Tested on alpha, amd64, i386 and sparc64.
manpage suggestions from jmc, ok deraadt


# 1.56 23-Apr-2008 norby

Import MPLS (Multi Protocol Label Switching)

MPLS support partly based on the (abandoned?) AYAME project.
Basic LSR (Label Switch Router) functionality is present, but not fully
functional yet.

It is currently possible to insert entries in the LIB (Label Information Base)
with route(8), but setting the operation type is not supported yet.

Imported to allow more people to work on this in the coming weeks.

ok claudio@ laurent@ dlg@


Revision tags: OPENBSD_4_3_BASE
# 1.55 27-Nov-2007 martynas

typos; ok jmc@
sys/dev/pci/pciide.c from naddy@


# 1.54 24-Sep-2007 henning

updatecomment and manpage toemtion optional seventh level (rtable id)
From: Pierre Riteau <pierre.riteau@free.fr>


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.53 31-Mar-2006 claudio

Add sysctl to retrieve the routing table statisitcs. Will be used by netstat
instead of kvm access. OK henning@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.52 27-May-2005 mcbride

Experimental support for opportunitic use of jumbograms where only some hosts
on the local network support them.

This adds a new socket option, SO_JUMBO, and a new route flag,
RTF_JUMBO. If _both_ the socket option is set and the route for the host
has RTF_JUMBO set, ip_output will fragment the packet to the largest
possible size for the link, ignoring the card's MTU.

The semantics of this feature will be evolving rapidly; talk to us
if you intend to use it.

ok deraadt@ marius@


# 1.51 04-Apr-2005 hshoexer

Add sysctl for dumping the SPD
ok deraadt, ok markus some time ago


# 1.50 22-Mar-2005 henning

fix a typo, don't #define PF_RTIP to something nonmexistant
nothing in our tree uses it (well, would have been spotted then)
netbsd PR kern/29624 via jmc@, agreed on by claudio some time ago


Revision tags: OPENBSD_3_7_BASE
# 1.49 14-Jan-2005 grange

First step in Bluetooth protocol stack support.

The code is adopted from the FreeBSD netgraph-based Bluetooth
implementation by Maksim Yevmenkin <m_evmenkin@yahoo.com> but
all netgraph glue was replaced with usual BSD network stack
hooks. This is a work in progress. Only HCI layer works for now,
L2CAP and RFCOMM are on the way.

Help in testing from many, ok markus@.


# 1.48 26-Nov-2004 markus

add pfkey sysctl subtree; ok deraadt


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.47 24-Feb-2004 tedu

sysctl knob for bpf tunables. some tips from canacar@
ok canacar@ deraadt@ mcbride@


Revision tags: OPENBSD_3_4_BASE
# 1.46 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.45 24-Nov-2002 espie

Explicit unsigned char and unsigned short instead of u_char, u_short.
Make these files usable with -D_POSIX_SOURCE
okay millert@


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.44 10-Sep-2002 deraadt

typo; krapht@secureops.com


Revision tags: OPENBSD_3_1_BASE
# 1.43 15-Mar-2002 itojun

typecast in CMSG_NXTHDR. spotted by hugh@openbsd


# 1.42 14-Mar-2002 millert

First round of __P removal in sys


# 1.41 08-Mar-2002 espie

Make msghdr fields usable from all languages.
ok millert@


# 1.40 10-Jan-2002 itojun

remove duplicated decl of PF_INET6. found by kjc


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.39 07-Sep-2001 itojun

branches: 1.39.4;
just as RFC2292 suggests, validate cmsg_controllen on CMSG_FIRSTHDR.
sync with kame.


# 1.38 26-Jun-2001 dugsong

implement djb's getpeereid(2), to allow local-domain servers to determine client credentials. mostly from superscript.com. deraadt@ ok


# 1.37 22-Jun-2001 deraadt

KNF


# 1.36 28-May-2001 dugsong

add BIOC[GS]HDRCMPLT ioctl for BPF, to disable overwriting of link level source address in forged frames. from NetBSD. art@ok


Revision tags: OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.35 13-Aug-2000 ericj

if COMPAT_OSF1 is defined, define COMPAT_OLDSOCK
and COMPAT_OLDTTY.


# 1.34 02-Jul-2000 fgsch

MSG_COMPAT is needed for COMPAT_BSDOS too.


Revision tags: OPENBSD_2_7_BASE
# 1.33 03-Apr-2000 itojun

hide CMSG_ALIGN from userland, it is not part of RFC2292/Posix.1g.


# 1.32 04-Mar-2000 itojun

to be Posix.1g compliant, fix ancillary message alignment. it will now be
aligned to ALIGNBYTES (arch dependent).
NOTE: the change requires you to recompile IPv6 userland, if you are
on arch that is ALIGNBYTES != sizeof(long) - 1 (sparc seems to be it).
sorry for the mess.


# 1.31 18-Feb-2000 itojun

fix alignment problem in ancillary data (alpha).

only ipv6 tools (which touches ancillary data) are affected.

From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


Revision tags: SMP_BASE kame_19991208
# 1.30 08-Dec-1999 itojun

branches: 1.30.2;
bring in KAME IPv6 code, dated 19991208.
replaces NRL IPv6 layer. reuses NRL pcb layer. no IPsec-on-v6 support.
see sys/netinet6/{TODO,IMPLEMENTATION} for more details.

GENERIC configuration should work fine as before. GENERIC.v6 works fine
as well, but you'll need KAME userland tools to play with IPv6 (will be
bringed into soon).


Revision tags: OPENBSD_2_6_BASE
# 1.29 06-Jun-1999 deraadt

sockaddr_storage; per rfc2553


Revision tags: OPENBSD_2_5_BASE
# 1.28 25-Feb-1999 deraadt

rename sysctl names


# 1.27 25-Feb-1999 deraadt

sockaddr_union cannot be declared here, obviously, or in any other file that i know of


# 1.26 24-Feb-1999 angelos

Changes to socket.h to include union sockaddr_union, temporarily add osdep.h,
until pfkey files are cleaned up.


# 1.25 16-Feb-1999 millert

sendto(2) takes socklen_t for length param


# 1.24 15-Feb-1999 millert

pasto


# 1.23 15-Feb-1999 millert

more uses of socklen_t


# 1.22 15-Feb-1999 millert

Use and document socklen_t


# 1.21 05-Feb-1999 deraadt

support MSG_BCAST and MSG_MCAST


# 1.20 10-Jan-1999 deraadt

add SO_NETPROC and CMSG_{FIRSTHDR,ALIGN,LEN,SPACE}; cmetz


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.19 30-Nov-1997 millert

Move in_addr_t and in_port_t to <sys/types.h> and add sa_family_t
and suseconds_t types for XPG4.2.


# 1.18 16-Nov-1997 deraadt

add SHUT_* values as defined by XPG4.2


Revision tags: OPENBSD_2_2_BASE
# 1.17 14-Jul-1997 angelos

Fix the CTLNET order.


Revision tags: OPENBSD_2_1_BASE
# 1.16 24-Apr-1997 angelos

Added PF_KEY definition.


# 1.15 12-Mar-1997 downsj

Move AF_SIP and put AF_INET6 in the same location as BSD/OS.

I couldn't find any use of AF_SIP in the kernel, didn't check user land.


# 1.14 28-Feb-1997 angelos

Moved everything to netinet/in.h, where they should have been in the
first place.


# 1.13 28-Feb-1997 angelos

Per security-level defaults.


# 1.12 28-Feb-1997 angelos

Can't make up my mind; i think this is final.


# 1.11 28-Feb-1997 angelos

IPsec socket API.


# 1.10 22-Feb-1997 angelos

Preliminaries for IPsec socket API.


# 1.9 20-Feb-1997 deraadt

IPSEC package by John Ioannidis and Angelos D. Keromytis. Written in
Greece. From ftp.funet.fi:/pub/unix/security/net/ip/BSDipsec.tar.gz


# 1.8 12-Dec-1996 mickey

undo last change.


# 1.7 12-Dec-1996 deraadt

wrong place for bindresvport() proto


# 1.6 12-Dec-1996 mickey

struct sockaddr_in; prototype


# 1.5 12-Dec-1996 mickey

int bindresvport __P((int sd, struct sockaddr_in *sin));


Revision tags: OPENBSD_2_0_BASE
# 1.4 03-Jul-1996 chuck

renumber AF_NATM to avoid a conflict with freebsd which put ISDN @ 26.
(i should have checked first)


# 1.3 30-Jun-1996 chuck

add native mode atm socket type


# 1.2 29-Feb-1996 niklas

From NetBSD: Merge with NetBSD 960217


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.101 07-Nov-2021 claudio

Fix tpyo of ecma. Reported by Matthew (chohag at jtan dot com)


Revision tags: OPENBSD_7_0_BASE
# 1.100 17-May-2021 claudio

Forgot this directory in last commit for the UNIX-domain socket buffer
change.


Revision tags: OPENBSD_6_9_BASE
# 1.99 29-Oct-2020 denis

Add feature to force the selection of source IP address

Based/previous work on an idea from deraadt@
Input from claudio@, djm@, deraadt@, sthen@

OK deraadt@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.98 22-Jul-2019 robert

implement SO_DOMAIN and SO_PROTOCOL so that the domain and the protocol
can also be retrieved with getsockopt(3)
it looks like these will also be in the next issue of posix:
http://austingroupbugs.net/view.php?id=840#c2263

ok claudio@, sthen@


# 1.97 03-Jul-2019 dlg

prepare sysctl net mib to allow runtime tuning of rx q pressure thresholds

this renames the PF_LINK bit of the mib from "link_layer" to "link".
then it makes it a node that could be used for generic link layer
bits. the first of these is an "ifrxq" node where the "pressure_return"
and "pressure_drop" things go.

ok visa@ deraadt@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.96 08-Apr-2018 guenther

AF_LOCAL was a failed attempt (by POSIX?) to seem less UNIX-specific, but
AF_UNIX is both the historical _and_ standard name, so prefer and recommend
it in the headers, manpages, and kernel.

ok miller@ deraadt@ schwarze@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.95 31-May-2017 markus

new socketoption SO_ZEROIZE: zero out all mbufs sent over socket
ok deraadt bluhm


# 1.94 04-May-2017 bluhm

Introduce sstosa() for converting sockaddr_storage with a type safe
inline function instead of casting it to sockaddr. While there,
use inline instead of __inline for all these conversions. Some
struct sockaddr casts can be avoided completely.
OK dhill@ mpi@


Revision tags: OPENBSD_6_1_BASE
# 1.93 14-Nov-2016 mpi

Automatically create a default lo(4) interface per rdomain.

In order to stop abusing lo0 for all rdomains, a new loopback interface
will be created every time a rdomain is created. The unit number will
be the same as the rdomain, i.e. lo1 will be attached to rdomain 1.

If this loopback interface is already in use it wont be possible to create
the corresponding rdomain.

In order to know which lo(4) interface is attached to a rdomain, its index
is stored in the rtable/rdomain map.

This is a long overdue since the introduction of rtable/rdomain. It also
fixes a recent regression due to resetting the rdomain of an incoming
packet reported by semarie@, Andreas Bartelt and Nils Frohberg.

ok claudio@


# 1.92 28-Sep-2016 jca

Hide RT_TABLEID_MAX behind __BSD_VISIBLE

Alternate define location suggested by deraadt@ and kettenis@, ok kettenis@


# 1.91 12-Sep-2016 guenther

More #include cleanup per POSIX:
- <sys/types.h>: don't pull in <sys/select.h>
- <sys/select.h>: don't pull in <sys/time.h>, but rather declare timeval
and timespec locally
- <sys/time.h>: *do* always pull in <sys/select.h>
- <sys/socket.h>: declare timeval if __BSD_VISIBLE for struct splice

Ports testing and fixed by ajacoutot@
ok deraadt@ millert@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.90 23-Oct-2015 claudio

Introduce a new sysctl NET_RT_IFNAMES that returns only ifnames to ifindex
mappings. This will be used by if_nameindex(3), if_nametoindex(3) and
if_indextoname(3) soon to fix the issues in pledge because of inet6 link
local addressing.
OK mpi@ benno@ deraadt@
The libc version will follow soon so better start updating your kernels


# 1.89 20-Oct-2015 deraadt

At guenther's suggestion replace dnssocket() with a SOCK_DNS flag on
socket(). Without pledge, all other socket behaviours become permitted,
except this one case: connect/send* only works to *:53. In pledge mode,
a very few are further restricted. Some backwards compatibility for
the dnssocket/dnsconnect calls will remain in the tree temporarily so
that people can build through the transition.
ok tedu guenther semarie


Revision tags: OPENBSD_5_8_BASE
# 1.88 17-Jul-2015 guenther

In socketpair(), need to mask the type argument when testing for dgram.

based on jeremy@'s diff
ok jeremy@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.87 21-Jan-2015 guenther

Delete option COMPAT_43: support for pre-sa_len binaries has been obsolete
for a couple decades. Keep the OSIOCGIFCONF ioctl to support COMPAT_LINUX
but move the rest of the Linux-specific ioctl() handling into linux_socket.c
This lets struct osockaddr finally move from sys/socket.h to protocols/talkd.h

ok krw@ deraadt@ mpi@


# 1.86 18-Jan-2015 guenther

Per POSIX, <sys/socket.h> needs to expose struct iovec, and may do so
by pulling in <sys/uio.h>, so do so. Remove some stuff that we can trust
<sys/uio.h> to also provide, like cdefs.h, _types.h, and exposing size_t
and ssize_t

pointed out by naddy@
ok deraadt@


# 1.85 31-Aug-2014 guenther

Add sockatmark()

ok millert@ manpage feedback jmc@


# 1.84 31-Aug-2014 guenther

Add additional kernel interfaces for setting close-on-exec on fds
when creating them: pipe2(), dup3(), accept4(), MSG_CMSG_CLOEXEC,
SOCK_CLOEXEC. Includes SOCK_NONBLOCK support.

ok matthew@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.83 02-Apr-2013 guenther

Use internal types instead of the old BSD u_int#_t types in the
standard portion of the header.

Most of the diff from James Turner (james (at) calminferno.net)


Revision tags: OPENBSD_5_3_BASE
# 1.82 15-Sep-2012 guenther

Improve POSIX/SUS compliance of <netdb.h>, <sys/socket.h>, and <sys/un.h>.

Much ports testing of various versions by naddy@ and jasper@
ok matthew@, miller@


Revision tags: OPENBSD_5_2_BASE
# 1.81 11-Apr-2012 deraadt

tedu struct omsghdr


# 1.80 04-Apr-2012 deraadt

SCM_CREDS can go away, since everything uses the newer APIs.
ports tree checked by naddy


# 1.79 17-Mar-2012 dlg

remove IP_JUMBO, SO_JUMBO, and RTF_JUMBO.

no objection from mcbride@ krw@ markus@ deraadt@


Revision tags: OPENBSD_5_1_BASE
# 1.78 03-Dec-2011 fgsch

add support for MSG_NOSIGNAL.
linux bits compiled on i386 by sebastia@, mikeb@ ok


# 1.77 08-Sep-2011 guenther

Provide namespace-safe alignment macros in <machine/_types.h>, with
compat names kept in <machine/param.h>. In <sys/socket.h>, pull
in <sys/_types.h> instead of the namespace polluting <machine/param.h>
and completely eliminate __CMSG_ALIGN, replaced by _ALIGN

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.76 08-Jul-2011 deraadt

Remove COMPAT_OLDSOCK since no nothing sets MSG_COMPAT anymore.
The song and dance for handling 16-bit af_family on big-endian
machines remains untouched.
ok claudio miod tedu guenther


# 1.75 08-Jul-2011 mikeb

surround splice structure with __BSD_VISIBLE (the right one, noticed by
bluhm, jasper and millert -- an epic fail on my side), style nits from
deraadt, millert, ok guenther, kettenis, millert, ports tests by jasper


# 1.74 08-Jul-2011 yasuoka

this must be included my previous commit.

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.73 04-Jul-2011 mikeb

Implement an idle timeout for the socket splicing. A new `sp_idle'
field of the `splice' structure can be used to specify a period of
inactivity after which splicing will be dissolved. ETIMEDOUT error
retrieved with a SO_ERROR indicates the idle timeout expiration.
With comments from and OK bluhm.


# 1.72 05-Apr-2011 guenther

Push COMPAT_FREEBSD in front of a whale. Buggy, out of date, no
one has been weeding it, and it makes life harder.

Toasts of Brennivin for its passing from many; diff ok henning@


Revision tags: OPENBSD_4_9_BASE
# 1.71 07-Jan-2011 bluhm

Add socket option SO_SPLICE to splice together two TCP sockets.
The data received on the source socket will automatically be sent
on the drain socket. This allows to write relay daemons with zero
data copy.
ok markus@


Revision tags: OPENBSD_4_8_BASE
# 1.70 05-Jul-2010 tedu

remove compat_bsdos support


# 1.69 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.68 02-Jul-2010 tedu

remove support for compat_sunos (and m68k4k). ok deraadt guenther


# 1.67 01-Jul-2010 deraadt

Put SO_PEERCRED into the non-flag area
suggested by guenther


# 1.66 30-Jun-2010 tedu

remove compat_osf1 support from the kernel
ok deraadt miod


# 1.65 30-Jun-2010 deraadt

Add getsockopt SOL_SOCKET SO_PEERCRED support. This behaves similar to
getpeereid(2), but also supplies the remote pid. This is supplied in
a 'struct sockpeercred' (unlike Linux -- they showed how little they
know about real unix by calling theirs 'struct ucred').
ok guenther ajacoutot


# 1.64 29-Jun-2010 guenther

Remove COMPAT_HPUX. No one wanted to support it and its fewmets were
blocking other cleanups
ok miod@


# 1.63 21-Apr-2010 claudio

Implement a way to get information about a rtable. Currently only the rtableid
and rdomainid are returned. This is necessary to know where L2 information
of a table is stored (which will be needed soon by bgpd).
Also while there change the errno for non-existing routing tables to ENOENT.
'Fine' deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.62 27-Nov-2009 guenther

Add setrdomain() and getrdomain() system calls. Committing now to
catch the libc major bump per request from deraadt@

Diff by reyk.

ok guenther@


Revision tags: OPENBSD_4_6_BASE
# 1.61 11-Jun-2009 jsg

tab indent SO_RDOMAIN, like all the other SO_* defines.


# 1.60 05-Jun-2009 claudio

Initial support for routing domains. This allows to bind interfaces to
alternate routing table and separate them from other interfaces in distinct
routing tables. The same network can now be used in any doamin at the same
time without causing conflicts.
This diff is mostly mechanical and adds the necessary rdomain checks accross
net and netinet. L2 and IPv4 are mostly covered still missing pf and IPv6.
input and tested by jsg@, phessler@ and reyk@. "put it in" deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.59 16-Sep-2008 gollo

netstat statistics for pflow(4) via pseudo family

ok cluadio@ henning@


Revision tags: OPENBSD_4_4_BASE
# 1.58 09-May-2008 markus

Add SO_BINDANY socket option from BSD/OS.

The option allows a socket to be bound to addresses which are not
local to the machine. In order to receive packets for these addresses
SO_BINDANY needs to be combined with matching outgoing pf(4) divert
rules, see pf.conf(5).

ok beck@


# 1.57 02-May-2008 ckuethe

Make the SO_TIMESTAMP sockopt work. When set, this allows the user to
get a timestamp of when the datagram was accepted (by udp(4), for
example) rather than having to take a timestamp with gettimeofday(2)
when recv(2) returns - possibly several hundreds of microseconds later.
May be of use to those interested in precision network timing schemes
or QoS for media applications. Tested on alpha, amd64, i386 and sparc64.
manpage suggestions from jmc, ok deraadt


# 1.56 23-Apr-2008 norby

Import MPLS (Multi Protocol Label Switching)

MPLS support partly based on the (abandoned?) AYAME project.
Basic LSR (Label Switch Router) functionality is present, but not fully
functional yet.

It is currently possible to insert entries in the LIB (Label Information Base)
with route(8), but setting the operation type is not supported yet.

Imported to allow more people to work on this in the coming weeks.

ok claudio@ laurent@ dlg@


Revision tags: OPENBSD_4_3_BASE
# 1.55 27-Nov-2007 martynas

typos; ok jmc@
sys/dev/pci/pciide.c from naddy@


# 1.54 24-Sep-2007 henning

updatecomment and manpage toemtion optional seventh level (rtable id)
From: Pierre Riteau <pierre.riteau@free.fr>


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.53 31-Mar-2006 claudio

Add sysctl to retrieve the routing table statisitcs. Will be used by netstat
instead of kvm access. OK henning@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.52 27-May-2005 mcbride

Experimental support for opportunitic use of jumbograms where only some hosts
on the local network support them.

This adds a new socket option, SO_JUMBO, and a new route flag,
RTF_JUMBO. If _both_ the socket option is set and the route for the host
has RTF_JUMBO set, ip_output will fragment the packet to the largest
possible size for the link, ignoring the card's MTU.

The semantics of this feature will be evolving rapidly; talk to us
if you intend to use it.

ok deraadt@ marius@


# 1.51 04-Apr-2005 hshoexer

Add sysctl for dumping the SPD
ok deraadt, ok markus some time ago


# 1.50 22-Mar-2005 henning

fix a typo, don't #define PF_RTIP to something nonmexistant
nothing in our tree uses it (well, would have been spotted then)
netbsd PR kern/29624 via jmc@, agreed on by claudio some time ago


Revision tags: OPENBSD_3_7_BASE
# 1.49 14-Jan-2005 grange

First step in Bluetooth protocol stack support.

The code is adopted from the FreeBSD netgraph-based Bluetooth
implementation by Maksim Yevmenkin <m_evmenkin@yahoo.com> but
all netgraph glue was replaced with usual BSD network stack
hooks. This is a work in progress. Only HCI layer works for now,
L2CAP and RFCOMM are on the way.

Help in testing from many, ok markus@.


# 1.48 26-Nov-2004 markus

add pfkey sysctl subtree; ok deraadt


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.47 24-Feb-2004 tedu

sysctl knob for bpf tunables. some tips from canacar@
ok canacar@ deraadt@ mcbride@


Revision tags: OPENBSD_3_4_BASE
# 1.46 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.45 24-Nov-2002 espie

Explicit unsigned char and unsigned short instead of u_char, u_short.
Make these files usable with -D_POSIX_SOURCE
okay millert@


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.44 10-Sep-2002 deraadt

typo; krapht@secureops.com


Revision tags: OPENBSD_3_1_BASE
# 1.43 15-Mar-2002 itojun

typecast in CMSG_NXTHDR. spotted by hugh@openbsd


# 1.42 14-Mar-2002 millert

First round of __P removal in sys


# 1.41 08-Mar-2002 espie

Make msghdr fields usable from all languages.
ok millert@


# 1.40 10-Jan-2002 itojun

remove duplicated decl of PF_INET6. found by kjc


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.39 07-Sep-2001 itojun

branches: 1.39.4;
just as RFC2292 suggests, validate cmsg_controllen on CMSG_FIRSTHDR.
sync with kame.


# 1.38 26-Jun-2001 dugsong

implement djb's getpeereid(2), to allow local-domain servers to determine client credentials. mostly from superscript.com. deraadt@ ok


# 1.37 22-Jun-2001 deraadt

KNF


# 1.36 28-May-2001 dugsong

add BIOC[GS]HDRCMPLT ioctl for BPF, to disable overwriting of link level source address in forged frames. from NetBSD. art@ok


Revision tags: OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.35 13-Aug-2000 ericj

if COMPAT_OSF1 is defined, define COMPAT_OLDSOCK
and COMPAT_OLDTTY.


# 1.34 02-Jul-2000 fgsch

MSG_COMPAT is needed for COMPAT_BSDOS too.


Revision tags: OPENBSD_2_7_BASE
# 1.33 03-Apr-2000 itojun

hide CMSG_ALIGN from userland, it is not part of RFC2292/Posix.1g.


# 1.32 04-Mar-2000 itojun

to be Posix.1g compliant, fix ancillary message alignment. it will now be
aligned to ALIGNBYTES (arch dependent).
NOTE: the change requires you to recompile IPv6 userland, if you are
on arch that is ALIGNBYTES != sizeof(long) - 1 (sparc seems to be it).
sorry for the mess.


# 1.31 18-Feb-2000 itojun

fix alignment problem in ancillary data (alpha).

only ipv6 tools (which touches ancillary data) are affected.

From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


Revision tags: SMP_BASE kame_19991208
# 1.30 08-Dec-1999 itojun

branches: 1.30.2;
bring in KAME IPv6 code, dated 19991208.
replaces NRL IPv6 layer. reuses NRL pcb layer. no IPsec-on-v6 support.
see sys/netinet6/{TODO,IMPLEMENTATION} for more details.

GENERIC configuration should work fine as before. GENERIC.v6 works fine
as well, but you'll need KAME userland tools to play with IPv6 (will be
bringed into soon).


Revision tags: OPENBSD_2_6_BASE
# 1.29 06-Jun-1999 deraadt

sockaddr_storage; per rfc2553


Revision tags: OPENBSD_2_5_BASE
# 1.28 25-Feb-1999 deraadt

rename sysctl names


# 1.27 25-Feb-1999 deraadt

sockaddr_union cannot be declared here, obviously, or in any other file that i know of


# 1.26 24-Feb-1999 angelos

Changes to socket.h to include union sockaddr_union, temporarily add osdep.h,
until pfkey files are cleaned up.


# 1.25 16-Feb-1999 millert

sendto(2) takes socklen_t for length param


# 1.24 15-Feb-1999 millert

pasto


# 1.23 15-Feb-1999 millert

more uses of socklen_t


# 1.22 15-Feb-1999 millert

Use and document socklen_t


# 1.21 05-Feb-1999 deraadt

support MSG_BCAST and MSG_MCAST


# 1.20 10-Jan-1999 deraadt

add SO_NETPROC and CMSG_{FIRSTHDR,ALIGN,LEN,SPACE}; cmetz


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.19 30-Nov-1997 millert

Move in_addr_t and in_port_t to <sys/types.h> and add sa_family_t
and suseconds_t types for XPG4.2.


# 1.18 16-Nov-1997 deraadt

add SHUT_* values as defined by XPG4.2


Revision tags: OPENBSD_2_2_BASE
# 1.17 14-Jul-1997 angelos

Fix the CTLNET order.


Revision tags: OPENBSD_2_1_BASE
# 1.16 24-Apr-1997 angelos

Added PF_KEY definition.


# 1.15 12-Mar-1997 downsj

Move AF_SIP and put AF_INET6 in the same location as BSD/OS.

I couldn't find any use of AF_SIP in the kernel, didn't check user land.


# 1.14 28-Feb-1997 angelos

Moved everything to netinet/in.h, where they should have been in the
first place.


# 1.13 28-Feb-1997 angelos

Per security-level defaults.


# 1.12 28-Feb-1997 angelos

Can't make up my mind; i think this is final.


# 1.11 28-Feb-1997 angelos

IPsec socket API.


# 1.10 22-Feb-1997 angelos

Preliminaries for IPsec socket API.


# 1.9 20-Feb-1997 deraadt

IPSEC package by John Ioannidis and Angelos D. Keromytis. Written in
Greece. From ftp.funet.fi:/pub/unix/security/net/ip/BSDipsec.tar.gz


# 1.8 12-Dec-1996 mickey

undo last change.


# 1.7 12-Dec-1996 deraadt

wrong place for bindresvport() proto


# 1.6 12-Dec-1996 mickey

struct sockaddr_in; prototype


# 1.5 12-Dec-1996 mickey

int bindresvport __P((int sd, struct sockaddr_in *sin));


Revision tags: OPENBSD_2_0_BASE
# 1.4 03-Jul-1996 chuck

renumber AF_NATM to avoid a conflict with freebsd which put ISDN @ 26.
(i should have checked first)


# 1.3 30-Jun-1996 chuck

add native mode atm socket type


# 1.2 29-Feb-1996 niklas

From NetBSD: Merge with NetBSD 960217


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.100 17-May-2021 claudio

Forgot this directory in last commit for the UNIX-domain socket buffer
change.


Revision tags: OPENBSD_6_9_BASE
# 1.99 29-Oct-2020 denis

Add feature to force the selection of source IP address

Based/previous work on an idea from deraadt@
Input from claudio@, djm@, deraadt@, sthen@

OK deraadt@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.98 22-Jul-2019 robert

implement SO_DOMAIN and SO_PROTOCOL so that the domain and the protocol
can also be retrieved with getsockopt(3)
it looks like these will also be in the next issue of posix:
http://austingroupbugs.net/view.php?id=840#c2263

ok claudio@, sthen@


# 1.97 03-Jul-2019 dlg

prepare sysctl net mib to allow runtime tuning of rx q pressure thresholds

this renames the PF_LINK bit of the mib from "link_layer" to "link".
then it makes it a node that could be used for generic link layer
bits. the first of these is an "ifrxq" node where the "pressure_return"
and "pressure_drop" things go.

ok visa@ deraadt@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.96 08-Apr-2018 guenther

AF_LOCAL was a failed attempt (by POSIX?) to seem less UNIX-specific, but
AF_UNIX is both the historical _and_ standard name, so prefer and recommend
it in the headers, manpages, and kernel.

ok miller@ deraadt@ schwarze@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.95 31-May-2017 markus

new socketoption SO_ZEROIZE: zero out all mbufs sent over socket
ok deraadt bluhm


# 1.94 04-May-2017 bluhm

Introduce sstosa() for converting sockaddr_storage with a type safe
inline function instead of casting it to sockaddr. While there,
use inline instead of __inline for all these conversions. Some
struct sockaddr casts can be avoided completely.
OK dhill@ mpi@


Revision tags: OPENBSD_6_1_BASE
# 1.93 14-Nov-2016 mpi

Automatically create a default lo(4) interface per rdomain.

In order to stop abusing lo0 for all rdomains, a new loopback interface
will be created every time a rdomain is created. The unit number will
be the same as the rdomain, i.e. lo1 will be attached to rdomain 1.

If this loopback interface is already in use it wont be possible to create
the corresponding rdomain.

In order to know which lo(4) interface is attached to a rdomain, its index
is stored in the rtable/rdomain map.

This is a long overdue since the introduction of rtable/rdomain. It also
fixes a recent regression due to resetting the rdomain of an incoming
packet reported by semarie@, Andreas Bartelt and Nils Frohberg.

ok claudio@


# 1.92 28-Sep-2016 jca

Hide RT_TABLEID_MAX behind __BSD_VISIBLE

Alternate define location suggested by deraadt@ and kettenis@, ok kettenis@


# 1.91 12-Sep-2016 guenther

More #include cleanup per POSIX:
- <sys/types.h>: don't pull in <sys/select.h>
- <sys/select.h>: don't pull in <sys/time.h>, but rather declare timeval
and timespec locally
- <sys/time.h>: *do* always pull in <sys/select.h>
- <sys/socket.h>: declare timeval if __BSD_VISIBLE for struct splice

Ports testing and fixed by ajacoutot@
ok deraadt@ millert@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.90 23-Oct-2015 claudio

Introduce a new sysctl NET_RT_IFNAMES that returns only ifnames to ifindex
mappings. This will be used by if_nameindex(3), if_nametoindex(3) and
if_indextoname(3) soon to fix the issues in pledge because of inet6 link
local addressing.
OK mpi@ benno@ deraadt@
The libc version will follow soon so better start updating your kernels


# 1.89 20-Oct-2015 deraadt

At guenther's suggestion replace dnssocket() with a SOCK_DNS flag on
socket(). Without pledge, all other socket behaviours become permitted,
except this one case: connect/send* only works to *:53. In pledge mode,
a very few are further restricted. Some backwards compatibility for
the dnssocket/dnsconnect calls will remain in the tree temporarily so
that people can build through the transition.
ok tedu guenther semarie


Revision tags: OPENBSD_5_8_BASE
# 1.88 17-Jul-2015 guenther

In socketpair(), need to mask the type argument when testing for dgram.

based on jeremy@'s diff
ok jeremy@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.87 21-Jan-2015 guenther

Delete option COMPAT_43: support for pre-sa_len binaries has been obsolete
for a couple decades. Keep the OSIOCGIFCONF ioctl to support COMPAT_LINUX
but move the rest of the Linux-specific ioctl() handling into linux_socket.c
This lets struct osockaddr finally move from sys/socket.h to protocols/talkd.h

ok krw@ deraadt@ mpi@


# 1.86 18-Jan-2015 guenther

Per POSIX, <sys/socket.h> needs to expose struct iovec, and may do so
by pulling in <sys/uio.h>, so do so. Remove some stuff that we can trust
<sys/uio.h> to also provide, like cdefs.h, _types.h, and exposing size_t
and ssize_t

pointed out by naddy@
ok deraadt@


# 1.85 31-Aug-2014 guenther

Add sockatmark()

ok millert@ manpage feedback jmc@


# 1.84 31-Aug-2014 guenther

Add additional kernel interfaces for setting close-on-exec on fds
when creating them: pipe2(), dup3(), accept4(), MSG_CMSG_CLOEXEC,
SOCK_CLOEXEC. Includes SOCK_NONBLOCK support.

ok matthew@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.83 02-Apr-2013 guenther

Use internal types instead of the old BSD u_int#_t types in the
standard portion of the header.

Most of the diff from James Turner (james (at) calminferno.net)


Revision tags: OPENBSD_5_3_BASE
# 1.82 15-Sep-2012 guenther

Improve POSIX/SUS compliance of <netdb.h>, <sys/socket.h>, and <sys/un.h>.

Much ports testing of various versions by naddy@ and jasper@
ok matthew@, miller@


Revision tags: OPENBSD_5_2_BASE
# 1.81 11-Apr-2012 deraadt

tedu struct omsghdr


# 1.80 04-Apr-2012 deraadt

SCM_CREDS can go away, since everything uses the newer APIs.
ports tree checked by naddy


# 1.79 17-Mar-2012 dlg

remove IP_JUMBO, SO_JUMBO, and RTF_JUMBO.

no objection from mcbride@ krw@ markus@ deraadt@


Revision tags: OPENBSD_5_1_BASE
# 1.78 03-Dec-2011 fgsch

add support for MSG_NOSIGNAL.
linux bits compiled on i386 by sebastia@, mikeb@ ok


# 1.77 08-Sep-2011 guenther

Provide namespace-safe alignment macros in <machine/_types.h>, with
compat names kept in <machine/param.h>. In <sys/socket.h>, pull
in <sys/_types.h> instead of the namespace polluting <machine/param.h>
and completely eliminate __CMSG_ALIGN, replaced by _ALIGN

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.76 08-Jul-2011 deraadt

Remove COMPAT_OLDSOCK since no nothing sets MSG_COMPAT anymore.
The song and dance for handling 16-bit af_family on big-endian
machines remains untouched.
ok claudio miod tedu guenther


# 1.75 08-Jul-2011 mikeb

surround splice structure with __BSD_VISIBLE (the right one, noticed by
bluhm, jasper and millert -- an epic fail on my side), style nits from
deraadt, millert, ok guenther, kettenis, millert, ports tests by jasper


# 1.74 08-Jul-2011 yasuoka

this must be included my previous commit.

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.73 04-Jul-2011 mikeb

Implement an idle timeout for the socket splicing. A new `sp_idle'
field of the `splice' structure can be used to specify a period of
inactivity after which splicing will be dissolved. ETIMEDOUT error
retrieved with a SO_ERROR indicates the idle timeout expiration.
With comments from and OK bluhm.


# 1.72 05-Apr-2011 guenther

Push COMPAT_FREEBSD in front of a whale. Buggy, out of date, no
one has been weeding it, and it makes life harder.

Toasts of Brennivin for its passing from many; diff ok henning@


Revision tags: OPENBSD_4_9_BASE
# 1.71 07-Jan-2011 bluhm

Add socket option SO_SPLICE to splice together two TCP sockets.
The data received on the source socket will automatically be sent
on the drain socket. This allows to write relay daemons with zero
data copy.
ok markus@


Revision tags: OPENBSD_4_8_BASE
# 1.70 05-Jul-2010 tedu

remove compat_bsdos support


# 1.69 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.68 02-Jul-2010 tedu

remove support for compat_sunos (and m68k4k). ok deraadt guenther


# 1.67 01-Jul-2010 deraadt

Put SO_PEERCRED into the non-flag area
suggested by guenther


# 1.66 30-Jun-2010 tedu

remove compat_osf1 support from the kernel
ok deraadt miod


# 1.65 30-Jun-2010 deraadt

Add getsockopt SOL_SOCKET SO_PEERCRED support. This behaves similar to
getpeereid(2), but also supplies the remote pid. This is supplied in
a 'struct sockpeercred' (unlike Linux -- they showed how little they
know about real unix by calling theirs 'struct ucred').
ok guenther ajacoutot


# 1.64 29-Jun-2010 guenther

Remove COMPAT_HPUX. No one wanted to support it and its fewmets were
blocking other cleanups
ok miod@


# 1.63 21-Apr-2010 claudio

Implement a way to get information about a rtable. Currently only the rtableid
and rdomainid are returned. This is necessary to know where L2 information
of a table is stored (which will be needed soon by bgpd).
Also while there change the errno for non-existing routing tables to ENOENT.
'Fine' deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.62 27-Nov-2009 guenther

Add setrdomain() and getrdomain() system calls. Committing now to
catch the libc major bump per request from deraadt@

Diff by reyk.

ok guenther@


Revision tags: OPENBSD_4_6_BASE
# 1.61 11-Jun-2009 jsg

tab indent SO_RDOMAIN, like all the other SO_* defines.


# 1.60 05-Jun-2009 claudio

Initial support for routing domains. This allows to bind interfaces to
alternate routing table and separate them from other interfaces in distinct
routing tables. The same network can now be used in any doamin at the same
time without causing conflicts.
This diff is mostly mechanical and adds the necessary rdomain checks accross
net and netinet. L2 and IPv4 are mostly covered still missing pf and IPv6.
input and tested by jsg@, phessler@ and reyk@. "put it in" deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.59 16-Sep-2008 gollo

netstat statistics for pflow(4) via pseudo family

ok cluadio@ henning@


Revision tags: OPENBSD_4_4_BASE
# 1.58 09-May-2008 markus

Add SO_BINDANY socket option from BSD/OS.

The option allows a socket to be bound to addresses which are not
local to the machine. In order to receive packets for these addresses
SO_BINDANY needs to be combined with matching outgoing pf(4) divert
rules, see pf.conf(5).

ok beck@


# 1.57 02-May-2008 ckuethe

Make the SO_TIMESTAMP sockopt work. When set, this allows the user to
get a timestamp of when the datagram was accepted (by udp(4), for
example) rather than having to take a timestamp with gettimeofday(2)
when recv(2) returns - possibly several hundreds of microseconds later.
May be of use to those interested in precision network timing schemes
or QoS for media applications. Tested on alpha, amd64, i386 and sparc64.
manpage suggestions from jmc, ok deraadt


# 1.56 23-Apr-2008 norby

Import MPLS (Multi Protocol Label Switching)

MPLS support partly based on the (abandoned?) AYAME project.
Basic LSR (Label Switch Router) functionality is present, but not fully
functional yet.

It is currently possible to insert entries in the LIB (Label Information Base)
with route(8), but setting the operation type is not supported yet.

Imported to allow more people to work on this in the coming weeks.

ok claudio@ laurent@ dlg@


Revision tags: OPENBSD_4_3_BASE
# 1.55 27-Nov-2007 martynas

typos; ok jmc@
sys/dev/pci/pciide.c from naddy@


# 1.54 24-Sep-2007 henning

updatecomment and manpage toemtion optional seventh level (rtable id)
From: Pierre Riteau <pierre.riteau@free.fr>


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.53 31-Mar-2006 claudio

Add sysctl to retrieve the routing table statisitcs. Will be used by netstat
instead of kvm access. OK henning@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.52 27-May-2005 mcbride

Experimental support for opportunitic use of jumbograms where only some hosts
on the local network support them.

This adds a new socket option, SO_JUMBO, and a new route flag,
RTF_JUMBO. If _both_ the socket option is set and the route for the host
has RTF_JUMBO set, ip_output will fragment the packet to the largest
possible size for the link, ignoring the card's MTU.

The semantics of this feature will be evolving rapidly; talk to us
if you intend to use it.

ok deraadt@ marius@


# 1.51 04-Apr-2005 hshoexer

Add sysctl for dumping the SPD
ok deraadt, ok markus some time ago


# 1.50 22-Mar-2005 henning

fix a typo, don't #define PF_RTIP to something nonmexistant
nothing in our tree uses it (well, would have been spotted then)
netbsd PR kern/29624 via jmc@, agreed on by claudio some time ago


Revision tags: OPENBSD_3_7_BASE
# 1.49 14-Jan-2005 grange

First step in Bluetooth protocol stack support.

The code is adopted from the FreeBSD netgraph-based Bluetooth
implementation by Maksim Yevmenkin <m_evmenkin@yahoo.com> but
all netgraph glue was replaced with usual BSD network stack
hooks. This is a work in progress. Only HCI layer works for now,
L2CAP and RFCOMM are on the way.

Help in testing from many, ok markus@.


# 1.48 26-Nov-2004 markus

add pfkey sysctl subtree; ok deraadt


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.47 24-Feb-2004 tedu

sysctl knob for bpf tunables. some tips from canacar@
ok canacar@ deraadt@ mcbride@


Revision tags: OPENBSD_3_4_BASE
# 1.46 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.45 24-Nov-2002 espie

Explicit unsigned char and unsigned short instead of u_char, u_short.
Make these files usable with -D_POSIX_SOURCE
okay millert@


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.44 10-Sep-2002 deraadt

typo; krapht@secureops.com


Revision tags: OPENBSD_3_1_BASE
# 1.43 15-Mar-2002 itojun

typecast in CMSG_NXTHDR. spotted by hugh@openbsd


# 1.42 14-Mar-2002 millert

First round of __P removal in sys


# 1.41 08-Mar-2002 espie

Make msghdr fields usable from all languages.
ok millert@


# 1.40 10-Jan-2002 itojun

remove duplicated decl of PF_INET6. found by kjc


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.39 07-Sep-2001 itojun

branches: 1.39.4;
just as RFC2292 suggests, validate cmsg_controllen on CMSG_FIRSTHDR.
sync with kame.


# 1.38 26-Jun-2001 dugsong

implement djb's getpeereid(2), to allow local-domain servers to determine client credentials. mostly from superscript.com. deraadt@ ok


# 1.37 22-Jun-2001 deraadt

KNF


# 1.36 28-May-2001 dugsong

add BIOC[GS]HDRCMPLT ioctl for BPF, to disable overwriting of link level source address in forged frames. from NetBSD. art@ok


Revision tags: OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.35 13-Aug-2000 ericj

if COMPAT_OSF1 is defined, define COMPAT_OLDSOCK
and COMPAT_OLDTTY.


# 1.34 02-Jul-2000 fgsch

MSG_COMPAT is needed for COMPAT_BSDOS too.


Revision tags: OPENBSD_2_7_BASE
# 1.33 03-Apr-2000 itojun

hide CMSG_ALIGN from userland, it is not part of RFC2292/Posix.1g.


# 1.32 04-Mar-2000 itojun

to be Posix.1g compliant, fix ancillary message alignment. it will now be
aligned to ALIGNBYTES (arch dependent).
NOTE: the change requires you to recompile IPv6 userland, if you are
on arch that is ALIGNBYTES != sizeof(long) - 1 (sparc seems to be it).
sorry for the mess.


# 1.31 18-Feb-2000 itojun

fix alignment problem in ancillary data (alpha).

only ipv6 tools (which touches ancillary data) are affected.

From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


Revision tags: SMP_BASE kame_19991208
# 1.30 08-Dec-1999 itojun

branches: 1.30.2;
bring in KAME IPv6 code, dated 19991208.
replaces NRL IPv6 layer. reuses NRL pcb layer. no IPsec-on-v6 support.
see sys/netinet6/{TODO,IMPLEMENTATION} for more details.

GENERIC configuration should work fine as before. GENERIC.v6 works fine
as well, but you'll need KAME userland tools to play with IPv6 (will be
bringed into soon).


Revision tags: OPENBSD_2_6_BASE
# 1.29 06-Jun-1999 deraadt

sockaddr_storage; per rfc2553


Revision tags: OPENBSD_2_5_BASE
# 1.28 25-Feb-1999 deraadt

rename sysctl names


# 1.27 25-Feb-1999 deraadt

sockaddr_union cannot be declared here, obviously, or in any other file that i know of


# 1.26 24-Feb-1999 angelos

Changes to socket.h to include union sockaddr_union, temporarily add osdep.h,
until pfkey files are cleaned up.


# 1.25 16-Feb-1999 millert

sendto(2) takes socklen_t for length param


# 1.24 15-Feb-1999 millert

pasto


# 1.23 15-Feb-1999 millert

more uses of socklen_t


# 1.22 15-Feb-1999 millert

Use and document socklen_t


# 1.21 05-Feb-1999 deraadt

support MSG_BCAST and MSG_MCAST


# 1.20 10-Jan-1999 deraadt

add SO_NETPROC and CMSG_{FIRSTHDR,ALIGN,LEN,SPACE}; cmetz


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.19 30-Nov-1997 millert

Move in_addr_t and in_port_t to <sys/types.h> and add sa_family_t
and suseconds_t types for XPG4.2.


# 1.18 16-Nov-1997 deraadt

add SHUT_* values as defined by XPG4.2


Revision tags: OPENBSD_2_2_BASE
# 1.17 14-Jul-1997 angelos

Fix the CTLNET order.


Revision tags: OPENBSD_2_1_BASE
# 1.16 24-Apr-1997 angelos

Added PF_KEY definition.


# 1.15 12-Mar-1997 downsj

Move AF_SIP and put AF_INET6 in the same location as BSD/OS.

I couldn't find any use of AF_SIP in the kernel, didn't check user land.


# 1.14 28-Feb-1997 angelos

Moved everything to netinet/in.h, where they should have been in the
first place.


# 1.13 28-Feb-1997 angelos

Per security-level defaults.


# 1.12 28-Feb-1997 angelos

Can't make up my mind; i think this is final.


# 1.11 28-Feb-1997 angelos

IPsec socket API.


# 1.10 22-Feb-1997 angelos

Preliminaries for IPsec socket API.


# 1.9 20-Feb-1997 deraadt

IPSEC package by John Ioannidis and Angelos D. Keromytis. Written in
Greece. From ftp.funet.fi:/pub/unix/security/net/ip/BSDipsec.tar.gz


# 1.8 12-Dec-1996 mickey

undo last change.


# 1.7 12-Dec-1996 deraadt

wrong place for bindresvport() proto


# 1.6 12-Dec-1996 mickey

struct sockaddr_in; prototype


# 1.5 12-Dec-1996 mickey

int bindresvport __P((int sd, struct sockaddr_in *sin));


Revision tags: OPENBSD_2_0_BASE
# 1.4 03-Jul-1996 chuck

renumber AF_NATM to avoid a conflict with freebsd which put ISDN @ 26.
(i should have checked first)


# 1.3 30-Jun-1996 chuck

add native mode atm socket type


# 1.2 29-Feb-1996 niklas

From NetBSD: Merge with NetBSD 960217


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.99 29-Oct-2020 denis

Add feature to force the selection of source IP address

Based/previous work on an idea from deraadt@
Input from claudio@, djm@, deraadt@, sthen@

OK deraadt@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.98 22-Jul-2019 robert

implement SO_DOMAIN and SO_PROTOCOL so that the domain and the protocol
can also be retrieved with getsockopt(3)
it looks like these will also be in the next issue of posix:
http://austingroupbugs.net/view.php?id=840#c2263

ok claudio@, sthen@


# 1.97 03-Jul-2019 dlg

prepare sysctl net mib to allow runtime tuning of rx q pressure thresholds

this renames the PF_LINK bit of the mib from "link_layer" to "link".
then it makes it a node that could be used for generic link layer
bits. the first of these is an "ifrxq" node where the "pressure_return"
and "pressure_drop" things go.

ok visa@ deraadt@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.96 08-Apr-2018 guenther

AF_LOCAL was a failed attempt (by POSIX?) to seem less UNIX-specific, but
AF_UNIX is both the historical _and_ standard name, so prefer and recommend
it in the headers, manpages, and kernel.

ok miller@ deraadt@ schwarze@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.95 31-May-2017 markus

new socketoption SO_ZEROIZE: zero out all mbufs sent over socket
ok deraadt bluhm


# 1.94 04-May-2017 bluhm

Introduce sstosa() for converting sockaddr_storage with a type safe
inline function instead of casting it to sockaddr. While there,
use inline instead of __inline for all these conversions. Some
struct sockaddr casts can be avoided completely.
OK dhill@ mpi@


Revision tags: OPENBSD_6_1_BASE
# 1.93 14-Nov-2016 mpi

Automatically create a default lo(4) interface per rdomain.

In order to stop abusing lo0 for all rdomains, a new loopback interface
will be created every time a rdomain is created. The unit number will
be the same as the rdomain, i.e. lo1 will be attached to rdomain 1.

If this loopback interface is already in use it wont be possible to create
the corresponding rdomain.

In order to know which lo(4) interface is attached to a rdomain, its index
is stored in the rtable/rdomain map.

This is a long overdue since the introduction of rtable/rdomain. It also
fixes a recent regression due to resetting the rdomain of an incoming
packet reported by semarie@, Andreas Bartelt and Nils Frohberg.

ok claudio@


# 1.92 28-Sep-2016 jca

Hide RT_TABLEID_MAX behind __BSD_VISIBLE

Alternate define location suggested by deraadt@ and kettenis@, ok kettenis@


# 1.91 12-Sep-2016 guenther

More #include cleanup per POSIX:
- <sys/types.h>: don't pull in <sys/select.h>
- <sys/select.h>: don't pull in <sys/time.h>, but rather declare timeval
and timespec locally
- <sys/time.h>: *do* always pull in <sys/select.h>
- <sys/socket.h>: declare timeval if __BSD_VISIBLE for struct splice

Ports testing and fixed by ajacoutot@
ok deraadt@ millert@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.90 23-Oct-2015 claudio

Introduce a new sysctl NET_RT_IFNAMES that returns only ifnames to ifindex
mappings. This will be used by if_nameindex(3), if_nametoindex(3) and
if_indextoname(3) soon to fix the issues in pledge because of inet6 link
local addressing.
OK mpi@ benno@ deraadt@
The libc version will follow soon so better start updating your kernels


# 1.89 20-Oct-2015 deraadt

At guenther's suggestion replace dnssocket() with a SOCK_DNS flag on
socket(). Without pledge, all other socket behaviours become permitted,
except this one case: connect/send* only works to *:53. In pledge mode,
a very few are further restricted. Some backwards compatibility for
the dnssocket/dnsconnect calls will remain in the tree temporarily so
that people can build through the transition.
ok tedu guenther semarie


Revision tags: OPENBSD_5_8_BASE
# 1.88 17-Jul-2015 guenther

In socketpair(), need to mask the type argument when testing for dgram.

based on jeremy@'s diff
ok jeremy@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.87 21-Jan-2015 guenther

Delete option COMPAT_43: support for pre-sa_len binaries has been obsolete
for a couple decades. Keep the OSIOCGIFCONF ioctl to support COMPAT_LINUX
but move the rest of the Linux-specific ioctl() handling into linux_socket.c
This lets struct osockaddr finally move from sys/socket.h to protocols/talkd.h

ok krw@ deraadt@ mpi@


# 1.86 18-Jan-2015 guenther

Per POSIX, <sys/socket.h> needs to expose struct iovec, and may do so
by pulling in <sys/uio.h>, so do so. Remove some stuff that we can trust
<sys/uio.h> to also provide, like cdefs.h, _types.h, and exposing size_t
and ssize_t

pointed out by naddy@
ok deraadt@


# 1.85 31-Aug-2014 guenther

Add sockatmark()

ok millert@ manpage feedback jmc@


# 1.84 31-Aug-2014 guenther

Add additional kernel interfaces for setting close-on-exec on fds
when creating them: pipe2(), dup3(), accept4(), MSG_CMSG_CLOEXEC,
SOCK_CLOEXEC. Includes SOCK_NONBLOCK support.

ok matthew@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.83 02-Apr-2013 guenther

Use internal types instead of the old BSD u_int#_t types in the
standard portion of the header.

Most of the diff from James Turner (james (at) calminferno.net)


Revision tags: OPENBSD_5_3_BASE
# 1.82 15-Sep-2012 guenther

Improve POSIX/SUS compliance of <netdb.h>, <sys/socket.h>, and <sys/un.h>.

Much ports testing of various versions by naddy@ and jasper@
ok matthew@, miller@


Revision tags: OPENBSD_5_2_BASE
# 1.81 11-Apr-2012 deraadt

tedu struct omsghdr


# 1.80 04-Apr-2012 deraadt

SCM_CREDS can go away, since everything uses the newer APIs.
ports tree checked by naddy


# 1.79 17-Mar-2012 dlg

remove IP_JUMBO, SO_JUMBO, and RTF_JUMBO.

no objection from mcbride@ krw@ markus@ deraadt@


Revision tags: OPENBSD_5_1_BASE
# 1.78 03-Dec-2011 fgsch

add support for MSG_NOSIGNAL.
linux bits compiled on i386 by sebastia@, mikeb@ ok


# 1.77 08-Sep-2011 guenther

Provide namespace-safe alignment macros in <machine/_types.h>, with
compat names kept in <machine/param.h>. In <sys/socket.h>, pull
in <sys/_types.h> instead of the namespace polluting <machine/param.h>
and completely eliminate __CMSG_ALIGN, replaced by _ALIGN

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.76 08-Jul-2011 deraadt

Remove COMPAT_OLDSOCK since no nothing sets MSG_COMPAT anymore.
The song and dance for handling 16-bit af_family on big-endian
machines remains untouched.
ok claudio miod tedu guenther


# 1.75 08-Jul-2011 mikeb

surround splice structure with __BSD_VISIBLE (the right one, noticed by
bluhm, jasper and millert -- an epic fail on my side), style nits from
deraadt, millert, ok guenther, kettenis, millert, ports tests by jasper


# 1.74 08-Jul-2011 yasuoka

this must be included my previous commit.

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.73 04-Jul-2011 mikeb

Implement an idle timeout for the socket splicing. A new `sp_idle'
field of the `splice' structure can be used to specify a period of
inactivity after which splicing will be dissolved. ETIMEDOUT error
retrieved with a SO_ERROR indicates the idle timeout expiration.
With comments from and OK bluhm.


# 1.72 05-Apr-2011 guenther

Push COMPAT_FREEBSD in front of a whale. Buggy, out of date, no
one has been weeding it, and it makes life harder.

Toasts of Brennivin for its passing from many; diff ok henning@


Revision tags: OPENBSD_4_9_BASE
# 1.71 07-Jan-2011 bluhm

Add socket option SO_SPLICE to splice together two TCP sockets.
The data received on the source socket will automatically be sent
on the drain socket. This allows to write relay daemons with zero
data copy.
ok markus@


Revision tags: OPENBSD_4_8_BASE
# 1.70 05-Jul-2010 tedu

remove compat_bsdos support


# 1.69 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.68 02-Jul-2010 tedu

remove support for compat_sunos (and m68k4k). ok deraadt guenther


# 1.67 01-Jul-2010 deraadt

Put SO_PEERCRED into the non-flag area
suggested by guenther


# 1.66 30-Jun-2010 tedu

remove compat_osf1 support from the kernel
ok deraadt miod


# 1.65 30-Jun-2010 deraadt

Add getsockopt SOL_SOCKET SO_PEERCRED support. This behaves similar to
getpeereid(2), but also supplies the remote pid. This is supplied in
a 'struct sockpeercred' (unlike Linux -- they showed how little they
know about real unix by calling theirs 'struct ucred').
ok guenther ajacoutot


# 1.64 29-Jun-2010 guenther

Remove COMPAT_HPUX. No one wanted to support it and its fewmets were
blocking other cleanups
ok miod@


# 1.63 21-Apr-2010 claudio

Implement a way to get information about a rtable. Currently only the rtableid
and rdomainid are returned. This is necessary to know where L2 information
of a table is stored (which will be needed soon by bgpd).
Also while there change the errno for non-existing routing tables to ENOENT.
'Fine' deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.62 27-Nov-2009 guenther

Add setrdomain() and getrdomain() system calls. Committing now to
catch the libc major bump per request from deraadt@

Diff by reyk.

ok guenther@


Revision tags: OPENBSD_4_6_BASE
# 1.61 11-Jun-2009 jsg

tab indent SO_RDOMAIN, like all the other SO_* defines.


# 1.60 05-Jun-2009 claudio

Initial support for routing domains. This allows to bind interfaces to
alternate routing table and separate them from other interfaces in distinct
routing tables. The same network can now be used in any doamin at the same
time without causing conflicts.
This diff is mostly mechanical and adds the necessary rdomain checks accross
net and netinet. L2 and IPv4 are mostly covered still missing pf and IPv6.
input and tested by jsg@, phessler@ and reyk@. "put it in" deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.59 16-Sep-2008 gollo

netstat statistics for pflow(4) via pseudo family

ok cluadio@ henning@


Revision tags: OPENBSD_4_4_BASE
# 1.58 09-May-2008 markus

Add SO_BINDANY socket option from BSD/OS.

The option allows a socket to be bound to addresses which are not
local to the machine. In order to receive packets for these addresses
SO_BINDANY needs to be combined with matching outgoing pf(4) divert
rules, see pf.conf(5).

ok beck@


# 1.57 02-May-2008 ckuethe

Make the SO_TIMESTAMP sockopt work. When set, this allows the user to
get a timestamp of when the datagram was accepted (by udp(4), for
example) rather than having to take a timestamp with gettimeofday(2)
when recv(2) returns - possibly several hundreds of microseconds later.
May be of use to those interested in precision network timing schemes
or QoS for media applications. Tested on alpha, amd64, i386 and sparc64.
manpage suggestions from jmc, ok deraadt


# 1.56 23-Apr-2008 norby

Import MPLS (Multi Protocol Label Switching)

MPLS support partly based on the (abandoned?) AYAME project.
Basic LSR (Label Switch Router) functionality is present, but not fully
functional yet.

It is currently possible to insert entries in the LIB (Label Information Base)
with route(8), but setting the operation type is not supported yet.

Imported to allow more people to work on this in the coming weeks.

ok claudio@ laurent@ dlg@


Revision tags: OPENBSD_4_3_BASE
# 1.55 27-Nov-2007 martynas

typos; ok jmc@
sys/dev/pci/pciide.c from naddy@


# 1.54 24-Sep-2007 henning

updatecomment and manpage toemtion optional seventh level (rtable id)
From: Pierre Riteau <pierre.riteau@free.fr>


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.53 31-Mar-2006 claudio

Add sysctl to retrieve the routing table statisitcs. Will be used by netstat
instead of kvm access. OK henning@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.52 27-May-2005 mcbride

Experimental support for opportunitic use of jumbograms where only some hosts
on the local network support them.

This adds a new socket option, SO_JUMBO, and a new route flag,
RTF_JUMBO. If _both_ the socket option is set and the route for the host
has RTF_JUMBO set, ip_output will fragment the packet to the largest
possible size for the link, ignoring the card's MTU.

The semantics of this feature will be evolving rapidly; talk to us
if you intend to use it.

ok deraadt@ marius@


# 1.51 04-Apr-2005 hshoexer

Add sysctl for dumping the SPD
ok deraadt, ok markus some time ago


# 1.50 22-Mar-2005 henning

fix a typo, don't #define PF_RTIP to something nonmexistant
nothing in our tree uses it (well, would have been spotted then)
netbsd PR kern/29624 via jmc@, agreed on by claudio some time ago


Revision tags: OPENBSD_3_7_BASE
# 1.49 14-Jan-2005 grange

First step in Bluetooth protocol stack support.

The code is adopted from the FreeBSD netgraph-based Bluetooth
implementation by Maksim Yevmenkin <m_evmenkin@yahoo.com> but
all netgraph glue was replaced with usual BSD network stack
hooks. This is a work in progress. Only HCI layer works for now,
L2CAP and RFCOMM are on the way.

Help in testing from many, ok markus@.


# 1.48 26-Nov-2004 markus

add pfkey sysctl subtree; ok deraadt


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.47 24-Feb-2004 tedu

sysctl knob for bpf tunables. some tips from canacar@
ok canacar@ deraadt@ mcbride@


Revision tags: OPENBSD_3_4_BASE
# 1.46 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.45 24-Nov-2002 espie

Explicit unsigned char and unsigned short instead of u_char, u_short.
Make these files usable with -D_POSIX_SOURCE
okay millert@


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.44 10-Sep-2002 deraadt

typo; krapht@secureops.com


Revision tags: OPENBSD_3_1_BASE
# 1.43 15-Mar-2002 itojun

typecast in CMSG_NXTHDR. spotted by hugh@openbsd


# 1.42 14-Mar-2002 millert

First round of __P removal in sys


# 1.41 08-Mar-2002 espie

Make msghdr fields usable from all languages.
ok millert@


# 1.40 10-Jan-2002 itojun

remove duplicated decl of PF_INET6. found by kjc


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.39 07-Sep-2001 itojun

branches: 1.39.4;
just as RFC2292 suggests, validate cmsg_controllen on CMSG_FIRSTHDR.
sync with kame.


# 1.38 26-Jun-2001 dugsong

implement djb's getpeereid(2), to allow local-domain servers to determine client credentials. mostly from superscript.com. deraadt@ ok


# 1.37 22-Jun-2001 deraadt

KNF


# 1.36 28-May-2001 dugsong

add BIOC[GS]HDRCMPLT ioctl for BPF, to disable overwriting of link level source address in forged frames. from NetBSD. art@ok


Revision tags: OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.35 13-Aug-2000 ericj

if COMPAT_OSF1 is defined, define COMPAT_OLDSOCK
and COMPAT_OLDTTY.


# 1.34 02-Jul-2000 fgsch

MSG_COMPAT is needed for COMPAT_BSDOS too.


Revision tags: OPENBSD_2_7_BASE
# 1.33 03-Apr-2000 itojun

hide CMSG_ALIGN from userland, it is not part of RFC2292/Posix.1g.


# 1.32 04-Mar-2000 itojun

to be Posix.1g compliant, fix ancillary message alignment. it will now be
aligned to ALIGNBYTES (arch dependent).
NOTE: the change requires you to recompile IPv6 userland, if you are
on arch that is ALIGNBYTES != sizeof(long) - 1 (sparc seems to be it).
sorry for the mess.


# 1.31 18-Feb-2000 itojun

fix alignment problem in ancillary data (alpha).

only ipv6 tools (which touches ancillary data) are affected.

From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


Revision tags: SMP_BASE kame_19991208
# 1.30 08-Dec-1999 itojun

branches: 1.30.2;
bring in KAME IPv6 code, dated 19991208.
replaces NRL IPv6 layer. reuses NRL pcb layer. no IPsec-on-v6 support.
see sys/netinet6/{TODO,IMPLEMENTATION} for more details.

GENERIC configuration should work fine as before. GENERIC.v6 works fine
as well, but you'll need KAME userland tools to play with IPv6 (will be
bringed into soon).


Revision tags: OPENBSD_2_6_BASE
# 1.29 06-Jun-1999 deraadt

sockaddr_storage; per rfc2553


Revision tags: OPENBSD_2_5_BASE
# 1.28 25-Feb-1999 deraadt

rename sysctl names


# 1.27 25-Feb-1999 deraadt

sockaddr_union cannot be declared here, obviously, or in any other file that i know of


# 1.26 24-Feb-1999 angelos

Changes to socket.h to include union sockaddr_union, temporarily add osdep.h,
until pfkey files are cleaned up.


# 1.25 16-Feb-1999 millert

sendto(2) takes socklen_t for length param


# 1.24 15-Feb-1999 millert

pasto


# 1.23 15-Feb-1999 millert

more uses of socklen_t


# 1.22 15-Feb-1999 millert

Use and document socklen_t


# 1.21 05-Feb-1999 deraadt

support MSG_BCAST and MSG_MCAST


# 1.20 10-Jan-1999 deraadt

add SO_NETPROC and CMSG_{FIRSTHDR,ALIGN,LEN,SPACE}; cmetz


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.19 30-Nov-1997 millert

Move in_addr_t and in_port_t to <sys/types.h> and add sa_family_t
and suseconds_t types for XPG4.2.


# 1.18 16-Nov-1997 deraadt

add SHUT_* values as defined by XPG4.2


Revision tags: OPENBSD_2_2_BASE
# 1.17 14-Jul-1997 angelos

Fix the CTLNET order.


Revision tags: OPENBSD_2_1_BASE
# 1.16 24-Apr-1997 angelos

Added PF_KEY definition.


# 1.15 12-Mar-1997 downsj

Move AF_SIP and put AF_INET6 in the same location as BSD/OS.

I couldn't find any use of AF_SIP in the kernel, didn't check user land.


# 1.14 28-Feb-1997 angelos

Moved everything to netinet/in.h, where they should have been in the
first place.


# 1.13 28-Feb-1997 angelos

Per security-level defaults.


# 1.12 28-Feb-1997 angelos

Can't make up my mind; i think this is final.


# 1.11 28-Feb-1997 angelos

IPsec socket API.


# 1.10 22-Feb-1997 angelos

Preliminaries for IPsec socket API.


# 1.9 20-Feb-1997 deraadt

IPSEC package by John Ioannidis and Angelos D. Keromytis. Written in
Greece. From ftp.funet.fi:/pub/unix/security/net/ip/BSDipsec.tar.gz


# 1.8 12-Dec-1996 mickey

undo last change.


# 1.7 12-Dec-1996 deraadt

wrong place for bindresvport() proto


# 1.6 12-Dec-1996 mickey

struct sockaddr_in; prototype


# 1.5 12-Dec-1996 mickey

int bindresvport __P((int sd, struct sockaddr_in *sin));


Revision tags: OPENBSD_2_0_BASE
# 1.4 03-Jul-1996 chuck

renumber AF_NATM to avoid a conflict with freebsd which put ISDN @ 26.
(i should have checked first)


# 1.3 30-Jun-1996 chuck

add native mode atm socket type


# 1.2 29-Feb-1996 niklas

From NetBSD: Merge with NetBSD 960217


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.98 22-Jul-2019 robert

implement SO_DOMAIN and SO_PROTOCOL so that the domain and the protocol
can also be retrieved with getsockopt(3)
it looks like these will also be in the next issue of posix:
http://austingroupbugs.net/view.php?id=840#c2263

ok claudio@, sthen@


# 1.97 03-Jul-2019 dlg

prepare sysctl net mib to allow runtime tuning of rx q pressure thresholds

this renames the PF_LINK bit of the mib from "link_layer" to "link".
then it makes it a node that could be used for generic link layer
bits. the first of these is an "ifrxq" node where the "pressure_return"
and "pressure_drop" things go.

ok visa@ deraadt@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.96 08-Apr-2018 guenther

AF_LOCAL was a failed attempt (by POSIX?) to seem less UNIX-specific, but
AF_UNIX is both the historical _and_ standard name, so prefer and recommend
it in the headers, manpages, and kernel.

ok miller@ deraadt@ schwarze@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.95 31-May-2017 markus

new socketoption SO_ZEROIZE: zero out all mbufs sent over socket
ok deraadt bluhm


# 1.94 04-May-2017 bluhm

Introduce sstosa() for converting sockaddr_storage with a type safe
inline function instead of casting it to sockaddr. While there,
use inline instead of __inline for all these conversions. Some
struct sockaddr casts can be avoided completely.
OK dhill@ mpi@


Revision tags: OPENBSD_6_1_BASE
# 1.93 14-Nov-2016 mpi

Automatically create a default lo(4) interface per rdomain.

In order to stop abusing lo0 for all rdomains, a new loopback interface
will be created every time a rdomain is created. The unit number will
be the same as the rdomain, i.e. lo1 will be attached to rdomain 1.

If this loopback interface is already in use it wont be possible to create
the corresponding rdomain.

In order to know which lo(4) interface is attached to a rdomain, its index
is stored in the rtable/rdomain map.

This is a long overdue since the introduction of rtable/rdomain. It also
fixes a recent regression due to resetting the rdomain of an incoming
packet reported by semarie@, Andreas Bartelt and Nils Frohberg.

ok claudio@


# 1.92 28-Sep-2016 jca

Hide RT_TABLEID_MAX behind __BSD_VISIBLE

Alternate define location suggested by deraadt@ and kettenis@, ok kettenis@


# 1.91 12-Sep-2016 guenther

More #include cleanup per POSIX:
- <sys/types.h>: don't pull in <sys/select.h>
- <sys/select.h>: don't pull in <sys/time.h>, but rather declare timeval
and timespec locally
- <sys/time.h>: *do* always pull in <sys/select.h>
- <sys/socket.h>: declare timeval if __BSD_VISIBLE for struct splice

Ports testing and fixed by ajacoutot@
ok deraadt@ millert@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.90 23-Oct-2015 claudio

Introduce a new sysctl NET_RT_IFNAMES that returns only ifnames to ifindex
mappings. This will be used by if_nameindex(3), if_nametoindex(3) and
if_indextoname(3) soon to fix the issues in pledge because of inet6 link
local addressing.
OK mpi@ benno@ deraadt@
The libc version will follow soon so better start updating your kernels


# 1.89 20-Oct-2015 deraadt

At guenther's suggestion replace dnssocket() with a SOCK_DNS flag on
socket(). Without pledge, all other socket behaviours become permitted,
except this one case: connect/send* only works to *:53. In pledge mode,
a very few are further restricted. Some backwards compatibility for
the dnssocket/dnsconnect calls will remain in the tree temporarily so
that people can build through the transition.
ok tedu guenther semarie


Revision tags: OPENBSD_5_8_BASE
# 1.88 17-Jul-2015 guenther

In socketpair(), need to mask the type argument when testing for dgram.

based on jeremy@'s diff
ok jeremy@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.87 21-Jan-2015 guenther

Delete option COMPAT_43: support for pre-sa_len binaries has been obsolete
for a couple decades. Keep the OSIOCGIFCONF ioctl to support COMPAT_LINUX
but move the rest of the Linux-specific ioctl() handling into linux_socket.c
This lets struct osockaddr finally move from sys/socket.h to protocols/talkd.h

ok krw@ deraadt@ mpi@


# 1.86 18-Jan-2015 guenther

Per POSIX, <sys/socket.h> needs to expose struct iovec, and may do so
by pulling in <sys/uio.h>, so do so. Remove some stuff that we can trust
<sys/uio.h> to also provide, like cdefs.h, _types.h, and exposing size_t
and ssize_t

pointed out by naddy@
ok deraadt@


# 1.85 31-Aug-2014 guenther

Add sockatmark()

ok millert@ manpage feedback jmc@


# 1.84 31-Aug-2014 guenther

Add additional kernel interfaces for setting close-on-exec on fds
when creating them: pipe2(), dup3(), accept4(), MSG_CMSG_CLOEXEC,
SOCK_CLOEXEC. Includes SOCK_NONBLOCK support.

ok matthew@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.83 02-Apr-2013 guenther

Use internal types instead of the old BSD u_int#_t types in the
standard portion of the header.

Most of the diff from James Turner (james (at) calminferno.net)


Revision tags: OPENBSD_5_3_BASE
# 1.82 15-Sep-2012 guenther

Improve POSIX/SUS compliance of <netdb.h>, <sys/socket.h>, and <sys/un.h>.

Much ports testing of various versions by naddy@ and jasper@
ok matthew@, miller@


Revision tags: OPENBSD_5_2_BASE
# 1.81 11-Apr-2012 deraadt

tedu struct omsghdr


# 1.80 04-Apr-2012 deraadt

SCM_CREDS can go away, since everything uses the newer APIs.
ports tree checked by naddy


# 1.79 17-Mar-2012 dlg

remove IP_JUMBO, SO_JUMBO, and RTF_JUMBO.

no objection from mcbride@ krw@ markus@ deraadt@


Revision tags: OPENBSD_5_1_BASE
# 1.78 03-Dec-2011 fgsch

add support for MSG_NOSIGNAL.
linux bits compiled on i386 by sebastia@, mikeb@ ok


# 1.77 08-Sep-2011 guenther

Provide namespace-safe alignment macros in <machine/_types.h>, with
compat names kept in <machine/param.h>. In <sys/socket.h>, pull
in <sys/_types.h> instead of the namespace polluting <machine/param.h>
and completely eliminate __CMSG_ALIGN, replaced by _ALIGN

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.76 08-Jul-2011 deraadt

Remove COMPAT_OLDSOCK since no nothing sets MSG_COMPAT anymore.
The song and dance for handling 16-bit af_family on big-endian
machines remains untouched.
ok claudio miod tedu guenther


# 1.75 08-Jul-2011 mikeb

surround splice structure with __BSD_VISIBLE (the right one, noticed by
bluhm, jasper and millert -- an epic fail on my side), style nits from
deraadt, millert, ok guenther, kettenis, millert, ports tests by jasper


# 1.74 08-Jul-2011 yasuoka

this must be included my previous commit.

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.73 04-Jul-2011 mikeb

Implement an idle timeout for the socket splicing. A new `sp_idle'
field of the `splice' structure can be used to specify a period of
inactivity after which splicing will be dissolved. ETIMEDOUT error
retrieved with a SO_ERROR indicates the idle timeout expiration.
With comments from and OK bluhm.


# 1.72 05-Apr-2011 guenther

Push COMPAT_FREEBSD in front of a whale. Buggy, out of date, no
one has been weeding it, and it makes life harder.

Toasts of Brennivin for its passing from many; diff ok henning@


Revision tags: OPENBSD_4_9_BASE
# 1.71 07-Jan-2011 bluhm

Add socket option SO_SPLICE to splice together two TCP sockets.
The data received on the source socket will automatically be sent
on the drain socket. This allows to write relay daemons with zero
data copy.
ok markus@


Revision tags: OPENBSD_4_8_BASE
# 1.70 05-Jul-2010 tedu

remove compat_bsdos support


# 1.69 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.68 02-Jul-2010 tedu

remove support for compat_sunos (and m68k4k). ok deraadt guenther


# 1.67 01-Jul-2010 deraadt

Put SO_PEERCRED into the non-flag area
suggested by guenther


# 1.66 30-Jun-2010 tedu

remove compat_osf1 support from the kernel
ok deraadt miod


# 1.65 30-Jun-2010 deraadt

Add getsockopt SOL_SOCKET SO_PEERCRED support. This behaves similar to
getpeereid(2), but also supplies the remote pid. This is supplied in
a 'struct sockpeercred' (unlike Linux -- they showed how little they
know about real unix by calling theirs 'struct ucred').
ok guenther ajacoutot


# 1.64 29-Jun-2010 guenther

Remove COMPAT_HPUX. No one wanted to support it and its fewmets were
blocking other cleanups
ok miod@


# 1.63 21-Apr-2010 claudio

Implement a way to get information about a rtable. Currently only the rtableid
and rdomainid are returned. This is necessary to know where L2 information
of a table is stored (which will be needed soon by bgpd).
Also while there change the errno for non-existing routing tables to ENOENT.
'Fine' deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.62 27-Nov-2009 guenther

Add setrdomain() and getrdomain() system calls. Committing now to
catch the libc major bump per request from deraadt@

Diff by reyk.

ok guenther@


Revision tags: OPENBSD_4_6_BASE
# 1.61 11-Jun-2009 jsg

tab indent SO_RDOMAIN, like all the other SO_* defines.


# 1.60 05-Jun-2009 claudio

Initial support for routing domains. This allows to bind interfaces to
alternate routing table and separate them from other interfaces in distinct
routing tables. The same network can now be used in any doamin at the same
time without causing conflicts.
This diff is mostly mechanical and adds the necessary rdomain checks accross
net and netinet. L2 and IPv4 are mostly covered still missing pf and IPv6.
input and tested by jsg@, phessler@ and reyk@. "put it in" deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.59 16-Sep-2008 gollo

netstat statistics for pflow(4) via pseudo family

ok cluadio@ henning@


Revision tags: OPENBSD_4_4_BASE
# 1.58 09-May-2008 markus

Add SO_BINDANY socket option from BSD/OS.

The option allows a socket to be bound to addresses which are not
local to the machine. In order to receive packets for these addresses
SO_BINDANY needs to be combined with matching outgoing pf(4) divert
rules, see pf.conf(5).

ok beck@


# 1.57 02-May-2008 ckuethe

Make the SO_TIMESTAMP sockopt work. When set, this allows the user to
get a timestamp of when the datagram was accepted (by udp(4), for
example) rather than having to take a timestamp with gettimeofday(2)
when recv(2) returns - possibly several hundreds of microseconds later.
May be of use to those interested in precision network timing schemes
or QoS for media applications. Tested on alpha, amd64, i386 and sparc64.
manpage suggestions from jmc, ok deraadt


# 1.56 23-Apr-2008 norby

Import MPLS (Multi Protocol Label Switching)

MPLS support partly based on the (abandoned?) AYAME project.
Basic LSR (Label Switch Router) functionality is present, but not fully
functional yet.

It is currently possible to insert entries in the LIB (Label Information Base)
with route(8), but setting the operation type is not supported yet.

Imported to allow more people to work on this in the coming weeks.

ok claudio@ laurent@ dlg@


Revision tags: OPENBSD_4_3_BASE
# 1.55 27-Nov-2007 martynas

typos; ok jmc@
sys/dev/pci/pciide.c from naddy@


# 1.54 24-Sep-2007 henning

updatecomment and manpage toemtion optional seventh level (rtable id)
From: Pierre Riteau <pierre.riteau@free.fr>


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.53 31-Mar-2006 claudio

Add sysctl to retrieve the routing table statisitcs. Will be used by netstat
instead of kvm access. OK henning@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.52 27-May-2005 mcbride

Experimental support for opportunitic use of jumbograms where only some hosts
on the local network support them.

This adds a new socket option, SO_JUMBO, and a new route flag,
RTF_JUMBO. If _both_ the socket option is set and the route for the host
has RTF_JUMBO set, ip_output will fragment the packet to the largest
possible size for the link, ignoring the card's MTU.

The semantics of this feature will be evolving rapidly; talk to us
if you intend to use it.

ok deraadt@ marius@


# 1.51 04-Apr-2005 hshoexer

Add sysctl for dumping the SPD
ok deraadt, ok markus some time ago


# 1.50 22-Mar-2005 henning

fix a typo, don't #define PF_RTIP to something nonmexistant
nothing in our tree uses it (well, would have been spotted then)
netbsd PR kern/29624 via jmc@, agreed on by claudio some time ago


Revision tags: OPENBSD_3_7_BASE
# 1.49 14-Jan-2005 grange

First step in Bluetooth protocol stack support.

The code is adopted from the FreeBSD netgraph-based Bluetooth
implementation by Maksim Yevmenkin <m_evmenkin@yahoo.com> but
all netgraph glue was replaced with usual BSD network stack
hooks. This is a work in progress. Only HCI layer works for now,
L2CAP and RFCOMM are on the way.

Help in testing from many, ok markus@.


# 1.48 26-Nov-2004 markus

add pfkey sysctl subtree; ok deraadt


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.47 24-Feb-2004 tedu

sysctl knob for bpf tunables. some tips from canacar@
ok canacar@ deraadt@ mcbride@


Revision tags: OPENBSD_3_4_BASE
# 1.46 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.45 24-Nov-2002 espie

Explicit unsigned char and unsigned short instead of u_char, u_short.
Make these files usable with -D_POSIX_SOURCE
okay millert@


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.44 10-Sep-2002 deraadt

typo; krapht@secureops.com


Revision tags: OPENBSD_3_1_BASE
# 1.43 15-Mar-2002 itojun

typecast in CMSG_NXTHDR. spotted by hugh@openbsd


# 1.42 14-Mar-2002 millert

First round of __P removal in sys


# 1.41 08-Mar-2002 espie

Make msghdr fields usable from all languages.
ok millert@


# 1.40 10-Jan-2002 itojun

remove duplicated decl of PF_INET6. found by kjc


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.39 07-Sep-2001 itojun

branches: 1.39.4;
just as RFC2292 suggests, validate cmsg_controllen on CMSG_FIRSTHDR.
sync with kame.


# 1.38 26-Jun-2001 dugsong

implement djb's getpeereid(2), to allow local-domain servers to determine client credentials. mostly from superscript.com. deraadt@ ok


# 1.37 22-Jun-2001 deraadt

KNF


# 1.36 28-May-2001 dugsong

add BIOC[GS]HDRCMPLT ioctl for BPF, to disable overwriting of link level source address in forged frames. from NetBSD. art@ok


Revision tags: OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.35 13-Aug-2000 ericj

if COMPAT_OSF1 is defined, define COMPAT_OLDSOCK
and COMPAT_OLDTTY.


# 1.34 02-Jul-2000 fgsch

MSG_COMPAT is needed for COMPAT_BSDOS too.


Revision tags: OPENBSD_2_7_BASE
# 1.33 03-Apr-2000 itojun

hide CMSG_ALIGN from userland, it is not part of RFC2292/Posix.1g.


# 1.32 04-Mar-2000 itojun

to be Posix.1g compliant, fix ancillary message alignment. it will now be
aligned to ALIGNBYTES (arch dependent).
NOTE: the change requires you to recompile IPv6 userland, if you are
on arch that is ALIGNBYTES != sizeof(long) - 1 (sparc seems to be it).
sorry for the mess.


# 1.31 18-Feb-2000 itojun

fix alignment problem in ancillary data (alpha).

only ipv6 tools (which touches ancillary data) are affected.

From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


Revision tags: SMP_BASE kame_19991208
# 1.30 08-Dec-1999 itojun

branches: 1.30.2;
bring in KAME IPv6 code, dated 19991208.
replaces NRL IPv6 layer. reuses NRL pcb layer. no IPsec-on-v6 support.
see sys/netinet6/{TODO,IMPLEMENTATION} for more details.

GENERIC configuration should work fine as before. GENERIC.v6 works fine
as well, but you'll need KAME userland tools to play with IPv6 (will be
bringed into soon).


Revision tags: OPENBSD_2_6_BASE
# 1.29 06-Jun-1999 deraadt

sockaddr_storage; per rfc2553


Revision tags: OPENBSD_2_5_BASE
# 1.28 25-Feb-1999 deraadt

rename sysctl names


# 1.27 25-Feb-1999 deraadt

sockaddr_union cannot be declared here, obviously, or in any other file that i know of


# 1.26 24-Feb-1999 angelos

Changes to socket.h to include union sockaddr_union, temporarily add osdep.h,
until pfkey files are cleaned up.


# 1.25 16-Feb-1999 millert

sendto(2) takes socklen_t for length param


# 1.24 15-Feb-1999 millert

pasto


# 1.23 15-Feb-1999 millert

more uses of socklen_t


# 1.22 15-Feb-1999 millert

Use and document socklen_t


# 1.21 05-Feb-1999 deraadt

support MSG_BCAST and MSG_MCAST


# 1.20 10-Jan-1999 deraadt

add SO_NETPROC and CMSG_{FIRSTHDR,ALIGN,LEN,SPACE}; cmetz


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.19 30-Nov-1997 millert

Move in_addr_t and in_port_t to <sys/types.h> and add sa_family_t
and suseconds_t types for XPG4.2.


# 1.18 16-Nov-1997 deraadt

add SHUT_* values as defined by XPG4.2


Revision tags: OPENBSD_2_2_BASE
# 1.17 14-Jul-1997 angelos

Fix the CTLNET order.


Revision tags: OPENBSD_2_1_BASE
# 1.16 24-Apr-1997 angelos

Added PF_KEY definition.


# 1.15 12-Mar-1997 downsj

Move AF_SIP and put AF_INET6 in the same location as BSD/OS.

I couldn't find any use of AF_SIP in the kernel, didn't check user land.


# 1.14 28-Feb-1997 angelos

Moved everything to netinet/in.h, where they should have been in the
first place.


# 1.13 28-Feb-1997 angelos

Per security-level defaults.


# 1.12 28-Feb-1997 angelos

Can't make up my mind; i think this is final.


# 1.11 28-Feb-1997 angelos

IPsec socket API.


# 1.10 22-Feb-1997 angelos

Preliminaries for IPsec socket API.


# 1.9 20-Feb-1997 deraadt

IPSEC package by John Ioannidis and Angelos D. Keromytis. Written in
Greece. From ftp.funet.fi:/pub/unix/security/net/ip/BSDipsec.tar.gz


# 1.8 12-Dec-1996 mickey

undo last change.


# 1.7 12-Dec-1996 deraadt

wrong place for bindresvport() proto


# 1.6 12-Dec-1996 mickey

struct sockaddr_in; prototype


# 1.5 12-Dec-1996 mickey

int bindresvport __P((int sd, struct sockaddr_in *sin));


Revision tags: OPENBSD_2_0_BASE
# 1.4 03-Jul-1996 chuck

renumber AF_NATM to avoid a conflict with freebsd which put ISDN @ 26.
(i should have checked first)


# 1.3 30-Jun-1996 chuck

add native mode atm socket type


# 1.2 29-Feb-1996 niklas

From NetBSD: Merge with NetBSD 960217


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.97 03-Jul-2019 dlg

prepare sysctl net mib to allow runtime tuning of rx q pressure thresholds

this renames the PF_LINK bit of the mib from "link_layer" to "link".
then it makes it a node that could be used for generic link layer
bits. the first of these is an "ifrxq" node where the "pressure_return"
and "pressure_drop" things go.

ok visa@ deraadt@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.96 08-Apr-2018 guenther

AF_LOCAL was a failed attempt (by POSIX?) to seem less UNIX-specific, but
AF_UNIX is both the historical _and_ standard name, so prefer and recommend
it in the headers, manpages, and kernel.

ok miller@ deraadt@ schwarze@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.95 31-May-2017 markus

new socketoption SO_ZEROIZE: zero out all mbufs sent over socket
ok deraadt bluhm


# 1.94 04-May-2017 bluhm

Introduce sstosa() for converting sockaddr_storage with a type safe
inline function instead of casting it to sockaddr. While there,
use inline instead of __inline for all these conversions. Some
struct sockaddr casts can be avoided completely.
OK dhill@ mpi@


Revision tags: OPENBSD_6_1_BASE
# 1.93 14-Nov-2016 mpi

Automatically create a default lo(4) interface per rdomain.

In order to stop abusing lo0 for all rdomains, a new loopback interface
will be created every time a rdomain is created. The unit number will
be the same as the rdomain, i.e. lo1 will be attached to rdomain 1.

If this loopback interface is already in use it wont be possible to create
the corresponding rdomain.

In order to know which lo(4) interface is attached to a rdomain, its index
is stored in the rtable/rdomain map.

This is a long overdue since the introduction of rtable/rdomain. It also
fixes a recent regression due to resetting the rdomain of an incoming
packet reported by semarie@, Andreas Bartelt and Nils Frohberg.

ok claudio@


# 1.92 28-Sep-2016 jca

Hide RT_TABLEID_MAX behind __BSD_VISIBLE

Alternate define location suggested by deraadt@ and kettenis@, ok kettenis@


# 1.91 12-Sep-2016 guenther

More #include cleanup per POSIX:
- <sys/types.h>: don't pull in <sys/select.h>
- <sys/select.h>: don't pull in <sys/time.h>, but rather declare timeval
and timespec locally
- <sys/time.h>: *do* always pull in <sys/select.h>
- <sys/socket.h>: declare timeval if __BSD_VISIBLE for struct splice

Ports testing and fixed by ajacoutot@
ok deraadt@ millert@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.90 23-Oct-2015 claudio

Introduce a new sysctl NET_RT_IFNAMES that returns only ifnames to ifindex
mappings. This will be used by if_nameindex(3), if_nametoindex(3) and
if_indextoname(3) soon to fix the issues in pledge because of inet6 link
local addressing.
OK mpi@ benno@ deraadt@
The libc version will follow soon so better start updating your kernels


# 1.89 20-Oct-2015 deraadt

At guenther's suggestion replace dnssocket() with a SOCK_DNS flag on
socket(). Without pledge, all other socket behaviours become permitted,
except this one case: connect/send* only works to *:53. In pledge mode,
a very few are further restricted. Some backwards compatibility for
the dnssocket/dnsconnect calls will remain in the tree temporarily so
that people can build through the transition.
ok tedu guenther semarie


Revision tags: OPENBSD_5_8_BASE
# 1.88 17-Jul-2015 guenther

In socketpair(), need to mask the type argument when testing for dgram.

based on jeremy@'s diff
ok jeremy@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.87 21-Jan-2015 guenther

Delete option COMPAT_43: support for pre-sa_len binaries has been obsolete
for a couple decades. Keep the OSIOCGIFCONF ioctl to support COMPAT_LINUX
but move the rest of the Linux-specific ioctl() handling into linux_socket.c
This lets struct osockaddr finally move from sys/socket.h to protocols/talkd.h

ok krw@ deraadt@ mpi@


# 1.86 18-Jan-2015 guenther

Per POSIX, <sys/socket.h> needs to expose struct iovec, and may do so
by pulling in <sys/uio.h>, so do so. Remove some stuff that we can trust
<sys/uio.h> to also provide, like cdefs.h, _types.h, and exposing size_t
and ssize_t

pointed out by naddy@
ok deraadt@


# 1.85 31-Aug-2014 guenther

Add sockatmark()

ok millert@ manpage feedback jmc@


# 1.84 31-Aug-2014 guenther

Add additional kernel interfaces for setting close-on-exec on fds
when creating them: pipe2(), dup3(), accept4(), MSG_CMSG_CLOEXEC,
SOCK_CLOEXEC. Includes SOCK_NONBLOCK support.

ok matthew@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.83 02-Apr-2013 guenther

Use internal types instead of the old BSD u_int#_t types in the
standard portion of the header.

Most of the diff from James Turner (james (at) calminferno.net)


Revision tags: OPENBSD_5_3_BASE
# 1.82 15-Sep-2012 guenther

Improve POSIX/SUS compliance of <netdb.h>, <sys/socket.h>, and <sys/un.h>.

Much ports testing of various versions by naddy@ and jasper@
ok matthew@, miller@


Revision tags: OPENBSD_5_2_BASE
# 1.81 11-Apr-2012 deraadt

tedu struct omsghdr


# 1.80 04-Apr-2012 deraadt

SCM_CREDS can go away, since everything uses the newer APIs.
ports tree checked by naddy


# 1.79 17-Mar-2012 dlg

remove IP_JUMBO, SO_JUMBO, and RTF_JUMBO.

no objection from mcbride@ krw@ markus@ deraadt@


Revision tags: OPENBSD_5_1_BASE
# 1.78 03-Dec-2011 fgsch

add support for MSG_NOSIGNAL.
linux bits compiled on i386 by sebastia@, mikeb@ ok


# 1.77 08-Sep-2011 guenther

Provide namespace-safe alignment macros in <machine/_types.h>, with
compat names kept in <machine/param.h>. In <sys/socket.h>, pull
in <sys/_types.h> instead of the namespace polluting <machine/param.h>
and completely eliminate __CMSG_ALIGN, replaced by _ALIGN

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.76 08-Jul-2011 deraadt

Remove COMPAT_OLDSOCK since no nothing sets MSG_COMPAT anymore.
The song and dance for handling 16-bit af_family on big-endian
machines remains untouched.
ok claudio miod tedu guenther


# 1.75 08-Jul-2011 mikeb

surround splice structure with __BSD_VISIBLE (the right one, noticed by
bluhm, jasper and millert -- an epic fail on my side), style nits from
deraadt, millert, ok guenther, kettenis, millert, ports tests by jasper


# 1.74 08-Jul-2011 yasuoka

this must be included my previous commit.

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.73 04-Jul-2011 mikeb

Implement an idle timeout for the socket splicing. A new `sp_idle'
field of the `splice' structure can be used to specify a period of
inactivity after which splicing will be dissolved. ETIMEDOUT error
retrieved with a SO_ERROR indicates the idle timeout expiration.
With comments from and OK bluhm.


# 1.72 05-Apr-2011 guenther

Push COMPAT_FREEBSD in front of a whale. Buggy, out of date, no
one has been weeding it, and it makes life harder.

Toasts of Brennivin for its passing from many; diff ok henning@


Revision tags: OPENBSD_4_9_BASE
# 1.71 07-Jan-2011 bluhm

Add socket option SO_SPLICE to splice together two TCP sockets.
The data received on the source socket will automatically be sent
on the drain socket. This allows to write relay daemons with zero
data copy.
ok markus@


Revision tags: OPENBSD_4_8_BASE
# 1.70 05-Jul-2010 tedu

remove compat_bsdos support


# 1.69 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.68 02-Jul-2010 tedu

remove support for compat_sunos (and m68k4k). ok deraadt guenther


# 1.67 01-Jul-2010 deraadt

Put SO_PEERCRED into the non-flag area
suggested by guenther


# 1.66 30-Jun-2010 tedu

remove compat_osf1 support from the kernel
ok deraadt miod


# 1.65 30-Jun-2010 deraadt

Add getsockopt SOL_SOCKET SO_PEERCRED support. This behaves similar to
getpeereid(2), but also supplies the remote pid. This is supplied in
a 'struct sockpeercred' (unlike Linux -- they showed how little they
know about real unix by calling theirs 'struct ucred').
ok guenther ajacoutot


# 1.64 29-Jun-2010 guenther

Remove COMPAT_HPUX. No one wanted to support it and its fewmets were
blocking other cleanups
ok miod@


# 1.63 21-Apr-2010 claudio

Implement a way to get information about a rtable. Currently only the rtableid
and rdomainid are returned. This is necessary to know where L2 information
of a table is stored (which will be needed soon by bgpd).
Also while there change the errno for non-existing routing tables to ENOENT.
'Fine' deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.62 27-Nov-2009 guenther

Add setrdomain() and getrdomain() system calls. Committing now to
catch the libc major bump per request from deraadt@

Diff by reyk.

ok guenther@


Revision tags: OPENBSD_4_6_BASE
# 1.61 11-Jun-2009 jsg

tab indent SO_RDOMAIN, like all the other SO_* defines.


# 1.60 05-Jun-2009 claudio

Initial support for routing domains. This allows to bind interfaces to
alternate routing table and separate them from other interfaces in distinct
routing tables. The same network can now be used in any doamin at the same
time without causing conflicts.
This diff is mostly mechanical and adds the necessary rdomain checks accross
net and netinet. L2 and IPv4 are mostly covered still missing pf and IPv6.
input and tested by jsg@, phessler@ and reyk@. "put it in" deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.59 16-Sep-2008 gollo

netstat statistics for pflow(4) via pseudo family

ok cluadio@ henning@


Revision tags: OPENBSD_4_4_BASE
# 1.58 09-May-2008 markus

Add SO_BINDANY socket option from BSD/OS.

The option allows a socket to be bound to addresses which are not
local to the machine. In order to receive packets for these addresses
SO_BINDANY needs to be combined with matching outgoing pf(4) divert
rules, see pf.conf(5).

ok beck@


# 1.57 02-May-2008 ckuethe

Make the SO_TIMESTAMP sockopt work. When set, this allows the user to
get a timestamp of when the datagram was accepted (by udp(4), for
example) rather than having to take a timestamp with gettimeofday(2)
when recv(2) returns - possibly several hundreds of microseconds later.
May be of use to those interested in precision network timing schemes
or QoS for media applications. Tested on alpha, amd64, i386 and sparc64.
manpage suggestions from jmc, ok deraadt


# 1.56 23-Apr-2008 norby

Import MPLS (Multi Protocol Label Switching)

MPLS support partly based on the (abandoned?) AYAME project.
Basic LSR (Label Switch Router) functionality is present, but not fully
functional yet.

It is currently possible to insert entries in the LIB (Label Information Base)
with route(8), but setting the operation type is not supported yet.

Imported to allow more people to work on this in the coming weeks.

ok claudio@ laurent@ dlg@


Revision tags: OPENBSD_4_3_BASE
# 1.55 27-Nov-2007 martynas

typos; ok jmc@
sys/dev/pci/pciide.c from naddy@


# 1.54 24-Sep-2007 henning

updatecomment and manpage toemtion optional seventh level (rtable id)
From: Pierre Riteau <pierre.riteau@free.fr>


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.53 31-Mar-2006 claudio

Add sysctl to retrieve the routing table statisitcs. Will be used by netstat
instead of kvm access. OK henning@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.52 27-May-2005 mcbride

Experimental support for opportunitic use of jumbograms where only some hosts
on the local network support them.

This adds a new socket option, SO_JUMBO, and a new route flag,
RTF_JUMBO. If _both_ the socket option is set and the route for the host
has RTF_JUMBO set, ip_output will fragment the packet to the largest
possible size for the link, ignoring the card's MTU.

The semantics of this feature will be evolving rapidly; talk to us
if you intend to use it.

ok deraadt@ marius@


# 1.51 04-Apr-2005 hshoexer

Add sysctl for dumping the SPD
ok deraadt, ok markus some time ago


# 1.50 22-Mar-2005 henning

fix a typo, don't #define PF_RTIP to something nonmexistant
nothing in our tree uses it (well, would have been spotted then)
netbsd PR kern/29624 via jmc@, agreed on by claudio some time ago


Revision tags: OPENBSD_3_7_BASE
# 1.49 14-Jan-2005 grange

First step in Bluetooth protocol stack support.

The code is adopted from the FreeBSD netgraph-based Bluetooth
implementation by Maksim Yevmenkin <m_evmenkin@yahoo.com> but
all netgraph glue was replaced with usual BSD network stack
hooks. This is a work in progress. Only HCI layer works for now,
L2CAP and RFCOMM are on the way.

Help in testing from many, ok markus@.


# 1.48 26-Nov-2004 markus

add pfkey sysctl subtree; ok deraadt


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.47 24-Feb-2004 tedu

sysctl knob for bpf tunables. some tips from canacar@
ok canacar@ deraadt@ mcbride@


Revision tags: OPENBSD_3_4_BASE
# 1.46 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.45 24-Nov-2002 espie

Explicit unsigned char and unsigned short instead of u_char, u_short.
Make these files usable with -D_POSIX_SOURCE
okay millert@


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.44 10-Sep-2002 deraadt

typo; krapht@secureops.com


Revision tags: OPENBSD_3_1_BASE
# 1.43 15-Mar-2002 itojun

typecast in CMSG_NXTHDR. spotted by hugh@openbsd


# 1.42 14-Mar-2002 millert

First round of __P removal in sys


# 1.41 08-Mar-2002 espie

Make msghdr fields usable from all languages.
ok millert@


# 1.40 10-Jan-2002 itojun

remove duplicated decl of PF_INET6. found by kjc


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.39 07-Sep-2001 itojun

branches: 1.39.4;
just as RFC2292 suggests, validate cmsg_controllen on CMSG_FIRSTHDR.
sync with kame.


# 1.38 26-Jun-2001 dugsong

implement djb's getpeereid(2), to allow local-domain servers to determine client credentials. mostly from superscript.com. deraadt@ ok


# 1.37 22-Jun-2001 deraadt

KNF


# 1.36 28-May-2001 dugsong

add BIOC[GS]HDRCMPLT ioctl for BPF, to disable overwriting of link level source address in forged frames. from NetBSD. art@ok


Revision tags: OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.35 13-Aug-2000 ericj

if COMPAT_OSF1 is defined, define COMPAT_OLDSOCK
and COMPAT_OLDTTY.


# 1.34 02-Jul-2000 fgsch

MSG_COMPAT is needed for COMPAT_BSDOS too.


Revision tags: OPENBSD_2_7_BASE
# 1.33 03-Apr-2000 itojun

hide CMSG_ALIGN from userland, it is not part of RFC2292/Posix.1g.


# 1.32 04-Mar-2000 itojun

to be Posix.1g compliant, fix ancillary message alignment. it will now be
aligned to ALIGNBYTES (arch dependent).
NOTE: the change requires you to recompile IPv6 userland, if you are
on arch that is ALIGNBYTES != sizeof(long) - 1 (sparc seems to be it).
sorry for the mess.


# 1.31 18-Feb-2000 itojun

fix alignment problem in ancillary data (alpha).

only ipv6 tools (which touches ancillary data) are affected.

From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


Revision tags: SMP_BASE kame_19991208
# 1.30 08-Dec-1999 itojun

branches: 1.30.2;
bring in KAME IPv6 code, dated 19991208.
replaces NRL IPv6 layer. reuses NRL pcb layer. no IPsec-on-v6 support.
see sys/netinet6/{TODO,IMPLEMENTATION} for more details.

GENERIC configuration should work fine as before. GENERIC.v6 works fine
as well, but you'll need KAME userland tools to play with IPv6 (will be
bringed into soon).


Revision tags: OPENBSD_2_6_BASE
# 1.29 06-Jun-1999 deraadt

sockaddr_storage; per rfc2553


Revision tags: OPENBSD_2_5_BASE
# 1.28 25-Feb-1999 deraadt

rename sysctl names


# 1.27 25-Feb-1999 deraadt

sockaddr_union cannot be declared here, obviously, or in any other file that i know of


# 1.26 24-Feb-1999 angelos

Changes to socket.h to include union sockaddr_union, temporarily add osdep.h,
until pfkey files are cleaned up.


# 1.25 16-Feb-1999 millert

sendto(2) takes socklen_t for length param


# 1.24 15-Feb-1999 millert

pasto


# 1.23 15-Feb-1999 millert

more uses of socklen_t


# 1.22 15-Feb-1999 millert

Use and document socklen_t


# 1.21 05-Feb-1999 deraadt

support MSG_BCAST and MSG_MCAST


# 1.20 10-Jan-1999 deraadt

add SO_NETPROC and CMSG_{FIRSTHDR,ALIGN,LEN,SPACE}; cmetz


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.19 30-Nov-1997 millert

Move in_addr_t and in_port_t to <sys/types.h> and add sa_family_t
and suseconds_t types for XPG4.2.


# 1.18 16-Nov-1997 deraadt

add SHUT_* values as defined by XPG4.2


Revision tags: OPENBSD_2_2_BASE
# 1.17 14-Jul-1997 angelos

Fix the CTLNET order.


Revision tags: OPENBSD_2_1_BASE
# 1.16 24-Apr-1997 angelos

Added PF_KEY definition.


# 1.15 12-Mar-1997 downsj

Move AF_SIP and put AF_INET6 in the same location as BSD/OS.

I couldn't find any use of AF_SIP in the kernel, didn't check user land.


# 1.14 28-Feb-1997 angelos

Moved everything to netinet/in.h, where they should have been in the
first place.


# 1.13 28-Feb-1997 angelos

Per security-level defaults.


# 1.12 28-Feb-1997 angelos

Can't make up my mind; i think this is final.


# 1.11 28-Feb-1997 angelos

IPsec socket API.


# 1.10 22-Feb-1997 angelos

Preliminaries for IPsec socket API.


# 1.9 20-Feb-1997 deraadt

IPSEC package by John Ioannidis and Angelos D. Keromytis. Written in
Greece. From ftp.funet.fi:/pub/unix/security/net/ip/BSDipsec.tar.gz


# 1.8 12-Dec-1996 mickey

undo last change.


# 1.7 12-Dec-1996 deraadt

wrong place for bindresvport() proto


# 1.6 12-Dec-1996 mickey

struct sockaddr_in; prototype


# 1.5 12-Dec-1996 mickey

int bindresvport __P((int sd, struct sockaddr_in *sin));


Revision tags: OPENBSD_2_0_BASE
# 1.4 03-Jul-1996 chuck

renumber AF_NATM to avoid a conflict with freebsd which put ISDN @ 26.
(i should have checked first)


# 1.3 30-Jun-1996 chuck

add native mode atm socket type


# 1.2 29-Feb-1996 niklas

From NetBSD: Merge with NetBSD 960217


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.96 08-Apr-2018 guenther

AF_LOCAL was a failed attempt (by POSIX?) to seem less UNIX-specific, but
AF_UNIX is both the historical _and_ standard name, so prefer and recommend
it in the headers, manpages, and kernel.

ok miller@ deraadt@ schwarze@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.95 31-May-2017 markus

new socketoption SO_ZEROIZE: zero out all mbufs sent over socket
ok deraadt bluhm


# 1.94 04-May-2017 bluhm

Introduce sstosa() for converting sockaddr_storage with a type safe
inline function instead of casting it to sockaddr. While there,
use inline instead of __inline for all these conversions. Some
struct sockaddr casts can be avoided completely.
OK dhill@ mpi@


Revision tags: OPENBSD_6_1_BASE
# 1.93 14-Nov-2016 mpi

Automatically create a default lo(4) interface per rdomain.

In order to stop abusing lo0 for all rdomains, a new loopback interface
will be created every time a rdomain is created. The unit number will
be the same as the rdomain, i.e. lo1 will be attached to rdomain 1.

If this loopback interface is already in use it wont be possible to create
the corresponding rdomain.

In order to know which lo(4) interface is attached to a rdomain, its index
is stored in the rtable/rdomain map.

This is a long overdue since the introduction of rtable/rdomain. It also
fixes a recent regression due to resetting the rdomain of an incoming
packet reported by semarie@, Andreas Bartelt and Nils Frohberg.

ok claudio@


# 1.92 28-Sep-2016 jca

Hide RT_TABLEID_MAX behind __BSD_VISIBLE

Alternate define location suggested by deraadt@ and kettenis@, ok kettenis@


# 1.91 12-Sep-2016 guenther

More #include cleanup per POSIX:
- <sys/types.h>: don't pull in <sys/select.h>
- <sys/select.h>: don't pull in <sys/time.h>, but rather declare timeval
and timespec locally
- <sys/time.h>: *do* always pull in <sys/select.h>
- <sys/socket.h>: declare timeval if __BSD_VISIBLE for struct splice

Ports testing and fixed by ajacoutot@
ok deraadt@ millert@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.90 23-Oct-2015 claudio

Introduce a new sysctl NET_RT_IFNAMES that returns only ifnames to ifindex
mappings. This will be used by if_nameindex(3), if_nametoindex(3) and
if_indextoname(3) soon to fix the issues in pledge because of inet6 link
local addressing.
OK mpi@ benno@ deraadt@
The libc version will follow soon so better start updating your kernels


# 1.89 20-Oct-2015 deraadt

At guenther's suggestion replace dnssocket() with a SOCK_DNS flag on
socket(). Without pledge, all other socket behaviours become permitted,
except this one case: connect/send* only works to *:53. In pledge mode,
a very few are further restricted. Some backwards compatibility for
the dnssocket/dnsconnect calls will remain in the tree temporarily so
that people can build through the transition.
ok tedu guenther semarie


Revision tags: OPENBSD_5_8_BASE
# 1.88 17-Jul-2015 guenther

In socketpair(), need to mask the type argument when testing for dgram.

based on jeremy@'s diff
ok jeremy@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.87 21-Jan-2015 guenther

Delete option COMPAT_43: support for pre-sa_len binaries has been obsolete
for a couple decades. Keep the OSIOCGIFCONF ioctl to support COMPAT_LINUX
but move the rest of the Linux-specific ioctl() handling into linux_socket.c
This lets struct osockaddr finally move from sys/socket.h to protocols/talkd.h

ok krw@ deraadt@ mpi@


# 1.86 18-Jan-2015 guenther

Per POSIX, <sys/socket.h> needs to expose struct iovec, and may do so
by pulling in <sys/uio.h>, so do so. Remove some stuff that we can trust
<sys/uio.h> to also provide, like cdefs.h, _types.h, and exposing size_t
and ssize_t

pointed out by naddy@
ok deraadt@


# 1.85 31-Aug-2014 guenther

Add sockatmark()

ok millert@ manpage feedback jmc@


# 1.84 31-Aug-2014 guenther

Add additional kernel interfaces for setting close-on-exec on fds
when creating them: pipe2(), dup3(), accept4(), MSG_CMSG_CLOEXEC,
SOCK_CLOEXEC. Includes SOCK_NONBLOCK support.

ok matthew@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.83 02-Apr-2013 guenther

Use internal types instead of the old BSD u_int#_t types in the
standard portion of the header.

Most of the diff from James Turner (james (at) calminferno.net)


Revision tags: OPENBSD_5_3_BASE
# 1.82 15-Sep-2012 guenther

Improve POSIX/SUS compliance of <netdb.h>, <sys/socket.h>, and <sys/un.h>.

Much ports testing of various versions by naddy@ and jasper@
ok matthew@, miller@


Revision tags: OPENBSD_5_2_BASE
# 1.81 11-Apr-2012 deraadt

tedu struct omsghdr


# 1.80 04-Apr-2012 deraadt

SCM_CREDS can go away, since everything uses the newer APIs.
ports tree checked by naddy


# 1.79 17-Mar-2012 dlg

remove IP_JUMBO, SO_JUMBO, and RTF_JUMBO.

no objection from mcbride@ krw@ markus@ deraadt@


Revision tags: OPENBSD_5_1_BASE
# 1.78 03-Dec-2011 fgsch

add support for MSG_NOSIGNAL.
linux bits compiled on i386 by sebastia@, mikeb@ ok


# 1.77 08-Sep-2011 guenther

Provide namespace-safe alignment macros in <machine/_types.h>, with
compat names kept in <machine/param.h>. In <sys/socket.h>, pull
in <sys/_types.h> instead of the namespace polluting <machine/param.h>
and completely eliminate __CMSG_ALIGN, replaced by _ALIGN

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.76 08-Jul-2011 deraadt

Remove COMPAT_OLDSOCK since no nothing sets MSG_COMPAT anymore.
The song and dance for handling 16-bit af_family on big-endian
machines remains untouched.
ok claudio miod tedu guenther


# 1.75 08-Jul-2011 mikeb

surround splice structure with __BSD_VISIBLE (the right one, noticed by
bluhm, jasper and millert -- an epic fail on my side), style nits from
deraadt, millert, ok guenther, kettenis, millert, ports tests by jasper


# 1.74 08-Jul-2011 yasuoka

this must be included my previous commit.

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.73 04-Jul-2011 mikeb

Implement an idle timeout for the socket splicing. A new `sp_idle'
field of the `splice' structure can be used to specify a period of
inactivity after which splicing will be dissolved. ETIMEDOUT error
retrieved with a SO_ERROR indicates the idle timeout expiration.
With comments from and OK bluhm.


# 1.72 05-Apr-2011 guenther

Push COMPAT_FREEBSD in front of a whale. Buggy, out of date, no
one has been weeding it, and it makes life harder.

Toasts of Brennivin for its passing from many; diff ok henning@


Revision tags: OPENBSD_4_9_BASE
# 1.71 07-Jan-2011 bluhm

Add socket option SO_SPLICE to splice together two TCP sockets.
The data received on the source socket will automatically be sent
on the drain socket. This allows to write relay daemons with zero
data copy.
ok markus@


Revision tags: OPENBSD_4_8_BASE
# 1.70 05-Jul-2010 tedu

remove compat_bsdos support


# 1.69 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.68 02-Jul-2010 tedu

remove support for compat_sunos (and m68k4k). ok deraadt guenther


# 1.67 01-Jul-2010 deraadt

Put SO_PEERCRED into the non-flag area
suggested by guenther


# 1.66 30-Jun-2010 tedu

remove compat_osf1 support from the kernel
ok deraadt miod


# 1.65 30-Jun-2010 deraadt

Add getsockopt SOL_SOCKET SO_PEERCRED support. This behaves similar to
getpeereid(2), but also supplies the remote pid. This is supplied in
a 'struct sockpeercred' (unlike Linux -- they showed how little they
know about real unix by calling theirs 'struct ucred').
ok guenther ajacoutot


# 1.64 29-Jun-2010 guenther

Remove COMPAT_HPUX. No one wanted to support it and its fewmets were
blocking other cleanups
ok miod@


# 1.63 21-Apr-2010 claudio

Implement a way to get information about a rtable. Currently only the rtableid
and rdomainid are returned. This is necessary to know where L2 information
of a table is stored (which will be needed soon by bgpd).
Also while there change the errno for non-existing routing tables to ENOENT.
'Fine' deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.62 27-Nov-2009 guenther

Add setrdomain() and getrdomain() system calls. Committing now to
catch the libc major bump per request from deraadt@

Diff by reyk.

ok guenther@


Revision tags: OPENBSD_4_6_BASE
# 1.61 11-Jun-2009 jsg

tab indent SO_RDOMAIN, like all the other SO_* defines.


# 1.60 05-Jun-2009 claudio

Initial support for routing domains. This allows to bind interfaces to
alternate routing table and separate them from other interfaces in distinct
routing tables. The same network can now be used in any doamin at the same
time without causing conflicts.
This diff is mostly mechanical and adds the necessary rdomain checks accross
net and netinet. L2 and IPv4 are mostly covered still missing pf and IPv6.
input and tested by jsg@, phessler@ and reyk@. "put it in" deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.59 16-Sep-2008 gollo

netstat statistics for pflow(4) via pseudo family

ok cluadio@ henning@


Revision tags: OPENBSD_4_4_BASE
# 1.58 09-May-2008 markus

Add SO_BINDANY socket option from BSD/OS.

The option allows a socket to be bound to addresses which are not
local to the machine. In order to receive packets for these addresses
SO_BINDANY needs to be combined with matching outgoing pf(4) divert
rules, see pf.conf(5).

ok beck@


# 1.57 02-May-2008 ckuethe

Make the SO_TIMESTAMP sockopt work. When set, this allows the user to
get a timestamp of when the datagram was accepted (by udp(4), for
example) rather than having to take a timestamp with gettimeofday(2)
when recv(2) returns - possibly several hundreds of microseconds later.
May be of use to those interested in precision network timing schemes
or QoS for media applications. Tested on alpha, amd64, i386 and sparc64.
manpage suggestions from jmc, ok deraadt


# 1.56 23-Apr-2008 norby

Import MPLS (Multi Protocol Label Switching)

MPLS support partly based on the (abandoned?) AYAME project.
Basic LSR (Label Switch Router) functionality is present, but not fully
functional yet.

It is currently possible to insert entries in the LIB (Label Information Base)
with route(8), but setting the operation type is not supported yet.

Imported to allow more people to work on this in the coming weeks.

ok claudio@ laurent@ dlg@


Revision tags: OPENBSD_4_3_BASE
# 1.55 27-Nov-2007 martynas

typos; ok jmc@
sys/dev/pci/pciide.c from naddy@


# 1.54 24-Sep-2007 henning

updatecomment and manpage toemtion optional seventh level (rtable id)
From: Pierre Riteau <pierre.riteau@free.fr>


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.53 31-Mar-2006 claudio

Add sysctl to retrieve the routing table statisitcs. Will be used by netstat
instead of kvm access. OK henning@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.52 27-May-2005 mcbride

Experimental support for opportunitic use of jumbograms where only some hosts
on the local network support them.

This adds a new socket option, SO_JUMBO, and a new route flag,
RTF_JUMBO. If _both_ the socket option is set and the route for the host
has RTF_JUMBO set, ip_output will fragment the packet to the largest
possible size for the link, ignoring the card's MTU.

The semantics of this feature will be evolving rapidly; talk to us
if you intend to use it.

ok deraadt@ marius@


# 1.51 04-Apr-2005 hshoexer

Add sysctl for dumping the SPD
ok deraadt, ok markus some time ago


# 1.50 22-Mar-2005 henning

fix a typo, don't #define PF_RTIP to something nonmexistant
nothing in our tree uses it (well, would have been spotted then)
netbsd PR kern/29624 via jmc@, agreed on by claudio some time ago


Revision tags: OPENBSD_3_7_BASE
# 1.49 14-Jan-2005 grange

First step in Bluetooth protocol stack support.

The code is adopted from the FreeBSD netgraph-based Bluetooth
implementation by Maksim Yevmenkin <m_evmenkin@yahoo.com> but
all netgraph glue was replaced with usual BSD network stack
hooks. This is a work in progress. Only HCI layer works for now,
L2CAP and RFCOMM are on the way.

Help in testing from many, ok markus@.


# 1.48 26-Nov-2004 markus

add pfkey sysctl subtree; ok deraadt


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.47 24-Feb-2004 tedu

sysctl knob for bpf tunables. some tips from canacar@
ok canacar@ deraadt@ mcbride@


Revision tags: OPENBSD_3_4_BASE
# 1.46 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.45 24-Nov-2002 espie

Explicit unsigned char and unsigned short instead of u_char, u_short.
Make these files usable with -D_POSIX_SOURCE
okay millert@


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.44 10-Sep-2002 deraadt

typo; krapht@secureops.com


Revision tags: OPENBSD_3_1_BASE
# 1.43 15-Mar-2002 itojun

typecast in CMSG_NXTHDR. spotted by hugh@openbsd


# 1.42 14-Mar-2002 millert

First round of __P removal in sys


# 1.41 08-Mar-2002 espie

Make msghdr fields usable from all languages.
ok millert@


# 1.40 10-Jan-2002 itojun

remove duplicated decl of PF_INET6. found by kjc


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.39 07-Sep-2001 itojun

branches: 1.39.4;
just as RFC2292 suggests, validate cmsg_controllen on CMSG_FIRSTHDR.
sync with kame.


# 1.38 26-Jun-2001 dugsong

implement djb's getpeereid(2), to allow local-domain servers to determine client credentials. mostly from superscript.com. deraadt@ ok


# 1.37 22-Jun-2001 deraadt

KNF


# 1.36 28-May-2001 dugsong

add BIOC[GS]HDRCMPLT ioctl for BPF, to disable overwriting of link level source address in forged frames. from NetBSD. art@ok


Revision tags: OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.35 13-Aug-2000 ericj

if COMPAT_OSF1 is defined, define COMPAT_OLDSOCK
and COMPAT_OLDTTY.


# 1.34 02-Jul-2000 fgsch

MSG_COMPAT is needed for COMPAT_BSDOS too.


Revision tags: OPENBSD_2_7_BASE
# 1.33 03-Apr-2000 itojun

hide CMSG_ALIGN from userland, it is not part of RFC2292/Posix.1g.


# 1.32 04-Mar-2000 itojun

to be Posix.1g compliant, fix ancillary message alignment. it will now be
aligned to ALIGNBYTES (arch dependent).
NOTE: the change requires you to recompile IPv6 userland, if you are
on arch that is ALIGNBYTES != sizeof(long) - 1 (sparc seems to be it).
sorry for the mess.


# 1.31 18-Feb-2000 itojun

fix alignment problem in ancillary data (alpha).

only ipv6 tools (which touches ancillary data) are affected.

From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


Revision tags: SMP_BASE kame_19991208
# 1.30 08-Dec-1999 itojun

branches: 1.30.2;
bring in KAME IPv6 code, dated 19991208.
replaces NRL IPv6 layer. reuses NRL pcb layer. no IPsec-on-v6 support.
see sys/netinet6/{TODO,IMPLEMENTATION} for more details.

GENERIC configuration should work fine as before. GENERIC.v6 works fine
as well, but you'll need KAME userland tools to play with IPv6 (will be
bringed into soon).


Revision tags: OPENBSD_2_6_BASE
# 1.29 06-Jun-1999 deraadt

sockaddr_storage; per rfc2553


Revision tags: OPENBSD_2_5_BASE
# 1.28 25-Feb-1999 deraadt

rename sysctl names


# 1.27 25-Feb-1999 deraadt

sockaddr_union cannot be declared here, obviously, or in any other file that i know of


# 1.26 24-Feb-1999 angelos

Changes to socket.h to include union sockaddr_union, temporarily add osdep.h,
until pfkey files are cleaned up.


# 1.25 16-Feb-1999 millert

sendto(2) takes socklen_t for length param


# 1.24 15-Feb-1999 millert

pasto


# 1.23 15-Feb-1999 millert

more uses of socklen_t


# 1.22 15-Feb-1999 millert

Use and document socklen_t


# 1.21 05-Feb-1999 deraadt

support MSG_BCAST and MSG_MCAST


# 1.20 10-Jan-1999 deraadt

add SO_NETPROC and CMSG_{FIRSTHDR,ALIGN,LEN,SPACE}; cmetz


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.19 30-Nov-1997 millert

Move in_addr_t and in_port_t to <sys/types.h> and add sa_family_t
and suseconds_t types for XPG4.2.


# 1.18 16-Nov-1997 deraadt

add SHUT_* values as defined by XPG4.2


Revision tags: OPENBSD_2_2_BASE
# 1.17 14-Jul-1997 angelos

Fix the CTLNET order.


Revision tags: OPENBSD_2_1_BASE
# 1.16 24-Apr-1997 angelos

Added PF_KEY definition.


# 1.15 12-Mar-1997 downsj

Move AF_SIP and put AF_INET6 in the same location as BSD/OS.

I couldn't find any use of AF_SIP in the kernel, didn't check user land.


# 1.14 28-Feb-1997 angelos

Moved everything to netinet/in.h, where they should have been in the
first place.


# 1.13 28-Feb-1997 angelos

Per security-level defaults.


# 1.12 28-Feb-1997 angelos

Can't make up my mind; i think this is final.


# 1.11 28-Feb-1997 angelos

IPsec socket API.


# 1.10 22-Feb-1997 angelos

Preliminaries for IPsec socket API.


# 1.9 20-Feb-1997 deraadt

IPSEC package by John Ioannidis and Angelos D. Keromytis. Written in
Greece. From ftp.funet.fi:/pub/unix/security/net/ip/BSDipsec.tar.gz


# 1.8 12-Dec-1996 mickey

undo last change.


# 1.7 12-Dec-1996 deraadt

wrong place for bindresvport() proto


# 1.6 12-Dec-1996 mickey

struct sockaddr_in; prototype


# 1.5 12-Dec-1996 mickey

int bindresvport __P((int sd, struct sockaddr_in *sin));


Revision tags: OPENBSD_2_0_BASE
# 1.4 03-Jul-1996 chuck

renumber AF_NATM to avoid a conflict with freebsd which put ISDN @ 26.
(i should have checked first)


# 1.3 30-Jun-1996 chuck

add native mode atm socket type


# 1.2 29-Feb-1996 niklas

From NetBSD: Merge with NetBSD 960217


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_6_2_BASE
# 1.95 31-May-2017 markus

new socketoption SO_ZEROIZE: zero out all mbufs sent over socket
ok deraadt bluhm


# 1.94 04-May-2017 bluhm

Introduce sstosa() for converting sockaddr_storage with a type safe
inline function instead of casting it to sockaddr. While there,
use inline instead of __inline for all these conversions. Some
struct sockaddr casts can be avoided completely.
OK dhill@ mpi@


Revision tags: OPENBSD_6_1_BASE
# 1.93 14-Nov-2016 mpi

Automatically create a default lo(4) interface per rdomain.

In order to stop abusing lo0 for all rdomains, a new loopback interface
will be created every time a rdomain is created. The unit number will
be the same as the rdomain, i.e. lo1 will be attached to rdomain 1.

If this loopback interface is already in use it wont be possible to create
the corresponding rdomain.

In order to know which lo(4) interface is attached to a rdomain, its index
is stored in the rtable/rdomain map.

This is a long overdue since the introduction of rtable/rdomain. It also
fixes a recent regression due to resetting the rdomain of an incoming
packet reported by semarie@, Andreas Bartelt and Nils Frohberg.

ok claudio@


# 1.92 28-Sep-2016 jca

Hide RT_TABLEID_MAX behind __BSD_VISIBLE

Alternate define location suggested by deraadt@ and kettenis@, ok kettenis@


# 1.91 12-Sep-2016 guenther

More #include cleanup per POSIX:
- <sys/types.h>: don't pull in <sys/select.h>
- <sys/select.h>: don't pull in <sys/time.h>, but rather declare timeval
and timespec locally
- <sys/time.h>: *do* always pull in <sys/select.h>
- <sys/socket.h>: declare timeval if __BSD_VISIBLE for struct splice

Ports testing and fixed by ajacoutot@
ok deraadt@ millert@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE
# 1.90 23-Oct-2015 claudio

Introduce a new sysctl NET_RT_IFNAMES that returns only ifnames to ifindex
mappings. This will be used by if_nameindex(3), if_nametoindex(3) and
if_indextoname(3) soon to fix the issues in pledge because of inet6 link
local addressing.
OK mpi@ benno@ deraadt@
The libc version will follow soon so better start updating your kernels


# 1.89 20-Oct-2015 deraadt

At guenther's suggestion replace dnssocket() with a SOCK_DNS flag on
socket(). Without pledge, all other socket behaviours become permitted,
except this one case: connect/send* only works to *:53. In pledge mode,
a very few are further restricted. Some backwards compatibility for
the dnssocket/dnsconnect calls will remain in the tree temporarily so
that people can build through the transition.
ok tedu guenther semarie


Revision tags: OPENBSD_5_8_BASE
# 1.88 17-Jul-2015 guenther

In socketpair(), need to mask the type argument when testing for dgram.

based on jeremy@'s diff
ok jeremy@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.87 21-Jan-2015 guenther

Delete option COMPAT_43: support for pre-sa_len binaries has been obsolete
for a couple decades. Keep the OSIOCGIFCONF ioctl to support COMPAT_LINUX
but move the rest of the Linux-specific ioctl() handling into linux_socket.c
This lets struct osockaddr finally move from sys/socket.h to protocols/talkd.h

ok krw@ deraadt@ mpi@


# 1.86 18-Jan-2015 guenther

Per POSIX, <sys/socket.h> needs to expose struct iovec, and may do so
by pulling in <sys/uio.h>, so do so. Remove some stuff that we can trust
<sys/uio.h> to also provide, like cdefs.h, _types.h, and exposing size_t
and ssize_t

pointed out by naddy@
ok deraadt@


# 1.85 31-Aug-2014 guenther

Add sockatmark()

ok millert@ manpage feedback jmc@


# 1.84 31-Aug-2014 guenther

Add additional kernel interfaces for setting close-on-exec on fds
when creating them: pipe2(), dup3(), accept4(), MSG_CMSG_CLOEXEC,
SOCK_CLOEXEC. Includes SOCK_NONBLOCK support.

ok matthew@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.83 02-Apr-2013 guenther

Use internal types instead of the old BSD u_int#_t types in the
standard portion of the header.

Most of the diff from James Turner (james (at) calminferno.net)


Revision tags: OPENBSD_5_3_BASE
# 1.82 15-Sep-2012 guenther

Improve POSIX/SUS compliance of <netdb.h>, <sys/socket.h>, and <sys/un.h>.

Much ports testing of various versions by naddy@ and jasper@
ok matthew@, miller@


Revision tags: OPENBSD_5_2_BASE
# 1.81 11-Apr-2012 deraadt

tedu struct omsghdr


# 1.80 04-Apr-2012 deraadt

SCM_CREDS can go away, since everything uses the newer APIs.
ports tree checked by naddy


# 1.79 17-Mar-2012 dlg

remove IP_JUMBO, SO_JUMBO, and RTF_JUMBO.

no objection from mcbride@ krw@ markus@ deraadt@


Revision tags: OPENBSD_5_1_BASE
# 1.78 03-Dec-2011 fgsch

add support for MSG_NOSIGNAL.
linux bits compiled on i386 by sebastia@, mikeb@ ok


# 1.77 08-Sep-2011 guenther

Provide namespace-safe alignment macros in <machine/_types.h>, with
compat names kept in <machine/param.h>. In <sys/socket.h>, pull
in <sys/_types.h> instead of the namespace polluting <machine/param.h>
and completely eliminate __CMSG_ALIGN, replaced by _ALIGN

ok deraadt@


Revision tags: OPENBSD_5_0_BASE
# 1.76 08-Jul-2011 deraadt

Remove COMPAT_OLDSOCK since no nothing sets MSG_COMPAT anymore.
The song and dance for handling 16-bit af_family on big-endian
machines remains untouched.
ok claudio miod tedu guenther


# 1.75 08-Jul-2011 mikeb

surround splice structure with __BSD_VISIBLE (the right one, noticed by
bluhm, jasper and millert -- an epic fail on my side), style nits from
deraadt, millert, ok guenther, kettenis, millert, ports tests by jasper


# 1.74 08-Jul-2011 yasuoka

this must be included my previous commit.

Include PIPEX in kernel by default. And add new sysctl variable
`net.pipex.enable' to enable PIPEX. By default, pipex is disabled
and it will not process packets from wire. Update man pages and
update HOWTO_PIPEX_NPPPD.txt for testers.

discussed with dlg@, ok deraadt@ mcbride@ claudio@


# 1.73 04-Jul-2011 mikeb

Implement an idle timeout for the socket splicing. A new `sp_idle'
field of the `splice' structure can be used to specify a period of
inactivity after which splicing will be dissolved. ETIMEDOUT error
retrieved with a SO_ERROR indicates the idle timeout expiration.
With comments from and OK bluhm.


# 1.72 05-Apr-2011 guenther

Push COMPAT_FREEBSD in front of a whale. Buggy, out of date, no
one has been weeding it, and it makes life harder.

Toasts of Brennivin for its passing from many; diff ok henning@


Revision tags: OPENBSD_4_9_BASE
# 1.71 07-Jan-2011 bluhm

Add socket option SO_SPLICE to splice together two TCP sockets.
The data received on the source socket will automatically be sent
on the drain socket. This allows to write relay daemons with zero
data copy.
ok markus@


Revision tags: OPENBSD_4_8_BASE
# 1.70 05-Jul-2010 tedu

remove compat_bsdos support


# 1.69 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.68 02-Jul-2010 tedu

remove support for compat_sunos (and m68k4k). ok deraadt guenther


# 1.67 01-Jul-2010 deraadt

Put SO_PEERCRED into the non-flag area
suggested by guenther


# 1.66 30-Jun-2010 tedu

remove compat_osf1 support from the kernel
ok deraadt miod


# 1.65 30-Jun-2010 deraadt

Add getsockopt SOL_SOCKET SO_PEERCRED support. This behaves similar to
getpeereid(2), but also supplies the remote pid. This is supplied in
a 'struct sockpeercred' (unlike Linux -- they showed how little they
know about real unix by calling theirs 'struct ucred').
ok guenther ajacoutot


# 1.64 29-Jun-2010 guenther

Remove COMPAT_HPUX. No one wanted to support it and its fewmets were
blocking other cleanups
ok miod@


# 1.63 21-Apr-2010 claudio

Implement a way to get information about a rtable. Currently only the rtableid
and rdomainid are returned. This is necessary to know where L2 information
of a table is stored (which will be needed soon by bgpd).
Also while there change the errno for non-existing routing tables to ENOENT.
'Fine' deraadt@


Revision tags: OPENBSD_4_7_BASE
# 1.62 27-Nov-2009 guenther

Add setrdomain() and getrdomain() system calls. Committing now to
catch the libc major bump per request from deraadt@

Diff by reyk.

ok guenther@


Revision tags: OPENBSD_4_6_BASE
# 1.61 11-Jun-2009 jsg

tab indent SO_RDOMAIN, like all the other SO_* defines.


# 1.60 05-Jun-2009 claudio

Initial support for routing domains. This allows to bind interfaces to
alternate routing table and separate them from other interfaces in distinct
routing tables. The same network can now be used in any doamin at the same
time without causing conflicts.
This diff is mostly mechanical and adds the necessary rdomain checks accross
net and netinet. L2 and IPv4 are mostly covered still missing pf and IPv6.
input and tested by jsg@, phessler@ and reyk@. "put it in" deraadt@


Revision tags: OPENBSD_4_5_BASE
# 1.59 16-Sep-2008 gollo

netstat statistics for pflow(4) via pseudo family

ok cluadio@ henning@


Revision tags: OPENBSD_4_4_BASE
# 1.58 09-May-2008 markus

Add SO_BINDANY socket option from BSD/OS.

The option allows a socket to be bound to addresses which are not
local to the machine. In order to receive packets for these addresses
SO_BINDANY needs to be combined with matching outgoing pf(4) divert
rules, see pf.conf(5).

ok beck@


# 1.57 02-May-2008 ckuethe

Make the SO_TIMESTAMP sockopt work. When set, this allows the user to
get a timestamp of when the datagram was accepted (by udp(4), for
example) rather than having to take a timestamp with gettimeofday(2)
when recv(2) returns - possibly several hundreds of microseconds later.
May be of use to those interested in precision network timing schemes
or QoS for media applications. Tested on alpha, amd64, i386 and sparc64.
manpage suggestions from jmc, ok deraadt


# 1.56 23-Apr-2008 norby

Import MPLS (Multi Protocol Label Switching)

MPLS support partly based on the (abandoned?) AYAME project.
Basic LSR (Label Switch Router) functionality is present, but not fully
functional yet.

It is currently possible to insert entries in the LIB (Label Information Base)
with route(8), but setting the operation type is not supported yet.

Imported to allow more people to work on this in the coming weeks.

ok claudio@ laurent@ dlg@


Revision tags: OPENBSD_4_3_BASE
# 1.55 27-Nov-2007 martynas

typos; ok jmc@
sys/dev/pci/pciide.c from naddy@


# 1.54 24-Sep-2007 henning

updatecomment and manpage toemtion optional seventh level (rtable id)
From: Pierre Riteau <pierre.riteau@free.fr>


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.53 31-Mar-2006 claudio

Add sysctl to retrieve the routing table statisitcs. Will be used by netstat
instead of kvm access. OK henning@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.52 27-May-2005 mcbride

Experimental support for opportunitic use of jumbograms where only some hosts
on the local network support them.

This adds a new socket option, SO_JUMBO, and a new route flag,
RTF_JUMBO. If _both_ the socket option is set and the route for the host
has RTF_JUMBO set, ip_output will fragment the packet to the largest
possible size for the link, ignoring the card's MTU.

The semantics of this feature will be evolving rapidly; talk to us
if you intend to use it.

ok deraadt@ marius@


# 1.51 04-Apr-2005 hshoexer

Add sysctl for dumping the SPD
ok deraadt, ok markus some time ago


# 1.50 22-Mar-2005 henning

fix a typo, don't #define PF_RTIP to something nonmexistant
nothing in our tree uses it (well, would have been spotted then)
netbsd PR kern/29624 via jmc@, agreed on by claudio some time ago


Revision tags: OPENBSD_3_7_BASE
# 1.49 14-Jan-2005 grange

First step in Bluetooth protocol stack support.

The code is adopted from the FreeBSD netgraph-based Bluetooth
implementation by Maksim Yevmenkin <m_evmenkin@yahoo.com> but
all netgraph glue was replaced with usual BSD network stack
hooks. This is a work in progress. Only HCI layer works for now,
L2CAP and RFCOMM are on the way.

Help in testing from many, ok markus@.


# 1.48 26-Nov-2004 markus

add pfkey sysctl subtree; ok deraadt


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.47 24-Feb-2004 tedu

sysctl knob for bpf tunables. some tips from canacar@
ok canacar@ deraadt@ mcbride@


Revision tags: OPENBSD_3_4_BASE
# 1.46 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.45 24-Nov-2002 espie

Explicit unsigned char and unsigned short instead of u_char, u_short.
Make these files usable with -D_POSIX_SOURCE
okay millert@


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.44 10-Sep-2002 deraadt

typo; krapht@secureops.com


Revision tags: OPENBSD_3_1_BASE
# 1.43 15-Mar-2002 itojun

typecast in CMSG_NXTHDR. spotted by hugh@openbsd


# 1.42 14-Mar-2002 millert

First round of __P removal in sys


# 1.41 08-Mar-2002 espie

Make msghdr fields usable from all languages.
ok millert@


# 1.40 10-Jan-2002 itojun

remove duplicated decl of PF_INET6. found by kjc


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.39 07-Sep-2001 itojun

branches: 1.39.4;
just as RFC2292 suggests, validate cmsg_controllen on CMSG_FIRSTHDR.
sync with kame.


# 1.38 26-Jun-2001 dugsong

implement djb's getpeereid(2), to allow local-domain servers to determine client credentials. mostly from superscript.com. deraadt@ ok


# 1.37 22-Jun-2001 deraadt

KNF


# 1.36 28-May-2001 dugsong

add BIOC[GS]HDRCMPLT ioctl for BPF, to disable overwriting of link level source address in forged frames. from NetBSD. art@ok


Revision tags: OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.35 13-Aug-2000 ericj

if COMPAT_OSF1 is defined, define COMPAT_OLDSOCK
and COMPAT_OLDTTY.


# 1.34 02-Jul-2000 fgsch

MSG_COMPAT is needed for COMPAT_BSDOS too.


Revision tags: OPENBSD_2_7_BASE
# 1.33 03-Apr-2000 itojun

hide CMSG_ALIGN from userland, it is not part of RFC2292/Posix.1g.


# 1.32 04-Mar-2000 itojun

to be Posix.1g compliant, fix ancillary message alignment. it will now be
aligned to ALIGNBYTES (arch dependent).
NOTE: the change requires you to recompile IPv6 userland, if you are
on arch that is ALIGNBYTES != sizeof(long) - 1 (sparc seems to be it).
sorry for the mess.


# 1.31 18-Feb-2000 itojun

fix alignment problem in ancillary data (alpha).

only ipv6 tools (which touches ancillary data) are affected.

From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


Revision tags: SMP_BASE kame_19991208
# 1.30 08-Dec-1999 itojun

branches: 1.30.2;
bring in KAME IPv6 code, dated 19991208.
replaces NRL IPv6 layer. reuses NRL pcb layer. no IPsec-on-v6 support.
see sys/netinet6/{TODO,IMPLEMENTATION} for more details.

GENERIC configuration should work fine as before. GENERIC.v6 works fine
as well, but you'll need KAME userland tools to play with IPv6 (will be
bringed into soon).


Revision tags: OPENBSD_2_6_BASE
# 1.29 06-Jun-1999 deraadt

sockaddr_storage; per rfc2553


Revision tags: OPENBSD_2_5_BASE
# 1.28 25-Feb-1999 deraadt

rename sysctl names


# 1.27 25-Feb-1999 deraadt

sockaddr_union cannot be declared here, obviously, or in any other file that i know of


# 1.26 24-Feb-1999 angelos

Changes to socket.h to include union sockaddr_union, temporarily add osdep.h,
until pfkey files are cleaned up.


# 1.25 16-Feb-1999 millert

sendto(2) takes socklen_t for length param


# 1.24 15-Feb-1999 millert

pasto


# 1.23 15-Feb-1999 millert

more uses of socklen_t


# 1.22 15-Feb-1999 millert

Use and document socklen_t


# 1.21 05-Feb-1999 deraadt

support MSG_BCAST and MSG_MCAST


# 1.20 10-Jan-1999 deraadt

add SO_NETPROC and CMSG_{FIRSTHDR,ALIGN,LEN,SPACE}; cmetz


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE
# 1.19 30-Nov-1997 millert

Move in_addr_t and in_port_t to <sys/types.h> and add sa_family_t
and suseconds_t types for XPG4.2.


# 1.18 16-Nov-1997 deraadt

add SHUT_* values as defined by XPG4.2


Revision tags: OPENBSD_2_2_BASE
# 1.17 14-Jul-1997 angelos

Fix the CTLNET order.


Revision tags: OPENBSD_2_1_BASE
# 1.16 24-Apr-1997 angelos

Added PF_KEY definition.


# 1.15 12-Mar-1997 downsj

Move AF_SIP and put AF_INET6 in the same location as BSD/OS.

I couldn't find any use of AF_SIP in the kernel, didn't check user land.


# 1.14 28-Feb-1997 angelos

Moved everything to netinet/in.h, where they should have been in the
first place.


# 1.13 28-Feb-1997 angelos

Per security-level defaults.


# 1.12 28-Feb-1997 angelos

Can't make up my mind; i think this is final.


# 1.11 28-Feb-1997 angelos

IPsec socket API.


# 1.10 22-Feb-1997 angelos

Preliminaries for IPsec socket API.


# 1.9 20-Feb-1997 deraadt

IPSEC package by John Ioannidis and Angelos D. Keromytis. Written in
Greece. From ftp.funet.fi:/pub/unix/security/net/ip/BSDipsec.tar.gz


# 1.8 12-Dec-1996 mickey

undo last change.


# 1.7 12-Dec-1996 deraadt

wrong place for bindresvport() proto


# 1.6 12-Dec-1996 mickey

struct sockaddr_in; prototype


# 1.5 12-Dec-1996 mickey

int bindresvport __P((int sd, struct sockaddr_in *sin));


Revision tags: OPENBSD_2_0_BASE
# 1.4 03-Jul-1996 chuck

renumber AF_NATM to avoid a conflict with freebsd which put ISDN @ 26.
(i should have checked first)


# 1.3 30-Jun-1996 chuck

add native mode atm socket type


# 1.2 29-Feb-1996 niklas

From NetBSD: Merge with NetBSD 960217


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision