-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathl4_protocols.h
More file actions
65 lines (44 loc) · 1.12 KB
/
l4_protocols.h
File metadata and controls
65 lines (44 loc) · 1.12 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
#ifndef L4_PROTOCOLS_H
#define L4_PROTOCOLS_H
#include <vector>
#include <iostream>
#include <fstream>
#include <cstdint>
#include <list>
#include "addressing.h"
using namespace std;
#define TCP_SYN 0x0002
#define TCP_ACK 0x0010
#define TCP_FIN 0x0001
#define TCP_SYNACK (TCP_ACK | TCP_SYN)
#define TCP_FINACK (TCP_ACK | TCP_FIN)
#define TCP_INITIAL_SN 0
#define TCP_HEADER_SIZE 18
#define UDP_HEADER_SIZE 8
#define SEGMENT_EOF 0xFF
// layer 4 types
// UDP
struct UDP {
uint16_t source_port;
uint16_t destination_port;
uint16_t length;
uint16_t checksum;
vector<uint8_t> payload;
};
UDP generate_UDP(vector<uint8_t> udp_u8);
vector<UDP> * file_to_UDP_segments(const char * , uint16_t , uint16_t , int );
// TCP
struct TCP {
uint16_t source_port;
uint16_t destination_port;
uint32_t sequence_number;
uint32_t ACK_number;
uint16_t details; // includes header length, SYN, FIN, ACK
uint16_t receive_window;
uint16_t checksum;
vector<uint8_t> payload;
};
TCP generate_TCP(vector<uint8_t> tcp_u8);
vector<TCP> * file_to_TCP_segments(const char *, uint16_t , uint16_t , int );
// MPDU* TCP_to_MPDU();
#endif