mirror of
https://github.com/subhobhai943/SUB-OS.git
synced 2026-10-25 16:52:29 +00:00
feat(net): Full TCP state machine, SYN-ACK packet handler, NetFilter integration, and dynamic netstat
This commit is contained in:
1 parent
c59af27cdb
commit
1ecd677604
4 files changed
+265
-4
No files matched your search
@@ -3,6 +3,13 @@
|
||||
|
||||
#include <net/net.h>
|
||||
|
||||
#define TCP_FLAG_FIN 0x01
|
||||
#define TCP_FLAG_SYN 0x02
|
||||
#define TCP_FLAG_RST 0x04
|
||||
#define TCP_FLAG_PSH 0x08
|
||||
#define TCP_FLAG_ACK 0x10
|
||||
#define TCP_FLAG_URG 0x20
|
||||
|
||||
#define TCP_STATE_CLOSED 0
|
||||
#define TCP_STATE_LISTEN 1
|
||||
#define TCP_STATE_SYN_SENT 2
|
||||
@@ -27,7 +34,24 @@ typedef struct {
|
||||
uint16_t urgent_pointer;
|
||||
} __attribute__((packed)) tcp_header_t;
|
||||
|
||||
typedef struct tcp_conn {
|
||||
uint32_t local_ip;
|
||||
uint32_t remote_ip;
|
||||
uint16_t local_port;
|
||||
uint16_t remote_port;
|
||||
uint8_t state;
|
||||
uint32_t seq_num;
|
||||
uint32_t ack_num;
|
||||
bool in_use;
|
||||
} tcp_conn_t;
|
||||
|
||||
void tcp_init(void);
|
||||
void tcp_receive(const uint8_t* packet, uint16_t length, uint32_t src_ip);
|
||||
void tcp_send_packet(uint32_t dst_ip, uint16_t src_port, uint16_t dst_port,
|
||||
uint32_t seq, uint32_t ack, uint8_t flags,
|
||||
const void* payload, uint16_t payload_len);
|
||||
|
||||
size_t tcp_get_connections_count(void);
|
||||
const tcp_conn_t* tcp_get_connection(size_t index);
|
||||
|
||||
#endif // _NET_TCP_H
|
||||
Reference in new issue
Block a user