-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.h
More file actions
72 lines (59 loc) · 2.02 KB
/
Copy pathstack.h
File metadata and controls
72 lines (59 loc) · 2.02 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef STACK_H
#define STACK_H
#include <sys/types.h>
#include <stdint.h>
#include <arpa/inet.h>
#include "icmp.h"
#include "ip.h"
#include "ethernet.h"
#include "tcp.h"
#define NUMBER_INTERFACES 3
#define CACHE_LENGTH 3
#define TABLE_LENGTH 3
#define HOST_TCP_PORT 1234
#define TCP_IP {0xC0,0xA8,0x00,0x05} //Interface1 IP address
#define TCP_MAC {0x12,0x9f,0x41,0x0d,0x0e,0x64} //Interface1 MAC
#define TCP_CONNECTION_LIMIT 10
typedef struct router{
uint8_t interface_mac;
uint8_t interface_ip;
}router;
typedef struct interface{
/*
the quantity, IP addresses, MAC addresses, and network parameters for each simulated interface;
*/
uint8_t mac_addr[6];
uint8_t ip_addr[4];
int switch_[2];
}interface;
//routing table row
typedef struct table_r{
uint8_t dest[4];
uint8_t gateway[4];
uint8_t genmask[4];
uint8_t flag[4];
uint8_t Netif[3];
uint8_t subnet_mask;
int interface_id;
//add more below
}table_r;
typedef struct arp{
uint16_t hardware_type;
uint16_t protocol_type;
uint8_t hardware_size;
uint8_t protocol_size;
uint16_t opcode; //1 for request 2 for reply
uint8_t sender_mac[6];
uint8_t sender_ip[4];
uint8_t target_mac[6];
uint8_t target_ip[6];
}arp;
typedef struct arp_cache{
uint8_t ip_addr[4];
uint8_t mac_addr[6];
}arp_cache;
void interface_receiver(struct frame_fields *frame_f, struct frame_flags *curr_frame, uint32_t *curr_check_sum, ssize_t *data_size, struct table_r *routing_table, struct arp_cache *arp_cache, struct interface *interface_list_, int net_id, struct tcp_connection *tcp_connection_table_);
void handle_arp(struct frame_fields *frame_, uint8_t *or_frame, ssize_t len, struct packet_info *packet_inf, struct interface *interface_list_);
int is_interface(struct interface *interface_list, uint8_t *ip_addr);
void network_configuration(struct frame_fields *frame_f, struct frame_flags *curr_frame, uint32_t *curr_check_sum, ssize_t *data_size, struct table_r *routing_table, struct arp_cache *arp_cache, struct interface *interface_list_, struct tcp_connection *tcp_connection_table_);
#endif