1 /*	if_imphost.h	6.1	83/07/29	*/
2 
3 /*
4  * Host structure used with IMP's.
5  * Used to hold outgoing packets which
6  * would exceed allowed RFNM count.
7  *
8  * These structures are packed into
9  * mbuf's and kept as small as possible.
10  */
11 struct host {
12 	struct	mbuf *h_q;		/* holding queue */
13 	struct	in_addr h_addr;		/* host's address */
14 	u_char	h_qcnt;          	/* size of holding q */
15 	u_char	h_timer;		/* used to stay off deletion */
16 	u_char	h_rfnm;			/* # outstanding rfnm's */
17 	u_char	h_flags;		/* see below */
18 };
19 
20 /*
21  * A host structure is kept around (even when there are no
22  * references to it) for a spell to avoid constant reallocation
23  * and also to reflect IMP status back to sites which aren't
24  * directly connected to the IMP.  When structures are marked
25  * free, a timer is started; when the timer expires the structure
26  * is scavenged.
27  */
28 #define	HF_INUSE	0x1
29 #define	HF_DEAD		(1<<IMPTYPE_HOSTDEAD)
30 #define	HF_UNREACH	(1<<IMPTYPE_HOSTUNREACH)
31 
32 #define	HOSTTIMER	128		/* keep structure around awhile */
33 
34 /*
35  * Host structures, as seen inside an mbuf.
36  * Hashing on the host address is used to
37  * select an index into the first mbuf.  Collisions
38  * are then resolved by searching successive
39  * mbuf's at the same index.  Reclamation is done
40  * automatically at the time a structure is free'd.
41  */
42 #define	HPMBUF	((MLEN - sizeof(int)) / sizeof(struct host))
43 #if vax
44 #define	HOSTHASH(a)	((((a).s_addr>>8)+(a).s_net) % HPMBUF)
45 #endif
46 
47 /*
48  * In-line expansions for queuing operations on
49  * host message holding queue.  Queue is maintained
50  * as circular list with the head pointing to the
51  * last message in the queue.
52  */
53 #define	HOST_ENQUE(hp, m) { \
54 	register struct mbuf *n; \
55 	(hp)->h_qcnt++; \
56 	if ((n = (hp)->h_q) == 0) \
57 		(hp)->h_q = (m)->m_act = (m); \
58 	else { \
59 		(m)->m_act = n->m_act; \
60 		(hp)->h_q = n->m_act = (m); \
61 	} \
62 }
63 #define	HOST_DEQUE(hp, m) { \
64 	if ((m) = (hp)->h_q) { \
65 		if ((m)->m_act == (m)) \
66 			(hp)->h_q = 0; \
67 		else { \
68 			(m) = (m)->m_act; \
69 			(hp)->h_q->m_act = (m)->m_act; \
70 		} \
71 		(hp)->h_qcnt--; \
72 		(m)->m_act = 0; \
73 	} \
74 }
75 
76 struct hmbuf {
77 	int	hm_count;		/* # of struct's in use */
78 	struct	host hm_hosts[HPMBUF];	/* data structures proper */
79 };
80 
81 #ifdef KERNEL
82 struct host *hostlookup();
83 struct host *hostenter();
84 struct mbuf *hostdeque();
85 #endif
86