1 #include "../h/param.h" 2 #include "../inet/protocol.h" 3 #include "../inet/protocolsw.h" 4 /* should include a header file giving desired protocols */ 5 #define NTCP 1 6 7 /* 8 * Protocol configuration table and routines to search it. 9 */ 10 11 /* 12 * Generic (local or not yet specified) protocol. 13 */ 14 int gen_usrreq(); 15 16 #if NTCP > 0 17 /* 18 * TCP/IP protocol family: IP, ICMP, UDP, TCP. 19 */ 20 int ip_input(),ip_output(),ip_advise(),ip_slowtimo(),ip_drain(); 21 int icmp_input(),icmp_output(); 22 int udp_input(),udp_advise(),udp_usrreq(),udp_sense(); 23 int tcp_input(),tcp_advise(),tcp_fasttimo(),tcp_slowtimo(), 24 tcp_drain(),tcp_sense(); 25 int rawip_input(),rawip_advise(),rawip_advise(),rawip_usrreq(), 26 rawip_sense(); 27 #endif 28 29 #if NPUP > 0 30 /* 31 * Pup protocols: PUP, BSP. 32 */ 33 int pup1_input(),pup1_output(),pup1_advise(),pup1_slowtimo(), 34 pup1_drain(),pup1_usrreq(),pup1_sense(); 35 int bsp_input(),bsp_advise(),bsp_fasttimo(),bsp_slowtimo(), 36 bsp_drain(),bsp_usrreq(),bsp_sense(); 37 int rawpup_input(),rawpup_usrreq(),rawpup_sense(); 38 #endif 39 40 #if NCHAOS > 0 41 /* 42 * Chaosnet protocols. 43 */ 44 /* ... */ 45 #endif 46 47 #if NOISCP > 0 48 /* 49 * Office information system communcation protocols. 50 */ 51 /* ... */ 52 #endif 53 54 #if NNBS > 0 55 /* 56 * NBS protocols. 57 */ 58 /* ... */ 59 #endif 60 61 #if NECMA > 0 62 /* 63 * ECMA protocols. 64 */ 65 /* ... */ 66 #endif 67 68 #if NDATAKIT > 0 69 /* 70 * Datakit protocols. 71 */ 72 /* ... */ 73 #endif 74 75 struct protosw protosw[] = { 76 { SOCK_STREAM, PF_GENERIC, 0, 0, 77 0, 0, 0, 78 0, 0, 0, gen_usrreq, 0, 79 0 }, 80 { SOCK_DGRAM, PF_GENERIC, 0, PR_ATOMIC|PR_PROVIDEADDR, 81 0, 0, 0, 82 0, 0, 0, gen_usrreq, 0, 83 0 }, 84 { SOCK_RDM, PF_GENERIC, 0, PR_ATOMIC|PR_PROVIDEADDR, 85 0, 0, 0, 86 0, 0, 0, gen_usrreq, 0, 87 0 }, 88 { SOCK_RAW, PF_GENERIC, 0, PR_ATOMIC|PR_PROVIDEADDR, 89 0, 0, 0, 90 0, 0, 0, gen_usrreq, 0, 91 #if NTCP > 0 92 { 0, 0, 0, 0, 93 ip_input, ip_output, 0, 94 0, ip_slowtimo, ip_drain, 0, 0, 95 0 }, 96 { 0, 0, IPPROTO_ICMP, 0, 97 icmp_input, icmp_output, 0, 98 0, 0, icmp_drain, 0, 0, 99 0 }, 100 { SOCK_DGRAM, PF_INET, IPPROTO_UDP, PR_ATOMIC|PR_PROVIDEADDR, 101 udp_input, 0, udp_advise, 102 0, 0, 0, udp_usrreq, udp_sense, 103 MLEN }, 104 { SOCK_STREAM, PF_INET, IPPROTO_TCP, 0, 105 tcp_input, 0, tcp_advise, 106 tcp_fasttimo, tcp_slowtimo, tcp_drain, tcp_usrreq, tcp_sense, 107 MLEN }, 108 { SOCK_RAW, PF_INET, IPPROTO_RAW, PR_ATOMIC|PR_PROVIDEADDR, 109 ri_input, 0, ri_advise, 110 ri_fasttimo, ri_slowtimo, ri_drain, ri_usrreq, ri_sense, 111 MLEN }, 112 #endif 113 #if NPUP > 0 114 { SOCK_DGRAM, PF_PUP, 0, PR_ATOMIC|PR_PROVIDEADDR, 115 pup_input, pup_output, pup_advise, 116 0, pup_slowtimo, pup_drain, pup_usrreq, pup_sense, 117 MLEN }, 118 { SOCK_STREAM, PF_PUP1, PUPPROTO_BSP, 0, 119 bsp_input, 0, bsp_advise, 120 bsp_fasttimo, bsp_slowtimo, bsp_drain, bsp_usrreq, bsp_sense, 121 MLEN }, 122 { SOCK_RAW, PF_PUP1, PUPPROTO_RAW, PR_ATOMIC|PR_PROVIDEADDR, 123 rp_input, 0, rp_advise, 124 rp_fasttimo, rp_slowtimo, rp_drain, rp_usrreq, rp_sense, 125 MLEN }, 126 #endif 127 #if NCHAOS > 0 128 /* ... */ 129 #endif 130 #if NOISCP > 0 131 /* ... */ 132 #endif 133 #if NNBS > 0 134 /* ... */ 135 #endif 136 #if NECMA > 0 137 /* ... */ 138 #endif 139 #if NDATAKIT > 0 140 /* ... */ 141 #endif 142 }; 143 #define protoswEND &protosw[sizeof (protosw)/sizeof (protosw[0])] 144 145 /* 146 * Operations on protocol table and protocol families. 147 */ 148 149 /* 150 * Find a standard protocol in a protocol family 151 * of a specific type. 152 */ 153 pf_stdproto(family, type) 154 int family, type; 155 { 156 register struct protosw *pr; 157 158 if (family == 0) 159 return (0); 160 for (pr = protosw; pr < protoswEND; pr++) 161 if (pr->pr_family == family && pr->pr_type == type) 162 return (pr); 163 return (0); 164 } 165 166 /* 167 * Find a specified protocol in a specified protocol family. 168 */ 169 pf_findproto(family, proto) 170 int family, proto; 171 { 172 register struct protosw *pr; 173 174 if (family == 0) 175 return (0); 176 for (pr = protosw; pr < protoswEND; pr++) 177 if (pr->pr_family == family && pr->pr_proto == proto) 178 return (pr); 179 return (0); 180 } 181