nwconn: add packet burst diagnostics
All checks were successful
Source release / source-package (push) Successful in 47s

Add explicit debug logging around the existing Packet Burst code paths.

Log burst buffer negotiation, connection setup, incoming burst data packets,
read/write burst requests and replies, response packets, and missing-list
requests. This makes it possible to distinguish normal NCP file transfers from
actual Packet Burst data-path usage when ENABLE_BURSTMODE is enabled.

No protocol behavior change.
This commit is contained in:
Mario Fetka
2026-05-29 19:56:31 +02:00
parent dd91d45beb
commit f7a9dd0075

View File

@@ -2506,8 +2506,12 @@ static int handle_ncp_serv(void)
U16_TO_BE16(wantsize, xdata->getsize);
U16_TO_BE16(sock_echo, xdata->socket);
data_len = sizeof(*xdata);
XDPRINTF((5,0, "Negotiate Buffer (new) =0x%04x,(%d), flags=0x%x",
(int) wantsize, (int) wantsize, flags));
XDPRINTF((2,0, "Packet Burst negotiate buffer: want=0x%04x reply=0x%04x rw_buffer=0x%04x echo_socket=0x%04x flags=0x%x",
(int) GET_BE16((uint8*)requestdata),
(int) wantsize,
(int) rw_buffer_size,
(int) sock_echo,
flags));
} else
#endif
{
@@ -2605,6 +2609,12 @@ static int handle_ncp_serv(void)
burst_w->ud.addr.maxlen = sizeof(ipxAddr_t);
burst_w->ud.addr.buf = (char*)&(burst_w->to_addr);
data_len = sizeof(*xdata);
XDPRINTF((2,0, "Packet Burst connection accepted: client_socket=0x%04x max_packet=%u max_data=%u send=%u recv=%u",
client_socket,
(unsigned)(max_packet_size + 30),
(unsigned)burst_w->max_burst_data_size,
(unsigned)burst_w->max_send_size,
(unsigned)burst_w->max_recv_size));
} else
#endif
{
@@ -2874,6 +2884,8 @@ static int send_burst(int offset, int datasize, int flags)
memcpy(sb+1, burst_w->send_buf+offset, datasize);
burst_w->ud.udata.len =
burst_w->ud.udata.maxlen = datasize+sizeof(BURSTPACKET);
XDPRINTF((8, 0, "Packet Burst send packet: seq=%u off=%d size=%d flags=0x%x",
(unsigned)(burst_w->packet_sequence-1), offset, datasize, flags));
if (t_sndudata(FD_NCP_OUT, &(burst_w->ud)) < 0){
if (nw_debug) t_error("t_sndudata in NWCONN !OK");
return(-1);
@@ -2897,6 +2909,10 @@ static void handle_burst_response(uint32 offset, int size)
U16_TO_BE16(burst_w->burst_sequence+1, sb->ack_seq);
U32_TO_BE32(size, sb->burstsize);
XDPRINTF((3, 0, "Packet Burst response: seq=%u offset=%u size=%d max_packet_data=%d",
(unsigned)burst_w->burst_sequence, (unsigned)offset, size,
burst_w->max_burst_data_size));
while (size) {
int sendsize=min(size, burst_w->max_burst_data_size);
int flags=0;
@@ -2918,6 +2934,9 @@ static void handle_burst(BURSTPACKET *bp, int len)
int burstsequence = GET_BE16(bp->burst_seq);
int datasize = GET_BE16(bp->datasize);
XDPRINTF((6, 0, "Packet Burst recv packet: seq=%d flags=0x%x off=%u datasize=%d len=%d",
burstsequence, bp->flags, (unsigned)burstoffset, datasize, len));
if (datasize && !(bp->flags & 0x80)) {
/* copy if no System Packet */
if (datasize+burstoffset > burst_w->max_recv_size+24) {
@@ -2956,15 +2975,21 @@ static void handle_burst(BURSTPACKET *bp, int len)
uint8 readbytes[4]; /* hi-lo */
} *xdata= (struct XDATA*)burst_w->send_buf;
int zusatz = 0; /* (foffset & 1) ? 1 : 0; */
int size = nw_read_file(fhandle,
burst_w->send_buf+sizeof(struct XDATA),
fsize, foffset);
int size;
XDPRINTF((2, 0, "Packet Burst READ request: fh=0x%x off=%u size=%u seq=%d",
(unsigned)fhandle, (unsigned)foffset, (unsigned)fsize,
burstsequence));
size = nw_read_file(fhandle,
burst_w->send_buf+sizeof(struct XDATA),
fsize, foffset);
if (zusatz) {
XDPRINTF((1, 0, "foffset=%d, fsize=%d", foffset, fsize));
}
if (size > -1) {
U32_TO_32(0, xdata->resultcode);
U32_TO_BE32(size, xdata->readbytes);
XDPRINTF((2, 0, "Packet Burst READ reply: fh=0x%x off=%u requested=%u read=%d",
(unsigned)fhandle, (unsigned)foffset, (unsigned)fsize, size));
} else {
U32_TO_32(3, xdata->resultcode);
U32_TO_BE32(0, xdata->readbytes);
@@ -2979,8 +3004,15 @@ static void handle_burst(BURSTPACKET *bp, int len)
* 4=write error
*/
} *xdata= (struct XDATA*)burst_w->send_buf;
int size = nw_write_file(fhandle, req->data, fsize, foffset);
int size;
XDPRINTF((2, 0, "Packet Burst WRITE request: fh=0x%x off=%u size=%u seq=%d",
(unsigned)fhandle, (unsigned)foffset, (unsigned)fsize,
burstsequence));
size = nw_write_file(fhandle, req->data, fsize, foffset);
U32_TO_32(size==fsize ? 0 : 4, xdata->resultcode);
XDPRINTF((2, 0, "Packet Burst WRITE reply: fh=0x%x off=%u requested=%u written=%d result=%s",
(unsigned)fhandle, (unsigned)foffset, (unsigned)fsize, size,
size==fsize ? "ok" : "error"));
burst_w->burst_sequence = burstsequence;
handle_burst_response(0, sizeof(struct XDATA));
}
@@ -2992,9 +3024,12 @@ static void handle_burst(BURSTPACKET *bp, int len)
int missing=GET_BE16(bp->missing);
uint8 *p=(uint8*)(bp+1);
burst_w->burst_sequence = burstsequence;
XDPRINTF((3, 0, "Packet Burst missing-list request: seq=%d missing=%d",
burstsequence, missing));
while (missing--){
int offs=GET_BE32(p);
int size=GET_BE16(p+4);
XDPRINTF((3, 0, "Packet Burst resend range: off=%d size=%d", offs, size));
handle_burst_response(offs, size);
p+=6;
}
@@ -3233,7 +3268,7 @@ int main(int argc, char **argv)
#if ENABLE_BURSTMODE
if (ncp_type == 0x7777) { /* BURST-MODE */
XDPRINTF((16, 0, "GOT BURSTPACKET"));
XDPRINTF((2, 0, "Packet Burst data packet received: len=%d", data_len));
handle_burst((BURSTPACKET*)readbuff, data_len);
} else
#endif