-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathip.h
More file actions
42 lines (35 loc) · 1.38 KB
/
Copy pathip.h
File metadata and controls
42 lines (35 loc) · 1.38 KB
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
#ifndef IP_H
#define IP_H
#include <sys/types.h>
#include <stdint.h>
#include <arpa/inet.h>
//stack.h struct declarations
struct frame_fields;
struct interface;
struct icmp;
struct arp_cache;
struct table_r;
struct tcp_connection;
typedef struct ip_header{
uint8_t version_IHL; //version and IHL
uint8_t type_of_service;
uint16_t total_length;
uint16_t identification;
uint16_t flag_fragment_offset; //flag and fragment offset
uint8_t ttl;
uint8_t protocol;
uint16_t header_checksum;
uint8_t src_addr[4];
uint8_t dest_addr[4];
}ip_header;
typedef struct packet_info{
char src_ip_addr[INET_ADDRSTRLEN];
char dest_ip_addr[INET_ADDRSTRLEN];
int valid_checksum;
int valid_length;
}packet_info;
/*ip packethandling function*/
void handle_packet(ssize_t len, struct frame_fields *frame_f, uint8_t *or_frame, struct ip_header *packet, struct packet_info *packet_inf, struct icmp *curr_icmp, struct table_r *routing_table, struct arp_cache *arp_cache__, struct interface *interface_list_, int *receiver_id, struct tcp_connection *tcp_connection_table_);
/*ip encapsulation function*/
void encapsulation(struct frame_fields *frame_, struct ip_header *packet_, ssize_t *len, uint8_t *or_frame, uint8_t *dest_addr, struct icmp *curr_icmp, struct interface *interface_list_, int error_, struct packet_info *packet_inf, int transmitter_id, struct tcp_connection *tcp_connection_table_, int flag);
#endif