1: /*
   2:  * Copyright (c) 1982, 1986 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  *
   6:  *	@(#)uipc_domain.c	7.1 (Berkeley) 6/5/86
   7:  */
   8: 
   9: #include "param.h"
  10: #include "socket.h"
  11: #include "protosw.h"
  12: #include "domain.h"
  13: #include "time.h"
  14: #include "kernel.h"
  15: 
  16: #define ADDDOMAIN(x)    { \
  17:     extern struct domain x/**/domain; \
  18:     x/**/domain.dom_next = domains; \
  19:     domains = &x/**/domain; \
  20: }
  21: 
  22: domaininit()
  23: {
  24:     register struct domain *dp;
  25:     register struct protosw *pr;
  26: 
  27: #ifndef lint
  28:     ADDDOMAIN(unix);
  29: #ifdef INET
  30:     ADDDOMAIN(inet);
  31: #endif
  32: #ifdef NS
  33:     ADDDOMAIN(ns);
  34: #endif
  35: #include "imp.h"
  36: #if NIMP > 0
  37:     ADDDOMAIN(imp);
  38: #endif
  39: #endif
  40: 
  41:     for (dp = domains; dp; dp = dp->dom_next) {
  42:         if (dp->dom_init)
  43:             (*dp->dom_init)();
  44:         for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
  45:             if (pr->pr_init)
  46:                 (*pr->pr_init)();
  47:     }
  48:     null_init();
  49:     pffasttimo();
  50:     pfslowtimo();
  51: }
  52: 
  53: struct protosw *
  54: pffindtype(family, type)
  55:     int family, type;
  56: {
  57:     register struct domain *dp;
  58:     register struct protosw *pr;
  59: 
  60:     for (dp = domains; dp; dp = dp->dom_next)
  61:         if (dp->dom_family == family)
  62:             goto found;
  63:     return (0);
  64: found:
  65:     for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
  66:         if (pr->pr_type && pr->pr_type == type)
  67:             return (pr);
  68:     return (0);
  69: }
  70: 
  71: struct protosw *
  72: pffindproto(family, protocol, type)
  73:     int family, protocol, type;
  74: {
  75:     register struct domain *dp;
  76:     register struct protosw *pr;
  77:     struct protosw *maybe = 0;
  78: 
  79:     if (family == 0)
  80:         return (0);
  81:     for (dp = domains; dp; dp = dp->dom_next)
  82:         if (dp->dom_family == family)
  83:             goto found;
  84:     return (0);
  85: found:
  86:     for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) {
  87:         if ((pr->pr_protocol == protocol) && (pr->pr_type == type))
  88:             return (pr);
  89: 
  90:         if (type == SOCK_RAW && pr->pr_type == SOCK_RAW &&
  91:             pr->pr_protocol == 0 && maybe == (struct protosw *)0)
  92:             maybe = pr;
  93:     }
  94:     return (maybe);
  95: }
  96: 
  97: pfctlinput(cmd, sa)
  98:     int cmd;
  99:     struct sockaddr *sa;
 100: {
 101:     register struct domain *dp;
 102:     register struct protosw *pr;
 103: 
 104:     for (dp = domains; dp; dp = dp->dom_next)
 105:         for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
 106:             if (pr->pr_ctlinput)
 107:                 (*pr->pr_ctlinput)(cmd, sa);
 108: }
 109: 
 110: pfslowtimo()
 111: {
 112:     register struct domain *dp;
 113:     register struct protosw *pr;
 114: 
 115:     for (dp = domains; dp; dp = dp->dom_next)
 116:         for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
 117:             if (pr->pr_slowtimo)
 118:                 (*pr->pr_slowtimo)();
 119:     timeout(pfslowtimo, (caddr_t)0, hz/2);
 120: }
 121: 
 122: pffasttimo()
 123: {
 124:     register struct domain *dp;
 125:     register struct protosw *pr;
 126: 
 127:     for (dp = domains; dp; dp = dp->dom_next)
 128:         for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
 129:             if (pr->pr_fasttimo)
 130:                 (*pr->pr_fasttimo)();
 131:     timeout(pffasttimo, (caddr_t)0, hz/5);
 132: }

Defined functions

domaininit defined in line 22; used 1 times
pffasttimo defined in line 122; used 2 times
pffindtype defined in line 53; used 2 times
pfslowtimo defined in line 110; used 2 times

Defined macros

ADDDOMAIN defined in line 16; used 4 times
Last modified: 1986-06-05
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 921
Valid CSS Valid XHTML 1.0 Strict