Skip to content

Commit f0a4a4e

Browse files
committed
Merge branch 'feat/net_debug_add_ip' into 'master'
tools: Added ip print in net debug mode See merge request application/esp-at!1915
2 parents bd128f8 + 86c3120 commit f0a4a4e

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

tools/at_net_debug.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ def ESP_LOGE(x):
1717
#include "esp_log.h"
1818
#include "sdkconfig.h"
1919
20+
#define IPSTR_TX " (%d.%d.%d.%d > %d.%d.%d.%d)"
21+
#define IPSTR_RX " (%d.%d.%d.%d < %d.%d.%d.%d)"
22+
#define IP2STR_VAL(local,remote) (local)[0], (local)[1], (local)[2], (local)[3], (remote)[0], (remote)[1], (remote)[2], (remote)[3]
23+
2024
/* IPv4+ protocol check */
2125
typedef enum {
2226
IP4_PROTO_ICMP = 1,
@@ -103,6 +107,9 @@ def ESP_LOGE(x):
103107
uint16_t ip_hlen = (*ip4 & 0x0F) * 4;
104108
uint16_t ip_dlen = ip_tlen - ip_hlen;
105109
110+
uint8_t *src_ip = (ip4 + 12);
111+
uint8_t *dst_ip = (ip4 + 16);
112+
106113
switch (ip_proto) {
107114
108115
#if CONFIG_AT_NET_TCP_DEBUG
@@ -124,9 +131,9 @@ def ESP_LOGE(x):
124131
}
125132
126133
if (tx) {
127-
ESP_LOGI("@@tcp-tx", "IPL:%u, S:%u, A:%u, SP:%u, DP:%u, F:0x%x, TDL:%u", ip_tlen, seq, ack, src_port, dst_port, flags, tcp_dlen);
134+
ESP_LOGI("@@tcp-tx", "IPL:%u, S:%u, A:%u, SP:%u, DP:%u, F:0x%x, TDL:%u" IPSTR_TX, ip_tlen, seq, ack, src_port, dst_port, flags, tcp_dlen, IP2STR_VAL(src_ip,dst_ip));
128135
} else {
129-
ESP_LOGI("@@tcp-rx", "IPL:%u, S:%u, A:%u, SP:%u, DP:%u, F:0x%x, TDL:%u", ip_tlen, seq, ack, src_port, dst_port, flags, tcp_dlen);
136+
ESP_LOGI("@@tcp-rx", "IPL:%u, S:%u, A:%u, SP:%u, DP:%u, F:0x%x, TDL:%u" IPSTR_RX, ip_tlen, seq, ack, src_port, dst_port, flags, tcp_dlen, IP2STR_VAL(dst_ip,src_ip));
130137
}
131138
}
132139
break;
@@ -147,9 +154,9 @@ def ESP_LOGE(x):
147154
}
148155
149156
if (tx) {
150-
ESP_LOGI("udp-tx", "IPL:%u, SP:%u, DP:%u, UDL:%u", ip_tlen, src_port, dst_port, udp_dlen);
157+
ESP_LOGI("udp-tx", "IPL:%u, SP:%u, DP:%u, UDL:%u" IPSTR_TX, ip_tlen, src_port, dst_port, udp_dlen, IP2STR_VAL(src_ip,dst_ip));
151158
} else {
152-
ESP_LOGI("udp-rx", "IPL:%u, SP:%u, DP:%u, UDL:%u", ip_tlen, src_port, dst_port, udp_dlen);
159+
ESP_LOGI("udp-rx", "IPL:%u, SP:%u, DP:%u, UDL:%u" IPSTR_RX, ip_tlen, src_port, dst_port, udp_dlen, IP2STR_VAL(dst_ip,src_ip));
153160
}
154161
}
155162
break;
@@ -172,9 +179,9 @@ def ESP_LOGE(x):
172179
uint16_t id = *(icmp + 4); id <<= 8; id += *(icmp + 5);
173180
uint16_t seq = *(icmp + 6); seq <<= 8; seq += *(icmp + 7);
174181
if (tx) {
175-
ESP_LOGI("icmp-tx", "%s, IPL:%u, ID:0x%x, S:%u PDL:%u", (type == 8) ? "Echo" : "Echo Reply", ip_tlen, id, seq, icmp_dlen);
182+
ESP_LOGI("icmp-tx", "%s, IPL:%u, ID:0x%x, S:%u PDL:%u" IPSTR_TX, (type == 8) ? "Echo" : "Echo Reply", ip_tlen, id, seq, icmp_dlen, IP2STR_VAL(src_ip,dst_ip));
176183
} else {
177-
ESP_LOGI("icmp-rx", "%s, IPL:%u, ID:0x%x, S:%u PDL:%u", (type == 8) ? "Echo" : "Echo Reply", ip_tlen, id, seq, icmp_dlen);
184+
ESP_LOGI("icmp-rx", "%s, IPL:%u, ID:0x%x, S:%u PDL:%u" IPSTR_RX, (type == 8) ? "Echo" : "Echo Reply", ip_tlen, id, seq, icmp_dlen, IP2STR_VAL(dst_ip,src_ip));
178185
}
179186
}
180187
break;

0 commit comments

Comments
 (0)