@@ -483,9 +483,8 @@ packet_t ax25_from_text (char *monitor, int strict)
483
483
return (NULL );
484
484
}
485
485
486
- ax25_set_addr (this_p , AX25_SOURCE , pa );
486
+ ax25_set_addr (this_p , AX25_SOURCE , atemp );
487
487
ax25_set_h (this_p , AX25_SOURCE ); // c/r in this position
488
-
489
488
ax25_set_ssid (this_p , AX25_SOURCE , ssid_temp );
490
489
491
490
/*
@@ -507,9 +506,8 @@ packet_t ax25_from_text (char *monitor, int strict)
507
506
return (NULL );
508
507
}
509
508
510
- ax25_set_addr (this_p , AX25_DESTINATION , pa );
509
+ ax25_set_addr (this_p , AX25_DESTINATION , atemp );
511
510
ax25_set_h (this_p , AX25_DESTINATION ); // c/r in this position
512
-
513
511
ax25_set_ssid (this_p , AX25_DESTINATION , ssid_temp );
514
512
515
513
/*
@@ -522,17 +520,14 @@ packet_t ax25_from_text (char *monitor, int strict)
522
520
523
521
k = this_p -> num_addr ;
524
522
525
- // JWL 10:38 this_p->num_addr++;
526
-
527
523
if ( ! ax25_parse_addr (k , pa , strict , atemp , & ssid_temp , & heard_temp )) {
528
524
text_color_set (DW_COLOR_ERROR );
529
525
dw_printf ("Failed to create packet from text. Bad digipeater address\n" );
530
526
ax25_delete (this_p );
531
527
return (NULL );
532
528
}
533
529
534
- ax25_set_addr (this_p , k , pa );
535
-
530
+ ax25_set_addr (this_p , k , atemp );
536
531
ax25_set_ssid (this_p , k , ssid_temp );
537
532
538
533
// Does it have an "*" at the end?
@@ -934,7 +929,6 @@ void ax25_set_addr (packet_t this_p, int n, char *ad)
934
929
assert (this_p -> magic1 == MAGIC );
935
930
assert (this_p -> magic2 == MAGIC );
936
931
assert (n >= 0 && n < AX25_MAX_ADDRS );
937
- assert (strlen (ad ) < AX25_MAX_ADDR_LEN );
938
932
939
933
//dw_printf ("ax25_set_addr (%d, %s) num_addr=%d\n", n, ad, this_p->num_addr);
940
934
@@ -944,6 +938,11 @@ void ax25_set_addr (packet_t this_p, int n, char *ad)
944
938
/*
945
939
* Set existing address position.
946
940
*/
941
+
942
+ // Why aren't we setting 'strict' here?
943
+ // Messages from IGate have q-constructs.
944
+ // We use this to parse it and later remove unwanted parts.
945
+
947
946
ax25_parse_addr (n , ad , 0 , atemp , & ssid_temp , & heard_temp );
948
947
949
948
memset (this_p -> frame_data + n * 7 , ' ' << 1 , 6 );
@@ -1011,7 +1010,6 @@ void ax25_insert_addr (packet_t this_p, int n, char *ad)
1011
1010
assert (this_p -> magic1 == MAGIC );
1012
1011
assert (this_p -> magic2 == MAGIC );
1013
1012
assert (n >= AX25_REPEATER_1 && n < AX25_MAX_ADDRS );
1014
- assert (strlen (ad ) < AX25_MAX_ADDR_LEN );
1015
1013
1016
1014
//dw_printf ("ax25_insert_addr (%d, %s)\n", n, ad);
1017
1015
@@ -1770,11 +1768,12 @@ int ax25_pack (packet_t this_p, unsigned char result[AX25_MAX_PACKET_LEN])
1770
1768
*------------------------------------------------------------------*/
1771
1769
1772
1770
// TODO: need someway to ensure caller allocated enough space.
1773
- #define DESC_SIZ 16
1771
+ #define DESC_SIZ 32
1774
1772
1775
1773
ax25_frame_type_t ax25_frame_type (packet_t this_p , ax25_modulo_t modulo , char * desc , int * pf , int * nr , int * ns )
1776
1774
{
1777
- int c ;
1775
+ int c ; // U frames are always one control byte.
1776
+ int c2 ; // I & S frames can have second Control byte.
1778
1777
1779
1778
assert (this_p -> magic1 == MAGIC );
1780
1779
assert (this_p -> magic2 == MAGIC );
@@ -1789,13 +1788,16 @@ ax25_frame_type_t ax25_frame_type (packet_t this_p, ax25_modulo_t modulo, char *
1789
1788
strlcpy (desc , "Not AX.25" , DESC_SIZ );
1790
1789
return (frame_not_AX25 );
1791
1790
}
1791
+ if (modulo == modulo_128 ) {
1792
+ c2 = ax25_get_c2 (this_p );
1793
+ }
1794
+
1792
1795
1793
1796
if ((c & 1 ) == 0 ) {
1794
1797
1795
- // Information
1798
+ // Information rrr p sss 0 or sssssss 0 rrrrrrr p
1796
1799
1797
1800
if (modulo == modulo_128 ) {
1798
- int c2 = ax25_get_c2 (this_p );
1799
1801
* ns = (c >> 1 ) & 0x7f ;
1800
1802
* pf = c2 & 1 ;
1801
1803
* nr = (c2 >> 1 ) & 0x7f ;
@@ -1805,15 +1807,14 @@ ax25_frame_type_t ax25_frame_type (packet_t this_p, ax25_modulo_t modulo, char *
1805
1807
* pf = (c >> 4 ) & 1 ;
1806
1808
* nr = (c >> 5 ) & 7 ;
1807
1809
}
1808
- strlcpy (desc , "I frame" , DESC_SIZ );
1810
+ snprintf (desc , DESC_SIZ , "I frame, n(s)= %d, n(r)=%d, p=%d " , * ns , * nr , * pf );
1809
1811
return (frame_type_I );
1810
1812
}
1811
1813
else if ((c & 2 ) == 0 ) {
1812
1814
1813
- // Supervisory
1815
+ // Supervisory rrr p/f ss 0 1 or 0000 ss 0 1 rrrrrrr p/f
1814
1816
1815
1817
if (modulo == modulo_128 ) {
1816
- int c2 = ax25_get_c2 (this_p );
1817
1818
* pf = c2 & 1 ;
1818
1819
* nr = (c2 >> 1 ) & 0x7f ;
1819
1820
}
@@ -1823,35 +1824,35 @@ ax25_frame_type_t ax25_frame_type (packet_t this_p, ax25_modulo_t modulo, char *
1823
1824
}
1824
1825
1825
1826
switch ((c >> 2 ) & 3 ) {
1826
- case 0 : strlcpy (desc , "S frame RR" , DESC_SIZ ); return (frame_type_RR ); break ;
1827
- case 1 : strlcpy (desc , "S frame RNR" , DESC_SIZ ); return (frame_type_RNR ); break ;
1828
- case 2 : strlcpy (desc , "S frame REJ" , DESC_SIZ ); return (frame_type_REJ ); break ;
1829
- case 3 : strlcpy (desc , "S frame SREJ" , DESC_SIZ ); return (frame_type_SREJ ); break ;
1827
+ case 0 : snprintf (desc , DESC_SIZ , "S frame RR, n(r)=%d, p/f=%d " , * nr , * pf ); return (frame_type_S_RR ); break ;
1828
+ case 1 : snprintf (desc , DESC_SIZ , "S frame RNR, n(r)=%d, p/f=%d " , * nr , * pf ); return (frame_type_S_RNR ); break ;
1829
+ case 2 : snprintf (desc , DESC_SIZ , "S frame REJ, n(r)=%d, p/f=%d " , * nr , * pf ); return (frame_type_S_REJ ); break ;
1830
+ case 3 : snprintf (desc , DESC_SIZ , "S frame SREJ, n(r)=%d, p/f=%d " , * nr , * pf ); return (frame_type_S_SREJ ); break ;
1830
1831
}
1831
1832
}
1832
1833
else {
1833
1834
1834
- // Unnumbered
1835
+ // Unnumbered mmm p/f mm 1 1
1835
1836
1836
1837
* pf = (c >> 4 ) & 1 ;
1837
1838
1838
1839
switch (c & 0xef ) {
1839
1840
1840
- case 0x6f : strlcpy (desc , "U frame SABME" , DESC_SIZ ); return (frame_type_SABME ); break ;
1841
- case 0x2f : strlcpy (desc , "U frame SABM" , DESC_SIZ ); return (frame_type_SABM ); break ;
1842
- case 0x43 : strlcpy (desc , "U frame DISC" , DESC_SIZ ); return (frame_type_DISC ); break ;
1843
- case 0x0f : strlcpy (desc , "U frame DM" , DESC_SIZ ); return (frame_type_DM ); break ;
1844
- case 0x63 : strlcpy (desc , "U frame UA" , DESC_SIZ ); return (frame_type_UA ); break ;
1845
- case 0x87 : strlcpy (desc , "U frame FRMR" , DESC_SIZ ); return (frame_type_FRMR ); break ;
1846
- case 0x03 : strlcpy (desc , "U frame UI" , DESC_SIZ ); return (frame_type_UI ); break ;
1847
- case 0xaf : strlcpy (desc , "U frame XID" , DESC_SIZ ); return (frame_type_XID ); break ;
1848
- case 0xe3 : strlcpy (desc , "U frame TEST" , DESC_SIZ ); return (frame_type_TEST ); break ;
1849
- default : strlcpy (desc , "U frame ???" , DESC_SIZ ); return (frame_type_U ); break ;
1841
+ case 0x6f : snprintf (desc , DESC_SIZ , "U frame SABME, p=%d " , * pf ); return (frame_type_U_SABME ); break ;
1842
+ case 0x2f : snprintf (desc , DESC_SIZ , "U frame SABM, p=%d " , * pf ); return (frame_type_U_SABM ); break ;
1843
+ case 0x43 : snprintf (desc , DESC_SIZ , "U frame DISC, p=%d " , * pf ); return (frame_type_U_DISC ); break ;
1844
+ case 0x0f : snprintf (desc , DESC_SIZ , "U frame DM, f=%d " , * pf ); return (frame_type_U_DM ); break ;
1845
+ case 0x63 : snprintf (desc , DESC_SIZ , "U frame UA, f=%d " , * pf ); return (frame_type_U_UA ); break ;
1846
+ case 0x87 : snprintf (desc , DESC_SIZ , "U frame FRMR, f=%d " , * pf ); return (frame_type_U_FRMR ); break ;
1847
+ case 0x03 : snprintf (desc , DESC_SIZ , "U frame UI, pf=%d " , * pf ); return (frame_type_U_UI ); break ;
1848
+ case 0xaf : snprintf (desc , DESC_SIZ , "U frame XID, pf=%d " , * pf ); return (frame_type_U_XID ); break ;
1849
+ case 0xe3 : snprintf (desc , DESC_SIZ , "U frame TEST, pf=%d " , * pf ); return (frame_type_U_TEST ); break ;
1850
+ default : snprintf (desc , DESC_SIZ , "U frame ???" ); return (frame_type_U ); break ;
1850
1851
}
1851
1852
}
1852
1853
1853
1854
// Should be unreachable but compiler doesn't realize that.
1854
- // Suppress "warning: control reaches end of non-void function"
1855
+ // Here only to suppress "warning: control reaches end of non-void function"
1855
1856
1856
1857
return (frame_not_AX25 );
1857
1858
0 commit comments