layer2/packet_structs: use variable to reduce duplication

This commit is contained in:
Simon Ruderich 2024-07-23 09:15:56 +02:00
parent b3a49fe0ba
commit 766caf7e07

View file

@ -94,28 +94,31 @@ void layer2_dump_packet_header(int level, const layer2_packet_header_t *header)
LOG(level, " TX Seq. Nr: %2u", header->tx_seq_nr);
ham64_addr_type_t addr_type;
const char* addr_type_string;
char addr_buf[HAM64_FMT_MAX_LEN];
addr_type = ham64_get_addr_type(&header->src_addr);
addr_type_string = ham64_addr_type_to_string(addr_type);
ham64_format(&header->src_addr, addr_buf);
if(addr_type == HAM64_ADDR_TYPE_CALLSIGN) {
char callsign[13];
ham64_decode_callsign(&header->src_addr, callsign);
LOG(level, " Source Address: %s [%s] -> %s", addr_buf, ham64_addr_type_to_string(addr_type), callsign);
LOG(level, " Source Address: %s [%s] -> %s", addr_buf, addr_type_string, callsign);
} else {
LOG(level, " Source Address: %s [%s]", addr_buf, ham64_addr_type_to_string(addr_type));
LOG(level, " Source Address: %s [%s]", addr_buf, addr_type_string);
}
addr_type = ham64_get_addr_type(&header->dst_addr);
addr_type_string = ham64_addr_type_to_string(addr_type);
ham64_format(&header->dst_addr, addr_buf);
if(addr_type == HAM64_ADDR_TYPE_CALLSIGN) {
char callsign[13];
ham64_decode_callsign(&header->dst_addr, callsign);
LOG(level, " Dest. Address: %s [%s] -> %s", addr_buf, ham64_addr_type_to_string(addr_type), callsign);
LOG(level, " Dest. Address: %s [%s] -> %s", addr_buf, addr_type_string, callsign);
} else {
LOG(level, " Dest. Address: %s [%s]", addr_buf, ham64_addr_type_to_string(addr_type));
LOG(level, " Dest. Address: %s [%s]", addr_buf, addr_type_string);
}
}