Annotation of 43BSDReno/sys/net/raw_cb.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1980, 1986 Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution is only permitted until one year after the first shipment
                      6:  * of 4.4BSD by the Regents.  Otherwise, redistribution and use in source and
                      7:  * binary forms are permitted provided that: (1) source distributions retain
                      8:  * this entire copyright notice and comment, and (2) distributions including
                      9:  * binaries display the following acknowledgement:  This product includes
                     10:  * software developed by the University of California, Berkeley and its
                     11:  * contributors'' in the documentation or other materials provided with the
                     12:  * distribution and in all advertising materials mentioning features or use
                     13:  * of this software.  Neither the name of the University nor the names of
                     14:  * its contributors may be used to endorse or promote products derived from
                     15:  * this software without specific prior written permission.
                     16:  * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
                     17:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
                     18:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     19:  *
                     20:  *     @(#)raw_cb.c    7.11 (Berkeley) 6/28/90
                     21:  */
                     22: 
                     23: #include "param.h"
                     24: #include "systm.h"
                     25: #include "mbuf.h"
                     26: #include "socket.h"
                     27: #include "socketvar.h"
                     28: #include "domain.h"
                     29: #include "protosw.h"
                     30: #include "errno.h"
                     31: 
                     32: #include "if.h"
                     33: #include "route.h"
                     34: #include "raw_cb.h"
                     35: #include "../netinet/in.h"
                     36: 
                     37: #include "machine/mtpr.h"
                     38: 
                     39: /*
                     40:  * Routines to manage the raw protocol control blocks. 
                     41:  *
                     42:  * TODO:
                     43:  *     hash lookups by protocol family/protocol + address family
                     44:  *     take care of unique address problems per AF?
                     45:  *     redo address binding to allow wildcards
                     46:  */
                     47: 
                     48: u_long raw_sendspace = RAWSNDQ;
                     49: u_long raw_recvspace = RAWRCVQ;
                     50: 
                     51: /*
                     52:  * Allocate a control block and a nominal amount
                     53:  * of buffer space for the socket.
                     54:  */
                     55: raw_attach(so, proto)
                     56:        register struct socket *so;
                     57:        int proto;
                     58: {
                     59:        register struct rawcb *rp = sotorawcb(so);
                     60:        int error;
                     61: 
                     62:        /*
                     63:         * It is assumed that raw_attach is called
                     64:         * after space has been allocated for the
                     65:         * rawcb.
                     66:         */
                     67:        if (rp == 0)
                     68:                return (ENOBUFS);
                     69:        if (error = soreserve(so, raw_sendspace, raw_recvspace))
                     70:                return (error);
                     71:        rp->rcb_socket = so;
                     72:        rp->rcb_proto.sp_family = so->so_proto->pr_domain->dom_family;
                     73:        rp->rcb_proto.sp_protocol = proto;
                     74:        insque(rp, &rawcb);
                     75:        return (0);
                     76: }
                     77: 
                     78: /*
                     79:  * Detach the raw connection block and discard
                     80:  * socket resources.
                     81:  */
                     82: raw_detach(rp)
                     83:        register struct rawcb *rp;
                     84: {
                     85:        struct socket *so = rp->rcb_socket;
                     86: 
                     87:        so->so_pcb = 0;
                     88:        sofree(so);
                     89:        remque(rp);
                     90: #ifdef notdef
                     91:        if (rp->rcb_laddr)
                     92:                m_freem(dtom(rp->rcb_laddr));
                     93:        rp->rcb_laddr = 0;
                     94: #endif
                     95:        free((caddr_t)(rp), M_PCB);
                     96: }
                     97: 
                     98: /*
                     99:  * Disconnect and possibly release resources.
                    100:  */
                    101: raw_disconnect(rp)
                    102:        struct rawcb *rp;
                    103: {
                    104: 
                    105: #ifdef notdef
                    106:        if (rp->rcb_faddr)
                    107:                m_freem(dtom(rp->rcb_faddr));
                    108:        rp->rcb_faddr = 0;
                    109: #endif
                    110:        if (rp->rcb_socket->so_state & SS_NOFDREF)
                    111:                raw_detach(rp);
                    112: }
                    113: 
                    114: #ifdef notdef
                    115: raw_bind(so, nam)
                    116:        register struct socket *so;
                    117:        struct mbuf *nam;
                    118: {
                    119:        struct sockaddr *addr = mtod(nam, struct sockaddr *);
                    120:        register struct rawcb *rp;
                    121: 
                    122:        if (ifnet == 0)
                    123:                return (EADDRNOTAVAIL);
                    124:        rp = sotorawcb(so);
                    125:        nam = m_copym(nam, 0, M_COPYALL, M_WAITOK);
                    126:        rp->rcb_laddr = mtod(nam, struct sockaddr *);
                    127:        return (0);
                    128: }
                    129: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.