|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1982, 1986 Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution is only permitted until one year after the first shipment ! 6: * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and ! 7: * binary forms are permitted provided that: (1) source distributions retain ! 8: * this entire copyright notice and comment, and (2) distributions including ! 9: * binaries display the following acknowledgement: This product includes ! 10: * software developed by the University of California, Berkeley and its ! 11: * contributors'' in the documentation or other materials provided with the ! 12: * distribution and in all advertising materials mentioning features or use ! 13: * of this software. Neither the name of the University nor the names of ! 14: * its contributors may be used to endorse or promote products derived from ! 15: * this software without specific prior written permission. ! 16: * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED ! 17: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF ! 18: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 19: * ! 20: * @(#)uipc_domain.c 7.7 (Berkeley) 6/28/90 ! 21: */ ! 22: ! 23: #include "param.h" ! 24: #include "socket.h" ! 25: #include "protosw.h" ! 26: #include "domain.h" ! 27: #include "mbuf.h" ! 28: #include "time.h" ! 29: #include "kernel.h" ! 30: ! 31: #define ADDDOMAIN(x) { \ ! 32: extern struct domain x/**/domain; \ ! 33: x/**/domain.dom_next = domains; \ ! 34: domains = &x/**/domain; \ ! 35: } ! 36: ! 37: domaininit() ! 38: { ! 39: register struct domain *dp; ! 40: register struct protosw *pr; ! 41: ! 42: #ifndef lint ! 43: ADDDOMAIN(unix); ! 44: ADDDOMAIN(route); ! 45: #ifdef INET ! 46: ADDDOMAIN(inet); ! 47: #endif ! 48: #ifdef NS ! 49: ADDDOMAIN(ns); ! 50: #endif ! 51: #ifdef ISO ! 52: ADDDOMAIN(iso); ! 53: #endif ! 54: #ifdef RMP ! 55: ADDDOMAIN(rmp); ! 56: #endif ! 57: #include "imp.h" ! 58: #if NIMP > 0 ! 59: ADDDOMAIN(imp); ! 60: #endif ! 61: #endif ! 62: ! 63: for (dp = domains; dp; dp = dp->dom_next) { ! 64: if (dp->dom_init) ! 65: (*dp->dom_init)(); ! 66: for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) ! 67: if (pr->pr_init) ! 68: (*pr->pr_init)(); ! 69: } ! 70: ! 71: if (max_linkhdr < 16) /* XXX */ ! 72: max_linkhdr = 16; ! 73: max_hdr = max_linkhdr + max_protohdr; ! 74: max_datalen = MHLEN - max_hdr; ! 75: pffasttimo(); ! 76: pfslowtimo(); ! 77: } ! 78: ! 79: struct protosw * ! 80: pffindtype(family, type) ! 81: int family, type; ! 82: { ! 83: register struct domain *dp; ! 84: register struct protosw *pr; ! 85: ! 86: for (dp = domains; dp; dp = dp->dom_next) ! 87: if (dp->dom_family == family) ! 88: goto found; ! 89: return (0); ! 90: found: ! 91: for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) ! 92: if (pr->pr_type && pr->pr_type == type) ! 93: return (pr); ! 94: return (0); ! 95: } ! 96: ! 97: struct protosw * ! 98: pffindproto(family, protocol, type) ! 99: int family, protocol, type; ! 100: { ! 101: register struct domain *dp; ! 102: register struct protosw *pr; ! 103: struct protosw *maybe = 0; ! 104: ! 105: if (family == 0) ! 106: return (0); ! 107: for (dp = domains; dp; dp = dp->dom_next) ! 108: if (dp->dom_family == family) ! 109: goto found; ! 110: return (0); ! 111: found: ! 112: for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) { ! 113: if ((pr->pr_protocol == protocol) && (pr->pr_type == type)) ! 114: return (pr); ! 115: ! 116: if (type == SOCK_RAW && pr->pr_type == SOCK_RAW && ! 117: pr->pr_protocol == 0 && maybe == (struct protosw *)0) ! 118: maybe = pr; ! 119: } ! 120: return (maybe); ! 121: } ! 122: ! 123: pfctlinput(cmd, sa) ! 124: int cmd; ! 125: struct sockaddr *sa; ! 126: { ! 127: register struct domain *dp; ! 128: register struct protosw *pr; ! 129: ! 130: for (dp = domains; dp; dp = dp->dom_next) ! 131: for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) ! 132: if (pr->pr_ctlinput) ! 133: (*pr->pr_ctlinput)(cmd, sa, (caddr_t) 0); ! 134: } ! 135: ! 136: pfslowtimo() ! 137: { ! 138: register struct domain *dp; ! 139: register struct protosw *pr; ! 140: ! 141: for (dp = domains; dp; dp = dp->dom_next) ! 142: for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) ! 143: if (pr->pr_slowtimo) ! 144: (*pr->pr_slowtimo)(); ! 145: timeout(pfslowtimo, (caddr_t)0, hz/2); ! 146: } ! 147: ! 148: pffasttimo() ! 149: { ! 150: register struct domain *dp; ! 151: register struct protosw *pr; ! 152: ! 153: for (dp = domains; dp; dp = dp->dom_next) ! 154: for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) ! 155: if (pr->pr_fasttimo) ! 156: (*pr->pr_fasttimo)(); ! 157: timeout(pffasttimo, (caddr_t)0, hz/5); ! 158: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.