Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8094f71

Browse filesBrowse files
committed
lwIpWrapper: CNetIf make recv_callback_data a static data structure
This ensure access to existing data if icmp callback is fired after ping timeout
1 parent 7f6ad1e commit 8094f71
Copy full SHA for 8094f71

File tree

Expand file treeCollapse file tree

1 file changed

+8
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-3
lines changed

‎libraries/lwIpWrapper/src/CNetIf.cpp

Copy file name to clipboardExpand all lines: libraries/lwIpWrapper/src/CNetIf.cpp
+8-3Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ static u8_t icmp_receive_callback(void *arg, struct raw_pcb *pcb, struct pbuf *p
4343
request->endMillis = millis();
4444
pbuf_free(p);
4545
return 1; /* consume the packet */
46-
4746
}
4847

4948
ip_addr_t* u8_to_ip_addr(uint8_t* ipu8, ip_addr_t* ipaddr)
@@ -159,9 +158,15 @@ int CLwipIf::ping(IPAddress ip, uint8_t ttl)
159158
(void)ttl;
160159
ip_addr_t addr;
161160
addr.addr = ip;
162-
recv_callback_data requestCbkData = { 0, 0, (uint16_t)random(0xffff) };
163161

164-
//Create a raw socket
162+
/* ICMP ping callback data structure */
163+
static recv_callback_data requestCbkData;
164+
165+
/* initialize callback data for a new request */
166+
memset(&requestCbkData, 0, sizeof(recv_callback_data));
167+
requestCbkData.seqNum = (uint16_t)random(0xffff);
168+
169+
/* Create a raw socket */
165170
struct raw_pcb* s = raw_new(IP_PROTO_ICMP);
166171
if (!s) {
167172
return -1;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.