CCSDS Frame Security Report (FSR)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

regenerate EverParse C files with wire 0.9.0

Wire_3d now generates ExternalTypedefs.h, ExternalAPI.h, Wrapper,
and Fields files for schemas using WireCtx. Bitfield padding is
fixed so .3d structs match the OCaml codec wire_size. Test.c passes
NULL for the WIRECTX parameter and links per-schema Field stubs.

Affected: ax25, cfdp, fsr, ltp, mbr, pid1, pus, rpmsg, sdls,
spacefibre, squashfs, tcpcl, udpcl, spacewire, and others via @gen.

+96 -36
+9 -9
c/FSR.3d
··· 1 1 extern typedef struct _WireCtx WireCtx 2 2 3 - extern unit WireSetU32BE(mutable WireCtx *ctx, UINT32 idx, UINT32BE v) 3 + extern unit FSRSetU32BE(mutable WireCtx *ctx, UINT32 idx, UINT32BE v) 4 4 5 5 entrypoint 6 6 typedef struct _FSR(mutable WireCtx *ctx) 7 7 { 8 - UINT32BE CWT : 1 {:act WireSetU32BE(ctx, (UINT32) 0, CWT); }; 9 - UINT32BE Version : 3 {:act WireSetU32BE(ctx, (UINT32) 1, Version); }; 10 - UINT32BE Alarm : 1 {:act WireSetU32BE(ctx, (UINT32) 2, Alarm); }; 11 - UINT32BE BadSN : 1 {:act WireSetU32BE(ctx, (UINT32) 3, BadSN); }; 12 - UINT32BE BadMAC : 1 {:act WireSetU32BE(ctx, (UINT32) 4, BadMAC); }; 13 - UINT32BE BadSA : 1 {:act WireSetU32BE(ctx, (UINT32) 5, BadSA); }; 14 - UINT32BE SPI : 16 {:act WireSetU32BE(ctx, (UINT32) 6, SPI); }; 15 - UINT32BE ARSN_LSB : 8 {:act WireSetU32BE(ctx, (UINT32) 7, ARSN_LSB); }; 8 + UINT32BE CWT : 1 {:act FSRSetU32BE(ctx, (UINT32) 0, CWT); }; 9 + UINT32BE Version : 3 {:act FSRSetU32BE(ctx, (UINT32) 1, Version); }; 10 + UINT32BE Alarm : 1 {:act FSRSetU32BE(ctx, (UINT32) 2, Alarm); }; 11 + UINT32BE BadSN : 1 {:act FSRSetU32BE(ctx, (UINT32) 3, BadSN); }; 12 + UINT32BE BadMAC : 1 {:act FSRSetU32BE(ctx, (UINT32) 4, BadMAC); }; 13 + UINT32BE BadSA : 1 {:act FSRSetU32BE(ctx, (UINT32) 5, BadSA); }; 14 + UINT32BE SPI : 16 {:act FSRSetU32BE(ctx, (UINT32) 6, SPI); }; 15 + UINT32BE ARSN_LSB : 8 {:act FSRSetU32BE(ctx, (UINT32) 7, ARSN_LSB); }; 16 16 } FSR; 17 17 18 18
+8 -8
c/FSR.c
··· 45 45 else 46 46 { 47 47 uint32_t bitfield0 = Load32Be(Input + (uint32_t)StartPosition); 48 - WireSetU32be(Ctx, (uint32_t)0U, EverParseGetBitfield32MsbFirst(bitfield0, 0U, 1U)); 49 - WireSetU32be(Ctx, (uint32_t)1U, EverParseGetBitfield32MsbFirst(bitfield0, 1U, 4U)); 50 - WireSetU32be(Ctx, (uint32_t)2U, EverParseGetBitfield32MsbFirst(bitfield0, 4U, 5U)); 51 - WireSetU32be(Ctx, (uint32_t)3U, EverParseGetBitfield32MsbFirst(bitfield0, 5U, 6U)); 52 - WireSetU32be(Ctx, (uint32_t)4U, EverParseGetBitfield32MsbFirst(bitfield0, 6U, 7U)); 53 - WireSetU32be(Ctx, (uint32_t)5U, EverParseGetBitfield32MsbFirst(bitfield0, 7U, 8U)); 54 - WireSetU32be(Ctx, (uint32_t)6U, EverParseGetBitfield32MsbFirst(bitfield0, 8U, 24U)); 55 - WireSetU32be(Ctx, (uint32_t)7U, EverParseGetBitfield32MsbFirst(bitfield0, 24U, 32U)); 48 + FsrsetU32be(Ctx, (uint32_t)0U, EverParseGetBitfield32MsbFirst(bitfield0, 0U, 1U)); 49 + FsrsetU32be(Ctx, (uint32_t)1U, EverParseGetBitfield32MsbFirst(bitfield0, 1U, 4U)); 50 + FsrsetU32be(Ctx, (uint32_t)2U, EverParseGetBitfield32MsbFirst(bitfield0, 4U, 5U)); 51 + FsrsetU32be(Ctx, (uint32_t)3U, EverParseGetBitfield32MsbFirst(bitfield0, 5U, 6U)); 52 + FsrsetU32be(Ctx, (uint32_t)4U, EverParseGetBitfield32MsbFirst(bitfield0, 6U, 7U)); 53 + FsrsetU32be(Ctx, (uint32_t)5U, EverParseGetBitfield32MsbFirst(bitfield0, 7U, 8U)); 54 + FsrsetU32be(Ctx, (uint32_t)6U, EverParseGetBitfield32MsbFirst(bitfield0, 8U, 24U)); 55 + FsrsetU32be(Ctx, (uint32_t)7U, EverParseGetBitfield32MsbFirst(bitfield0, 24U, 32U)); 56 56 BOOLEAN actionResult = TRUE; 57 57 KRML_MAYBE_UNUSED_VAR(actionResult); 58 58 positionAfterFsr = positionAfterBitfield0;
+1 -1
c/FSR_ExternalAPI.h
··· 10 10 #include "EverParse.h" 11 11 #include "FSR_ExternalTypedefs.h" 12 12 13 - extern void WireSetU32be(WIRECTX *ctx, uint32_t idx, uint32_t v); 13 + extern void FsrsetU32be(WIRECTX *ctx, uint32_t idx, uint32_t v); 14 14 15 15 #if defined(__cplusplus) 16 16 }
+1 -2
c/FSR_ExternalTypedefs.h
··· 1 1 #ifndef WIRECTX_DEFINED 2 2 #define WIRECTX_DEFINED 3 - #include <stdint.h> 4 - typedef struct { int64_t *fields; } WIRECTX; 3 + typedef struct FSRFields WIRECTX; 5 4 #endif
+20
c/FSR_Fields.c
··· 1 + #include <stdint.h> 2 + #include "FSR_Fields.h" 3 + #include "FSR_ExternalTypedefs.h" 4 + #include "FSR_ExternalAPI.h" 5 + 6 + void FsrsetU32be(WIRECTX *ctx, uint32_t idx, uint32_t v) { 7 + FSRFields *f = (FSRFields *) ctx; 8 + switch (idx) { 9 + case 0: f->CWT = (uint32_t) v; break; 10 + case 1: f->Version = (uint32_t) v; break; 11 + case 2: f->Alarm = (uint32_t) v; break; 12 + case 3: f->BadSN = (uint32_t) v; break; 13 + case 4: f->BadMAC = (uint32_t) v; break; 14 + case 5: f->BadSA = (uint32_t) v; break; 15 + case 6: f->SPI = (uint32_t) v; break; 16 + case 7: f->ARSN_LSB = (uint32_t) v; break; 17 + default: (void) f; (void) v; break; 18 + } 19 + } 20 +
+28
c/FSR_Fields.h
··· 1 + #ifndef FSR_FIELDS_H 2 + #define FSR_FIELDS_H 3 + #include <stdint.h> 4 + 5 + /* Field indices -- use with the schema's WireSet* callbacks in a 6 + custom [WIRECTX] if you only want to capture a subset. */ 7 + #define FSR_IDX_CWT 0 8 + #define FSR_IDX_VERSION 1 9 + #define FSR_IDX_ALARM 2 10 + #define FSR_IDX_BADSN 3 11 + #define FSR_IDX_BADMAC 4 12 + #define FSR_IDX_BADSA 5 13 + #define FSR_IDX_SPI 6 14 + #define FSR_IDX_ARSN_LSB 7 15 + 16 + /* Default plug: one typed member per named field. Pass a pointer to 17 + [FSRFields] as [WIRECTX *] when you want every field populated. */ 18 + typedef struct FSRFields { 19 + uint32_t CWT; 20 + uint32_t Version; 21 + uint32_t Alarm; 22 + uint32_t BadSN; 23 + uint32_t BadMAC; 24 + uint32_t BadSA; 25 + uint32_t SPI; 26 + uint32_t ARSN_LSB; 27 + } FSRFields; 28 + #endif
+5 -3
c/dune.inc
··· 9 9 (rule 10 10 (alias gen) 11 11 (mode fallback) 12 - (targets EverParse.h EverParseEndianness.h FSR.h FSR.c FSR_ExternalTypedefs.h FSR_ExternalAPI.h FSRWrapper.c FSRWrapper.h test.c) 12 + (targets EverParse.h EverParseEndianness.h FSR.h FSR.c FSR_ExternalTypedefs.h FSR_ExternalAPI.h FSRWrapper.c FSRWrapper.h FSR_Fields.h FSR_Fields.c test.c) 13 13 (deps gen.exe FSR.3d) 14 14 (action 15 15 (run ./gen.exe c))) 16 16 17 17 (rule 18 18 (alias runtest) 19 - (deps test.c EverParse.h EverParseEndianness.h FSR.h FSR.c FSR_ExternalTypedefs.h FSR_ExternalAPI.h FSRWrapper.c FSRWrapper.h) 19 + (deps test.c EverParse.h EverParseEndianness.h FSR.h FSR.c FSR_ExternalTypedefs.h FSR_ExternalAPI.h FSRWrapper.c FSRWrapper.h FSR_Fields.h FSR_Fields.c) 20 20 (action 21 21 (system 22 - "cc -std=c11 -Wall -Wextra -Werror -o test_fsr test.c FSR.c FSRWrapper.c && ./test_fsr"))) 22 + "cc -std=c99 -Wall -Wextra -Werror -Wpedantic -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wcast-qual -o test_fsr test.c FSR.c FSR_Fields.c && ./test_fsr"))) 23 23 24 24 (install 25 25 (package fsr) ··· 32 32 (FSR_ExternalAPI.h as c/FSR_ExternalAPI.h) 33 33 (FSRWrapper.c as c/FSRWrapper.c) 34 34 (FSRWrapper.h as c/FSRWrapper.h) 35 + (FSR_Fields.h as c/FSR_Fields.h) 36 + (FSR_Fields.c as c/FSR_Fields.c) 35 37 (EverParse.h as c/EverParse.h) 36 38 (EverParseEndianness.h as c/EverParseEndianness.h)))
+24 -13
c/test.c
··· 4 4 #include <string.h> 5 5 #include "EverParse.h" 6 6 #include "FSR.h" 7 + #include "FSR_Fields.h" 7 8 8 9 static int error_count; 9 10 ··· 22 23 int main(void) { 23 24 int failures = 0; 24 25 25 - /* FSR (32 bytes) */ 26 + /* FSR (4 bytes) */ 26 27 { 27 28 int pass = 0, fail = 0; 28 - uint8_t buf[32]; 29 + uint8_t buf[4]; 29 30 uint64_t r; 31 + FSRFields ctx = {0}; 30 32 31 - memset(buf, 0, 32); 32 - r = FsrValidateFsr(NULL, NULL, counting_error_handler, buf, 32, 0); 33 + memset(buf, 0, 4); 34 + r = FsrValidateFsr((WIRECTX *) &ctx, NULL, counting_error_handler, buf, 4, 0); 35 + if (!EverParseIsSuccess(r) || r != 4) { 36 + fprintf(stderr, 37 + "FATAL: FSR wire_size mismatch -- codec declared 4 bytes, " 38 + "EverParse validator returned %llu. Fix the OCaml codec's " 39 + "wire_size or the .3d projection.\n", 40 + (unsigned long long) r); 41 + return 2; 42 + } 33 43 CHECK("zero buffer validates", EverParseIsSuccess(r)); 34 - CHECK("position advanced to 32", r == 32); 44 + CHECK("position advanced to 4", r == 4); 35 45 36 - r = FsrValidateFsr(NULL, NULL, counting_error_handler, buf, 64, 0); 46 + r = FsrValidateFsr((WIRECTX *) &ctx, NULL, counting_error_handler, buf, 8, 0); 37 47 CHECK("larger buffer validates", EverParseIsSuccess(r)); 38 - CHECK("position is 32 not 64", r == 32); 48 + CHECK("position is 4 not 8", r == 4); 39 49 40 - for (uint64_t len = 0; len < 32; len++) { 50 + for (uint64_t len = 0; len < 4; len++) { 41 51 error_count = 0; 42 - r = FsrValidateFsr(NULL, NULL, counting_error_handler, buf, len, 0); 52 + r = FsrValidateFsr((WIRECTX *) &ctx, NULL, counting_error_handler, buf, len, 0); 43 53 CHECK("truncated to len fails", EverParseIsError(r)); 44 54 } 45 55 46 - r = FsrValidateFsr(NULL, NULL, counting_error_handler, buf, 0, 0); 56 + r = FsrValidateFsr((WIRECTX *) &ctx, NULL, counting_error_handler, buf, 0, 0); 47 57 CHECK("empty input fails", EverParseIsError(r)); 48 58 49 59 srand(42); 50 60 for (int i = 0; i < 1000; i++) { 51 - for (int j = 0; j < 32; j++) 61 + for (int j = 0; j < 4; j++) 52 62 buf[j] = (uint8_t)(rand() & 0xff); 53 - r = FsrValidateFsr(NULL, NULL, counting_error_handler, buf, 32, 0); 63 + r = FsrValidateFsr((WIRECTX *) &ctx, NULL, counting_error_handler, buf, 4, 0); 54 64 CHECK("random buffer validates", EverParseIsSuccess(r)); 55 - CHECK("random position correct", r == 32); 65 + CHECK("random position correct", r == 4); 56 66 } 57 67 68 + (void) ctx; 58 69 printf("fsr: %d passed, %d failed\n", pass, fail); 59 70 failures += fail; 60 71 }