Annotation of kernel/bsd/netiso/idrp_usrreq.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
                      7:  * Reserved.  This file contains Original Code and/or Modifications of
                      8:  * Original Code as defined in and that are subject to the Apple Public
                      9:  * Source License Version 1.1 (the "License").  You may not use this file
                     10:  * except in compliance with the License.  Please obtain a copy of the
                     11:  * License at http://www.apple.com/publicsource and read it before using
                     12:  * this file.
                     13:  * 
                     14:  * The Original Code and all software distributed under the License are
                     15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     19:  * License for the specific language governing rights and limitations
                     20:  * under the License.
                     21:  * 
                     22:  * @APPLE_LICENSE_HEADER_END@
                     23:  */
                     24: 
                     25: /*
                     26:  * Copyright (c) 1992, 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:  *     @(#)idrp_usrreq.c       8.1 (Berkeley) 6/10/93
                     58:  */
                     59: 
                     60: #include <sys/param.h>
                     61: #include <sys/proc.h>
                     62: #include <sys/systm.h>
                     63: #include <sys/malloc.h>
                     64: #include <sys/mbuf.h>
                     65: #include <sys/socket.h>
                     66: #include <sys/socketvar.h>
                     67: #include <sys/protosw.h>
                     68: #include <sys/errno.h>
                     69: 
                     70: #include <net/route.h>
                     71: #include <net/if.h>
                     72: 
                     73: #include <netiso/argo_debug.h>
                     74: #include <netiso/iso.h>
                     75: #include <netiso/clnp.h>
                     76: #include <netiso/clnl.h>
                     77: #include <netiso/iso_pcb.h>
                     78: #include <netiso/iso_var.h>
                     79: 
                     80: int idrp_input();
                     81: struct isopcb  idrp_isop;
                     82: static struct  sockaddr_iso idrp_addrs[2] =
                     83: {  { sizeof(idrp_addrs), AF_ISO, }, { sizeof(idrp_addrs[1]), AF_ISO, } };
                     84: /*
                     85:  * IDRP initialization
                     86:  */
                     87: idrp_init()
                     88: {
                     89:        extern struct clnl_protosw clnl_protox[256];
                     90: 
                     91:        idrp_isop.isop_next = idrp_isop.isop_prev = &idrp_isop;
                     92:        idrp_isop.isop_faddr = &idrp_isop.isop_sfaddr;
                     93:        idrp_isop.isop_laddr = &idrp_isop.isop_sladdr;
                     94:        idrp_isop.isop_sladdr = idrp_addrs[1];
                     95:        idrp_isop.isop_sfaddr = idrp_addrs[1];
                     96:        clnl_protox[ISO10747_IDRP].clnl_input = idrp_input;
                     97: }
                     98: 
                     99: /*
                    100:  * CALLED FROM:
                    101:  *     tpclnp_input().
                    102:  * FUNCTION and ARGUMENTS:
                    103:  * Take a packet (m) from clnp, strip off the clnp header
                    104:  * and mke suitable for the idrp socket.
                    105:  * No return value.  
                    106:  */
                    107: idrp_input(m, src, dst)
                    108:        register struct mbuf *m;
                    109:        struct sockaddr_iso *src, *dst;
                    110: {
                    111:        if (idrp_isop.isop_socket == 0) {
                    112:        bad:    m_freem(m);
                    113:                return 0;
                    114:        }
                    115:        bzero(idrp_addrs[0].siso_data, sizeof(idrp_addrs[0].siso_data));
                    116:        bcopy((caddr_t)&(src->siso_addr), (caddr_t)&idrp_addrs[0].siso_addr,
                    117:                1 + src->siso_nlen);
                    118:        bzero(idrp_addrs[1].siso_data, sizeof(idrp_addrs[1].siso_data));
                    119:        bcopy((caddr_t)&(dst->siso_addr), (caddr_t)&idrp_addrs[1].siso_addr,
                    120:                1 + dst->siso_nlen);
                    121:        if (sbappendaddr(&idrp_isop.isop_socket->so_rcv,
                    122:                (struct sockaddr *)idrp_addrs, m, (struct mbuf *)0) == 0)
                    123:                goto bad;
                    124:        sorwakeup(idrp_isop.isop_socket);
                    125:        return 0;
                    126: }
                    127: 
                    128: idrp_output(m, addr)
                    129:        struct mbuf *m, *addr;
                    130: {
                    131:        register struct sockaddr_iso *siso = mtod(addr, struct sockaddr_iso *);
                    132:        int s = splnet(), i;
                    133: 
                    134:        bcopy((caddr_t)&(siso->siso_addr),
                    135:              (caddr_t)&idrp_isop.isop_sfaddr.siso_addr, 1 + siso->siso_nlen);
                    136:        siso++;
                    137:        bcopy((caddr_t)&(siso->siso_addr),
                    138:              (caddr_t)&idrp_isop.isop_sladdr.siso_addr, 1 + siso->siso_nlen);
                    139:        i = clnp_output(m, idrp_isop, m->m_pkthdr.len, 0);
                    140:        splx(s);
                    141:        return (i);
                    142: }
                    143: 
                    144: u_long idrp_sendspace = 3072;          /* really max datagram size */
                    145: u_long idrp_recvspace = 40 * 1024;     /* 40 1K datagrams */
                    146: 
                    147: /*ARGSUSED*/
                    148: idrp_usrreq(so, req, m, addr, control)
                    149:        struct socket *so;
                    150:        int req;
                    151:        struct mbuf *m, *addr, *control;
                    152: {
                    153:        int error = 0;
                    154: 
                    155:         /* Note: need to block idrp_input while changing
                    156:         * the udp pcb queue and/or pcb addresses.
                    157:         */
                    158:        switch (req) {
                    159: 
                    160:        case PRU_ATTACH:
                    161:                if (idrp_isop.isop_socket != NULL) {
                    162:                        error = ENXIO;
                    163:                        break;
                    164:                }
                    165:                idrp_isop.isop_socket = so;
                    166:                error = soreserve(so, idrp_sendspace, idrp_recvspace);
                    167:                break;
                    168: 
                    169:        case PRU_SHUTDOWN:
                    170:                socantsendmore(so);
                    171:                break;
                    172: 
                    173:        case PRU_SEND:
                    174:                return (idrp_output(m, addr));
                    175: 
                    176:        case PRU_ABORT:
                    177:                soisdisconnected(so);
                    178:        case PRU_DETACH:
                    179:                idrp_isop.isop_socket = 0;
                    180:                break;
                    181: 
                    182: 
                    183:        case PRU_SENSE:
                    184:                /*
                    185:                 * stat: don't bother with a blocksize.
                    186:                 */
                    187:                return (0);
                    188: 
                    189:        default:
                    190:                return (EOPNOTSUPP);    /* do not free mbuf's */
                    191:        }
                    192: 
                    193: release:
                    194:        if (control) {
                    195:                printf("idrp control data unexpectedly retained\n");
                    196:                m_freem(control);
                    197:        }
                    198:        if (m)
                    199:                m_freem(m);
                    200:        return (error);
                    201: }

unix.superglobalmegacorp.com

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