The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/bsd/net/raw_cb.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
    3  *
    4  * @APPLE_LICENSE_HEADER_START@
    5  * 
    6  * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
    7  * 
    8  * This file contains Original Code and/or Modifications of Original Code
    9  * as defined in and that are subject to the Apple Public Source License
   10  * Version 2.0 (the 'License'). You may not use this file except in
   11  * compliance with the License. Please obtain a copy of the License at
   12  * http://www.opensource.apple.com/apsl/ and read it before using this
   13  * file.
   14  * 
   15  * The Original Code and all software distributed under the License are
   16  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
   17  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
   18  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
   19  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
   20  * Please see the License for the specific language governing rights and
   21  * limitations under the License.
   22  * 
   23  * @APPLE_LICENSE_HEADER_END@
   24  */
   25 /*
   26  * Copyright (c) 1980, 1986, 1993
   27  *      The Regents of the University of California.  All rights reserved.
   28  *
   29  * Redistribution and use in source and binary forms, with or without
   30  * modification, are permitted provided that the following conditions
   31  * are met:
   32  * 1. Redistributions of source code must retain the above copyright
   33  *    notice, this list of conditions and the following disclaimer.
   34  * 2. Redistributions in binary form must reproduce the above copyright
   35  *    notice, this list of conditions and the following disclaimer in the
   36  *    documentation and/or other materials provided with the distribution.
   37  * 3. All advertising materials mentioning features or use of this software
   38  *    must display the following acknowledgement:
   39  *      This product includes software developed by the University of
   40  *      California, Berkeley and its contributors.
   41  * 4. Neither the name of the University nor the names of its contributors
   42  *    may be used to endorse or promote products derived from this software
   43  *    without specific prior written permission.
   44  *
   45  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   46  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   47  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   48  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   49  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   50  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   51  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   52  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   53  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   54  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   55  * SUCH DAMAGE.
   56  *
   57  *      @(#)raw_cb.c    8.1 (Berkeley) 6/10/93
   58  */
   59 
   60 #include <sys/param.h>
   61 #include <sys/malloc.h>
   62 #include <sys/socket.h>
   63 #include <sys/socketvar.h>
   64 #include <sys/domain.h>
   65 #include <sys/protosw.h>
   66 
   67 #include <net/raw_cb.h>
   68 
   69 /*
   70  * Routines to manage the raw protocol control blocks.
   71  *
   72  * TODO:
   73  *      hash lookups by protocol family/protocol + address family
   74  *      take care of unique address problems per AF?
   75  *      redo address binding to allow wildcards
   76  */
   77 
   78 struct rawcb_list_head rawcb_list;
   79 
   80 static u_long   raw_sendspace = RAWSNDQ;
   81 static u_long   raw_recvspace = RAWRCVQ;
   82 
   83 /*
   84  * Allocate a control block and a nominal amount
   85  * of buffer space for the socket.
   86  */
   87 int
   88 raw_attach(so, proto)
   89         register struct socket *so;
   90         int proto;
   91 {
   92         register struct rawcb *rp = sotorawcb(so);
   93         int error;
   94 
   95         /*
   96          * It is assumed that raw_attach is called
   97          * after space has been allocated for the
   98          * rawcb.
   99          */
  100         if (rp == 0)
  101                 return (ENOBUFS);
  102         error = soreserve(so, raw_sendspace, raw_recvspace);
  103         if (error)
  104                 return (error);
  105         rp->rcb_socket = so;
  106         rp->rcb_proto.sp_family = so->so_proto->pr_domain->dom_family;
  107         rp->rcb_proto.sp_protocol = proto;
  108         LIST_INSERT_HEAD(&rawcb_list, rp, list);
  109         return (0);
  110 }
  111 
  112 /*
  113  * Detach the raw connection block and discard
  114  * socket resources.
  115  */
  116 void
  117 raw_detach(rp)
  118         register struct rawcb *rp;
  119 {
  120         struct socket *so = rp->rcb_socket;
  121 
  122         so->so_pcb = 0;
  123         sofree(so);
  124         LIST_REMOVE(rp, list);
  125 #ifdef notdef
  126         if (rp->rcb_laddr)
  127                 m_freem(dtom(rp->rcb_laddr));
  128         rp->rcb_laddr = 0;
  129 #endif
  130         FREE((caddr_t)(rp), M_PCB);
  131 }
  132 
  133 /*
  134  * Disconnect and possibly release resources.
  135  */
  136 void
  137 raw_disconnect(rp)
  138         struct rawcb *rp;
  139 {
  140 
  141 #ifdef notdef
  142         if (rp->rcb_faddr)
  143                 m_freem(dtom(rp->rcb_faddr));
  144         rp->rcb_faddr = 0;
  145 #endif
  146         if (rp->rcb_socket->so_state & SS_NOFDREF)
  147                 raw_detach(rp);
  148 }
  149 
  150 #ifdef notdef
  151 #include <sys/mbuf.h>
  152 
  153 int
  154 raw_bind(so, nam)
  155         register struct socket *so;
  156         struct mbuf *nam;
  157 {
  158         struct sockaddr *addr = mtod(nam, struct sockaddr *);
  159         register struct rawcb *rp;
  160 
  161         if (ifnet == 0)
  162                 return (EADDRNOTAVAIL);
  163         rp = sotorawcb(so);
  164         nam = m_copym(nam, 0, M_COPYALL, M_WAITOK);
  165         rp->rcb_laddr = mtod(nam, struct sockaddr *);
  166         return (0);
  167 }
  168 #endif

Cache object: 2e508b1c193a1a633766e76b3a83d4f3


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.