Skip to content

Commit

Permalink
Implement Chaosnet broadcast for ifmeth=chudp (#72)
Browse files Browse the repository at this point in the history
Implement broadcast for ifmeth=chudp, by simply sending the packet on all chudp links.
  • Loading branch information
bictorv committed Mar 12, 2024
1 parent 4955fb8 commit cf87fd1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
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

0 comments on commit cf87fd1

Please sign in to comment.