Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Chaosnet broadcast for ifmeth=chudp #72

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions src/dpchaos.c
Original file line number Diff line number Diff line change
Expand Up @@ -1044,14 +1044,12 @@ hosttochaos(register struct dpchaos_s *dpchaos)

if (!dpchaos->dpchaos_ifmeth_chudp) {
// Ethernet case
u_char *ch = &buff[dpchaos->dpchaos_outoff]; // DPCHAOS_CHUDP_DATAOFFSET
// length excluding trailer
u_short cpklen = dpchaos->dpchaos_outoff+CHAOS_HEADERSIZE+chlen+(chlen%2);

// Use hardware dest, which is based on ITS routing table.
// But remove trailer before sending on Ethernet.
u_short cpklen = dpchaos->dpchaos_outoff+CHAOS_HEADERSIZE+chlen+(chlen%2); // length excluding trailer
u_short *hdchad = (u_short *)&buff[cpklen];
u_short dchad = htons(*hdchad);

// But remove trailer before sending on Ethernet.
if (DBGFLG & 2)
dbprintln("Found dest addr %#o (%#x) at offset %d+%d+%d+%d = %d",
dchad, dchad, dpchaos->dpchaos_outoff, CHAOS_HEADERSIZE, chlen, chlen%2,
Expand All @@ -1076,11 +1074,22 @@ hosttochaos(register struct dpchaos_s *dpchaos)
}
}
} else {
// CHUDP case
// CHUDP case: send the whole pkt after adding CHUDP header
memcpy(buff, (void *)&chuhdr, sizeof(chuhdr)); /* put in CHUDP hdr */
/* find IP destination given chaos packet */
if (hi_iproute(&ipdest, &ipport, &buff[dpchaos->dpchaos_outoff], rcnt - dpchaos->dpchaos_outoff, dpchaos)) {
ip_write(&ipdest, ipport, buff, rcnt, dpchaos);
// Get dest address from Chaos header
u_char *ch = &buff[sizeof(chuhdr)+DPCHAOS_CH_DESTOFF];
u_short dchad = ch[0]<<8 | ch[1];
if (dchad == 0) { // Broadcast: send on all links
for (int i = 0; i < dpchaos->dpchaos_chip_tlen; i++) {
memcpy(&ipport, &dpchaos->dpchaos_chip_tbl[i].dpchaos_chip_ipport, sizeof(in_port_t));
memcpy(&ipdest, &dpchaos->dpchaos_chip_tbl[i].dpchaos_chip_ipaddr,
sizeof(struct in_addr));
ip_write(&ipdest, ipport, buff, rcnt, dpchaos);
}
} else { // Unicast: find IP destination given chaos packet
if (hi_iproute(&ipdest, &ipport, &buff[dpchaos->dpchaos_outoff], rcnt - dpchaos->dpchaos_outoff, dpchaos)) {
ip_write(&ipdest, ipport, buff, rcnt, dpchaos);
}
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/dvch11.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ The ch11 device in KLH10 for ITS, which was originally just a dummy
inteface to keep ITS running, is now a functional Unibus Chaosnet
device, which supports Chaosnet-on-Ethernet and Chaosnet-over-UDP.
It does not support SPY (promiscuous) mode, or LUP (loopback), but ITS
doesn't seem to use/need these. It only supports broadcast on
Ethernet, not on UDP.
doesn't seem to use/need these.

Latest update: 2021-02-23

Expand Down
Loading