Skip to content

Commit 1f5eca7

Browse files
authored
Merge pull request #15 from OpenCyphal-Garage/cleanup
Clean up the libudpard source and test files. With this change we are establishing a baseline with workflows that pass with `-werror` on in the CMake List file.
2 parents bb86d0a + abc068d commit 1f5eca7

File tree

13 files changed

+6666
-12656
lines changed

13 files changed

+6666
-12656
lines changed

.github/workflows/main.yml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ env:
55
jobs:
66
debug:
77
runs-on: ubuntu-latest
8+
container: ghcr.io/opencyphal/toolshed:ts20.4.1
89
strategy:
910
matrix:
1011
toolchain: ['clang', 'gcc']
@@ -16,24 +17,17 @@ jobs:
1617
c-compiler: clang
1718
cxx-compiler: clang++
1819
steps:
19-
- uses: actions/checkout@v2
20-
- run: |
21-
wget https://apt.llvm.org/llvm.sh
22-
chmod +x llvm.sh
23-
sudo ./llvm.sh $LLVM_VERSION
24-
sudo apt update -y && sudo apt upgrade -y
25-
sudo apt-get -y install gcc-multilib g++-multilib clang-tidy-$LLVM_VERSION
26-
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-$LLVM_VERSION 50
27-
clang-tidy --version
20+
- uses: actions/checkout@v3
2821
- run: >
2922
cmake
3023
-B ${{ github.workspace }}/build
3124
-DCMAKE_BUILD_TYPE=Debug
3225
-DCMAKE_C_COMPILER=${{ matrix.c-compiler }}
3326
-DCMAKE_CXX_COMPILER=${{ matrix.cxx-compiler }}
3427
tests
35-
- working-directory: ${{github.workspace}}/build
28+
- name: make
3629
run: |
30+
cd ${{ github.workspace }}/build
3731
make VERBOSE=1
3832
make test
3933
- uses: actions/upload-artifact@v2
@@ -45,6 +39,7 @@ jobs:
4539

4640
optimizations:
4741
runs-on: ubuntu-latest
42+
container: ghcr.io/opencyphal/toolshed:ts20.4.1
4843
strategy:
4944
matrix:
5045
toolchain: ['clang', 'gcc']
@@ -57,10 +52,7 @@ jobs:
5752
c-compiler: clang
5853
cxx-compiler: clang++
5954
steps:
60-
- uses: actions/checkout@v2
61-
- run: |
62-
sudo apt update -y && sudo apt upgrade -y
63-
sudo apt install gcc-multilib g++-multilib
55+
- uses: actions/checkout@v3
6456
- run: >
6557
cmake
6658
-B ${{ github.workspace }}/build
@@ -69,8 +61,9 @@ jobs:
6961
-DCMAKE_CXX_COMPILER=${{ matrix.cxx-compiler }}
7062
-DNO_STATIC_ANALYSIS=1
7163
tests
72-
- working-directory: ${{github.workspace}}/build
64+
- name: make
7365
run: |
66+
cd ${{ github.workspace }}/build
7467
make VERBOSE=1
7568
make test
7669
- uses: actions/upload-artifact@v2

libudpard/udpard.c

Lines changed: 55 additions & 107 deletions
Large diffs are not rendered by default.

libudpard/udpard.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,20 @@ extern "C" {
5151
#define UDPARD_SUCCESS 0
5252

5353
/// MTU values for the supported protocols.
54-
#define UDPARD_MTU_UDP_IPV4 576U
55-
#define UDPARD_MTU_UDP_IPV6 1280U
56-
#define UDPARD_MTU_UDP_IPV4_TEMP 64U
57-
#define UDPARD_MTU_MAX UDPARD_MTU_UDP_IPV6 /// We may want to set this to 1400/1500 for Ethernet MTU
54+
/// RFC 791 states that hosts must be prepared to accept datagrams of up to 576 octets and it is expected that this
55+
/// library will receive non ip-fragmented datagrams thus the minimum MTU should be larger than 576.
56+
/// That being said, the MTU here is set to 1408 which is derived from
57+
/// A 1500B Ethernet MTU RFC 894 - 60B IPv4 max header - 8B UDP Header - 24B Cyphal header which is equal to 1408B
58+
#define UDPARD_MTU_MAX 1408U // Note that to guarantee a single frame transfer your max payload size shall be 1404
59+
// This value is to accomodate for a 4B CRC which is appended to the transfer.
60+
#define UDPARD_MTU_UDP_IPV4 UDPARD_MTU_MAX
61+
#define UDPARD_MTU_UDP_IPV6 UDPARD_MTU_MAX
5862

5963
/// Parameter ranges are inclusive; the lower bound is zero for all. See Cyphal/UDP Specification for background.
6064
#define UDPARD_SUBJECT_ID_MAX 32767U /// 15 bits subject ID
6165
#define UDPARD_SERVICE_ID_MAX 65535U /// The hard limit for ports
6266
#define UDPARD_NODE_SUBNET_MAX 31U /// 5 bits for subnet
63-
#define UDPARD_NODE_ID_MAX 65535U /// 16 bits is the hard limit. But this may change pending implementations
67+
#define UDPARD_NODE_ID_MAX 65534U /// 16 bits - 1 is the hard limit. But this may change pending implementations
6468
#define UDPARD_PRIORITY_MAX 7U
6569
#define UDPARD_TRANSFER_ID_BIT_LENGTH 63ULL
6670
#define UDPARD_TRANSFER_ID_MAX ((1ULL << UDPARD_TRANSFER_ID_BIT_LENGTH) - 1ULL)
@@ -541,7 +545,6 @@ int8_t udpardRxAccept(UdpardInstance* const ins,
541545
const UdpardMicrosecond timestamp_usec,
542546
UdpardFrame* const frame,
543547
const uint8_t redundant_transport_index,
544-
UdpardSessionSpecifier* const specifier,
545548
UdpardRxTransfer* const out_transfer,
546549
UdpardRxSubscription** const out_subscription);
547550

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ set(CMAKE_CXX_STANDARD 17)
3737
set(CXX_EXTENSIONS OFF)
3838
add_compile_options(
3939
-Wall -Wextra -pedantic -fstrict-aliasing -Wdouble-promotion -Wswitch-enum -Wfloat-equal -Wundef
40-
# -Werror
40+
-Werror
4141
-Wconversion -Wtype-limits -Wsign-conversion -Wcast-align
4242
)
4343
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual -Wnon-virtual-dtor -Wsign-promo")

0 commit comments

Comments
 (0)