-
Notifications
You must be signed in to change notification settings - Fork 4
/
mpsock_dns.h
89 lines (73 loc) · 1.81 KB
/
mpsock_dns.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
* Multipath Multi-source HTTP (mHTTP)
*
* Developers: Juhoon Kim ([email protected]), Karl Fischer
*
*/
#ifndef __MPSOCK_DNS_H__
#define __MPSOCK_DNS_H__
#include "libmpsocket.h"
#include "mpsock_connection.h"
typedef struct mpsock_addr
{
unsigned long ip;
int inuse;
int priority;
} mpsock_addr;
typedef struct mpsock_addrs
{
// TODO: check if ok without const
//const char *name; // the key: a url or a hostname
char *name; // the key: a url or a hostname
unsigned long ip; // the representative IP
// address
int ttl; // the life time of the
// address mapping
int count; // the number of addresses
mpsock_addr ipset[MAX_ADDRESSES];
UT_hash_handle hh; // makes this structure
// hashable
} mpsock_addrs;
// hashtable from libmpsocket.c
extern mpsock_addrs *mpsock_address_table;
/*
* return number of ips in table
*/
int count_all_ips();
/*
* return number of unused ips in table
*/
int count_unused_ips();
/*
* lookup address of given name
*/
mpsock_addrs *lookup_by_name(const char *name);
/*
* lookup address
*/
mpsock_addrs *lookup_by_keyip(unsigned long ip);
/*
* return first ip from table
*/
//unsigned long get_first_ip(unsigned long first_ip);
/*
* return an ip address for the given host
*/
//unsigned long get_ip(const char *host);
/*
* create an address entry in given table
*/
void create_addr(char *ip_list, const char *host, unsigned long *ips, int cnt);
/*
* create address...
*/
void create_addr_from_addrinfo(char *ip_list, const char *host, const struct addrinfo *ai);
/*
* remove address...
*/
void remove_addr(mpsock_addrs *e);
/*
* set index and ip to connection for given ip
*/
void set_index_and_ip(struct mpsock_connection *connection, unsigned long ip);
#endif