Annotation of kernel/bsd/netat/h/atp_inc.h, 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: /*
                     27:  *     Copyright (c) 1988, 1989 Apple Computer, Inc. 
                     28:  *
                     29:  *     The information contained herein is subject to change without
                     30:  *     notice and  should not be  construed as a commitment by Apple
                     31:  *     Computer, Inc. Apple Computer, Inc. assumes no responsibility
                     32:  *     for any errors that may appear.
                     33:  *
                     34:  *     Confidential and Proprietary to Apple Computer, Inc.
                     35:  */
                     36: 
                     37: /* "@(#)atp_inc.h: 2.0, 1.16; 10/4/93; Copyright 1988-89, Apple Computer, Inc." */
                     38: 
                     39: #include "sysglue.h"
                     40: #include "debug.h"
                     41: #include "at-config.h"
                     42: 
                     43: /*
                     44:  *     Stuff for accessing protocol headers 
                     45:  */
                     46: #define AT_DDP_HDR(m) ((at_ddp_t *)(gbuf_rptr(m)))
                     47: #define AT_ATP_HDR(m) ((at_atp_t *)(&((at_ddp_t *)(gbuf_rptr(m)))->data[0]))
                     48: 
                     49: /*
                     50:  *     Masks for accessing/manipulating the bitmap field in atp headers
                     51:  */
                     52: 
                     53: #ifdef ATP_DECLARE
                     54: unsigned char atp_mask [] = {
                     55:        0x01, 0x02, 0x04, 0x08, 
                     56:        0x10, 0x20, 0x40, 0x80, 
                     57: };
                     58: 
                     59: unsigned char atp_lomask [] = {
                     60:        0x00, 0x01, 0x03, 0x07, 
                     61:        0x0f, 0x1f, 0x3f, 0x7f, 
                     62:        0xff
                     63: };
                     64: #else
                     65: extern unsigned char atp_mask [];
                     66: extern unsigned char atp_lomask [];
                     67: #endif /* ATP_DECLARE */
                     68: 
                     69: /*
                     70:  *     doubly linked queue types and primitives
                     71:  */
                     72: 
                     73: #define ATP_Q_ENTER(hdr, object, entry) {                                      \
                     74:                if ((hdr).head) {                                               \
                     75:                        (hdr).head->entry.prev = (object);                      \
                     76:                        (object)->entry.next = (hdr).head;                      \
                     77:                } else {                                                        \
                     78:                        (hdr).tail = (object);                                  \
                     79:                        (object)->entry.next = NULL;                            \
                     80:                }                                                               \
                     81:                (object)->entry.prev = NULL;                                    \
                     82:                (hdr).head = (object);                                          \
                     83:        }
                     84: 
                     85: #define ATP_Q_APPEND(hdr, object, entry) {                                     \
                     86:                if ((hdr).head) {                                               \
                     87:                        (hdr).tail->entry.next = (object);                      \
                     88:                        (object)->entry.prev = (hdr).tail;                      \
                     89:                } else {                                                        \
                     90:                        (hdr).head = (object);                                  \
                     91:                        (object)->entry.prev = NULL;                            \
                     92:                }                                                               \
                     93:                (object)->entry.next = NULL;                                    \
                     94:                (hdr).tail = (object);                                          \
                     95:        }
                     96: 
                     97: #define ATP_Q_REMOVE(hdr, object, entry) {                                     \
                     98:                if ((object)->entry.prev) {                                     \
                     99:                        (object)->entry.prev->entry.next = (object)->entry.next;\
                    100:                } else {                                                        \
                    101:                        (hdr).head = (object)->entry.next;                      \
                    102:                }                                                               \
                    103:                if ((object)->entry.next) {                                     \
                    104:                        (object)->entry.next->entry.prev = (object)->entry.prev;\
                    105:                } else {                                                        \
                    106:                        (hdr).tail = (object)->entry.prev;                      \
                    107:                }                                                               \
                    108:        }
                    109: 
                    110: struct atp_rcb_qhead {
                    111:        struct atp_rcb  *head;
                    112:        struct atp_rcb  *tail;
                    113: };
                    114: 
                    115: struct atp_rcb_q {
                    116:        struct atp_rcb *prev;
                    117:        struct atp_rcb *next;
                    118: };
                    119: 
                    120: struct atp_trans_qhead {
                    121:        struct atp_trans *head;
                    122:        struct atp_trans *tail;
                    123: };
                    124: 
                    125: struct atp_trans_q {
                    126:        struct atp_trans *prev;
                    127:        struct atp_trans *next;
                    128: };
                    129: 
                    130: /*
                    131:  *     Locally saved remote node address
                    132:  */
                    133: 
                    134: struct atp_socket {
                    135:        u_short         net;
                    136:        at_node         node;
                    137:        at_socket       socket;
                    138: };
                    139: 
                    140: /*
                    141:  *     transaction control block (local context at requester end)
                    142:  */
                    143: 
                    144: struct atp_trans {
                    145:        struct atp_trans_q      tr_list;                /* trans list */
                    146:        struct atp_state        *tr_queue;              /* state data structure */
                    147:        gbuf_t                  *tr_xmt;                /* message being sent */
                    148:        gbuf_t                  *tr_rcv[8];             /* message being rcvd */
                    149:        unsigned int            tr_retry;               /* # retries left */
                    150:        unsigned int            tr_timeout;             /* timer interval */
                    151:        char                    tr_state;               /* current state */
                    152:        char                    tr_rsp_wait;            /* waiting for transaction response */
                    153:        char                    filler[2];
                    154:        unsigned char           tr_xo;                  /* execute once transaction */
                    155:        unsigned char           tr_bitmap;              /* requested bitmask */
                    156:        unsigned short          tr_tid;                 /* transaction id */
                    157:        struct atp_socket       tr_socket;              /* the remote socket id */
                    158:        struct atp_trans_q      tr_snd_wait;            /* list of transactions waiting
                    159:                                                           for space to send a msg */
                    160:        at_socket               tr_local_socket;
                    161:        unsigned char   tr_local_node;
                    162:        unsigned char   tr_local_net[2];
                    163:        gbuf_t                  *tr_bdsp;               /* bds structure pointer */
                    164:        unsigned int            tr_tmo_delta;
                    165:        void                            (*tr_tmo_func)();
                    166:        struct atp_trans        *tr_tmo_next;
                    167:        struct atp_trans        *tr_tmo_prev;
                    168:        atlock_t tr_lock;
                    169:        atevent_t tr_event;
                    170: };
                    171: 
                    172: #define        TRANS_TIMEOUT           0       /* waiting for a reply */
                    173: #define        TRANS_REQUEST           1       /* waiting to send a request */
                    174: #define        TRANS_RELEASE           2       /* waiting to send a release */
                    175: #define        TRANS_DONE              3       /* done - waiting for poll to complete */
                    176: #define        TRANS_FAILED            4       /* done - waiting for poll to report failure */
                    177: 
                    178: /*
                    179:  *     reply control block (local context at repling end)
                    180:  */
                    181: 
                    182: struct atp_rcb {
                    183:        struct atp_rcb_q        rc_list;                /* rcb list */
                    184:        struct atp_rcb_q        rc_tlist;
                    185:        struct atp_state        *rc_queue;              /* state data structure */
                    186:        gbuf_t                  *rc_xmt;                /* replys being sent */
                    187:        gbuf_t                  *rc_ioctl;              /* waiting ioctl */
                    188:        char                    rc_snd[8];              /* replys actually to be sent */
                    189:        int                     rc_pktcnt;              /* no of pkts in this trans */
                    190:        short                   rc_state;               /* current state */
                    191:        unsigned char           rc_xo;                  /* execute once transaction */
                    192:        unsigned char           rc_local_node;
                    193:        unsigned char           rc_local_net[2];
                    194:        short                   rc_rep_waiting;         /* in the reply wait list */
                    195:        int                     rc_timestamp;           /* reply timer */
                    196:        unsigned char           rc_bitmap;              /* replied bitmask */
                    197:        unsigned char           rc_not_sent_bitmap;     /* replied bitmask */
                    198:        unsigned short          rc_tid;                 /* transaction id */
                    199:        struct atp_socket       rc_socket;              /* the remote socket id */
                    200: };
                    201: 
                    202: #define RCB_UNQUEUED           0       /* newly allocated, not q'd */
                    203: #define RCB_RESPONDING         2       /* waiting all of response from process*/
                    204: #define RCB_RESPONSE_FULL      3       /* got all of response */
                    205: #define RCB_RELEASED           4       /* got our release */
                    206: #define RCB_PENDING            5       /* a no wait rcb is full */
                    207: #define RCB_NOTIFIED           6
                    208: #define RCB_SENDING            7       /* we're currently xmitting this trans */
                    209: 
                    210: /*
                    211:  *     socket state (per module data structure)
                    212:  */
                    213: 
                    214: struct atp_state {
                    215:        gref_t          *atp_gref;      /* must be the first entry */
                    216:        int                     atp_pid; /* process id, must be the second entry */
                    217:        gbuf_t                  *atp_msgq; /* data msg, must be the third entry */
                    218:        unsigned char   dflag; /* structure flag, must be the fourth entry */
                    219:        unsigned char   filler;
                    220:        short   atp_minor_no;
                    221:        short   atp_socket_no;
                    222:        short   atp_flags;              /* general flags */
                    223:        struct atp_trans_qhead  atp_trans_wait;         /* pending transaction list */
                    224:        struct atp_state        *atp_trans_waiting;     /* list of atps waiting for a
                    225:                                                           free transaction */
                    226:        unsigned int            atp_retry;              /* retry count */
                    227:        unsigned int            atp_timeout;            /* retry timeout */
                    228:        struct atp_state        *atp_rcb_waiting;
                    229:        struct atp_rcb_qhead    atp_rcb;                /* active rcbs */
                    230:        struct atp_rcb_qhead    atp_attached;           /* rcb's waiting to be read */
                    231:        atlock_t atp_lock;
                    232:        atevent_t atp_event;
                    233:        atlock_t atp_delay_lock;
                    234:        atevent_t atp_delay_event;
                    235: };
                    236: 
                    237: 
                    238: /*
                    239:  *     atp_state flag definitions
                    240:  */
                    241: #define ATP_CLOSING  0x08        /* atp stream in process of closing */
                    242: 
                    243: 
                    244: /*
                    245:  *     tcb/rcb/state allocation queues
                    246:  */
                    247: 
                    248: /*
                    249:  * Size defines; must be outside following #ifdef to permit
                    250:  *  debugging code to reference independent of ATP_DECLARE
                    251:  */
                    252: #define        NATP_RCB        512     /* the number of ATP RCBs at once */
                    253: #define NATP_STATE     192     /* the number of ATP sockets open at once */
                    254:                                /* note: I made NATP_STATE == NSOCKETS */
                    255: 
                    256: #ifdef ATP_DECLARE
                    257: struct atp_trans *atp_trans_free_list = NULL;  /* free transactions */
                    258: struct atp_rcb *atp_rcb_free_list = NULL;      /* free rcbs */
                    259: static struct atp_state *atp_free_list = NULL;         /* free atp states */
                    260: static struct atp_rcb atp_rcb_data[NATP_RCB];
                    261: static struct atp_state atp_state_data[NATP_STATE];
                    262: 
                    263: #else
                    264: extern struct atp_trans *atp_trans_free_list;          /* free transactions */
                    265: extern struct atp_rcb *atp_rcb_free_list;              /* free rcbs */
                    266: extern struct atp_state *atp_free_list;                        /* free atp states */
                    267: extern struct atp_rcb atp_rcb_data[];
                    268: extern struct atp_state atp_state_data[];
                    269: 
                    270: extern void atp_req_timeout();
                    271: extern void atp_rcb_timer();
                    272: extern void atp_x_done();
                    273: extern struct atp_rcb *atp_rcb_alloc();
                    274: extern struct atp_trans *atp_trans_alloc();
                    275: #endif /* ATP_DECLARE */
                    276: 
                    277: /* prototypes */
                    278: void atp_send_req(gref_t *, gbuf_t *);
                    279: void atp_drop_req(gref_t *, gbuf_t *);
                    280: void atp_send_rsp(gref_t *, gbuf_t *, int);
                    281: void atp_wput(gref_t *, gbuf_t *);
                    282: void atp_rput(gref_t *, gbuf_t *);
                    283: void atp_retry_req(gbuf_t *);
                    284: void atp_stop(gbuf_t *, int);
                    285: void atp_cancel_req(gref_t *, unsigned short);
                    286: int atp_open(gref_t *, int);
                    287: int atp_bind(gref_t *, unsigned int, unsigned char *);
                    288: int atp_close(gref_t *, int);
                    289: gbuf_t *atp_build_release(struct atp_trans *);
                    290: void atp_req_timeout(struct atp_trans *);
                    291: void atp_free(struct atp_trans *);
                    292: void atp_x_done(struct atp_trans *);
                    293: void atp_send(struct atp_trans *);
                    294: void atp_rsp_ind(struct atp_trans *, gbuf_t *);
                    295: void atp_trans_free(struct atp_trans *);
                    296: void atp_reply(struct atp_rcb *);
                    297: void atp_rcb_free(struct atp_rcb *);
                    298: void atp_send_replies(struct atp_state *, struct atp_rcb *);
                    299: void atp_dequeue_atp(struct atp_state *);
                    300: int atp_iocack(struct atp_state *, gbuf_t *);
                    301: void atp_req_ind(struct atp_state *, gbuf_t *);
                    302: int atp_iocnak(struct atp_state *, gbuf_t *, int);
                    303: void atp_trp_timer(void *, int);
                    304: void atp_timout(void (*func)(), struct atp_trans *, int);
                    305: void atp_untimout(void (*func)(), struct atp_trans *);
                    306: int atp_tid(struct atp_state *);

unix.superglobalmegacorp.com

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