nat_traversal.h 640 Bytes
Newer Older
Jason Fong's avatar
Jason Fong committed
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
#include <stdint.h>

#include "nat_type.h"

typedef struct client client;
struct client {
    int sfd;
    uint32_t id;
    char buf[128];
    char* msg_buf;
    nat_type type;
    char ext_ip[16];
    uint16_t ext_port;
};

struct peer_info {
    char ip[16];
    uint16_t port;
    uint16_t type;
};

enum msg_type {     
     Enroll = 0x01,      
     GetPeerInfo = 0x02,     
     NotifyPeer = 0x03,      
 };

// public functions
Fong's avatar
Fong committed
29
30
int enroll(struct peer_info self, struct sockaddr_in punch_server, client* c);
pthread_t wait_for_command(int server_sock);
Jason Fong's avatar
Jason Fong committed
31
32
int connect_to_peer(client* cli, uint32_t peer_id);
void on_connected(int sock);