|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1982, 1986, 1988 Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution is only permitted until one year after the first shipment ! 6: * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and ! 7: * binary forms are permitted provided that: (1) source distributions retain ! 8: * this entire copyright notice and comment, and (2) distributions including ! 9: * binaries display the following acknowledgement: This product includes ! 10: * software developed by the University of California, Berkeley and its ! 11: * contributors'' in the documentation or other materials provided with the ! 12: * distribution and in all advertising materials mentioning features or use ! 13: * of this software. Neither the name of the University nor the names of ! 14: * its contributors may be used to endorse or promote products derived from ! 15: * this software without specific prior written permission. ! 16: * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED ! 17: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF ! 18: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 19: * ! 20: * @(#)if_imphost.h 7.7 (Berkeley) 6/28/90 ! 21: */ ! 22: ! 23: /* ! 24: * Host structure used with IMP's. ! 25: * Used to hold outgoing packets which ! 26: * would exceed allowed RFNM count. ! 27: * ! 28: * These structures are packed into ! 29: * mbuf's and kept as small as possible. ! 30: */ ! 31: struct host { ! 32: struct mbuf *h_q; /* holding queue */ ! 33: u_short h_timer; /* used to stay off deletion */ ! 34: u_short h_imp; /* host's imp number */ ! 35: u_char h_host; /* host's number on imp */ ! 36: u_char h_qcnt; /* size of holding q */ ! 37: u_char h_rfnm; /* # outstanding rfnm's */ ! 38: u_char h_flags; /* see below */ ! 39: }; ! 40: ! 41: /* ! 42: * A host structure is kept around (even when there are no ! 43: * references to it) for a spell to avoid constant reallocation ! 44: * and also to reflect IMP status back to sites which aren't ! 45: * directly connected to the IMP. When structures are marked ! 46: * idle, a timer is started; when the timer expires the structure ! 47: * is deallocated. A structure may be reused before the timer expires. ! 48: * A structure holds a reference on the containing mbuf when it is marked ! 49: * HF_INUSE. ! 50: */ ! 51: #define HF_INUSE 0x1 ! 52: #define HF_DEAD (1<<IMPTYPE_HOSTDEAD) ! 53: #define HF_UNREACH (1<<IMPTYPE_HOSTUNREACH) ! 54: ! 55: #define HOSTTIMER 128 /* keep structure around awhile */ ! 56: ! 57: /* ! 58: * Mark a host structure free; used if host entry returned by hostlookup ! 59: * isn't needed. h_rfnm must be zero. ! 60: */ ! 61: #define hostfree(hp) { \ ! 62: if ((hp)->h_timer == 0 && (hp)->h_qcnt == 0 && \ ! 63: (hp)->h_flags & HF_INUSE) \ ! 64: hostrelease(hp); \ ! 65: } ! 66: ! 67: /* ! 68: * Release a host entry when last rfnm is received. ! 69: */ ! 70: #define hostidle(hp) { (hp)->h_timer = HOSTTIMER; } ! 71: ! 72: /* ! 73: * Host structures, as seen inside an mbuf. ! 74: * Hashing on the host and imp is used to ! 75: * select an index into the first mbuf. Collisions ! 76: * are then resolved by searching successive ! 77: * mbuf's at the same index. Reclamation is done ! 78: * automatically at the time a structure is freed. ! 79: */ ! 80: #define HPMBUF ((MLEN - sizeof(int)) / sizeof(struct host)) ! 81: /* don't need to swab as long as HPMBUF is odd */ ! 82: #if defined(notdef) && BYTE_ORDER == BIG_ENDIAN ! 83: #define HOSTHASH(imp, host) ((unsigned)(ntohs(imp)+(host)) % HPMBUF) ! 84: #else ! 85: #define HOSTHASH(imp, host) ((unsigned)((imp)+(host)) % HPMBUF) ! 86: #endif ! 87: ! 88: /* ! 89: * In-line expansions for queuing operations on ! 90: * host message holding queue. Queue is maintained ! 91: * as circular list with the head pointing to the ! 92: * last message in the queue. ! 93: */ ! 94: #define HOST_ENQUE(hp, m) { \ ! 95: register struct mbuf *n; \ ! 96: (hp)->h_qcnt++; \ ! 97: if ((n = (hp)->h_q) == 0) \ ! 98: (hp)->h_q = (m)->m_act = (m); \ ! 99: else { \ ! 100: (m)->m_act = n->m_act; \ ! 101: (hp)->h_q = n->m_act = (m); \ ! 102: } \ ! 103: } ! 104: #define HOST_DEQUE(hp, m) { \ ! 105: if ((m) = (hp)->h_q) { \ ! 106: if ((m)->m_act == (m)) \ ! 107: (hp)->h_q = 0; \ ! 108: else { \ ! 109: (m) = (m)->m_act; \ ! 110: (hp)->h_q->m_act = (m)->m_act; \ ! 111: } \ ! 112: (hp)->h_qcnt--; \ ! 113: (m)->m_act = 0; \ ! 114: } \ ! 115: } ! 116: ! 117: struct hmbuf { ! 118: int hm_count; /* # of struct's in use */ ! 119: struct host hm_hosts[HPMBUF]; /* data structures proper */ ! 120: }; ! 121: ! 122: #ifdef KERNEL ! 123: struct host *hostlookup(); ! 124: struct host *hostenter(); ! 125: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.