*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->FreeBSD man pages -> pfctlinput2 (9)              



NAME    [Toc]    [Back]

     net_add_domain, pfctlinput, pfctlinput2, pffindproto, pffindtype,
     DOMAIN_SET -- network domain management

SYNOPSIS    [Toc]    [Back]

     #include <sys/param.h>
     #include <sys/kernel.h>
     #include <sys/protosw.h>
     #include <sys/domain.h>

     net_add_domain(void *data);

     pfctlinput(int cmd, struct sockaddr *sa);

     pfctlinput2(int cmd, struct sockaddr *sa, void *ctlparam);

     struct protosw *
     pffindproto(int family, int protocol, int type);

     struct protosw *
     pffindtype(int family, int type);


DESCRIPTION    [Toc]    [Back]

     Network protocols installed in the system are maintained within what are
     called domains (for example the inetdomain and localdomain).

     struct domain {
	     int     dom_family;	     /* AF_xxx */
	     char    *dom_name;
	     void    (*dom_init)	     /* initialize domain data structures */
	     int     (*dom_externalize)      /* externalize access rights */
		     (struct mbuf *, struct mbuf **);
	     void    (*dom_dispose)	     /* dispose of internalized rights */
		     (struct mbuf *);
	     struct  protosw *dom_protosw, *dom_protoswNPROTOSW;
	     struct  domain *dom_next;
	     int     (*dom_rtattach)	     /* initialize routing table */
		     (void **, int);
	     int     dom_rtoffset;	     /* an arg to rtattach, in bits */
	     int     dom_maxrtkey;	     /* for routing layer */

     Each domain contains an array of protocol switch structures (struct
     protosw *), one for each socket type supported.

     struct protosw {
	     short   pr_type;		     /* socket type used for */
	     struct  domain *pr_domain;      /* domain protocol a member of */
	     short   pr_protocol;	     /* protocol number */
	     short   pr_flags;		     /* see below */
     /* protocol-protocol hooks */
	     pr_input_t *pr_input;	     /* input to protocol (from below) */
	     pr_output_t *pr_output;	     /* output to protocol (from above) */
	     pr_ctlinput_t *pr_ctlinput;     /* control input (from below) */
	     pr_ctloutput_t *pr_ctloutput;   /* control output (from above) */
     /* user-protocol hook */
	     pr_usrreq_t     *pr_ousrreq;
     /* utility hooks */
	     pr_init_t *pr_init;
	     pr_fasttimo_t *pr_fasttimo;     /* fast timeout (200ms) */
	     pr_slowtimo_t *pr_slowtimo;     /* slow timeout (500ms) */
	     pr_drain_t *pr_drain;	     /* flush any excess space possible */

	     struct  pr_usrreqs *pr_usrreqs; /* supersedes pr_usrreq() */
	     struct  pfil_head	     pr_pfh;

     The following functions handle the registration of a new domain, lookups
     of specific protocols and protocol types within those domains, and handle
     control messages from the system.

     pfctlinput() is called by the system whenever an event occurs that could
     affect every domain.  Examples of those types of events are routing table
     changes, interface shutdowns or certain ICMP message types.  When called,
     pfctlinput() calls the protocol specific pr_ctlinput() function for each
     protocol in that has defined one, in every domain.

     pfctlinput2() provides that same functionality of pfctlinput(), but with
     a few additional checks and a new void * argument that is passed directly
     to the protocol's pr_ctlinput() function.	Unlike pfctlinput(),
     pfctlinput2() verifies that sa is not NULL, and that only the protocol
     families that are the same as sa have their pr_ctlinput() function

     net_add_domain() adds a new protocol domain to the system.  The argument
     data is cast directly to struct domain * within the function, but is
     declared void * in order to prevent compiler warnings when new domains
     are registered with SYSINIT().  In most cases net_add_domain() is not
     called directly, instead DOMAIN_SET() is used.

     If the new domain has defined an initialization routine, it is called by
     net_add_domain(); as well, each of the protocols within the domain that
     have defined an initialization routine will have theirs called.

     Once a domain is added it cannot be unloaded.  This is because there is
     no reference counting system in place to determine if there are any
     active references from sockets within that domain.

     pffindtype() and pffindproto() look up a protocol by its number or by its
     type.  In most cases, if the protocol or type cannot be found, NULL is
     returned, but pffindproto() may return the default if the requested type
     is SOCK_RAW, a protocol switch type of SOCK_RAW is found, and the domain
     has a default raw protocol.

     Both functions are called by socreate() in order to resolve the protocol
     for the socket currently being created.

     DOMAIN_SET() is a macro that simplifies the registration of a domain via
     SYSINIT().  The code resulting from the macro expects there to be a
     domain structure named ``namedomain'' where name is the argument to

     struct domain localdomain =
     { AF_LOCAL, "local", unp_init, unp_externalize, unp_dispose,
       localsw, &localsw[sizeof(localsw)/sizeof(localsw[0])] };


RETURN VALUES    [Toc]    [Back]

     Both pffindtype() and pffindproto() return a struct protosw * for the
     protocol requested.  If the protocol or socket type is not found, NULL is
     returned.	In the case of pffindproto(), the default protocol may be
     returned for SOCK_RAW types if the domain has a default raw protocol.

SEE ALSO    [Toc]    [Back]


AUTHORS    [Toc]    [Back]

     This man page was written by Chad David <davidc@acns.ab.ca>.

FreeBSD 5.2.1		       December 7, 2001 		 FreeBSD 5.2.1
[ Back ]
 Similar pages
Name OS Title
setdomainna HP-UX get/set name of current Network Information Service domain
domainname HP-UX set or display name of Network Information Service domain
getdomainna HP-UX get/set name of current Network Information Service domain
whois FreeBSD Internet domain name and network number directory service
whois OpenBSD Internet domain name and network number directory service
bind_manual_setup Tru64 Describes how to manually set up the Berkeley Internet Name Domain (BIND) service on your network.
ifmib FreeBSD Management Information Base for network interfaces
peer_snmpd IRIX Simple Network Management Protocol daemon
snmpd IRIX Simple Network Management Protocol daemon
snmpdm HP-UX Simple Network Management Protocol (SNMP) process
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service