-
Notifications
You must be signed in to change notification settings - Fork 0
/
devices.h
49 lines (43 loc) · 1.06 KB
/
devices.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
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
typedef struct frame
{
uint8_t preamble[7];
uint8_t sof;
uint64_t destination;
uint64_t source;
uint16_t type;
uint8_t *data;
uint8_t fcs[4];
}frame;
typedef struct commutation {
uint64_t *mac;
uint8_t nb_mac;
int state;
} commutation;
typedef struct station
{
uint64_t mac;
uint32_t ip;
} station;
typedef struct bridge {
uint64_t mac;
uint8_t nb_ports;
uint16_t priority;
commutation *table; //table de commutation
} bridge;
void print_mac(uint64_t mac);
void print_ip(uint32_t ip);
uint64_t build_mac(char* token);
unsigned int str_to_int(char* field);
int power(int nb, int expo);
uint32_t build_ip(char* addr);
int know_destintaion(bridge my_bridge, uint64_t mac);
int compare_mac(uint64_t mac1, uint64_t mac2);
void create_frame(frame *message,uint64_t src, uint64_t dest, uint8_t const *data, uint16_t size);
void show_frame(frame *message);
void show_frame_for_dev(frame *message);
void print_commutation_table(bridge my_bridge);