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