accf_data.c revision 61837
161837Salfred/*- 261837Salfred * Copyright (c) 2000 Alfred Perlstein <alfred@FreeBSD.org> 361837Salfred * All rights reserved. 461837Salfred * 561837Salfred * Redistribution and use in source and binary forms, with or without 661837Salfred * modification, are permitted provided that the following conditions 761837Salfred * are met: 861837Salfred * 1. Redistributions of source code must retain the above copyright 961837Salfred * notice, this list of conditions and the following disclaimer. 1061837Salfred * 2. Redistributions in binary form must reproduce the above copyright 1161837Salfred * notice, this list of conditions and the following disclaimer in the 1261837Salfred * documentation and/or other materials provided with the distribution. 1361837Salfred * 1461837Salfred * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1561837Salfred * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1661837Salfred * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1761837Salfred * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1861837Salfred * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1961837Salfred * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2061837Salfred * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2161837Salfred * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2261837Salfred * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2361837Salfred * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2461837Salfred * SUCH DAMAGE. 2561837Salfred * 2661837Salfred * $FreeBSD: head/sys/netinet/accf_data.c 61837 2000-06-20 01:09:23Z alfred $ 2761837Salfred */ 2861837Salfred 2961837Salfred#define ACCEPT_FILTER_MOD 3061837Salfred 3161837Salfred#include <sys/param.h> 3261837Salfred#include <sys/systm.h> 3361837Salfred#include <sys/sysproto.h> 3461837Salfred#include <sys/kernel.h> 3561837Salfred#include <sys/proc.h> 3661837Salfred#include <sys/malloc.h> 3761837Salfred#include <sys/unistd.h> 3861837Salfred#include <sys/file.h> 3961837Salfred#include <sys/fcntl.h> 4061837Salfred#include <sys/protosw.h> 4161837Salfred#include <sys/socket.h> 4261837Salfred#include <sys/socketvar.h> 4361837Salfred#include <sys/stat.h> 4461837Salfred#include <sys/mbuf.h> 4561837Salfred#include <sys/resource.h> 4661837Salfred#include <sys/sysent.h> 4761837Salfred#include <sys/resourcevar.h> 4861837Salfred 4961837Salfred/* accept filter that holds a socket until data arrives */ 5061837Salfred 5161837Salfredstatic void sohasdata(struct socket *so, void *arg, int waitflag); 5261837Salfred 5361837Salfredstatic struct accept_filter accf_data_filter = { 5461837Salfred "dataready", 5561837Salfred sohasdata, 5661837Salfred NULL, 5761837Salfred NULL 5861837Salfred}; 5961837Salfred 6061837Salfredstatic moduledata_t accf_data_mod = { 6161837Salfred "accf_data", 6261837Salfred accept_filt_generic_mod_event, 6361837Salfred &accf_data_filter 6461837Salfred}; 6561837Salfred 6661837SalfredDECLARE_MODULE(accf_data, accf_data_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE); 6761837Salfred 6861837Salfredstatic void 6961837Salfredsohasdata(struct socket *so, void *arg, int waitflag) 7061837Salfred{ 7161837Salfred 7261837Salfred if (!soreadable(so)) { 7361837Salfred return; 7461837Salfred } 7561837Salfred 7661837Salfred so->so_upcall = NULL; 7761837Salfred so->so_rcv.sb_flags &= ~SB_UPCALL; 7861837Salfred soisconnected(so); 7961837Salfred return; 8061837Salfred} 81