1139823Simp/*- 21541Srgrimes * Copyright (c) 1980, 1986, 1993 3180305Srwatson * The Regents of the University of California. 4180305Srwatson * All rights reserved. 51541Srgrimes * 61541Srgrimes * Redistribution and use in source and binary forms, with or without 71541Srgrimes * modification, are permitted provided that the following conditions 81541Srgrimes * are met: 91541Srgrimes * 1. Redistributions of source code must retain the above copyright 101541Srgrimes * notice, this list of conditions and the following disclaimer. 111541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 121541Srgrimes * notice, this list of conditions and the following disclaimer in the 131541Srgrimes * documentation and/or other materials provided with the distribution. 141541Srgrimes * 4. Neither the name of the University nor the names of its contributors 151541Srgrimes * may be used to endorse or promote products derived from this software 161541Srgrimes * without specific prior written permission. 171541Srgrimes * 181541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 191541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 201541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 211541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 221541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 231541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 241541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 251541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 261541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 271541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 281541Srgrimes * SUCH DAMAGE. 291541Srgrimes * 301541Srgrimes * @(#)raw_cb.h 8.1 (Berkeley) 6/10/93 3150477Speter * $FreeBSD$ 321541Srgrimes */ 331541Srgrimes 342168Spaul#ifndef _NET_RAW_CB_H_ 352168Spaul#define _NET_RAW_CB_H_ 362168Spaul 3733058Sbde#include <sys/queue.h> 3833058Sbde 391541Srgrimes/* 40180305Srwatson * Raw protocol interface control block. Used to tie a socket to the generic 41180305Srwatson * raw interface. 421541Srgrimes */ 431541Srgrimesstruct rawcb { 4460938Sjake LIST_ENTRY(rawcb) list; 451541Srgrimes struct socket *rcb_socket; /* back pointer to socket */ 461541Srgrimes struct sockproto rcb_proto; /* protocol family, protocol */ 471541Srgrimes}; 481541Srgrimes 491541Srgrimes#define sotorawcb(so) ((struct rawcb *)(so)->so_pcb) 501541Srgrimes 511541Srgrimes/* 521541Srgrimes * Nominal space allocated to a raw socket. 531541Srgrimes */ 541541Srgrimes#define RAWSNDQ 8192 551541Srgrimes#define RAWRCVQ 8192 561541Srgrimes 5755205Speter#ifdef _KERNEL 58195699SrwatsonVNET_DECLARE(LIST_HEAD(rawcb_list_head, rawcb), rawcb_list); 59195727Srwatson#define V_rawcb_list VNET(rawcb_list) 60195699Srwatson 61130514Srwatsonextern struct mtx rawcb_mtx; 621541Srgrimes 63180307Srwatson/* 64180307Srwatson * Generic protosw entries for raw socket protocols. 65180307Srwatson */ 6683366Sjulianpr_ctlinput_t raw_ctlinput; 6783366Sjulianpr_init_t raw_init; 6883366Sjulian 69180307Srwatson/* 70180307Srwatson * Library routines for raw socket usrreq functions; will always be wrapped 71180307Srwatson * so that protocol-specific functions can be handled. 72180307Srwatson */ 73225837Sbztypedef int (*raw_input_cb_fn)(struct mbuf *, struct sockproto *, 74225837Sbz struct sockaddr *, struct rawcb *); 75225837Sbz 7692725Salfredint raw_attach(struct socket *, int); 7792725Salfredvoid raw_detach(struct rawcb *); 78180385Srwatsonvoid raw_input(struct mbuf *, struct sockproto *, struct sockaddr *); 79225837Sbzvoid raw_input_ext(struct mbuf *, struct sockproto *, struct sockaddr *, 80225837Sbz raw_input_cb_fn); 8183366Sjulian 82180307Srwatson/* 83180307Srwatson * Generic pr_usrreqs entries for raw socket protocols, usually wrapped so 84180307Srwatson * that protocol-specific functions can be handled. 85180307Srwatson */ 8625201Swollmanextern struct pr_usrreqs raw_usrreqs; 871541Srgrimes#endif 882168Spaul 892168Spaul#endif 90