From 314eab64b718b4e1764f06ab12dcf0d04b3ac222 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 10 Oct 2020 17:10:22 +0300 Subject: [PATCH] bsdsocket.library SBTC_GET_BYTES_RECEIVED and SBTC_GET_BYTES_SENT. --- bsdsocket.cpp | 17 +++++++++++++++++ include/bsdsocket.h | 1 + od-win32/bsdsock.cpp | 2 ++ 3 files changed, 20 insertions(+) diff --git a/bsdsocket.cpp b/bsdsocket.cpp index dfbd2c72..dfdf902d 100644 --- a/bsdsocket.cpp +++ b/bsdsocket.cpp @@ -1433,6 +1433,8 @@ static uae_u32 strErrptr, strReleaseVer; #define SBTC_ERRNOLONGPTR 24 #define SBTC_HERRNOLONGPTR 25 #define SBTC_RELEASESTRPTR 29 +#define SBTC_GET_BYTES_RECEIVED 64 +#define SBTC_GET_BYTES_SENT 65 #define LOG_FACMASK 0x03f8 @@ -1684,6 +1686,21 @@ static uae_u32 REGPARAM2 bsdsocklib_SocketBaseTagList(TrapContext *ctx) tagcopy(ctx, currtag, currval, tagptr, &strReleaseVer); } break; + case SBTC_GET_BYTES_RECEIVED: + BSDTRACE ((_T("SBTC_GET_BYTES_RECEIVED),%08x"), currval)); + if ((currtag & 0x8001) == 0x8000) { /* SBTM_GETREF */ + trap_put_long(ctx, currval + 0, sb->bytesreceived >> 32); + trap_put_long(ctx, currval + 4, sb->bytesreceived >> 0); + } + break; + case SBTC_GET_BYTES_SENT: + BSDTRACE ((_T("SBTC_GET_BYTES_SENT),%08x"), currval)); + if ((currtag & 0x8001) == 0x8000) { /* SBTM_GETREF */ + trap_put_long(ctx, currval + 0, sb->bytestransmitted >> 32); + trap_put_long(ctx, currval + 4, sb->bytestransmitted >> 0); + } + break; + default: write_log (_T("bsdsocket: WARNING: Unsupported tag type (%08x=%d) in SocketBaseTagList(%x)\n"), currtag, (currtag / 2) & SBTS_CODE, trap_get_areg(ctx, 0)); diff --git a/include/bsdsocket.h b/include/bsdsocket.h index c5c89f82..9b50c9bc 100644 --- a/include/bsdsocket.h +++ b/include/bsdsocket.h @@ -69,6 +69,7 @@ struct socketbase { uae_u32 logmask; uae_u32 logfacility; uaecptr fdcallback; + uae_u64 bytestransmitted, bytesreceived; unsigned int *mtable; /* window messages allocated for asynchronous event notification */ /* host-specific fields below */ diff --git a/od-win32/bsdsock.cpp b/od-win32/bsdsock.cpp index a03492ad..fb0d4e3c 100644 --- a/od-win32/bsdsock.cpp +++ b/od-win32/bsdsock.cpp @@ -1215,6 +1215,7 @@ void host_sendto (TrapContext *ctx, SB, uae_u32 sd, uae_u32 msg, uae_u8 *hmsg, u } else { realpt += sb->resultval; len -= sb->resultval; + sb->bytestransmitted += sb->resultval; if (len <= 0) break; else @@ -1323,6 +1324,7 @@ void host_recvfrom(TrapContext *ctx, SB, uae_u32 sd, uae_u32 msg, uae_u8 *hmsg, int l = sb->resultval; realpt += l; len -= l; + sb->bytesreceived += l; waitallgot += l; if (len <= 0) { sb->resultval = waitallgot; -- 2.47.3