Commit | Line | Data |
---|---|---|
b454c3ea | 1 | /* uipc_proto.c 4.10 81/12/03 */ |
07d8f161 | 2 | |
d0e67d5f | 3 | #include "../h/param.h" |
07d8f161 | 4 | #include "../h/socket.h" |
07d8f161 BJ |
5 | #include "../h/protosw.h" |
6 | #include "../h/mbuf.h" | |
0ef33f87 BJ |
7 | #include "../net/in.h" |
8 | #include "../net/in_systm.h" | |
07d8f161 | 9 | |
d0e67d5f BJ |
10 | /* |
11 | * Protocol configuration table and routines to search it. | |
cc15ab5d BJ |
12 | * |
13 | * SHOULD INCLUDE A HEADER FILE GIVING DESIRED PROTOCOLS | |
d0e67d5f BJ |
14 | */ |
15 | ||
16 | /* | |
cc15ab5d | 17 | * Local protocol handler. |
d0e67d5f | 18 | */ |
2b4b57cd | 19 | int piusrreq(); |
d0e67d5f | 20 | |
d0e67d5f BJ |
21 | /* |
22 | * TCP/IP protocol family: IP, ICMP, UDP, TCP. | |
23 | */ | |
0ef33f87 | 24 | int ip_output(); |
cc15ab5d | 25 | int ip_init(),ip_slowtimo(),ip_drain(); |
b454c3ea | 26 | int icmp_input(),icmp_ctlinput(); |
cc15ab5d BJ |
27 | int icmp_drain(); |
28 | int udp_input(),udp_ctlinput(); | |
b454c3ea | 29 | int udp_usrreq(); |
cc15ab5d BJ |
30 | int udp_init(); |
31 | int tcp_input(),tcp_ctlinput(); | |
b454c3ea | 32 | int tcp_usrreq(); |
cc15ab5d | 33 | int tcp_init(),tcp_fasttimo(),tcp_slowtimo(),tcp_drain(); |
5b3fa994 BJ |
34 | int rip_input(),rip_output(),rip_ctlinput(); |
35 | int rip_usrreq(),rip_slowtimo(); | |
d0e67d5f BJ |
36 | |
37 | struct protosw protosw[] = { | |
5b3fa994 | 38 | { SOCK_STREAM, PF_UNIX, 0, PR_CONNREQUIRED, |
07d8f161 | 39 | 0, 0, 0, 0, |
5b3fa994 | 40 | piusrreq, |
07d8f161 | 41 | 0, 0, 0, 0, |
cc15ab5d | 42 | }, |
5b3fa994 | 43 | { SOCK_DGRAM, PF_UNIX, 0, PR_ATOMIC|PR_ADDR, |
07d8f161 | 44 | 0, 0, 0, 0, |
5b3fa994 | 45 | piusrreq, |
07d8f161 | 46 | 0, 0, 0, 0, |
cc15ab5d | 47 | }, |
5b3fa994 | 48 | { SOCK_RDM, PF_UNIX, 0, PR_ATOMIC|PR_ADDR, |
cc15ab5d | 49 | 0, 0, 0, 0, |
5b3fa994 | 50 | piusrreq, |
cc15ab5d BJ |
51 | 0, 0, 0, 0, |
52 | }, | |
5b3fa994 | 53 | { SOCK_RAW, PF_UNIX, 0, PR_ATOMIC|PR_ADDR, |
cc15ab5d | 54 | 0, 0, 0, 0, |
5b3fa994 | 55 | piusrreq, |
cc15ab5d BJ |
56 | 0, 0, 0, 0, |
57 | }, | |
d0e67d5f | 58 | { 0, 0, 0, 0, |
0ef33f87 | 59 | 0, ip_output, 0, 0, |
5b3fa994 | 60 | 0, |
cc15ab5d BJ |
61 | ip_init, 0, ip_slowtimo, ip_drain, |
62 | }, | |
d0e67d5f | 63 | { 0, 0, IPPROTO_ICMP, 0, |
b454c3ea | 64 | icmp_input, 0, icmp_ctlinput, 0, |
5b3fa994 | 65 | 0, |
cc15ab5d BJ |
66 | 0, 0, 0, icmp_drain, |
67 | }, | |
07d8f161 | 68 | { SOCK_DGRAM, PF_INET, IPPROTO_UDP, PR_ATOMIC|PR_ADDR, |
cc15ab5d | 69 | udp_input, 0, udp_ctlinput, 0, |
5b3fa994 | 70 | udp_usrreq, |
cc15ab5d BJ |
71 | udp_init, 0, 0, 0, |
72 | }, | |
687794cc | 73 | { SOCK_STREAM, PF_INET, IPPROTO_TCP, PR_CONNREQUIRED|PR_WANTRCVD, |
cc15ab5d | 74 | tcp_input, 0, tcp_ctlinput, 0, |
5b3fa994 | 75 | tcp_usrreq, |
cc15ab5d BJ |
76 | tcp_init, tcp_fasttimo, tcp_slowtimo, tcp_drain, |
77 | }, | |
07d8f161 | 78 | { SOCK_RAW, PF_INET, IPPROTO_RAW, PR_ATOMIC|PR_ADDR, |
5b3fa994 BJ |
79 | rip_input, rip_output, rip_ctlinput, 0, |
80 | rip_usrreq, | |
81 | 0, 0, rip_slowtimo, 0, | |
cc15ab5d | 82 | } |
d0e67d5f | 83 | }; |
cc15ab5d BJ |
84 | |
85 | #define NPROTOSW (sizeof(protosw) / sizeof(protosw[0])) | |
86 | ||
87 | struct protosw *protoswLAST = &protosw[NPROTOSW-1]; | |
d0e67d5f BJ |
88 | |
89 | /* | |
90 | * Operations on protocol table and protocol families. | |
91 | */ | |
92 | ||
cc15ab5d BJ |
93 | /* |
94 | * Initialize all protocols. | |
95 | */ | |
96 | pfinit() | |
97 | { | |
98 | register struct protosw *pr; | |
99 | ||
2b4b57cd | 100 | COUNT(PFINIT); |
cc15ab5d BJ |
101 | for (pr = protoswLAST; pr >= protosw; pr--) |
102 | if (pr->pr_init) | |
103 | (*pr->pr_init)(); | |
104 | } | |
105 | ||
d0e67d5f BJ |
106 | /* |
107 | * Find a standard protocol in a protocol family | |
108 | * of a specific type. | |
109 | */ | |
07d8f161 | 110 | struct protosw * |
cc15ab5d | 111 | pffindtype(family, type) |
d0e67d5f BJ |
112 | int family, type; |
113 | { | |
114 | register struct protosw *pr; | |
115 | ||
2b4b57cd | 116 | COUNT(PFFINDTYPE); |
d0e67d5f BJ |
117 | if (family == 0) |
118 | return (0); | |
687794cc | 119 | for (pr = protosw; pr <= protoswLAST; pr++) |
d0e67d5f BJ |
120 | if (pr->pr_family == family && pr->pr_type == type) |
121 | return (pr); | |
122 | return (0); | |
123 | } | |
124 | ||
125 | /* | |
126 | * Find a specified protocol in a specified protocol family. | |
127 | */ | |
07d8f161 | 128 | struct protosw * |
cc15ab5d | 129 | pffindproto(family, protocol) |
07d8f161 | 130 | int family, protocol; |
d0e67d5f BJ |
131 | { |
132 | register struct protosw *pr; | |
133 | ||
2b4b57cd | 134 | COUNT(PFFINDPROTO); |
d0e67d5f BJ |
135 | if (family == 0) |
136 | return (0); | |
687794cc | 137 | for (pr = protosw; pr <= protoswLAST; pr++) |
07d8f161 | 138 | if (pr->pr_family == family && pr->pr_protocol == protocol) |
d0e67d5f BJ |
139 | return (pr); |
140 | return (0); | |
141 | } |