Annotation of researchv8dc/sys/chaosld/chconn.c, revision 1.1

1.1     ! root        1: /*
        !             2:  *             C H  C O N N
        !             3:  *
        !             4:  * Connection handling utilities for the Chaosnet line discipline.
        !             5:  *
        !             6:  *
        !             7:  * (c) Copyright 1984  Nirvonics, Inc.
        !             8:  *
        !             9:  * Written by Kurt Gollhardt
        !            10:  * Last update Thu Dec  6 13:47:21 1984
        !            11:  *
        !            12:  * This software is the property of Nirvonics, Inc.
        !            13:  * All rights reserved.
        !            14:  *
        !            15:  */
        !            16: 
        !            17: #include "ch.h"
        !            18: #if NCH > 0
        !            19: #include "../h/param.h"
        !            20: #include "../h/systm.h"
        !            21: #include "../h/stream.h"
        !            22: #include "../h/conf.h"
        !            23: #include "../chaosld/types.h"
        !            24: #include "../chaosld/constants.h"
        !            25: #include "../chaosld/globals.h"
        !            26: 
        !            27: 
        !            28: /*
        !            29:  * Allocate a connection and return it, also allocating a slot in Chconntab
        !            30:  */
        !            31: struct connection *
        !            32: new_conn(tidx)
        !            33: {
        !            34:      register struct connection *conn;
        !            35:      static int uniq;
        !            36: 
        !            37:      if ((conn = cnalloc()) == NOCONN) {
        !            38:           debug(DCONN|DABNOR,printf("Conn: alloc failed (packet)\n"));
        !            39:           Chaos_error = CHNOCONN;
        !            40:           return(NOCONN);
        !            41:      }
        !            42: 
        !            43:      bfill((char *)conn, sizeof(struct connection), 0);
        !            44:      if (++uniq == 0)
        !            45:           uniq = 1;
        !            46:      conn->cn_lidx.ci_uniq = uniq;
        !            47:      conn->cn_lidx.ci_tidx = tidx;
        !            48:      conn->cn_state = 0;
        !            49:      conn->cn_time = Chclock;
        !            50: 
        !            51:      debug(DCONN,printf("Conn: alloc #%x\n", conn->cn_lidx));
        !            52:      return(conn);
        !            53: }
        !            54:      
        !            55: /*
        !            56:  * Release a connection - freeing all associated storage.
        !            57:  * This removes all trace of the connection.
        !            58:  */
        !            59: free_conn(conn)
        !            60:      struct connection   *conn;
        !            61: {
        !            62:      Chconn[conn->cn_lidx.ci_tidx] = NOCONN;
        !            63:      freelist(conn->cn_routorder);
        !            64:      freelist(conn->cn_thead);
        !            65:      if (conn->cn_toutput != NOPKT)
        !            66:           free_packet(conn->cn_toutput);
        !            67:      if (conn->cn_expkt != NOPKT)
        !            68:           free_packet(conn->cn_expkt);
        !            69:      if (conn->cn_wait != NOBLOCK) /* ??? */
        !            70:           freeb(conn->cn_wait);
        !            71:      debug(DCONN,printf("Conn: release #%x\n", conn->cn_lidx));
        !            72:      cnfree(conn);
        !            73: }
        !            74: 
        !            75: 
        !            76: /*
        !            77:  * Make a connection closed with given state, at interrupt time.
        !            78:  * Queue the given packet on the input queue for the user.
        !            79:  */
        !            80: close_conn(conn, state, pkt)
        !            81:      register struct connection    *conn;
        !            82:      register struct packet        *pkt;
        !            83: {
        !            84:      freelist(conn->cn_thead);
        !            85:      conn->cn_thead = conn->cn_ttail = NOPKT;
        !            86:      conn->cn_state = state;
        !            87:      debug(DCONN|DABNOR, printf("Conn #%x: CLOSED: state: %d\n",
        !            88:           conn->cn_lidx, state));
        !            89:      if (pkt != NOPKT)
        !            90:           chdrint(conn, pkt);
        !            91:      chd_newstate(conn);
        !            92: }
        !            93: 
        !            94: #endif

unix.superglobalmegacorp.com

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