udp_usrreq.c revision 1.1 1 1.1 cgd /*
2 1.1 cgd * Copyright (c) 1982, 1986, 1988, 1990 Regents of the University of California.
3 1.1 cgd * All rights reserved.
4 1.1 cgd *
5 1.1 cgd * Redistribution and use in source and binary forms, with or without
6 1.1 cgd * modification, are permitted provided that the following conditions
7 1.1 cgd * are met:
8 1.1 cgd * 1. Redistributions of source code must retain the above copyright
9 1.1 cgd * notice, this list of conditions and the following disclaimer.
10 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
11 1.1 cgd * notice, this list of conditions and the following disclaimer in the
12 1.1 cgd * documentation and/or other materials provided with the distribution.
13 1.1 cgd * 3. All advertising materials mentioning features or use of this software
14 1.1 cgd * must display the following acknowledgement:
15 1.1 cgd * This product includes software developed by the University of
16 1.1 cgd * California, Berkeley and its contributors.
17 1.1 cgd * 4. Neither the name of the University nor the names of its contributors
18 1.1 cgd * may be used to endorse or promote products derived from this software
19 1.1 cgd * without specific prior written permission.
20 1.1 cgd *
21 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 1.1 cgd * SUCH DAMAGE.
32 1.1 cgd *
33 1.1 cgd * @(#)udp_usrreq.c 7.20 (Berkeley) 4/20/91
34 1.1 cgd */
35 1.1 cgd
36 1.1 cgd #include "param.h"
37 1.1 cgd #include "malloc.h"
38 1.1 cgd #include "mbuf.h"
39 1.1 cgd #include "protosw.h"
40 1.1 cgd #include "socket.h"
41 1.1 cgd #include "socketvar.h"
42 1.1 cgd #include "stat.h"
43 1.1 cgd
44 1.1 cgd #include "../net/if.h"
45 1.1 cgd #include "../net/route.h"
46 1.1 cgd
47 1.1 cgd #include "in.h"
48 1.1 cgd #include "in_systm.h"
49 1.1 cgd #include "ip.h"
50 1.1 cgd #include "in_pcb.h"
51 1.1 cgd #include "ip_var.h"
52 1.1 cgd #include "ip_icmp.h"
53 1.1 cgd #include "udp.h"
54 1.1 cgd #include "udp_var.h"
55 1.1 cgd
56 1.1 cgd struct inpcb *udp_last_inpcb = &udb;
57 1.1 cgd
58 1.1 cgd /*
59 1.1 cgd * UDP protocol implementation.
60 1.1 cgd * Per RFC 768, August, 1980.
61 1.1 cgd */
62 1.1 cgd udp_init()
63 1.1 cgd {
64 1.1 cgd
65 1.1 cgd udb.inp_next = udb.inp_prev = &udb;
66 1.1 cgd }
67 1.1 cgd
68 1.1 cgd #ifndef COMPAT_42
69 1.1 cgd int udpcksum = 1;
70 1.1 cgd #else
71 1.1 cgd int udpcksum = 0; /* XXX */
72 1.1 cgd #endif
73 1.1 cgd int udp_ttl = UDP_TTL;
74 1.1 cgd
75 1.1 cgd struct sockaddr_in udp_in = { sizeof(udp_in), AF_INET };
76 1.1 cgd
77 1.1 cgd udp_input(m, iphlen)
78 1.1 cgd register struct mbuf *m;
79 1.1 cgd int iphlen;
80 1.1 cgd {
81 1.1 cgd register struct ip *ip;
82 1.1 cgd register struct udphdr *uh;
83 1.1 cgd register struct inpcb *inp;
84 1.1 cgd struct mbuf *opts = 0;
85 1.1 cgd int len;
86 1.1 cgd struct ip save_ip;
87 1.1 cgd
88 1.1 cgd udpstat.udps_ipackets++;
89 1.1 cgd
90 1.1 cgd /*
91 1.1 cgd * Strip IP options, if any; should skip this,
92 1.1 cgd * make available to user, and use on returned packets,
93 1.1 cgd * but we don't yet have a way to check the checksum
94 1.1 cgd * with options still present.
95 1.1 cgd */
96 1.1 cgd if (iphlen > sizeof (struct ip)) {
97 1.1 cgd ip_stripoptions(m, (struct mbuf *)0);
98 1.1 cgd iphlen = sizeof(struct ip);
99 1.1 cgd }
100 1.1 cgd
101 1.1 cgd /*
102 1.1 cgd * Get IP and UDP header together in first mbuf.
103 1.1 cgd */
104 1.1 cgd ip = mtod(m, struct ip *);
105 1.1 cgd if (m->m_len < iphlen + sizeof(struct udphdr)) {
106 1.1 cgd if ((m = m_pullup(m, iphlen + sizeof(struct udphdr))) == 0) {
107 1.1 cgd udpstat.udps_hdrops++;
108 1.1 cgd return;
109 1.1 cgd }
110 1.1 cgd ip = mtod(m, struct ip *);
111 1.1 cgd }
112 1.1 cgd uh = (struct udphdr *)((caddr_t)ip + iphlen);
113 1.1 cgd
114 1.1 cgd /*
115 1.1 cgd * Make mbuf data length reflect UDP length.
116 1.1 cgd * If not enough data to reflect UDP length, drop.
117 1.1 cgd */
118 1.1 cgd len = ntohs((u_short)uh->uh_ulen);
119 1.1 cgd if (ip->ip_len != len) {
120 1.1 cgd if (len > ip->ip_len) {
121 1.1 cgd udpstat.udps_badlen++;
122 1.1 cgd goto bad;
123 1.1 cgd }
124 1.1 cgd m_adj(m, len - ip->ip_len);
125 1.1 cgd /* ip->ip_len = len; */
126 1.1 cgd }
127 1.1 cgd /*
128 1.1 cgd * Save a copy of the IP header in case we want restore it
129 1.1 cgd * for sending an ICMP error message in response.
130 1.1 cgd */
131 1.1 cgd save_ip = *ip;
132 1.1 cgd
133 1.1 cgd /*
134 1.1 cgd * Checksum extended UDP header and data.
135 1.1 cgd */
136 1.1 cgd if (udpcksum && uh->uh_sum) {
137 1.1 cgd ((struct ipovly *)ip)->ih_next = 0;
138 1.1 cgd ((struct ipovly *)ip)->ih_prev = 0;
139 1.1 cgd ((struct ipovly *)ip)->ih_x1 = 0;
140 1.1 cgd ((struct ipovly *)ip)->ih_len = uh->uh_ulen;
141 1.1 cgd if (uh->uh_sum = in_cksum(m, len + sizeof (struct ip))) {
142 1.1 cgd udpstat.udps_badsum++;
143 1.1 cgd m_freem(m);
144 1.1 cgd return;
145 1.1 cgd }
146 1.1 cgd }
147 1.1 cgd
148 1.1 cgd /*
149 1.1 cgd * Locate pcb for datagram.
150 1.1 cgd */
151 1.1 cgd inp = udp_last_inpcb;
152 1.1 cgd if (inp->inp_lport != uh->uh_dport ||
153 1.1 cgd inp->inp_fport != uh->uh_sport ||
154 1.1 cgd inp->inp_faddr.s_addr != ip->ip_src.s_addr ||
155 1.1 cgd inp->inp_laddr.s_addr != ip->ip_dst.s_addr) {
156 1.1 cgd inp = in_pcblookup(&udb, ip->ip_src, uh->uh_sport,
157 1.1 cgd ip->ip_dst, uh->uh_dport, INPLOOKUP_WILDCARD);
158 1.1 cgd if (inp)
159 1.1 cgd udp_last_inpcb = inp;
160 1.1 cgd udpstat.udpps_pcbcachemiss++;
161 1.1 cgd }
162 1.1 cgd if (inp == 0) {
163 1.1 cgd /* don't send ICMP response for broadcast packet */
164 1.1 cgd udpstat.udps_noport++;
165 1.1 cgd if (m->m_flags & M_BCAST) {
166 1.1 cgd udpstat.udps_noportbcast++;
167 1.1 cgd goto bad;
168 1.1 cgd }
169 1.1 cgd *ip = save_ip;
170 1.1 cgd ip->ip_len += iphlen;
171 1.1 cgd icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PORT);
172 1.1 cgd return;
173 1.1 cgd }
174 1.1 cgd
175 1.1 cgd /*
176 1.1 cgd * Construct sockaddr format source address.
177 1.1 cgd * Stuff source address and datagram in user buffer.
178 1.1 cgd */
179 1.1 cgd udp_in.sin_port = uh->uh_sport;
180 1.1 cgd udp_in.sin_addr = ip->ip_src;
181 1.1 cgd if (inp->inp_flags & INP_CONTROLOPTS) {
182 1.1 cgd struct mbuf **mp = &opts;
183 1.1 cgd struct mbuf *udp_saveopt();
184 1.1 cgd
185 1.1 cgd if (inp->inp_flags & INP_RECVDSTADDR) {
186 1.1 cgd *mp = udp_saveopt((caddr_t) &ip->ip_dst,
187 1.1 cgd sizeof(struct in_addr), IP_RECVDSTADDR);
188 1.1 cgd if (*mp)
189 1.1 cgd mp = &(*mp)->m_next;
190 1.1 cgd }
191 1.1 cgd #ifdef notyet
192 1.1 cgd /* options were tossed above */
193 1.1 cgd if (inp->inp_flags & INP_RECVOPTS) {
194 1.1 cgd *mp = udp_saveopt((caddr_t) opts_deleted_above,
195 1.1 cgd sizeof(struct in_addr), IP_RECVOPTS);
196 1.1 cgd if (*mp)
197 1.1 cgd mp = &(*mp)->m_next;
198 1.1 cgd }
199 1.1 cgd /* ip_srcroute doesn't do what we want here, need to fix */
200 1.1 cgd if (inp->inp_flags & INP_RECVRETOPTS) {
201 1.1 cgd *mp = udp_saveopt((caddr_t) ip_srcroute(),
202 1.1 cgd sizeof(struct in_addr), IP_RECVRETOPTS);
203 1.1 cgd if (*mp)
204 1.1 cgd mp = &(*mp)->m_next;
205 1.1 cgd }
206 1.1 cgd #endif
207 1.1 cgd }
208 1.1 cgd iphlen += sizeof(struct udphdr);
209 1.1 cgd m->m_len -= iphlen;
210 1.1 cgd m->m_pkthdr.len -= iphlen;
211 1.1 cgd m->m_data += iphlen;
212 1.1 cgd if (sbappendaddr(&inp->inp_socket->so_rcv, (struct sockaddr *)&udp_in,
213 1.1 cgd m, opts) == 0) {
214 1.1 cgd udpstat.udps_fullsock++;
215 1.1 cgd goto bad;
216 1.1 cgd }
217 1.1 cgd sorwakeup(inp->inp_socket);
218 1.1 cgd return;
219 1.1 cgd bad:
220 1.1 cgd m_freem(m);
221 1.1 cgd if (opts)
222 1.1 cgd m_freem(opts);
223 1.1 cgd }
224 1.1 cgd
225 1.1 cgd /*
226 1.1 cgd * Create a "control" mbuf containing the specified data
227 1.1 cgd * with the specified type for presentation with a datagram.
228 1.1 cgd */
229 1.1 cgd struct mbuf *
230 1.1 cgd udp_saveopt(p, size, type)
231 1.1 cgd caddr_t p;
232 1.1 cgd register int size;
233 1.1 cgd int type;
234 1.1 cgd {
235 1.1 cgd register struct cmsghdr *cp;
236 1.1 cgd struct mbuf *m;
237 1.1 cgd
238 1.1 cgd if ((m = m_get(M_DONTWAIT, MT_CONTROL)) == NULL)
239 1.1 cgd return ((struct mbuf *) NULL);
240 1.1 cgd cp = (struct cmsghdr *) mtod(m, struct cmsghdr *);
241 1.1 cgd bcopy(p, (caddr_t)(cp + 1), size);
242 1.1 cgd size += sizeof(*cp);
243 1.1 cgd m->m_len = size;
244 1.1 cgd cp->cmsg_len = size;
245 1.1 cgd cp->cmsg_level = IPPROTO_IP;
246 1.1 cgd cp->cmsg_type = type;
247 1.1 cgd return (m);
248 1.1 cgd }
249 1.1 cgd
250 1.1 cgd /*
251 1.1 cgd * Notify a udp user of an asynchronous error;
252 1.1 cgd * just wake up so that he can collect error status.
253 1.1 cgd */
254 1.1 cgd udp_notify(inp, errno)
255 1.1 cgd register struct inpcb *inp;
256 1.1 cgd {
257 1.1 cgd
258 1.1 cgd inp->inp_socket->so_error = errno;
259 1.1 cgd sorwakeup(inp->inp_socket);
260 1.1 cgd sowwakeup(inp->inp_socket);
261 1.1 cgd }
262 1.1 cgd
263 1.1 cgd udp_ctlinput(cmd, sa, ip)
264 1.1 cgd int cmd;
265 1.1 cgd struct sockaddr *sa;
266 1.1 cgd register struct ip *ip;
267 1.1 cgd {
268 1.1 cgd register struct udphdr *uh;
269 1.1 cgd extern struct in_addr zeroin_addr;
270 1.1 cgd extern u_char inetctlerrmap[];
271 1.1 cgd
272 1.1 cgd if ((unsigned)cmd > PRC_NCMDS || inetctlerrmap[cmd] == 0)
273 1.1 cgd return;
274 1.1 cgd if (ip) {
275 1.1 cgd uh = (struct udphdr *)((caddr_t)ip + (ip->ip_hl << 2));
276 1.1 cgd in_pcbnotify(&udb, sa, uh->uh_dport, ip->ip_src, uh->uh_sport,
277 1.1 cgd cmd, udp_notify);
278 1.1 cgd } else
279 1.1 cgd in_pcbnotify(&udb, sa, 0, zeroin_addr, 0, cmd, udp_notify);
280 1.1 cgd }
281 1.1 cgd
282 1.1 cgd udp_output(inp, m, addr, control)
283 1.1 cgd register struct inpcb *inp;
284 1.1 cgd register struct mbuf *m;
285 1.1 cgd struct mbuf *addr, *control;
286 1.1 cgd {
287 1.1 cgd register struct udpiphdr *ui;
288 1.1 cgd register int len = m->m_pkthdr.len;
289 1.1 cgd struct in_addr laddr;
290 1.1 cgd int s, error = 0;
291 1.1 cgd
292 1.1 cgd if (control)
293 1.1 cgd m_freem(control); /* XXX */
294 1.1 cgd
295 1.1 cgd if (addr) {
296 1.1 cgd laddr = inp->inp_laddr;
297 1.1 cgd if (inp->inp_faddr.s_addr != INADDR_ANY) {
298 1.1 cgd error = EISCONN;
299 1.1 cgd goto release;
300 1.1 cgd }
301 1.1 cgd /*
302 1.1 cgd * Must block input while temporarily connected.
303 1.1 cgd */
304 1.1 cgd s = splnet();
305 1.1 cgd error = in_pcbconnect(inp, addr);
306 1.1 cgd if (error) {
307 1.1 cgd splx(s);
308 1.1 cgd goto release;
309 1.1 cgd }
310 1.1 cgd } else {
311 1.1 cgd if (inp->inp_faddr.s_addr == INADDR_ANY) {
312 1.1 cgd error = ENOTCONN;
313 1.1 cgd goto release;
314 1.1 cgd }
315 1.1 cgd }
316 1.1 cgd /*
317 1.1 cgd * Calculate data length and get a mbuf
318 1.1 cgd * for UDP and IP headers.
319 1.1 cgd */
320 1.1 cgd M_PREPEND(m, sizeof(struct udpiphdr), M_WAIT);
321 1.1 cgd
322 1.1 cgd /*
323 1.1 cgd * Fill in mbuf with extended UDP header
324 1.1 cgd * and addresses and length put into network format.
325 1.1 cgd */
326 1.1 cgd ui = mtod(m, struct udpiphdr *);
327 1.1 cgd ui->ui_next = ui->ui_prev = 0;
328 1.1 cgd ui->ui_x1 = 0;
329 1.1 cgd ui->ui_pr = IPPROTO_UDP;
330 1.1 cgd ui->ui_len = htons((u_short)len + sizeof (struct udphdr));
331 1.1 cgd ui->ui_src = inp->inp_laddr;
332 1.1 cgd ui->ui_dst = inp->inp_faddr;
333 1.1 cgd ui->ui_sport = inp->inp_lport;
334 1.1 cgd ui->ui_dport = inp->inp_fport;
335 1.1 cgd ui->ui_ulen = ui->ui_len;
336 1.1 cgd
337 1.1 cgd /*
338 1.1 cgd * Stuff checksum and output datagram.
339 1.1 cgd */
340 1.1 cgd ui->ui_sum = 0;
341 1.1 cgd if (udpcksum) {
342 1.1 cgd if ((ui->ui_sum = in_cksum(m, sizeof (struct udpiphdr) + len)) == 0)
343 1.1 cgd ui->ui_sum = 0xffff;
344 1.1 cgd }
345 1.1 cgd ((struct ip *)ui)->ip_len = sizeof (struct udpiphdr) + len;
346 1.1 cgd ((struct ip *)ui)->ip_ttl = inp->inp_ip.ip_ttl; /* XXX */
347 1.1 cgd ((struct ip *)ui)->ip_tos = inp->inp_ip.ip_tos; /* XXX */
348 1.1 cgd udpstat.udps_opackets++;
349 1.1 cgd error = ip_output(m, inp->inp_options, &inp->inp_route,
350 1.1 cgd inp->inp_socket->so_options & (SO_DONTROUTE | SO_BROADCAST));
351 1.1 cgd
352 1.1 cgd if (addr) {
353 1.1 cgd in_pcbdisconnect(inp);
354 1.1 cgd inp->inp_laddr = laddr;
355 1.1 cgd splx(s);
356 1.1 cgd }
357 1.1 cgd return (error);
358 1.1 cgd
359 1.1 cgd release:
360 1.1 cgd m_freem(m);
361 1.1 cgd return (error);
362 1.1 cgd }
363 1.1 cgd
364 1.1 cgd u_long udp_sendspace = 9216; /* really max datagram size */
365 1.1 cgd u_long udp_recvspace = 40 * (1024 + sizeof(struct sockaddr_in));
366 1.1 cgd /* 40 1K datagrams */
367 1.1 cgd
368 1.1 cgd /*ARGSUSED*/
369 1.1 cgd udp_usrreq(so, req, m, addr, control)
370 1.1 cgd struct socket *so;
371 1.1 cgd int req;
372 1.1 cgd struct mbuf *m, *addr, *control;
373 1.1 cgd {
374 1.1 cgd struct inpcb *inp = sotoinpcb(so);
375 1.1 cgd int error = 0;
376 1.1 cgd int s;
377 1.1 cgd
378 1.1 cgd if (req == PRU_CONTROL)
379 1.1 cgd return (in_control(so, (int)m, (caddr_t)addr,
380 1.1 cgd (struct ifnet *)control));
381 1.1 cgd if (inp == NULL && req != PRU_ATTACH) {
382 1.1 cgd error = EINVAL;
383 1.1 cgd goto release;
384 1.1 cgd }
385 1.1 cgd /*
386 1.1 cgd * Note: need to block udp_input while changing
387 1.1 cgd * the udp pcb queue and/or pcb addresses.
388 1.1 cgd */
389 1.1 cgd switch (req) {
390 1.1 cgd
391 1.1 cgd case PRU_ATTACH:
392 1.1 cgd if (inp != NULL) {
393 1.1 cgd error = EINVAL;
394 1.1 cgd break;
395 1.1 cgd }
396 1.1 cgd s = splnet();
397 1.1 cgd error = in_pcballoc(so, &udb);
398 1.1 cgd splx(s);
399 1.1 cgd if (error)
400 1.1 cgd break;
401 1.1 cgd error = soreserve(so, udp_sendspace, udp_recvspace);
402 1.1 cgd if (error)
403 1.1 cgd break;
404 1.1 cgd ((struct inpcb *) so->so_pcb)->inp_ip.ip_ttl = udp_ttl;
405 1.1 cgd break;
406 1.1 cgd
407 1.1 cgd case PRU_DETACH:
408 1.1 cgd udp_detach(inp);
409 1.1 cgd break;
410 1.1 cgd
411 1.1 cgd case PRU_BIND:
412 1.1 cgd s = splnet();
413 1.1 cgd error = in_pcbbind(inp, addr);
414 1.1 cgd splx(s);
415 1.1 cgd break;
416 1.1 cgd
417 1.1 cgd case PRU_LISTEN:
418 1.1 cgd error = EOPNOTSUPP;
419 1.1 cgd break;
420 1.1 cgd
421 1.1 cgd case PRU_CONNECT:
422 1.1 cgd if (inp->inp_faddr.s_addr != INADDR_ANY) {
423 1.1 cgd error = EISCONN;
424 1.1 cgd break;
425 1.1 cgd }
426 1.1 cgd s = splnet();
427 1.1 cgd error = in_pcbconnect(inp, addr);
428 1.1 cgd splx(s);
429 1.1 cgd if (error == 0)
430 1.1 cgd soisconnected(so);
431 1.1 cgd break;
432 1.1 cgd
433 1.1 cgd case PRU_CONNECT2:
434 1.1 cgd error = EOPNOTSUPP;
435 1.1 cgd break;
436 1.1 cgd
437 1.1 cgd case PRU_ACCEPT:
438 1.1 cgd error = EOPNOTSUPP;
439 1.1 cgd break;
440 1.1 cgd
441 1.1 cgd case PRU_DISCONNECT:
442 1.1 cgd if (inp->inp_faddr.s_addr == INADDR_ANY) {
443 1.1 cgd error = ENOTCONN;
444 1.1 cgd break;
445 1.1 cgd }
446 1.1 cgd s = splnet();
447 1.1 cgd in_pcbdisconnect(inp);
448 1.1 cgd inp->inp_laddr.s_addr = INADDR_ANY;
449 1.1 cgd splx(s);
450 1.1 cgd so->so_state &= ~SS_ISCONNECTED; /* XXX */
451 1.1 cgd break;
452 1.1 cgd
453 1.1 cgd case PRU_SHUTDOWN:
454 1.1 cgd socantsendmore(so);
455 1.1 cgd break;
456 1.1 cgd
457 1.1 cgd case PRU_SEND:
458 1.1 cgd return (udp_output(inp, m, addr, control));
459 1.1 cgd
460 1.1 cgd case PRU_ABORT:
461 1.1 cgd soisdisconnected(so);
462 1.1 cgd udp_detach(inp);
463 1.1 cgd break;
464 1.1 cgd
465 1.1 cgd case PRU_SOCKADDR:
466 1.1 cgd in_setsockaddr(inp, addr);
467 1.1 cgd break;
468 1.1 cgd
469 1.1 cgd case PRU_PEERADDR:
470 1.1 cgd in_setpeeraddr(inp, addr);
471 1.1 cgd break;
472 1.1 cgd
473 1.1 cgd case PRU_SENSE:
474 1.1 cgd /*
475 1.1 cgd * stat: don't bother with a blocksize.
476 1.1 cgd */
477 1.1 cgd return (0);
478 1.1 cgd
479 1.1 cgd case PRU_SENDOOB:
480 1.1 cgd case PRU_FASTTIMO:
481 1.1 cgd case PRU_SLOWTIMO:
482 1.1 cgd case PRU_PROTORCV:
483 1.1 cgd case PRU_PROTOSEND:
484 1.1 cgd error = EOPNOTSUPP;
485 1.1 cgd break;
486 1.1 cgd
487 1.1 cgd case PRU_RCVD:
488 1.1 cgd case PRU_RCVOOB:
489 1.1 cgd return (EOPNOTSUPP); /* do not free mbuf's */
490 1.1 cgd
491 1.1 cgd default:
492 1.1 cgd panic("udp_usrreq");
493 1.1 cgd }
494 1.1 cgd
495 1.1 cgd release:
496 1.1 cgd if (control) {
497 1.1 cgd printf("udp control data unexpectedly retained\n");
498 1.1 cgd m_freem(control);
499 1.1 cgd }
500 1.1 cgd if (m)
501 1.1 cgd m_freem(m);
502 1.1 cgd return (error);
503 1.1 cgd }
504 1.1 cgd
505 1.1 cgd udp_detach(inp)
506 1.1 cgd struct inpcb *inp;
507 1.1 cgd {
508 1.1 cgd int s = splnet();
509 1.1 cgd
510 1.1 cgd if (inp == udp_last_inpcb)
511 1.1 cgd udp_last_inpcb = &udb;
512 1.1 cgd in_pcbdetach(inp);
513 1.1 cgd splx(s);
514 1.1 cgd }
515