raw_ip.c revision 105199
1/*
2 * Copyright (c) 1982, 1986, 1988, 1993
3 *	The Regents of the University of California.  All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 *    must display the following acknowledgement:
15 *	This product includes software developed by the University of
16 *	California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 *    may be used to endorse or promote products derived from this software
19 *    without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 *	@(#)raw_ip.c	8.7 (Berkeley) 5/15/95
34 * $FreeBSD: head/sys/netinet/raw_ip.c 105199 2002-10-16 02:25:05Z sam $
35 */
36
37#include "opt_inet6.h"
38#include "opt_ipsec.h"
39#include "opt_mac.h"
40#include "opt_random_ip_id.h"
41
42#include <sys/param.h>
43#include <sys/kernel.h>
44#include <sys/lock.h>
45#include <sys/mac.h>
46#include <sys/malloc.h>
47#include <sys/mbuf.h>
48#include <sys/proc.h>
49#include <sys/protosw.h>
50#include <sys/signalvar.h>
51#include <sys/socket.h>
52#include <sys/socketvar.h>
53#include <sys/sx.h>
54#include <sys/sysctl.h>
55#include <sys/systm.h>
56
57#include <vm/uma.h>
58
59#include <net/if.h>
60#include <net/route.h>
61
62#define _IP_VHL
63#include <netinet/in.h>
64#include <netinet/in_systm.h>
65#include <netinet/in_pcb.h>
66#include <netinet/in_var.h>
67#include <netinet/ip.h>
68#include <netinet/ip_var.h>
69#include <netinet/ip_mroute.h>
70
71#include <netinet/ip_fw.h>
72#include <netinet/ip_dummynet.h>
73
74#ifdef FAST_IPSEC
75#include <netipsec/ipsec.h>
76#endif /*FAST_IPSEC*/
77
78#ifdef IPSEC
79#include <netinet6/ipsec.h>
80#endif /*IPSEC*/
81
82struct	inpcbhead ripcb;
83struct	inpcbinfo ripcbinfo;
84
85/* control hooks for ipfw and dummynet */
86ip_fw_ctl_t *ip_fw_ctl_ptr;
87ip_dn_ctl_t *ip_dn_ctl_ptr;
88
89/*
90 * Nominal space allocated to a raw ip socket.
91 */
92#define	RIPSNDQ		8192
93#define	RIPRCVQ		8192
94
95/*
96 * Raw interface to IP protocol.
97 */
98
99/*
100 * Initialize raw connection block q.
101 */
102void
103rip_init()
104{
105	INP_INFO_LOCK_INIT(&ripcbinfo, "rip");
106	LIST_INIT(&ripcb);
107	ripcbinfo.listhead = &ripcb;
108	/*
109	 * XXX We don't use the hash list for raw IP, but it's easier
110	 * to allocate a one entry hash list than it is to check all
111	 * over the place for hashbase == NULL.
112	 */
113	ripcbinfo.hashbase = hashinit(1, M_PCB, &ripcbinfo.hashmask);
114	ripcbinfo.porthashbase = hashinit(1, M_PCB, &ripcbinfo.porthashmask);
115	ripcbinfo.ipi_zone = uma_zcreate("ripcb", sizeof(struct inpcb),
116	    NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
117	uma_zone_set_max(ripcbinfo.ipi_zone, maxsockets);
118}
119
120static struct	sockaddr_in ripsrc = { sizeof(ripsrc), AF_INET };
121/*
122 * Setup generic address and protocol structures
123 * for raw_input routine, then pass them along with
124 * mbuf chain.
125 */
126void
127rip_input(m, off)
128	struct mbuf *m;
129	int off;
130{
131	register struct ip *ip = mtod(m, struct ip *);
132	register struct inpcb *inp;
133	struct inpcb *last = 0;
134	struct mbuf *opts = 0;
135	int proto = ip->ip_p;
136
137	ripsrc.sin_addr = ip->ip_src;
138	LIST_FOREACH(inp, &ripcb, inp_list) {
139#ifdef INET6
140		if ((inp->inp_vflag & INP_IPV4) == 0)
141			continue;
142#endif
143		if (inp->inp_ip_p && inp->inp_ip_p != proto)
144			continue;
145		if (inp->inp_laddr.s_addr &&
146                  inp->inp_laddr.s_addr != ip->ip_dst.s_addr)
147			continue;
148		if (inp->inp_faddr.s_addr &&
149                  inp->inp_faddr.s_addr != ip->ip_src.s_addr)
150			continue;
151		if (last) {
152			struct mbuf *n = m_copy(m, 0, (int)M_COPYALL);
153			int policyfail = 0;
154
155			if (n != NULL) {
156#ifdef IPSSEC
157				/* check AH/ESP integrity. */
158				if (ipsec4_in_reject_so(n, last->inp_socket)) {
159					policyfail = 1;
160					ipsecstat.in_polvio++;
161					/* do not inject data to pcb */
162				}
163#endif /*IPSEC*/
164#ifdef FAST_IPSEC
165				/* check AH/ESP integrity. */
166				if (ipsec4_in_reject(n, last)) {
167					policyfail = 1;
168					/* do not inject data to pcb */
169				}
170#endif /*FAST_IPSEC*/
171#ifdef MAC
172				if (policyfail == 0 &&
173				    mac_check_socket_deliver(last->inp_socket,
174				    n) != 0)
175					policyfail = 1;
176#endif
177			}
178			if (policyfail)
179				m_freem(n);
180			else if (n) {
181				if (last->inp_flags & INP_CONTROLOPTS ||
182				    last->inp_socket->so_options & SO_TIMESTAMP)
183				    ip_savecontrol(last, &opts, ip, n);
184				if (sbappendaddr(&last->inp_socket->so_rcv,
185				    (struct sockaddr *)&ripsrc, n,
186				    opts) == 0) {
187					/* should notify about lost packet */
188					m_freem(n);
189					if (opts)
190					    m_freem(opts);
191				} else
192					sorwakeup(last->inp_socket);
193				opts = 0;
194			}
195		}
196		last = inp;
197	}
198	if (last) {
199#ifdef IPSEC
200		/* check AH/ESP integrity. */
201		if (ipsec4_in_reject_so(m, last->inp_socket)) {
202			m_freem(m);
203			ipsecstat.in_polvio++;
204			ipstat.ips_delivered--;
205			/* do not inject data to pcb */
206			return;
207		}
208#endif /*IPSEC*/
209#ifdef FAST_IPSEC
210		/* check AH/ESP integrity. */
211		if (ipsec4_in_reject(m, last)) {
212			m_freem(m);
213			ipstat.ips_delivered--;
214			/* do not inject data to pcb */
215			return;
216		}
217#endif /*FAST_IPSEC*/
218#ifdef MAC
219		if (mac_check_socket_deliver(last->inp_socket, m) != 0) {
220			m_freem(m);
221			ipstat.ips_delivered--;
222			return;
223		}
224#endif
225		if (last->inp_flags & INP_CONTROLOPTS ||
226		    last->inp_socket->so_options & SO_TIMESTAMP)
227			ip_savecontrol(last, &opts, ip, m);
228		if (sbappendaddr(&last->inp_socket->so_rcv,
229		    (struct sockaddr *)&ripsrc, m, opts) == 0) {
230			m_freem(m);
231			if (opts)
232			    m_freem(opts);
233		} else
234			sorwakeup(last->inp_socket);
235	} else {
236		m_freem(m);
237		ipstat.ips_noproto++;
238		ipstat.ips_delivered--;
239	}
240}
241
242/*
243 * Generate IP header and pass packet to ip_output.
244 * Tack on options user may have setup with control call.
245 */
246int
247rip_output(m, so, dst)
248	struct mbuf *m;
249	struct socket *so;
250	u_long dst;
251{
252	register struct ip *ip;
253	register struct inpcb *inp = sotoinpcb(so);
254	int flags = (so->so_options & SO_DONTROUTE) | IP_ALLOWBROADCAST;
255
256#ifdef MAC
257	mac_create_mbuf_from_socket(so, m);
258#endif
259
260	/*
261	 * If the user handed us a complete IP packet, use it.
262	 * Otherwise, allocate an mbuf for a header and fill it in.
263	 */
264	if ((inp->inp_flags & INP_HDRINCL) == 0) {
265		if (m->m_pkthdr.len + sizeof(struct ip) > IP_MAXPACKET) {
266			m_freem(m);
267			return(EMSGSIZE);
268		}
269		M_PREPEND(m, sizeof(struct ip), M_TRYWAIT);
270		ip = mtod(m, struct ip *);
271		ip->ip_tos = inp->inp_ip_tos;
272		ip->ip_off = 0;
273		ip->ip_p = inp->inp_ip_p;
274		ip->ip_len = m->m_pkthdr.len;
275		ip->ip_src = inp->inp_laddr;
276		ip->ip_dst.s_addr = dst;
277		ip->ip_ttl = inp->inp_ip_ttl;
278	} else {
279		if (m->m_pkthdr.len > IP_MAXPACKET) {
280			m_freem(m);
281			return(EMSGSIZE);
282		}
283		ip = mtod(m, struct ip *);
284		/* don't allow both user specified and setsockopt options,
285		   and don't allow packet length sizes that will crash */
286		if (((IP_VHL_HL(ip->ip_vhl) != (sizeof (*ip) >> 2))
287		     && inp->inp_options)
288		    || (ip->ip_len > m->m_pkthdr.len)
289		    || (ip->ip_len < (IP_VHL_HL(ip->ip_vhl) << 2))) {
290			m_freem(m);
291			return EINVAL;
292		}
293		if (ip->ip_id == 0)
294#ifdef RANDOM_IP_ID
295			ip->ip_id = ip_randomid();
296#else
297			ip->ip_id = htons(ip_id++);
298#endif
299		/* XXX prevent ip_output from overwriting header fields */
300		flags |= IP_RAWOUTPUT;
301		ipstat.ips_rawout++;
302	}
303
304	return (ip_output(m, inp->inp_options, &inp->inp_route, flags,
305			  inp->inp_moptions, inp));
306}
307
308/*
309 * Raw IP socket option processing.
310 */
311int
312rip_ctloutput(so, sopt)
313	struct socket *so;
314	struct sockopt *sopt;
315{
316	struct	inpcb *inp = sotoinpcb(so);
317	int	error, optval;
318
319	if (sopt->sopt_level != IPPROTO_IP)
320		return (EINVAL);
321
322	error = 0;
323
324	switch (sopt->sopt_dir) {
325	case SOPT_GET:
326		switch (sopt->sopt_name) {
327		case IP_HDRINCL:
328			optval = inp->inp_flags & INP_HDRINCL;
329			error = sooptcopyout(sopt, &optval, sizeof optval);
330			break;
331
332		case IP_FW_ADD:	/* ADD actually returns the body... */
333		case IP_FW_GET:
334			if (IPFW_LOADED)
335				error = ip_fw_ctl_ptr(sopt);
336			else
337				error = ENOPROTOOPT;
338			break;
339
340		case IP_DUMMYNET_GET:
341			if (DUMMYNET_LOADED)
342				error = ip_dn_ctl_ptr(sopt);
343			else
344				error = ENOPROTOOPT;
345			break ;
346
347		case MRT_INIT:
348		case MRT_DONE:
349		case MRT_ADD_VIF:
350		case MRT_DEL_VIF:
351		case MRT_ADD_MFC:
352		case MRT_DEL_MFC:
353		case MRT_VERSION:
354		case MRT_ASSERT:
355			error = ip_mrouter_get(so, sopt);
356			break;
357
358		default:
359			error = ip_ctloutput(so, sopt);
360			break;
361		}
362		break;
363
364	case SOPT_SET:
365		switch (sopt->sopt_name) {
366		case IP_HDRINCL:
367			error = sooptcopyin(sopt, &optval, sizeof optval,
368					    sizeof optval);
369			if (error)
370				break;
371			if (optval)
372				inp->inp_flags |= INP_HDRINCL;
373			else
374				inp->inp_flags &= ~INP_HDRINCL;
375			break;
376
377		case IP_FW_ADD:
378		case IP_FW_DEL:
379		case IP_FW_FLUSH:
380		case IP_FW_ZERO:
381		case IP_FW_RESETLOG:
382			if (IPFW_LOADED)
383				error = ip_fw_ctl_ptr(sopt);
384			else
385				error = ENOPROTOOPT;
386			break;
387
388		case IP_DUMMYNET_CONFIGURE:
389		case IP_DUMMYNET_DEL:
390		case IP_DUMMYNET_FLUSH:
391			if (DUMMYNET_LOADED)
392				error = ip_dn_ctl_ptr(sopt);
393			else
394				error = ENOPROTOOPT ;
395			break ;
396
397		case IP_RSVP_ON:
398			error = ip_rsvp_init(so);
399			break;
400
401		case IP_RSVP_OFF:
402			error = ip_rsvp_done();
403			break;
404
405			/* XXX - should be combined */
406		case IP_RSVP_VIF_ON:
407			error = ip_rsvp_vif_init(so, sopt);
408			break;
409
410		case IP_RSVP_VIF_OFF:
411			error = ip_rsvp_vif_done(so, sopt);
412			break;
413
414		case MRT_INIT:
415		case MRT_DONE:
416		case MRT_ADD_VIF:
417		case MRT_DEL_VIF:
418		case MRT_ADD_MFC:
419		case MRT_DEL_MFC:
420		case MRT_VERSION:
421		case MRT_ASSERT:
422			error = ip_mrouter_set(so, sopt);
423			break;
424
425		default:
426			error = ip_ctloutput(so, sopt);
427			break;
428		}
429		break;
430	}
431
432	return (error);
433}
434
435/*
436 * This function exists solely to receive the PRC_IFDOWN messages which
437 * are sent by if_down().  It looks for an ifaddr whose ifa_addr is sa,
438 * and calls in_ifadown() to remove all routes corresponding to that address.
439 * It also receives the PRC_IFUP messages from if_up() and reinstalls the
440 * interface routes.
441 */
442void
443rip_ctlinput(cmd, sa, vip)
444	int cmd;
445	struct sockaddr *sa;
446	void *vip;
447{
448	struct in_ifaddr *ia;
449	struct ifnet *ifp;
450	int err;
451	int flags;
452
453	switch (cmd) {
454	case PRC_IFDOWN:
455		TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) {
456			if (ia->ia_ifa.ifa_addr == sa
457			    && (ia->ia_flags & IFA_ROUTE)) {
458				/*
459				 * in_ifscrub kills the interface route.
460				 */
461				in_ifscrub(ia->ia_ifp, ia);
462				/*
463				 * in_ifadown gets rid of all the rest of
464				 * the routes.  This is not quite the right
465				 * thing to do, but at least if we are running
466				 * a routing process they will come back.
467				 */
468				in_ifadown(&ia->ia_ifa, 0);
469				break;
470			}
471		}
472		break;
473
474	case PRC_IFUP:
475		TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) {
476			if (ia->ia_ifa.ifa_addr == sa)
477				break;
478		}
479		if (ia == 0 || (ia->ia_flags & IFA_ROUTE))
480			return;
481		flags = RTF_UP;
482		ifp = ia->ia_ifa.ifa_ifp;
483
484		if ((ifp->if_flags & IFF_LOOPBACK)
485		    || (ifp->if_flags & IFF_POINTOPOINT))
486			flags |= RTF_HOST;
487
488		err = rtinit(&ia->ia_ifa, RTM_ADD, flags);
489		if (err == 0)
490			ia->ia_flags |= IFA_ROUTE;
491		break;
492	}
493}
494
495u_long	rip_sendspace = RIPSNDQ;
496u_long	rip_recvspace = RIPRCVQ;
497
498SYSCTL_INT(_net_inet_raw, OID_AUTO, maxdgram, CTLFLAG_RW,
499    &rip_sendspace, 0, "Maximum outgoing raw IP datagram size");
500SYSCTL_INT(_net_inet_raw, OID_AUTO, recvspace, CTLFLAG_RW,
501    &rip_recvspace, 0, "Maximum incoming raw IP datagram size");
502
503static int
504rip_attach(struct socket *so, int proto, struct thread *td)
505{
506	struct inpcb *inp;
507	int error, s;
508
509	inp = sotoinpcb(so);
510	if (inp)
511		panic("rip_attach");
512	if (td && (error = suser(td)) != 0)
513		return error;
514
515	error = soreserve(so, rip_sendspace, rip_recvspace);
516	if (error)
517		return error;
518	s = splnet();
519	error = in_pcballoc(so, &ripcbinfo, td);
520	splx(s);
521	if (error)
522		return error;
523	inp = (struct inpcb *)so->so_pcb;
524	inp->inp_vflag |= INP_IPV4;
525	inp->inp_ip_p = proto;
526	inp->inp_ip_ttl = ip_defttl;
527	return 0;
528}
529
530static int
531rip_detach(struct socket *so)
532{
533	struct inpcb *inp;
534
535	inp = sotoinpcb(so);
536	if (inp == 0)
537		panic("rip_detach");
538	if (so == ip_mrouter)
539		ip_mrouter_done();
540	ip_rsvp_force_done(so);
541	if (so == ip_rsvpd)
542		ip_rsvp_done();
543	in_pcbdetach(inp);
544	return 0;
545}
546
547static int
548rip_abort(struct socket *so)
549{
550	soisdisconnected(so);
551	return rip_detach(so);
552}
553
554static int
555rip_disconnect(struct socket *so)
556{
557	if ((so->so_state & SS_ISCONNECTED) == 0)
558		return ENOTCONN;
559	return rip_abort(so);
560}
561
562static int
563rip_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
564{
565	struct inpcb *inp = sotoinpcb(so);
566	struct sockaddr_in *addr = (struct sockaddr_in *)nam;
567
568	if (nam->sa_len != sizeof(*addr))
569		return EINVAL;
570
571	if (TAILQ_EMPTY(&ifnet) || ((addr->sin_family != AF_INET) &&
572				    (addr->sin_family != AF_IMPLINK)) ||
573	    (addr->sin_addr.s_addr &&
574	     ifa_ifwithaddr((struct sockaddr *)addr) == 0))
575		return EADDRNOTAVAIL;
576	inp->inp_laddr = addr->sin_addr;
577	return 0;
578}
579
580static int
581rip_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
582{
583	struct inpcb *inp = sotoinpcb(so);
584	struct sockaddr_in *addr = (struct sockaddr_in *)nam;
585
586	if (nam->sa_len != sizeof(*addr))
587		return EINVAL;
588	if (TAILQ_EMPTY(&ifnet))
589		return EADDRNOTAVAIL;
590	if ((addr->sin_family != AF_INET) &&
591	    (addr->sin_family != AF_IMPLINK))
592		return EAFNOSUPPORT;
593	inp->inp_faddr = addr->sin_addr;
594	soisconnected(so);
595	return 0;
596}
597
598static int
599rip_shutdown(struct socket *so)
600{
601	socantsendmore(so);
602	return 0;
603}
604
605static int
606rip_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam,
607	 struct mbuf *control, struct thread *td)
608{
609	struct inpcb *inp = sotoinpcb(so);
610	register u_long dst;
611
612	if (so->so_state & SS_ISCONNECTED) {
613		if (nam) {
614			m_freem(m);
615			return EISCONN;
616		}
617		dst = inp->inp_faddr.s_addr;
618	} else {
619		if (nam == NULL) {
620			m_freem(m);
621			return ENOTCONN;
622		}
623		dst = ((struct sockaddr_in *)nam)->sin_addr.s_addr;
624	}
625	return rip_output(m, so, dst);
626}
627
628static int
629rip_pcblist(SYSCTL_HANDLER_ARGS)
630{
631	int error, i, n, s;
632	struct inpcb *inp, **inp_list;
633	inp_gen_t gencnt;
634	struct xinpgen xig;
635
636	/*
637	 * The process of preparing the TCB list is too time-consuming and
638	 * resource-intensive to repeat twice on every request.
639	 */
640	if (req->oldptr == 0) {
641		n = ripcbinfo.ipi_count;
642		req->oldidx = 2 * (sizeof xig)
643			+ (n + n/8) * sizeof(struct xinpcb);
644		return 0;
645	}
646
647	if (req->newptr != 0)
648		return EPERM;
649
650	/*
651	 * OK, now we're committed to doing something.
652	 */
653	s = splnet();
654	gencnt = ripcbinfo.ipi_gencnt;
655	n = ripcbinfo.ipi_count;
656	splx(s);
657
658	xig.xig_len = sizeof xig;
659	xig.xig_count = n;
660	xig.xig_gen = gencnt;
661	xig.xig_sogen = so_gencnt;
662	error = SYSCTL_OUT(req, &xig, sizeof xig);
663	if (error)
664		return error;
665
666	inp_list = malloc(n * sizeof *inp_list, M_TEMP, M_WAITOK);
667	if (inp_list == 0)
668		return ENOMEM;
669
670	s = splnet();
671	for (inp = LIST_FIRST(ripcbinfo.listhead), i = 0; inp && i < n;
672	     inp = LIST_NEXT(inp, inp_list)) {
673		if (inp->inp_gencnt <= gencnt) {
674			if (cr_canseesocket(req->td->td_ucred,
675			    inp->inp_socket))
676				continue;
677			inp_list[i++] = inp;
678		}
679	}
680	splx(s);
681	n = i;
682
683	error = 0;
684	for (i = 0; i < n; i++) {
685		inp = inp_list[i];
686		if (inp->inp_gencnt <= gencnt) {
687			struct xinpcb xi;
688			xi.xi_len = sizeof xi;
689			/* XXX should avoid extra copy */
690			bcopy(inp, &xi.xi_inp, sizeof *inp);
691			if (inp->inp_socket)
692				sotoxsocket(inp->inp_socket, &xi.xi_socket);
693			error = SYSCTL_OUT(req, &xi, sizeof xi);
694		}
695	}
696	if (!error) {
697		/*
698		 * Give the user an updated idea of our state.
699		 * If the generation differs from what we told
700		 * her before, she knows that something happened
701		 * while we were processing this request, and it
702		 * might be necessary to retry.
703		 */
704		s = splnet();
705		xig.xig_gen = ripcbinfo.ipi_gencnt;
706		xig.xig_sogen = so_gencnt;
707		xig.xig_count = ripcbinfo.ipi_count;
708		splx(s);
709		error = SYSCTL_OUT(req, &xig, sizeof xig);
710	}
711	free(inp_list, M_TEMP);
712	return error;
713}
714
715/*
716 * This is the wrapper function for in_setsockaddr.  We just pass down
717 * the pcbinfo for in_setpeeraddr to lock.
718 */
719static int
720rip_sockaddr(struct socket *so, struct sockaddr **nam)
721{
722	return (in_setsockaddr(so, nam, &ripcbinfo));
723}
724
725/*
726 * This is the wrapper function for in_setpeeraddr.  We just pass down
727 * the pcbinfo for in_setpeeraddr to lock.
728 */
729static int
730rip_peeraddr(struct socket *so, struct sockaddr **nam)
731{
732	return (in_setpeeraddr(so, nam, &ripcbinfo));
733}
734
735
736SYSCTL_PROC(_net_inet_raw, OID_AUTO/*XXX*/, pcblist, CTLFLAG_RD, 0, 0,
737	    rip_pcblist, "S,xinpcb", "List of active raw IP sockets");
738
739struct pr_usrreqs rip_usrreqs = {
740	rip_abort, pru_accept_notsupp, rip_attach, rip_bind, rip_connect,
741	pru_connect2_notsupp, in_control, rip_detach, rip_disconnect,
742	pru_listen_notsupp, rip_peeraddr, pru_rcvd_notsupp,
743	pru_rcvoob_notsupp, rip_send, pru_sense_null, rip_shutdown,
744	rip_sockaddr, sosend, soreceive, sopoll
745};
746