SCCS-vsn: sys/vax/if/if_acc.c 4.4
SCCS-vsn: sys/deprecated/netimp/if_imp.c 4.5
SCCS-vsn: sys/deprecated/netimp/if_imphost.c 4.3
SCCS-vsn: sys/deprecated/netimp/if_imphost.h 4.3
-/* if_imp.c 4.4 82/02/12 */
+/* if_imp.c 4.5 82/02/16 */
#include "imp.h"
#if NIMP > 0
#include "imp.h"
#if NIMP > 0
* TODO:
* rethink coupling between this module and device driver
* pass more error indications up to protocol modules
* TODO:
* rethink coupling between this module and device driver
* pass more error indications up to protocol modules
- * test raw imp interface
*/
#include "../h/param.h"
#include "../h/systm.h"
*/
#include "../h/param.h"
#include "../h/systm.h"
#include "../net/in.h"
#include "../net/in_systm.h"
#include "../net/if.h"
#include "../net/in.h"
#include "../net/in_systm.h"
#include "../net/if.h"
#include "../net/if_imp.h"
#include "../net/if_imp.h"
-#include "../net/host.h"
+#include "../net/if_imphost.h"
#include "../net/ip.h"
#include "../net/ip_var.h"
#include "../net/ip.h"
#include "../net/ip_var.h"
struct in_addr addr;
COUNT(IMP_INPUT);
struct in_addr addr;
COUNT(IMP_INPUT);
-printf("impinput(%d, %x), len=%d\n", unit, m, m->m_len);
-printleader("impinput", mtod(m, struct imp_leader *));
/*
* Verify leader length. Be careful with control
* message which don't get a length included.
/*
* Verify leader length. Be careful with control
* message which don't get a length included.
case IMPTYPE_HOSTDEAD:
case IMPTYPE_HOSTUNREACH:
case IMPTYPE_BADDATA:
case IMPTYPE_HOSTDEAD:
case IMPTYPE_HOSTUNREACH:
case IMPTYPE_BADDATA:
addr.s_net = ip->il_network;
addr.s_net = ip->il_network;
+#else
+ addr.s_net = 0;
+#endif
addr.s_imp = ip->il_imp;
addr.s_host = ip->il_host;
hp = hostlookup(addr);
addr.s_imp = ip->il_imp;
addr.s_host = ip->il_host;
hp = hostlookup(addr);
if (hp->h_rfnm == 0)
hostfree(hp);
}
if (hp->h_rfnm == 0)
hostfree(hp);
}
/*
* Host or IMP can't be reached. Flush any packets
/*
* Host or IMP can't be reached. Flush any packets
common:
if (hp)
hostfree(hp); /* won't work right */
common:
if (hp)
hostfree(hp); /* won't work right */
/*
* Error in data. Clear RFNM status for this host and send
/*
* Error in data. Clear RFNM status for this host and send
if (hp)
hp->h_rfnm = 0;
impnoops(sc);
if (hp)
hp->h_rfnm = 0;
impnoops(sc);
impproto.sp_protocol = ip->il_link;
impdst.sin_addr = sc->imp_if.if_addr;
impsrc.sin_addr.s_net = ip->il_network;
impproto.sp_protocol = ip->il_link;
impdst.sin_addr = sc->imp_if.if_addr;
impsrc.sin_addr.s_net = ip->il_network;
int x, dhost, dimp, dlink, len, dnet;
COUNT(IMPOUTPUT);
int x, dhost, dimp, dlink, len, dnet;
COUNT(IMPOUTPUT);
-printf("impoutput(%x, %x, %x)\n", ifp, m0, pf);
-
#ifdef notdef
/*
* Don't even try if the IMP is unavailable.
#ifdef notdef
/*
* Don't even try if the IMP is unavailable.
dimp = ip->ip_dst.s_imp;
dlink = IMPLINK_IP;
len = ntohs(ip->ip_len);
dimp = ip->ip_dst.s_imp;
dlink = IMPLINK_IP;
len = ntohs(ip->ip_len);
-printf("impoutput: net=%d,host=%d,imp=%d,len=%d\n",dnet,dhost,dimp,len);
}
imp = mtod(m, struct imp_leader *);
imp->il_format = IMP_NFF;
}
imp = mtod(m, struct imp_leader *);
imp->il_format = IMP_NFF;
+ imp->il_mtype = IMPTYPE_DATA;
imp->il_network = dnet;
imp->il_host = dhost;
imp->il_imp = dimp;
imp->il_length = htons((len + sizeof(struct imp_leader)) << 3);
imp->il_link = dlink;
imp->il_network = dnet;
imp->il_host = dhost;
imp->il_imp = dimp;
imp->il_length = htons((len + sizeof(struct imp_leader)) << 3);
imp->il_link = dlink;
+ imp->il_flags = imp->il_htype = imp->il_subtype = 0;
-printf("impsnd(%x, %x)\n", ifp, m);
ip = mtod(m, struct imp_leader *);
/*
ip = mtod(m, struct imp_leader *);
/*
if (ip->il_mtype == IMPTYPE_DATA) {
struct in_addr addr;
if (ip->il_mtype == IMPTYPE_DATA) {
struct in_addr addr;
addr.s_net = ip->il_network;
addr.s_net = ip->il_network;
+#else
+ addr.s_net = 0;
+#endif
addr.s_host = ip->il_host;
addr.s_imp = ip->il_imp;
addr.s_host = ip->il_host;
addr.s_imp = ip->il_imp;
if ((hp = hostlookup(addr)) == 0)
hp = hostenter(addr);
if ((hp = hostlookup(addr)) == 0)
hp = hostenter(addr);
if (hp->h_rfnm < 8) {
hp->h_rfnm++;
if (hp->h_rfnm < 8) {
hp->h_rfnm++;
m->m_next = n->m_next;
hp->h_q = n->m_next = m;
}
m->m_next = n->m_next;
hp->h_q = n->m_next = m;
}
goto start;
}
drop:
m_freem(m);
goto start;
}
drop:
m_freem(m);
-printleader("impsnd", mtod(m, struct imp_leader *));
x = splimp();
IF_ENQUEUE(&ifp->if_snd, m);
splx(x);
x = splimp();
IF_ENQUEUE(&ifp->if_snd, m);
splx(x);
cp->dl_host = sc->imp_if.if_addr.s_host;/* XXX */
cp->dl_imp = sc->imp_if.if_addr.s_imp; /* XXX */
#endif
cp->dl_host = sc->imp_if.if_addr.s_host;/* XXX */
cp->dl_imp = sc->imp_if.if_addr.s_imp; /* XXX */
#endif
-printleader("impnoops", cp);
x = splimp();
IF_PREPEND(&sc->imp_if.if_snd, m);
splx(x);
x = splimp();
IF_PREPEND(&sc->imp_if.if_snd, m);
splx(x);
(*sc->imp_cb.ic_start)(sc->imp_if.if_unit);
}
(*sc->imp_cb.ic_start)(sc->imp_if.if_unit);
}
printleader(routine, ip)
char *routine;
register struct imp_leader *ip;
printleader(routine, ip)
char *routine;
register struct imp_leader *ip;
-/* if_imphost.c 4.2 82/02/12 */
+/* if_imphost.c 4.3 82/02/16 */
#include "imp.h"
#if NIMP > 0
#include "imp.h"
#if NIMP > 0
#include "../h/mbuf.h"
#include "../net/in.h"
#include "../net/in_systm.h"
#include "../h/mbuf.h"
#include "../net/in.h"
#include "../net/in_systm.h"
-#include "../net/host.h"
#include "../net/if_imp.h"
#include "../net/if_imp.h"
+#include "../net/if_imphost.h"
/*
* Head of host table hash chains.
*/
/*
* Head of host table hash chains.
*/
-struct mbuf hosttable = { 0, MMINOFF };
/*
* Given an internet address
/*
* Given an internet address
register int hash = HOSTHASH(addr);
COUNT(HOSTLOOKUP);
register int hash = HOSTHASH(addr);
COUNT(HOSTLOOKUP);
-printf("hostlookup(%x)\n", addr);
- for (m = &hosttable; m; m = m->m_next) {
+ for (m = hosts; m; m = m->m_next) {
hp = &mtod(m, struct hmbuf *)->hm_hosts[hash];
if (hp->h_refcnt == 0)
hp = &mtod(m, struct hmbuf *)->hm_hosts[hash];
if (hp->h_refcnt == 0)
- break;
-printf("hostlookup: addr=%x\n", hp->h_addr.s_addr);
if (hp->h_addr.s_addr == addr.s_addr)
return (hp);
}
if (hp->h_addr.s_addr == addr.s_addr)
return (hp);
}
hostenter(addr)
struct in_addr addr;
{
hostenter(addr)
struct in_addr addr;
{
- register struct mbuf *m, *mprev;
- register struct host *hp;
+ register struct mbuf *m, **mprev;
+ register struct host *hp, *hp0 = 0;
register int hash = HOSTHASH(addr);
COUNT(HOSTENTER);
register int hash = HOSTHASH(addr);
COUNT(HOSTENTER);
-printf("hostenter(%x)\n", addr);
- for (m = &hosttable; m; mprev = m, m = m->m_next) {
+ mprev = &hosts;
+ while (m = *mprev) {
hp = &mtod(m, struct hmbuf *)->hm_hosts[hash];
hp = &mtod(m, struct hmbuf *)->hm_hosts[hash];
- if (hp->h_refcnt == 0)
- break;
-printf("hostenter: addr=%x\n", addr);
+ if (hp->h_refcnt == 0) {
+ if (hp0 == 0)
+ hp0 = hp;
+ continue;
+ }
if (hp->h_addr.s_addr == addr.s_addr)
goto foundhost;
if (hp->h_addr.s_addr == addr.s_addr)
goto foundhost;
* If our search ran off the end of the
* chain of mbuf's, allocate another.
*/
* If our search ran off the end of the
* chain of mbuf's, allocate another.
*/
-printf("hostenter: new host\n");
- if (m == 0) {
m = m_getclr(M_DONTWAIT);
if (m == 0)
return (0);
m = m_getclr(M_DONTWAIT);
if (m == 0)
return (0);
- mprev->m_next = m;
- m->m_act = mprev;
- hp = &mtod(m, struct hmbuf *)->hm_hosts[hash];
+ *mprev = m;
+ m->m_off = MMINOFF;
+ hp0 = &mtod(m, struct hmbuf *)->hm_hosts[hash];
- mtod(m, struct hmbuf *)->hm_count++;
+ mtod(dtom(hp0), struct hmbuf *)->hm_count++;
+ hp = hp0;
hp->h_addr = addr;
hp->h_status = HOSTS_UP;
hp->h_addr = addr;
hp->h_status = HOSTS_UP;
* Free a reference to a host. If this causes the
* host structure to be released do so.
*/
* Free a reference to a host. If this causes the
* host structure to be released do so.
*/
-hostfree(addr)
- struct in_addr addr;
+hostfree(hp)
+ register struct host *hp;
{
register struct mbuf *m;
{
register struct mbuf *m;
- register struct host *hp;
- register int hash = HOSTHASH(addr);
-printf("hostfree(%x)\n", addr);
- for (m = &hosttable; m; m = m->m_next) {
- hp = &mtod(m, struct hmbuf *)->hm_hosts[hash];
- if (hp->h_refcnt == 0)
- return;
- if (hp->h_addr.s_addr == addr.s_addr) {
- if (--hp->h_refcnt == 0)
- hostrelease(mtod(m, struct hmbuf *), hp);
- return;
- }
- }
- panic("hostfree");
+ if (--hp->h_refcnt)
+ return;
+ hostrelease(hp);
{
register struct mbuf *m;
register struct host *hp, *lp;
{
register struct mbuf *m;
register struct host *hp, *lp;
+ struct hmbuf *hm;
+ int x;
-printf("hostreset(%x)\n", net);
- for (m = &hosttable; m; m = m->m_next) {
- hp = mtod(m, struct hmbuf *)->hm_hosts;
+ x = splimp();
+ for (m = hosts; m; m = m->m_next) {
+ hm = mtod(m, struct hmbuf *);
+ hp = hm->hm_hosts;
+ while (hm->hm_count != 0 && hp < lp) {
if (hp->h_addr.s_net == net)
hostrelease(mtod(m, struct hmbuf *), hp);
hp++;
}
}
if (hp->h_addr.s_net == net)
hostrelease(mtod(m, struct hmbuf *), hp);
hp++;
}
}
}
/*
* Remove a host structure and release
* any resources it's accumulated.
*/
}
/*
* Remove a host structure and release
* any resources it's accumulated.
*/
-hostrelease(hm, hp)
- struct hmbuf *hm;
register struct host *hp;
{
register struct host *hp;
{
- register struct mbuf *m;
+ register struct mbuf *m, **mprev, *mh = dtom(hp);
-printf("hostrelease(%x,%x)\n", hm, hp);
/*
* Discard any packets left on the waiting q
*/
/*
* Discard any packets left on the waiting q
*/
hp->h_q = 0;
m_freem(m);
}
hp->h_q = 0;
m_freem(m);
}
- /*
- * We could compact the database here, but is
- * it worth it? For now we assume not and just
- * handle the simple case.
- */
-printf("hostrelease: count=%d\n", hm->hm_count);
- if (--hm->hm_count || (m = dtom(hm)) == &hosttable)
+ if (--mtod(mh, struct hmbuf *)->hm_count)
- m->m_act->m_next = m->m_next;
- m->m_next->m_act = m->m_act;
- (void) m_free(m);
+ mprev = &hosts;
+ while ((m = *mprev) != mh)
+ mprev = &m->m_next;
+ *mprev = mh->m_next;
+ (void) m_free(mh);
-/* if_imphost.h 4.2 82/02/12 */
+/* if_imphost.h 4.3 82/02/16 */
/*
* Host structure used with IMP's.
/*
* Host structure used with IMP's.
* automatically at the time a structure is free'd.
*/
#define HPMBUF ((MLEN - sizeof(int)) / sizeof(struct host))
* automatically at the time a structure is free'd.
*/
#define HPMBUF ((MLEN - sizeof(int)) / sizeof(struct host))
-#define HOSTHASH(a) ((a.s_addr) % HPMBUF)
+#define HOSTHASH(a) (((a).s_addr&~0x80000000) % HPMBUF)
struct hmbuf {
int hm_count; /* # of struct's in use */
struct hmbuf {
int hm_count; /* # of struct's in use */
-/* if_acc.c 4.3 82/02/12 */
+/* if_acc.c 4.4 82/02/16 */
#include "acc.h"
#ifdef NACC > 0
#include "acc.h"
#ifdef NACC > 0
u_short cmd;
COUNT(ACCSTART);
u_short cmd;
COUNT(ACCSTART);
-printf("accstart: active=%d\n", sc->acc_ic->ic_oactive);
if (sc->acc_ic->ic_oactive)
goto restart;
if (sc->acc_ic->ic_oactive)
goto restart;
* requeusts, just return.
*/
IF_DEQUEUE(&sc->acc_if->if_snd, m);
* requeusts, just return.
*/
IF_DEQUEUE(&sc->acc_if->if_snd, m);
-printf("accstart: dequeue m=%x\n", m);
if (m == 0) {
sc->acc_ic->ic_oactive = 0;
return;
}
sc->acc_olen = if_wubaput(&sc->acc_ifuba, m);
if (m == 0) {
sc->acc_ic->ic_oactive = 0;
return;
}
sc->acc_olen = if_wubaput(&sc->acc_ifuba, m);
-printf("accstart: olen=%d\n", sc->acc_olen);
return;
}
addr = (struct accdevice *)ui->ui_addr;
return;
}
addr = (struct accdevice *)ui->ui_addr;
-printf("accxint: ocsr=%b\n", addr->ocsr, ACC_OUTBITS);
sc->acc_if->if_opackets++;
sc->acc_ic->ic_oactive = 0;
if (addr->ocsr & ACC_ERR) {
sc->acc_if->if_opackets++;
sc->acc_ic->ic_oactive = 0;
if (addr->ocsr & ACC_ERR) {
m_freem(sc->acc_ifuba.ifu_xtofree);
sc->acc_ifuba.ifu_xtofree = 0;
}
m_freem(sc->acc_ifuba.ifu_xtofree);
sc->acc_ifuba.ifu_xtofree = 0;
}
- if (sc->acc_if->if_snd.ifq_head == 0)
- return;
- accstart(unit);
+ if (sc->acc_if->if_snd.ifq_head)
+ accstart(unit);
if (sc->acc_ifuba.ifu_flags & UBA_NEEDBDP)
UBAPURGE(sc->acc_ifuba.ifu_uba, sc->acc_ifuba.ifu_r.ifrw_bdp);
addr = (struct accdevice *)accinfo[unit]->ui_addr;
if (sc->acc_ifuba.ifu_flags & UBA_NEEDBDP)
UBAPURGE(sc->acc_ifuba.ifu_uba, sc->acc_ifuba.ifu_r.ifrw_bdp);
addr = (struct accdevice *)accinfo[unit]->ui_addr;
-printf("accrint: icsr=%b, flush=%d\n", addr->icsr, ACC_INBITS, sc->acc_flush);
if (addr->icsr & ACC_ERR) {
printf("acc%d: input error, csr=%b\n", unit,
addr->icsr, ACC_INBITS);
if (addr->icsr & ACC_ERR) {
printf("acc%d: input error, csr=%b\n", unit,
addr->icsr, ACC_INBITS);
goto setup;
}
len = IMP_MTU + (addr->iwc << 1);
goto setup;
}
len = IMP_MTU + (addr->iwc << 1);
-printf("accrint: len=%d\n", len);
if (len < 0 || len > IMP_MTU) {
printf("acc%d: bad length=%d\n", len);
sc->acc_if->if_ierrors++;
if (len < 0 || len > IMP_MTU) {
printf("acc%d: bad length=%d\n", len);
sc->acc_if->if_ierrors++;
* trailers on the ARPAnet is insane.
*/
m = if_rubaget(&sc->acc_ifuba, len, 0);
* trailers on the ARPAnet is insane.
*/
m = if_rubaget(&sc->acc_ifuba, len, 0);
-printf("accrint: m=%x\n", m);
if (m == 0)
goto setup;
if ((addr->icsr & IN_EOM) == 0) {
if (m == 0)
goto setup;
if ((addr->icsr & IN_EOM) == 0) {