forked from dtnaylor/bitrate-project-starter
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmydns.h
41 lines (37 loc) · 1.22 KB
/
mydns.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
#include <netdb.h>
/**
* Initialize your client DNS library with the IP address and port number of
* your DNS server.
*
* @param dns_ip The IP address of the DNS server.
* @param dns_port The port number of the DNS server.
* @param local_ip The local IP address client sockets should bind to.
*
* @return 0 on success, -1 otherwise
*/
int init_mydns(const char *dns_ip, unsigned int dns_port, const char *local_ip);
/**
* Resolve a DNS name using your custom DNS server.
*
* Whenever your proxy needs to open a connection to a web server, it calls
* resolve() as follows:
*
* struct addrinfo *result;
* int rc = resolve("video.cs.cmu.edu", "8080", null, &result);
* if (rc != 0) {
* // handle error
* }
* // connect to address in result
* free(result);
*
*
* @param node The hostname to resolve.
* @param service The desired port number as a string.
* @param hints Should be null. resolve() ignores this parameter.
* @param res The result. resolve() should allocate a struct addrinfo, which
* the caller is responsible for freeing.
*
* @return 0 on success, -1 otherwise
*/
int resolve(const char *node, const char *service,
const struct addrinfo *hints, struct addrinfo **res);