Skip to content
This repository was archived by the owner on Aug 3, 2021. It is now read-only.

Commit a09cba5

Browse files
author
David Gatti
committed
Profing
1 parent ec02d0f commit a09cba5

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

C/pingWithStructResponse.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,25 @@ int main() {
3838
icmp_hdr_t pckt;
3939

4040
//
41-
// 4. Set the apropriate values to our struct, which is our ICMP header
41+
// 4. Set the appropriate values to our struct, which is our ICMP header
4242
//
4343
pckt.type = 8; // The echo request is 8
4444
pckt.code = 0; // No need
45-
pckt.chksum = 0xfff7; // Fixed checksume since the data is not changing
45+
pckt.chksum = 0xfff7; // Fixed checksum since the data is not changing
4646
pckt.data = 0; // We don't send anything.
4747

4848
//
49-
// 5. Creatign a IP Header from a struct that exists in another library
50-
//
49+
// 5. Creating a IP Header from a struct that exists in another library
50+
//
5151
struct sockaddr_in addr;
5252
addr.sin_family = AF_INET;
5353
addr.sin_port = 0;
5454
addr.sin_addr.s_addr = inet_addr("8.8.8.8");
5555

5656
//
57-
// 6. Send our PING
57+
// 6. Send our PING
5858
//
59-
int actionSendResult = sendto(s, &pckt, sizeof(pckt),
59+
int actionSendResult = sendto(s, &pckt, sizeof(pckt),
6060
0, (struct sockaddr*)&addr, sizeof(addr));
6161

6262
//
@@ -69,15 +69,15 @@ int main() {
6969
}
7070

7171
//
72-
// 7. Prepare all the necesary variable to handle the response
72+
// 7. Prepare all the necessary variable to handle the response
7373
//
7474
unsigned int resAddressSize;
7575
unsigned char res[30] = "";
7676
struct sockaddr resAddress;
7777

78-
//
78+
//
7979
// 8. Creating the struct to better handle the response
80-
//
80+
//
8181
typedef struct {
8282
uint8_t type;
8383
uint8_t code;
@@ -89,27 +89,27 @@ int main() {
8989
//
9090
// 9. Read the response from the remote host
9191
//
92-
int ressponse = recvfrom(s, res, sizeof(res), 0, &resAddress,
92+
int ressponse = recvfrom(s, res, sizeof(res), 0, &resAddress,
9393
&resAddressSize);
9494

9595
//
96-
// -> Display the response by accessign the struct
96+
// -> Display the response by accessing the struct
9797
//
9898
if(ressponse > 0)
9999
{
100-
//
101-
// 10. Create the response variable usign our custom struct
102-
//
100+
//
101+
// 10. Create the response variable using our custom struct
102+
//
103103
icmp_response_t* echo_response;
104104

105105
//
106-
// 11. Map our resposne to our response struct starting from byte 20
106+
// 11. Map our response to our response struct starting from byte 20
107107
//
108108
echo_response = (icmp_response_t *)&res[20];
109109

110-
//
111-
// -> Log the data that we'v got back
112-
//
110+
//
111+
// -> Log the data that we've got back
112+
//
113113
printf(
114114
"type: %x, code: %x, checksum: %x, identifier: %x, sequence: %x\n",
115115
echo_response->type,
@@ -120,8 +120,8 @@ int main() {
120120
);
121121

122122
exit(0);
123-
}
124-
else
123+
}
124+
else
125125
{
126126
perror("Response Error");
127127
exit(0);

0 commit comments

Comments
 (0)