History log of /netbsd-current/sys/sys/socket.h
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.132 22-Jan-2024 christos

PR/57871: Haelwenn Monnier: Don't use u_char because it is not defined in with
POSIX_C_SOURCE


Revision tags: netbsd-10-0-RC3 netbsd-10-0-RC2 thorpej-ifq-base thorpej-altq-separation-base netbsd-10-0-RC1 netbsd-10-base bouyer-sunxi-drm-base
# 1.131 02-Nov-2021 christos

unconditionally define sockaddr_storage; this is what linux and FreeBSD do
and it has been there since Issue 6:
https://pubs.opengroup.org/onlinepubs/009604599/basedefs/sys/socket.h.html


# 1.130 12-Oct-2021 christos

Revert previous change because it causes uninitialized warnings with KMSAN.
The previous code was correct. Add a comment explaining why. Requested by chuq@


Revision tags: netbsd-9-3-RELEASE thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base netbsd-9-1-RELEASE bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.129 04-Nov-2018 christos

- Introduce a new SO_RERROR socket option to explicitly turn on
receive overflow errors re-instating the default behavior to
silently ignore them as before 2018-03-19.
- Introduce a new kern.sooptions sysctl to control the default
behavior of socket options. Setting this to 0x4000 (SO_RERROR),
turns on receive overflow error reporting for all sockets.
- Change dhcpcd to turn on SO_RERROR on all its sockets.

As discussed in tech-net.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930
# 1.128 16-Sep-2018 mrg

clean up a comment left behind from the previous commit.
this now only has sysctl pcb info.


Revision tags: pgoyette-compat-0906
# 1.127 22-Aug-2018 msaitoh

- Cleanup for dynamic sysctl:
- Remove unused *_NAMES macros for sysctl.
- Remove unused *_MAXID for sysctls.
- Move CTL_MACHDEP sysctl definitions for m68k into m68k/include/cpu.h and
use them on all m68k machines.


# 1.126 31-Jul-2018 rjs

Add declaration of getsockopt2().


Revision tags: pgoyette-compat-0728
# 1.125 17-Jul-2018 msaitoh

Add /d(dump) and /v(verbose) modifiers to DDB's "show mbuf" command. Mainly
written by Hiroki SUENAGA. Currently, /v supports Ethernet, PPP, PPPoE, ARP,
IPv4, ICMP, IPv6, ICMPv6, TCP and UDP.


Revision tags: phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422
# 1.124 19-Apr-2018 christos

branches: 1.124.2;
s/static inline/static __inline/g for consistency with other include
headers.


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.123 01-Jul-2017 christos

branches: 1.123.4;
put the code that returns the sizeof the socket by family in one place.


Revision tags: netbsd-8-base
# 1.122 27-May-2017 bouyer

branches: 1.122.2;
merge the bouyer-socketcan branch to HEAD.

CAN stands for Controller Area Network, a broadcast network used
in automation and automotive fields. For example, the NMEA2000 standard
developped for marine devices uses a CAN network as the link layer.

This is an implementation of the linux socketcan API:
https://www.kernel.org/doc/Documentation/networking/can.txt
you can also see can(4).

This adds a new socket family (AF_CAN) and protocol (PF_CAN),
as well as the canconfig(8) utility, used to set timing parameter of
CAN hardware. Also inclued is a driver for the CAN controller
found in the allwinner A20 SoC (I tested it with an Olimex lime2 board,
connected with PIC18-based CAN devices).

There is also the canloop(4) pseudo-device, which allows to use
the socketcan API without CAN hardware.

At this time the CANFD part of the linux socketcan API is not implemented.
Error frames are not implemented either. But I could get the cansend and
canreceive utilities from the canutils package to build and run with minimal
changes. tcpudmp(8) can also be used to record frames, which can be
decoded with etherreal.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.121 08-Feb-2017 maya

Add accept4, a tiny wrapper around paccept.

accept4 is a syscall in Linux, FreeBSD and OpenBSD. It is used in
LLVM, zeromq, and probably others. paccept is a superset of it.

adding it to libc ensures it is used by programs and prevents the
need to define the same wrapper in every program.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.120 21-Sep-2016 roy

branches: 1.120.2;
Add ifam_pid and ifam_addrflags to ifa_msghdr.
Re-version RTM_NEWADDR, RTM_DELADDR, RTM_CHGADDR and NET_RT_IFLIST.
Add compat code for old version.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422
# 1.119 06-Apr-2016 roy

branches: 1.119.2;
Add sc_pid to sockcred so that SOCK_DGRAM and LOCAL_CREDS socket option
can learn the process id of the AF_LOCAL sender.
Add compat glue for old structure.


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.118 13-Oct-2015 rjs

Add core networking support for SCTP.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.117 03-Apr-2015 rtr

* change pr_bind to accept struct sockaddr * instead of struct mbuf *
* update protocol bind implementations to use/expect sockaddr *
instead of mbuf *
* introduce sockaddr_big struct for storage of addr data passed via
sys_bind; sockaddr_big is of sufficient size and alignment to
accommodate all addr data sizes received.
* modify sys_bind to allocate sockaddr_big instead of using an mbuf.
* bump kernel version to 7.99.9 for change to pr_bind() parameter type.

Patch posted to tech-net@
http://mail-index.netbsd.org/tech-net/2015/03/15/msg005004.html

The choice to use a new structure sockaddr_big has been retained since
changing sockaddr_storage size would lead to unnecessary ABI change. The
use of the new structure does not preclude future work that increases
the size of sockaddr_storage and at that time sockaddr_big may be
trivially replaced.

Tested by mrg@ and myself, discussed with rmind@, posted to tech-net@


# 1.116 10-Feb-2015 rjs

Add DCCP protocol support from KAME.


# 1.115 24-Jan-2015 christos

cleanup the CMSG* macro mess.


# 1.114 24-Jan-2015 christos

back to return u_char * according to:
http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/socket.h.html


# 1.113 20-Jan-2015 christos

add void casts to CMSG_


# 1.112 20-Jan-2015 christos

add lint comment


# 1.111 02-Dec-2014 christos

sockaddr_format now returns the number of chars written.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.110 28-May-2014 christos

branches: 1.110.4;
CID 976378: Avoid incorrect computation with ngrps == 0


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.109 17-Apr-2014 christos

CID/1203196: Don't confuse coverity with out of bounds access


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 1.108 31-Jan-2013 joerg

branches: 1.108.2; 1.108.10;
Add sockaddr_format to ease debugging code dealing with socket
addresses.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.107 22-Jun-2012 christos

branches: 1.107.2;
Add {send,recv}mmsg from Linux


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.106 29-Jan-2012 roy

Allow using CMSG_NXTHDR with -Wcast-align.

If various checks are omitted, the CMSG_NXTHDR macro expands to
(struct cmsghdr *)((char *)(cmsg) + \
_ALIGN(((struct cmsghdr *)(cmsg))->cmsg_len))

Although there is no alignment problem (assuming cmsg is properly aligned
and _ALIGN is correct), this violates -Wcast-align on strict-alignment
architectures. Therefore an intermediate cast to void * is appropriate here.

There is no workaround other than not using -Wcast-align.

Taken from FreeBSD commit r220742 by jilles


# 1.105 25-Jan-2012 christos

As discussed in tech-kern, provide the means to prevent delivery of SIGPIPE
on EPIPE for all file descriptor types:

- provide O_NOSIGPIPE for open,kqueue1,pipe2,dup3,fcntl(F_{G,S}ETFL) [NetBSD]
- provide SOCK_NOSIGPIPE for socket,socketpair [NetBSD]
- provide SO_NOSIGPIPE for {g,s}seckopt [NetBSD/FreeBSD/MacOSX]
- provide F_{G,S}ETNOSIGPIPE for fcntl [MacOSX]


# 1.104 20-Jan-2012 joerg

Change CMSG_SPACE and CMSG_LEN to provide Integer Constant Expressions
again. This was changed in sys/socket.h r1.51 to work around fallout
from the IPv6 aux data migration. It broke the historic ABI on some
platforms. This commit restores compatibility for netbsd32 code on such
platforms and provides a template for future changes to the CMSG_*
alignment. Revert PCC/Clang workarounds in postfix and tmux.


# 1.103 20-Jan-2012 joerg

CMSG_ALIGN is only for the kernel.


# 1.102 20-Jan-2012 joerg

Don't use __cmsg_alignbytes in the kernel. Mark it as constant function
for userland as its value never changes. This allows the compiler to
optimise most invocations away.


# 1.101 20-Dec-2011 christos

- Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.
- Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis
- Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets.
- Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all
errors?).


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.100 26-Jun-2011 christos

branches: 1.100.2; 1.100.6;
* Arrange for interfaces that create new file descriptors to be able to
set close-on-exec on creation (http://udrepper.livejournal.com/20407.html).

- Add F_DUPFD_CLOEXEC to fcntl(2).
- Add MSG_CMSG_CLOEXEC to recvmsg(2) for unix file descriptor passing.
- Add dup3(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK.
- Add pipe2(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK.
- Add flags SOCK_CLOEXEC, SOCK_NONBLOCK to the socket type parameter
for socket(2) and socketpair(2).
- Add new paccept(2) syscall that takes an additional sigset_t to alter
the sigmask temporarily and a flags argument to set SOCK_CLOEXEC,
SOCK_NONBLOCK.
- Add new mode character 'e' to fopen(3) and popen(3) to open pipes
and file descriptors for close on exec.
- Add new kqueue1(2) syscall with a new flags argument to open the
kqueue file descriptor with O_CLOEXEC, O_NONBLOCK.

* Fix the system calls that take socklen_t arguments to actually do so.

* Don't include userland header files (signal.h) from system header files
(rump_syscallargs.h).

* Bump libc version for the new syscalls.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base rmind-uvmplock-base
# 1.99 01-Feb-2011 matt

Add a new AF/PF_ROUTE which is 64-bit clean which makes the routing socket
interface (and its associated sysctls) act identically for both 32 and 64 bit
programs. The old unclean one remains for backward compatibility.


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.98 26-Jun-2010 kefren

branches: 1.98.2; 1.98.4;
Add MPLS support, proposed on tech-net@ a couple of days ago

Welcome to 5.99.33


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211
# 1.97 05-Dec-2009 pooka

branches: 1.97.2; 1.97.4;
Remove the portalfs kernel file system driver. Replace mount_portal(8)
with a version based on puffs. User functionality remains the same.


Revision tags: yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.96 11-Sep-2009 dyoung

Make ifconfig(8) set and display preference numbers for IPv6
addresses. Make the kernel support SIOC[SG]IFADDRPREF for IPv6
interface addresses.

In in6ifa_ifpforlinklocal(), consult preference numbers before
making an otherwise arbitrary choice of in6_ifaddr. Otherwise,
preference numbers are *not* consulted by the kernel, but that will
be rather easy for somebody with a little bit of free time to fix.

Please note that setting the preference number for a link-local
IPv6 address does not work right, yet, but that ought to be fixed
soon.

In support of the changes above,

1 Add a method to struct domain for "externalizing" a sockaddr, and
provide an implementation for IPv6. Expect more work in this area: it
may be more proper to say that the IPv6 implementation "internalizes"
a sockaddr. Add sockaddr_externalize().

2 Add a subroutine, sofamily(), that returns a struct socket's address
family or AF_UNSPEC.

3 Make a lot of IPv4-specific code generic, and move it from
sys/netinet/ to sys/net/ for re-use by IPv6 parts of the kernel and
ifconfig(8).


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.95 28-Apr-2009 dyoung

Extract sockaddr_any_by_family() from sockaddr_any() for looking up a
wildcard ("any") address by protocol family instead of by sockaddr.


Revision tags: nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base
# 1.94 19-Jan-2009 christos

branches: 1.94.2;
Provide compatibility to the old timeval SCM_TIMESTAMP messages.


Revision tags: mjf-devfs2-base
# 1.93 14-Jan-2009 christos

version the timeout get/set sockopt calls, because they take struct timeval.


# 1.92 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base christos-time_t-nbase netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base christos-time_t-base
# 1.91 04-Aug-2008 tls

branches: 1.91.2;
Add accept filters, ported from FreeBSD by Coyote Point Systems. Add inetd
support for specifying an accept filter for a service (mostly as a usage
example, but it can be handy for other things). Manual pages to follow
in a day or so.

OK core@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.90 15-Jun-2008 christos

branches: 1.90.2;
define AF_80211


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase jmcneill-base mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base vmlocking-base
# 1.89 19-Sep-2007 dyoung

branches: 1.89.16; 1.89.20; 1.89.22; 1.89.24; 1.89.26; 1.89.28; 1.89.30;
1) Introduce a new socket option, (SOL_SOCKET, SO_NOHEADER), that
tells a socket that it should both add a protocol header to tx'd
datagrams and remove the header from rx'd datagrams:

int onoff = 1, s = socket(...);
setsockopt(s, SOL_SOCKET, SO_NOHEADER, &onoff);

2) Add an implementation of (SOL_SOCKET, SO_NOHEADER) for raw IPv4
sockets.

3) Reorganize the protocols' pr_ctloutput implementations a bit.
Consistently return ENOPROTOOPT when an option is unsupported,
and EINVAL if a supported option's arguments are incorrect.
Reorganize the flow of code so that it's more clear how/when
options are passed down the stack until they are handled.

Shorten some pr_ctloutput staircases for readability.

4) Extract common mbuf code into subroutines, add new sockaddr
methods, and introduce a new subroutine, fsocreate(), for reuse
later; use it first in sys_socket():

struct mbuf *m_getsombuf(struct socket *so)

Create an mbuf and make its owner the socket `so'.

struct mbuf *m_intopt(struct socket *so, int val)

Create an mbuf, make its owner the socket `so', put the
int `val' into it, and set its length to sizeof(int).


int fsocreate(..., int *fd)

Create a socket, a la socreate(9), put the socket into the
given LWP's descriptor table, return the descriptor at `fd'
on success.

void *sockaddr_addr(struct sockaddr *sa, socklen_t *slenp)
const void *sockaddr_const_addr(const struct sockaddr *sa, socklen_t *slenp)

Extract a pointer to the address part of a sockaddr. Write
the length of the address part at `slenp', if `slenp' is
not NULL.

socklen_t sockaddr_getlen(const struct sockaddr *sa)

Return the length of a sockaddr. This just evaluates to
sa->sa_len. I only add this for consistency with code that
appears in a portable userland library that I am going to
import.

const struct sockaddr *sockaddr_any(const struct sockaddr *sa)

Return the "don't care" sockaddr in the same family as
`sa'. This is the address a client should sobind(9) if it
does not care the source address and, if applicable, the
port et cetera that it uses.

const void *sockaddr_anyaddr(const struct sockaddr *sa, socklen_t *slenp)

Return the "don't care" sockaddr in the same family as
`sa'. This is the address a client should sobind(9) if it
does not care the source address and, if applicable, the
port et cetera that it uses.


Revision tags: nick-csl-alignment-base5
# 1.88 30-Aug-2007 dyoung

Use malloc(9) for sockaddrs instead of pool(9), and remove dom_sa_pool
and dom_sa_len members from struct domain. Pools of fixed-size
objects are too rigid for sockaddr_dls, whose size can vary over
a wide range.

Return sockaddr_dl to its "historical" size. Now that I'm using
malloc(9) instead of pool(9) to allocate sockaddr_dl, I can create
a sockaddr_dl of any size in the kernel, so expanding sockaddr_dl
is useless.

Avoid using sizeof(struct sockaddr_dl) in the kernel.

Introduce sockaddr_dl_alloc() for allocating & initializing an
arbitrary sockaddr_dl on the heap.

Add an argument, the sockaddr length, to sockaddr_alloc(),
sockaddr_copy(), and sockaddr_dl_setaddr().

Constify: LLADDR() -> CLLADDR().

Where the kernel overwrites LLADDR(), use sockaddr_dl_setaddr(),
instead. Used properly, sockaddr_dl_setaddr() will not overrun
the end of the sockaddr.


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.87 24-Jun-2007 dsl

branches: 1.87.2; 1.87.6; 1.87.8;
Split sys_getpeername() and sys_getsockname() so they can be called when the
'name' is wanted in kernel code.
Similarly split sys_accept() and change the split in recvmsg() so that it
is useful to the compat functions, recvit() is removed and replaced by
do_sys_recvmsg().
Factor out the code that writes socked names to userspace (from mbuf) to
avoid replicated code.
Extract the code that writes socket 'control' (CMSG) data out to userspace,
being more careful about the 'fd' that may exist inside SCM_RIGHTS msgs.
(they still get lost if some of the latter copyout calls fail).
Since these are new functions, and old LKMs will fail to load.


# 1.86 01-Jun-2007 dsl

Split sys_bind() and sys_connect() so that compat code can use common code
once the 'address' has been copied into an mbuf.
Add extra flags for 'struct msghdr.msg_flags' to indicate that the address
and control are already in mbufs, and that the uio structure is in userspace
for sending data, rename sendit() to do_sys_sendmsg() to ensure no old code
passes in random flags.
Changes to compat code to use new functions - removing some stackgap use.
Fix a 'use after free' in compat_43_sys_recvmsg.
I ***THINK*** the code that converts 'cmsg' formatted data is borked!
svr4_stream.c ought to be generated from svr4_32_stream.c during the build.


Revision tags: yamt-idlelwp-base8
# 1.85 02-May-2007 dyoung

Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.

The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.

Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.

DETAILS

1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:

struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);

sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.

sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.

The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).

2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.

3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:

int rtcache_setdst(struct route *, const struct sockaddr *);

rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.

It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.

4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.


Revision tags: thorpej-atomic-base
# 1.84 04-Mar-2007 christos

branches: 1.84.2; 1.84.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.83 20-Feb-2007 plunky

add comment for PF_BLUETOOTH


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 netbsd-4-base rpaulo-netinet-merge-pcb-base
# 1.82 27-Jun-2006 mrg

branches: 1.82.10;
that should be _STANDALONE, not STANDALONE.


# 1.81 26-Jun-2006 mrg

version the socket(2) syscall. for compat30 socket, we use
EPROTONOSUPPORT instead of EAFNOSUPPORT.

from pavel@ with a little bit of clean up from myself.

XXX: netbsd32 (and perhaps other emulations) should be able
XXX: to call the standard socket calls for this i think, but
XXX: revisit this at another time.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase chap-midi-base
# 1.80 19-Jun-2006 gdamore

Initial import of bluetooth stack on behalf of Iain Hibbert. (plunky@,
NetBSD Foundation Membership still pending.) This stack was written by
Iain under sponsorship from Itronix Inc.

The stack includes support for rfcomm networking (networking via your
bluetooth enabled cell phone), hid devices (keyboards/mice), and headsets.

Drivers for both PCMCIA and USB bluetooth controllers are included.


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.79 11-May-2006 christos

branches: 1.79.2; 1.79.4;
Add MSG_NOSIGNAL (from FreeBSD)


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.78 28-Jan-2006 kleink

branches: 1.78.2; 1.78.4; 1.78.6; 1.78.8; 1.78.10;
Since NULL isn't necessarily available, change CMSG_*() to use the
integer constant expression directly instead.

Fixes a problem in the build of rxvt-unicode-7.2, as reported by
Thomas Klausner.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 29-Nov-2005 christos

branches: 1.77.2;
sprinkle const


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.76 24-Sep-2005 christos

branches: 1.76.6;
It is now ``later''. Follow cgd's 1993 wish and move struct osockaddr
and struct omsghdr to a compat header.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.75 09-Mar-2005 tron

branches: 1.75.2; 1.75.4;
Solve problem invented in revision 1.73 differently:
Use "__uint64_t" etc. instead of pulling in "sys/socket.h" to avoid
namespace pollution. Based on comments made by Klaus Klein on the
current-users mailing list.


# 1.74 09-Mar-2005 tron

Include "sys/types.h" to get definition of "uint64_t". This is necessary
because socket(2) lists only "sys/socket.h" as a requirement. And besides
that it fixes build errors in our "libc".


# 1.73 09-Mar-2005 atatat

Add the following nodes to the sysctl tree:

net.local.stream.pcblist
net.local.dgram.pcblist
net.inet.tcp.pcblist
net.inet.udp.pcblist
net.inet.raw.pcblist
net.inet6.tcp6.pcblist
net.inet6.udp6.pcblist
net.inet6.raw6.pcblist

which allow retrieval of the pcbs in use for those protocols. The
struct involved is 32/64 bit clean and incorporates parts of struct
inpcb, struct unpcb, a bit of struct tcpcb, and two socket addresses.


# 1.72 08-Mar-2005 kleink

Fix a (harmless) typo in the definition of PF_RTIP;
from usa@garbagecollect.jp in PR kern/29624.


# 1.71 26-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.70 03-Feb-2005 perry

de-__P


Revision tags: yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Sep-2004 darrenr

branches: 1.69.4; 1.69.6;
add a per-socket counter for dropped UDP packets when the internal buffers
are full.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.68 07-Aug-2003 agc

branches: 1.68.4;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.67 28-Apr-2003 bjh21

branches: 1.67.2;
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.

This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.

I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.

Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.


# 1.66 19-Apr-2003 christos

PR/2845: Mike Schwartz: Allow some #defines to be tuned by kernel options
by protecting them via #ifndef OPTIONNAME


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base thorpej-mips-cache-base kqueue-base
# 1.65 22-Oct-2001 kleink

Sprinkle some __restrict into <sys/socket.h>.


# 1.64 22-Oct-2001 kleink

Add a sockatmark(3), the 1003.1g wrapper around SIOCATMARK.


# 1.63 16-Oct-2001 kleink

Make this capable of being included without pre-requisite headers.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf
# 1.62 07-Sep-2001 itojun

make CMSG_FIRSTHDR() validat emsg_controllen, as suggested in RFC2292.
from kame


Revision tags: thorpej-devvp-base
# 1.61 17-Jul-2001 jdolecek

branches: 1.61.2;
Expel MSG_COMPAT/COMPAT_OLDSOCK, make the COMPAT_43 wrappers
arrange things as needed. Unfortunately, the check in sockargs()
have to stay, since 4.3BSD bind(2), connect(2) and sendto(2) were
not versioned at the time :(

This code was tested to pass regression tests.


# 1.60 05-May-2001 kleink

branches: 1.60.2;
* Replace a couple of cases of u_char and u_short with uint8_t and uint16_t,
respectively.
* Simplify sockaddr_storage calculations a bit by the fact that, per defintion,
sizeof (char) == 1.
Fixes PR standards/10791.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.59 04-Oct-2000 toshii

branches: 1.59.2;
Wrap __cmsg_alignbytes in __BEGIN_DECLS ... __END_DECLS.


# 1.58 28-Jul-2000 kleink

Avoid recursion with traditional cpp.


# 1.57 05-Jul-2000 christos

delint a macro


# 1.56 26-Jun-2000 kleink

XNS5.2: define sa_family_t and use it where specified by the standard.


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.55 04-Jun-2000 itojun

branches: 1.55.2;
move socklen_t decl to sys/ansi.h.
sys/socket.h pulls in sys/ansi.h and declare socklen_t as necessary.
the change is to allow declaration of socklen_t with less inclusion ordering
constraints. (netdb.h needs this change)


Revision tags: minoura-xpg4dl-base
# 1.54 03-Apr-2000 augustss

branches: 1.54.2;
Change #define CMSG_ALIGN so it's not recursive. Now the kernel compiles
again.


# 1.53 03-Apr-2000 itojun

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


# 1.52 28-Mar-2000 simonb

Remove prototype for pfctlinput() - there's already one in
sys/protosw.h with the other pf*() prototypes.


# 1.51 02-Mar-2000 itojun

make CMSG_ALIGN always synchronize with kernel's idea of ALIGNBYTES.
ancillary data alignment will be ALIGNBYTES, not sizeof(long) - 1, from now.

CMSG_xx will NOT resolve into constant. if you use CMSG_xx to allocate
arrays, you'll lose.

bump shlib minor for libc.

NOTE: if you are on top of arch with ALIGNBYTES != sizeof(long) - 1,
you need to recompile IPv6-related binaries. there is no way to guarantee
backward compat in this aspect. sorry for this. this should be the last
backward compat breakage for IPv6-related ancillary data manipulation.
(we still have PR 9516 for unix-domain sockets...)


# 1.50 18-Feb-2000 itojun

fix alignment problem in ancillary messages (alpha).

the change constitutes binary compatibility issue hen sizeof(long) !=4.
there's no way to be backward compatible, and only guys affected
are IPv6 userland tools.

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


Revision tags: chs-ubc2-newbase
# 1.49 03-Feb-2000 enami

Remove duplicated PF_INET6 definition.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.48 20-Dec-1999 itojun

based on recent discussion on ipngwg, use XNET definition for
sockaddr_storage. next revision of RFC2553 will be using this.

ss_len and ss_family are now available for userland programmers.


# 1.47 19-Nov-1999 bouyer

Update protocoles and interfaces stats counters to 64bit.
RTM_IFINFO is now 0xf, 0xe is RTM_OIFINFO which returns the old (if_msghdr14)
struct with 32bit counters (binary compat, conditioned on COMPAT_14).
Same for sysctl: node 3 is renamed NET_RT_OIFLIST, NET_RT_IFLIST is now node 4.
Change rt_msg1() to add an mbuf to the mbuf chain instead of just panic()
when the message is larger than MHLEN.


Revision tags: comdex-fall-1999-base fvdl-softdep-base chs-ubc2-base
# 1.46 03-Jul-1999 kleink

branches: 1.46.2; 1.46.8;
Modify the previous change to:
* not declare struct sockaddr_storage in pre-XNS5.2 D2.0 environments, and
* not use __{BEGIN,END}_DECLS in a _KERNEL environment, which is not necessary.


# 1.45 01-Jul-1999 itojun

avoid void * arithmetic (msg_control is now void *).


# 1.44 01-Jul-1999 itojun

IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.43 11-Feb-1999 cjs

branches: 1.43.4; 1.43.6;
Fix compiler warning.


# 1.42 10-Feb-1999 kleink

* Define socklen_t, an unsigned integral type used to hold the lengths of
socket options, addresses etc., and use it where specified by XNS5.
* Per XNS5, change data pointers types in struct msghdr from caddr_t to void *;
make msg_iovlen a signed int (apparently for consistency with the iovcnt
argument to readv()/writev()).
* Some name space protection.


# 1.41 18-Dec-1998 drochner

solve the COMPAT_OLDSOCK/MSG_COMPAT problem differently:
The source files which need MSG_COMPAT define COMPAT_OLDSOCK.


# 1.40 13-Dec-1998 christos

add include "opt_compat_43.h" otherwise, if this is our only compat option,
we don't link (reported by Klaus Klein).


Revision tags: kenh-if-detach-base
# 1.39 09-Nov-1998 mrg

compat_ultrix wants MSG_COMPAT/COMPAT_OLDSOCK: don't depend on COMPAT_43


Revision tags: chs-ubc-base
# 1.38 05-Sep-1998 kleink

Protect _XOPEN_SOURCE against sysctl MIB identifiers.


Revision tags: eeh-paddr_t-base
# 1.37 26-Jun-1998 hannken

Back out last change. usr.sbin/pstat/pstat.c is wrong.


# 1.36 26-Jun-1998 hannken

Protect '#include "opt_*"' by '#if defined(_KERNEL)' for userland build.


# 1.35 25-Jun-1998 thorpej

defopt COMPAT_HPUX


# 1.34 25-Jun-1998 thorpej

defopt COMPAT_SUNOS


# 1.33 25-Jun-1998 thorpej

defopt COMPAT_LINUX


# 1.32 25-Jun-1998 thorpej

defopt COMPAT_FREEBSD


# 1.31 30-Apr-1998 thorpej

Define a new pseudo-address family, pseudo_AF_HDRCMPLT, which is used by
BPF to tell interface output routines to not fill in the layer 2 source
address. From Greg Smith <greg@nas.nasa.gov>.


# 1.30 25-Apr-1998 matt

Add MSG_MCAST and MSG_BCAST so recvmsg can return how the message was received.


# 1.29 25-Apr-1998 kleink

Per X/Open CAE Spec, Issue 5, define 3 preprocessor symbols to be used to
specify the type of socket shutdown(2).


# 1.28 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.27 07-Jan-1998 thorpej

Add the sockcred structure and related definitions, and the SCM_CREDS
control message type.


Revision tags: netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.26 05-May-1997 thorpej

branches: 1.26.8;
Ok, _really_ back out the sockaddr alignment change this time. We can't
reasonably "fix" the compiler "bug" that causes the forced alignment
to fail on certain platforms (e.g. m68k), so we _have_ to solve this
problem a different way.


# 1.25 02-May-1997 thorpej

Align a sockaddr to 4 bytes, not sizeof(long)


# 1.24 02-May-1997 thorpej

Revert the reverting of the last change. Turns out the trouble
on the m68k was a compiler bug (thanks Charles and Christos!)


# 1.23 02-May-1997 thorpej

Revert previous alignment-related change. It caused unexpected problems
on at least one architecture. The alignment issue on the alpha will
be solved in a different way.


# 1.22 02-May-1997 thorpej

Deal with an alignment problem on the Alpha port. The maximum required
alignment of any field in a struct sockaddr is 1, since all members are
chars or char arrays (as noted by Ross Harvey on port-alpha). This causes
the possibility of unaligned access faults when a sockaddr is cast to
e.g. a sockaddr_in. Solution: explicitly direct the compiler to
longword-align the start of a struct sockaddr.


# 1.21 18-Mar-1997 sommerfe

Reserve a place for PF_KEY; rename SIP to INET6


# 1.20 15-Mar-1997 is

Synchronize the CTL_NET_NAMES with the AF_* definitions (ISDN and ARP where
missing).


Revision tags: is-newarp-before-merge is-newarp-base
# 1.19 11-Feb-1997 is

branches: 1.19.4;
Allocate and define AF_ARP and PF_ARP. These will be used to
a) communicate the hardware independent part of ARP packets (rfc826) from/to
if_*subr.c in the ongoing effort to rewrite the ARP subsystem for non-Ethernet
networks
b) communicate the hardware independent part of RARP packets (rfc903) from/to
userland sockets to avoid putting link level header format knowledge into
rarpd, when it is enhanced to support non-Ethernet networks.


# 1.18 11-Jan-1997 thorpej

Implement SO_TIMESTAMP socket option: receive a timeval timestamp
as a control message with a datagram.


# 1.17 04-Jul-1996 chuck

add native mode atm protocol info, also ensure AF number remain sync'd
with freebsd.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-May-1996 neil

Remove #ifdefs

Thanks to cgd@NetBSD.ORG for pointing the following out to me:

listen (fd, SOMAXCONN); would break.

As programs wouldn't see the changes that might be specified in
the kernel config file.

As penance I am going to see if it would be possible to move this
into param.h and provide away of finding out what the kernel
value is. On busy network servers this value is useful to have as a tunable
kernel parameter.


# 1.15 02-May-1996 neil

Add ability to do options SOMAXCONN=n which is useful on
busy network servers.


# 1.14 09-Feb-1996 christos

Filesystem prototype changes


# 1.13 09-Feb-1996 mycroft

Increase SOMAXCONN.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.12 29-Mar-1995 briggs

KERNEL -> _KERNEL


# 1.11 26-Mar-1995 jtc

KERNEL -> _KERNEL


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 13-May-1994 mycroft

Update to 4.4-Lite networking code, with a few local changes.


# 1.7 04-May-1994 mycroft

Move internal prototypes to a better place.


# 1.6 04-May-1994 mycroft

Prototype lots of kernel-internal functions.


Revision tags: nvm-base wnvm magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.5 27-Jun-1993 andrew

branches: 1.5.4;
ANSIfications - lots of function prototyping.


# 1.4 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.3 19-Apr-1993 mycroft

Fix typo.


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.131 02-Nov-2021 christos

unconditionally define sockaddr_storage; this is what linux and FreeBSD do
and it has been there since Issue 6:
https://pubs.opengroup.org/onlinepubs/009604599/basedefs/sys/socket.h.html


# 1.130 12-Oct-2021 christos

Revert previous change because it causes uninitialized warnings with KMSAN.
The previous code was correct. Add a comment explaining why. Requested by chuq@


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base netbsd-9-1-RELEASE bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.129 04-Nov-2018 christos

- Introduce a new SO_RERROR socket option to explicitly turn on
receive overflow errors re-instating the default behavior to
silently ignore them as before 2018-03-19.
- Introduce a new kern.sooptions sysctl to control the default
behavior of socket options. Setting this to 0x4000 (SO_RERROR),
turns on receive overflow error reporting for all sockets.
- Change dhcpcd to turn on SO_RERROR on all its sockets.

As discussed in tech-net.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930
# 1.128 16-Sep-2018 mrg

clean up a comment left behind from the previous commit.
this now only has sysctl pcb info.


Revision tags: pgoyette-compat-0906
# 1.127 22-Aug-2018 msaitoh

- Cleanup for dynamic sysctl:
- Remove unused *_NAMES macros for sysctl.
- Remove unused *_MAXID for sysctls.
- Move CTL_MACHDEP sysctl definitions for m68k into m68k/include/cpu.h and
use them on all m68k machines.


# 1.126 31-Jul-2018 rjs

Add declaration of getsockopt2().


Revision tags: pgoyette-compat-0728
# 1.125 17-Jul-2018 msaitoh

Add /d(dump) and /v(verbose) modifiers to DDB's "show mbuf" command. Mainly
written by Hiroki SUENAGA. Currently, /v supports Ethernet, PPP, PPPoE, ARP,
IPv4, ICMP, IPv6, ICMPv6, TCP and UDP.


Revision tags: phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422
# 1.124 19-Apr-2018 christos

branches: 1.124.2;
s/static inline/static __inline/g for consistency with other include
headers.


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.123 01-Jul-2017 christos

branches: 1.123.4;
put the code that returns the sizeof the socket by family in one place.


Revision tags: netbsd-8-base
# 1.122 27-May-2017 bouyer

branches: 1.122.2;
merge the bouyer-socketcan branch to HEAD.

CAN stands for Controller Area Network, a broadcast network used
in automation and automotive fields. For example, the NMEA2000 standard
developped for marine devices uses a CAN network as the link layer.

This is an implementation of the linux socketcan API:
https://www.kernel.org/doc/Documentation/networking/can.txt
you can also see can(4).

This adds a new socket family (AF_CAN) and protocol (PF_CAN),
as well as the canconfig(8) utility, used to set timing parameter of
CAN hardware. Also inclued is a driver for the CAN controller
found in the allwinner A20 SoC (I tested it with an Olimex lime2 board,
connected with PIC18-based CAN devices).

There is also the canloop(4) pseudo-device, which allows to use
the socketcan API without CAN hardware.

At this time the CANFD part of the linux socketcan API is not implemented.
Error frames are not implemented either. But I could get the cansend and
canreceive utilities from the canutils package to build and run with minimal
changes. tcpudmp(8) can also be used to record frames, which can be
decoded with etherreal.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.121 08-Feb-2017 maya

Add accept4, a tiny wrapper around paccept.

accept4 is a syscall in Linux, FreeBSD and OpenBSD. It is used in
LLVM, zeromq, and probably others. paccept is a superset of it.

adding it to libc ensures it is used by programs and prevents the
need to define the same wrapper in every program.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.120 21-Sep-2016 roy

branches: 1.120.2;
Add ifam_pid and ifam_addrflags to ifa_msghdr.
Re-version RTM_NEWADDR, RTM_DELADDR, RTM_CHGADDR and NET_RT_IFLIST.
Add compat code for old version.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422
# 1.119 06-Apr-2016 roy

branches: 1.119.2;
Add sc_pid to sockcred so that SOCK_DGRAM and LOCAL_CREDS socket option
can learn the process id of the AF_LOCAL sender.
Add compat glue for old structure.


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.118 13-Oct-2015 rjs

Add core networking support for SCTP.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.117 03-Apr-2015 rtr

* change pr_bind to accept struct sockaddr * instead of struct mbuf *
* update protocol bind implementations to use/expect sockaddr *
instead of mbuf *
* introduce sockaddr_big struct for storage of addr data passed via
sys_bind; sockaddr_big is of sufficient size and alignment to
accommodate all addr data sizes received.
* modify sys_bind to allocate sockaddr_big instead of using an mbuf.
* bump kernel version to 7.99.9 for change to pr_bind() parameter type.

Patch posted to tech-net@
http://mail-index.netbsd.org/tech-net/2015/03/15/msg005004.html

The choice to use a new structure sockaddr_big has been retained since
changing sockaddr_storage size would lead to unnecessary ABI change. The
use of the new structure does not preclude future work that increases
the size of sockaddr_storage and at that time sockaddr_big may be
trivially replaced.

Tested by mrg@ and myself, discussed with rmind@, posted to tech-net@


# 1.116 10-Feb-2015 rjs

Add DCCP protocol support from KAME.


# 1.115 24-Jan-2015 christos

cleanup the CMSG* macro mess.


# 1.114 24-Jan-2015 christos

back to return u_char * according to:
http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/socket.h.html


# 1.113 20-Jan-2015 christos

add void casts to CMSG_


# 1.112 20-Jan-2015 christos

add lint comment


# 1.111 02-Dec-2014 christos

sockaddr_format now returns the number of chars written.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.110 28-May-2014 christos

branches: 1.110.4;
CID 976378: Avoid incorrect computation with ngrps == 0


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.109 17-Apr-2014 christos

CID/1203196: Don't confuse coverity with out of bounds access


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 1.108 31-Jan-2013 joerg

branches: 1.108.2; 1.108.10;
Add sockaddr_format to ease debugging code dealing with socket
addresses.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.107 22-Jun-2012 christos

branches: 1.107.2;
Add {send,recv}mmsg from Linux


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.106 29-Jan-2012 roy

Allow using CMSG_NXTHDR with -Wcast-align.

If various checks are omitted, the CMSG_NXTHDR macro expands to
(struct cmsghdr *)((char *)(cmsg) + \
_ALIGN(((struct cmsghdr *)(cmsg))->cmsg_len))

Although there is no alignment problem (assuming cmsg is properly aligned
and _ALIGN is correct), this violates -Wcast-align on strict-alignment
architectures. Therefore an intermediate cast to void * is appropriate here.

There is no workaround other than not using -Wcast-align.

Taken from FreeBSD commit r220742 by jilles


# 1.105 25-Jan-2012 christos

As discussed in tech-kern, provide the means to prevent delivery of SIGPIPE
on EPIPE for all file descriptor types:

- provide O_NOSIGPIPE for open,kqueue1,pipe2,dup3,fcntl(F_{G,S}ETFL) [NetBSD]
- provide SOCK_NOSIGPIPE for socket,socketpair [NetBSD]
- provide SO_NOSIGPIPE for {g,s}seckopt [NetBSD/FreeBSD/MacOSX]
- provide F_{G,S}ETNOSIGPIPE for fcntl [MacOSX]


# 1.104 20-Jan-2012 joerg

Change CMSG_SPACE and CMSG_LEN to provide Integer Constant Expressions
again. This was changed in sys/socket.h r1.51 to work around fallout
from the IPv6 aux data migration. It broke the historic ABI on some
platforms. This commit restores compatibility for netbsd32 code on such
platforms and provides a template for future changes to the CMSG_*
alignment. Revert PCC/Clang workarounds in postfix and tmux.


# 1.103 20-Jan-2012 joerg

CMSG_ALIGN is only for the kernel.


# 1.102 20-Jan-2012 joerg

Don't use __cmsg_alignbytes in the kernel. Mark it as constant function
for userland as its value never changes. This allows the compiler to
optimise most invocations away.


# 1.101 20-Dec-2011 christos

- Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.
- Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis
- Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets.
- Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all
errors?).


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.100 26-Jun-2011 christos

branches: 1.100.2; 1.100.6;
* Arrange for interfaces that create new file descriptors to be able to
set close-on-exec on creation (http://udrepper.livejournal.com/20407.html).

- Add F_DUPFD_CLOEXEC to fcntl(2).
- Add MSG_CMSG_CLOEXEC to recvmsg(2) for unix file descriptor passing.
- Add dup3(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK.
- Add pipe2(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK.
- Add flags SOCK_CLOEXEC, SOCK_NONBLOCK to the socket type parameter
for socket(2) and socketpair(2).
- Add new paccept(2) syscall that takes an additional sigset_t to alter
the sigmask temporarily and a flags argument to set SOCK_CLOEXEC,
SOCK_NONBLOCK.
- Add new mode character 'e' to fopen(3) and popen(3) to open pipes
and file descriptors for close on exec.
- Add new kqueue1(2) syscall with a new flags argument to open the
kqueue file descriptor with O_CLOEXEC, O_NONBLOCK.

* Fix the system calls that take socklen_t arguments to actually do so.

* Don't include userland header files (signal.h) from system header files
(rump_syscallargs.h).

* Bump libc version for the new syscalls.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base rmind-uvmplock-base
# 1.99 01-Feb-2011 matt

Add a new AF/PF_ROUTE which is 64-bit clean which makes the routing socket
interface (and its associated sysctls) act identically for both 32 and 64 bit
programs. The old unclean one remains for backward compatibility.


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.98 26-Jun-2010 kefren

branches: 1.98.2; 1.98.4;
Add MPLS support, proposed on tech-net@ a couple of days ago

Welcome to 5.99.33


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211
# 1.97 05-Dec-2009 pooka

branches: 1.97.2; 1.97.4;
Remove the portalfs kernel file system driver. Replace mount_portal(8)
with a version based on puffs. User functionality remains the same.


Revision tags: yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.96 11-Sep-2009 dyoung

Make ifconfig(8) set and display preference numbers for IPv6
addresses. Make the kernel support SIOC[SG]IFADDRPREF for IPv6
interface addresses.

In in6ifa_ifpforlinklocal(), consult preference numbers before
making an otherwise arbitrary choice of in6_ifaddr. Otherwise,
preference numbers are *not* consulted by the kernel, but that will
be rather easy for somebody with a little bit of free time to fix.

Please note that setting the preference number for a link-local
IPv6 address does not work right, yet, but that ought to be fixed
soon.

In support of the changes above,

1 Add a method to struct domain for "externalizing" a sockaddr, and
provide an implementation for IPv6. Expect more work in this area: it
may be more proper to say that the IPv6 implementation "internalizes"
a sockaddr. Add sockaddr_externalize().

2 Add a subroutine, sofamily(), that returns a struct socket's address
family or AF_UNSPEC.

3 Make a lot of IPv4-specific code generic, and move it from
sys/netinet/ to sys/net/ for re-use by IPv6 parts of the kernel and
ifconfig(8).


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.95 28-Apr-2009 dyoung

Extract sockaddr_any_by_family() from sockaddr_any() for looking up a
wildcard ("any") address by protocol family instead of by sockaddr.


Revision tags: nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base
# 1.94 19-Jan-2009 christos

branches: 1.94.2;
Provide compatibility to the old timeval SCM_TIMESTAMP messages.


Revision tags: mjf-devfs2-base
# 1.93 14-Jan-2009 christos

version the timeout get/set sockopt calls, because they take struct timeval.


# 1.92 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base christos-time_t-nbase netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base christos-time_t-base
# 1.91 04-Aug-2008 tls

branches: 1.91.2;
Add accept filters, ported from FreeBSD by Coyote Point Systems. Add inetd
support for specifying an accept filter for a service (mostly as a usage
example, but it can be handy for other things). Manual pages to follow
in a day or so.

OK core@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.90 15-Jun-2008 christos

branches: 1.90.2;
define AF_80211


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase jmcneill-base mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base vmlocking-base
# 1.89 19-Sep-2007 dyoung

branches: 1.89.16; 1.89.20; 1.89.22; 1.89.24; 1.89.26; 1.89.28; 1.89.30;
1) Introduce a new socket option, (SOL_SOCKET, SO_NOHEADER), that
tells a socket that it should both add a protocol header to tx'd
datagrams and remove the header from rx'd datagrams:

int onoff = 1, s = socket(...);
setsockopt(s, SOL_SOCKET, SO_NOHEADER, &onoff);

2) Add an implementation of (SOL_SOCKET, SO_NOHEADER) for raw IPv4
sockets.

3) Reorganize the protocols' pr_ctloutput implementations a bit.
Consistently return ENOPROTOOPT when an option is unsupported,
and EINVAL if a supported option's arguments are incorrect.
Reorganize the flow of code so that it's more clear how/when
options are passed down the stack until they are handled.

Shorten some pr_ctloutput staircases for readability.

4) Extract common mbuf code into subroutines, add new sockaddr
methods, and introduce a new subroutine, fsocreate(), for reuse
later; use it first in sys_socket():

struct mbuf *m_getsombuf(struct socket *so)

Create an mbuf and make its owner the socket `so'.

struct mbuf *m_intopt(struct socket *so, int val)

Create an mbuf, make its owner the socket `so', put the
int `val' into it, and set its length to sizeof(int).


int fsocreate(..., int *fd)

Create a socket, a la socreate(9), put the socket into the
given LWP's descriptor table, return the descriptor at `fd'
on success.

void *sockaddr_addr(struct sockaddr *sa, socklen_t *slenp)
const void *sockaddr_const_addr(const struct sockaddr *sa, socklen_t *slenp)

Extract a pointer to the address part of a sockaddr. Write
the length of the address part at `slenp', if `slenp' is
not NULL.

socklen_t sockaddr_getlen(const struct sockaddr *sa)

Return the length of a sockaddr. This just evaluates to
sa->sa_len. I only add this for consistency with code that
appears in a portable userland library that I am going to
import.

const struct sockaddr *sockaddr_any(const struct sockaddr *sa)

Return the "don't care" sockaddr in the same family as
`sa'. This is the address a client should sobind(9) if it
does not care the source address and, if applicable, the
port et cetera that it uses.

const void *sockaddr_anyaddr(const struct sockaddr *sa, socklen_t *slenp)

Return the "don't care" sockaddr in the same family as
`sa'. This is the address a client should sobind(9) if it
does not care the source address and, if applicable, the
port et cetera that it uses.


Revision tags: nick-csl-alignment-base5
# 1.88 30-Aug-2007 dyoung

Use malloc(9) for sockaddrs instead of pool(9), and remove dom_sa_pool
and dom_sa_len members from struct domain. Pools of fixed-size
objects are too rigid for sockaddr_dls, whose size can vary over
a wide range.

Return sockaddr_dl to its "historical" size. Now that I'm using
malloc(9) instead of pool(9) to allocate sockaddr_dl, I can create
a sockaddr_dl of any size in the kernel, so expanding sockaddr_dl
is useless.

Avoid using sizeof(struct sockaddr_dl) in the kernel.

Introduce sockaddr_dl_alloc() for allocating & initializing an
arbitrary sockaddr_dl on the heap.

Add an argument, the sockaddr length, to sockaddr_alloc(),
sockaddr_copy(), and sockaddr_dl_setaddr().

Constify: LLADDR() -> CLLADDR().

Where the kernel overwrites LLADDR(), use sockaddr_dl_setaddr(),
instead. Used properly, sockaddr_dl_setaddr() will not overrun
the end of the sockaddr.


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.87 24-Jun-2007 dsl

branches: 1.87.2; 1.87.6; 1.87.8;
Split sys_getpeername() and sys_getsockname() so they can be called when the
'name' is wanted in kernel code.
Similarly split sys_accept() and change the split in recvmsg() so that it
is useful to the compat functions, recvit() is removed and replaced by
do_sys_recvmsg().
Factor out the code that writes socked names to userspace (from mbuf) to
avoid replicated code.
Extract the code that writes socket 'control' (CMSG) data out to userspace,
being more careful about the 'fd' that may exist inside SCM_RIGHTS msgs.
(they still get lost if some of the latter copyout calls fail).
Since these are new functions, and old LKMs will fail to load.


# 1.86 01-Jun-2007 dsl

Split sys_bind() and sys_connect() so that compat code can use common code
once the 'address' has been copied into an mbuf.
Add extra flags for 'struct msghdr.msg_flags' to indicate that the address
and control are already in mbufs, and that the uio structure is in userspace
for sending data, rename sendit() to do_sys_sendmsg() to ensure no old code
passes in random flags.
Changes to compat code to use new functions - removing some stackgap use.
Fix a 'use after free' in compat_43_sys_recvmsg.
I ***THINK*** the code that converts 'cmsg' formatted data is borked!
svr4_stream.c ought to be generated from svr4_32_stream.c during the build.


Revision tags: yamt-idlelwp-base8
# 1.85 02-May-2007 dyoung

Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.

The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.

Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.

DETAILS

1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:

struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);

sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.

sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.

The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).

2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.

3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:

int rtcache_setdst(struct route *, const struct sockaddr *);

rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.

It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.

4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.


Revision tags: thorpej-atomic-base
# 1.84 04-Mar-2007 christos

branches: 1.84.2; 1.84.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.83 20-Feb-2007 plunky

add comment for PF_BLUETOOTH


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 netbsd-4-base rpaulo-netinet-merge-pcb-base
# 1.82 27-Jun-2006 mrg

branches: 1.82.10;
that should be _STANDALONE, not STANDALONE.


# 1.81 26-Jun-2006 mrg

version the socket(2) syscall. for compat30 socket, we use
EPROTONOSUPPORT instead of EAFNOSUPPORT.

from pavel@ with a little bit of clean up from myself.

XXX: netbsd32 (and perhaps other emulations) should be able
XXX: to call the standard socket calls for this i think, but
XXX: revisit this at another time.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase chap-midi-base
# 1.80 19-Jun-2006 gdamore

Initial import of bluetooth stack on behalf of Iain Hibbert. (plunky@,
NetBSD Foundation Membership still pending.) This stack was written by
Iain under sponsorship from Itronix Inc.

The stack includes support for rfcomm networking (networking via your
bluetooth enabled cell phone), hid devices (keyboards/mice), and headsets.

Drivers for both PCMCIA and USB bluetooth controllers are included.


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.79 11-May-2006 christos

branches: 1.79.2; 1.79.4;
Add MSG_NOSIGNAL (from FreeBSD)


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.78 28-Jan-2006 kleink

branches: 1.78.2; 1.78.4; 1.78.6; 1.78.8; 1.78.10;
Since NULL isn't necessarily available, change CMSG_*() to use the
integer constant expression directly instead.

Fixes a problem in the build of rxvt-unicode-7.2, as reported by
Thomas Klausner.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 29-Nov-2005 christos

branches: 1.77.2;
sprinkle const


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.76 24-Sep-2005 christos

branches: 1.76.6;
It is now ``later''. Follow cgd's 1993 wish and move struct osockaddr
and struct omsghdr to a compat header.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.75 09-Mar-2005 tron

branches: 1.75.2; 1.75.4;
Solve problem invented in revision 1.73 differently:
Use "__uint64_t" etc. instead of pulling in "sys/socket.h" to avoid
namespace pollution. Based on comments made by Klaus Klein on the
current-users mailing list.


# 1.74 09-Mar-2005 tron

Include "sys/types.h" to get definition of "uint64_t". This is necessary
because socket(2) lists only "sys/socket.h" as a requirement. And besides
that it fixes build errors in our "libc".


# 1.73 09-Mar-2005 atatat

Add the following nodes to the sysctl tree:

net.local.stream.pcblist
net.local.dgram.pcblist
net.inet.tcp.pcblist
net.inet.udp.pcblist
net.inet.raw.pcblist
net.inet6.tcp6.pcblist
net.inet6.udp6.pcblist
net.inet6.raw6.pcblist

which allow retrieval of the pcbs in use for those protocols. The
struct involved is 32/64 bit clean and incorporates parts of struct
inpcb, struct unpcb, a bit of struct tcpcb, and two socket addresses.


# 1.72 08-Mar-2005 kleink

Fix a (harmless) typo in the definition of PF_RTIP;
from usa@garbagecollect.jp in PR kern/29624.


# 1.71 26-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.70 03-Feb-2005 perry

de-__P


Revision tags: yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Sep-2004 darrenr

branches: 1.69.4; 1.69.6;
add a per-socket counter for dropped UDP packets when the internal buffers
are full.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.68 07-Aug-2003 agc

branches: 1.68.4;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.67 28-Apr-2003 bjh21

branches: 1.67.2;
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.

This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.

I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.

Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.


# 1.66 19-Apr-2003 christos

PR/2845: Mike Schwartz: Allow some #defines to be tuned by kernel options
by protecting them via #ifndef OPTIONNAME


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base thorpej-mips-cache-base kqueue-base
# 1.65 22-Oct-2001 kleink

Sprinkle some __restrict into <sys/socket.h>.


# 1.64 22-Oct-2001 kleink

Add a sockatmark(3), the 1003.1g wrapper around SIOCATMARK.


# 1.63 16-Oct-2001 kleink

Make this capable of being included without pre-requisite headers.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf
# 1.62 07-Sep-2001 itojun

make CMSG_FIRSTHDR() validat emsg_controllen, as suggested in RFC2292.
from kame


Revision tags: thorpej-devvp-base
# 1.61 17-Jul-2001 jdolecek

branches: 1.61.2;
Expel MSG_COMPAT/COMPAT_OLDSOCK, make the COMPAT_43 wrappers
arrange things as needed. Unfortunately, the check in sockargs()
have to stay, since 4.3BSD bind(2), connect(2) and sendto(2) were
not versioned at the time :(

This code was tested to pass regression tests.


# 1.60 05-May-2001 kleink

branches: 1.60.2;
* Replace a couple of cases of u_char and u_short with uint8_t and uint16_t,
respectively.
* Simplify sockaddr_storage calculations a bit by the fact that, per defintion,
sizeof (char) == 1.
Fixes PR standards/10791.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.59 04-Oct-2000 toshii

branches: 1.59.2;
Wrap __cmsg_alignbytes in __BEGIN_DECLS ... __END_DECLS.


# 1.58 28-Jul-2000 kleink

Avoid recursion with traditional cpp.


# 1.57 05-Jul-2000 christos

delint a macro


# 1.56 26-Jun-2000 kleink

XNS5.2: define sa_family_t and use it where specified by the standard.


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.55 04-Jun-2000 itojun

branches: 1.55.2;
move socklen_t decl to sys/ansi.h.
sys/socket.h pulls in sys/ansi.h and declare socklen_t as necessary.
the change is to allow declaration of socklen_t with less inclusion ordering
constraints. (netdb.h needs this change)


Revision tags: minoura-xpg4dl-base
# 1.54 03-Apr-2000 augustss

branches: 1.54.2;
Change #define CMSG_ALIGN so it's not recursive. Now the kernel compiles
again.


# 1.53 03-Apr-2000 itojun

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


# 1.52 28-Mar-2000 simonb

Remove prototype for pfctlinput() - there's already one in
sys/protosw.h with the other pf*() prototypes.


# 1.51 02-Mar-2000 itojun

make CMSG_ALIGN always synchronize with kernel's idea of ALIGNBYTES.
ancillary data alignment will be ALIGNBYTES, not sizeof(long) - 1, from now.

CMSG_xx will NOT resolve into constant. if you use CMSG_xx to allocate
arrays, you'll lose.

bump shlib minor for libc.

NOTE: if you are on top of arch with ALIGNBYTES != sizeof(long) - 1,
you need to recompile IPv6-related binaries. there is no way to guarantee
backward compat in this aspect. sorry for this. this should be the last
backward compat breakage for IPv6-related ancillary data manipulation.
(we still have PR 9516 for unix-domain sockets...)


# 1.50 18-Feb-2000 itojun

fix alignment problem in ancillary messages (alpha).

the change constitutes binary compatibility issue hen sizeof(long) !=4.
there's no way to be backward compatible, and only guys affected
are IPv6 userland tools.

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


Revision tags: chs-ubc2-newbase
# 1.49 03-Feb-2000 enami

Remove duplicated PF_INET6 definition.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.48 20-Dec-1999 itojun

based on recent discussion on ipngwg, use XNET definition for
sockaddr_storage. next revision of RFC2553 will be using this.

ss_len and ss_family are now available for userland programmers.


# 1.47 19-Nov-1999 bouyer

Update protocoles and interfaces stats counters to 64bit.
RTM_IFINFO is now 0xf, 0xe is RTM_OIFINFO which returns the old (if_msghdr14)
struct with 32bit counters (binary compat, conditioned on COMPAT_14).
Same for sysctl: node 3 is renamed NET_RT_OIFLIST, NET_RT_IFLIST is now node 4.
Change rt_msg1() to add an mbuf to the mbuf chain instead of just panic()
when the message is larger than MHLEN.


Revision tags: comdex-fall-1999-base fvdl-softdep-base chs-ubc2-base
# 1.46 03-Jul-1999 kleink

branches: 1.46.2; 1.46.8;
Modify the previous change to:
* not declare struct sockaddr_storage in pre-XNS5.2 D2.0 environments, and
* not use __{BEGIN,END}_DECLS in a _KERNEL environment, which is not necessary.


# 1.45 01-Jul-1999 itojun

avoid void * arithmetic (msg_control is now void *).


# 1.44 01-Jul-1999 itojun

IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.43 11-Feb-1999 cjs

branches: 1.43.4; 1.43.6;
Fix compiler warning.


# 1.42 10-Feb-1999 kleink

* Define socklen_t, an unsigned integral type used to hold the lengths of
socket options, addresses etc., and use it where specified by XNS5.
* Per XNS5, change data pointers types in struct msghdr from caddr_t to void *;
make msg_iovlen a signed int (apparently for consistency with the iovcnt
argument to readv()/writev()).
* Some name space protection.


# 1.41 18-Dec-1998 drochner

solve the COMPAT_OLDSOCK/MSG_COMPAT problem differently:
The source files which need MSG_COMPAT define COMPAT_OLDSOCK.


# 1.40 13-Dec-1998 christos

add include "opt_compat_43.h" otherwise, if this is our only compat option,
we don't link (reported by Klaus Klein).


Revision tags: kenh-if-detach-base
# 1.39 09-Nov-1998 mrg

compat_ultrix wants MSG_COMPAT/COMPAT_OLDSOCK: don't depend on COMPAT_43


Revision tags: chs-ubc-base
# 1.38 05-Sep-1998 kleink

Protect _XOPEN_SOURCE against sysctl MIB identifiers.


Revision tags: eeh-paddr_t-base
# 1.37 26-Jun-1998 hannken

Back out last change. usr.sbin/pstat/pstat.c is wrong.


# 1.36 26-Jun-1998 hannken

Protect '#include "opt_*"' by '#if defined(_KERNEL)' for userland build.


# 1.35 25-Jun-1998 thorpej

defopt COMPAT_HPUX


# 1.34 25-Jun-1998 thorpej

defopt COMPAT_SUNOS


# 1.33 25-Jun-1998 thorpej

defopt COMPAT_LINUX


# 1.32 25-Jun-1998 thorpej

defopt COMPAT_FREEBSD


# 1.31 30-Apr-1998 thorpej

Define a new pseudo-address family, pseudo_AF_HDRCMPLT, which is used by
BPF to tell interface output routines to not fill in the layer 2 source
address. From Greg Smith <greg@nas.nasa.gov>.


# 1.30 25-Apr-1998 matt

Add MSG_MCAST and MSG_BCAST so recvmsg can return how the message was received.


# 1.29 25-Apr-1998 kleink

Per X/Open CAE Spec, Issue 5, define 3 preprocessor symbols to be used to
specify the type of socket shutdown(2).


# 1.28 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.27 07-Jan-1998 thorpej

Add the sockcred structure and related definitions, and the SCM_CREDS
control message type.


Revision tags: netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.26 05-May-1997 thorpej

branches: 1.26.8;
Ok, _really_ back out the sockaddr alignment change this time. We can't
reasonably "fix" the compiler "bug" that causes the forced alignment
to fail on certain platforms (e.g. m68k), so we _have_ to solve this
problem a different way.


# 1.25 02-May-1997 thorpej

Align a sockaddr to 4 bytes, not sizeof(long)


# 1.24 02-May-1997 thorpej

Revert the reverting of the last change. Turns out the trouble
on the m68k was a compiler bug (thanks Charles and Christos!)


# 1.23 02-May-1997 thorpej

Revert previous alignment-related change. It caused unexpected problems
on at least one architecture. The alignment issue on the alpha will
be solved in a different way.


# 1.22 02-May-1997 thorpej

Deal with an alignment problem on the Alpha port. The maximum required
alignment of any field in a struct sockaddr is 1, since all members are
chars or char arrays (as noted by Ross Harvey on port-alpha). This causes
the possibility of unaligned access faults when a sockaddr is cast to
e.g. a sockaddr_in. Solution: explicitly direct the compiler to
longword-align the start of a struct sockaddr.


# 1.21 18-Mar-1997 sommerfe

Reserve a place for PF_KEY; rename SIP to INET6


# 1.20 15-Mar-1997 is

Synchronize the CTL_NET_NAMES with the AF_* definitions (ISDN and ARP where
missing).


Revision tags: is-newarp-before-merge is-newarp-base
# 1.19 11-Feb-1997 is

branches: 1.19.4;
Allocate and define AF_ARP and PF_ARP. These will be used to
a) communicate the hardware independent part of ARP packets (rfc826) from/to
if_*subr.c in the ongoing effort to rewrite the ARP subsystem for non-Ethernet
networks
b) communicate the hardware independent part of RARP packets (rfc903) from/to
userland sockets to avoid putting link level header format knowledge into
rarpd, when it is enhanced to support non-Ethernet networks.


# 1.18 11-Jan-1997 thorpej

Implement SO_TIMESTAMP socket option: receive a timeval timestamp
as a control message with a datagram.


# 1.17 04-Jul-1996 chuck

add native mode atm protocol info, also ensure AF number remain sync'd
with freebsd.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-May-1996 neil

Remove #ifdefs

Thanks to cgd@NetBSD.ORG for pointing the following out to me:

listen (fd, SOMAXCONN); would break.

As programs wouldn't see the changes that might be specified in
the kernel config file.

As penance I am going to see if it would be possible to move this
into param.h and provide away of finding out what the kernel
value is. On busy network servers this value is useful to have as a tunable
kernel parameter.


# 1.15 02-May-1996 neil

Add ability to do options SOMAXCONN=n which is useful on
busy network servers.


# 1.14 09-Feb-1996 christos

Filesystem prototype changes


# 1.13 09-Feb-1996 mycroft

Increase SOMAXCONN.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.12 29-Mar-1995 briggs

KERNEL -> _KERNEL


# 1.11 26-Mar-1995 jtc

KERNEL -> _KERNEL


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 13-May-1994 mycroft

Update to 4.4-Lite networking code, with a few local changes.


# 1.7 04-May-1994 mycroft

Move internal prototypes to a better place.


# 1.6 04-May-1994 mycroft

Prototype lots of kernel-internal functions.


Revision tags: nvm-base wnvm magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.5 27-Jun-1993 andrew

branches: 1.5.4;
ANSIfications - lots of function prototyping.


# 1.4 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.3 19-Apr-1993 mycroft

Fix typo.


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.130 12-Oct-2021 christos

Revert previous change because it causes uninitialized warnings with KMSAN.
The previous code was correct. Add a comment explaining why. Requested by chuq@


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base netbsd-9-1-RELEASE bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.129 04-Nov-2018 christos

- Introduce a new SO_RERROR socket option to explicitly turn on
receive overflow errors re-instating the default behavior to
silently ignore them as before 2018-03-19.
- Introduce a new kern.sooptions sysctl to control the default
behavior of socket options. Setting this to 0x4000 (SO_RERROR),
turns on receive overflow error reporting for all sockets.
- Change dhcpcd to turn on SO_RERROR on all its sockets.

As discussed in tech-net.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930
# 1.128 16-Sep-2018 mrg

clean up a comment left behind from the previous commit.
this now only has sysctl pcb info.


Revision tags: pgoyette-compat-0906
# 1.127 22-Aug-2018 msaitoh

- Cleanup for dynamic sysctl:
- Remove unused *_NAMES macros for sysctl.
- Remove unused *_MAXID for sysctls.
- Move CTL_MACHDEP sysctl definitions for m68k into m68k/include/cpu.h and
use them on all m68k machines.


# 1.126 31-Jul-2018 rjs

Add declaration of getsockopt2().


Revision tags: pgoyette-compat-0728
# 1.125 17-Jul-2018 msaitoh

Add /d(dump) and /v(verbose) modifiers to DDB's "show mbuf" command. Mainly
written by Hiroki SUENAGA. Currently, /v supports Ethernet, PPP, PPPoE, ARP,
IPv4, ICMP, IPv6, ICMPv6, TCP and UDP.


Revision tags: phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422
# 1.124 19-Apr-2018 christos

branches: 1.124.2;
s/static inline/static __inline/g for consistency with other include
headers.


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.123 01-Jul-2017 christos

branches: 1.123.4;
put the code that returns the sizeof the socket by family in one place.


Revision tags: netbsd-8-base
# 1.122 27-May-2017 bouyer

branches: 1.122.2;
merge the bouyer-socketcan branch to HEAD.

CAN stands for Controller Area Network, a broadcast network used
in automation and automotive fields. For example, the NMEA2000 standard
developped for marine devices uses a CAN network as the link layer.

This is an implementation of the linux socketcan API:
https://www.kernel.org/doc/Documentation/networking/can.txt
you can also see can(4).

This adds a new socket family (AF_CAN) and protocol (PF_CAN),
as well as the canconfig(8) utility, used to set timing parameter of
CAN hardware. Also inclued is a driver for the CAN controller
found in the allwinner A20 SoC (I tested it with an Olimex lime2 board,
connected with PIC18-based CAN devices).

There is also the canloop(4) pseudo-device, which allows to use
the socketcan API without CAN hardware.

At this time the CANFD part of the linux socketcan API is not implemented.
Error frames are not implemented either. But I could get the cansend and
canreceive utilities from the canutils package to build and run with minimal
changes. tcpudmp(8) can also be used to record frames, which can be
decoded with etherreal.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.121 08-Feb-2017 maya

Add accept4, a tiny wrapper around paccept.

accept4 is a syscall in Linux, FreeBSD and OpenBSD. It is used in
LLVM, zeromq, and probably others. paccept is a superset of it.

adding it to libc ensures it is used by programs and prevents the
need to define the same wrapper in every program.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.120 21-Sep-2016 roy

branches: 1.120.2;
Add ifam_pid and ifam_addrflags to ifa_msghdr.
Re-version RTM_NEWADDR, RTM_DELADDR, RTM_CHGADDR and NET_RT_IFLIST.
Add compat code for old version.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422
# 1.119 06-Apr-2016 roy

branches: 1.119.2;
Add sc_pid to sockcred so that SOCK_DGRAM and LOCAL_CREDS socket option
can learn the process id of the AF_LOCAL sender.
Add compat glue for old structure.


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.118 13-Oct-2015 rjs

Add core networking support for SCTP.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.117 03-Apr-2015 rtr

* change pr_bind to accept struct sockaddr * instead of struct mbuf *
* update protocol bind implementations to use/expect sockaddr *
instead of mbuf *
* introduce sockaddr_big struct for storage of addr data passed via
sys_bind; sockaddr_big is of sufficient size and alignment to
accommodate all addr data sizes received.
* modify sys_bind to allocate sockaddr_big instead of using an mbuf.
* bump kernel version to 7.99.9 for change to pr_bind() parameter type.

Patch posted to tech-net@
http://mail-index.netbsd.org/tech-net/2015/03/15/msg005004.html

The choice to use a new structure sockaddr_big has been retained since
changing sockaddr_storage size would lead to unnecessary ABI change. The
use of the new structure does not preclude future work that increases
the size of sockaddr_storage and at that time sockaddr_big may be
trivially replaced.

Tested by mrg@ and myself, discussed with rmind@, posted to tech-net@


# 1.116 10-Feb-2015 rjs

Add DCCP protocol support from KAME.


# 1.115 24-Jan-2015 christos

cleanup the CMSG* macro mess.


# 1.114 24-Jan-2015 christos

back to return u_char * according to:
http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/socket.h.html


# 1.113 20-Jan-2015 christos

add void casts to CMSG_


# 1.112 20-Jan-2015 christos

add lint comment


# 1.111 02-Dec-2014 christos

sockaddr_format now returns the number of chars written.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.110 28-May-2014 christos

branches: 1.110.4;
CID 976378: Avoid incorrect computation with ngrps == 0


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.109 17-Apr-2014 christos

CID/1203196: Don't confuse coverity with out of bounds access


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 1.108 31-Jan-2013 joerg

branches: 1.108.2; 1.108.10;
Add sockaddr_format to ease debugging code dealing with socket
addresses.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.107 22-Jun-2012 christos

branches: 1.107.2;
Add {send,recv}mmsg from Linux


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.106 29-Jan-2012 roy

Allow using CMSG_NXTHDR with -Wcast-align.

If various checks are omitted, the CMSG_NXTHDR macro expands to
(struct cmsghdr *)((char *)(cmsg) + \
_ALIGN(((struct cmsghdr *)(cmsg))->cmsg_len))

Although there is no alignment problem (assuming cmsg is properly aligned
and _ALIGN is correct), this violates -Wcast-align on strict-alignment
architectures. Therefore an intermediate cast to void * is appropriate here.

There is no workaround other than not using -Wcast-align.

Taken from FreeBSD commit r220742 by jilles


# 1.105 25-Jan-2012 christos

As discussed in tech-kern, provide the means to prevent delivery of SIGPIPE
on EPIPE for all file descriptor types:

- provide O_NOSIGPIPE for open,kqueue1,pipe2,dup3,fcntl(F_{G,S}ETFL) [NetBSD]
- provide SOCK_NOSIGPIPE for socket,socketpair [NetBSD]
- provide SO_NOSIGPIPE for {g,s}seckopt [NetBSD/FreeBSD/MacOSX]
- provide F_{G,S}ETNOSIGPIPE for fcntl [MacOSX]


# 1.104 20-Jan-2012 joerg

Change CMSG_SPACE and CMSG_LEN to provide Integer Constant Expressions
again. This was changed in sys/socket.h r1.51 to work around fallout
from the IPv6 aux data migration. It broke the historic ABI on some
platforms. This commit restores compatibility for netbsd32 code on such
platforms and provides a template for future changes to the CMSG_*
alignment. Revert PCC/Clang workarounds in postfix and tmux.


# 1.103 20-Jan-2012 joerg

CMSG_ALIGN is only for the kernel.


# 1.102 20-Jan-2012 joerg

Don't use __cmsg_alignbytes in the kernel. Mark it as constant function
for userland as its value never changes. This allows the compiler to
optimise most invocations away.


# 1.101 20-Dec-2011 christos

- Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.
- Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis
- Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets.
- Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all
errors?).


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.100 26-Jun-2011 christos

branches: 1.100.2; 1.100.6;
* Arrange for interfaces that create new file descriptors to be able to
set close-on-exec on creation (http://udrepper.livejournal.com/20407.html).

- Add F_DUPFD_CLOEXEC to fcntl(2).
- Add MSG_CMSG_CLOEXEC to recvmsg(2) for unix file descriptor passing.
- Add dup3(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK.
- Add pipe2(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK.
- Add flags SOCK_CLOEXEC, SOCK_NONBLOCK to the socket type parameter
for socket(2) and socketpair(2).
- Add new paccept(2) syscall that takes an additional sigset_t to alter
the sigmask temporarily and a flags argument to set SOCK_CLOEXEC,
SOCK_NONBLOCK.
- Add new mode character 'e' to fopen(3) and popen(3) to open pipes
and file descriptors for close on exec.
- Add new kqueue1(2) syscall with a new flags argument to open the
kqueue file descriptor with O_CLOEXEC, O_NONBLOCK.

* Fix the system calls that take socklen_t arguments to actually do so.

* Don't include userland header files (signal.h) from system header files
(rump_syscallargs.h).

* Bump libc version for the new syscalls.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base rmind-uvmplock-base
# 1.99 01-Feb-2011 matt

Add a new AF/PF_ROUTE which is 64-bit clean which makes the routing socket
interface (and its associated sysctls) act identically for both 32 and 64 bit
programs. The old unclean one remains for backward compatibility.


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.98 26-Jun-2010 kefren

branches: 1.98.2; 1.98.4;
Add MPLS support, proposed on tech-net@ a couple of days ago

Welcome to 5.99.33


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211
# 1.97 05-Dec-2009 pooka

branches: 1.97.2; 1.97.4;
Remove the portalfs kernel file system driver. Replace mount_portal(8)
with a version based on puffs. User functionality remains the same.


Revision tags: yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.96 11-Sep-2009 dyoung

Make ifconfig(8) set and display preference numbers for IPv6
addresses. Make the kernel support SIOC[SG]IFADDRPREF for IPv6
interface addresses.

In in6ifa_ifpforlinklocal(), consult preference numbers before
making an otherwise arbitrary choice of in6_ifaddr. Otherwise,
preference numbers are *not* consulted by the kernel, but that will
be rather easy for somebody with a little bit of free time to fix.

Please note that setting the preference number for a link-local
IPv6 address does not work right, yet, but that ought to be fixed
soon.

In support of the changes above,

1 Add a method to struct domain for "externalizing" a sockaddr, and
provide an implementation for IPv6. Expect more work in this area: it
may be more proper to say that the IPv6 implementation "internalizes"
a sockaddr. Add sockaddr_externalize().

2 Add a subroutine, sofamily(), that returns a struct socket's address
family or AF_UNSPEC.

3 Make a lot of IPv4-specific code generic, and move it from
sys/netinet/ to sys/net/ for re-use by IPv6 parts of the kernel and
ifconfig(8).


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.95 28-Apr-2009 dyoung

Extract sockaddr_any_by_family() from sockaddr_any() for looking up a
wildcard ("any") address by protocol family instead of by sockaddr.


Revision tags: nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base
# 1.94 19-Jan-2009 christos

branches: 1.94.2;
Provide compatibility to the old timeval SCM_TIMESTAMP messages.


Revision tags: mjf-devfs2-base
# 1.93 14-Jan-2009 christos

version the timeout get/set sockopt calls, because they take struct timeval.


# 1.92 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base christos-time_t-nbase netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base christos-time_t-base
# 1.91 04-Aug-2008 tls

branches: 1.91.2;
Add accept filters, ported from FreeBSD by Coyote Point Systems. Add inetd
support for specifying an accept filter for a service (mostly as a usage
example, but it can be handy for other things). Manual pages to follow
in a day or so.

OK core@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.90 15-Jun-2008 christos

branches: 1.90.2;
define AF_80211


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase jmcneill-base mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base vmlocking-base
# 1.89 19-Sep-2007 dyoung

branches: 1.89.16; 1.89.20; 1.89.22; 1.89.24; 1.89.26; 1.89.28; 1.89.30;
1) Introduce a new socket option, (SOL_SOCKET, SO_NOHEADER), that
tells a socket that it should both add a protocol header to tx'd
datagrams and remove the header from rx'd datagrams:

int onoff = 1, s = socket(...);
setsockopt(s, SOL_SOCKET, SO_NOHEADER, &onoff);

2) Add an implementation of (SOL_SOCKET, SO_NOHEADER) for raw IPv4
sockets.

3) Reorganize the protocols' pr_ctloutput implementations a bit.
Consistently return ENOPROTOOPT when an option is unsupported,
and EINVAL if a supported option's arguments are incorrect.
Reorganize the flow of code so that it's more clear how/when
options are passed down the stack until they are handled.

Shorten some pr_ctloutput staircases for readability.

4) Extract common mbuf code into subroutines, add new sockaddr
methods, and introduce a new subroutine, fsocreate(), for reuse
later; use it first in sys_socket():

struct mbuf *m_getsombuf(struct socket *so)

Create an mbuf and make its owner the socket `so'.

struct mbuf *m_intopt(struct socket *so, int val)

Create an mbuf, make its owner the socket `so', put the
int `val' into it, and set its length to sizeof(int).


int fsocreate(..., int *fd)

Create a socket, a la socreate(9), put the socket into the
given LWP's descriptor table, return the descriptor at `fd'
on success.

void *sockaddr_addr(struct sockaddr *sa, socklen_t *slenp)
const void *sockaddr_const_addr(const struct sockaddr *sa, socklen_t *slenp)

Extract a pointer to the address part of a sockaddr. Write
the length of the address part at `slenp', if `slenp' is
not NULL.

socklen_t sockaddr_getlen(const struct sockaddr *sa)

Return the length of a sockaddr. This just evaluates to
sa->sa_len. I only add this for consistency with code that
appears in a portable userland library that I am going to
import.

const struct sockaddr *sockaddr_any(const struct sockaddr *sa)

Return the "don't care" sockaddr in the same family as
`sa'. This is the address a client should sobind(9) if it
does not care the source address and, if applicable, the
port et cetera that it uses.

const void *sockaddr_anyaddr(const struct sockaddr *sa, socklen_t *slenp)

Return the "don't care" sockaddr in the same family as
`sa'. This is the address a client should sobind(9) if it
does not care the source address and, if applicable, the
port et cetera that it uses.


Revision tags: nick-csl-alignment-base5
# 1.88 30-Aug-2007 dyoung

Use malloc(9) for sockaddrs instead of pool(9), and remove dom_sa_pool
and dom_sa_len members from struct domain. Pools of fixed-size
objects are too rigid for sockaddr_dls, whose size can vary over
a wide range.

Return sockaddr_dl to its "historical" size. Now that I'm using
malloc(9) instead of pool(9) to allocate sockaddr_dl, I can create
a sockaddr_dl of any size in the kernel, so expanding sockaddr_dl
is useless.

Avoid using sizeof(struct sockaddr_dl) in the kernel.

Introduce sockaddr_dl_alloc() for allocating & initializing an
arbitrary sockaddr_dl on the heap.

Add an argument, the sockaddr length, to sockaddr_alloc(),
sockaddr_copy(), and sockaddr_dl_setaddr().

Constify: LLADDR() -> CLLADDR().

Where the kernel overwrites LLADDR(), use sockaddr_dl_setaddr(),
instead. Used properly, sockaddr_dl_setaddr() will not overrun
the end of the sockaddr.


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.87 24-Jun-2007 dsl

branches: 1.87.2; 1.87.6; 1.87.8;
Split sys_getpeername() and sys_getsockname() so they can be called when the
'name' is wanted in kernel code.
Similarly split sys_accept() and change the split in recvmsg() so that it
is useful to the compat functions, recvit() is removed and replaced by
do_sys_recvmsg().
Factor out the code that writes socked names to userspace (from mbuf) to
avoid replicated code.
Extract the code that writes socket 'control' (CMSG) data out to userspace,
being more careful about the 'fd' that may exist inside SCM_RIGHTS msgs.
(they still get lost if some of the latter copyout calls fail).
Since these are new functions, and old LKMs will fail to load.


# 1.86 01-Jun-2007 dsl

Split sys_bind() and sys_connect() so that compat code can use common code
once the 'address' has been copied into an mbuf.
Add extra flags for 'struct msghdr.msg_flags' to indicate that the address
and control are already in mbufs, and that the uio structure is in userspace
for sending data, rename sendit() to do_sys_sendmsg() to ensure no old code
passes in random flags.
Changes to compat code to use new functions - removing some stackgap use.
Fix a 'use after free' in compat_43_sys_recvmsg.
I ***THINK*** the code that converts 'cmsg' formatted data is borked!
svr4_stream.c ought to be generated from svr4_32_stream.c during the build.


Revision tags: yamt-idlelwp-base8
# 1.85 02-May-2007 dyoung

Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.

The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.

Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.

DETAILS

1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:

struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);

sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.

sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.

The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).

2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.

3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:

int rtcache_setdst(struct route *, const struct sockaddr *);

rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.

It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.

4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.


Revision tags: thorpej-atomic-base
# 1.84 04-Mar-2007 christos

branches: 1.84.2; 1.84.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.83 20-Feb-2007 plunky

add comment for PF_BLUETOOTH


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 netbsd-4-base rpaulo-netinet-merge-pcb-base
# 1.82 27-Jun-2006 mrg

branches: 1.82.10;
that should be _STANDALONE, not STANDALONE.


# 1.81 26-Jun-2006 mrg

version the socket(2) syscall. for compat30 socket, we use
EPROTONOSUPPORT instead of EAFNOSUPPORT.

from pavel@ with a little bit of clean up from myself.

XXX: netbsd32 (and perhaps other emulations) should be able
XXX: to call the standard socket calls for this i think, but
XXX: revisit this at another time.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase chap-midi-base
# 1.80 19-Jun-2006 gdamore

Initial import of bluetooth stack on behalf of Iain Hibbert. (plunky@,
NetBSD Foundation Membership still pending.) This stack was written by
Iain under sponsorship from Itronix Inc.

The stack includes support for rfcomm networking (networking via your
bluetooth enabled cell phone), hid devices (keyboards/mice), and headsets.

Drivers for both PCMCIA and USB bluetooth controllers are included.


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.79 11-May-2006 christos

branches: 1.79.2; 1.79.4;
Add MSG_NOSIGNAL (from FreeBSD)


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.78 28-Jan-2006 kleink

branches: 1.78.2; 1.78.4; 1.78.6; 1.78.8; 1.78.10;
Since NULL isn't necessarily available, change CMSG_*() to use the
integer constant expression directly instead.

Fixes a problem in the build of rxvt-unicode-7.2, as reported by
Thomas Klausner.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 29-Nov-2005 christos

branches: 1.77.2;
sprinkle const


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.76 24-Sep-2005 christos

branches: 1.76.6;
It is now ``later''. Follow cgd's 1993 wish and move struct osockaddr
and struct omsghdr to a compat header.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.75 09-Mar-2005 tron

branches: 1.75.2; 1.75.4;
Solve problem invented in revision 1.73 differently:
Use "__uint64_t" etc. instead of pulling in "sys/socket.h" to avoid
namespace pollution. Based on comments made by Klaus Klein on the
current-users mailing list.


# 1.74 09-Mar-2005 tron

Include "sys/types.h" to get definition of "uint64_t". This is necessary
because socket(2) lists only "sys/socket.h" as a requirement. And besides
that it fixes build errors in our "libc".


# 1.73 09-Mar-2005 atatat

Add the following nodes to the sysctl tree:

net.local.stream.pcblist
net.local.dgram.pcblist
net.inet.tcp.pcblist
net.inet.udp.pcblist
net.inet.raw.pcblist
net.inet6.tcp6.pcblist
net.inet6.udp6.pcblist
net.inet6.raw6.pcblist

which allow retrieval of the pcbs in use for those protocols. The
struct involved is 32/64 bit clean and incorporates parts of struct
inpcb, struct unpcb, a bit of struct tcpcb, and two socket addresses.


# 1.72 08-Mar-2005 kleink

Fix a (harmless) typo in the definition of PF_RTIP;
from usa@garbagecollect.jp in PR kern/29624.


# 1.71 26-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.70 03-Feb-2005 perry

de-__P


Revision tags: yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Sep-2004 darrenr

branches: 1.69.4; 1.69.6;
add a per-socket counter for dropped UDP packets when the internal buffers
are full.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.68 07-Aug-2003 agc

branches: 1.68.4;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.67 28-Apr-2003 bjh21

branches: 1.67.2;
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.

This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.

I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.

Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.


# 1.66 19-Apr-2003 christos

PR/2845: Mike Schwartz: Allow some #defines to be tuned by kernel options
by protecting them via #ifndef OPTIONNAME


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base thorpej-mips-cache-base kqueue-base
# 1.65 22-Oct-2001 kleink

Sprinkle some __restrict into <sys/socket.h>.


# 1.64 22-Oct-2001 kleink

Add a sockatmark(3), the 1003.1g wrapper around SIOCATMARK.


# 1.63 16-Oct-2001 kleink

Make this capable of being included without pre-requisite headers.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf
# 1.62 07-Sep-2001 itojun

make CMSG_FIRSTHDR() validat emsg_controllen, as suggested in RFC2292.
from kame


Revision tags: thorpej-devvp-base
# 1.61 17-Jul-2001 jdolecek

branches: 1.61.2;
Expel MSG_COMPAT/COMPAT_OLDSOCK, make the COMPAT_43 wrappers
arrange things as needed. Unfortunately, the check in sockargs()
have to stay, since 4.3BSD bind(2), connect(2) and sendto(2) were
not versioned at the time :(

This code was tested to pass regression tests.


# 1.60 05-May-2001 kleink

branches: 1.60.2;
* Replace a couple of cases of u_char and u_short with uint8_t and uint16_t,
respectively.
* Simplify sockaddr_storage calculations a bit by the fact that, per defintion,
sizeof (char) == 1.
Fixes PR standards/10791.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.59 04-Oct-2000 toshii

branches: 1.59.2;
Wrap __cmsg_alignbytes in __BEGIN_DECLS ... __END_DECLS.


# 1.58 28-Jul-2000 kleink

Avoid recursion with traditional cpp.


# 1.57 05-Jul-2000 christos

delint a macro


# 1.56 26-Jun-2000 kleink

XNS5.2: define sa_family_t and use it where specified by the standard.


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.55 04-Jun-2000 itojun

branches: 1.55.2;
move socklen_t decl to sys/ansi.h.
sys/socket.h pulls in sys/ansi.h and declare socklen_t as necessary.
the change is to allow declaration of socklen_t with less inclusion ordering
constraints. (netdb.h needs this change)


Revision tags: minoura-xpg4dl-base
# 1.54 03-Apr-2000 augustss

branches: 1.54.2;
Change #define CMSG_ALIGN so it's not recursive. Now the kernel compiles
again.


# 1.53 03-Apr-2000 itojun

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


# 1.52 28-Mar-2000 simonb

Remove prototype for pfctlinput() - there's already one in
sys/protosw.h with the other pf*() prototypes.


# 1.51 02-Mar-2000 itojun

make CMSG_ALIGN always synchronize with kernel's idea of ALIGNBYTES.
ancillary data alignment will be ALIGNBYTES, not sizeof(long) - 1, from now.

CMSG_xx will NOT resolve into constant. if you use CMSG_xx to allocate
arrays, you'll lose.

bump shlib minor for libc.

NOTE: if you are on top of arch with ALIGNBYTES != sizeof(long) - 1,
you need to recompile IPv6-related binaries. there is no way to guarantee
backward compat in this aspect. sorry for this. this should be the last
backward compat breakage for IPv6-related ancillary data manipulation.
(we still have PR 9516 for unix-domain sockets...)


# 1.50 18-Feb-2000 itojun

fix alignment problem in ancillary messages (alpha).

the change constitutes binary compatibility issue hen sizeof(long) !=4.
there's no way to be backward compatible, and only guys affected
are IPv6 userland tools.

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


Revision tags: chs-ubc2-newbase
# 1.49 03-Feb-2000 enami

Remove duplicated PF_INET6 definition.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.48 20-Dec-1999 itojun

based on recent discussion on ipngwg, use XNET definition for
sockaddr_storage. next revision of RFC2553 will be using this.

ss_len and ss_family are now available for userland programmers.


# 1.47 19-Nov-1999 bouyer

Update protocoles and interfaces stats counters to 64bit.
RTM_IFINFO is now 0xf, 0xe is RTM_OIFINFO which returns the old (if_msghdr14)
struct with 32bit counters (binary compat, conditioned on COMPAT_14).
Same for sysctl: node 3 is renamed NET_RT_OIFLIST, NET_RT_IFLIST is now node 4.
Change rt_msg1() to add an mbuf to the mbuf chain instead of just panic()
when the message is larger than MHLEN.


Revision tags: comdex-fall-1999-base fvdl-softdep-base chs-ubc2-base
# 1.46 03-Jul-1999 kleink

branches: 1.46.2; 1.46.8;
Modify the previous change to:
* not declare struct sockaddr_storage in pre-XNS5.2 D2.0 environments, and
* not use __{BEGIN,END}_DECLS in a _KERNEL environment, which is not necessary.


# 1.45 01-Jul-1999 itojun

avoid void * arithmetic (msg_control is now void *).


# 1.44 01-Jul-1999 itojun

IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.43 11-Feb-1999 cjs

branches: 1.43.4; 1.43.6;
Fix compiler warning.


# 1.42 10-Feb-1999 kleink

* Define socklen_t, an unsigned integral type used to hold the lengths of
socket options, addresses etc., and use it where specified by XNS5.
* Per XNS5, change data pointers types in struct msghdr from caddr_t to void *;
make msg_iovlen a signed int (apparently for consistency with the iovcnt
argument to readv()/writev()).
* Some name space protection.


# 1.41 18-Dec-1998 drochner

solve the COMPAT_OLDSOCK/MSG_COMPAT problem differently:
The source files which need MSG_COMPAT define COMPAT_OLDSOCK.


# 1.40 13-Dec-1998 christos

add include "opt_compat_43.h" otherwise, if this is our only compat option,
we don't link (reported by Klaus Klein).


Revision tags: kenh-if-detach-base
# 1.39 09-Nov-1998 mrg

compat_ultrix wants MSG_COMPAT/COMPAT_OLDSOCK: don't depend on COMPAT_43


Revision tags: chs-ubc-base
# 1.38 05-Sep-1998 kleink

Protect _XOPEN_SOURCE against sysctl MIB identifiers.


Revision tags: eeh-paddr_t-base
# 1.37 26-Jun-1998 hannken

Back out last change. usr.sbin/pstat/pstat.c is wrong.


# 1.36 26-Jun-1998 hannken

Protect '#include "opt_*"' by '#if defined(_KERNEL)' for userland build.


# 1.35 25-Jun-1998 thorpej

defopt COMPAT_HPUX


# 1.34 25-Jun-1998 thorpej

defopt COMPAT_SUNOS


# 1.33 25-Jun-1998 thorpej

defopt COMPAT_LINUX


# 1.32 25-Jun-1998 thorpej

defopt COMPAT_FREEBSD


# 1.31 30-Apr-1998 thorpej

Define a new pseudo-address family, pseudo_AF_HDRCMPLT, which is used by
BPF to tell interface output routines to not fill in the layer 2 source
address. From Greg Smith <greg@nas.nasa.gov>.


# 1.30 25-Apr-1998 matt

Add MSG_MCAST and MSG_BCAST so recvmsg can return how the message was received.


# 1.29 25-Apr-1998 kleink

Per X/Open CAE Spec, Issue 5, define 3 preprocessor symbols to be used to
specify the type of socket shutdown(2).


# 1.28 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.27 07-Jan-1998 thorpej

Add the sockcred structure and related definitions, and the SCM_CREDS
control message type.


Revision tags: netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.26 05-May-1997 thorpej

branches: 1.26.8;
Ok, _really_ back out the sockaddr alignment change this time. We can't
reasonably "fix" the compiler "bug" that causes the forced alignment
to fail on certain platforms (e.g. m68k), so we _have_ to solve this
problem a different way.


# 1.25 02-May-1997 thorpej

Align a sockaddr to 4 bytes, not sizeof(long)


# 1.24 02-May-1997 thorpej

Revert the reverting of the last change. Turns out the trouble
on the m68k was a compiler bug (thanks Charles and Christos!)


# 1.23 02-May-1997 thorpej

Revert previous alignment-related change. It caused unexpected problems
on at least one architecture. The alignment issue on the alpha will
be solved in a different way.


# 1.22 02-May-1997 thorpej

Deal with an alignment problem on the Alpha port. The maximum required
alignment of any field in a struct sockaddr is 1, since all members are
chars or char arrays (as noted by Ross Harvey on port-alpha). This causes
the possibility of unaligned access faults when a sockaddr is cast to
e.g. a sockaddr_in. Solution: explicitly direct the compiler to
longword-align the start of a struct sockaddr.


# 1.21 18-Mar-1997 sommerfe

Reserve a place for PF_KEY; rename SIP to INET6


# 1.20 15-Mar-1997 is

Synchronize the CTL_NET_NAMES with the AF_* definitions (ISDN and ARP where
missing).


Revision tags: is-newarp-before-merge is-newarp-base
# 1.19 11-Feb-1997 is

branches: 1.19.4;
Allocate and define AF_ARP and PF_ARP. These will be used to
a) communicate the hardware independent part of ARP packets (rfc826) from/to
if_*subr.c in the ongoing effort to rewrite the ARP subsystem for non-Ethernet
networks
b) communicate the hardware independent part of RARP packets (rfc903) from/to
userland sockets to avoid putting link level header format knowledge into
rarpd, when it is enhanced to support non-Ethernet networks.


# 1.18 11-Jan-1997 thorpej

Implement SO_TIMESTAMP socket option: receive a timeval timestamp
as a control message with a datagram.


# 1.17 04-Jul-1996 chuck

add native mode atm protocol info, also ensure AF number remain sync'd
with freebsd.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-May-1996 neil

Remove #ifdefs

Thanks to cgd@NetBSD.ORG for pointing the following out to me:

listen (fd, SOMAXCONN); would break.

As programs wouldn't see the changes that might be specified in
the kernel config file.

As penance I am going to see if it would be possible to move this
into param.h and provide away of finding out what the kernel
value is. On busy network servers this value is useful to have as a tunable
kernel parameter.


# 1.15 02-May-1996 neil

Add ability to do options SOMAXCONN=n which is useful on
busy network servers.


# 1.14 09-Feb-1996 christos

Filesystem prototype changes


# 1.13 09-Feb-1996 mycroft

Increase SOMAXCONN.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.12 29-Mar-1995 briggs

KERNEL -> _KERNEL


# 1.11 26-Mar-1995 jtc

KERNEL -> _KERNEL


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 13-May-1994 mycroft

Update to 4.4-Lite networking code, with a few local changes.


# 1.7 04-May-1994 mycroft

Move internal prototypes to a better place.


# 1.6 04-May-1994 mycroft

Prototype lots of kernel-internal functions.


Revision tags: nvm-base wnvm magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.5 27-Jun-1993 andrew

branches: 1.5.4;
ANSIfications - lots of function prototyping.


# 1.4 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.3 19-Apr-1993 mycroft

Fix typo.


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.129 04-Nov-2018 christos

- Introduce a new SO_RERROR socket option to explicitly turn on
receive overflow errors re-instating the default behavior to
silently ignore them as before 2018-03-19.
- Introduce a new kern.sooptions sysctl to control the default
behavior of socket options. Setting this to 0x4000 (SO_RERROR),
turns on receive overflow error reporting for all sockets.
- Change dhcpcd to turn on SO_RERROR on all its sockets.

As discussed in tech-net.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930
# 1.128 16-Sep-2018 mrg

clean up a comment left behind from the previous commit.
this now only has sysctl pcb info.


Revision tags: pgoyette-compat-0906
# 1.127 22-Aug-2018 msaitoh

- Cleanup for dynamic sysctl:
- Remove unused *_NAMES macros for sysctl.
- Remove unused *_MAXID for sysctls.
- Move CTL_MACHDEP sysctl definitions for m68k into m68k/include/cpu.h and
use them on all m68k machines.


# 1.126 31-Jul-2018 rjs

Add declaration of getsockopt2().


Revision tags: pgoyette-compat-0728
# 1.125 17-Jul-2018 msaitoh

Add /d(dump) and /v(verbose) modifiers to DDB's "show mbuf" command. Mainly
written by Hiroki SUENAGA. Currently, /v supports Ethernet, PPP, PPPoE, ARP,
IPv4, ICMP, IPv6, ICMPv6, TCP and UDP.


Revision tags: phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422
# 1.124 19-Apr-2018 christos

s/static inline/static __inline/g for consistency with other include
headers.


Revision tags: pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.123 01-Jul-2017 christos

branches: 1.123.4;
put the code that returns the sizeof the socket by family in one place.


Revision tags: netbsd-8-base
# 1.122 27-May-2017 bouyer

branches: 1.122.2;
merge the bouyer-socketcan branch to HEAD.

CAN stands for Controller Area Network, a broadcast network used
in automation and automotive fields. For example, the NMEA2000 standard
developped for marine devices uses a CAN network as the link layer.

This is an implementation of the linux socketcan API:
https://www.kernel.org/doc/Documentation/networking/can.txt
you can also see can(4).

This adds a new socket family (AF_CAN) and protocol (PF_CAN),
as well as the canconfig(8) utility, used to set timing parameter of
CAN hardware. Also inclued is a driver for the CAN controller
found in the allwinner A20 SoC (I tested it with an Olimex lime2 board,
connected with PIC18-based CAN devices).

There is also the canloop(4) pseudo-device, which allows to use
the socketcan API without CAN hardware.

At this time the CANFD part of the linux socketcan API is not implemented.
Error frames are not implemented either. But I could get the cansend and
canreceive utilities from the canutils package to build and run with minimal
changes. tcpudmp(8) can also be used to record frames, which can be
decoded with etherreal.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.121 08-Feb-2017 maya

Add accept4, a tiny wrapper around paccept.

accept4 is a syscall in Linux, FreeBSD and OpenBSD. It is used in
LLVM, zeromq, and probably others. paccept is a superset of it.

adding it to libc ensures it is used by programs and prevents the
need to define the same wrapper in every program.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.120 21-Sep-2016 roy

branches: 1.120.2;
Add ifam_pid and ifam_addrflags to ifa_msghdr.
Re-version RTM_NEWADDR, RTM_DELADDR, RTM_CHGADDR and NET_RT_IFLIST.
Add compat code for old version.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422
# 1.119 06-Apr-2016 roy

branches: 1.119.2;
Add sc_pid to sockcred so that SOCK_DGRAM and LOCAL_CREDS socket option
can learn the process id of the AF_LOCAL sender.
Add compat glue for old structure.


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.118 13-Oct-2015 rjs

Add core networking support for SCTP.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.117 03-Apr-2015 rtr

* change pr_bind to accept struct sockaddr * instead of struct mbuf *
* update protocol bind implementations to use/expect sockaddr *
instead of mbuf *
* introduce sockaddr_big struct for storage of addr data passed via
sys_bind; sockaddr_big is of sufficient size and alignment to
accommodate all addr data sizes received.
* modify sys_bind to allocate sockaddr_big instead of using an mbuf.
* bump kernel version to 7.99.9 for change to pr_bind() parameter type.

Patch posted to tech-net@
http://mail-index.netbsd.org/tech-net/2015/03/15/msg005004.html

The choice to use a new structure sockaddr_big has been retained since
changing sockaddr_storage size would lead to unnecessary ABI change. The
use of the new structure does not preclude future work that increases
the size of sockaddr_storage and at that time sockaddr_big may be
trivially replaced.

Tested by mrg@ and myself, discussed with rmind@, posted to tech-net@


# 1.116 10-Feb-2015 rjs

Add DCCP protocol support from KAME.


# 1.115 24-Jan-2015 christos

cleanup the CMSG* macro mess.


# 1.114 24-Jan-2015 christos

back to return u_char * according to:
http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/socket.h.html


# 1.113 20-Jan-2015 christos

add void casts to CMSG_


# 1.112 20-Jan-2015 christos

add lint comment


# 1.111 02-Dec-2014 christos

sockaddr_format now returns the number of chars written.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.110 28-May-2014 christos

branches: 1.110.4;
CID 976378: Avoid incorrect computation with ngrps == 0


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.109 17-Apr-2014 christos

CID/1203196: Don't confuse coverity with out of bounds access


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 1.108 31-Jan-2013 joerg

branches: 1.108.2; 1.108.10;
Add sockaddr_format to ease debugging code dealing with socket
addresses.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.107 22-Jun-2012 christos

branches: 1.107.2;
Add {send,recv}mmsg from Linux


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.106 29-Jan-2012 roy

Allow using CMSG_NXTHDR with -Wcast-align.

If various checks are omitted, the CMSG_NXTHDR macro expands to
(struct cmsghdr *)((char *)(cmsg) + \
_ALIGN(((struct cmsghdr *)(cmsg))->cmsg_len))

Although there is no alignment problem (assuming cmsg is properly aligned
and _ALIGN is correct), this violates -Wcast-align on strict-alignment
architectures. Therefore an intermediate cast to void * is appropriate here.

There is no workaround other than not using -Wcast-align.

Taken from FreeBSD commit r220742 by jilles


# 1.105 25-Jan-2012 christos

As discussed in tech-kern, provide the means to prevent delivery of SIGPIPE
on EPIPE for all file descriptor types:

- provide O_NOSIGPIPE for open,kqueue1,pipe2,dup3,fcntl(F_{G,S}ETFL) [NetBSD]
- provide SOCK_NOSIGPIPE for socket,socketpair [NetBSD]
- provide SO_NOSIGPIPE for {g,s}seckopt [NetBSD/FreeBSD/MacOSX]
- provide F_{G,S}ETNOSIGPIPE for fcntl [MacOSX]


# 1.104 20-Jan-2012 joerg

Change CMSG_SPACE and CMSG_LEN to provide Integer Constant Expressions
again. This was changed in sys/socket.h r1.51 to work around fallout
from the IPv6 aux data migration. It broke the historic ABI on some
platforms. This commit restores compatibility for netbsd32 code on such
platforms and provides a template for future changes to the CMSG_*
alignment. Revert PCC/Clang workarounds in postfix and tmux.


# 1.103 20-Jan-2012 joerg

CMSG_ALIGN is only for the kernel.


# 1.102 20-Jan-2012 joerg

Don't use __cmsg_alignbytes in the kernel. Mark it as constant function
for userland as its value never changes. This allows the compiler to
optimise most invocations away.


# 1.101 20-Dec-2011 christos

- Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.
- Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis
- Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets.
- Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all
errors?).


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.100 26-Jun-2011 christos

branches: 1.100.2; 1.100.6;
* Arrange for interfaces that create new file descriptors to be able to
set close-on-exec on creation (http://udrepper.livejournal.com/20407.html).

- Add F_DUPFD_CLOEXEC to fcntl(2).
- Add MSG_CMSG_CLOEXEC to recvmsg(2) for unix file descriptor passing.
- Add dup3(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK.
- Add pipe2(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK.
- Add flags SOCK_CLOEXEC, SOCK_NONBLOCK to the socket type parameter
for socket(2) and socketpair(2).
- Add new paccept(2) syscall that takes an additional sigset_t to alter
the sigmask temporarily and a flags argument to set SOCK_CLOEXEC,
SOCK_NONBLOCK.
- Add new mode character 'e' to fopen(3) and popen(3) to open pipes
and file descriptors for close on exec.
- Add new kqueue1(2) syscall with a new flags argument to open the
kqueue file descriptor with O_CLOEXEC, O_NONBLOCK.

* Fix the system calls that take socklen_t arguments to actually do so.

* Don't include userland header files (signal.h) from system header files
(rump_syscallargs.h).

* Bump libc version for the new syscalls.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base rmind-uvmplock-base
# 1.99 01-Feb-2011 matt

Add a new AF/PF_ROUTE which is 64-bit clean which makes the routing socket
interface (and its associated sysctls) act identically for both 32 and 64 bit
programs. The old unclean one remains for backward compatibility.


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.98 26-Jun-2010 kefren

branches: 1.98.2; 1.98.4;
Add MPLS support, proposed on tech-net@ a couple of days ago

Welcome to 5.99.33


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211
# 1.97 05-Dec-2009 pooka

branches: 1.97.2; 1.97.4;
Remove the portalfs kernel file system driver. Replace mount_portal(8)
with a version based on puffs. User functionality remains the same.


Revision tags: yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.96 11-Sep-2009 dyoung

Make ifconfig(8) set and display preference numbers for IPv6
addresses. Make the kernel support SIOC[SG]IFADDRPREF for IPv6
interface addresses.

In in6ifa_ifpforlinklocal(), consult preference numbers before
making an otherwise arbitrary choice of in6_ifaddr. Otherwise,
preference numbers are *not* consulted by the kernel, but that will
be rather easy for somebody with a little bit of free time to fix.

Please note that setting the preference number for a link-local
IPv6 address does not work right, yet, but that ought to be fixed
soon.

In support of the changes above,

1 Add a method to struct domain for "externalizing" a sockaddr, and
provide an implementation for IPv6. Expect more work in this area: it
may be more proper to say that the IPv6 implementation "internalizes"
a sockaddr. Add sockaddr_externalize().

2 Add a subroutine, sofamily(), that returns a struct socket's address
family or AF_UNSPEC.

3 Make a lot of IPv4-specific code generic, and move it from
sys/netinet/ to sys/net/ for re-use by IPv6 parts of the kernel and
ifconfig(8).


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.95 28-Apr-2009 dyoung

Extract sockaddr_any_by_family() from sockaddr_any() for looking up a
wildcard ("any") address by protocol family instead of by sockaddr.


Revision tags: nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base
# 1.94 19-Jan-2009 christos

branches: 1.94.2;
Provide compatibility to the old timeval SCM_TIMESTAMP messages.


Revision tags: mjf-devfs2-base
# 1.93 14-Jan-2009 christos

version the timeout get/set sockopt calls, because they take struct timeval.


# 1.92 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base christos-time_t-nbase netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base christos-time_t-base
# 1.91 04-Aug-2008 tls

branches: 1.91.2;
Add accept filters, ported from FreeBSD by Coyote Point Systems. Add inetd
support for specifying an accept filter for a service (mostly as a usage
example, but it can be handy for other things). Manual pages to follow
in a day or so.

OK core@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.90 15-Jun-2008 christos

branches: 1.90.2;
define AF_80211


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase jmcneill-base mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base vmlocking-base
# 1.89 19-Sep-2007 dyoung

branches: 1.89.16; 1.89.20; 1.89.22; 1.89.24; 1.89.26; 1.89.28; 1.89.30;
1) Introduce a new socket option, (SOL_SOCKET, SO_NOHEADER), that
tells a socket that it should both add a protocol header to tx'd
datagrams and remove the header from rx'd datagrams:

int onoff = 1, s = socket(...);
setsockopt(s, SOL_SOCKET, SO_NOHEADER, &onoff);

2) Add an implementation of (SOL_SOCKET, SO_NOHEADER) for raw IPv4
sockets.

3) Reorganize the protocols' pr_ctloutput implementations a bit.
Consistently return ENOPROTOOPT when an option is unsupported,
and EINVAL if a supported option's arguments are incorrect.
Reorganize the flow of code so that it's more clear how/when
options are passed down the stack until they are handled.

Shorten some pr_ctloutput staircases for readability.

4) Extract common mbuf code into subroutines, add new sockaddr
methods, and introduce a new subroutine, fsocreate(), for reuse
later; use it first in sys_socket():

struct mbuf *m_getsombuf(struct socket *so)

Create an mbuf and make its owner the socket `so'.

struct mbuf *m_intopt(struct socket *so, int val)

Create an mbuf, make its owner the socket `so', put the
int `val' into it, and set its length to sizeof(int).


int fsocreate(..., int *fd)

Create a socket, a la socreate(9), put the socket into the
given LWP's descriptor table, return the descriptor at `fd'
on success.

void *sockaddr_addr(struct sockaddr *sa, socklen_t *slenp)
const void *sockaddr_const_addr(const struct sockaddr *sa, socklen_t *slenp)

Extract a pointer to the address part of a sockaddr. Write
the length of the address part at `slenp', if `slenp' is
not NULL.

socklen_t sockaddr_getlen(const struct sockaddr *sa)

Return the length of a sockaddr. This just evaluates to
sa->sa_len. I only add this for consistency with code that
appears in a portable userland library that I am going to
import.

const struct sockaddr *sockaddr_any(const struct sockaddr *sa)

Return the "don't care" sockaddr in the same family as
`sa'. This is the address a client should sobind(9) if it
does not care the source address and, if applicable, the
port et cetera that it uses.

const void *sockaddr_anyaddr(const struct sockaddr *sa, socklen_t *slenp)

Return the "don't care" sockaddr in the same family as
`sa'. This is the address a client should sobind(9) if it
does not care the source address and, if applicable, the
port et cetera that it uses.


Revision tags: nick-csl-alignment-base5
# 1.88 30-Aug-2007 dyoung

Use malloc(9) for sockaddrs instead of pool(9), and remove dom_sa_pool
and dom_sa_len members from struct domain. Pools of fixed-size
objects are too rigid for sockaddr_dls, whose size can vary over
a wide range.

Return sockaddr_dl to its "historical" size. Now that I'm using
malloc(9) instead of pool(9) to allocate sockaddr_dl, I can create
a sockaddr_dl of any size in the kernel, so expanding sockaddr_dl
is useless.

Avoid using sizeof(struct sockaddr_dl) in the kernel.

Introduce sockaddr_dl_alloc() for allocating & initializing an
arbitrary sockaddr_dl on the heap.

Add an argument, the sockaddr length, to sockaddr_alloc(),
sockaddr_copy(), and sockaddr_dl_setaddr().

Constify: LLADDR() -> CLLADDR().

Where the kernel overwrites LLADDR(), use sockaddr_dl_setaddr(),
instead. Used properly, sockaddr_dl_setaddr() will not overrun
the end of the sockaddr.


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.87 24-Jun-2007 dsl

branches: 1.87.2; 1.87.6; 1.87.8;
Split sys_getpeername() and sys_getsockname() so they can be called when the
'name' is wanted in kernel code.
Similarly split sys_accept() and change the split in recvmsg() so that it
is useful to the compat functions, recvit() is removed and replaced by
do_sys_recvmsg().
Factor out the code that writes socked names to userspace (from mbuf) to
avoid replicated code.
Extract the code that writes socket 'control' (CMSG) data out to userspace,
being more careful about the 'fd' that may exist inside SCM_RIGHTS msgs.
(they still get lost if some of the latter copyout calls fail).
Since these are new functions, and old LKMs will fail to load.


# 1.86 01-Jun-2007 dsl

Split sys_bind() and sys_connect() so that compat code can use common code
once the 'address' has been copied into an mbuf.
Add extra flags for 'struct msghdr.msg_flags' to indicate that the address
and control are already in mbufs, and that the uio structure is in userspace
for sending data, rename sendit() to do_sys_sendmsg() to ensure no old code
passes in random flags.
Changes to compat code to use new functions - removing some stackgap use.
Fix a 'use after free' in compat_43_sys_recvmsg.
I ***THINK*** the code that converts 'cmsg' formatted data is borked!
svr4_stream.c ought to be generated from svr4_32_stream.c during the build.


Revision tags: yamt-idlelwp-base8
# 1.85 02-May-2007 dyoung

Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.

The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.

Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.

DETAILS

1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:

struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);

sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.

sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.

The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).

2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.

3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:

int rtcache_setdst(struct route *, const struct sockaddr *);

rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.

It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.

4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.


Revision tags: thorpej-atomic-base
# 1.84 04-Mar-2007 christos

branches: 1.84.2; 1.84.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.83 20-Feb-2007 plunky

add comment for PF_BLUETOOTH


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 netbsd-4-base rpaulo-netinet-merge-pcb-base
# 1.82 27-Jun-2006 mrg

branches: 1.82.10;
that should be _STANDALONE, not STANDALONE.


# 1.81 26-Jun-2006 mrg

version the socket(2) syscall. for compat30 socket, we use
EPROTONOSUPPORT instead of EAFNOSUPPORT.

from pavel@ with a little bit of clean up from myself.

XXX: netbsd32 (and perhaps other emulations) should be able
XXX: to call the standard socket calls for this i think, but
XXX: revisit this at another time.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase chap-midi-base
# 1.80 19-Jun-2006 gdamore

Initial import of bluetooth stack on behalf of Iain Hibbert. (plunky@,
NetBSD Foundation Membership still pending.) This stack was written by
Iain under sponsorship from Itronix Inc.

The stack includes support for rfcomm networking (networking via your
bluetooth enabled cell phone), hid devices (keyboards/mice), and headsets.

Drivers for both PCMCIA and USB bluetooth controllers are included.


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.79 11-May-2006 christos

branches: 1.79.2; 1.79.4;
Add MSG_NOSIGNAL (from FreeBSD)


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.78 28-Jan-2006 kleink

branches: 1.78.2; 1.78.4; 1.78.6; 1.78.8; 1.78.10;
Since NULL isn't necessarily available, change CMSG_*() to use the
integer constant expression directly instead.

Fixes a problem in the build of rxvt-unicode-7.2, as reported by
Thomas Klausner.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 29-Nov-2005 christos

branches: 1.77.2;
sprinkle const


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.76 24-Sep-2005 christos

branches: 1.76.6;
It is now ``later''. Follow cgd's 1993 wish and move struct osockaddr
and struct omsghdr to a compat header.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.75 09-Mar-2005 tron

branches: 1.75.2; 1.75.4;
Solve problem invented in revision 1.73 differently:
Use "__uint64_t" etc. instead of pulling in "sys/socket.h" to avoid
namespace pollution. Based on comments made by Klaus Klein on the
current-users mailing list.


# 1.74 09-Mar-2005 tron

Include "sys/types.h" to get definition of "uint64_t". This is necessary
because socket(2) lists only "sys/socket.h" as a requirement. And besides
that it fixes build errors in our "libc".


# 1.73 09-Mar-2005 atatat

Add the following nodes to the sysctl tree:

net.local.stream.pcblist
net.local.dgram.pcblist
net.inet.tcp.pcblist
net.inet.udp.pcblist
net.inet.raw.pcblist
net.inet6.tcp6.pcblist
net.inet6.udp6.pcblist
net.inet6.raw6.pcblist

which allow retrieval of the pcbs in use for those protocols. The
struct involved is 32/64 bit clean and incorporates parts of struct
inpcb, struct unpcb, a bit of struct tcpcb, and two socket addresses.


# 1.72 08-Mar-2005 kleink

Fix a (harmless) typo in the definition of PF_RTIP;
from usa@garbagecollect.jp in PR kern/29624.


# 1.71 26-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.70 03-Feb-2005 perry

de-__P


Revision tags: yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Sep-2004 darrenr

branches: 1.69.4; 1.69.6;
add a per-socket counter for dropped UDP packets when the internal buffers
are full.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.68 07-Aug-2003 agc

branches: 1.68.4;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.67 28-Apr-2003 bjh21

branches: 1.67.2;
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.

This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.

I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.

Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.


# 1.66 19-Apr-2003 christos

PR/2845: Mike Schwartz: Allow some #defines to be tuned by kernel options
by protecting them via #ifndef OPTIONNAME


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base thorpej-mips-cache-base kqueue-base
# 1.65 22-Oct-2001 kleink

Sprinkle some __restrict into <sys/socket.h>.


# 1.64 22-Oct-2001 kleink

Add a sockatmark(3), the 1003.1g wrapper around SIOCATMARK.


# 1.63 16-Oct-2001 kleink

Make this capable of being included without pre-requisite headers.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf
# 1.62 07-Sep-2001 itojun

make CMSG_FIRSTHDR() validat emsg_controllen, as suggested in RFC2292.
from kame


Revision tags: thorpej-devvp-base
# 1.61 17-Jul-2001 jdolecek

branches: 1.61.2;
Expel MSG_COMPAT/COMPAT_OLDSOCK, make the COMPAT_43 wrappers
arrange things as needed. Unfortunately, the check in sockargs()
have to stay, since 4.3BSD bind(2), connect(2) and sendto(2) were
not versioned at the time :(

This code was tested to pass regression tests.


# 1.60 05-May-2001 kleink

branches: 1.60.2;
* Replace a couple of cases of u_char and u_short with uint8_t and uint16_t,
respectively.
* Simplify sockaddr_storage calculations a bit by the fact that, per defintion,
sizeof (char) == 1.
Fixes PR standards/10791.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.59 04-Oct-2000 toshii

branches: 1.59.2;
Wrap __cmsg_alignbytes in __BEGIN_DECLS ... __END_DECLS.


# 1.58 28-Jul-2000 kleink

Avoid recursion with traditional cpp.


# 1.57 05-Jul-2000 christos

delint a macro


# 1.56 26-Jun-2000 kleink

XNS5.2: define sa_family_t and use it where specified by the standard.


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.55 04-Jun-2000 itojun

branches: 1.55.2;
move socklen_t decl to sys/ansi.h.
sys/socket.h pulls in sys/ansi.h and declare socklen_t as necessary.
the change is to allow declaration of socklen_t with less inclusion ordering
constraints. (netdb.h needs this change)


Revision tags: minoura-xpg4dl-base
# 1.54 03-Apr-2000 augustss

branches: 1.54.2;
Change #define CMSG_ALIGN so it's not recursive. Now the kernel compiles
again.


# 1.53 03-Apr-2000 itojun

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


# 1.52 28-Mar-2000 simonb

Remove prototype for pfctlinput() - there's already one in
sys/protosw.h with the other pf*() prototypes.


# 1.51 02-Mar-2000 itojun

make CMSG_ALIGN always synchronize with kernel's idea of ALIGNBYTES.
ancillary data alignment will be ALIGNBYTES, not sizeof(long) - 1, from now.

CMSG_xx will NOT resolve into constant. if you use CMSG_xx to allocate
arrays, you'll lose.

bump shlib minor for libc.

NOTE: if you are on top of arch with ALIGNBYTES != sizeof(long) - 1,
you need to recompile IPv6-related binaries. there is no way to guarantee
backward compat in this aspect. sorry for this. this should be the last
backward compat breakage for IPv6-related ancillary data manipulation.
(we still have PR 9516 for unix-domain sockets...)


# 1.50 18-Feb-2000 itojun

fix alignment problem in ancillary messages (alpha).

the change constitutes binary compatibility issue hen sizeof(long) !=4.
there's no way to be backward compatible, and only guys affected
are IPv6 userland tools.

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


Revision tags: chs-ubc2-newbase
# 1.49 03-Feb-2000 enami

Remove duplicated PF_INET6 definition.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.48 20-Dec-1999 itojun

based on recent discussion on ipngwg, use XNET definition for
sockaddr_storage. next revision of RFC2553 will be using this.

ss_len and ss_family are now available for userland programmers.


# 1.47 19-Nov-1999 bouyer

Update protocoles and interfaces stats counters to 64bit.
RTM_IFINFO is now 0xf, 0xe is RTM_OIFINFO which returns the old (if_msghdr14)
struct with 32bit counters (binary compat, conditioned on COMPAT_14).
Same for sysctl: node 3 is renamed NET_RT_OIFLIST, NET_RT_IFLIST is now node 4.
Change rt_msg1() to add an mbuf to the mbuf chain instead of just panic()
when the message is larger than MHLEN.


Revision tags: comdex-fall-1999-base fvdl-softdep-base chs-ubc2-base
# 1.46 03-Jul-1999 kleink

branches: 1.46.2; 1.46.8;
Modify the previous change to:
* not declare struct sockaddr_storage in pre-XNS5.2 D2.0 environments, and
* not use __{BEGIN,END}_DECLS in a _KERNEL environment, which is not necessary.


# 1.45 01-Jul-1999 itojun

avoid void * arithmetic (msg_control is now void *).


# 1.44 01-Jul-1999 itojun

IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.43 11-Feb-1999 cjs

branches: 1.43.4; 1.43.6;
Fix compiler warning.


# 1.42 10-Feb-1999 kleink

* Define socklen_t, an unsigned integral type used to hold the lengths of
socket options, addresses etc., and use it where specified by XNS5.
* Per XNS5, change data pointers types in struct msghdr from caddr_t to void *;
make msg_iovlen a signed int (apparently for consistency with the iovcnt
argument to readv()/writev()).
* Some name space protection.


# 1.41 18-Dec-1998 drochner

solve the COMPAT_OLDSOCK/MSG_COMPAT problem differently:
The source files which need MSG_COMPAT define COMPAT_OLDSOCK.


# 1.40 13-Dec-1998 christos

add include "opt_compat_43.h" otherwise, if this is our only compat option,
we don't link (reported by Klaus Klein).


Revision tags: kenh-if-detach-base
# 1.39 09-Nov-1998 mrg

compat_ultrix wants MSG_COMPAT/COMPAT_OLDSOCK: don't depend on COMPAT_43


Revision tags: chs-ubc-base
# 1.38 05-Sep-1998 kleink

Protect _XOPEN_SOURCE against sysctl MIB identifiers.


Revision tags: eeh-paddr_t-base
# 1.37 26-Jun-1998 hannken

Back out last change. usr.sbin/pstat/pstat.c is wrong.


# 1.36 26-Jun-1998 hannken

Protect '#include "opt_*"' by '#if defined(_KERNEL)' for userland build.


# 1.35 25-Jun-1998 thorpej

defopt COMPAT_HPUX


# 1.34 25-Jun-1998 thorpej

defopt COMPAT_SUNOS


# 1.33 25-Jun-1998 thorpej

defopt COMPAT_LINUX


# 1.32 25-Jun-1998 thorpej

defopt COMPAT_FREEBSD


# 1.31 30-Apr-1998 thorpej

Define a new pseudo-address family, pseudo_AF_HDRCMPLT, which is used by
BPF to tell interface output routines to not fill in the layer 2 source
address. From Greg Smith <greg@nas.nasa.gov>.


# 1.30 25-Apr-1998 matt

Add MSG_MCAST and MSG_BCAST so recvmsg can return how the message was received.


# 1.29 25-Apr-1998 kleink

Per X/Open CAE Spec, Issue 5, define 3 preprocessor symbols to be used to
specify the type of socket shutdown(2).


# 1.28 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.27 07-Jan-1998 thorpej

Add the sockcred structure and related definitions, and the SCM_CREDS
control message type.


Revision tags: netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.26 05-May-1997 thorpej

branches: 1.26.8;
Ok, _really_ back out the sockaddr alignment change this time. We can't
reasonably "fix" the compiler "bug" that causes the forced alignment
to fail on certain platforms (e.g. m68k), so we _have_ to solve this
problem a different way.


# 1.25 02-May-1997 thorpej

Align a sockaddr to 4 bytes, not sizeof(long)


# 1.24 02-May-1997 thorpej

Revert the reverting of the last change. Turns out the trouble
on the m68k was a compiler bug (thanks Charles and Christos!)


# 1.23 02-May-1997 thorpej

Revert previous alignment-related change. It caused unexpected problems
on at least one architecture. The alignment issue on the alpha will
be solved in a different way.


# 1.22 02-May-1997 thorpej

Deal with an alignment problem on the Alpha port. The maximum required
alignment of any field in a struct sockaddr is 1, since all members are
chars or char arrays (as noted by Ross Harvey on port-alpha). This causes
the possibility of unaligned access faults when a sockaddr is cast to
e.g. a sockaddr_in. Solution: explicitly direct the compiler to
longword-align the start of a struct sockaddr.


# 1.21 18-Mar-1997 sommerfe

Reserve a place for PF_KEY; rename SIP to INET6


# 1.20 15-Mar-1997 is

Synchronize the CTL_NET_NAMES with the AF_* definitions (ISDN and ARP where
missing).


Revision tags: is-newarp-before-merge is-newarp-base
# 1.19 11-Feb-1997 is

branches: 1.19.4;
Allocate and define AF_ARP and PF_ARP. These will be used to
a) communicate the hardware independent part of ARP packets (rfc826) from/to
if_*subr.c in the ongoing effort to rewrite the ARP subsystem for non-Ethernet
networks
b) communicate the hardware independent part of RARP packets (rfc903) from/to
userland sockets to avoid putting link level header format knowledge into
rarpd, when it is enhanced to support non-Ethernet networks.


# 1.18 11-Jan-1997 thorpej

Implement SO_TIMESTAMP socket option: receive a timeval timestamp
as a control message with a datagram.


# 1.17 04-Jul-1996 chuck

add native mode atm protocol info, also ensure AF number remain sync'd
with freebsd.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-May-1996 neil

Remove #ifdefs

Thanks to cgd@NetBSD.ORG for pointing the following out to me:

listen (fd, SOMAXCONN); would break.

As programs wouldn't see the changes that might be specified in
the kernel config file.

As penance I am going to see if it would be possible to move this
into param.h and provide away of finding out what the kernel
value is. On busy network servers this value is useful to have as a tunable
kernel parameter.


# 1.15 02-May-1996 neil

Add ability to do options SOMAXCONN=n which is useful on
busy network servers.


# 1.14 09-Feb-1996 christos

Filesystem prototype changes


# 1.13 09-Feb-1996 mycroft

Increase SOMAXCONN.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.12 29-Mar-1995 briggs

KERNEL -> _KERNEL


# 1.11 26-Mar-1995 jtc

KERNEL -> _KERNEL


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 13-May-1994 mycroft

Update to 4.4-Lite networking code, with a few local changes.


# 1.7 04-May-1994 mycroft

Move internal prototypes to a better place.


# 1.6 04-May-1994 mycroft

Prototype lots of kernel-internal functions.


Revision tags: nvm-base wnvm magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.5 27-Jun-1993 andrew

branches: 1.5.4;
ANSIfications - lots of function prototyping.


# 1.4 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.3 19-Apr-1993 mycroft

Fix typo.


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.123 01-Jul-2017 christos

put the code that returns the sizeof the socket by family in one place.


Revision tags: netbsd-8-base
# 1.122 27-May-2017 bouyer

merge the bouyer-socketcan branch to HEAD.

CAN stands for Controller Area Network, a broadcast network used
in automation and automotive fields. For example, the NMEA2000 standard
developped for marine devices uses a CAN network as the link layer.

This is an implementation of the linux socketcan API:
https://www.kernel.org/doc/Documentation/networking/can.txt
you can also see can(4).

This adds a new socket family (AF_CAN) and protocol (PF_CAN),
as well as the canconfig(8) utility, used to set timing parameter of
CAN hardware. Also inclued is a driver for the CAN controller
found in the allwinner A20 SoC (I tested it with an Olimex lime2 board,
connected with PIC18-based CAN devices).

There is also the canloop(4) pseudo-device, which allows to use
the socketcan API without CAN hardware.

At this time the CANFD part of the linux socketcan API is not implemented.
Error frames are not implemented either. But I could get the cansend and
canreceive utilities from the canutils package to build and run with minimal
changes. tcpudmp(8) can also be used to record frames, which can be
decoded with etherreal.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.121 08-Feb-2017 maya

Add accept4, a tiny wrapper around paccept.

accept4 is a syscall in Linux, FreeBSD and OpenBSD. It is used in
LLVM, zeromq, and probably others. paccept is a superset of it.

adding it to libc ensures it is used by programs and prevents the
need to define the same wrapper in every program.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.120 21-Sep-2016 roy

branches: 1.120.2;
Add ifam_pid and ifam_addrflags to ifa_msghdr.
Re-version RTM_NEWADDR, RTM_DELADDR, RTM_CHGADDR and NET_RT_IFLIST.
Add compat code for old version.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422
# 1.119 06-Apr-2016 roy

branches: 1.119.2;
Add sc_pid to sockcred so that SOCK_DGRAM and LOCAL_CREDS socket option
can learn the process id of the AF_LOCAL sender.
Add compat glue for old structure.


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.118 13-Oct-2015 rjs

Add core networking support for SCTP.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.117 03-Apr-2015 rtr

* change pr_bind to accept struct sockaddr * instead of struct mbuf *
* update protocol bind implementations to use/expect sockaddr *
instead of mbuf *
* introduce sockaddr_big struct for storage of addr data passed via
sys_bind; sockaddr_big is of sufficient size and alignment to
accommodate all addr data sizes received.
* modify sys_bind to allocate sockaddr_big instead of using an mbuf.
* bump kernel version to 7.99.9 for change to pr_bind() parameter type.

Patch posted to tech-net@
http://mail-index.netbsd.org/tech-net/2015/03/15/msg005004.html

The choice to use a new structure sockaddr_big has been retained since
changing sockaddr_storage size would lead to unnecessary ABI change. The
use of the new structure does not preclude future work that increases
the size of sockaddr_storage and at that time sockaddr_big may be
trivially replaced.

Tested by mrg@ and myself, discussed with rmind@, posted to tech-net@


# 1.116 10-Feb-2015 rjs

Add DCCP protocol support from KAME.


# 1.115 24-Jan-2015 christos

cleanup the CMSG* macro mess.


# 1.114 24-Jan-2015 christos

back to return u_char * according to:
http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/socket.h.html


# 1.113 20-Jan-2015 christos

add void casts to CMSG_


# 1.112 20-Jan-2015 christos

add lint comment


# 1.111 02-Dec-2014 christos

sockaddr_format now returns the number of chars written.


Revision tags: netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.110 28-May-2014 christos

branches: 1.110.4;
CID 976378: Avoid incorrect computation with ngrps == 0


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.109 17-Apr-2014 christos

CID/1203196: Don't confuse coverity with out of bounds access


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 1.108 31-Jan-2013 joerg

branches: 1.108.2; 1.108.10;
Add sockaddr_format to ease debugging code dealing with socket
addresses.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.107 22-Jun-2012 christos

branches: 1.107.2;
Add {send,recv}mmsg from Linux


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.106 29-Jan-2012 roy

Allow using CMSG_NXTHDR with -Wcast-align.

If various checks are omitted, the CMSG_NXTHDR macro expands to
(struct cmsghdr *)((char *)(cmsg) + \
_ALIGN(((struct cmsghdr *)(cmsg))->cmsg_len))

Although there is no alignment problem (assuming cmsg is properly aligned
and _ALIGN is correct), this violates -Wcast-align on strict-alignment
architectures. Therefore an intermediate cast to void * is appropriate here.

There is no workaround other than not using -Wcast-align.

Taken from FreeBSD commit r220742 by jilles


# 1.105 25-Jan-2012 christos

As discussed in tech-kern, provide the means to prevent delivery of SIGPIPE
on EPIPE for all file descriptor types:

- provide O_NOSIGPIPE for open,kqueue1,pipe2,dup3,fcntl(F_{G,S}ETFL) [NetBSD]
- provide SOCK_NOSIGPIPE for socket,socketpair [NetBSD]
- provide SO_NOSIGPIPE for {g,s}seckopt [NetBSD/FreeBSD/MacOSX]
- provide F_{G,S}ETNOSIGPIPE for fcntl [MacOSX]


# 1.104 20-Jan-2012 joerg

Change CMSG_SPACE and CMSG_LEN to provide Integer Constant Expressions
again. This was changed in sys/socket.h r1.51 to work around fallout
from the IPv6 aux data migration. It broke the historic ABI on some
platforms. This commit restores compatibility for netbsd32 code on such
platforms and provides a template for future changes to the CMSG_*
alignment. Revert PCC/Clang workarounds in postfix and tmux.


# 1.103 20-Jan-2012 joerg

CMSG_ALIGN is only for the kernel.


# 1.102 20-Jan-2012 joerg

Don't use __cmsg_alignbytes in the kernel. Mark it as constant function
for userland as its value never changes. This allows the compiler to
optimise most invocations away.


# 1.101 20-Dec-2011 christos

- Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.
- Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis
- Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets.
- Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all
errors?).


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.100 26-Jun-2011 christos

branches: 1.100.2; 1.100.6;
* Arrange for interfaces that create new file descriptors to be able to
set close-on-exec on creation (http://udrepper.livejournal.com/20407.html).

- Add F_DUPFD_CLOEXEC to fcntl(2).
- Add MSG_CMSG_CLOEXEC to recvmsg(2) for unix file descriptor passing.
- Add dup3(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK.
- Add pipe2(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK.
- Add flags SOCK_CLOEXEC, SOCK_NONBLOCK to the socket type parameter
for socket(2) and socketpair(2).
- Add new paccept(2) syscall that takes an additional sigset_t to alter
the sigmask temporarily and a flags argument to set SOCK_CLOEXEC,
SOCK_NONBLOCK.
- Add new mode character 'e' to fopen(3) and popen(3) to open pipes
and file descriptors for close on exec.
- Add new kqueue1(2) syscall with a new flags argument to open the
kqueue file descriptor with O_CLOEXEC, O_NONBLOCK.

* Fix the system calls that take socklen_t arguments to actually do so.

* Don't include userland header files (signal.h) from system header files
(rump_syscallargs.h).

* Bump libc version for the new syscalls.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base rmind-uvmplock-base
# 1.99 01-Feb-2011 matt

Add a new AF/PF_ROUTE which is 64-bit clean which makes the routing socket
interface (and its associated sysctls) act identically for both 32 and 64 bit
programs. The old unclean one remains for backward compatibility.


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.98 26-Jun-2010 kefren

branches: 1.98.2; 1.98.4;
Add MPLS support, proposed on tech-net@ a couple of days ago

Welcome to 5.99.33


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211
# 1.97 05-Dec-2009 pooka

branches: 1.97.2; 1.97.4;
Remove the portalfs kernel file system driver. Replace mount_portal(8)
with a version based on puffs. User functionality remains the same.


Revision tags: yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.96 11-Sep-2009 dyoung

Make ifconfig(8) set and display preference numbers for IPv6
addresses. Make the kernel support SIOC[SG]IFADDRPREF for IPv6
interface addresses.

In in6ifa_ifpforlinklocal(), consult preference numbers before
making an otherwise arbitrary choice of in6_ifaddr. Otherwise,
preference numbers are *not* consulted by the kernel, but that will
be rather easy for somebody with a little bit of free time to fix.

Please note that setting the preference number for a link-local
IPv6 address does not work right, yet, but that ought to be fixed
soon.

In support of the changes above,

1 Add a method to struct domain for "externalizing" a sockaddr, and
provide an implementation for IPv6. Expect more work in this area: it
may be more proper to say that the IPv6 implementation "internalizes"
a sockaddr. Add sockaddr_externalize().

2 Add a subroutine, sofamily(), that returns a struct socket's address
family or AF_UNSPEC.

3 Make a lot of IPv4-specific code generic, and move it from
sys/netinet/ to sys/net/ for re-use by IPv6 parts of the kernel and
ifconfig(8).


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.95 28-Apr-2009 dyoung

Extract sockaddr_any_by_family() from sockaddr_any() for looking up a
wildcard ("any") address by protocol family instead of by sockaddr.


Revision tags: nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base
# 1.94 19-Jan-2009 christos

branches: 1.94.2;
Provide compatibility to the old timeval SCM_TIMESTAMP messages.


Revision tags: mjf-devfs2-base
# 1.93 14-Jan-2009 christos

version the timeout get/set sockopt calls, because they take struct timeval.


# 1.92 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base christos-time_t-nbase netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base christos-time_t-base
# 1.91 04-Aug-2008 tls

branches: 1.91.2;
Add accept filters, ported from FreeBSD by Coyote Point Systems. Add inetd
support for specifying an accept filter for a service (mostly as a usage
example, but it can be handy for other things). Manual pages to follow
in a day or so.

OK core@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.90 15-Jun-2008 christos

branches: 1.90.2;
define AF_80211


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase jmcneill-base mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base vmlocking-base
# 1.89 19-Sep-2007 dyoung

branches: 1.89.16; 1.89.20; 1.89.22; 1.89.24; 1.89.26; 1.89.28; 1.89.30;
1) Introduce a new socket option, (SOL_SOCKET, SO_NOHEADER), that
tells a socket that it should both add a protocol header to tx'd
datagrams and remove the header from rx'd datagrams:

int onoff = 1, s = socket(...);
setsockopt(s, SOL_SOCKET, SO_NOHEADER, &onoff);

2) Add an implementation of (SOL_SOCKET, SO_NOHEADER) for raw IPv4
sockets.

3) Reorganize the protocols' pr_ctloutput implementations a bit.
Consistently return ENOPROTOOPT when an option is unsupported,
and EINVAL if a supported option's arguments are incorrect.
Reorganize the flow of code so that it's more clear how/when
options are passed down the stack until they are handled.

Shorten some pr_ctloutput staircases for readability.

4) Extract common mbuf code into subroutines, add new sockaddr
methods, and introduce a new subroutine, fsocreate(), for reuse
later; use it first in sys_socket():

struct mbuf *m_getsombuf(struct socket *so)

Create an mbuf and make its owner the socket `so'.

struct mbuf *m_intopt(struct socket *so, int val)

Create an mbuf, make its owner the socket `so', put the
int `val' into it, and set its length to sizeof(int).


int fsocreate(..., int *fd)

Create a socket, a la socreate(9), put the socket into the
given LWP's descriptor table, return the descriptor at `fd'
on success.

void *sockaddr_addr(struct sockaddr *sa, socklen_t *slenp)
const void *sockaddr_const_addr(const struct sockaddr *sa, socklen_t *slenp)

Extract a pointer to the address part of a sockaddr. Write
the length of the address part at `slenp', if `slenp' is
not NULL.

socklen_t sockaddr_getlen(const struct sockaddr *sa)

Return the length of a sockaddr. This just evaluates to
sa->sa_len. I only add this for consistency with code that
appears in a portable userland library that I am going to
import.

const struct sockaddr *sockaddr_any(const struct sockaddr *sa)

Return the "don't care" sockaddr in the same family as
`sa'. This is the address a client should sobind(9) if it
does not care the source address and, if applicable, the
port et cetera that it uses.

const void *sockaddr_anyaddr(const struct sockaddr *sa, socklen_t *slenp)

Return the "don't care" sockaddr in the same family as
`sa'. This is the address a client should sobind(9) if it
does not care the source address and, if applicable, the
port et cetera that it uses.


Revision tags: nick-csl-alignment-base5
# 1.88 30-Aug-2007 dyoung

Use malloc(9) for sockaddrs instead of pool(9), and remove dom_sa_pool
and dom_sa_len members from struct domain. Pools of fixed-size
objects are too rigid for sockaddr_dls, whose size can vary over
a wide range.

Return sockaddr_dl to its "historical" size. Now that I'm using
malloc(9) instead of pool(9) to allocate sockaddr_dl, I can create
a sockaddr_dl of any size in the kernel, so expanding sockaddr_dl
is useless.

Avoid using sizeof(struct sockaddr_dl) in the kernel.

Introduce sockaddr_dl_alloc() for allocating & initializing an
arbitrary sockaddr_dl on the heap.

Add an argument, the sockaddr length, to sockaddr_alloc(),
sockaddr_copy(), and sockaddr_dl_setaddr().

Constify: LLADDR() -> CLLADDR().

Where the kernel overwrites LLADDR(), use sockaddr_dl_setaddr(),
instead. Used properly, sockaddr_dl_setaddr() will not overrun
the end of the sockaddr.


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.87 24-Jun-2007 dsl

branches: 1.87.2; 1.87.6; 1.87.8;
Split sys_getpeername() and sys_getsockname() so they can be called when the
'name' is wanted in kernel code.
Similarly split sys_accept() and change the split in recvmsg() so that it
is useful to the compat functions, recvit() is removed and replaced by
do_sys_recvmsg().
Factor out the code that writes socked names to userspace (from mbuf) to
avoid replicated code.
Extract the code that writes socket 'control' (CMSG) data out to userspace,
being more careful about the 'fd' that may exist inside SCM_RIGHTS msgs.
(they still get lost if some of the latter copyout calls fail).
Since these are new functions, and old LKMs will fail to load.


# 1.86 01-Jun-2007 dsl

Split sys_bind() and sys_connect() so that compat code can use common code
once the 'address' has been copied into an mbuf.
Add extra flags for 'struct msghdr.msg_flags' to indicate that the address
and control are already in mbufs, and that the uio structure is in userspace
for sending data, rename sendit() to do_sys_sendmsg() to ensure no old code
passes in random flags.
Changes to compat code to use new functions - removing some stackgap use.
Fix a 'use after free' in compat_43_sys_recvmsg.
I ***THINK*** the code that converts 'cmsg' formatted data is borked!
svr4_stream.c ought to be generated from svr4_32_stream.c during the build.


Revision tags: yamt-idlelwp-base8
# 1.85 02-May-2007 dyoung

Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.

The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.

Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.

DETAILS

1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:

struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);

sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.

sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.

The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).

2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.

3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:

int rtcache_setdst(struct route *, const struct sockaddr *);

rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.

It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.

4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.


Revision tags: thorpej-atomic-base
# 1.84 04-Mar-2007 christos

branches: 1.84.2; 1.84.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.83 20-Feb-2007 plunky

add comment for PF_BLUETOOTH


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 netbsd-4-base rpaulo-netinet-merge-pcb-base
# 1.82 27-Jun-2006 mrg

branches: 1.82.10;
that should be _STANDALONE, not STANDALONE.


# 1.81 26-Jun-2006 mrg

version the socket(2) syscall. for compat30 socket, we use
EPROTONOSUPPORT instead of EAFNOSUPPORT.

from pavel@ with a little bit of clean up from myself.

XXX: netbsd32 (and perhaps other emulations) should be able
XXX: to call the standard socket calls for this i think, but
XXX: revisit this at another time.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase chap-midi-base
# 1.80 19-Jun-2006 gdamore

Initial import of bluetooth stack on behalf of Iain Hibbert. (plunky@,
NetBSD Foundation Membership still pending.) This stack was written by
Iain under sponsorship from Itronix Inc.

The stack includes support for rfcomm networking (networking via your
bluetooth enabled cell phone), hid devices (keyboards/mice), and headsets.

Drivers for both PCMCIA and USB bluetooth controllers are included.


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.79 11-May-2006 christos

branches: 1.79.2; 1.79.4;
Add MSG_NOSIGNAL (from FreeBSD)


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.78 28-Jan-2006 kleink

branches: 1.78.2; 1.78.4; 1.78.6; 1.78.8; 1.78.10;
Since NULL isn't necessarily available, change CMSG_*() to use the
integer constant expression directly instead.

Fixes a problem in the build of rxvt-unicode-7.2, as reported by
Thomas Klausner.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 29-Nov-2005 christos

branches: 1.77.2;
sprinkle const


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.76 24-Sep-2005 christos

branches: 1.76.6;
It is now ``later''. Follow cgd's 1993 wish and move struct osockaddr
and struct omsghdr to a compat header.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.75 09-Mar-2005 tron

branches: 1.75.2; 1.75.4;
Solve problem invented in revision 1.73 differently:
Use "__uint64_t" etc. instead of pulling in "sys/socket.h" to avoid
namespace pollution. Based on comments made by Klaus Klein on the
current-users mailing list.


# 1.74 09-Mar-2005 tron

Include "sys/types.h" to get definition of "uint64_t". This is necessary
because socket(2) lists only "sys/socket.h" as a requirement. And besides
that it fixes build errors in our "libc".


# 1.73 09-Mar-2005 atatat

Add the following nodes to the sysctl tree:

net.local.stream.pcblist
net.local.dgram.pcblist
net.inet.tcp.pcblist
net.inet.udp.pcblist
net.inet.raw.pcblist
net.inet6.tcp6.pcblist
net.inet6.udp6.pcblist
net.inet6.raw6.pcblist

which allow retrieval of the pcbs in use for those protocols. The
struct involved is 32/64 bit clean and incorporates parts of struct
inpcb, struct unpcb, a bit of struct tcpcb, and two socket addresses.


# 1.72 08-Mar-2005 kleink

Fix a (harmless) typo in the definition of PF_RTIP;
from usa@garbagecollect.jp in PR kern/29624.


# 1.71 26-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.70 03-Feb-2005 perry

de-__P


Revision tags: yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Sep-2004 darrenr

branches: 1.69.4; 1.69.6;
add a per-socket counter for dropped UDP packets when the internal buffers
are full.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.68 07-Aug-2003 agc

branches: 1.68.4;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.67 28-Apr-2003 bjh21

branches: 1.67.2;
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.

This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.

I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.

Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.


# 1.66 19-Apr-2003 christos

PR/2845: Mike Schwartz: Allow some #defines to be tuned by kernel options
by protecting them via #ifndef OPTIONNAME


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base thorpej-mips-cache-base kqueue-base
# 1.65 22-Oct-2001 kleink

Sprinkle some __restrict into <sys/socket.h>.


# 1.64 22-Oct-2001 kleink

Add a sockatmark(3), the 1003.1g wrapper around SIOCATMARK.


# 1.63 16-Oct-2001 kleink

Make this capable of being included without pre-requisite headers.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf
# 1.62 07-Sep-2001 itojun

make CMSG_FIRSTHDR() validat emsg_controllen, as suggested in RFC2292.
from kame


Revision tags: thorpej-devvp-base
# 1.61 17-Jul-2001 jdolecek

branches: 1.61.2;
Expel MSG_COMPAT/COMPAT_OLDSOCK, make the COMPAT_43 wrappers
arrange things as needed. Unfortunately, the check in sockargs()
have to stay, since 4.3BSD bind(2), connect(2) and sendto(2) were
not versioned at the time :(

This code was tested to pass regression tests.


# 1.60 05-May-2001 kleink

branches: 1.60.2;
* Replace a couple of cases of u_char and u_short with uint8_t and uint16_t,
respectively.
* Simplify sockaddr_storage calculations a bit by the fact that, per defintion,
sizeof (char) == 1.
Fixes PR standards/10791.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.59 04-Oct-2000 toshii

branches: 1.59.2;
Wrap __cmsg_alignbytes in __BEGIN_DECLS ... __END_DECLS.


# 1.58 28-Jul-2000 kleink

Avoid recursion with traditional cpp.


# 1.57 05-Jul-2000 christos

delint a macro


# 1.56 26-Jun-2000 kleink

XNS5.2: define sa_family_t and use it where specified by the standard.


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.55 04-Jun-2000 itojun

branches: 1.55.2;
move socklen_t decl to sys/ansi.h.
sys/socket.h pulls in sys/ansi.h and declare socklen_t as necessary.
the change is to allow declaration of socklen_t with less inclusion ordering
constraints. (netdb.h needs this change)


Revision tags: minoura-xpg4dl-base
# 1.54 03-Apr-2000 augustss

branches: 1.54.2;
Change #define CMSG_ALIGN so it's not recursive. Now the kernel compiles
again.


# 1.53 03-Apr-2000 itojun

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


# 1.52 28-Mar-2000 simonb

Remove prototype for pfctlinput() - there's already one in
sys/protosw.h with the other pf*() prototypes.


# 1.51 02-Mar-2000 itojun

make CMSG_ALIGN always synchronize with kernel's idea of ALIGNBYTES.
ancillary data alignment will be ALIGNBYTES, not sizeof(long) - 1, from now.

CMSG_xx will NOT resolve into constant. if you use CMSG_xx to allocate
arrays, you'll lose.

bump shlib minor for libc.

NOTE: if you are on top of arch with ALIGNBYTES != sizeof(long) - 1,
you need to recompile IPv6-related binaries. there is no way to guarantee
backward compat in this aspect. sorry for this. this should be the last
backward compat breakage for IPv6-related ancillary data manipulation.
(we still have PR 9516 for unix-domain sockets...)


# 1.50 18-Feb-2000 itojun

fix alignment problem in ancillary messages (alpha).

the change constitutes binary compatibility issue hen sizeof(long) !=4.
there's no way to be backward compatible, and only guys affected
are IPv6 userland tools.

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


Revision tags: chs-ubc2-newbase
# 1.49 03-Feb-2000 enami

Remove duplicated PF_INET6 definition.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.48 20-Dec-1999 itojun

based on recent discussion on ipngwg, use XNET definition for
sockaddr_storage. next revision of RFC2553 will be using this.

ss_len and ss_family are now available for userland programmers.


# 1.47 19-Nov-1999 bouyer

Update protocoles and interfaces stats counters to 64bit.
RTM_IFINFO is now 0xf, 0xe is RTM_OIFINFO which returns the old (if_msghdr14)
struct with 32bit counters (binary compat, conditioned on COMPAT_14).
Same for sysctl: node 3 is renamed NET_RT_OIFLIST, NET_RT_IFLIST is now node 4.
Change rt_msg1() to add an mbuf to the mbuf chain instead of just panic()
when the message is larger than MHLEN.


Revision tags: comdex-fall-1999-base fvdl-softdep-base chs-ubc2-base
# 1.46 03-Jul-1999 kleink

branches: 1.46.2; 1.46.8;
Modify the previous change to:
* not declare struct sockaddr_storage in pre-XNS5.2 D2.0 environments, and
* not use __{BEGIN,END}_DECLS in a _KERNEL environment, which is not necessary.


# 1.45 01-Jul-1999 itojun

avoid void * arithmetic (msg_control is now void *).


# 1.44 01-Jul-1999 itojun

IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.43 11-Feb-1999 cjs

branches: 1.43.4; 1.43.6;
Fix compiler warning.


# 1.42 10-Feb-1999 kleink

* Define socklen_t, an unsigned integral type used to hold the lengths of
socket options, addresses etc., and use it where specified by XNS5.
* Per XNS5, change data pointers types in struct msghdr from caddr_t to void *;
make msg_iovlen a signed int (apparently for consistency with the iovcnt
argument to readv()/writev()).
* Some name space protection.


# 1.41 18-Dec-1998 drochner

solve the COMPAT_OLDSOCK/MSG_COMPAT problem differently:
The source files which need MSG_COMPAT define COMPAT_OLDSOCK.


# 1.40 13-Dec-1998 christos

add include "opt_compat_43.h" otherwise, if this is our only compat option,
we don't link (reported by Klaus Klein).


Revision tags: kenh-if-detach-base
# 1.39 09-Nov-1998 mrg

compat_ultrix wants MSG_COMPAT/COMPAT_OLDSOCK: don't depend on COMPAT_43


Revision tags: chs-ubc-base
# 1.38 05-Sep-1998 kleink

Protect _XOPEN_SOURCE against sysctl MIB identifiers.


Revision tags: eeh-paddr_t-base
# 1.37 26-Jun-1998 hannken

Back out last change. usr.sbin/pstat/pstat.c is wrong.


# 1.36 26-Jun-1998 hannken

Protect '#include "opt_*"' by '#if defined(_KERNEL)' for userland build.


# 1.35 25-Jun-1998 thorpej

defopt COMPAT_HPUX


# 1.34 25-Jun-1998 thorpej

defopt COMPAT_SUNOS


# 1.33 25-Jun-1998 thorpej

defopt COMPAT_LINUX


# 1.32 25-Jun-1998 thorpej

defopt COMPAT_FREEBSD


# 1.31 30-Apr-1998 thorpej

Define a new pseudo-address family, pseudo_AF_HDRCMPLT, which is used by
BPF to tell interface output routines to not fill in the layer 2 source
address. From Greg Smith <greg@nas.nasa.gov>.


# 1.30 25-Apr-1998 matt

Add MSG_MCAST and MSG_BCAST so recvmsg can return how the message was received.


# 1.29 25-Apr-1998 kleink

Per X/Open CAE Spec, Issue 5, define 3 preprocessor symbols to be used to
specify the type of socket shutdown(2).


# 1.28 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.27 07-Jan-1998 thorpej

Add the sockcred structure and related definitions, and the SCM_CREDS
control message type.


Revision tags: netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.26 05-May-1997 thorpej

branches: 1.26.8;
Ok, _really_ back out the sockaddr alignment change this time. We can't
reasonably "fix" the compiler "bug" that causes the forced alignment
to fail on certain platforms (e.g. m68k), so we _have_ to solve this
problem a different way.


# 1.25 02-May-1997 thorpej

Align a sockaddr to 4 bytes, not sizeof(long)


# 1.24 02-May-1997 thorpej

Revert the reverting of the last change. Turns out the trouble
on the m68k was a compiler bug (thanks Charles and Christos!)


# 1.23 02-May-1997 thorpej

Revert previous alignment-related change. It caused unexpected problems
on at least one architecture. The alignment issue on the alpha will
be solved in a different way.


# 1.22 02-May-1997 thorpej

Deal with an alignment problem on the Alpha port. The maximum required
alignment of any field in a struct sockaddr is 1, since all members are
chars or char arrays (as noted by Ross Harvey on port-alpha). This causes
the possibility of unaligned access faults when a sockaddr is cast to
e.g. a sockaddr_in. Solution: explicitly direct the compiler to
longword-align the start of a struct sockaddr.


# 1.21 18-Mar-1997 sommerfe

Reserve a place for PF_KEY; rename SIP to INET6


# 1.20 15-Mar-1997 is

Synchronize the CTL_NET_NAMES with the AF_* definitions (ISDN and ARP where
missing).


Revision tags: is-newarp-before-merge is-newarp-base
# 1.19 11-Feb-1997 is

branches: 1.19.4;
Allocate and define AF_ARP and PF_ARP. These will be used to
a) communicate the hardware independent part of ARP packets (rfc826) from/to
if_*subr.c in the ongoing effort to rewrite the ARP subsystem for non-Ethernet
networks
b) communicate the hardware independent part of RARP packets (rfc903) from/to
userland sockets to avoid putting link level header format knowledge into
rarpd, when it is enhanced to support non-Ethernet networks.


# 1.18 11-Jan-1997 thorpej

Implement SO_TIMESTAMP socket option: receive a timeval timestamp
as a control message with a datagram.


# 1.17 04-Jul-1996 chuck

add native mode atm protocol info, also ensure AF number remain sync'd
with freebsd.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-May-1996 neil

Remove #ifdefs

Thanks to cgd@NetBSD.ORG for pointing the following out to me:

listen (fd, SOMAXCONN); would break.

As programs wouldn't see the changes that might be specified in
the kernel config file.

As penance I am going to see if it would be possible to move this
into param.h and provide away of finding out what the kernel
value is. On busy network servers this value is useful to have as a tunable
kernel parameter.


# 1.15 02-May-1996 neil

Add ability to do options SOMAXCONN=n which is useful on
busy network servers.


# 1.14 09-Feb-1996 christos

Filesystem prototype changes


# 1.13 09-Feb-1996 mycroft

Increase SOMAXCONN.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.12 29-Mar-1995 briggs

KERNEL -> _KERNEL


# 1.11 26-Mar-1995 jtc

KERNEL -> _KERNEL


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 13-May-1994 mycroft

Update to 4.4-Lite networking code, with a few local changes.


# 1.7 04-May-1994 mycroft

Move internal prototypes to a better place.


# 1.6 04-May-1994 mycroft

Prototype lots of kernel-internal functions.


Revision tags: nvm-base wnvm magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.5 27-Jun-1993 andrew

branches: 1.5.4;
ANSIfications - lots of function prototyping.


# 1.4 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.3 19-Apr-1993 mycroft

Fix typo.


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.122 27-May-2017 bouyer

merge the bouyer-socketcan branch to HEAD.

CAN stands for Controller Area Network, a broadcast network used
in automation and automotive fields. For example, the NMEA2000 standard
developped for marine devices uses a CAN network as the link layer.

This is an implementation of the linux socketcan API:
https://www.kernel.org/doc/Documentation/networking/can.txt
you can also see can(4).

This adds a new socket family (AF_CAN) and protocol (PF_CAN),
as well as the canconfig(8) utility, used to set timing parameter of
CAN hardware. Also inclued is a driver for the CAN controller
found in the allwinner A20 SoC (I tested it with an Olimex lime2 board,
connected with PIC18-based CAN devices).

There is also the canloop(4) pseudo-device, which allows to use
the socketcan API without CAN hardware.

At this time the CANFD part of the linux socketcan API is not implemented.
Error frames are not implemented either. But I could get the cansend and
canreceive utilities from the canutils package to build and run with minimal
changes. tcpudmp(8) can also be used to record frames, which can be
decoded with etherreal.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.121 08-Feb-2017 maya

Add accept4, a tiny wrapper around paccept.

accept4 is a syscall in Linux, FreeBSD and OpenBSD. It is used in
LLVM, zeromq, and probably others. paccept is a superset of it.

adding it to libc ensures it is used by programs and prevents the
need to define the same wrapper in every program.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.120 21-Sep-2016 roy

branches: 1.120.2;
Add ifam_pid and ifam_addrflags to ifa_msghdr.
Re-version RTM_NEWADDR, RTM_DELADDR, RTM_CHGADDR and NET_RT_IFLIST.
Add compat code for old version.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422
# 1.119 06-Apr-2016 roy

branches: 1.119.2;
Add sc_pid to sockcred so that SOCK_DGRAM and LOCAL_CREDS socket option
can learn the process id of the AF_LOCAL sender.
Add compat glue for old structure.


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.118 13-Oct-2015 rjs

Add core networking support for SCTP.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.117 03-Apr-2015 rtr

* change pr_bind to accept struct sockaddr * instead of struct mbuf *
* update protocol bind implementations to use/expect sockaddr *
instead of mbuf *
* introduce sockaddr_big struct for storage of addr data passed via
sys_bind; sockaddr_big is of sufficient size and alignment to
accommodate all addr data sizes received.
* modify sys_bind to allocate sockaddr_big instead of using an mbuf.
* bump kernel version to 7.99.9 for change to pr_bind() parameter type.

Patch posted to tech-net@
http://mail-index.netbsd.org/tech-net/2015/03/15/msg005004.html

The choice to use a new structure sockaddr_big has been retained since
changing sockaddr_storage size would lead to unnecessary ABI change. The
use of the new structure does not preclude future work that increases
the size of sockaddr_storage and at that time sockaddr_big may be
trivially replaced.

Tested by mrg@ and myself, discussed with rmind@, posted to tech-net@


# 1.116 10-Feb-2015 rjs

Add DCCP protocol support from KAME.


# 1.115 24-Jan-2015 christos

cleanup the CMSG* macro mess.


# 1.114 24-Jan-2015 christos

back to return u_char * according to:
http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/socket.h.html


# 1.113 20-Jan-2015 christos

add void casts to CMSG_


# 1.112 20-Jan-2015 christos

add lint comment


# 1.111 02-Dec-2014 christos

sockaddr_format now returns the number of chars written.


Revision tags: netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.110 28-May-2014 christos

branches: 1.110.4;
CID 976378: Avoid incorrect computation with ngrps == 0


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.109 17-Apr-2014 christos

CID/1203196: Don't confuse coverity with out of bounds access


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 1.108 31-Jan-2013 joerg

branches: 1.108.2; 1.108.10;
Add sockaddr_format to ease debugging code dealing with socket
addresses.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.107 22-Jun-2012 christos

branches: 1.107.2;
Add {send,recv}mmsg from Linux


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.106 29-Jan-2012 roy

Allow using CMSG_NXTHDR with -Wcast-align.

If various checks are omitted, the CMSG_NXTHDR macro expands to
(struct cmsghdr *)((char *)(cmsg) + \
_ALIGN(((struct cmsghdr *)(cmsg))->cmsg_len))

Although there is no alignment problem (assuming cmsg is properly aligned
and _ALIGN is correct), this violates -Wcast-align on strict-alignment
architectures. Therefore an intermediate cast to void * is appropriate here.

There is no workaround other than not using -Wcast-align.

Taken from FreeBSD commit r220742 by jilles


# 1.105 25-Jan-2012 christos

As discussed in tech-kern, provide the means to prevent delivery of SIGPIPE
on EPIPE for all file descriptor types:

- provide O_NOSIGPIPE for open,kqueue1,pipe2,dup3,fcntl(F_{G,S}ETFL) [NetBSD]
- provide SOCK_NOSIGPIPE for socket,socketpair [NetBSD]
- provide SO_NOSIGPIPE for {g,s}seckopt [NetBSD/FreeBSD/MacOSX]
- provide F_{G,S}ETNOSIGPIPE for fcntl [MacOSX]


# 1.104 20-Jan-2012 joerg

Change CMSG_SPACE and CMSG_LEN to provide Integer Constant Expressions
again. This was changed in sys/socket.h r1.51 to work around fallout
from the IPv6 aux data migration. It broke the historic ABI on some
platforms. This commit restores compatibility for netbsd32 code on such
platforms and provides a template for future changes to the CMSG_*
alignment. Revert PCC/Clang workarounds in postfix and tmux.


# 1.103 20-Jan-2012 joerg

CMSG_ALIGN is only for the kernel.


# 1.102 20-Jan-2012 joerg

Don't use __cmsg_alignbytes in the kernel. Mark it as constant function
for userland as its value never changes. This allows the compiler to
optimise most invocations away.


# 1.101 20-Dec-2011 christos

- Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.
- Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis
- Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets.
- Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all
errors?).


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.100 26-Jun-2011 christos

branches: 1.100.2; 1.100.6;
* Arrange for interfaces that create new file descriptors to be able to
set close-on-exec on creation (http://udrepper.livejournal.com/20407.html).

- Add F_DUPFD_CLOEXEC to fcntl(2).
- Add MSG_CMSG_CLOEXEC to recvmsg(2) for unix file descriptor passing.
- Add dup3(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK.
- Add pipe2(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK.
- Add flags SOCK_CLOEXEC, SOCK_NONBLOCK to the socket type parameter
for socket(2) and socketpair(2).
- Add new paccept(2) syscall that takes an additional sigset_t to alter
the sigmask temporarily and a flags argument to set SOCK_CLOEXEC,
SOCK_NONBLOCK.
- Add new mode character 'e' to fopen(3) and popen(3) to open pipes
and file descriptors for close on exec.
- Add new kqueue1(2) syscall with a new flags argument to open the
kqueue file descriptor with O_CLOEXEC, O_NONBLOCK.

* Fix the system calls that take socklen_t arguments to actually do so.

* Don't include userland header files (signal.h) from system header files
(rump_syscallargs.h).

* Bump libc version for the new syscalls.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base rmind-uvmplock-base
# 1.99 01-Feb-2011 matt

Add a new AF/PF_ROUTE which is 64-bit clean which makes the routing socket
interface (and its associated sysctls) act identically for both 32 and 64 bit
programs. The old unclean one remains for backward compatibility.


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.98 26-Jun-2010 kefren

branches: 1.98.2; 1.98.4;
Add MPLS support, proposed on tech-net@ a couple of days ago

Welcome to 5.99.33


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211
# 1.97 05-Dec-2009 pooka

branches: 1.97.2; 1.97.4;
Remove the portalfs kernel file system driver. Replace mount_portal(8)
with a version based on puffs. User functionality remains the same.


Revision tags: yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.96 11-Sep-2009 dyoung

Make ifconfig(8) set and display preference numbers for IPv6
addresses. Make the kernel support SIOC[SG]IFADDRPREF for IPv6
interface addresses.

In in6ifa_ifpforlinklocal(), consult preference numbers before
making an otherwise arbitrary choice of in6_ifaddr. Otherwise,
preference numbers are *not* consulted by the kernel, but that will
be rather easy for somebody with a little bit of free time to fix.

Please note that setting the preference number for a link-local
IPv6 address does not work right, yet, but that ought to be fixed
soon.

In support of the changes above,

1 Add a method to struct domain for "externalizing" a sockaddr, and
provide an implementation for IPv6. Expect more work in this area: it
may be more proper to say that the IPv6 implementation "internalizes"
a sockaddr. Add sockaddr_externalize().

2 Add a subroutine, sofamily(), that returns a struct socket's address
family or AF_UNSPEC.

3 Make a lot of IPv4-specific code generic, and move it from
sys/netinet/ to sys/net/ for re-use by IPv6 parts of the kernel and
ifconfig(8).


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.95 28-Apr-2009 dyoung

Extract sockaddr_any_by_family() from sockaddr_any() for looking up a
wildcard ("any") address by protocol family instead of by sockaddr.


Revision tags: nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base
# 1.94 19-Jan-2009 christos

branches: 1.94.2;
Provide compatibility to the old timeval SCM_TIMESTAMP messages.


Revision tags: mjf-devfs2-base
# 1.93 14-Jan-2009 christos

version the timeout get/set sockopt calls, because they take struct timeval.


# 1.92 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base christos-time_t-nbase netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base christos-time_t-base
# 1.91 04-Aug-2008 tls

branches: 1.91.2;
Add accept filters, ported from FreeBSD by Coyote Point Systems. Add inetd
support for specifying an accept filter for a service (mostly as a usage
example, but it can be handy for other things). Manual pages to follow
in a day or so.

OK core@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.90 15-Jun-2008 christos

branches: 1.90.2;
define AF_80211


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase jmcneill-base mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base vmlocking-base
# 1.89 19-Sep-2007 dyoung

branches: 1.89.16; 1.89.20; 1.89.22; 1.89.24; 1.89.26; 1.89.28; 1.89.30;
1) Introduce a new socket option, (SOL_SOCKET, SO_NOHEADER), that
tells a socket that it should both add a protocol header to tx'd
datagrams and remove the header from rx'd datagrams:

int onoff = 1, s = socket(...);
setsockopt(s, SOL_SOCKET, SO_NOHEADER, &onoff);

2) Add an implementation of (SOL_SOCKET, SO_NOHEADER) for raw IPv4
sockets.

3) Reorganize the protocols' pr_ctloutput implementations a bit.
Consistently return ENOPROTOOPT when an option is unsupported,
and EINVAL if a supported option's arguments are incorrect.
Reorganize the flow of code so that it's more clear how/when
options are passed down the stack until they are handled.

Shorten some pr_ctloutput staircases for readability.

4) Extract common mbuf code into subroutines, add new sockaddr
methods, and introduce a new subroutine, fsocreate(), for reuse
later; use it first in sys_socket():

struct mbuf *m_getsombuf(struct socket *so)

Create an mbuf and make its owner the socket `so'.

struct mbuf *m_intopt(struct socket *so, int val)

Create an mbuf, make its owner the socket `so', put the
int `val' into it, and set its length to sizeof(int).


int fsocreate(..., int *fd)

Create a socket, a la socreate(9), put the socket into the
given LWP's descriptor table, return the descriptor at `fd'
on success.

void *sockaddr_addr(struct sockaddr *sa, socklen_t *slenp)
const void *sockaddr_const_addr(const struct sockaddr *sa, socklen_t *slenp)

Extract a pointer to the address part of a sockaddr. Write
the length of the address part at `slenp', if `slenp' is
not NULL.

socklen_t sockaddr_getlen(const struct sockaddr *sa)

Return the length of a sockaddr. This just evaluates to
sa->sa_len. I only add this for consistency with code that
appears in a portable userland library that I am going to
import.

const struct sockaddr *sockaddr_any(const struct sockaddr *sa)

Return the "don't care" sockaddr in the same family as
`sa'. This is the address a client should sobind(9) if it
does not care the source address and, if applicable, the
port et cetera that it uses.

const void *sockaddr_anyaddr(const struct sockaddr *sa, socklen_t *slenp)

Return the "don't care" sockaddr in the same family as
`sa'. This is the address a client should sobind(9) if it
does not care the source address and, if applicable, the
port et cetera that it uses.


Revision tags: nick-csl-alignment-base5
# 1.88 30-Aug-2007 dyoung

Use malloc(9) for sockaddrs instead of pool(9), and remove dom_sa_pool
and dom_sa_len members from struct domain. Pools of fixed-size
objects are too rigid for sockaddr_dls, whose size can vary over
a wide range.

Return sockaddr_dl to its "historical" size. Now that I'm using
malloc(9) instead of pool(9) to allocate sockaddr_dl, I can create
a sockaddr_dl of any size in the kernel, so expanding sockaddr_dl
is useless.

Avoid using sizeof(struct sockaddr_dl) in the kernel.

Introduce sockaddr_dl_alloc() for allocating & initializing an
arbitrary sockaddr_dl on the heap.

Add an argument, the sockaddr length, to sockaddr_alloc(),
sockaddr_copy(), and sockaddr_dl_setaddr().

Constify: LLADDR() -> CLLADDR().

Where the kernel overwrites LLADDR(), use sockaddr_dl_setaddr(),
instead. Used properly, sockaddr_dl_setaddr() will not overrun
the end of the sockaddr.


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.87 24-Jun-2007 dsl

branches: 1.87.2; 1.87.6; 1.87.8;
Split sys_getpeername() and sys_getsockname() so they can be called when the
'name' is wanted in kernel code.
Similarly split sys_accept() and change the split in recvmsg() so that it
is useful to the compat functions, recvit() is removed and replaced by
do_sys_recvmsg().
Factor out the code that writes socked names to userspace (from mbuf) to
avoid replicated code.
Extract the code that writes socket 'control' (CMSG) data out to userspace,
being more careful about the 'fd' that may exist inside SCM_RIGHTS msgs.
(they still get lost if some of the latter copyout calls fail).
Since these are new functions, and old LKMs will fail to load.


# 1.86 01-Jun-2007 dsl

Split sys_bind() and sys_connect() so that compat code can use common code
once the 'address' has been copied into an mbuf.
Add extra flags for 'struct msghdr.msg_flags' to indicate that the address
and control are already in mbufs, and that the uio structure is in userspace
for sending data, rename sendit() to do_sys_sendmsg() to ensure no old code
passes in random flags.
Changes to compat code to use new functions - removing some stackgap use.
Fix a 'use after free' in compat_43_sys_recvmsg.
I ***THINK*** the code that converts 'cmsg' formatted data is borked!
svr4_stream.c ought to be generated from svr4_32_stream.c during the build.


Revision tags: yamt-idlelwp-base8
# 1.85 02-May-2007 dyoung

Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.

The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.

Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.

DETAILS

1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:

struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);

sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.

sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.

The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).

2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.

3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:

int rtcache_setdst(struct route *, const struct sockaddr *);

rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.

It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.

4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.


Revision tags: thorpej-atomic-base
# 1.84 04-Mar-2007 christos

branches: 1.84.2; 1.84.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.83 20-Feb-2007 plunky

add comment for PF_BLUETOOTH


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 netbsd-4-base rpaulo-netinet-merge-pcb-base
# 1.82 27-Jun-2006 mrg

branches: 1.82.10;
that should be _STANDALONE, not STANDALONE.


# 1.81 26-Jun-2006 mrg

version the socket(2) syscall. for compat30 socket, we use
EPROTONOSUPPORT instead of EAFNOSUPPORT.

from pavel@ with a little bit of clean up from myself.

XXX: netbsd32 (and perhaps other emulations) should be able
XXX: to call the standard socket calls for this i think, but
XXX: revisit this at another time.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase chap-midi-base
# 1.80 19-Jun-2006 gdamore

Initial import of bluetooth stack on behalf of Iain Hibbert. (plunky@,
NetBSD Foundation Membership still pending.) This stack was written by
Iain under sponsorship from Itronix Inc.

The stack includes support for rfcomm networking (networking via your
bluetooth enabled cell phone), hid devices (keyboards/mice), and headsets.

Drivers for both PCMCIA and USB bluetooth controllers are included.


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.79 11-May-2006 christos

branches: 1.79.2; 1.79.4;
Add MSG_NOSIGNAL (from FreeBSD)


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.78 28-Jan-2006 kleink

branches: 1.78.2; 1.78.4; 1.78.6; 1.78.8; 1.78.10;
Since NULL isn't necessarily available, change CMSG_*() to use the
integer constant expression directly instead.

Fixes a problem in the build of rxvt-unicode-7.2, as reported by
Thomas Klausner.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 29-Nov-2005 christos

branches: 1.77.2;
sprinkle const


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.76 24-Sep-2005 christos

branches: 1.76.6;
It is now ``later''. Follow cgd's 1993 wish and move struct osockaddr
and struct omsghdr to a compat header.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.75 09-Mar-2005 tron

branches: 1.75.2; 1.75.4;
Solve problem invented in revision 1.73 differently:
Use "__uint64_t" etc. instead of pulling in "sys/socket.h" to avoid
namespace pollution. Based on comments made by Klaus Klein on the
current-users mailing list.


# 1.74 09-Mar-2005 tron

Include "sys/types.h" to get definition of "uint64_t". This is necessary
because socket(2) lists only "sys/socket.h" as a requirement. And besides
that it fixes build errors in our "libc".


# 1.73 09-Mar-2005 atatat

Add the following nodes to the sysctl tree:

net.local.stream.pcblist
net.local.dgram.pcblist
net.inet.tcp.pcblist
net.inet.udp.pcblist
net.inet.raw.pcblist
net.inet6.tcp6.pcblist
net.inet6.udp6.pcblist
net.inet6.raw6.pcblist

which allow retrieval of the pcbs in use for those protocols. The
struct involved is 32/64 bit clean and incorporates parts of struct
inpcb, struct unpcb, a bit of struct tcpcb, and two socket addresses.


# 1.72 08-Mar-2005 kleink

Fix a (harmless) typo in the definition of PF_RTIP;
from usa@garbagecollect.jp in PR kern/29624.


# 1.71 26-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.70 03-Feb-2005 perry

de-__P


Revision tags: yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Sep-2004 darrenr

branches: 1.69.4; 1.69.6;
add a per-socket counter for dropped UDP packets when the internal buffers
are full.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.68 07-Aug-2003 agc

branches: 1.68.4;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.67 28-Apr-2003 bjh21

branches: 1.67.2;
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.

This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.

I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.

Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.


# 1.66 19-Apr-2003 christos

PR/2845: Mike Schwartz: Allow some #defines to be tuned by kernel options
by protecting them via #ifndef OPTIONNAME


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base thorpej-mips-cache-base kqueue-base
# 1.65 22-Oct-2001 kleink

Sprinkle some __restrict into <sys/socket.h>.


# 1.64 22-Oct-2001 kleink

Add a sockatmark(3), the 1003.1g wrapper around SIOCATMARK.


# 1.63 16-Oct-2001 kleink

Make this capable of being included without pre-requisite headers.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf
# 1.62 07-Sep-2001 itojun

make CMSG_FIRSTHDR() validat emsg_controllen, as suggested in RFC2292.
from kame


Revision tags: thorpej-devvp-base
# 1.61 17-Jul-2001 jdolecek

branches: 1.61.2;
Expel MSG_COMPAT/COMPAT_OLDSOCK, make the COMPAT_43 wrappers
arrange things as needed. Unfortunately, the check in sockargs()
have to stay, since 4.3BSD bind(2), connect(2) and sendto(2) were
not versioned at the time :(

This code was tested to pass regression tests.


# 1.60 05-May-2001 kleink

branches: 1.60.2;
* Replace a couple of cases of u_char and u_short with uint8_t and uint16_t,
respectively.
* Simplify sockaddr_storage calculations a bit by the fact that, per defintion,
sizeof (char) == 1.
Fixes PR standards/10791.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.59 04-Oct-2000 toshii

branches: 1.59.2;
Wrap __cmsg_alignbytes in __BEGIN_DECLS ... __END_DECLS.


# 1.58 28-Jul-2000 kleink

Avoid recursion with traditional cpp.


# 1.57 05-Jul-2000 christos

delint a macro


# 1.56 26-Jun-2000 kleink

XNS5.2: define sa_family_t and use it where specified by the standard.


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.55 04-Jun-2000 itojun

branches: 1.55.2;
move socklen_t decl to sys/ansi.h.
sys/socket.h pulls in sys/ansi.h and declare socklen_t as necessary.
the change is to allow declaration of socklen_t with less inclusion ordering
constraints. (netdb.h needs this change)


Revision tags: minoura-xpg4dl-base
# 1.54 03-Apr-2000 augustss

branches: 1.54.2;
Change #define CMSG_ALIGN so it's not recursive. Now the kernel compiles
again.


# 1.53 03-Apr-2000 itojun

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


# 1.52 28-Mar-2000 simonb

Remove prototype for pfctlinput() - there's already one in
sys/protosw.h with the other pf*() prototypes.


# 1.51 02-Mar-2000 itojun

make CMSG_ALIGN always synchronize with kernel's idea of ALIGNBYTES.
ancillary data alignment will be ALIGNBYTES, not sizeof(long) - 1, from now.

CMSG_xx will NOT resolve into constant. if you use CMSG_xx to allocate
arrays, you'll lose.

bump shlib minor for libc.

NOTE: if you are on top of arch with ALIGNBYTES != sizeof(long) - 1,
you need to recompile IPv6-related binaries. there is no way to guarantee
backward compat in this aspect. sorry for this. this should be the last
backward compat breakage for IPv6-related ancillary data manipulation.
(we still have PR 9516 for unix-domain sockets...)


# 1.50 18-Feb-2000 itojun

fix alignment problem in ancillary messages (alpha).

the change constitutes binary compatibility issue hen sizeof(long) !=4.
there's no way to be backward compatible, and only guys affected
are IPv6 userland tools.

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


Revision tags: chs-ubc2-newbase
# 1.49 03-Feb-2000 enami

Remove duplicated PF_INET6 definition.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.48 20-Dec-1999 itojun

based on recent discussion on ipngwg, use XNET definition for
sockaddr_storage. next revision of RFC2553 will be using this.

ss_len and ss_family are now available for userland programmers.


# 1.47 19-Nov-1999 bouyer

Update protocoles and interfaces stats counters to 64bit.
RTM_IFINFO is now 0xf, 0xe is RTM_OIFINFO which returns the old (if_msghdr14)
struct with 32bit counters (binary compat, conditioned on COMPAT_14).
Same for sysctl: node 3 is renamed NET_RT_OIFLIST, NET_RT_IFLIST is now node 4.
Change rt_msg1() to add an mbuf to the mbuf chain instead of just panic()
when the message is larger than MHLEN.


Revision tags: comdex-fall-1999-base fvdl-softdep-base chs-ubc2-base
# 1.46 03-Jul-1999 kleink

branches: 1.46.2; 1.46.8;
Modify the previous change to:
* not declare struct sockaddr_storage in pre-XNS5.2 D2.0 environments, and
* not use __{BEGIN,END}_DECLS in a _KERNEL environment, which is not necessary.


# 1.45 01-Jul-1999 itojun

avoid void * arithmetic (msg_control is now void *).


# 1.44 01-Jul-1999 itojun

IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.43 11-Feb-1999 cjs

branches: 1.43.4; 1.43.6;
Fix compiler warning.


# 1.42 10-Feb-1999 kleink

* Define socklen_t, an unsigned integral type used to hold the lengths of
socket options, addresses etc., and use it where specified by XNS5.
* Per XNS5, change data pointers types in struct msghdr from caddr_t to void *;
make msg_iovlen a signed int (apparently for consistency with the iovcnt
argument to readv()/writev()).
* Some name space protection.


# 1.41 18-Dec-1998 drochner

solve the COMPAT_OLDSOCK/MSG_COMPAT problem differently:
The source files which need MSG_COMPAT define COMPAT_OLDSOCK.


# 1.40 13-Dec-1998 christos

add include "opt_compat_43.h" otherwise, if this is our only compat option,
we don't link (reported by Klaus Klein).


Revision tags: kenh-if-detach-base
# 1.39 09-Nov-1998 mrg

compat_ultrix wants MSG_COMPAT/COMPAT_OLDSOCK: don't depend on COMPAT_43


Revision tags: chs-ubc-base
# 1.38 05-Sep-1998 kleink

Protect _XOPEN_SOURCE against sysctl MIB identifiers.


Revision tags: eeh-paddr_t-base
# 1.37 26-Jun-1998 hannken

Back out last change. usr.sbin/pstat/pstat.c is wrong.


# 1.36 26-Jun-1998 hannken

Protect '#include "opt_*"' by '#if defined(_KERNEL)' for userland build.


# 1.35 25-Jun-1998 thorpej

defopt COMPAT_HPUX


# 1.34 25-Jun-1998 thorpej

defopt COMPAT_SUNOS


# 1.33 25-Jun-1998 thorpej

defopt COMPAT_LINUX


# 1.32 25-Jun-1998 thorpej

defopt COMPAT_FREEBSD


# 1.31 30-Apr-1998 thorpej

Define a new pseudo-address family, pseudo_AF_HDRCMPLT, which is used by
BPF to tell interface output routines to not fill in the layer 2 source
address. From Greg Smith <greg@nas.nasa.gov>.


# 1.30 25-Apr-1998 matt

Add MSG_MCAST and MSG_BCAST so recvmsg can return how the message was received.


# 1.29 25-Apr-1998 kleink

Per X/Open CAE Spec, Issue 5, define 3 preprocessor symbols to be used to
specify the type of socket shutdown(2).


# 1.28 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.27 07-Jan-1998 thorpej

Add the sockcred structure and related definitions, and the SCM_CREDS
control message type.


Revision tags: netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.26 05-May-1997 thorpej

branches: 1.26.8;
Ok, _really_ back out the sockaddr alignment change this time. We can't
reasonably "fix" the compiler "bug" that causes the forced alignment
to fail on certain platforms (e.g. m68k), so we _have_ to solve this
problem a different way.


# 1.25 02-May-1997 thorpej

Align a sockaddr to 4 bytes, not sizeof(long)


# 1.24 02-May-1997 thorpej

Revert the reverting of the last change. Turns out the trouble
on the m68k was a compiler bug (thanks Charles and Christos!)


# 1.23 02-May-1997 thorpej

Revert previous alignment-related change. It caused unexpected problems
on at least one architecture. The alignment issue on the alpha will
be solved in a different way.


# 1.22 02-May-1997 thorpej

Deal with an alignment problem on the Alpha port. The maximum required
alignment of any field in a struct sockaddr is 1, since all members are
chars or char arrays (as noted by Ross Harvey on port-alpha). This causes
the possibility of unaligned access faults when a sockaddr is cast to
e.g. a sockaddr_in. Solution: explicitly direct the compiler to
longword-align the start of a struct sockaddr.


# 1.21 18-Mar-1997 sommerfe

Reserve a place for PF_KEY; rename SIP to INET6


# 1.20 15-Mar-1997 is

Synchronize the CTL_NET_NAMES with the AF_* definitions (ISDN and ARP where
missing).


Revision tags: is-newarp-before-merge is-newarp-base
# 1.19 11-Feb-1997 is

branches: 1.19.4;
Allocate and define AF_ARP and PF_ARP. These will be used to
a) communicate the hardware independent part of ARP packets (rfc826) from/to
if_*subr.c in the ongoing effort to rewrite the ARP subsystem for non-Ethernet
networks
b) communicate the hardware independent part of RARP packets (rfc903) from/to
userland sockets to avoid putting link level header format knowledge into
rarpd, when it is enhanced to support non-Ethernet networks.


# 1.18 11-Jan-1997 thorpej

Implement SO_TIMESTAMP socket option: receive a timeval timestamp
as a control message with a datagram.


# 1.17 04-Jul-1996 chuck

add native mode atm protocol info, also ensure AF number remain sync'd
with freebsd.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-May-1996 neil

Remove #ifdefs

Thanks to cgd@NetBSD.ORG for pointing the following out to me:

listen (fd, SOMAXCONN); would break.

As programs wouldn't see the changes that might be specified in
the kernel config file.

As penance I am going to see if it would be possible to move this
into param.h and provide away of finding out what the kernel
value is. On busy network servers this value is useful to have as a tunable
kernel parameter.


# 1.15 02-May-1996 neil

Add ability to do options SOMAXCONN=n which is useful on
busy network servers.


# 1.14 09-Feb-1996 christos

Filesystem prototype changes


# 1.13 09-Feb-1996 mycroft

Increase SOMAXCONN.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.12 29-Mar-1995 briggs

KERNEL -> _KERNEL


# 1.11 26-Mar-1995 jtc

KERNEL -> _KERNEL


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 13-May-1994 mycroft

Update to 4.4-Lite networking code, with a few local changes.


# 1.7 04-May-1994 mycroft

Move internal prototypes to a better place.


# 1.6 04-May-1994 mycroft

Prototype lots of kernel-internal functions.


Revision tags: nvm-base wnvm magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.5 27-Jun-1993 andrew

branches: 1.5.4;
ANSIfications - lots of function prototyping.


# 1.4 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.3 19-Apr-1993 mycroft

Fix typo.


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.121 08-Feb-2017 maya

Add accept4, a tiny wrapper around paccept.

accept4 is a syscall in Linux, FreeBSD and OpenBSD. It is used in
LLVM, zeromq, and probably others. paccept is a superset of it.

adding it to libc ensures it is used by programs and prevents the
need to define the same wrapper in every program.


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.120 21-Sep-2016 roy

branches: 1.120.2;
Add ifam_pid and ifam_addrflags to ifa_msghdr.
Re-version RTM_NEWADDR, RTM_DELADDR, RTM_CHGADDR and NET_RT_IFLIST.
Add compat code for old version.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422
# 1.119 06-Apr-2016 roy

branches: 1.119.2;
Add sc_pid to sockcred so that SOCK_DGRAM and LOCAL_CREDS socket option
can learn the process id of the AF_LOCAL sender.
Add compat glue for old structure.


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.118 13-Oct-2015 rjs

Add core networking support for SCTP.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.117 03-Apr-2015 rtr

* change pr_bind to accept struct sockaddr * instead of struct mbuf *
* update protocol bind implementations to use/expect sockaddr *
instead of mbuf *
* introduce sockaddr_big struct for storage of addr data passed via
sys_bind; sockaddr_big is of sufficient size and alignment to
accommodate all addr data sizes received.
* modify sys_bind to allocate sockaddr_big instead of using an mbuf.
* bump kernel version to 7.99.9 for change to pr_bind() parameter type.

Patch posted to tech-net@
http://mail-index.netbsd.org/tech-net/2015/03/15/msg005004.html

The choice to use a new structure sockaddr_big has been retained since
changing sockaddr_storage size would lead to unnecessary ABI change. The
use of the new structure does not preclude future work that increases
the size of sockaddr_storage and at that time sockaddr_big may be
trivially replaced.

Tested by mrg@ and myself, discussed with rmind@, posted to tech-net@


# 1.116 10-Feb-2015 rjs

Add DCCP protocol support from KAME.


# 1.115 24-Jan-2015 christos

cleanup the CMSG* macro mess.


# 1.114 24-Jan-2015 christos

back to return u_char * according to:
http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/socket.h.html


# 1.113 20-Jan-2015 christos

add void casts to CMSG_


# 1.112 20-Jan-2015 christos

add lint comment


# 1.111 02-Dec-2014 christos

sockaddr_format now returns the number of chars written.


Revision tags: netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.110 28-May-2014 christos

branches: 1.110.4;
CID 976378: Avoid incorrect computation with ngrps == 0


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.109 17-Apr-2014 christos

CID/1203196: Don't confuse coverity with out of bounds access


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 1.108 31-Jan-2013 joerg

branches: 1.108.2; 1.108.10;
Add sockaddr_format to ease debugging code dealing with socket
addresses.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.107 22-Jun-2012 christos

branches: 1.107.2;
Add {send,recv}mmsg from Linux


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.106 29-Jan-2012 roy

Allow using CMSG_NXTHDR with -Wcast-align.

If various checks are omitted, the CMSG_NXTHDR macro expands to
(struct cmsghdr *)((char *)(cmsg) + \
_ALIGN(((struct cmsghdr *)(cmsg))->cmsg_len))

Although there is no alignment problem (assuming cmsg is properly aligned
and _ALIGN is correct), this violates -Wcast-align on strict-alignment
architectures. Therefore an intermediate cast to void * is appropriate here.

There is no workaround other than not using -Wcast-align.

Taken from FreeBSD commit r220742 by jilles


# 1.105 25-Jan-2012 christos

As discussed in tech-kern, provide the means to prevent delivery of SIGPIPE
on EPIPE for all file descriptor types:

- provide O_NOSIGPIPE for open,kqueue1,pipe2,dup3,fcntl(F_{G,S}ETFL) [NetBSD]
- provide SOCK_NOSIGPIPE for socket,socketpair [NetBSD]
- provide SO_NOSIGPIPE for {g,s}seckopt [NetBSD/FreeBSD/MacOSX]
- provide F_{G,S}ETNOSIGPIPE for fcntl [MacOSX]


# 1.104 20-Jan-2012 joerg

Change CMSG_SPACE and CMSG_LEN to provide Integer Constant Expressions
again. This was changed in sys/socket.h r1.51 to work around fallout
from the IPv6 aux data migration. It broke the historic ABI on some
platforms. This commit restores compatibility for netbsd32 code on such
platforms and provides a template for future changes to the CMSG_*
alignment. Revert PCC/Clang workarounds in postfix and tmux.


# 1.103 20-Jan-2012 joerg

CMSG_ALIGN is only for the kernel.


# 1.102 20-Jan-2012 joerg

Don't use __cmsg_alignbytes in the kernel. Mark it as constant function
for userland as its value never changes. This allows the compiler to
optimise most invocations away.


# 1.101 20-Dec-2011 christos

- Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.
- Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis
- Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets.
- Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all
errors?).


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.100 26-Jun-2011 christos

branches: 1.100.2; 1.100.6;
* Arrange for interfaces that create new file descriptors to be able to
set close-on-exec on creation (http://udrepper.livejournal.com/20407.html).

- Add F_DUPFD_CLOEXEC to fcntl(2).
- Add MSG_CMSG_CLOEXEC to recvmsg(2) for unix file descriptor passing.
- Add dup3(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK.
- Add pipe2(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK.
- Add flags SOCK_CLOEXEC, SOCK_NONBLOCK to the socket type parameter
for socket(2) and socketpair(2).
- Add new paccept(2) syscall that takes an additional sigset_t to alter
the sigmask temporarily and a flags argument to set SOCK_CLOEXEC,
SOCK_NONBLOCK.
- Add new mode character 'e' to fopen(3) and popen(3) to open pipes
and file descriptors for close on exec.
- Add new kqueue1(2) syscall with a new flags argument to open the
kqueue file descriptor with O_CLOEXEC, O_NONBLOCK.

* Fix the system calls that take socklen_t arguments to actually do so.

* Don't include userland header files (signal.h) from system header files
(rump_syscallargs.h).

* Bump libc version for the new syscalls.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base rmind-uvmplock-base
# 1.99 01-Feb-2011 matt

Add a new AF/PF_ROUTE which is 64-bit clean which makes the routing socket
interface (and its associated sysctls) act identically for both 32 and 64 bit
programs. The old unclean one remains for backward compatibility.


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.98 26-Jun-2010 kefren

branches: 1.98.2; 1.98.4;
Add MPLS support, proposed on tech-net@ a couple of days ago

Welcome to 5.99.33


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211
# 1.97 05-Dec-2009 pooka

branches: 1.97.2; 1.97.4;
Remove the portalfs kernel file system driver. Replace mount_portal(8)
with a version based on puffs. User functionality remains the same.


Revision tags: yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.96 11-Sep-2009 dyoung

Make ifconfig(8) set and display preference numbers for IPv6
addresses. Make the kernel support SIOC[SG]IFADDRPREF for IPv6
interface addresses.

In in6ifa_ifpforlinklocal(), consult preference numbers before
making an otherwise arbitrary choice of in6_ifaddr. Otherwise,
preference numbers are *not* consulted by the kernel, but that will
be rather easy for somebody with a little bit of free time to fix.

Please note that setting the preference number for a link-local
IPv6 address does not work right, yet, but that ought to be fixed
soon.

In support of the changes above,

1 Add a method to struct domain for "externalizing" a sockaddr, and
provide an implementation for IPv6. Expect more work in this area: it
may be more proper to say that the IPv6 implementation "internalizes"
a sockaddr. Add sockaddr_externalize().

2 Add a subroutine, sofamily(), that returns a struct socket's address
family or AF_UNSPEC.

3 Make a lot of IPv4-specific code generic, and move it from
sys/netinet/ to sys/net/ for re-use by IPv6 parts of the kernel and
ifconfig(8).


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.95 28-Apr-2009 dyoung

Extract sockaddr_any_by_family() from sockaddr_any() for looking up a
wildcard ("any") address by protocol family instead of by sockaddr.


Revision tags: nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base
# 1.94 19-Jan-2009 christos

branches: 1.94.2;
Provide compatibility to the old timeval SCM_TIMESTAMP messages.


Revision tags: mjf-devfs2-base
# 1.93 14-Jan-2009 christos

version the timeout get/set sockopt calls, because they take struct timeval.


# 1.92 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base christos-time_t-nbase netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base christos-time_t-base
# 1.91 04-Aug-2008 tls

branches: 1.91.2;
Add accept filters, ported from FreeBSD by Coyote Point Systems. Add inetd
support for specifying an accept filter for a service (mostly as a usage
example, but it can be handy for other things). Manual pages to follow
in a day or so.

OK core@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.90 15-Jun-2008 christos

branches: 1.90.2;
define AF_80211


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase jmcneill-base mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base vmlocking-base
# 1.89 19-Sep-2007 dyoung

branches: 1.89.16; 1.89.20; 1.89.22; 1.89.24; 1.89.26; 1.89.28; 1.89.30;
1) Introduce a new socket option, (SOL_SOCKET, SO_NOHEADER), that
tells a socket that it should both add a protocol header to tx'd
datagrams and remove the header from rx'd datagrams:

int onoff = 1, s = socket(...);
setsockopt(s, SOL_SOCKET, SO_NOHEADER, &onoff);

2) Add an implementation of (SOL_SOCKET, SO_NOHEADER) for raw IPv4
sockets.

3) Reorganize the protocols' pr_ctloutput implementations a bit.
Consistently return ENOPROTOOPT when an option is unsupported,
and EINVAL if a supported option's arguments are incorrect.
Reorganize the flow of code so that it's more clear how/when
options are passed down the stack until they are handled.

Shorten some pr_ctloutput staircases for readability.

4) Extract common mbuf code into subroutines, add new sockaddr
methods, and introduce a new subroutine, fsocreate(), for reuse
later; use it first in sys_socket():

struct mbuf *m_getsombuf(struct socket *so)

Create an mbuf and make its owner the socket `so'.

struct mbuf *m_intopt(struct socket *so, int val)

Create an mbuf, make its owner the socket `so', put the
int `val' into it, and set its length to sizeof(int).


int fsocreate(..., int *fd)

Create a socket, a la socreate(9), put the socket into the
given LWP's descriptor table, return the descriptor at `fd'
on success.

void *sockaddr_addr(struct sockaddr *sa, socklen_t *slenp)
const void *sockaddr_const_addr(const struct sockaddr *sa, socklen_t *slenp)

Extract a pointer to the address part of a sockaddr. Write
the length of the address part at `slenp', if `slenp' is
not NULL.

socklen_t sockaddr_getlen(const struct sockaddr *sa)

Return the length of a sockaddr. This just evaluates to
sa->sa_len. I only add this for consistency with code that
appears in a portable userland library that I am going to
import.

const struct sockaddr *sockaddr_any(const struct sockaddr *sa)

Return the "don't care" sockaddr in the same family as
`sa'. This is the address a client should sobind(9) if it
does not care the source address and, if applicable, the
port et cetera that it uses.

const void *sockaddr_anyaddr(const struct sockaddr *sa, socklen_t *slenp)

Return the "don't care" sockaddr in the same family as
`sa'. This is the address a client should sobind(9) if it
does not care the source address and, if applicable, the
port et cetera that it uses.


Revision tags: nick-csl-alignment-base5
# 1.88 30-Aug-2007 dyoung

Use malloc(9) for sockaddrs instead of pool(9), and remove dom_sa_pool
and dom_sa_len members from struct domain. Pools of fixed-size
objects are too rigid for sockaddr_dls, whose size can vary over
a wide range.

Return sockaddr_dl to its "historical" size. Now that I'm using
malloc(9) instead of pool(9) to allocate sockaddr_dl, I can create
a sockaddr_dl of any size in the kernel, so expanding sockaddr_dl
is useless.

Avoid using sizeof(struct sockaddr_dl) in the kernel.

Introduce sockaddr_dl_alloc() for allocating & initializing an
arbitrary sockaddr_dl on the heap.

Add an argument, the sockaddr length, to sockaddr_alloc(),
sockaddr_copy(), and sockaddr_dl_setaddr().

Constify: LLADDR() -> CLLADDR().

Where the kernel overwrites LLADDR(), use sockaddr_dl_setaddr(),
instead. Used properly, sockaddr_dl_setaddr() will not overrun
the end of the sockaddr.


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.87 24-Jun-2007 dsl

branches: 1.87.2; 1.87.6; 1.87.8;
Split sys_getpeername() and sys_getsockname() so they can be called when the
'name' is wanted in kernel code.
Similarly split sys_accept() and change the split in recvmsg() so that it
is useful to the compat functions, recvit() is removed and replaced by
do_sys_recvmsg().
Factor out the code that writes socked names to userspace (from mbuf) to
avoid replicated code.
Extract the code that writes socket 'control' (CMSG) data out to userspace,
being more careful about the 'fd' that may exist inside SCM_RIGHTS msgs.
(they still get lost if some of the latter copyout calls fail).
Since these are new functions, and old LKMs will fail to load.


# 1.86 01-Jun-2007 dsl

Split sys_bind() and sys_connect() so that compat code can use common code
once the 'address' has been copied into an mbuf.
Add extra flags for 'struct msghdr.msg_flags' to indicate that the address
and control are already in mbufs, and that the uio structure is in userspace
for sending data, rename sendit() to do_sys_sendmsg() to ensure no old code
passes in random flags.
Changes to compat code to use new functions - removing some stackgap use.
Fix a 'use after free' in compat_43_sys_recvmsg.
I ***THINK*** the code that converts 'cmsg' formatted data is borked!
svr4_stream.c ought to be generated from svr4_32_stream.c during the build.


Revision tags: yamt-idlelwp-base8
# 1.85 02-May-2007 dyoung

Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.

The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.

Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.

DETAILS

1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:

struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);

sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.

sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.

The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).

2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.

3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:

int rtcache_setdst(struct route *, const struct sockaddr *);

rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.

It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.

4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.


Revision tags: thorpej-atomic-base
# 1.84 04-Mar-2007 christos

branches: 1.84.2; 1.84.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.83 20-Feb-2007 plunky

add comment for PF_BLUETOOTH


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 netbsd-4-base rpaulo-netinet-merge-pcb-base
# 1.82 27-Jun-2006 mrg

branches: 1.82.10;
that should be _STANDALONE, not STANDALONE.


# 1.81 26-Jun-2006 mrg

version the socket(2) syscall. for compat30 socket, we use
EPROTONOSUPPORT instead of EAFNOSUPPORT.

from pavel@ with a little bit of clean up from myself.

XXX: netbsd32 (and perhaps other emulations) should be able
XXX: to call the standard socket calls for this i think, but
XXX: revisit this at another time.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase chap-midi-base
# 1.80 19-Jun-2006 gdamore

Initial import of bluetooth stack on behalf of Iain Hibbert. (plunky@,
NetBSD Foundation Membership still pending.) This stack was written by
Iain under sponsorship from Itronix Inc.

The stack includes support for rfcomm networking (networking via your
bluetooth enabled cell phone), hid devices (keyboards/mice), and headsets.

Drivers for both PCMCIA and USB bluetooth controllers are included.


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.79 11-May-2006 christos

branches: 1.79.2; 1.79.4;
Add MSG_NOSIGNAL (from FreeBSD)


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.78 28-Jan-2006 kleink

branches: 1.78.2; 1.78.4; 1.78.6; 1.78.8; 1.78.10;
Since NULL isn't necessarily available, change CMSG_*() to use the
integer constant expression directly instead.

Fixes a problem in the build of rxvt-unicode-7.2, as reported by
Thomas Klausner.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 29-Nov-2005 christos

branches: 1.77.2;
sprinkle const


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.76 24-Sep-2005 christos

branches: 1.76.6;
It is now ``later''. Follow cgd's 1993 wish and move struct osockaddr
and struct omsghdr to a compat header.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.75 09-Mar-2005 tron

branches: 1.75.2; 1.75.4;
Solve problem invented in revision 1.73 differently:
Use "__uint64_t" etc. instead of pulling in "sys/socket.h" to avoid
namespace pollution. Based on comments made by Klaus Klein on the
current-users mailing list.


# 1.74 09-Mar-2005 tron

Include "sys/types.h" to get definition of "uint64_t". This is necessary
because socket(2) lists only "sys/socket.h" as a requirement. And besides
that it fixes build errors in our "libc".


# 1.73 09-Mar-2005 atatat

Add the following nodes to the sysctl tree:

net.local.stream.pcblist
net.local.dgram.pcblist
net.inet.tcp.pcblist
net.inet.udp.pcblist
net.inet.raw.pcblist
net.inet6.tcp6.pcblist
net.inet6.udp6.pcblist
net.inet6.raw6.pcblist

which allow retrieval of the pcbs in use for those protocols. The
struct involved is 32/64 bit clean and incorporates parts of struct
inpcb, struct unpcb, a bit of struct tcpcb, and two socket addresses.


# 1.72 08-Mar-2005 kleink

Fix a (harmless) typo in the definition of PF_RTIP;
from usa@garbagecollect.jp in PR kern/29624.


# 1.71 26-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.70 03-Feb-2005 perry

de-__P


Revision tags: yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Sep-2004 darrenr

branches: 1.69.4; 1.69.6;
add a per-socket counter for dropped UDP packets when the internal buffers
are full.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.68 07-Aug-2003 agc

branches: 1.68.4;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.67 28-Apr-2003 bjh21

branches: 1.67.2;
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.

This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.

I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.

Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.


# 1.66 19-Apr-2003 christos

PR/2845: Mike Schwartz: Allow some #defines to be tuned by kernel options
by protecting them via #ifndef OPTIONNAME


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base thorpej-mips-cache-base kqueue-base
# 1.65 22-Oct-2001 kleink

Sprinkle some __restrict into <sys/socket.h>.


# 1.64 22-Oct-2001 kleink

Add a sockatmark(3), the 1003.1g wrapper around SIOCATMARK.


# 1.63 16-Oct-2001 kleink

Make this capable of being included without pre-requisite headers.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf
# 1.62 07-Sep-2001 itojun

make CMSG_FIRSTHDR() validat emsg_controllen, as suggested in RFC2292.
from kame


Revision tags: thorpej-devvp-base
# 1.61 17-Jul-2001 jdolecek

branches: 1.61.2;
Expel MSG_COMPAT/COMPAT_OLDSOCK, make the COMPAT_43 wrappers
arrange things as needed. Unfortunately, the check in sockargs()
have to stay, since 4.3BSD bind(2), connect(2) and sendto(2) were
not versioned at the time :(

This code was tested to pass regression tests.


# 1.60 05-May-2001 kleink

branches: 1.60.2;
* Replace a couple of cases of u_char and u_short with uint8_t and uint16_t,
respectively.
* Simplify sockaddr_storage calculations a bit by the fact that, per defintion,
sizeof (char) == 1.
Fixes PR standards/10791.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.59 04-Oct-2000 toshii

branches: 1.59.2;
Wrap __cmsg_alignbytes in __BEGIN_DECLS ... __END_DECLS.


# 1.58 28-Jul-2000 kleink

Avoid recursion with traditional cpp.


# 1.57 05-Jul-2000 christos

delint a macro


# 1.56 26-Jun-2000 kleink

XNS5.2: define sa_family_t and use it where specified by the standard.


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.55 04-Jun-2000 itojun

branches: 1.55.2;
move socklen_t decl to sys/ansi.h.
sys/socket.h pulls in sys/ansi.h and declare socklen_t as necessary.
the change is to allow declaration of socklen_t with less inclusion ordering
constraints. (netdb.h needs this change)


Revision tags: minoura-xpg4dl-base
# 1.54 03-Apr-2000 augustss

branches: 1.54.2;
Change #define CMSG_ALIGN so it's not recursive. Now the kernel compiles
again.


# 1.53 03-Apr-2000 itojun

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


# 1.52 28-Mar-2000 simonb

Remove prototype for pfctlinput() - there's already one in
sys/protosw.h with the other pf*() prototypes.


# 1.51 02-Mar-2000 itojun

make CMSG_ALIGN always synchronize with kernel's idea of ALIGNBYTES.
ancillary data alignment will be ALIGNBYTES, not sizeof(long) - 1, from now.

CMSG_xx will NOT resolve into constant. if you use CMSG_xx to allocate
arrays, you'll lose.

bump shlib minor for libc.

NOTE: if you are on top of arch with ALIGNBYTES != sizeof(long) - 1,
you need to recompile IPv6-related binaries. there is no way to guarantee
backward compat in this aspect. sorry for this. this should be the last
backward compat breakage for IPv6-related ancillary data manipulation.
(we still have PR 9516 for unix-domain sockets...)


# 1.50 18-Feb-2000 itojun

fix alignment problem in ancillary messages (alpha).

the change constitutes binary compatibility issue hen sizeof(long) !=4.
there's no way to be backward compatible, and only guys affected
are IPv6 userland tools.

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


Revision tags: chs-ubc2-newbase
# 1.49 03-Feb-2000 enami

Remove duplicated PF_INET6 definition.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.48 20-Dec-1999 itojun

based on recent discussion on ipngwg, use XNET definition for
sockaddr_storage. next revision of RFC2553 will be using this.

ss_len and ss_family are now available for userland programmers.


# 1.47 19-Nov-1999 bouyer

Update protocoles and interfaces stats counters to 64bit.
RTM_IFINFO is now 0xf, 0xe is RTM_OIFINFO which returns the old (if_msghdr14)
struct with 32bit counters (binary compat, conditioned on COMPAT_14).
Same for sysctl: node 3 is renamed NET_RT_OIFLIST, NET_RT_IFLIST is now node 4.
Change rt_msg1() to add an mbuf to the mbuf chain instead of just panic()
when the message is larger than MHLEN.


Revision tags: comdex-fall-1999-base fvdl-softdep-base chs-ubc2-base
# 1.46 03-Jul-1999 kleink

branches: 1.46.2; 1.46.8;
Modify the previous change to:
* not declare struct sockaddr_storage in pre-XNS5.2 D2.0 environments, and
* not use __{BEGIN,END}_DECLS in a _KERNEL environment, which is not necessary.


# 1.45 01-Jul-1999 itojun

avoid void * arithmetic (msg_control is now void *).


# 1.44 01-Jul-1999 itojun

IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.43 11-Feb-1999 cjs

branches: 1.43.4; 1.43.6;
Fix compiler warning.


# 1.42 10-Feb-1999 kleink

* Define socklen_t, an unsigned integral type used to hold the lengths of
socket options, addresses etc., and use it where specified by XNS5.
* Per XNS5, change data pointers types in struct msghdr from caddr_t to void *;
make msg_iovlen a signed int (apparently for consistency with the iovcnt
argument to readv()/writev()).
* Some name space protection.


# 1.41 18-Dec-1998 drochner

solve the COMPAT_OLDSOCK/MSG_COMPAT problem differently:
The source files which need MSG_COMPAT define COMPAT_OLDSOCK.


# 1.40 13-Dec-1998 christos

add include "opt_compat_43.h" otherwise, if this is our only compat option,
we don't link (reported by Klaus Klein).


Revision tags: kenh-if-detach-base
# 1.39 09-Nov-1998 mrg

compat_ultrix wants MSG_COMPAT/COMPAT_OLDSOCK: don't depend on COMPAT_43


Revision tags: chs-ubc-base
# 1.38 05-Sep-1998 kleink

Protect _XOPEN_SOURCE against sysctl MIB identifiers.


Revision tags: eeh-paddr_t-base
# 1.37 26-Jun-1998 hannken

Back out last change. usr.sbin/pstat/pstat.c is wrong.


# 1.36 26-Jun-1998 hannken

Protect '#include "opt_*"' by '#if defined(_KERNEL)' for userland build.


# 1.35 25-Jun-1998 thorpej

defopt COMPAT_HPUX


# 1.34 25-Jun-1998 thorpej

defopt COMPAT_SUNOS


# 1.33 25-Jun-1998 thorpej

defopt COMPAT_LINUX


# 1.32 25-Jun-1998 thorpej

defopt COMPAT_FREEBSD


# 1.31 30-Apr-1998 thorpej

Define a new pseudo-address family, pseudo_AF_HDRCMPLT, which is used by
BPF to tell interface output routines to not fill in the layer 2 source
address. From Greg Smith <greg@nas.nasa.gov>.


# 1.30 25-Apr-1998 matt

Add MSG_MCAST and MSG_BCAST so recvmsg can return how the message was received.


# 1.29 25-Apr-1998 kleink

Per X/Open CAE Spec, Issue 5, define 3 preprocessor symbols to be used to
specify the type of socket shutdown(2).


# 1.28 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.27 07-Jan-1998 thorpej

Add the sockcred structure and related definitions, and the SCM_CREDS
control message type.


Revision tags: netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.26 05-May-1997 thorpej

branches: 1.26.8;
Ok, _really_ back out the sockaddr alignment change this time. We can't
reasonably "fix" the compiler "bug" that causes the forced alignment
to fail on certain platforms (e.g. m68k), so we _have_ to solve this
problem a different way.


# 1.25 02-May-1997 thorpej

Align a sockaddr to 4 bytes, not sizeof(long)


# 1.24 02-May-1997 thorpej

Revert the reverting of the last change. Turns out the trouble
on the m68k was a compiler bug (thanks Charles and Christos!)


# 1.23 02-May-1997 thorpej

Revert previous alignment-related change. It caused unexpected problems
on at least one architecture. The alignment issue on the alpha will
be solved in a different way.


# 1.22 02-May-1997 thorpej

Deal with an alignment problem on the Alpha port. The maximum required
alignment of any field in a struct sockaddr is 1, since all members are
chars or char arrays (as noted by Ross Harvey on port-alpha). This causes
the possibility of unaligned access faults when a sockaddr is cast to
e.g. a sockaddr_in. Solution: explicitly direct the compiler to
longword-align the start of a struct sockaddr.


# 1.21 18-Mar-1997 sommerfe

Reserve a place for PF_KEY; rename SIP to INET6


# 1.20 15-Mar-1997 is

Synchronize the CTL_NET_NAMES with the AF_* definitions (ISDN and ARP where
missing).


Revision tags: is-newarp-before-merge is-newarp-base
# 1.19 11-Feb-1997 is

branches: 1.19.4;
Allocate and define AF_ARP and PF_ARP. These will be used to
a) communicate the hardware independent part of ARP packets (rfc826) from/to
if_*subr.c in the ongoing effort to rewrite the ARP subsystem for non-Ethernet
networks
b) communicate the hardware independent part of RARP packets (rfc903) from/to
userland sockets to avoid putting link level header format knowledge into
rarpd, when it is enhanced to support non-Ethernet networks.


# 1.18 11-Jan-1997 thorpej

Implement SO_TIMESTAMP socket option: receive a timeval timestamp
as a control message with a datagram.


# 1.17 04-Jul-1996 chuck

add native mode atm protocol info, also ensure AF number remain sync'd
with freebsd.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-May-1996 neil

Remove #ifdefs

Thanks to cgd@NetBSD.ORG for pointing the following out to me:

listen (fd, SOMAXCONN); would break.

As programs wouldn't see the changes that might be specified in
the kernel config file.

As penance I am going to see if it would be possible to move this
into param.h and provide away of finding out what the kernel
value is. On busy network servers this value is useful to have as a tunable
kernel parameter.


# 1.15 02-May-1996 neil

Add ability to do options SOMAXCONN=n which is useful on
busy network servers.


# 1.14 09-Feb-1996 christos

Filesystem prototype changes


# 1.13 09-Feb-1996 mycroft

Increase SOMAXCONN.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.12 29-Mar-1995 briggs

KERNEL -> _KERNEL


# 1.11 26-Mar-1995 jtc

KERNEL -> _KERNEL


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 13-May-1994 mycroft

Update to 4.4-Lite networking code, with a few local changes.


# 1.7 04-May-1994 mycroft

Move internal prototypes to a better place.


# 1.6 04-May-1994 mycroft

Prototype lots of kernel-internal functions.


Revision tags: nvm-base wnvm magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.5 27-Jun-1993 andrew

branches: 1.5.4;
ANSIfications - lots of function prototyping.


# 1.4 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.3 19-Apr-1993 mycroft

Fix typo.


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.120 21-Sep-2016 roy

Add ifam_pid and ifam_addrflags to ifa_msghdr.
Re-version RTM_NEWADDR, RTM_DELADDR, RTM_CHGADDR and NET_RT_IFLIST.
Add compat code for old version.


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422
# 1.119 06-Apr-2016 roy

branches: 1.119.2;
Add sc_pid to sockcred so that SOCK_DGRAM and LOCAL_CREDS socket option
can learn the process id of the AF_LOCAL sender.
Add compat glue for old structure.


Revision tags: nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.118 13-Oct-2015 rjs

Add core networking support for SCTP.


Revision tags: nick-nhusb-base-20150921 nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.117 03-Apr-2015 rtr

* change pr_bind to accept struct sockaddr * instead of struct mbuf *
* update protocol bind implementations to use/expect sockaddr *
instead of mbuf *
* introduce sockaddr_big struct for storage of addr data passed via
sys_bind; sockaddr_big is of sufficient size and alignment to
accommodate all addr data sizes received.
* modify sys_bind to allocate sockaddr_big instead of using an mbuf.
* bump kernel version to 7.99.9 for change to pr_bind() parameter type.

Patch posted to tech-net@
http://mail-index.netbsd.org/tech-net/2015/03/15/msg005004.html

The choice to use a new structure sockaddr_big has been retained since
changing sockaddr_storage size would lead to unnecessary ABI change. The
use of the new structure does not preclude future work that increases
the size of sockaddr_storage and at that time sockaddr_big may be
trivially replaced.

Tested by mrg@ and myself, discussed with rmind@, posted to tech-net@


# 1.116 10-Feb-2015 rjs

Add DCCP protocol support from KAME.


# 1.115 24-Jan-2015 christos

cleanup the CMSG* macro mess.


# 1.114 24-Jan-2015 christos

back to return u_char * according to:
http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/socket.h.html


# 1.113 20-Jan-2015 christos

add void casts to CMSG_


# 1.112 20-Jan-2015 christos

add lint comment


# 1.111 02-Dec-2014 christos

sockaddr_format now returns the number of chars written.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.110 28-May-2014 christos

branches: 1.110.4;
CID 976378: Avoid incorrect computation with ngrps == 0


Revision tags: yamt-pagecache-base9 rmind-smpnet-nbase rmind-smpnet-base
# 1.109 17-Apr-2014 christos

CID/1203196: Don't confuse coverity with out of bounds access


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 1.108 31-Jan-2013 joerg

branches: 1.108.2; 1.108.10;
Add sockaddr_format to ease debugging code dealing with socket
addresses.


Revision tags: yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.107 22-Jun-2012 christos

branches: 1.107.2;
Add {send,recv}mmsg from Linux


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.106 29-Jan-2012 roy

Allow using CMSG_NXTHDR with -Wcast-align.

If various checks are omitted, the CMSG_NXTHDR macro expands to
(struct cmsghdr *)((char *)(cmsg) + \
_ALIGN(((struct cmsghdr *)(cmsg))->cmsg_len))

Although there is no alignment problem (assuming cmsg is properly aligned
and _ALIGN is correct), this violates -Wcast-align on strict-alignment
architectures. Therefore an intermediate cast to void * is appropriate here.

There is no workaround other than not using -Wcast-align.

Taken from FreeBSD commit r220742 by jilles


# 1.105 25-Jan-2012 christos

As discussed in tech-kern, provide the means to prevent delivery of SIGPIPE
on EPIPE for all file descriptor types:

- provide O_NOSIGPIPE for open,kqueue1,pipe2,dup3,fcntl(F_{G,S}ETFL) [NetBSD]
- provide SOCK_NOSIGPIPE for socket,socketpair [NetBSD]
- provide SO_NOSIGPIPE for {g,s}seckopt [NetBSD/FreeBSD/MacOSX]
- provide F_{G,S}ETNOSIGPIPE for fcntl [MacOSX]


# 1.104 20-Jan-2012 joerg

Change CMSG_SPACE and CMSG_LEN to provide Integer Constant Expressions
again. This was changed in sys/socket.h r1.51 to work around fallout
from the IPv6 aux data migration. It broke the historic ABI on some
platforms. This commit restores compatibility for netbsd32 code on such
platforms and provides a template for future changes to the CMSG_*
alignment. Revert PCC/Clang workarounds in postfix and tmux.


# 1.103 20-Jan-2012 joerg

CMSG_ALIGN is only for the kernel.


# 1.102 20-Jan-2012 joerg

Don't use __cmsg_alignbytes in the kernel. Mark it as constant function
for userland as its value never changes. This allows the compiler to
optimise most invocations away.


# 1.101 20-Dec-2011 christos

- Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.
- Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis
- Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets.
- Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all
errors?).


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.100 26-Jun-2011 christos

branches: 1.100.2; 1.100.6;
* Arrange for interfaces that create new file descriptors to be able to
set close-on-exec on creation (http://udrepper.livejournal.com/20407.html).

- Add F_DUPFD_CLOEXEC to fcntl(2).
- Add MSG_CMSG_CLOEXEC to recvmsg(2) for unix file descriptor passing.
- Add dup3(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK.
- Add pipe2(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK.
- Add flags SOCK_CLOEXEC, SOCK_NONBLOCK to the socket type parameter
for socket(2) and socketpair(2).
- Add new paccept(2) syscall that takes an additional sigset_t to alter
the sigmask temporarily and a flags argument to set SOCK_CLOEXEC,
SOCK_NONBLOCK.
- Add new mode character 'e' to fopen(3) and popen(3) to open pipes
and file descriptors for close on exec.
- Add new kqueue1(2) syscall with a new flags argument to open the
kqueue file descriptor with O_CLOEXEC, O_NONBLOCK.

* Fix the system calls that take socklen_t arguments to actually do so.

* Don't include userland header files (signal.h) from system header files
(rump_syscallargs.h).

* Bump libc version for the new syscalls.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base uebayasi-xip-base7 bouyer-quota2-nbase bouyer-quota2-base rmind-uvmplock-base
# 1.99 01-Feb-2011 matt

Add a new AF/PF_ROUTE which is 64-bit clean which makes the routing socket
interface (and its associated sysctls) act identically for both 32 and 64 bit
programs. The old unclean one remains for backward compatibility.


Revision tags: jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.98 26-Jun-2010 kefren

branches: 1.98.2; 1.98.4;
Add MPLS support, proposed on tech-net@ a couple of days ago

Welcome to 5.99.33


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211
# 1.97 05-Dec-2009 pooka

branches: 1.97.2; 1.97.4;
Remove the portalfs kernel file system driver. Replace mount_portal(8)
with a version based on puffs. User functionality remains the same.


Revision tags: yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.96 11-Sep-2009 dyoung

Make ifconfig(8) set and display preference numbers for IPv6
addresses. Make the kernel support SIOC[SG]IFADDRPREF for IPv6
interface addresses.

In in6ifa_ifpforlinklocal(), consult preference numbers before
making an otherwise arbitrary choice of in6_ifaddr. Otherwise,
preference numbers are *not* consulted by the kernel, but that will
be rather easy for somebody with a little bit of free time to fix.

Please note that setting the preference number for a link-local
IPv6 address does not work right, yet, but that ought to be fixed
soon.

In support of the changes above,

1 Add a method to struct domain for "externalizing" a sockaddr, and
provide an implementation for IPv6. Expect more work in this area: it
may be more proper to say that the IPv6 implementation "internalizes"
a sockaddr. Add sockaddr_externalize().

2 Add a subroutine, sofamily(), that returns a struct socket's address
family or AF_UNSPEC.

3 Make a lot of IPv4-specific code generic, and move it from
sys/netinet/ to sys/net/ for re-use by IPv6 parts of the kernel and
ifconfig(8).


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 jym-xensuspend-base
# 1.95 28-Apr-2009 dyoung

Extract sockaddr_any_by_family() from sockaddr_any() for looking up a
wildcard ("any") address by protocol family instead of by sockaddr.


Revision tags: nick-hppapmap-base3 nick-hppapmap-base2 nick-hppapmap-base
# 1.94 19-Jan-2009 christos

branches: 1.94.2;
Provide compatibility to the old timeval SCM_TIMESTAMP messages.


Revision tags: mjf-devfs2-base
# 1.93 14-Jan-2009 christos

version the timeout get/set sockopt calls, because they take struct timeval.


# 1.92 11-Jan-2009 christos

merge christos-time_t


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base christos-time_t-nbase netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 haad-dm-base christos-time_t-base
# 1.91 04-Aug-2008 tls

branches: 1.91.2;
Add accept filters, ported from FreeBSD by Coyote Point Systems. Add inetd
support for specifying an accept filter for a service (mostly as a usage
example, but it can be handy for other things). Manual pages to follow
in a day or so.

OK core@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base wrstuden-revivesa-base
# 1.90 15-Jun-2008 christos

branches: 1.90.2;
define AF_80211


Revision tags: yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase jmcneill-base mjf-devfs-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base vmlocking-base
# 1.89 19-Sep-2007 dyoung

branches: 1.89.16; 1.89.20; 1.89.22; 1.89.24; 1.89.26; 1.89.28; 1.89.30;
1) Introduce a new socket option, (SOL_SOCKET, SO_NOHEADER), that
tells a socket that it should both add a protocol header to tx'd
datagrams and remove the header from rx'd datagrams:

int onoff = 1, s = socket(...);
setsockopt(s, SOL_SOCKET, SO_NOHEADER, &onoff);

2) Add an implementation of (SOL_SOCKET, SO_NOHEADER) for raw IPv4
sockets.

3) Reorganize the protocols' pr_ctloutput implementations a bit.
Consistently return ENOPROTOOPT when an option is unsupported,
and EINVAL if a supported option's arguments are incorrect.
Reorganize the flow of code so that it's more clear how/when
options are passed down the stack until they are handled.

Shorten some pr_ctloutput staircases for readability.

4) Extract common mbuf code into subroutines, add new sockaddr
methods, and introduce a new subroutine, fsocreate(), for reuse
later; use it first in sys_socket():

struct mbuf *m_getsombuf(struct socket *so)

Create an mbuf and make its owner the socket `so'.

struct mbuf *m_intopt(struct socket *so, int val)

Create an mbuf, make its owner the socket `so', put the
int `val' into it, and set its length to sizeof(int).


int fsocreate(..., int *fd)

Create a socket, a la socreate(9), put the socket into the
given LWP's descriptor table, return the descriptor at `fd'
on success.

void *sockaddr_addr(struct sockaddr *sa, socklen_t *slenp)
const void *sockaddr_const_addr(const struct sockaddr *sa, socklen_t *slenp)

Extract a pointer to the address part of a sockaddr. Write
the length of the address part at `slenp', if `slenp' is
not NULL.

socklen_t sockaddr_getlen(const struct sockaddr *sa)

Return the length of a sockaddr. This just evaluates to
sa->sa_len. I only add this for consistency with code that
appears in a portable userland library that I am going to
import.

const struct sockaddr *sockaddr_any(const struct sockaddr *sa)

Return the "don't care" sockaddr in the same family as
`sa'. This is the address a client should sobind(9) if it
does not care the source address and, if applicable, the
port et cetera that it uses.

const void *sockaddr_anyaddr(const struct sockaddr *sa, socklen_t *slenp)

Return the "don't care" sockaddr in the same family as
`sa'. This is the address a client should sobind(9) if it
does not care the source address and, if applicable, the
port et cetera that it uses.


Revision tags: nick-csl-alignment-base5
# 1.88 30-Aug-2007 dyoung

Use malloc(9) for sockaddrs instead of pool(9), and remove dom_sa_pool
and dom_sa_len members from struct domain. Pools of fixed-size
objects are too rigid for sockaddr_dls, whose size can vary over
a wide range.

Return sockaddr_dl to its "historical" size. Now that I'm using
malloc(9) instead of pool(9) to allocate sockaddr_dl, I can create
a sockaddr_dl of any size in the kernel, so expanding sockaddr_dl
is useless.

Avoid using sizeof(struct sockaddr_dl) in the kernel.

Introduce sockaddr_dl_alloc() for allocating & initializing an
arbitrary sockaddr_dl on the heap.

Add an argument, the sockaddr length, to sockaddr_alloc(),
sockaddr_copy(), and sockaddr_dl_setaddr().

Constify: LLADDR() -> CLLADDR().

Where the kernel overwrites LLADDR(), use sockaddr_dl_setaddr(),
instead. Used properly, sockaddr_dl_setaddr() will not overrun
the end of the sockaddr.


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.87 24-Jun-2007 dsl

branches: 1.87.2; 1.87.6; 1.87.8;
Split sys_getpeername() and sys_getsockname() so they can be called when the
'name' is wanted in kernel code.
Similarly split sys_accept() and change the split in recvmsg() so that it
is useful to the compat functions, recvit() is removed and replaced by
do_sys_recvmsg().
Factor out the code that writes socked names to userspace (from mbuf) to
avoid replicated code.
Extract the code that writes socket 'control' (CMSG) data out to userspace,
being more careful about the 'fd' that may exist inside SCM_RIGHTS msgs.
(they still get lost if some of the latter copyout calls fail).
Since these are new functions, and old LKMs will fail to load.


# 1.86 01-Jun-2007 dsl

Split sys_bind() and sys_connect() so that compat code can use common code
once the 'address' has been copied into an mbuf.
Add extra flags for 'struct msghdr.msg_flags' to indicate that the address
and control are already in mbufs, and that the uio structure is in userspace
for sending data, rename sendit() to do_sys_sendmsg() to ensure no old code
passes in random flags.
Changes to compat code to use new functions - removing some stackgap use.
Fix a 'use after free' in compat_43_sys_recvmsg.
I ***THINK*** the code that converts 'cmsg' formatted data is borked!
svr4_stream.c ought to be generated from svr4_32_stream.c during the build.


Revision tags: yamt-idlelwp-base8
# 1.85 02-May-2007 dyoung

Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.

The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.

Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.

DETAILS

1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:

struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);

sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.

sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.

The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).

2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.

3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:

int rtcache_setdst(struct route *, const struct sockaddr *);

rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.

It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.

4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.


Revision tags: thorpej-atomic-base
# 1.84 04-Mar-2007 christos

branches: 1.84.2; 1.84.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: ad-audiomp-base
# 1.83 20-Feb-2007 plunky

add comment for PF_BLUETOOTH


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 abandoned-netbsd-4-base yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 newlock2-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 netbsd-4-base rpaulo-netinet-merge-pcb-base
# 1.82 27-Jun-2006 mrg

branches: 1.82.10;
that should be _STANDALONE, not STANDALONE.


# 1.81 26-Jun-2006 mrg

version the socket(2) syscall. for compat30 socket, we use
EPROTONOSUPPORT instead of EAFNOSUPPORT.

from pavel@ with a little bit of clean up from myself.

XXX: netbsd32 (and perhaps other emulations) should be able
XXX: to call the standard socket calls for this i think, but
XXX: revisit this at another time.


Revision tags: yamt-pdpolicy-base6 chap-midi-nbase chap-midi-base
# 1.80 19-Jun-2006 gdamore

Initial import of bluetooth stack on behalf of Iain Hibbert. (plunky@,
NetBSD Foundation Membership still pending.) This stack was written by
Iain under sponsorship from Itronix Inc.

The stack includes support for rfcomm networking (networking via your
bluetooth enabled cell phone), hid devices (keyboards/mice), and headsets.

Drivers for both PCMCIA and USB bluetooth controllers are included.


Revision tags: gdamore-uart-base yamt-pdpolicy-base5 elad-kernelauth-base simonb-timecounters-base
# 1.79 11-May-2006 christos

branches: 1.79.2; 1.79.4;
Add MSG_NOSIGNAL (from FreeBSD)


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.78 28-Jan-2006 kleink

branches: 1.78.2; 1.78.4; 1.78.6; 1.78.8; 1.78.10;
Since NULL isn't necessarily available, change CMSG_*() to use the
integer constant expression directly instead.

Fixes a problem in the build of rxvt-unicode-7.2, as reported by
Thomas Klausner.


Revision tags: yamt-readahead-base3 ktrace-lwp-base
# 1.77 29-Nov-2005 christos

branches: 1.77.2;
sprinkle const


Revision tags: yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base
# 1.76 24-Sep-2005 christos

branches: 1.76.6;
It is now ``later''. Follow cgd's 1993 wish and move struct osockaddr
and struct omsghdr to a compat header.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.75 09-Mar-2005 tron

branches: 1.75.2; 1.75.4;
Solve problem invented in revision 1.73 differently:
Use "__uint64_t" etc. instead of pulling in "sys/socket.h" to avoid
namespace pollution. Based on comments made by Klaus Klein on the
current-users mailing list.


# 1.74 09-Mar-2005 tron

Include "sys/types.h" to get definition of "uint64_t". This is necessary
because socket(2) lists only "sys/socket.h" as a requirement. And besides
that it fixes build errors in our "libc".


# 1.73 09-Mar-2005 atatat

Add the following nodes to the sysctl tree:

net.local.stream.pcblist
net.local.dgram.pcblist
net.inet.tcp.pcblist
net.inet.udp.pcblist
net.inet.raw.pcblist
net.inet6.tcp6.pcblist
net.inet6.udp6.pcblist
net.inet6.raw6.pcblist

which allow retrieval of the pcbs in use for those protocols. The
struct involved is 32/64 bit clean and incorporates parts of struct
inpcb, struct unpcb, a bit of struct tcpcb, and two socket addresses.


# 1.72 08-Mar-2005 kleink

Fix a (harmless) typo in the definition of PF_RTIP;
from usa@garbagecollect.jp in PR kern/29624.


# 1.71 26-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.70 03-Feb-2005 perry

de-__P


Revision tags: yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.69 03-Sep-2004 darrenr

branches: 1.69.4; 1.69.6;
add a per-socket counter for dropped UDP packets when the internal buffers
are full.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.68 07-Aug-2003 agc

branches: 1.68.4;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.67 28-Apr-2003 bjh21

branches: 1.67.2;
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.

This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.

I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.

Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.


# 1.66 19-Apr-2003 christos

PR/2845: Mike Schwartz: Allow some #defines to be tuned by kernel options
by protecting them via #ifndef OPTIONNAME


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base thorpej-mips-cache-base kqueue-base
# 1.65 22-Oct-2001 kleink

Sprinkle some __restrict into <sys/socket.h>.


# 1.64 22-Oct-2001 kleink

Add a sockatmark(3), the 1003.1g wrapper around SIOCATMARK.


# 1.63 16-Oct-2001 kleink

Make this capable of being included without pre-requisite headers.


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf
# 1.62 07-Sep-2001 itojun

make CMSG_FIRSTHDR() validat emsg_controllen, as suggested in RFC2292.
from kame


Revision tags: thorpej-devvp-base
# 1.61 17-Jul-2001 jdolecek

branches: 1.61.2;
Expel MSG_COMPAT/COMPAT_OLDSOCK, make the COMPAT_43 wrappers
arrange things as needed. Unfortunately, the check in sockargs()
have to stay, since 4.3BSD bind(2), connect(2) and sendto(2) were
not versioned at the time :(

This code was tested to pass regression tests.


# 1.60 05-May-2001 kleink

branches: 1.60.2;
* Replace a couple of cases of u_char and u_short with uint8_t and uint16_t,
respectively.
* Simplify sockaddr_storage calculations a bit by the fact that, per defintion,
sizeof (char) == 1.
Fixes PR standards/10791.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.59 04-Oct-2000 toshii

branches: 1.59.2;
Wrap __cmsg_alignbytes in __BEGIN_DECLS ... __END_DECLS.


# 1.58 28-Jul-2000 kleink

Avoid recursion with traditional cpp.


# 1.57 05-Jul-2000 christos

delint a macro


# 1.56 26-Jun-2000 kleink

XNS5.2: define sa_family_t and use it where specified by the standard.


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base
# 1.55 04-Jun-2000 itojun

branches: 1.55.2;
move socklen_t decl to sys/ansi.h.
sys/socket.h pulls in sys/ansi.h and declare socklen_t as necessary.
the change is to allow declaration of socklen_t with less inclusion ordering
constraints. (netdb.h needs this change)


Revision tags: minoura-xpg4dl-base
# 1.54 03-Apr-2000 augustss

branches: 1.54.2;
Change #define CMSG_ALIGN so it's not recursive. Now the kernel compiles
again.


# 1.53 03-Apr-2000 itojun

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


# 1.52 28-Mar-2000 simonb

Remove prototype for pfctlinput() - there's already one in
sys/protosw.h with the other pf*() prototypes.


# 1.51 02-Mar-2000 itojun

make CMSG_ALIGN always synchronize with kernel's idea of ALIGNBYTES.
ancillary data alignment will be ALIGNBYTES, not sizeof(long) - 1, from now.

CMSG_xx will NOT resolve into constant. if you use CMSG_xx to allocate
arrays, you'll lose.

bump shlib minor for libc.

NOTE: if you are on top of arch with ALIGNBYTES != sizeof(long) - 1,
you need to recompile IPv6-related binaries. there is no way to guarantee
backward compat in this aspect. sorry for this. this should be the last
backward compat breakage for IPv6-related ancillary data manipulation.
(we still have PR 9516 for unix-domain sockets...)


# 1.50 18-Feb-2000 itojun

fix alignment problem in ancillary messages (alpha).

the change constitutes binary compatibility issue hen sizeof(long) !=4.
there's no way to be backward compatible, and only guys affected
are IPv6 userland tools.

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


Revision tags: chs-ubc2-newbase
# 1.49 03-Feb-2000 enami

Remove duplicated PF_INET6 definition.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.48 20-Dec-1999 itojun

based on recent discussion on ipngwg, use XNET definition for
sockaddr_storage. next revision of RFC2553 will be using this.

ss_len and ss_family are now available for userland programmers.


# 1.47 19-Nov-1999 bouyer

Update protocoles and interfaces stats counters to 64bit.
RTM_IFINFO is now 0xf, 0xe is RTM_OIFINFO which returns the old (if_msghdr14)
struct with 32bit counters (binary compat, conditioned on COMPAT_14).
Same for sysctl: node 3 is renamed NET_RT_OIFLIST, NET_RT_IFLIST is now node 4.
Change rt_msg1() to add an mbuf to the mbuf chain instead of just panic()
when the message is larger than MHLEN.


Revision tags: comdex-fall-1999-base fvdl-softdep-base chs-ubc2-base
# 1.46 03-Jul-1999 kleink

branches: 1.46.2; 1.46.8;
Modify the previous change to:
* not declare struct sockaddr_storage in pre-XNS5.2 D2.0 environments, and
* not use __{BEGIN,END}_DECLS in a _KERNEL environment, which is not necessary.


# 1.45 01-Jul-1999 itojun

avoid void * arithmetic (msg_control is now void *).


# 1.44 01-Jul-1999 itojun

IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.43 11-Feb-1999 cjs

branches: 1.43.4; 1.43.6;
Fix compiler warning.


# 1.42 10-Feb-1999 kleink

* Define socklen_t, an unsigned integral type used to hold the lengths of
socket options, addresses etc., and use it where specified by XNS5.
* Per XNS5, change data pointers types in struct msghdr from caddr_t to void *;
make msg_iovlen a signed int (apparently for consistency with the iovcnt
argument to readv()/writev()).
* Some name space protection.


# 1.41 18-Dec-1998 drochner

solve the COMPAT_OLDSOCK/MSG_COMPAT problem differently:
The source files which need MSG_COMPAT define COMPAT_OLDSOCK.


# 1.40 13-Dec-1998 christos

add include "opt_compat_43.h" otherwise, if this is our only compat option,
we don't link (reported by Klaus Klein).


Revision tags: kenh-if-detach-base
# 1.39 09-Nov-1998 mrg

compat_ultrix wants MSG_COMPAT/COMPAT_OLDSOCK: don't depend on COMPAT_43


Revision tags: chs-ubc-base
# 1.38 05-Sep-1998 kleink

Protect _XOPEN_SOURCE against sysctl MIB identifiers.


Revision tags: eeh-paddr_t-base
# 1.37 26-Jun-1998 hannken

Back out last change. usr.sbin/pstat/pstat.c is wrong.


# 1.36 26-Jun-1998 hannken

Protect '#include "opt_*"' by '#if defined(_KERNEL)' for userland build.


# 1.35 25-Jun-1998 thorpej

defopt COMPAT_HPUX


# 1.34 25-Jun-1998 thorpej

defopt COMPAT_SUNOS


# 1.33 25-Jun-1998 thorpej

defopt COMPAT_LINUX


# 1.32 25-Jun-1998 thorpej

defopt COMPAT_FREEBSD


# 1.31 30-Apr-1998 thorpej

Define a new pseudo-address family, pseudo_AF_HDRCMPLT, which is used by
BPF to tell interface output routines to not fill in the layer 2 source
address. From Greg Smith <greg@nas.nasa.gov>.


# 1.30 25-Apr-1998 matt

Add MSG_MCAST and MSG_BCAST so recvmsg can return how the message was received.


# 1.29 25-Apr-1998 kleink

Per X/Open CAE Spec, Issue 5, define 3 preprocessor symbols to be used to
specify the type of socket shutdown(2).


# 1.28 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.27 07-Jan-1998 thorpej

Add the sockcred structure and related definitions, and the SCM_CREDS
control message type.


Revision tags: netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.26 05-May-1997 thorpej

branches: 1.26.8;
Ok, _really_ back out the sockaddr alignment change this time. We can't
reasonably "fix" the compiler "bug" that causes the forced alignment
to fail on certain platforms (e.g. m68k), so we _have_ to solve this
problem a different way.


# 1.25 02-May-1997 thorpej

Align a sockaddr to 4 bytes, not sizeof(long)


# 1.24 02-May-1997 thorpej

Revert the reverting of the last change. Turns out the trouble
on the m68k was a compiler bug (thanks Charles and Christos!)


# 1.23 02-May-1997 thorpej

Revert previous alignment-related change. It caused unexpected problems
on at least one architecture. The alignment issue on the alpha will
be solved in a different way.


# 1.22 02-May-1997 thorpej

Deal with an alignment problem on the Alpha port. The maximum required
alignment of any field in a struct sockaddr is 1, since all members are
chars or char arrays (as noted by Ross Harvey on port-alpha). This causes
the possibility of unaligned access faults when a sockaddr is cast to
e.g. a sockaddr_in. Solution: explicitly direct the compiler to
longword-align the start of a struct sockaddr.


# 1.21 18-Mar-1997 sommerfe

Reserve a place for PF_KEY; rename SIP to INET6


# 1.20 15-Mar-1997 is

Synchronize the CTL_NET_NAMES with the AF_* definitions (ISDN and ARP where
missing).


Revision tags: is-newarp-before-merge is-newarp-base
# 1.19 11-Feb-1997 is

branches: 1.19.4;
Allocate and define AF_ARP and PF_ARP. These will be used to
a) communicate the hardware independent part of ARP packets (rfc826) from/to
if_*subr.c in the ongoing effort to rewrite the ARP subsystem for non-Ethernet
networks
b) communicate the hardware independent part of RARP packets (rfc903) from/to
userland sockets to avoid putting link level header format knowledge into
rarpd, when it is enhanced to support non-Ethernet networks.


# 1.18 11-Jan-1997 thorpej

Implement SO_TIMESTAMP socket option: receive a timeval timestamp
as a control message with a datagram.


# 1.17 04-Jul-1996 chuck

add native mode atm protocol info, also ensure AF number remain sync'd
with freebsd.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-May-1996 neil

Remove #ifdefs

Thanks to cgd@NetBSD.ORG for pointing the following out to me:

listen (fd, SOMAXCONN); would break.

As programs wouldn't see the changes that might be specified in
the kernel config file.

As penance I am going to see if it would be possible to move this
into param.h and provide away of finding out what the kernel
value is. On busy network servers this value is useful to have as a tunable
kernel parameter.


# 1.15 02-May-1996 neil

Add ability to do options SOMAXCONN=n which is useful on
busy network servers.


# 1.14 09-Feb-1996 christos

Filesystem prototype changes


# 1.13 09-Feb-1996 mycroft

Increase SOMAXCONN.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.12 29-Mar-1995 briggs

KERNEL -> _KERNEL


# 1.11 26-Mar-1995 jtc

KERNEL -> _KERNEL


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 13-May-1994 mycroft

Update to 4.4-Lite networking code, with a few local changes.


# 1.7 04-May-1994 mycroft

Move internal prototypes to a better place.


# 1.6 04-May-1994 mycroft

Prototype lots of kernel-internal functions.


Revision tags: nvm-base wnvm magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.5 27-Jun-1993 andrew

branches: 1.5.4;
ANSIfications - lots of function prototyping.


# 1.4 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.3 19-Apr-1993 mycroft

Fix typo.


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision