Deleted Added
sdiff udiff text old ( 54799 ) new ( 55009 )
full compact
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

--- 17 unchanged lines hidden (view full) ---

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 54799 1999-12-19 01:55:37Z green $
35 */
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/kernel.h>
40#include <sys/malloc.h>
41#include <sys/mbuf.h>
42#include <sys/proc.h>
43#include <sys/protosw.h>
44#include <sys/socket.h>

--- 11 unchanged lines hidden (view full) ---

56#include <netinet/ip.h>
57#include <netinet/in_pcb.h>
58#include <netinet/in_var.h>
59#include <netinet/ip_var.h>
60#include <netinet/ip_mroute.h>
61
62#include <netinet/ip_fw.h>
63
64#include "opt_ipdn.h"
65#ifdef DUMMYNET
66#include <netinet/ip_dummynet.h>
67#endif
68
69struct inpcbhead ripcb;
70struct inpcbinfo ripcbinfo;
71

--- 28 unchanged lines hidden (view full) ---

100
101static struct sockaddr_in ripsrc = { sizeof(ripsrc), AF_INET };
102/*
103 * Setup generic address and protocol structures
104 * for raw_input routine, then pass them along with
105 * mbuf chain.
106 */
107void
108rip_input(m, iphlen)
109 struct mbuf *m;
110 int iphlen;
111{
112 register struct ip *ip = mtod(m, struct ip *);
113 register struct inpcb *inp;
114 struct inpcb *last = 0;
115 struct mbuf *opts = 0;
116
117 ripsrc.sin_addr = ip->ip_src;
118 for (inp = ripcb.lh_first; inp != NULL; inp = inp->inp_list.le_next) {
119 if (inp->inp_ip_p && inp->inp_ip_p != ip->ip_p)
120 continue;
121 if (inp->inp_laddr.s_addr &&
122 inp->inp_laddr.s_addr != ip->ip_dst.s_addr)
123 continue;
124 if (inp->inp_faddr.s_addr &&
125 inp->inp_faddr.s_addr != ip->ip_src.s_addr)
126 continue;
127 if (last) {
128 struct mbuf *n = m_copy(m, 0, (int)M_COPYALL);

--- 81 unchanged lines hidden (view full) ---

210 return EINVAL;
211 }
212 if (ip->ip_id == 0)
213 ip->ip_id = htons(ip_id++);
214 /* XXX prevent ip_output from overwriting header fields */
215 flags |= IP_RAWOUTPUT;
216 ipstat.ips_rawout++;
217 }
218 return (ip_output(m, inp->inp_options, &inp->inp_route, flags,
219 inp->inp_moptions));
220}
221
222/*
223 * Raw IP socket option processing.
224 */
225int
226rip_ctloutput(so, sopt)

--- 199 unchanged lines hidden (view full) ---

426 int error, s;
427
428 inp = sotoinpcb(so);
429 if (inp)
430 panic("rip_attach");
431 if (p && (error = suser(p)) != 0)
432 return error;
433
434 s = splnet();
435 error = in_pcballoc(so, &ripcbinfo, p);
436 splx(s);
437 if (error)
438 return error;
439 error = soreserve(so, rip_sendspace, rip_recvspace);
440 if (error)
441 return error;
442 inp = (struct inpcb *)so->so_pcb;
443 inp->inp_ip_p = proto;
444 return 0;
445}
446
447static int
448rip_detach(struct socket *so)
449{
450 struct inpcb *inp;
451

--- 186 unchanged lines hidden ---