/* if_imphost.c 4.5 82/02/21 */
* Host table manipulation routines.
* Only needed when shipping stuff through an IMP.
#include "../net/in_systm.h"
#include "../net/if_imp.h"
#include "../net/if_imphost.h"
* Head of host table hash chains.
* Given an internet address
* return a host structure (if it exists).
register struct host
*hp
;
register int hash
= HOSTHASH(addr
);
for (m
= hosts
; m
; m
= m
->m_next
) {
hp
= &mtod(m
, struct hmbuf
*)->hm_hosts
[hash
];
if (hp
->h_addr
.s_addr
== addr
.s_addr
)
* Enter a reference to this host's internet
* address. If no host structure exists, create
* one and hook it into the host database.
register struct mbuf
*m
, **mprev
;
register struct host
*hp
, *hp0
= 0;
register int hash
= HOSTHASH(addr
);
hp
= &mtod(m
, struct hmbuf
*)->hm_hosts
[hash
];
if (hp
->h_addr
.s_addr
== addr
.s_addr
)
* No current host structure, make one.
* If our search ran off the end of the
* chain of mbuf's, allocate another.
m
= m_getclr(M_DONTWAIT
);
hp0
= &mtod(m
, struct hmbuf
*)->hm_hosts
[hash
];
mtod(dtom(hp0
), struct hmbuf
*)->hm_count
++;
hp
->h_refcnt
++; /* know new structures have 0 val */
* Free a reference to a host. If this causes the
* host structure to be released do so.
register struct host
*hp
;
* Reset a given network's host entries.
* This involves clearing all packet queue's
* and releasing host structures.
register struct host
*hp
, *lp
;
for (m
= hosts
; m
; m
= m
->m_next
) {
hm
= mtod(m
, struct hmbuf
*);
while (hm
->hm_count
!= 0 && hp
< lp
) {
if (hp
->h_addr
.s_net
== net
)
hostrelease(mtod(m
, struct hmbuf
*), hp
);
* Remove a host structure and release
* any resources it's accumulated.
register struct host
*hp
;
register struct mbuf
*m
, **mprev
, *mh
= dtom(hp
);
* Discard any packets left on the waiting q
if (--mtod(mh
, struct hmbuf
*)->hm_count
)
while ((m
= *mprev
) != mh
)
* Remove a packet from the holding q.
* The RFNM counter is also bumped.
register struct host
*hp
;