-
Notifications
You must be signed in to change notification settings - Fork 4
/
TCPUtilities.h
51 lines (38 loc) · 1.08 KB
/
TCPUtilities.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
/*
* TCPUtilities.h
*
* Created on: 27-Nov-2014
* Author: jus-mine
*/
#ifndef TCPUTILITIES_H_
#define TCPUTILITIES_H_
#include<string>
#include<string.h>
#include<stdio.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netinet/tcp.h>
#include <netinet/ip.h>
#include <ifaddrs.h>
#include <iostream>
#include<pthread.h>
#include<sstream>
#include "CommonUtilities.h"
#include "Job.h"
#include <errno.h>
#define PACKET_LENGTH 2048
using namespace std;
class TCPUtilities {
CommonUtilities comUtil;
pthread_mutex_t createPacketLock = PTHREAD_MUTEX_INITIALIZER;
public :
TCPUtilities();
unsigned short csum(uint8_t *data, int length);
uint16_t calculateCheckSum(uint32_t ipSource,uint32_t ipDest,uint8_t protocol, uint16_t tcpLength,struct tcphdr tcpSegment);
void createPacket(string scanType,const char* destIP,const char* portNumber,char*,char*);
void createTCPHeader(struct tcphdr* tcpHeader , int sourcePort,const char* destPort, string scanType);
void sendTCPPacket(Job *job,char*);
};
#endif /* TCPUTILITIES_H_ */