Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change: boreas. Use sequence number 1. #813

Merged
merged 2 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .docker/prod-testing.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RUN apt-get update && \
libgnutls30 \
libuuid1 \
libssh-gcrypt-4 \
libhiredis0.14 \
libhiredis1.1.0 \
libhiredis-dev \
libxml2 \
libpcap0.8 \
Expand Down
16 changes: 14 additions & 2 deletions boreas/ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ struct pseudohdr
struct tcphdr tcpheader;
};

// Return a random uint16 avoiding the 0.
static uint16_t
get_echo_id (void)
{
uint16_t upper_bound = 65534;
uint16_t lower_bound = 1;

return rand () % (upper_bound - lower_bound + 1) + lower_bound;
}

/**
* @brief Get the size of the socket send buffer.
*
Expand Down Expand Up @@ -144,8 +154,8 @@ send_icmp_v6 (int soc, struct in6_addr *dst, int type)
icmp6 = (struct icmp6_hdr *) sendbuf;
icmp6->icmp6_type = type; /* ND_NEIGHBOR_SOLICIT or ICMP6_ECHO_REQUEST */
icmp6->icmp6_code = 0;
icmp6->icmp6_id = 234;
icmp6->icmp6_seq = 0;
icmp6->icmp6_id = get_echo_id ();
icmp6->icmp6_seq = 0x0100;

memset ((icmp6 + 1), 0xa5, datalen);
gettimeofday ((struct timeval *) (icmp6 + 1), NULL); // only for testing
Expand Down Expand Up @@ -197,6 +207,8 @@ send_icmp_v4 (int soc, struct in_addr *dst)
icmp = (struct icmphdr *) sendbuf;
icmp->type = ICMP_ECHO;
icmp->code = 0;
icmp->un.echo.id = get_echo_id ();
icmp->un.echo.sequence = 0x0100;
ArnoStiefvater marked this conversation as resolved.
Show resolved Hide resolved

len = 8 + datalen;
icmp->checksum = 0;
Expand Down
Loading