1
1
//
2
2
// This file is part of Dire Wolf, an amateur radio packet TNC.
3
3
//
4
- // Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016 John Langner, WB2OSZ
4
+ // Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017 John Langner, WB2OSZ
5
5
//
6
6
// This program is free software: you can redistribute it and/or modify
7
7
// it under the terms of the GNU General Public License as published by
59
59
*
60
60
* 'y' Ask Outstanding frames waiting on a Port (new in 1.2)
61
61
*
62
+ * 'Y' How many frames waiting for transmit for a particular station (new in 1.5)
63
+ *
62
64
* 'C' Connect, Start an AX.25 Connection (new in 1.4)
63
65
*
64
66
* 'v' Connect VIA, Start an AX.25 circuit thru digipeaters (new in 1.4)
92
94
*
93
95
* 'y' Outstanding frames waiting on a Port (new in 1.2)
94
96
*
97
+ * 'Y' How many frames waiting for transmit for a particular station (new in 1.5)
98
+ *
95
99
* 'C' AX.25 Connection Received (new in 1.4)
96
100
*
97
101
* 'D' Connected AX.25 Data (new in 1.4)
@@ -1259,16 +1263,20 @@ static THREAD_F cmd_listen_thread (void *arg)
1259
1263
}
1260
1264
1261
1265
/*
1262
- * Take some precautions to guard against bad data
1263
- * which could cause problems later.
1266
+ * Take some precautions to guard against bad data which could cause problems later.
1264
1267
*/
1268
+ if (cmd .hdr .portx < 0 || cmd .hdr .portx >= MAX_CHANS ) {
1269
+ text_color_set (DW_COLOR_ERROR );
1270
+ dw_printf ("\nInvalid port number, %d, in command '%c', from AGW client application %d.\n" ,
1271
+ cmd .hdr .portx , cmd .hdr .datakind , client );
1272
+ cmd .hdr .portx = 0 ; // avoid subscript out of bounds, try to keep going.
1273
+ }
1265
1274
1266
1275
/*
1267
- * Call to/from must not exceeed 9 characters.
1276
+ * Call to/from fields are 10 bytes but contents must not exceeed 9 characters.
1268
1277
* It's not guaranteed that unused bytes will contain 0 so we
1269
1278
* don't issue error message in this case.
1270
1279
*/
1271
-
1272
1280
cmd .hdr .call_from [sizeof (cmd .hdr .call_from )- 1 ] = '\0' ;
1273
1281
cmd .hdr .call_to [sizeof (cmd .hdr .call_to )- 1 ] = '\0' ;
1274
1282
@@ -1455,6 +1463,7 @@ static THREAD_F cmd_listen_thread (void *arg)
1455
1463
1456
1464
// YAAC asks for this.
1457
1465
// Fake it to keep application happy.
1466
+ // TODO: Supply real values instead of just faking it.
1458
1467
1459
1468
reply .on_air_baud_rate = 0 ;
1460
1469
reply .traffic_level = 1 ;
@@ -1842,6 +1851,7 @@ static THREAD_F cmd_listen_thread (void *arg)
1842
1851
1843
1852
case 'y' : /* Ask Outstanding frames waiting on a Port */
1844
1853
1854
+ /* Number of frames sitting in transmit queue for specified channel. */
1845
1855
{
1846
1856
struct {
1847
1857
struct agwpe_s hdr ;
@@ -1856,7 +1866,40 @@ static THREAD_F cmd_listen_thread (void *arg)
1856
1866
1857
1867
int n = 0 ;
1858
1868
if (cmd .hdr .portx >= 0 && cmd .hdr .portx < MAX_CHANS ) {
1859
- n = tq_count (cmd .hdr .portx , TQ_PRIO_0_HI ) + tq_count (cmd .hdr .portx , TQ_PRIO_1_LO );
1869
+ n = tq_count (cmd .hdr .portx , -1 , "" , "" );
1870
+ }
1871
+ reply .data_NETLE = host2netle (n );
1872
+
1873
+ send_to_client (client , & reply );
1874
+ }
1875
+ break ;
1876
+
1877
+ case 'Y' : /* How Many Outstanding frames wait for tx for a particular station */
1878
+
1879
+ /* Number of frames sitting in transmit queue for given channel, */
1880
+ /* source (optional) and destination addresses. */
1881
+ {
1882
+ char source [AX25_MAX_ADDR_LEN ];
1883
+ char dest [AX25_MAX_ADDR_LEN ];
1884
+
1885
+ struct {
1886
+ struct agwpe_s hdr ;
1887
+ int data_NETLE ; // Little endian order.
1888
+ } reply ;
1889
+
1890
+ strlcpy (source , cmd .hdr .call_from , sizeof (source ));
1891
+ strlcpy (dest , cmd .hdr .call_to , sizeof (dest ));
1892
+
1893
+ memset (& reply , 0 , sizeof (reply ));
1894
+ reply .hdr .portx = cmd .hdr .portx ; /* Reply with same port number, addresses. */
1895
+ reply .hdr .datakind = 'Y' ;
1896
+ strlcpy (reply .hdr .call_from , source , sizeof (reply .hdr .call_from ));
1897
+ strlcpy (reply .hdr .call_to , dest , sizeof (reply .hdr .call_to ));
1898
+ reply .hdr .data_len_NETLE = host2netle (4 );
1899
+
1900
+ int n = 0 ;
1901
+ if (cmd .hdr .portx >= 0 && cmd .hdr .portx < MAX_CHANS ) {
1902
+ n = tq_count (cmd .hdr .portx , -1 , source , dest );
1860
1903
}
1861
1904
reply .data_NETLE = host2netle (n );
1862
1905
0 commit comments