@@ -38,25 +38,25 @@ int main() {
38
38
icmp_hdr_t pckt ;
39
39
40
40
//
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
42
42
//
43
43
pckt .type = 8 ; // The echo request is 8
44
44
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
46
46
pckt .data = 0 ; // We don't send anything.
47
47
48
48
//
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
+ //
51
51
struct sockaddr_in addr ;
52
52
addr .sin_family = AF_INET ;
53
53
addr .sin_port = 0 ;
54
54
addr .sin_addr .s_addr = inet_addr ("8.8.8.8" );
55
55
56
56
//
57
- // 6. Send our PING
57
+ // 6. Send our PING
58
58
//
59
- int actionSendResult = sendto (s , & pckt , sizeof (pckt ),
59
+ int actionSendResult = sendto (s , & pckt , sizeof (pckt ),
60
60
0 , (struct sockaddr * )& addr , sizeof (addr ));
61
61
62
62
//
@@ -69,15 +69,15 @@ int main() {
69
69
}
70
70
71
71
//
72
- // 7. Prepare all the necesary variable to handle the response
72
+ // 7. Prepare all the necessary variable to handle the response
73
73
//
74
74
unsigned int resAddressSize ;
75
75
unsigned char res [30 ] = "" ;
76
76
struct sockaddr resAddress ;
77
77
78
- //
78
+ //
79
79
// 8. Creating the struct to better handle the response
80
- //
80
+ //
81
81
typedef struct {
82
82
uint8_t type ;
83
83
uint8_t code ;
@@ -89,27 +89,27 @@ int main() {
89
89
//
90
90
// 9. Read the response from the remote host
91
91
//
92
- int ressponse = recvfrom (s , res , sizeof (res ), 0 , & resAddress ,
92
+ int ressponse = recvfrom (s , res , sizeof (res ), 0 , & resAddress ,
93
93
& resAddressSize );
94
94
95
95
//
96
- // -> Display the response by accessign the struct
96
+ // -> Display the response by accessing the struct
97
97
//
98
98
if (ressponse > 0 )
99
99
{
100
- //
101
- // 10. Create the response variable usign our custom struct
102
- //
100
+ //
101
+ // 10. Create the response variable using our custom struct
102
+ //
103
103
icmp_response_t * echo_response ;
104
104
105
105
//
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
107
107
//
108
108
echo_response = (icmp_response_t * )& res [20 ];
109
109
110
- //
111
- // -> Log the data that we'v got back
112
- //
110
+ //
111
+ // -> Log the data that we've got back
112
+ //
113
113
printf (
114
114
"type: %x, code: %x, checksum: %x, identifier: %x, sequence: %x\n" ,
115
115
echo_response -> type ,
@@ -120,8 +120,8 @@ int main() {
120
120
);
121
121
122
122
exit (0 );
123
- }
124
- else
123
+ }
124
+ else
125
125
{
126
126
perror ("Response Error" );
127
127
exit (0 );
0 commit comments