ip_divert.c (169179) | ip_divert.c (169454) |
---|---|
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 --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * | 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 --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * |
29 * $FreeBSD: head/sys/netinet/ip_divert.c 169179 2007-05-01 16:31:02Z rwatson $ | 29 * $FreeBSD: head/sys/netinet/ip_divert.c 169454 2007-05-10 15:58:48Z rwatson $ |
30 */ 31 32#if !defined(KLD_MODULE) 33#include "opt_inet.h" 34#include "opt_ipfw.h" 35#include "opt_mac.h" 36#ifndef INET 37#error "IPDIVERT requires INET." --- 102 unchanged lines hidden (view full) --- 140 struct inpcb *inp = mem; 141 142 INP_LOCK_DESTROY(inp); 143} 144 145void 146div_init(void) 147{ | 30 */ 31 32#if !defined(KLD_MODULE) 33#include "opt_inet.h" 34#include "opt_ipfw.h" 35#include "opt_mac.h" 36#ifndef INET 37#error "IPDIVERT requires INET." --- 102 unchanged lines hidden (view full) --- 140 struct inpcb *inp = mem; 141 142 INP_LOCK_DESTROY(inp); 143} 144 145void 146div_init(void) 147{ |
148 |
|
148 INP_INFO_LOCK_INIT(&divcbinfo, "div"); 149 LIST_INIT(&divcb); 150 divcbinfo.ipi_listhead = &divcb; 151 /* 152 * XXX We don't use the hash list for divert IP, but it's easier 153 * to allocate a one entry hash list than it is to check all 154 * over the place for hashbase == NULL. 155 */ --- 137 unchanged lines hidden (view full) --- 293/* 294 * Deliver packet back into the IP processing machinery. 295 * 296 * If no address specified, or address is 0.0.0.0, send to ip_output(); 297 * otherwise, send to ip_input() and mark as having been received on 298 * the interface with that address. 299 */ 300static int | 149 INP_INFO_LOCK_INIT(&divcbinfo, "div"); 150 LIST_INIT(&divcb); 151 divcbinfo.ipi_listhead = &divcb; 152 /* 153 * XXX We don't use the hash list for divert IP, but it's easier 154 * to allocate a one entry hash list than it is to check all 155 * over the place for hashbase == NULL. 156 */ --- 137 unchanged lines hidden (view full) --- 294/* 295 * Deliver packet back into the IP processing machinery. 296 * 297 * If no address specified, or address is 0.0.0.0, send to ip_output(); 298 * otherwise, send to ip_input() and mark as having been received on 299 * the interface with that address. 300 */ 301static int |
301div_output(struct socket *so, struct mbuf *m, 302 struct sockaddr_in *sin, struct mbuf *control) | 302div_output(struct socket *so, struct mbuf *m, struct sockaddr_in *sin, 303 struct mbuf *control) |
303{ 304 struct m_tag *mtag; 305 struct divert_tag *dt; 306 int error = 0; 307 308 /* 309 * An mbuf may hasn't come from userland, but we pretend 310 * that it has. --- 186 unchanged lines hidden (view full) --- 497 INP_LOCK(inp); 498 socantsendmore(so); 499 INP_UNLOCK(inp); 500 return 0; 501} 502 503static int 504div_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, | 304{ 305 struct m_tag *mtag; 306 struct divert_tag *dt; 307 int error = 0; 308 309 /* 310 * An mbuf may hasn't come from userland, but we pretend 311 * that it has. --- 186 unchanged lines hidden (view full) --- 498 INP_LOCK(inp); 499 socantsendmore(so); 500 INP_UNLOCK(inp); 501 return 0; 502} 503 504static int 505div_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, |
505 struct mbuf *control, struct thread *td) | 506 struct mbuf *control, struct thread *td) |
506{ 507 /* Packet must have a header (but that's about it) */ 508 if (m->m_len < sizeof (struct ip) && 509 (m = m_pullup(m, sizeof (struct ip))) == 0) { 510 ipstat.ips_toosmall++; 511 m_freem(m); 512 return EINVAL; 513 } --- 111 unchanged lines hidden (view full) --- 625 626/* 627 * This is the wrapper function for in_setsockaddr. We just pass down 628 * the pcbinfo for in_setpeeraddr to lock. 629 */ 630static int 631div_sockaddr(struct socket *so, struct sockaddr **nam) 632{ | 507{ 508 /* Packet must have a header (but that's about it) */ 509 if (m->m_len < sizeof (struct ip) && 510 (m = m_pullup(m, sizeof (struct ip))) == 0) { 511 ipstat.ips_toosmall++; 512 m_freem(m); 513 return EINVAL; 514 } --- 111 unchanged lines hidden (view full) --- 626 627/* 628 * This is the wrapper function for in_setsockaddr. We just pass down 629 * the pcbinfo for in_setpeeraddr to lock. 630 */ 631static int 632div_sockaddr(struct socket *so, struct sockaddr **nam) 633{ |
634 |
|
633 return (in_setsockaddr(so, nam)); 634} 635 636/* 637 * This is the wrapper function for in_setpeeraddr. We just pass down 638 * the pcbinfo for in_setpeeraddr to lock. 639 */ 640static int 641div_peeraddr(struct socket *so, struct sockaddr **nam) 642{ | 635 return (in_setsockaddr(so, nam)); 636} 637 638/* 639 * This is the wrapper function for in_setpeeraddr. We just pass down 640 * the pcbinfo for in_setpeeraddr to lock. 641 */ 642static int 643div_peeraddr(struct socket *so, struct sockaddr **nam) 644{ |
645 |
|
643 return (in_setpeeraddr(so, nam)); 644} 645 646#ifdef SYSCTL_NODE 647SYSCTL_NODE(_net_inet, IPPROTO_DIVERT, divert, CTLFLAG_RW, 0, "IPDIVERT"); 648SYSCTL_PROC(_net_inet_divert, OID_AUTO, pcblist, CTLFLAG_RD, 0, 0, 649 div_pcblist, "S,xinpcb", "List of active divert sockets"); 650#endif --- 89 unchanged lines hidden --- | 646 return (in_setpeeraddr(so, nam)); 647} 648 649#ifdef SYSCTL_NODE 650SYSCTL_NODE(_net_inet, IPPROTO_DIVERT, divert, CTLFLAG_RW, 0, "IPDIVERT"); 651SYSCTL_PROC(_net_inet_divert, OID_AUTO, pcblist, CTLFLAG_RD, 0, 0, 652 div_pcblist, "S,xinpcb", "List of active divert sockets"); 653#endif --- 89 unchanged lines hidden --- |