@@ -163,7 +163,7 @@ int32_t crypto_standalone_process_command(int32_t cc, int32_t num_tokens, char *
163
163
{
164
164
Crypto_saPrint (test_association );
165
165
}
166
-
166
+ printf ( "Get_SA_Status: %d\n" , status );
167
167
if ((status == CRYPTO_LIB_SUCCESS ) && (test_association -> sa_state == SA_OPERATIONAL ) &&
168
168
(test_association -> gvcid_blk .mapid == TYPE_TC ) && (test_association -> gvcid_blk .scid == SCID ))
169
169
{
@@ -372,14 +372,10 @@ void crypto_standalone_tc_frame(uint8_t *in_data, uint16_t in_length, uint8_t *o
372
372
/* TC Length */
373
373
if (DYNAMIC_LENGTHS )
374
374
{
375
- uint8_t segment_hdr_len = tc_current_managed_parameters_struct . has_segmentation_hdr ? 1 : 0 ;
375
+ uint8_t segment_hdr_len = 1 ;
376
376
uint8_t fecf_len = tc_current_managed_parameters_struct .has_fecf ? 2 : 0 ;
377
377
378
- SecurityAssociation_t * sa_ptr ;
379
- sa_if -> sa_get_from_spi (tc_vcid , & sa_ptr );
380
-
381
- * out_length = TC_FRAME_HEADER_SIZE + segment_hdr_len + sa_ptr -> arsn_len + sa_ptr -> shivf_len +
382
- sa_ptr -> shplf_len + sa_ptr -> shsnf_len + in_length + sa_ptr -> stmacf_len + fecf_len ;
378
+ * out_length = TC_FRAME_HEADER_SIZE + segment_hdr_len + in_length + fecf_len ;
383
379
}
384
380
else
385
381
{
@@ -525,8 +521,9 @@ void crypto_standalone_tm_frame(uint8_t *in_data, uint16_t in_length, uint8_t *o
525
521
}
526
522
527
523
// Calculate security headers and trailers
528
- uint8_t header_length = TM_PRI_HDR_LENGTH + SDLS_SPI_LENGTH + sa_ptr -> shivf_len + sa_ptr -> shplf_len +
529
- sa_ptr -> shsnf_len ; // TODO: Why +40?
524
+ uint8_t header_length =
525
+ TM_PRI_HDR_LENGTH + SDLS_SPI_LENGTH + sa_ptr -> shivf_len + sa_ptr -> shplf_len + sa_ptr -> shsnf_len ;
526
+
530
527
uint8_t trailer_length = sa_ptr -> stmacf_len ;
531
528
if (tm_current_managed_parameters_struct .has_fecf == TM_HAS_FECF )
532
529
{
@@ -571,85 +568,76 @@ void crypto_standalone_tm_debug_process(uint8_t *tm_process_in)
571
568
}
572
569
}
573
570
574
- void crypto_standalone_spp_telem_or_idle (int32_t * status_p , uint8_t * tm_ptr , uint16_t * spp_len_p ,
575
- udp_interface_t * tm_socks , int * tm_process_len_p )
571
+ void crypto_standalone_spp_telem_or_idle (int32_t * status , uint8_t * tm_ptr , uint16_t * spp_len , udp_interface_t * tm_socks ,
572
+ int * tm_process_len )
576
573
{
577
- int32_t status = * status_p ;
578
- uint16_t spp_len = * spp_len_p ;
579
- int tm_process_len = * tm_process_len_p ;
580
-
581
574
udp_info_t * tm_write_sock = & tm_socks -> write ;
582
575
583
576
if ((tm_ptr [0 ] == 0x08 ) || (tm_ptr [0 ] == 0x09 ) || ((tm_ptr [0 ] == 0x07 ) && (tm_ptr [1 ] == 0xff )) ||
584
- (tm_ptr [0 ] == 0x0F && tm_ptr [1 ] == 0xFD ) || ( tm_ptr [ 0 ] == 0x1F && tm_ptr [ 1 ] == 0xFD ) )
577
+ (tm_ptr [0 ] == 0x0F && tm_ptr [1 ] == 0xFD ))
585
578
{
586
- spp_len = (((0xFFFF & tm_ptr [4 ]) << 8 ) | tm_ptr [5 ]) + 7 ;
579
+ * spp_len = (((0xFFFF & tm_ptr [4 ]) << 8 ) | tm_ptr [5 ]) + 7 ;
587
580
#ifdef CRYPTO_STANDALONE_TM_PROCESS_DEBUG
588
- printf ("crypto_standalone_tm_process - SPP[%d]: 0x" , spp_len );
589
- for (int i = 0 ; i < spp_len ; i ++ )
581
+ printf ("crypto_standalone_tm_process - SPP[%d]: 0x" , * spp_len );
582
+ for (int i = 0 ; i < * spp_len ; i ++ )
590
583
{
591
584
printf ("%02x" , tm_ptr [i ]);
592
585
}
593
586
printf ("\n" );
594
587
#endif
595
-
596
588
// Send all SPP telemetry packets
597
589
// 0x09 for HK/Device TLM Packets (Generic Components)
590
+ // 0x0FFD = CFDP
598
591
if (tm_ptr [0 ] == 0x08 || tm_ptr [0 ] == 0x09 || (tm_ptr [0 ] == 0x0f && tm_ptr [1 ] == 0xfd ))
599
592
{
600
- status = sendto (tm_write_sock -> sockfd , tm_ptr , spp_len , 0 , (struct sockaddr * )& tm_write_sock -> saddr ,
601
- sizeof (tm_write_sock -> saddr ));
593
+ * status = sendto (tm_write_sock -> sockfd , tm_ptr , * spp_len , 0 , (struct sockaddr * )& tm_write_sock -> saddr ,
594
+ sizeof (tm_write_sock -> saddr ));
602
595
}
603
596
// Only send idle packets if configured to do so
604
597
else
605
598
{
606
599
#ifdef CRYPTO_STANDALONE_DISCARD_IDLE_PACKETS
607
600
// Don't forward idle packets
608
- status = spp_len ;
601
+ * status = * spp_len ;
609
602
#else
610
- status = sendto (tm_write_sock -> sockfd , tm_ptr , spp_len , 0 , (struct sockaddr * )& tm_write_sock -> saddr ,
603
+ status = sendto (tm_write_sock -> sockfd , tm_ptr , * spp_len , 0 , (struct sockaddr * )& tm_write_sock -> saddr ,
611
604
sizeof (tm_write_sock -> saddr ));
612
605
#endif
613
606
}
614
607
615
608
// Check status
616
- if ((status == -1 ) || (status != spp_len ))
609
+ if ((* status == -1 ) || (* status != * spp_len ))
617
610
{
618
- printf ("crypto_standalone_tm_process - Reply error %d \n" , status );
611
+ printf ("crypto_standalone_tm_process - Reply error %d \n" , * status );
619
612
}
620
- tm_ptr = & tm_ptr [ spp_len ];
621
- tm_process_len = tm_process_len - spp_len ;
613
+
614
+ * tm_process_len -= * spp_len ;
622
615
}
623
616
else if ((tm_ptr [0 ] == 0xFF && tm_ptr [1 ] == 0x48 ) || (tm_ptr [0 ] == 0x00 && tm_ptr [1 ] == 0x00 ) ||
624
- (tm_ptr [0 ] == 0x02 && tm_ptr [1 ] == 0x00 ) || (tm_ptr [0 ] == 0xFF && tm_ptr [1 ] == 0xFF ) ||
625
- (tm_ptr [0 ] == 0x1F && tm_ptr [1 ] == 0xFE ))
617
+ (tm_ptr [0 ] == 0x02 && tm_ptr [1 ] == 0x00 ) || (tm_ptr [0 ] == 0xFF && tm_ptr [1 ] == 0xFF ))
626
618
{
627
619
// TODO: Why 0x0200?
628
620
// Idle Frame
629
621
// Idle Frame is entire length of remaining data
630
622
#ifdef CRYPTO_STANDALONE_DISCARD_IDLE_FRAMES
631
623
// Don't forward idle frame
632
- status = spp_len ;
624
+ * status = * spp_len ;
633
625
#else
634
- status = sendto (tm_write_sock -> sockfd , tm_ptr , spp_len , 0 , (struct sockaddr * )& tm_write_sock -> saddr ,
626
+ status = sendto (tm_write_sock -> sockfd , tm_ptr , * spp_len , 0 , (struct sockaddr * )& tm_write_sock -> saddr ,
635
627
sizeof (tm_write_sock -> saddr ));
636
- if ((status == -1 ) || (status != spp_len ))
628
+ if ((status == -1 ) || (status != * spp_len ))
637
629
{
638
- printf ("crypto_standalone_tm_process - Reply error %d \n" , status );
630
+ printf ("crypto_standalone_tm_process - Reply error %d \n" , * status );
639
631
}
640
- tm_ptr = & tm_ptr [spp_len ];
641
632
#endif
642
- tm_process_len = 0 ;
633
+ * tm_process_len = 0 ;
643
634
}
644
635
else
645
636
{
646
637
printf ("crypto_standalone_tm_process - SPP loop error, expected idle packet or frame! tm_ptr = 0x%02x%02x \n" ,
647
638
tm_ptr [0 ], tm_ptr [1 ]);
648
- tm_process_len = 0 ;
639
+ * tm_process_len = 0 ;
649
640
}
650
- * status_p = status ;
651
- * spp_len_p = spp_len ;
652
- * tm_process_len_p = tm_process_len ;
653
641
}
654
642
655
643
void * crypto_standalone_tm_process (void * socks )
@@ -747,6 +735,7 @@ void *crypto_standalone_tm_process(void *socks)
747
735
{
748
736
// SPP Telemetry OR SPP Idle Packet
749
737
crypto_standalone_spp_telem_or_idle (& status , tm_ptr , & spp_len , tm_socks , & tm_process_len );
738
+ tm_ptr = & tm_ptr [spp_len ];
750
739
}
751
740
}
752
741
else
@@ -757,13 +746,14 @@ void *crypto_standalone_tm_process(void *socks)
757
746
/* Reset */
758
747
memset (tm_process_in , 0x00 , sizeof (tm_process_in ));
759
748
tm_process_len = 0 ;
749
+ memset (tm_ptr , 0x00 , sizeof (tm_process_in ));
760
750
#ifdef CRYPTO_STANDALONE_TM_PROCESS_DEBUG
761
751
printf ("\n" );
762
752
#endif
763
753
}
764
754
765
755
/* Delay */
766
- usleep (100 );
756
+ usleep (10 );
767
757
}
768
758
close (tm_read_sock -> port );
769
759
close (tm_write_sock -> port );
0 commit comments