-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbt_parse.h
54 lines (47 loc) · 1.21 KB
/
bt_parse.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
/*
* bt_parse.h
*
* Initial Author: Ed Bardsley <[email protected]>
* Class: 15-441 (Spring 2005)
*
* Skeleton for 15-441 Project 2 command line and config file parsing
* stubs.
*
*/
#ifndef _BT_PARSE_H_
#define _BT_PARSE_H_
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/time.h>
#include <stdio.h>
#define BT_FILENAME_LEN 255
#define BT_MAX_PEERS 1024
typedef struct bt_peer_s {
short id;
struct sockaddr_in addr;
struct bt_peer_s *next;
} bt_peer_t;
struct bt_config_s {
char chunk_file[BT_FILENAME_LEN];
char has_chunk_file[BT_FILENAME_LEN];
char output_file[BT_FILENAME_LEN];
char peer_list_file[BT_FILENAME_LEN];
int max_conn;
short identity;
unsigned short myport;
struct timeval start_time;
FILE *cwnd;
int sock;
int argc;
char **argv;
bt_peer_t *peers;
};
typedef struct bt_config_s bt_config_t;
void bt_init(bt_config_t *c, int argc, char **argv);
void bt_parse_command_line(bt_config_t *c);
void bt_parse_peer_list(bt_config_t *c);
void bt_dump_config(bt_config_t *c);
bt_peer_t *bt_peer_info(const bt_config_t *c, int peer_id);
bt_peer_t* bt_peer_get(bt_config_t* config, struct sockaddr * from);
#endif /* _BT_PARSE_H_ */