Annotation of XNU/bsd/netat/sys_dep.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * The contents of this file constitute Original Code as defined in and
                      7:  * are subject to the Apple Public Source License Version 1.1 (the
                      8:  * "License").  You may not use this file except in compliance with the
                      9:  * License.  Please obtain a copy of the License at
                     10:  * http://www.apple.com/publicsource and read it before using this file.
                     11:  * 
                     12:  * This Original Code and all software distributed under the License are
                     13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     17:  * License for the specific language governing rights and limitations
                     18:  * under the License.
                     19:  * 
                     20:  * @APPLE_LICENSE_HEADER_END@
                     21:  */
                     22: /*
                     23:  *     Copyright (c) 1995-1998 Apple Computer, Inc. 
                     24:  *
                     25:  *  Change Log:
                     26:  *    Created February 20, 1995 by Tuyen Nguyen
                     27:  *    Modified for MP, 1996 by Tuyen Nguyen
                     28:  *    Modified, March 17, 1997 by Tuyen Nguyen for MacOSX.
                     29:  */
                     30: #include <sys/errno.h>
                     31: #include <sys/types.h>
                     32: #include <sys/param.h>
                     33: #include <machine/spl.h>
                     34: #include <sys/systm.h>
                     35: #include <sys/kernel.h>
                     36: #include <sys/proc.h>
                     37: #include <sys/filedesc.h>
                     38: #include <sys/fcntl.h>
                     39: #include <sys/mbuf.h>
                     40: #include <sys/malloc.h>
                     41: #include <sys/file.h>
                     42: #include <sys/socket.h>
                     43: 
                     44: #include <netat/sysglue.h>
                     45: #include <netat/appletalk.h>
                     46: #include <netat/at_pcb.h>
                     47: #include <netat/debug.h>
                     48: 
                     49: int (*sys_ATsocket)() = 0;
                     50: int (*sys_ATgetmsg)() = 0;
                     51: int (*sys_ATputmsg)() = 0;
                     52: int (*sys_ATPsndreq)() = 0;
                     53: int (*sys_ATPsndrsp)() = 0;
                     54: int (*sys_ATPgetreq)() = 0;
                     55: int (*sys_ATPgetrsp)() = 0;
                     56: 
                     57: int ATsocket(proc, uap, retval)
                     58:        void *proc;
                     59:        struct {
                     60:          int proto;
                     61:        } *uap;
                     62:        int *retval;
                     63: {
                     64:        int err;
                     65: 
                     66:        if (sys_ATsocket)
                     67:                *retval = (*sys_ATsocket)(uap->proto, &err, proc);
                     68:        else {
                     69:                *retval = -1;
                     70:                err = ENXIO;
                     71:        }
                     72:        return err;
                     73: }
                     74: 
                     75: int ATgetmsg(proc, uap, retval)
                     76:        void *proc;
                     77:        struct {
                     78:          int fd;
                     79:          void *ctlptr;
                     80:          void *datptr;
                     81:          int *flags;
                     82:        } *uap;
                     83:        int *retval;
                     84: {
                     85:        int err;
                     86: 
                     87:        if (sys_ATgetmsg)
                     88:                *retval = (*sys_ATgetmsg)(uap->fd,
                     89:                        uap->ctlptr, uap->datptr, uap->flags, &err, proc);
                     90:        else {
                     91:                *retval = -1;
                     92:                err = ENXIO;
                     93:        }
                     94:        return err;
                     95: }
                     96: 
                     97: int ATputmsg(proc, uap, retval)
                     98:        void *proc;
                     99:        struct {
                    100:        int fd;
                    101:        void *ctlptr;
                    102:        void *datptr;
                    103:        int flags;
                    104:        } *uap;
                    105:        int *retval;
                    106: {
                    107:        int err;
                    108: 
                    109:        if (sys_ATputmsg)
                    110:                *retval = (*sys_ATputmsg)(uap->fd,
                    111:                        uap->ctlptr, uap->datptr, uap->flags, &err, proc);
                    112:        else {
                    113:                *retval = -1;
                    114:                err = ENXIO;
                    115:        }
                    116:        return err;
                    117: }
                    118: 
                    119: int ATPsndreq(proc, uap, retval)
                    120:        void *proc;
                    121:        struct {
                    122:          int fd;
                    123:          unsigned char *buf;
                    124:          int len;
                    125:          int nowait;
                    126:        } *uap;
                    127:        int *retval;
                    128: {
                    129:        int err;
                    130: 
                    131:        if (sys_ATPsndreq)
                    132:                *retval = (*sys_ATPsndreq)(uap->fd,
                    133:                        uap->buf, uap->len, uap->nowait, &err, proc);
                    134:        else {
                    135:                *retval = -1;
                    136:                err= ENXIO;
                    137:        }
                    138:        return err;
                    139: }
                    140: 
                    141: int ATPsndrsp(proc, uap, retval)
                    142:        void *proc;
                    143:        struct {
                    144:          int fd;
                    145:          unsigned char *respbuff;
                    146:          int resplen;
                    147:          int datalen;
                    148:        } *uap;
                    149:        int *retval;
                    150: {
                    151:        int err;
                    152: 
                    153:        if (sys_ATPsndrsp)
                    154:                *retval = (*sys_ATPsndrsp)(uap->fd,
                    155:                        uap->respbuff, uap->resplen, uap->datalen, &err, proc);
                    156:        else {
                    157:                *retval = -1;
                    158:                err = ENXIO;
                    159:        }
                    160:        return err;
                    161: }
                    162: 
                    163: int ATPgetreq(proc, uap, retval)
                    164:        void *proc;
                    165:        struct {
                    166:          int fd;
                    167:          unsigned char *buf;
                    168:          int buflen;
                    169:        } *uap;
                    170:        int *retval;
                    171: {
                    172:        int err;
                    173: 
                    174:        if (sys_ATPgetreq)
                    175:                *retval = (*sys_ATPgetreq)(uap->fd,
                    176:                        uap->buf, uap->buflen, &err, proc);
                    177:        else {
                    178:                *retval = -1;
                    179:                err = ENXIO;
                    180:        }
                    181:        return err;
                    182: }
                    183: 
                    184: int ATPgetrsp(proc, uap, retval)
                    185:        void *proc;
                    186:        struct {
                    187:          int fd;
                    188:          unsigned char *bdsp;
                    189:        } *uap;
                    190:        int *retval;
                    191: {
                    192:        int err;
                    193: 
                    194:        if (sys_ATPgetrsp)
                    195:                *retval = (*sys_ATPgetrsp)(uap->fd, uap->bdsp, &err, proc);
                    196:        else {
                    197:                *retval = -1;
                    198:                err = ENXIO;
                    199:        }
                    200:        return err;
                    201: }
                    202: 
                    203: int atalk_closeref(fp, grefp)
                    204:        struct file *fp;
                    205:        gref_t **grefp;
                    206: {
                    207:        *grefp = (gref_t *)fp->f_data;
                    208: 
                    209:        fp->f_data = 0;
                    210: /*
                    211:        kprintf("atalk_closeref: fp = 0x%x, gref = 0x%x\n", (u_int)fp, 
                    212:                (u_int)*grefp);
                    213: */
                    214:        return 0;
                    215: }
                    216: 
                    217: int atalk_openref(gref, retfd, proc)
                    218:        gref_t *gref;
                    219:        int *retfd;
                    220:        struct proc *proc;
                    221: {
                    222:        extern int _ATread(), _ATwrite(),_ATioctl(), _ATselect(), _ATclose();
                    223:        static struct fileops fileops = 
                    224:                {_ATread, _ATwrite, _ATioctl, _ATselect, _ATclose};
                    225:        int err, fd;
                    226:        struct file *fp;
                    227: 
                    228:        if ((err = falloc(proc, &fp, &fd)) != 0)
                    229:                return err;
                    230:        fp->f_flag = FREAD|FWRITE;
                    231:        /*##### LD 5/7/96 Warning: we don't have a "DTYPE_OTHER" for
                    232:         * MacOSX, so defines DTYPE_ATALK as DTYPE_SOCKET...
                    233:         */
                    234:        fp->f_type = DTYPE_ATALK+1;
                    235:        fp->f_ops = &fileops;
                    236:        *fdflags(proc, fd) &= ~UF_RESERVED;
                    237:        *retfd = fd;
                    238:        fp->f_data = (void *)gref;
                    239: /*
                    240:        kprintf("atalk_openref: fp = 0x%x, gref = 0x%x\n", (u_int)fp, (u_int)gref);
                    241: */
                    242:        return 0;
                    243: }
                    244: 
                    245: /* go from file descriptor to gref, which has been saved in fp->f_data */
                    246: int atalk_getref(fp, fd, grefp, proc)
                    247:        struct file *fp;
                    248:        int fd;
                    249:        gref_t **grefp;
                    250:        struct proc *proc;
                    251: {
                    252:        if (fp == 0) {
                    253:                int error = fdgetf(proc, fd, &fp);
                    254: 
                    255:                if (error) {
                    256: 
                    257:                        *grefp = (gref_t *)0;
                    258:                        return EBADF;
                    259:                }
                    260:        }
                    261:        if ((*grefp = (gref_t *)fp->f_data) == 0)
                    262:                return EBADF;
                    263:        return 0;
                    264: }

unix.superglobalmegacorp.com

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