Skip to content

Commit

Permalink
Fix echo ID consistency for ECHO replies
Browse files Browse the repository at this point in the history
  • Loading branch information
emanuele-f committed Jun 30, 2021
1 parent 61aa2bc commit 6fadd10
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions zdtun.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,8 +872,15 @@ int zdtun_parse_pkt(const char *_pkt_buf, uint16_t pkt_len, zdtun_pkt_t *pkt) {
}

pkt->l4_hdr_len = sizeof(struct icmphdr);
pkt->tuple.echo_id = data->un.echo.id;
pkt->tuple.dst_port = 0;

// NOTE: echo ID in the source port is the same convention used by linux for ICMP connections
if(data->type == ICMP_ECHO) {
pkt->tuple.echo_id = data->un.echo.id;
pkt->tuple.dst_port = 0;
} else {
pkt->tuple.echo_id = 0;
pkt->tuple.dst_port = data->un.echo.id;
}
} else {
debug("Packet with unknown protocol: %u", ipproto);
return -3;
Expand Down

0 comments on commit 6fadd10

Please sign in to comment.