From 40a9e0f68797b802800330c6cefd24bd1f4a3d7c Mon Sep 17 00:00:00 2001 From: Dominik Zarfl <13350047+zarfld@users.noreply.github.com> Date: Wed, 18 Jun 2025 13:26:20 +0200 Subject: [PATCH 01/17] Create travis_sh.yml --- .github/workflows /travis_sh.yml | 89 ++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 .github/workflows /travis_sh.yml diff --git a/.github/workflows /travis_sh.yml b/.github/workflows /travis_sh.yml new file mode 100644 index 000000000..463c42820 --- /dev/null +++ b/.github/workflows /travis_sh.yml @@ -0,0 +1,89 @@ +name: Build and Test + +on: + push: + branches: + - '**' + pull_request: + branches: + - '**' + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential cmake + + - name: Set up dependencies + run: | + sudo apt update + sudo apt install -y \ + git build-essential cmake g++ \ + libpcap-dev libnl-3-dev libnl-genl-3-dev \ + uuid-dev libavahi-client-dev \ + linux-headers-generic libglib2.0-dev \ + libpci-dev libsndfile1-dev libjack-dev \ + libasound2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev + + - name: Fix submodule URLs + run: | + git config --file .gitmodules submodule.avdecc-lib.url https://github.com/AVnu/avdecc-lib.git + git config --file .gitmodules submodule.lib/atl_avb.url https://github.com/zarfld/atl_avb.git + git config --file .gitmodules submodule.lib/igb_avb.url https://github.com/AVnu/igb_avb.git + git config --file .gitmodules submodule.thirdparty/cpputest.url https://github.com/cpputest/cpputest.git + git submodule sync + git submodule update --init --recursive + + - name: Run legacy make tasks + run: | + set -ev + make daemons_all + make examples_all + make avtp_pipeline + + - name: Run legacy make avdecc + run: | + make avdecc + continue-on-error: true + + - name: Update to latest CppUTest + run: | + cd thirdparty/cpputest + git checkout master + git pull origin master + + - name: Configure and build CppUTest + run: | + mkdir -p cpputest_build + cd cpputest_build + cmake ../thirdparty/cpputest \ + -DCPPUTEST_USE_STD_CPP_LIB=ON \ + -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/cpputest_install + make + make install + + - name: Configure CMake project + run: | + mkdir build + cd build + cmake .. -G "Unix Makefiles" \ + -DCMAKE_CXX_FLAGS="-fexceptions -funwind-tables" \ + -DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/cpputest_install + + - name: Build project + run: | + cd build + make + + - name: Run tests + run: | + cd build + ARGS=--output-on-failure make test From 37af2f59c54464cc546ac2b5eb8ec71dc611c9e4 Mon Sep 17 00:00:00 2001 From: Dominik Zarfl <13350047+zarfld@users.noreply.github.com> Date: Wed, 18 Jun 2025 13:32:30 +0200 Subject: [PATCH 02/17] Create OpenAvnu_Build.yml --- .github/workflows /OpenAvnu_Build.yml | 100 ++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 .github/workflows /OpenAvnu_Build.yml diff --git a/.github/workflows /OpenAvnu_Build.yml b/.github/workflows /OpenAvnu_Build.yml new file mode 100644 index 000000000..fdce74174 --- /dev/null +++ b/.github/workflows /OpenAvnu_Build.yml @@ -0,0 +1,100 @@ +name: OpenAvnu Build CI + +on: + push: + branches: + - main + - master + - open-avb-next + pull_request: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: false # wir setzen die URLs gleich manuell + + - name: Set up dependencies + run: | + sudo apt update + sudo apt install -y \ + git build-essential cmake g++ \ + libpcap-dev libnl-3-dev libnl-genl-3-dev \ + uuid-dev libavahi-client-dev \ + linux-headers-generic libglib2.0-dev \ + libpci-dev libsndfile1-dev libjack-dev \ + libasound2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev + + - name: Fix submodule URLs + run: | + git config --file .gitmodules submodule.avdecc-lib.url https://github.com/AVnu/avdecc-lib.git + git config --file .gitmodules submodule.lib/atl_avb.url https://github.com/zarfld/atl_avb.git + git config --file .gitmodules submodule.lib/igb_avb.url https://github.com/AVnu/igb_avb.git + git config --file .gitmodules submodule.thirdparty/cpputest.url https://github.com/cpputest/cpputest.git + git submodule sync + git submodule update --init --recursive + + - name: Build daemons/maap seperately + run: | + make -C daemons/maap + continue-on-error: true + + - name: Build daemons/mrpd seperately + run: | + make -C daemons/mrpd + continue-on-error: true + + - name: Build daemons/shaper seperately + run: | + make -C daemons/shaper + continue-on-error: true + + - name: Build examples/simple_listener seperately + run: | + make -C examples/simple_listener + continue-on-error: true + + - name: Build examples/simple_talker seperately + run: | + make -C examples/simple_talker + continue-on-error: true + + - name: Build all + run: | + make all + + - name: Build lib/igb_avb/lib + run: | + make -C lib/igb_avb/lib all + + # ─────────────────────────────────────────────────────────────── + # Fehlerbehandlung: nur ausführen, wenn obiger Build fehlschlägt + # ─────────────────────────────────────────────────────────────── + + - name: Print directory contents on failure + if: failure() + run: | + echo "::group::Directory structure" + find . -type f | sort + echo "::endgroup::" + + - name: Show last 100 lines of all *.log or *.txt + if: failure() + run: | + find . -type f \( -name "*.log" -o -name "*.txt" \) -exec echo "::group::{}" \; -exec tail -n 100 {} \; -exec echo "::endgroup::" \; + + - name: Upload build output (if any) + if: failure() + uses: actions/upload-artifact@v4 + with: + name: build-output-on-failure + path: | + lib/**/lib*.a + **/*.o + **/*.log + **/*.txt From 2e716e18b8c5e387823362671991ad3106e0b26c Mon Sep 17 00:00:00 2001 From: Dominik Zarfl <13350047+zarfld@users.noreply.github.com> Date: Wed, 18 Jun 2025 13:43:51 +0200 Subject: [PATCH 03/17] mrpd: guard SOCKET typedef on linux --- daemons/mrpd/mrpd.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/daemons/mrpd/mrpd.h b/daemons/mrpd/mrpd.h index d33de1292..e6f69f0f2 100644 --- a/daemons/mrpd/mrpd.h +++ b/daemons/mrpd/mrpd.h @@ -47,7 +47,9 @@ size_t mrpd_send(SOCKET sockfd, const void *buf, size_t len, int flags); #include #include #include +#ifndef SOCKET typedef int SOCKET; +#endif typedef int HTIMER; #define INVALID_SOCKET -1 #define SOCKET_ERROR -1 From 47c32d0948000f04077628f19aa2eba90d4c9e9c Mon Sep 17 00:00:00 2001 From: Dominik Zarfl <13350047+zarfld@users.noreply.github.com> Date: Wed, 18 Jun 2025 13:50:28 +0200 Subject: [PATCH 04/17] Update OpenAvnu_Build.yml --- .github/workflows /OpenAvnu_Build.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows /OpenAvnu_Build.yml b/.github/workflows /OpenAvnu_Build.yml index fdce74174..e71b12eb9 100644 --- a/.github/workflows /OpenAvnu_Build.yml +++ b/.github/workflows /OpenAvnu_Build.yml @@ -3,10 +3,9 @@ name: OpenAvnu Build CI on: push: branches: - - main - - master - - open-avb-next + - '**' pull_request: + - '**' workflow_dispatch: jobs: From 03503404734a74d0ebabfc9d10bd3ace688b8b6c Mon Sep 17 00:00:00 2001 From: Dominik Zarfl <13350047+zarfld@users.noreply.github.com> Date: Wed, 18 Jun 2025 15:14:24 +0200 Subject: [PATCH 05/17] Increase response buffer sizes and use snprintf --- daemons/mrpd/mmrp.c | 74 +++++++++++++++++++++++---------------------- daemons/mrpd/mrpd.c | 3 +- daemons/mrpd/mvrp.c | 42 +++++++++++++------------ 3 files changed, 61 insertions(+), 58 deletions(-) diff --git a/daemons/mrpd/mmrp.c b/daemons/mrpd/mmrp.c index 15fba7f03..4631cbe90 100644 --- a/daemons/mrpd/mmrp.c +++ b/daemons/mrpd/mmrp.c @@ -1428,23 +1428,23 @@ int mmrp_send_notifications(struct mmrp_attribute *attrib, int notify) memset(msgbuf, 0, MAX_MRPD_CMDSZ); if (MMRP_SVCREQ_TYPE == attrib->type) { - sprintf(variant, "S=%d", attrib->attribute.svcreq); + snprintf(variant, 128, "S=%d", attrib->attribute.svcreq); } else { - sprintf(variant, "M=%02x%02x%02x%02x%02x%02x", - attrib->attribute.macaddr[0], - attrib->attribute.macaddr[1], - attrib->attribute.macaddr[2], - attrib->attribute.macaddr[3], - attrib->attribute.macaddr[4], - attrib->attribute.macaddr[5]); + snprintf(variant, 128, "M=%02x%02x%02x%02x%02x%02x", + attrib->attribute.macaddr[0], + attrib->attribute.macaddr[1], + attrib->attribute.macaddr[2], + attrib->attribute.macaddr[3], + attrib->attribute.macaddr[4], + attrib->attribute.macaddr[5]); } - sprintf(regsrc, "R=%02x%02x%02x%02x%02x%02x", - attrib->registrar.macaddr[0], - attrib->registrar.macaddr[1], - attrib->registrar.macaddr[2], - attrib->registrar.macaddr[3], - attrib->registrar.macaddr[4], attrib->registrar.macaddr[5]); + snprintf(regsrc, 128, "R=%02x%02x%02x%02x%02x%02x", + attrib->registrar.macaddr[0], + attrib->registrar.macaddr[1], + attrib->registrar.macaddr[2], + attrib->registrar.macaddr[3], + attrib->registrar.macaddr[4], attrib->registrar.macaddr[5]); mrp_decode_state(&attrib->registrar, &attrib->applicant, mrp_state, sizeof(mrp_state)); @@ -1508,43 +1508,45 @@ int mmrp_dumptable(struct sockaddr_in *client) attrib = MMRP_db->attrib_list; if (attrib == NULL) { - sprintf(msgbuf, "MMRP:Empty\n"); + snprintf(msgbuf, MAX_MRPD_CMDSZ, "MMRP:Empty\n"); } while (NULL != attrib) { if (MMRP_SVCREQ_TYPE == attrib->type) { - sprintf(variant, "S=%d", attrib->attribute.svcreq); + snprintf(variant, 128, "S=%d", attrib->attribute.svcreq); } else { - sprintf(variant, "M=%02x%02x%02x%02x%02x%02x", - attrib->attribute.macaddr[0], - attrib->attribute.macaddr[1], - attrib->attribute.macaddr[2], - attrib->attribute.macaddr[3], - attrib->attribute.macaddr[4], - attrib->attribute.macaddr[5]); + snprintf(variant, 128, "M=%02x%02x%02x%02x%02x%02x", + attrib->attribute.macaddr[0], + attrib->attribute.macaddr[1], + attrib->attribute.macaddr[2], + attrib->attribute.macaddr[3], + attrib->attribute.macaddr[4], + attrib->attribute.macaddr[5]); } - sprintf(regsrc, "R=%02x%02x%02x%02x%02x%02x", - attrib->registrar.macaddr[0], - attrib->registrar.macaddr[1], - attrib->registrar.macaddr[2], - attrib->registrar.macaddr[3], - attrib->registrar.macaddr[4], - attrib->registrar.macaddr[5]); + snprintf(regsrc, 128, "R=%02x%02x%02x%02x%02x%02x", + attrib->registrar.macaddr[0], + attrib->registrar.macaddr[1], + attrib->registrar.macaddr[2], + attrib->registrar.macaddr[3], + attrib->registrar.macaddr[4], + attrib->registrar.macaddr[5]); switch (attrib->registrar.mrp_state) { case MRP_IN_STATE: - sprintf(stage, "MIN %s %s\n", variant, regsrc); + snprintf(stage, 128, "MIN %s %s\n", variant, regsrc); break; case MRP_LV_STATE: - sprintf(stage, "MLV %s %s\n", variant, regsrc); + snprintf(stage, 128, "MLV %s %s\n", variant, regsrc); break; case MRP_MT_STATE: - sprintf(stage, "MMT %s %s\n", variant, regsrc); + snprintf(stage, 128, "MMT %s %s\n", variant, regsrc); break; default: break; } - sprintf(msgbuf_wrptr, "%s", stage); - msgbuf_wrptr += strnlen(stage, 128); + snprintf(msgbuf_wrptr, + MAX_MRPD_CMDSZ - (msgbuf_wrptr - msgbuf), + "%s", stage); + msgbuf_wrptr += strnlen(stage, 128); attrib = attrib->next; } @@ -1615,7 +1617,7 @@ int mmrp_recv_cmd(char *buf, int buflen, struct sockaddr_in *client) { int rc; int err_index; - char respbuf[12]; + char respbuf[64]; int mrp_event; uint8_t svcreq_param; uint8_t macvec_param[6]; diff --git a/daemons/mrpd/mrpd.c b/daemons/mrpd/mrpd.c index a712e2da6..eaac09b6e 100644 --- a/daemons/mrpd/mrpd.c +++ b/daemons/mrpd/mrpd.c @@ -258,8 +258,7 @@ mrpd_send_ctl_msg(struct sockaddr_in *client_addr, char *notify_data, int process_ctl_msg(char *buf, int buflen, struct sockaddr_in *client) { - - char respbuf[8]; + char respbuf[64]; /* * Inbound/output commands from/to a client: * diff --git a/daemons/mrpd/mvrp.c b/daemons/mrpd/mvrp.c index fa14ac378..b26d0e942 100644 --- a/daemons/mrpd/mvrp.c +++ b/daemons/mrpd/mvrp.c @@ -1033,14 +1033,14 @@ int mvrp_send_notifications(struct mvrp_attribute *attrib, int notify) memset(msgbuf, 0, MAX_MRPD_CMDSZ); - sprintf(variant, "%04x", attrib->attribute); + snprintf(variant, 128, "%04x", attrib->attribute); - sprintf(regsrc, "R=%02x%02x%02x%02x%02x%02x", - attrib->registrar.macaddr[0], - attrib->registrar.macaddr[1], - attrib->registrar.macaddr[2], - attrib->registrar.macaddr[3], - attrib->registrar.macaddr[4], attrib->registrar.macaddr[5]); + snprintf(regsrc, 128, "R=%02x%02x%02x%02x%02x%02x", + attrib->registrar.macaddr[0], + attrib->registrar.macaddr[1], + attrib->registrar.macaddr[2], + attrib->registrar.macaddr[3], + attrib->registrar.macaddr[4], attrib->registrar.macaddr[5]); mrp_decode_state(&attrib->registrar, &attrib->applicant, mrp_state, sizeof(mrp_state)); @@ -1105,25 +1105,27 @@ int mvrp_dumptable(struct sockaddr_in *client) attrib = MVRP_db->attrib_list; if (attrib == NULL) { - sprintf(msgbuf, "MVRP:Empty\n"); + snprintf(msgbuf, MAX_MRPD_CMDSZ, "MVRP:Empty\n"); } while (NULL != attrib) { - sprintf(variant, "V:I=%04x", attrib->attribute); + snprintf(variant, 128, "V:I=%04x", attrib->attribute); mrp_decode_state(&attrib->registrar, &attrib->applicant, mrp_state, sizeof(mrp_state)); - sprintf(regsrc, "R=%02x%02x%02x%02x%02x%02x %s", - attrib->registrar.macaddr[0], - attrib->registrar.macaddr[1], - attrib->registrar.macaddr[2], - attrib->registrar.macaddr[3], - attrib->registrar.macaddr[4], - attrib->registrar.macaddr[5], mrp_state); - - sprintf(stage, "%s %s\n", variant, regsrc); - sprintf(msgbuf_wrptr, "%s", stage); + snprintf(regsrc, 128, "R=%02x%02x%02x%02x%02x%02x %s", + attrib->registrar.macaddr[0], + attrib->registrar.macaddr[1], + attrib->registrar.macaddr[2], + attrib->registrar.macaddr[3], + attrib->registrar.macaddr[4], + attrib->registrar.macaddr[5], mrp_state); + + snprintf(stage, 128, "%s %s\n", variant, regsrc); + snprintf(msgbuf_wrptr, + MAX_MRPD_CMDSZ - (msgbuf_wrptr - msgbuf), + "%s", stage); msgbuf_wrptr += strnlen(stage, 128); attrib = attrib->next; } @@ -1173,7 +1175,7 @@ int mvrp_recv_cmd(char *buf, int buflen, struct sockaddr_in *client) { int rc; int mrp_event; - char respbuf[12]; + char respbuf[64]; uint16_t vid_param; int err_index; From cf431b88f0dc23b7ad69861043bb670dcbf2d3e3 Mon Sep 17 00:00:00 2001 From: Dominik Zarfl <13350047+zarfld@users.noreply.github.com> Date: Wed, 18 Jun 2025 15:17:47 +0200 Subject: [PATCH 06/17] Create travis_sh.yml --- .github/workflows/travis_sh.yml | 89 +++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 .github/workflows/travis_sh.yml diff --git a/.github/workflows/travis_sh.yml b/.github/workflows/travis_sh.yml new file mode 100644 index 000000000..463c42820 --- /dev/null +++ b/.github/workflows/travis_sh.yml @@ -0,0 +1,89 @@ +name: Build and Test + +on: + push: + branches: + - '**' + pull_request: + branches: + - '**' + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential cmake + + - name: Set up dependencies + run: | + sudo apt update + sudo apt install -y \ + git build-essential cmake g++ \ + libpcap-dev libnl-3-dev libnl-genl-3-dev \ + uuid-dev libavahi-client-dev \ + linux-headers-generic libglib2.0-dev \ + libpci-dev libsndfile1-dev libjack-dev \ + libasound2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev + + - name: Fix submodule URLs + run: | + git config --file .gitmodules submodule.avdecc-lib.url https://github.com/AVnu/avdecc-lib.git + git config --file .gitmodules submodule.lib/atl_avb.url https://github.com/zarfld/atl_avb.git + git config --file .gitmodules submodule.lib/igb_avb.url https://github.com/AVnu/igb_avb.git + git config --file .gitmodules submodule.thirdparty/cpputest.url https://github.com/cpputest/cpputest.git + git submodule sync + git submodule update --init --recursive + + - name: Run legacy make tasks + run: | + set -ev + make daemons_all + make examples_all + make avtp_pipeline + + - name: Run legacy make avdecc + run: | + make avdecc + continue-on-error: true + + - name: Update to latest CppUTest + run: | + cd thirdparty/cpputest + git checkout master + git pull origin master + + - name: Configure and build CppUTest + run: | + mkdir -p cpputest_build + cd cpputest_build + cmake ../thirdparty/cpputest \ + -DCPPUTEST_USE_STD_CPP_LIB=ON \ + -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/cpputest_install + make + make install + + - name: Configure CMake project + run: | + mkdir build + cd build + cmake .. -G "Unix Makefiles" \ + -DCMAKE_CXX_FLAGS="-fexceptions -funwind-tables" \ + -DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/cpputest_install + + - name: Build project + run: | + cd build + make + + - name: Run tests + run: | + cd build + ARGS=--output-on-failure make test From 7a3dac3511d68913b1336e262c04d28bcb3b09c6 Mon Sep 17 00:00:00 2001 From: Dominik Zarfl <13350047+zarfld@users.noreply.github.com> Date: Wed, 18 Jun 2025 15:18:25 +0200 Subject: [PATCH 07/17] Create OpenAvnu_Build.yml --- .github/workflows/OpenAvnu_Build.yml | 99 ++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 .github/workflows/OpenAvnu_Build.yml diff --git a/.github/workflows/OpenAvnu_Build.yml b/.github/workflows/OpenAvnu_Build.yml new file mode 100644 index 000000000..e71b12eb9 --- /dev/null +++ b/.github/workflows/OpenAvnu_Build.yml @@ -0,0 +1,99 @@ +name: OpenAvnu Build CI + +on: + push: + branches: + - '**' + pull_request: + - '**' + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: false # wir setzen die URLs gleich manuell + + - name: Set up dependencies + run: | + sudo apt update + sudo apt install -y \ + git build-essential cmake g++ \ + libpcap-dev libnl-3-dev libnl-genl-3-dev \ + uuid-dev libavahi-client-dev \ + linux-headers-generic libglib2.0-dev \ + libpci-dev libsndfile1-dev libjack-dev \ + libasound2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev + + - name: Fix submodule URLs + run: | + git config --file .gitmodules submodule.avdecc-lib.url https://github.com/AVnu/avdecc-lib.git + git config --file .gitmodules submodule.lib/atl_avb.url https://github.com/zarfld/atl_avb.git + git config --file .gitmodules submodule.lib/igb_avb.url https://github.com/AVnu/igb_avb.git + git config --file .gitmodules submodule.thirdparty/cpputest.url https://github.com/cpputest/cpputest.git + git submodule sync + git submodule update --init --recursive + + - name: Build daemons/maap seperately + run: | + make -C daemons/maap + continue-on-error: true + + - name: Build daemons/mrpd seperately + run: | + make -C daemons/mrpd + continue-on-error: true + + - name: Build daemons/shaper seperately + run: | + make -C daemons/shaper + continue-on-error: true + + - name: Build examples/simple_listener seperately + run: | + make -C examples/simple_listener + continue-on-error: true + + - name: Build examples/simple_talker seperately + run: | + make -C examples/simple_talker + continue-on-error: true + + - name: Build all + run: | + make all + + - name: Build lib/igb_avb/lib + run: | + make -C lib/igb_avb/lib all + + # ─────────────────────────────────────────────────────────────── + # Fehlerbehandlung: nur ausführen, wenn obiger Build fehlschlägt + # ─────────────────────────────────────────────────────────────── + + - name: Print directory contents on failure + if: failure() + run: | + echo "::group::Directory structure" + find . -type f | sort + echo "::endgroup::" + + - name: Show last 100 lines of all *.log or *.txt + if: failure() + run: | + find . -type f \( -name "*.log" -o -name "*.txt" \) -exec echo "::group::{}" \; -exec tail -n 100 {} \; -exec echo "::endgroup::" \; + + - name: Upload build output (if any) + if: failure() + uses: actions/upload-artifact@v4 + with: + name: build-output-on-failure + path: | + lib/**/lib*.a + **/*.o + **/*.log + **/*.txt From b89155197a481734ab8f6f4e5cb9186ebd9d1cd7 Mon Sep 17 00:00:00 2001 From: Dominik Zarfl <13350047+zarfld@users.noreply.github.com> Date: Wed, 18 Jun 2025 15:20:52 +0200 Subject: [PATCH 08/17] Delete .github/workflows directory --- .github/workflows /OpenAvnu_Build.yml | 99 --------------------------- .github/workflows /travis_sh.yml | 89 ------------------------ 2 files changed, 188 deletions(-) delete mode 100644 .github/workflows /OpenAvnu_Build.yml delete mode 100644 .github/workflows /travis_sh.yml diff --git a/.github/workflows /OpenAvnu_Build.yml b/.github/workflows /OpenAvnu_Build.yml deleted file mode 100644 index e71b12eb9..000000000 --- a/.github/workflows /OpenAvnu_Build.yml +++ /dev/null @@ -1,99 +0,0 @@ -name: OpenAvnu Build CI - -on: - push: - branches: - - '**' - pull_request: - - '**' - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - submodules: false # wir setzen die URLs gleich manuell - - - name: Set up dependencies - run: | - sudo apt update - sudo apt install -y \ - git build-essential cmake g++ \ - libpcap-dev libnl-3-dev libnl-genl-3-dev \ - uuid-dev libavahi-client-dev \ - linux-headers-generic libglib2.0-dev \ - libpci-dev libsndfile1-dev libjack-dev \ - libasound2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev - - - name: Fix submodule URLs - run: | - git config --file .gitmodules submodule.avdecc-lib.url https://github.com/AVnu/avdecc-lib.git - git config --file .gitmodules submodule.lib/atl_avb.url https://github.com/zarfld/atl_avb.git - git config --file .gitmodules submodule.lib/igb_avb.url https://github.com/AVnu/igb_avb.git - git config --file .gitmodules submodule.thirdparty/cpputest.url https://github.com/cpputest/cpputest.git - git submodule sync - git submodule update --init --recursive - - - name: Build daemons/maap seperately - run: | - make -C daemons/maap - continue-on-error: true - - - name: Build daemons/mrpd seperately - run: | - make -C daemons/mrpd - continue-on-error: true - - - name: Build daemons/shaper seperately - run: | - make -C daemons/shaper - continue-on-error: true - - - name: Build examples/simple_listener seperately - run: | - make -C examples/simple_listener - continue-on-error: true - - - name: Build examples/simple_talker seperately - run: | - make -C examples/simple_talker - continue-on-error: true - - - name: Build all - run: | - make all - - - name: Build lib/igb_avb/lib - run: | - make -C lib/igb_avb/lib all - - # ─────────────────────────────────────────────────────────────── - # Fehlerbehandlung: nur ausführen, wenn obiger Build fehlschlägt - # ─────────────────────────────────────────────────────────────── - - - name: Print directory contents on failure - if: failure() - run: | - echo "::group::Directory structure" - find . -type f | sort - echo "::endgroup::" - - - name: Show last 100 lines of all *.log or *.txt - if: failure() - run: | - find . -type f \( -name "*.log" -o -name "*.txt" \) -exec echo "::group::{}" \; -exec tail -n 100 {} \; -exec echo "::endgroup::" \; - - - name: Upload build output (if any) - if: failure() - uses: actions/upload-artifact@v4 - with: - name: build-output-on-failure - path: | - lib/**/lib*.a - **/*.o - **/*.log - **/*.txt diff --git a/.github/workflows /travis_sh.yml b/.github/workflows /travis_sh.yml deleted file mode 100644 index 463c42820..000000000 --- a/.github/workflows /travis_sh.yml +++ /dev/null @@ -1,89 +0,0 @@ -name: Build and Test - -on: - push: - branches: - - '**' - pull_request: - branches: - - '**' - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y build-essential cmake - - - name: Set up dependencies - run: | - sudo apt update - sudo apt install -y \ - git build-essential cmake g++ \ - libpcap-dev libnl-3-dev libnl-genl-3-dev \ - uuid-dev libavahi-client-dev \ - linux-headers-generic libglib2.0-dev \ - libpci-dev libsndfile1-dev libjack-dev \ - libasound2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev - - - name: Fix submodule URLs - run: | - git config --file .gitmodules submodule.avdecc-lib.url https://github.com/AVnu/avdecc-lib.git - git config --file .gitmodules submodule.lib/atl_avb.url https://github.com/zarfld/atl_avb.git - git config --file .gitmodules submodule.lib/igb_avb.url https://github.com/AVnu/igb_avb.git - git config --file .gitmodules submodule.thirdparty/cpputest.url https://github.com/cpputest/cpputest.git - git submodule sync - git submodule update --init --recursive - - - name: Run legacy make tasks - run: | - set -ev - make daemons_all - make examples_all - make avtp_pipeline - - - name: Run legacy make avdecc - run: | - make avdecc - continue-on-error: true - - - name: Update to latest CppUTest - run: | - cd thirdparty/cpputest - git checkout master - git pull origin master - - - name: Configure and build CppUTest - run: | - mkdir -p cpputest_build - cd cpputest_build - cmake ../thirdparty/cpputest \ - -DCPPUTEST_USE_STD_CPP_LIB=ON \ - -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/cpputest_install - make - make install - - - name: Configure CMake project - run: | - mkdir build - cd build - cmake .. -G "Unix Makefiles" \ - -DCMAKE_CXX_FLAGS="-fexceptions -funwind-tables" \ - -DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/cpputest_install - - - name: Build project - run: | - cd build - make - - - name: Run tests - run: | - cd build - ARGS=--output-on-failure make test From 8e1f45992b0bde82ff691c33a6da6205bfffab8f Mon Sep 17 00:00:00 2001 From: Dominik Zarfl <13350047+zarfld@users.noreply.github.com> Date: Wed, 18 Jun 2025 15:29:50 +0200 Subject: [PATCH 09/17] Update README.rst --- README.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 9ab93af78..14a47aea7 100644 --- a/README.rst +++ b/README.rst @@ -2,9 +2,10 @@ .. image:: avnu_logo.png | +.. image:: https://github.com/zarfld/OpenAvnu/actions/workflows/travis_sh.yml/badge.svg + :target: https://github.com/zarfld/OpenAvnu/actions/workflows/travis_sh.yml + :alt: Build status -.. image:: https://travis-ci.org/AVnu/OpenAvnu.svg?branch=open-avb-next - :target: https://travis-ci.org/AVnu/OpenAvnu OpenAvnu ======== From 4ac1b3a3888b53ac9f18b9476460f1849ac043d8 Mon Sep 17 00:00:00 2001 From: Dominik Zarfl <13350047+zarfld@users.noreply.github.com> Date: Wed, 18 Jun 2025 15:38:19 +0200 Subject: [PATCH 10/17] Update README.rst --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 14a47aea7..6ddaf1908 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ .. image:: avnu_logo.png | -.. image:: https://github.com/zarfld/OpenAvnu/actions/workflows/travis_sh.yml/badge.svg +.. image:: https://github.com/zarfld/OpenAvnu/actions/workflows/travis_sh.yml/badge.svg?branch=open-avb-next :target: https://github.com/zarfld/OpenAvnu/actions/workflows/travis_sh.yml :alt: Build status From ad85d1d7a725b725dc00fb2c1bbbe69ac9b6c878 Mon Sep 17 00:00:00 2001 From: Dominik Zarfl <13350047+zarfld@users.noreply.github.com> Date: Wed, 18 Jun 2025 15:39:57 +0200 Subject: [PATCH 11/17] Fix thread stack size check and static PTP data --- .../platform/Linux/openavb_grandmaster_osal.c | 2 +- lib/avtp_pipeline/platform/Linux/openavb_tasks.h | 12 +++++++----- lib/avtp_pipeline/platform/Linux/openavb_time_osal.c | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/avtp_pipeline/platform/Linux/openavb_grandmaster_osal.c b/lib/avtp_pipeline/platform/Linux/openavb_grandmaster_osal.c index 7acbf76d5..5ab277e6b 100644 --- a/lib/avtp_pipeline/platform/Linux/openavb_grandmaster_osal.c +++ b/lib/avtp_pipeline/platform/Linux/openavb_grandmaster_osal.c @@ -51,7 +51,7 @@ static pthread_mutex_t gOSALGrandmasterInitMutex = PTHREAD_MUTEX_INITIALIZER; static bool bInitialized = FALSE; static int gShmFd = -1; static char *gMmap = NULL; -gPtpTimeData gPtpTD; +static gPtpTimeData gPtpTD; static bool x_grandmasterInit(void) { AVB_TRACE_ENTRY(AVB_TRACE_GRANDMASTER); diff --git a/lib/avtp_pipeline/platform/Linux/openavb_tasks.h b/lib/avtp_pipeline/platform/Linux/openavb_tasks.h index 387fd985b..c653f39e7 100644 --- a/lib/avtp_pipeline/platform/Linux/openavb_tasks.h +++ b/lib/avtp_pipeline/platform/Linux/openavb_tasks.h @@ -34,12 +34,14 @@ Complete license and copyright information can be found at #include -#if !defined(PTHREAD_STACK_MIN) -#error "PTHREAD_STACK_MIN variable not defined" -#elif (PTHREAD_STACK_MIN > 65536) -#define THREAD_STACK_SIZE PTHREAD_STACK_MIN +#if defined(PTHREAD_STACK_MIN) && !defined(__USE_DYNAMIC_STACK_SIZE) +# if PTHREAD_STACK_MIN > 65536 +# define THREAD_STACK_SIZE PTHREAD_STACK_MIN +# else +# define THREAD_STACK_SIZE 65536 +# endif #else -#define THREAD_STACK_SIZE 65536 +# define THREAD_STACK_SIZE 65536 #endif /////////////////////////// diff --git a/lib/avtp_pipeline/platform/Linux/openavb_time_osal.c b/lib/avtp_pipeline/platform/Linux/openavb_time_osal.c index 9f2239b60..99c822e0b 100644 --- a/lib/avtp_pipeline/platform/Linux/openavb_time_osal.c +++ b/lib/avtp_pipeline/platform/Linux/openavb_time_osal.c @@ -51,7 +51,7 @@ static pthread_mutex_t gOSALTimeInitMutex = PTHREAD_MUTEX_INITIALIZER; static bool bInitialized = FALSE; static int gPtpShmFd = -1; static char *gPtpMmap = NULL; -gPtpTimeData gPtpTD; +static gPtpTimeData gPtpTD; static bool x_timeInit(void) { AVB_TRACE_ENTRY(AVB_TRACE_TIME); From 4927897b11e946e250e209edb4a99dbd9ade4b2d Mon Sep 17 00:00:00 2001 From: Dominik Zarfl <13350047+zarfld@users.noreply.github.com> Date: Wed, 18 Jun 2025 15:43:09 +0200 Subject: [PATCH 12/17] Update OpenAvnu_Build.yml --- .github/workflows/OpenAvnu_Build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/OpenAvnu_Build.yml b/.github/workflows/OpenAvnu_Build.yml index e71b12eb9..27987c34d 100644 --- a/.github/workflows/OpenAvnu_Build.yml +++ b/.github/workflows/OpenAvnu_Build.yml @@ -5,6 +5,7 @@ on: branches: - '**' pull_request: + branches: - '**' workflow_dispatch: From 6af635db16a3a90b443f7f8c645008fa80b47dec Mon Sep 17 00:00:00 2001 From: Dominik Zarfl <13350047+zarfld@users.noreply.github.com> Date: Wed, 18 Jun 2025 15:48:16 +0200 Subject: [PATCH 13/17] Update travis_sh.yml --- .github/workflows/travis_sh.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/travis_sh.yml b/.github/workflows/travis_sh.yml index 463c42820..5fd2c19e7 100644 --- a/.github/workflows/travis_sh.yml +++ b/.github/workflows/travis_sh.yml @@ -51,7 +51,7 @@ jobs: - name: Run legacy make avdecc run: | - make avdecc + make avtp_avdecc continue-on-error: true - name: Update to latest CppUTest From cad4341ca959d83b70f0e9357f4f545dde08c6dc Mon Sep 17 00:00:00 2001 From: Dominik Zarfl <13350047+zarfld@users.noreply.github.com> Date: Wed, 18 Jun 2025 16:00:39 +0200 Subject: [PATCH 14/17] maap: fix logging buffer sizes and update pcap API --- daemons/maap/common/maap_log.h | 4 +-- daemons/maap/linux/src/maap_log_linux.c | 40 ++++++++++++------------- daemons/maap/test/maap_test.c | 22 +++++++------- 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/daemons/maap/common/maap_log.h b/daemons/maap/common/maap_log.h index eb9ca01f2..c71c56d78 100644 --- a/daemons/maap/common/maap_log.h +++ b/daemons/maap/common/maap_log.h @@ -85,7 +85,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define LOG_MSG_LEN 1024 // The length of the full message -#define LOG_FULL_MSG_LEN 1024 +#define LOG_FULL_MSG_LEN 2048 #ifndef TRUE #define TRUE 1 @@ -135,7 +135,7 @@ static const int MAAP_LOG_FROM_THREAD = TRUE; static const int MAAP_LOG_PULL_MODE = FALSE; // When using the MAAP_LOG_FROM_THREAD option. These defines control the behavior of the msg queue -#define LOG_QUEUE_MSG_LEN 256 +#define LOG_QUEUE_MSG_LEN 2048 #define LOG_QUEUE_MSG_SIZE (LOG_QUEUE_MSG_LEN + 1) #define LOG_QUEUE_MSG_CNT 82 #define LOG_QUEUE_SLEEP_MSEC 100 diff --git a/daemons/maap/linux/src/maap_log_linux.c b/daemons/maap/linux/src/maap_log_linux.c index 35dcfcbc3..bf1009270 100644 --- a/daemons/maap/linux/src/maap_log_linux.c +++ b/daemons/maap/linux/src/maap_log_linux.c @@ -104,35 +104,35 @@ void maapLogRTRender(log_queue_item_t *pLogItem) strcat((char *)pLogItem->msg, pLogRTItem->pFormat); break; case LOG_RT_DATATYPE_NOW_TS: - sprintf(rt_msg, "[%lu:%09lu] ", pLogRTItem->data.nowTS.tv_sec, pLogRTItem->data.nowTS.tv_nsec); + snprintf(rt_msg, sizeof(rt_msg), "[%lu:%09lu] ", pLogRTItem->data.nowTS.tv_sec, pLogRTItem->data.nowTS.tv_nsec); strcat((char *)pLogItem->msg, rt_msg); break; case LOG_RT_DATATYPE_U16: - sprintf(rt_msg, pLogRTItem->pFormat, pLogRTItem->data.unsignedShortVar); + snprintf(rt_msg, sizeof(rt_msg), pLogRTItem->pFormat, pLogRTItem->data.unsignedShortVar); strcat((char *)pLogItem->msg, rt_msg); break; case LOG_RT_DATATYPE_S16: - sprintf(rt_msg, pLogRTItem->pFormat, pLogRTItem->data.signedShortVar); + snprintf(rt_msg, sizeof(rt_msg), pLogRTItem->pFormat, pLogRTItem->data.signedShortVar); strcat((char *)pLogItem->msg, rt_msg); break; case LOG_RT_DATATYPE_U32: - sprintf(rt_msg, pLogRTItem->pFormat, pLogRTItem->data.unsignedLongVar); + snprintf(rt_msg, sizeof(rt_msg), pLogRTItem->pFormat, pLogRTItem->data.unsignedLongVar); strcat((char *)pLogItem->msg, rt_msg); break; case LOG_RT_DATATYPE_S32: - sprintf(rt_msg, pLogRTItem->pFormat, pLogRTItem->data.signedLongVar); + snprintf(rt_msg, sizeof(rt_msg), pLogRTItem->pFormat, pLogRTItem->data.signedLongVar); strcat((char *)pLogItem->msg, rt_msg); break; case LOG_RT_DATATYPE_U64: - sprintf(rt_msg, pLogRTItem->pFormat, pLogRTItem->data.unsignedLongLongVar); + snprintf(rt_msg, sizeof(rt_msg), pLogRTItem->pFormat, pLogRTItem->data.unsignedLongLongVar); strcat((char *)pLogItem->msg, rt_msg); break; case LOG_RT_DATATYPE_S64: - sprintf(rt_msg, pLogRTItem->pFormat, pLogRTItem->data.signedLongLongVar); + snprintf(rt_msg, sizeof(rt_msg), pLogRTItem->pFormat, pLogRTItem->data.signedLongLongVar); strcat((char *)pLogItem->msg, rt_msg); break; case LOG_RT_DATATYPE_FLOAT: - sprintf(rt_msg, pLogRTItem->pFormat, pLogRTItem->data.floatVar); + snprintf(rt_msg, sizeof(rt_msg), pLogRTItem->pFormat, pLogRTItem->data.floatVar); strcat((char *)pLogItem->msg, rt_msg); break; default: @@ -250,7 +250,7 @@ void maapLogFn( LOG_LOCK(); - vsprintf(msg, fmt, args); + vsnprintf(msg, sizeof(msg), fmt, args); if (MAAP_LOG_FILE_INFO && path) { char* file = strrchr(path, '/'); @@ -260,33 +260,33 @@ void maapLogFn( file += 1; else file = (char*)path; - sprintf(file_msg, " %s:%d", file, line); + snprintf(file_msg, sizeof(file_msg), " %s:%d", file, line); } if (MAAP_LOG_PROC_INFO) { - sprintf(proc_msg, " P:%5.5d", GET_PID()); + snprintf(proc_msg, sizeof(proc_msg), " P:%5.5d", GET_PID()); } if (MAAP_LOG_THREAD_INFO) { - sprintf(thread_msg, " T:%lu", THREAD_SELF()); + snprintf(thread_msg, sizeof(thread_msg), " T:%lu", THREAD_SELF()); } if (MAAP_LOG_TIME_INFO) { time_t tNow = time(NULL); struct tm tmNow; localtime_r(&tNow, &tmNow); - sprintf(time_msg, "%2.2d:%2.2d:%2.2d", tmNow.tm_hour, tmNow.tm_min, tmNow.tm_sec); + snprintf(time_msg, sizeof(time_msg), "%2.2d:%2.2d:%2.2d", tmNow.tm_hour, tmNow.tm_min, tmNow.tm_sec); } if (MAAP_LOG_TIMESTAMP_INFO) { struct timespec nowTS; clock_gettime(CLOCK_REALTIME, &nowTS); - sprintf(timestamp_msg, "%lu:%09lu", nowTS.tv_sec, nowTS.tv_nsec); + snprintf(timestamp_msg, sizeof(timestamp_msg), "%lu:%09lu", nowTS.tv_sec, nowTS.tv_nsec); } // using sprintf and puts allows using static buffers rather than heap. - if (MAAP_LOG_EXTRA_NEWLINE) - /* int32_t full_msg_len = */ sprintf(full_msg, "[%s%s%s%s %s %s%s] %s: %s\n", time_msg, timestamp_msg, proc_msg, thread_msg, company, component, file_msg, tag, msg); - else - /* int32_t full_msg_len = */ sprintf(full_msg, "[%s%s%s%s %s %s%s] %s: %s", time_msg, timestamp_msg, proc_msg, thread_msg, company, component, file_msg, tag, msg); + if (MAAP_LOG_EXTRA_NEWLINE) + /* int32_t full_msg_len = */ snprintf(full_msg, sizeof(full_msg), "[%s%s%s%s %s %s%s] %s: %s\n", time_msg, timestamp_msg, proc_msg, thread_msg, company, component, file_msg, tag, msg); + else + /* int32_t full_msg_len = */ snprintf(full_msg, sizeof(full_msg), "[%s%s%s%s %s %s%s] %s: %s", time_msg, timestamp_msg, proc_msg, thread_msg, company, component, file_msg, tag, msg); if (!MAAP_LOG_FROM_THREAD && !MAAP_LOG_PULL_MODE) { fputs(full_msg, MAAP_LOG_OUTPUT_FD); @@ -297,8 +297,8 @@ void maapLogFn( if (elem) { log_queue_item_t *pLogItem = (log_queue_item_t *)maapLogQueueData(elem); pLogItem->bRT = FALSE; - strncpy((char *)pLogItem->msg, full_msg, LOG_QUEUE_MSG_LEN); - maapLogQueueHeadPush(logQueue); + snprintf((char *)pLogItem->msg, LOG_QUEUE_MSG_SIZE, "%s", full_msg); + maapLogQueueHeadPush(logQueue); } } } diff --git a/daemons/maap/test/maap_test.c b/daemons/maap/test/maap_test.c index 28f11daae..6e4ac2570 100644 --- a/daemons/maap/test/maap_test.c +++ b/daemons/maap/test/maap_test.c @@ -232,16 +232,18 @@ int main(int argc, char *argv[]) { bpf_u_int32 mask; bpf_u_int32 net; - if (argc < 2) { - dev = pcap_lookupdev(errbuf); - if (dev == NULL) { - fprintf(stderr, "Couldn't find default device: %s\n", errbuf); - fprintf(stderr, "Try specifying the device you want: %s \n", argv[0]); - return 2; - } - } else { - dev = argv[1]; - } + if (argc < 2) { + pcap_if_t *alldevs; + if (pcap_findalldevs(&alldevs, errbuf) == -1 || alldevs == NULL) { + fprintf(stderr, "Couldn't find default device: %s\n", errbuf); + fprintf(stderr, "Try specifying the device you want: %s \n", argv[0]); + return 2; + } + dev = alldevs->name; + pcap_freealldevs(alldevs); + } else { + dev = argv[1]; + } if (pcap_lookupnet(dev, &net, &mask, errbuf) == -1) { fprintf(stderr, "Couldn't get netmask for device: %s\n", dev); From b6e03a4afe6277830a87cfb6366090fcbc341802 Mon Sep 17 00:00:00 2001 From: Dominik Zarfl <13350047+zarfld@users.noreply.github.com> Date: Wed, 18 Jun 2025 18:37:18 +0200 Subject: [PATCH 15/17] Fix constant comparison and tighten log formatting --- daemons/shaper/src/shaper_daemon.c | 16 ++-- daemons/shaper/src/shaper_log_linux.c | 109 ++++++++++++++------------ 2 files changed, 65 insertions(+), 60 deletions(-) diff --git a/daemons/shaper/src/shaper_daemon.c b/daemons/shaper/src/shaper_daemon.c index 1ef6a69c1..00e6587b7 100644 --- a/daemons/shaper/src/shaper_daemon.c +++ b/daemons/shaper/src/shaper_daemon.c @@ -470,14 +470,14 @@ int process_command(int sockfd, char command[]) return -1; } } - if (input.unreserve_bw) - { - if (input.stream_da == 0) - { - log_client_error_message(sockfd, "Stream Destination Address is required to unreserve bandwidth"); - usage(sockfd); - return -1; - } + if (input.unreserve_bw) + { + if (strlen(input.stream_da) == 0) + { + log_client_error_message(sockfd, "Stream Destination Address is required to unreserve bandwidth"); + usage(sockfd); + return -1; + } } if ((input.quit==1 || input.delete_qdisc==1) &&(input.reserve_bw==1 || input.unreserve_bw==1)) { diff --git a/daemons/shaper/src/shaper_log_linux.c b/daemons/shaper/src/shaper_log_linux.c index 38017c389..728db55ba 100644 --- a/daemons/shaper/src/shaper_log_linux.c +++ b/daemons/shaper/src/shaper_log_linux.c @@ -60,7 +60,7 @@ typedef struct { static shaper_log_queue_t logQueue; static shaper_log_queue_t logRTQueue; -static char msg[LOG_MSG_LEN] = ""; +static char msg[LOG_QUEUE_MSG_LEN] = ""; static char time_msg[LOG_TIME_LEN] = ""; static char timestamp_msg[LOG_TIMESTAMP_LEN] = ""; static char file_msg[LOG_FILE_LEN] = ""; @@ -102,38 +102,38 @@ void shaperLogRTRender(log_queue_item_t *pLogItem) case LOG_RT_DATATYPE_CONST_STR: strcat((char *)pLogItem->msg, pLogRTItem->pFormat); break; - case LOG_RT_DATATYPE_NOW_TS: - sprintf(rt_msg, "[%lu:%09lu] ", pLogRTItem->data.nowTS.tv_sec, pLogRTItem->data.nowTS.tv_nsec); - strcat((char *)pLogItem->msg, rt_msg); - break; - case LOG_RT_DATATYPE_U16: - sprintf(rt_msg, pLogRTItem->pFormat, pLogRTItem->data.unsignedShortVar); - strcat((char *)pLogItem->msg, rt_msg); - break; - case LOG_RT_DATATYPE_S16: - sprintf(rt_msg, pLogRTItem->pFormat, pLogRTItem->data.signedShortVar); - strcat((char *)pLogItem->msg, rt_msg); - break; - case LOG_RT_DATATYPE_U32: - sprintf(rt_msg, pLogRTItem->pFormat, pLogRTItem->data.unsignedLongVar); - strcat((char *)pLogItem->msg, rt_msg); - break; - case LOG_RT_DATATYPE_S32: - sprintf(rt_msg, pLogRTItem->pFormat, pLogRTItem->data.signedLongVar); - strcat((char *)pLogItem->msg, rt_msg); - break; - case LOG_RT_DATATYPE_U64: - sprintf(rt_msg, pLogRTItem->pFormat, pLogRTItem->data.unsignedLongLongVar); - strcat((char *)pLogItem->msg, rt_msg); - break; - case LOG_RT_DATATYPE_S64: - sprintf(rt_msg, pLogRTItem->pFormat, pLogRTItem->data.signedLongLongVar); - strcat((char *)pLogItem->msg, rt_msg); - break; - case LOG_RT_DATATYPE_FLOAT: - sprintf(rt_msg, pLogRTItem->pFormat, pLogRTItem->data.floatVar); - strcat((char *)pLogItem->msg, rt_msg); - break; + case LOG_RT_DATATYPE_NOW_TS: + snprintf(rt_msg, sizeof(rt_msg), "[%lu:%09lu] ", pLogRTItem->data.nowTS.tv_sec, pLogRTItem->data.nowTS.tv_nsec); + strcat((char *)pLogItem->msg, rt_msg); + break; + case LOG_RT_DATATYPE_U16: + snprintf(rt_msg, sizeof(rt_msg), pLogRTItem->pFormat, pLogRTItem->data.unsignedShortVar); + strcat((char *)pLogItem->msg, rt_msg); + break; + case LOG_RT_DATATYPE_S16: + snprintf(rt_msg, sizeof(rt_msg), pLogRTItem->pFormat, pLogRTItem->data.signedShortVar); + strcat((char *)pLogItem->msg, rt_msg); + break; + case LOG_RT_DATATYPE_U32: + snprintf(rt_msg, sizeof(rt_msg), pLogRTItem->pFormat, pLogRTItem->data.unsignedLongVar); + strcat((char *)pLogItem->msg, rt_msg); + break; + case LOG_RT_DATATYPE_S32: + snprintf(rt_msg, sizeof(rt_msg), pLogRTItem->pFormat, pLogRTItem->data.signedLongVar); + strcat((char *)pLogItem->msg, rt_msg); + break; + case LOG_RT_DATATYPE_U64: + snprintf(rt_msg, sizeof(rt_msg), pLogRTItem->pFormat, pLogRTItem->data.unsignedLongLongVar); + strcat((char *)pLogItem->msg, rt_msg); + break; + case LOG_RT_DATATYPE_S64: + snprintf(rt_msg, sizeof(rt_msg), pLogRTItem->pFormat, pLogRTItem->data.signedLongLongVar); + strcat((char *)pLogItem->msg, rt_msg); + break; + case LOG_RT_DATATYPE_FLOAT: + snprintf(rt_msg, sizeof(rt_msg), pLogRTItem->pFormat, pLogRTItem->data.floatVar); + strcat((char *)pLogItem->msg, rt_msg); + break; default: break; } @@ -250,12 +250,12 @@ void shaperLogFn( ...) { if (level <= SHAPER_LOG_LEVEL) { - va_list args; - va_start(args, fmt); + va_list args; + va_start(args, fmt); - LOG_LOCK(); + LOG_LOCK(); - vsprintf(msg, fmt, args); + vsnprintf(msg, sizeof(msg), fmt, args); if (SHAPER_LOG_FILE_INFO && path) { char* file = strrchr(path, '/'); @@ -265,33 +265,33 @@ void shaperLogFn( file += 1; else file = (char*)path; - sprintf(file_msg, " %s:%d", file, line); + snprintf(file_msg, sizeof(file_msg), " %s:%d", file, line); } if (SHAPER_LOG_PROC_INFO) { - sprintf(proc_msg, " P:%5.5d", GET_PID()); + snprintf(proc_msg, sizeof(proc_msg), " P:%5.5d", GET_PID()); } if (SHAPER_LOG_THREAD_INFO) { - sprintf(thread_msg, " T:%lu", THREAD_SELF()); + snprintf(thread_msg, sizeof(thread_msg), " T:%lu", THREAD_SELF()); } if (SHAPER_LOG_TIME_INFO) { time_t tNow = time(NULL); struct tm tmNow; localtime_r(&tNow, &tmNow); - sprintf(time_msg, "%2.2d:%2.2d:%2.2d", tmNow.tm_hour, tmNow.tm_min, tmNow.tm_sec); + snprintf(time_msg, sizeof(time_msg), "%2.2d:%2.2d:%2.2d", tmNow.tm_hour, tmNow.tm_min, tmNow.tm_sec); } if (SHAPER_LOG_TIMESTAMP_INFO) { struct timespec nowTS; clock_gettime(CLOCK_REALTIME, &nowTS); - sprintf(timestamp_msg, "%lu:%09lu", nowTS.tv_sec, nowTS.tv_nsec); + snprintf(timestamp_msg, sizeof(timestamp_msg), "%lu:%09lu", nowTS.tv_sec, nowTS.tv_nsec); } // using sprintf and puts allows using static buffers rather than heap. - if (SHAPER_LOG_EXTRA_NEWLINE) - /* int32_t full_msg_len = */ sprintf(full_msg, "[%s%s%s%s %s %s%s] %s: %s\n", time_msg, timestamp_msg, proc_msg, thread_msg, company, component, file_msg, tag, msg); - else - /* int32_t full_msg_len = */ sprintf(full_msg, "[%s%s%s%s %s %s%s] %s: %s", time_msg, timestamp_msg, proc_msg, thread_msg, company, component, file_msg, tag, msg); + if (SHAPER_LOG_EXTRA_NEWLINE) + /* int32_t full_msg_len = */ snprintf(full_msg, sizeof(full_msg), "[%s%s%s%s %s %s%s] %s: %s\n", time_msg, timestamp_msg, proc_msg, thread_msg, company, component, file_msg, tag, msg); + else + /* int32_t full_msg_len = */ snprintf(full_msg, sizeof(full_msg), "[%s%s%s%s %s %s%s] %s: %s", time_msg, timestamp_msg, proc_msg, thread_msg, company, component, file_msg, tag, msg); if (!SHAPER_LOG_FROM_THREAD && !SHAPER_LOG_PULL_MODE) { fputs(full_msg, SHAPER_LOG_OUTPUT_FD); @@ -302,7 +302,12 @@ void shaperLogFn( if (elem) { log_queue_item_t *pLogItem = (log_queue_item_t *)shaperLogQueueData(elem); pLogItem->bRT = FALSE; - strncpy((char *)pLogItem->msg, full_msg, LOG_QUEUE_MSG_LEN); + size_t len = strlen(full_msg); + if (len >= LOG_QUEUE_MSG_LEN) { + len = LOG_QUEUE_MSG_LEN - 1; + } + memcpy(pLogItem->msg, full_msg, len); + pLogItem->msg[len] = '\0'; shaperLogQueueHeadPush(logQueue); } } @@ -428,11 +433,11 @@ void shaperLogBuffer( pszOut = szDataLine; *pszOut++ = '\t'; for (j = i; j < i + lineLen; ++j) { - if (j < dataLen) { - sprintf(pszOut, "%02x ", pData[j]); - } else { - strcpy(pszOut, " "); - } + if (j < dataLen) { + snprintf(pszOut, 4, "%02x ", pData[j]); + } else { + strcpy(pszOut, " "); + } pszOut += 3; } From f3b7eea3b5fae11db5bcadf9260cc78ac0d10d97 Mon Sep 17 00:00:00 2001 From: Dominik Zarfl <13350047+zarfld@users.noreply.github.com> Date: Wed, 18 Jun 2025 18:56:02 +0200 Subject: [PATCH 16/17] fix: mark fallthrough in talker mrp --- examples/common/talker_mrp_client.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/common/talker_mrp_client.c b/examples/common/talker_mrp_client.c index 6959e220b..145d5c4ed 100644 --- a/examples/common/talker_mrp_client.c +++ b/examples/common/talker_mrp_client.c @@ -271,13 +271,14 @@ int process_mrp_msg(char *buf, int buflen, struct mrp_talker_ctx *ctx) printf("listener left\n"); } break; - case 'J': - case 'N': - printf("got a new/join indication\n"); - if (substate > MSRP_LISTENER_ASKFAILED) { - if (memcmp - (recovered_streamid, - ctx->monitor_stream_id, + case 'J': + /* fall through */ + case 'N': + printf("got a new/join indication\n"); + if (substate > MSRP_LISTENER_ASKFAILED) { + if (memcmp + (recovered_streamid, + ctx->monitor_stream_id, sizeof(recovered_streamid)) == 0) ctx->listeners = 1; } From 7d5c3c64b43acd90dbec7a47dab9b0b99c815d30 Mon Sep 17 00:00:00 2001 From: Dominik Zarfl <13350047+zarfld@users.noreply.github.com> Date: Wed, 18 Jun 2025 18:58:20 +0200 Subject: [PATCH 17/17] Update talker_mrp_client.c --- examples/common/talker_mrp_client.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/common/talker_mrp_client.c b/examples/common/talker_mrp_client.c index 145d5c4ed..f23c463b8 100644 --- a/examples/common/talker_mrp_client.c +++ b/examples/common/talker_mrp_client.c @@ -273,6 +273,8 @@ int process_mrp_msg(char *buf, int buflen, struct mrp_talker_ctx *ctx) break; case 'J': /* fall through */ + printf("fall through\n"); + break; case 'N': printf("got a new/join indication\n"); if (substate > MSRP_LISTENER_ASKFAILED) {