-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMessageDealer.h
62 lines (38 loc) · 1.54 KB
/
MessageDealer.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
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// Created by 92798 on 2021/7/5.
//
#ifndef CM_DNS_CPP_MESSAGEDEALER_H
#define CM_DNS_CPP_MESSAGEDEALER_H
#include "define.h"
#include <winsock2.h>
#include <windows.h>
#include <string>
#include <vector>
#include <cstring>
#include <iostream>
#include "define.h"
#include <ws2tcpip.h>
#include "Message.h"
class MessageDealer {
public:
static Message messageInit(char *ptr, bool isResponse);
static DNS_HEADER *getDNSHeader(char *buff);
static DNS_QUERY *getDNSQuery(char buff[]);
static std::string getHostName(char *buff, char *domain_start_ptr);
static void printHeaderDetailed(DNS_HEADER *header);
static void printQueryDetailed(DNS_QUERY *query);
static void printQuerySimple(DNS_QUERY *query);
static void printResponsesDetailed(const std::vector<DNS_RESPONSE> &responses);
static void printResponsesSimple(const std::vector<DNS_RESPONSE> &responses);
static void printDetailedInfo(Message message);
static char *ipv4ToChar(const std::string &str);
static char *ipv6ToChar(const std::string &str);
static std::string charToIpv4(char *str);
static std::string charToIpv6(char *str);
static unsigned short getNewID(unsigned short recv_ID, sockaddr_in reveice_in, BOOL processed);
static std::vector<DNS_RESPONSE> getAllResponses(char *ptr, int startPoint, int num);
static DNS_RESPONSE getResponse(char *ptr, int *length, char *domain_start_ptr);
static bool isIntercept(Message message);
static bool isIPValid(const std::string &ip);
};
#endif //CM_DNS_CPP_MESSAGEDEALER_H