Commit a797d9bb authored by Manolis Surligas's avatar Manolis Surligas

Use AX.25 address field to reduce false alarms

parent 71caec1e
......@@ -122,7 +122,7 @@ namespace gr
*out++ = ((0b1111 & dest_ssid) << 1) | 0b01100000;
for (i = 0; i < src_addr.length (); i++) {
*out++ = dest_addr[i] << 1;
*out++ = src_addr[i] << 1;
}
for (; i < AX25_CALLSIGN_MAX_LEN; i++) {
*out++ = ' ' << 1;
......@@ -131,7 +131,7 @@ namespace gr
* the trailing bit is set to 1.
* /
/* FIXME: C bit is set to 0 implicitly */
*out++ = ((0b1111 & dest_ssid) << 1) | 0b01100001;
*out++ = ((0b1111 & src_ssid) << 1) | 0b01100001;
return AX25_MIN_ADDR_LEN;
}
......
......@@ -133,6 +133,11 @@ namespace gr
else{
d_decoded_bits++;
if(d_decoded_bits == 8) {
/* Check if the received byte is valid */
if(!check_byte()) {
reset_state ();
return i + 1;
}
d_frame_buffer[d_received_bytes] = d_dec_b;
d_received_bytes++;
d_decoded_bits = 0;
......@@ -226,6 +231,11 @@ namespace gr
else {
d_decoded_bits++;
if (d_decoded_bits == 8) {
/* Check if the received byte is valid */
if(!check_byte()) {
reset_state ();
return i + 1;
}
d_frame_buffer[d_received_bytes] = d_dec_b;
d_received_bytes++;
d_decoded_bits = 0;
......@@ -338,8 +348,6 @@ namespace gr
/* First check if the size of the frame is valid */
if (d_received_bytes < AX25_MIN_ADDR_LEN + sizeof(uint16_t)) {
message_port_pub (pmt::mp ("failed_pdu"),
pmt::make_blob (d_frame_buffer, d_received_bytes));
d_dec_b = 0x0;
d_shift_reg = 0x0;
d_decoded_bits = 0;
......@@ -417,6 +425,30 @@ namespace gr
d_dec_b = (d_dec_b >> 1) | (dec_bit << 7);
}
/**
* Checks if a AX.25 decoded byte is valid. This actually can be checked
* only in the address field, where all fields should have the LS bit
* set to zero.
* @returns true if the decoded byte is valid, false otherwise
*/
inline bool
ax25_decoder_bm_impl::check_byte ()
{
if(d_received_bytes < AX25_MIN_ADDR_LEN - 1) {
if(d_dec_b & 0x1) {
return false;
}
}
else if(d_received_bytes == AX25_MIN_ADDR_LEN - 1) {
if(d_dec_b & 0x1) {
return true;
}
return false;
}
return true;
}
int
ax25_decoder_bm_impl::work (int noutput_items,
gr_vector_const_void_star &input_items,
......
......@@ -72,6 +72,8 @@ namespace gr
descramble_and_decode_1b (uint8_t in);
inline void
decode_1b (uint8_t in);
inline bool
check_byte ();
public:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment