@@ -159,6 +159,7 @@ static THREAD_F connect_listen_thread (void *arg);
159
159
static THREAD_F kissnet_listen_thread (void * arg );
160
160
161
161
162
+ static struct misc_config_s * s_misc_config_p ;
162
163
163
164
static int kiss_debug = 0 ; /* Print information flowing from and to client. */
164
165
@@ -204,6 +205,8 @@ void kissnet_init (struct misc_config_s *mc)
204
205
pthread_t cmd_listen_tid [MAX_NET_CLIENTS ];
205
206
int e ;
206
207
#endif
208
+ s_misc_config_p = mc ;
209
+
207
210
int kiss_port = mc -> kiss_port ; /* default 8001 but easily changed. */
208
211
209
212
@@ -650,6 +653,90 @@ void kissnet_send_rec_packet (int chan, int kiss_cmd, unsigned char *fbuf, int f
650
653
} /* end kissnet_send_rec_packet */
651
654
652
655
656
+ /*-------------------------------------------------------------------
657
+ *
658
+ * Name: kissnet_copy
659
+ *
660
+ * Purpose: Send data from one network KISS client to all others.
661
+ *
662
+ * Inputs: in_msg - KISS frame data without the framing or escapes.
663
+ * The first byte is channel (port) and command (should be data).
664
+ *
665
+ * in_len - Number of bytes in above.
666
+ *
667
+ * chan - Channel. Redundant because it is also in first byte of kiss_msg.
668
+ * Not currently used.
669
+ *
670
+ * cmd - KISS command nybble. Redundant because it is in first byte.
671
+ * Should be 0 because I'm expecting this only for data.
672
+ *
673
+ * from_client - Number of network (TCP) client instance.
674
+ * Should be 0, 1, 2, ...
675
+ *
676
+ *
677
+ * Global In: kiss_copy - From misc. configuration.
678
+ * This enables the feature.
679
+ *
680
+ *
681
+ * Description: Send message to any attached network KISS clients, other than the one where it came from.
682
+ * Enable this by putting KISSCOPY in the configuration file.
683
+ * Note that this applies only to network (TCP) KISS clients, not serial port, or pseudo terminal.
684
+ *
685
+ *
686
+ *--------------------------------------------------------------------*/
687
+
688
+
689
+ void kissnet_copy (unsigned char * in_msg , int in_len , int chan , int cmd , int from_client )
690
+ {
691
+ unsigned char kiss_buff [2 * AX25_MAX_PACKET_LEN ];
692
+ int kiss_len ;
693
+ int err ;
694
+ int send_to ;
695
+
696
+ (void ) chan ;
697
+ (void ) cmd ;
698
+
699
+ if (s_misc_config_p -> kiss_copy ) {
700
+
701
+ for (send_to = 0 ; send_to < MAX_NET_CLIENTS ; send_to ++ ) {
702
+
703
+ if (send_to != from_client && client_sock [send_to ] != -1 ) {
704
+
705
+ kiss_len = kiss_encapsulate (in_msg , in_len , kiss_buff );
706
+
707
+ /* This has the escapes and the surrounding FENDs. */
708
+
709
+ if (kiss_debug ) {
710
+ kiss_debug_print (TO_CLIENT , NULL , kiss_buff , kiss_len );
711
+ }
712
+
713
+ #if __WIN32__
714
+ err = SOCK_SEND (client_sock [send_to ], (char * )kiss_buff , kiss_len );
715
+ if (err == SOCKET_ERROR )
716
+ {
717
+ text_color_set (DW_COLOR_ERROR );
718
+ dw_printf ("\nError %d copying message to KISS client %d application. Closing connection.\n\n" , WSAGetLastError (), send_to );
719
+ closesocket (client_sock [send_to ]);
720
+ client_sock [send_to ] = -1 ;
721
+ WSACleanup ();
722
+ }
723
+ #else
724
+ err = SOCK_SEND (client_sock [send_to ], kiss_buff , kiss_len );
725
+ if (err <= 0 )
726
+ {
727
+ text_color_set (DW_COLOR_ERROR );
728
+ dw_printf ("\nError copying message to KISS client %d application. Closing connection.\n\n" , send_to );
729
+ close (client_sock [send_to ]);
730
+ client_sock [send_to ] = -1 ;
731
+ }
732
+ #endif
733
+ } // if origin and destination different.
734
+ } // loop over all KISS network clients.
735
+ } // Feature enabled.
736
+
737
+ } /* end kissnet_copy */
738
+
739
+
653
740
654
741
/*-------------------------------------------------------------------
655
742
*
0 commit comments