Improve bad packet handling. Was consuming all output buffers.

pull/4/head
CInsights 2018-03-07 18:30:51 +11:00
rodzic e44dc2eb84
commit 5ad245387a
3 zmienionych plików z 26 dodań i 21 usunięć

Wyświetl plik

@ -169,17 +169,18 @@ void aprs_debug_getPacket(packet_t pp, char* buf, uint32_t len)
char rec[256];
unsigned char *pinfo;
ax25_format_addrs(pp, rec);
ax25_get_info(pp, &pinfo);
if(ax25_get_info(pp, &pinfo) == 0)
return;
// Print decoded packet
uint32_t out = chsnprintf(buf, len, "%s", rec);
for(uint32_t i=0; pinfo[i]; i++) {
if(pinfo[i] < 32 || pinfo[i] > 126) {
out += chsnprintf(&buf[out], len-out, "<0x%02x>", pinfo[i]);
} else {
out += chsnprintf(&buf[out], len-out, "%c", pinfo[i]);
}
}
// Print decoded packet
uint32_t out = chsnprintf(buf, len, "%s", rec);
for(uint32_t i=0; pinfo[i]; i++) {
if(pinfo[i] < 32 || pinfo[i] > 126) {
out += chsnprintf(&buf[out], len-out, "<0x%02x>", pinfo[i]);
} else {
out += chsnprintf(&buf[out], len-out, "%c", pinfo[i]);
}
}
}
/**
@ -308,7 +309,8 @@ static bool aprs_decode_message(packet_t pp)
// Get Info field
char src[256];
unsigned char *pinfo;
ax25_get_info(pp, &pinfo);
if(ax25_get_info(pp, &pinfo) == 0)
return false;
ax25_format_addrs(pp, src);
// Decode destination callsign
@ -570,7 +572,8 @@ void aprs_decode_packet(packet_t pp)
// Decode message packets
bool digipeat = true;
unsigned char *pinfo;
ax25_get_info(pp, &pinfo);
if(ax25_get_info(pp, &pinfo) == 0)
return;
if(pinfo[0] == ':') digipeat = aprs_decode_message(pp); // ax25_get_dti(pp)
// Digipeat packet

Wyświetl plik

@ -891,7 +891,8 @@ packet_t ax25_unwrap_third_party (packet_t from_pp)
return (NULL);
}
(void) ax25_get_info (from_pp, &info_p);
if(ax25_get_info(from_pp, &info_p) == 0)
return NULL;
// Want strict because addresses should conform to AX.25 here.
// That's not the case for something from an Internet Server.
@ -1587,11 +1588,11 @@ int ax25_get_rr (packet_t this_p, int n)
*
* Returns: Number of octets in the Information part.
* Should be in the range of AX25_MIN_INFO_LEN .. AX25_MAX_INFO_LEN.
* Returns 0 for malformed packet or buffer overflow.
*
*------------------------------------------------------------------------------*/
int ax25_get_info (packet_t this_p, unsigned char **paddr)
{
int ax25_get_info (packet_t this_p, unsigned char **paddr) {
unsigned char *info_ptr;
int info_len;
@ -1619,7 +1620,6 @@ int ax25_get_info (packet_t this_p, unsigned char **paddr)
if(!info_len) {
TRACE_ERROR("No data in packet");
return 0;
}
info_ptr[info_len] = '\0';
@ -1661,7 +1661,8 @@ int ax25_cut_at_crlf (packet_t this_p)
return 0;
}
info_len = ax25_get_info (this_p, &info_ptr);
if((info_len = ax25_get_info (this_p, &info_ptr)) == 0)
return 0;
// Can't use strchr because there is potential of nul character.
@ -2388,7 +2389,8 @@ unsigned short ax25_dedupe_crc (packet_t pp)
ax25_get_addr_with_ssid(pp, AX25_SOURCE, src);
ax25_get_addr_with_ssid(pp, AX25_DESTINATION, dest);
info_len = ax25_get_info (pp, &pinfo);
if((info_len = ax25_get_info (pp, &pinfo)) == 0)
return 0;
while (info_len >= 1 && (pinfo[info_len-1] == '\r' ||
pinfo[info_len-1] == '\n' ||

Wyświetl plik

@ -23,11 +23,11 @@ static void handlePacket(uint8_t *buf, uint32_t len) {
if(pp->num_addr > 0) {
aprs_decode_packet(pp);
} else {
TRACE_DEBUG("RX > No addresses in packet");
TRACE_DEBUG("RX > No addresses in packet - dropped");
}
ax25_delete(pp);
} else {
TRACE_DEBUG("RX > Error in packet");
TRACE_DEBUG("RX > Error in packet - dropped");
}
return;
}
@ -73,7 +73,7 @@ bool transmitOnRadio(packet_t pp, uint32_t freq, uint16_t step, uint8_t chan,
return false;
}
uint32_t op_freq = Si446x_computeOperatingFrequency(chan, RADIO_TX);
TRACE_INFO( "RAD > Transmit %d.%03d MHz (ch %d), Pwr %d, %s, %d byte",
TRACE_INFO( "RAD > Transmit packet on %d.%03d MHz (ch %d), Pwr %d, %s, %d byte",
op_freq/1000000, (op_freq%1000000)/1000, Si446x_getChannel(),
pwr, getModulation(mod), len
);