divert man page on OpenBSD

Man page or keyword search:  
man Server   11362 pages
apropos Keyword Search (all sections)
Output format
OpenBSD logo
[printable version]

DIVERT(4)		  OpenBSD Programmer's Manual		     DIVERT(4)

NAME
     divert - kernel packet diversion mechanism

SYNOPSIS
     #include <sys/types.h>
     #include <sys/socket.h>
     #include <netinet/in.h>

     int
     socket(AF_INET, SOCK_RAW, IPPROTO_DIVERT);

     int
     socket(AF_INET6, SOCK_RAW, IPPROTO_DIVERT);

DESCRIPTION
     Divert sockets are part of a mechanism completely integrated with pf(4)
     that queues raw packets from the kernel stack to userspace applications,
     and vice versa.

     A divert socket must be bound to a divert port through bind(2), which
     only the superuser can do.	 Divert ports have their own number space,
     completely separated from tcp(4) and udp(4).  When pf(4) processes a
     packet that matches a divert rule (see pf.conf(5) for details) it is
     immediately sent to the divert socket listening on the port specified in
     the rule.	pf(4) reassembles TCP streams by default (if IP reassembly is
     not disabled) before sending them to the divert sockets.  If there are no
     divert sockets listening, the packets are dropped.

     Packets can be read via read(2), recv(2), or recvfrom(2) from the divert
     socket.  The application that is processing the packets can then reinject
     them into the kernel.  After being reinjected, inbound and outbound
     packets are treated differently.  Inbound packets are added to the
     relevant input queue and a soft interrupt is scheduled to signal that a
     new packet is ready to be processed; outbound ones are processed directly
     by the relevant IP/IPv6 output function.  The packets' checksums are
     recalculated upon reinjection.

     Writing to a divert socket can be achieved using sendto(2) and it will
     skip pf(4) filters to avoid loops.	 A diverted packet that is not
     reinjected into the kernel stack is lost.

     Receive and send divert socket buffer space can be tuned through
     sysctl(8).	 netstat(1) shows information relevant to divert sockets.

SEE ALSO
     socket(2), ip(4), pf.conf(5)

HISTORY
     The divert protocol first appeared in OpenBSD 4.7.

OpenBSD 4.9		       December 6, 2009			   OpenBSD 4.9
[top]

List of man pages available for OpenBSD

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net