clatd: introduce MAXDUMPLEN

PACKETLEN is a bad name, let's try to move away from it

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I56e890d479bc64ed6c31a29772a370f0e83a2ff9
This commit is contained in:
Maciej Żenczykowski 2023-01-30 22:29:59 +00:00
commit bea3f7f981
2 changed files with 6 additions and 2 deletions

View file

@ -43,6 +43,10 @@ struct tun_data;
// ie. if we ever read >= MAXMTU bytes we should discard.
#define MAXMTU (0xFFFF + 28 + 1)
#define PACKETLEN (sizeof(struct tun_pi) + MAXMTU)
// logcat_hexdump() maximum binary data length
#define MAXDUMPLEN PACKETLEN
#define CLATD_VERSION "1.5"
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))

4
dump.c
View file

@ -226,11 +226,11 @@ void dump_tcp6(const struct tcphdr *tcp, const struct ip6_hdr *ip6, const uint8_
/* generic hex dump */
void logcat_hexdump(const char *info, const uint8_t *data, size_t len) {
char output[PACKETLEN * 3 + 2];
char output[MAXDUMPLEN * 3 + 2];
size_t i;
output[0] = '\0';
for (i = 0; i < len && i < PACKETLEN; i++) {
for (i = 0; i < len && i < MAXDUMPLEN; i++) {
snprintf(output + i * 3, 4, " %02x", data[i]);
}
output[len * 3 + 3] = '\0';