youtubeUnblock/mangle.h

83 lines
2.0 KiB
C
Raw Normal View History

#ifndef YU_MANGLE_H
#define YU_MANGLE_H
2024-08-03 22:29:57 +00:00
#include "types.h"
2024-08-11 08:40:13 +00:00
/**
* Result of analyze_tls_data function
*/
struct tls_verdict {
2024-08-08 12:29:04 +00:00
int target_sni; /* google video hello packet */
int sni_offset; /* offset from start of tcp _payload_ */
int sni_len;
};
2024-08-11 08:40:13 +00:00
/**
* Processes the packet and finds TLS Client Hello information inside it.
* data pointer points to start of TLS Message (TCP Payload)
*/
struct tls_verdict analyze_tls_data(const uint8_t *data, uint32_t dlen);
2024-08-11 08:40:13 +00:00
/**
* Generates fake client hello message
*/
2024-08-27 16:27:27 +00:00
int gen_fake_sni(const void *iph, uint32_t iph_len,
const struct tcphdr *tcph, uint32_t tcph_len,
2024-08-03 23:20:09 +00:00
uint8_t *buf, uint32_t *buflen);
2024-08-10 23:10:18 +00:00
2024-08-11 08:40:13 +00:00
/**
* Invalidates the raw packet. The function aims to invalid the packet
* in such way as it will be accepted by DPI, but dropped by target server
*/
2024-08-27 16:27:27 +00:00
int fail_packet(uint8_t *payload, uint32_t plen);
2024-08-10 23:10:18 +00:00
#define PKT_ACCEPT 0
#define PKT_DROP 1
/**
* Processes the packet and returns verdict.
* This is the primary function that traverses the packet.
*/
int process_packet(const uint8_t *packet, uint32_t packet_len);
2024-08-11 21:23:08 +00:00
/**
* Processe the TCP packet.
* Returns verdict.
*/
2024-08-27 16:27:27 +00:00
int process_tcp_packet(const uint8_t *raw_payload, uint32_t raw_payload_len);
/**
* Processes the UDP packet.
* Returns verdict.
*/
int process_udp_packet(const uint8_t *pkt, uint32_t pktlen);
2024-08-11 21:23:08 +00:00
/**
* Sends fake client hello.
*/
2024-08-27 16:27:27 +00:00
int post_fake_sni(const void *iph, unsigned int iph_len,
2024-08-11 21:23:08 +00:00
const struct tcphdr *tcph, unsigned int tcph_len,
unsigned char sequence_len);
/**
* Splits packet by poses and posts.
* Poses are relative to start of TCP payload.
* dvs used internally and should be zero.
*/
2024-08-27 16:27:27 +00:00
int send_tcp_frags(
2024-08-11 21:23:08 +00:00
const uint8_t *packet, uint32_t pktlen,
const uint32_t *poses, uint32_t poses_len, uint32_t dvs);
/**
* Splits packet by poses and posts.
* Poses are relative to start of TCP payload.
* dvs used internally and should be zero.
*/
int send_ip4_frags(
const uint8_t *packet, uint32_t pktlen,
const uint32_t *poses, uint32_t poses_len, uint32_t dvs);
#endif /* YU_MANGLE_H */