Annotation of kernel/bsd/netccitt/llc_timer.c, revision 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) Dirk Husemann, Computer Science Department IV, 
        !            27:  *              University of Erlangen-Nuremberg, Germany, 1990, 1991, 1992
        !            28:  * Copyright (c) 1992, 1993
        !            29:  *     The Regents of the University of California.  All rights reserved.
        !            30:  * 
        !            31:  * This code is derived from software contributed to Berkeley by
        !            32:  * Dirk Husemann and the Computer Science Department (IV) of
        !            33:  * the University of Erlangen-Nuremberg, Germany.
        !            34:  *
        !            35:  * Redistribution and use in source and binary forms, with or without
        !            36:  * modification, are permitted provided that the following conditions
        !            37:  * are met:
        !            38:  * 1. Redistributions of source code must retain the above copyright
        !            39:  *    notice, this list of conditions and the following disclaimer.
        !            40:  * 2. Redistributions in binary form must reproduce the above copyright
        !            41:  *    notice, this list of conditions and the following disclaimer in the
        !            42:  *    documentation and/or other materials provided with the distribution.
        !            43:  * 3. All advertising materials mentioning features or use of this software
        !            44:  *    must display the following acknowledgement:
        !            45:  *     This product includes software developed by the University of
        !            46:  *     California, Berkeley and its contributors.
        !            47:  * 4. Neither the name of the University nor the names of its contributors
        !            48:  *    may be used to endorse or promote products derived from this software
        !            49:  *    without specific prior written permission.
        !            50:  *
        !            51:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
        !            52:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            53:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            54:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
        !            55:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            56:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            57:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            58:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            59:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            60:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            61:  * SUCH DAMAGE.
        !            62:  *
        !            63:  *     @(#)llc_timer.c 8.1 (Berkeley) 6/10/93
        !            64:  */
        !            65: 
        !            66: #include <sys/param.h>
        !            67: #include <sys/systm.h>
        !            68: #include <sys/mbuf.h>
        !            69: #include <sys/domain.h>
        !            70: #include <sys/socket.h>
        !            71: #include <sys/protosw.h>
        !            72: #include <sys/errno.h>
        !            73: #include <sys/time.h>
        !            74: #include <sys/kernel.h>
        !            75: 
        !            76: #include <net/if.h>
        !            77: #include <net/if_dl.h>
        !            78: #include <net/if_llc.h>
        !            79: 
        !            80: #include <netccitt/dll.h>
        !            81: #include <netccitt/llc_var.h>
        !            82: 
        !            83: 
        !            84: /*
        !            85:  * Various timer values.  They can be adjusted
        !            86:  * by patching the binary with adb if necessary.
        !            87:  */
        !            88: /* ISO 8802-2 timers */
        !            89: int    llc_n2                  = LLC_N2_VALUE;
        !            90: int    llc_ACK_timer           = LLC_ACK_TIMER;
        !            91: int     llc_P_timer             = LLC_P_TIMER;
        !            92: int     llc_BUSY_timer          = LLC_BUSY_TIMER;
        !            93: int     llc_REJ_timer           = LLC_REJ_TIMER;
        !            94: /* Implementation specific timers */
        !            95: int    llc_AGE_timer           = LLC_AGE_TIMER;
        !            96: int     llc_DACTION_timer       = LLC_DACTION_TIMER;
        !            97: 
        !            98: /*
        !            99:  * The timer routine. We are called every 500ms by the kernel.
        !           100:  * Handle the various virtual timers.
        !           101:  */
        !           102: 
        !           103: void
        !           104: llc_timer()
        !           105: {
        !           106:        register struct llc_linkcb *linkp;
        !           107:        register struct llc_linkcb *nlinkp;
        !           108:        register int timer;
        !           109:        register int action;
        !           110:        register int s = splimp();
        !           111: 
        !           112:        /*
        !           113:         * All links are accessible over the doubly linked list llccb_q
        !           114:         */
        !           115:        if (!LQEMPTY) {
        !           116:                /*
        !           117:                 * A for-loop is not that great an idea as the linkp
        !           118:                 * might get deleted if the age timer has expired ...
        !           119:                 */
        !           120:                linkp = LQFIRST;
        !           121:                while (LQVALID(linkp)) {
        !           122:                        nlinkp = LQNEXT(linkp);
        !           123:                        /*
        !           124:                         * Check implementation specific timers first
        !           125:                         */
        !           126:                        /* The delayed action/acknowledge idle timer */
        !           127:                        switch (LLC_TIMERXPIRED(linkp, DACTION)) {
        !           128:                        case LLC_TIMER_RUNNING:
        !           129:                                LLC_AGETIMER(linkp, DACTION);
        !           130:                                break;
        !           131:                        case LLC_TIMER_EXPIRED: {
        !           132:                                register int cmdrsp;
        !           133:                                register int pollfinal;
        !           134: 
        !           135:                                switch (LLC_GETFLAG(linkp, DACTION)) {
        !           136:                                case LLC_DACKCMD:
        !           137:                                        cmdrsp = LLC_CMD, pollfinal = 0;
        !           138:                                        break;
        !           139:                                case LLC_DACKCMDPOLL:
        !           140:                                        cmdrsp = LLC_CMD, pollfinal = 1;
        !           141:                                        break;
        !           142:                                case LLC_DACKRSP:
        !           143:                                        cmdrsp = LLC_RSP, pollfinal = 0;
        !           144:                                        break;
        !           145:                                case LLC_DACKRSPFINAL:
        !           146:                                        cmdrsp = LLC_RSP, pollfinal = 1;
        !           147:                                        break;
        !           148:                                }
        !           149:                                llc_send(linkp, LLCFT_RR, cmdrsp, pollfinal);
        !           150:                                LLC_STOPTIMER(linkp, DACTION);
        !           151:                                break;
        !           152:                        }
        !           153:                        }
        !           154:                        /* The link idle timer */
        !           155:                        switch (LLC_TIMERXPIRED(linkp, AGE)) {
        !           156:                        case LLC_TIMER_RUNNING:
        !           157:                                LLC_AGETIMER(linkp, AGE);
        !           158:                                break;
        !           159:                        case LLC_TIMER_EXPIRED:
        !           160:                                /*
        !           161:                                 * Only crunch the link when really no
        !           162:                                 * timers are running any more.
        !           163:                                 */
        !           164:                                if (llc_anytimersup(linkp) == 0) {
        !           165:                                        llc_dellink(linkp);
        !           166:                                        LLC_STOPTIMER(linkp, AGE);
        !           167:                                        goto gone;
        !           168:                                } else {
        !           169:                                        LLC_STARTTIMER(linkp, AGE);
        !           170:                                }
        !           171:                                break;
        !           172:                        }
        !           173:                        /* 
        !           174:                         * Now, check all the ISO 8802-2 timers 
        !           175:                         */
        !           176:                        FOR_ALL_LLC_TIMERS(timer) {
        !           177:                                action = 0;
        !           178:                                if ((linkp->llcl_timerflags & (1<<timer)) &&
        !           179:                                    (linkp->llcl_timers[timer] == 0)) {
        !           180:                                        switch (timer) {
        !           181:                                        case LLC_ACK_SHIFT:
        !           182:                                                action = LLC_ACK_TIMER_EXPIRED;
        !           183:                                                break;
        !           184:                                        case LLC_P_SHIFT:
        !           185:                                                action = LLC_P_TIMER_EXPIRED;
        !           186:                                                break;
        !           187:                                        case LLC_BUSY_SHIFT:
        !           188:                                                action = LLC_BUSY_TIMER_EXPIRED;
        !           189:                                                break;
        !           190:                                        case LLC_REJ_SHIFT:
        !           191:                                                action = LLC_REJ_TIMER_EXPIRED;
        !           192:                                                break;
        !           193:                                        }
        !           194:                                        linkp->llcl_timerflags &= ~(1<<timer);
        !           195:                                        (void)llc_statehandler(linkp, (struct llc *)0, action, 0, 1);
        !           196:                                } else if (linkp->llcl_timers[timer] > 0)
        !           197:                                        linkp->llcl_timers[timer]--;
        !           198:                        }
        !           199:                        
        !           200: gone:                  linkp = nlinkp;
        !           201:                }
        !           202:        }
        !           203:        splx (s);
        !           204: }

unix.superglobalmegacorp.com

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