forked from DhavalKapil/icmptunnel
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathicmp.h
59 lines (48 loc) · 1020 Bytes
/
icmp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* icmp.h
*/
#ifndef icmp_guard
#define icmp_guard
// Maximum transmission unit
#define MTU 1472
#include <stdint.h>
struct icmp_packet
{
char src_addr[100];
char dest_addr[100];
int type;
char *payload;
int payload_size;
uint16_t id;
uint16_t seq;
};
/**
* Function to set packet type as ECHO
*/
void set_echo_type(struct icmp_packet *packet);
/**
* Function to set packet type as REPLY
*/
void set_reply_type(struct icmp_packet *packet);
/**
* Function to open a socket for icmp
*/
int open_icmp_socket();
/**
* Function to bind the socket to INADDR_ANY
*/
void bind_icmp_socket(int sock_fd);
/**
* Function to send ICMP Packet
*/
void send_icmp_packet(int sock_fd, struct icmp_packet *packet_details);
/**
* Function to receive ICMP Packet
*/
void receive_icmp_packet(int sock_fd, struct icmp_packet *packet_details);
void reply_icmp(int sock_fd, struct icmp_packet *packet_details);
/**
* Function to close the icmp socket
*/
void close_icmp_socket(int sock_fd);
#endif