| 1 | /* uipc_domain.c 5.8 83/02/10 */ |
| 2 | |
| 3 | #include "../h/param.h" |
| 4 | #include "../h/socket.h" |
| 5 | #include "../h/protosw.h" |
| 6 | #include "../h/domain.h" |
| 7 | #include "../h/time.h" |
| 8 | #include "../h/kernel.h" |
| 9 | |
| 10 | #define ADDDOMAIN(x) { \ |
| 11 | extern struct domain x/**/domain; \ |
| 12 | x/**/domain.dom_next = domains; \ |
| 13 | domains = &x/**/domain; \ |
| 14 | } |
| 15 | |
| 16 | domaininit() |
| 17 | { |
| 18 | register struct domain *dp; |
| 19 | register struct protosw *pr; |
| 20 | |
| 21 | #ifndef lint |
| 22 | ADDDOMAIN(unix); |
| 23 | #ifdef INET |
| 24 | ADDDOMAIN(inet); |
| 25 | #endif |
| 26 | #ifdef PUP |
| 27 | ADDDOMAIN(pup); |
| 28 | #endif |
| 29 | #include "imp.h" |
| 30 | #if NIMP > 0 |
| 31 | ADDDOMAIN(imp); |
| 32 | #endif |
| 33 | #endif |
| 34 | |
| 35 | for (dp = domains; dp; dp = dp->dom_next) |
| 36 | for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) |
| 37 | if (pr->pr_init) |
| 38 | (*pr->pr_init)(); |
| 39 | pffasttimo(); |
| 40 | pfslowtimo(); |
| 41 | } |
| 42 | |
| 43 | struct protosw * |
| 44 | pffindtype(family, type) |
| 45 | int family, type; |
| 46 | { |
| 47 | register struct domain *dp; |
| 48 | register struct protosw *pr; |
| 49 | |
| 50 | for (dp = domains; dp; dp = dp->dom_next) |
| 51 | if (dp->dom_family == family) |
| 52 | goto found; |
| 53 | return (0); |
| 54 | found: |
| 55 | for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) |
| 56 | if (pr->pr_type == type) |
| 57 | return (pr); |
| 58 | return (0); |
| 59 | } |
| 60 | |
| 61 | struct protosw * |
| 62 | pffindproto(family, protocol) |
| 63 | int family, protocol; |
| 64 | { |
| 65 | register struct domain *dp; |
| 66 | register struct protosw *pr; |
| 67 | |
| 68 | if (family == 0) |
| 69 | return (0); |
| 70 | for (dp = domains; dp; dp = dp->dom_next) |
| 71 | if (dp->dom_family == family) |
| 72 | goto found; |
| 73 | return (0); |
| 74 | found: |
| 75 | for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) |
| 76 | if (pr->pr_protocol == protocol) |
| 77 | return (pr); |
| 78 | return (0); |
| 79 | } |
| 80 | |
| 81 | pfctlinput(cmd, arg) |
| 82 | int cmd; |
| 83 | caddr_t arg; |
| 84 | { |
| 85 | register struct domain *dp; |
| 86 | register struct protosw *pr; |
| 87 | |
| 88 | for (dp = domains; dp; dp = dp->dom_next) |
| 89 | for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) |
| 90 | if (pr->pr_ctlinput) |
| 91 | (*pr->pr_ctlinput)(cmd, arg); |
| 92 | } |
| 93 | |
| 94 | pfslowtimo() |
| 95 | { |
| 96 | register struct domain *dp; |
| 97 | register struct protosw *pr; |
| 98 | |
| 99 | for (dp = domains; dp; dp = dp->dom_next) |
| 100 | for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) |
| 101 | if (pr->pr_slowtimo) |
| 102 | (*pr->pr_slowtimo)(); |
| 103 | timeout(pfslowtimo, (caddr_t)0, hz/2); |
| 104 | } |
| 105 | |
| 106 | pffasttimo() |
| 107 | { |
| 108 | register struct domain *dp; |
| 109 | register struct protosw *pr; |
| 110 | |
| 111 | for (dp = domains; dp; dp = dp->dom_next) |
| 112 | for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) |
| 113 | if (pr->pr_fasttimo) |
| 114 | (*pr->pr_fasttimo)(); |
| 115 | timeout(pffasttimo, (caddr_t)0, hz/5); |
| 116 | } |