-
Notifications
You must be signed in to change notification settings - Fork 0
/
includes.h
69 lines (60 loc) · 1.64 KB
/
includes.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
63
64
65
66
67
68
69
#include </Users/mudit/stdc++.h>
#include <sys/types.h>
#include <sys/socket.h>
#include<arpa/inet.h>
#include <signal.h>
#include <netinet/in.h>
#include<netdb.h>
#include<errno.h>
#include<unistd.h>
#include <pthread.h>
#include <dirent.h>
#include <openssl/ssl.h>
#include <sstream>
#include <fcntl.h>
#include <unordered_map>
using namespace std;
typedef struct sockaddr_in sockin_t;
typedef struct sockaddr sock_t;
string getHash(string filepath);
int connectToTracker(int port);
int connectToPort(int port);
vector<string> splitStringOnSpace(string);
vector<string> splitStringOnHash(string);
string makemsg(vector<string>);
void trackerProcessRequest(string,int);
void processPeerRequest(string,int);
void processTrackerRequest(string,int);
int sendFile(string filename,int sock);
int sendFileKthChunk(string filename,int sock,int k,int filesize,FILE *f);
int recvFileKthChunk(string filename,int sock,int k, int filesize,string filehash);
int getFileSize(string filename);
string lookupPorts(string filename);
int lookupFileSize(string filename);
bool ispresentvs(vector<string>,string);
const char* getChunkHash(char* data,int size);
//threads
void *peerserverthread(void *sock);
void *trackerConnectionThread(void *sock);
void *seeder(void *sock);
void *leecher(void *req_void);
void *inputthread(void *sockNum);
//#define C_SIZE (512*1024)
//#define MAX_RECV (8*1024)
/*************
* test
*************/
#define C_SIZE (512*1024)
#define MAX_RECV (8*1024)
typedef struct chunkRequest{
string filename;
int portNum;
int filesize;
string filehash;
}chunkRequest;
class User{
public:
string user_id;
string passwd;
bool islogged;
};