Skip to content

Commit 0b5a8b1

Browse files
committed
IP address library copied from libmill
Signed-off-by: Martin Sustrik <[email protected]>
1 parent abdbdaf commit 0b5a8b1

File tree

7 files changed

+10735
-2
lines changed

7 files changed

+10735
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ dillsocks.pc
2121
libtool
2222
*.o
2323
*.lo
24+
dns/.dirstamp
2425
libdillsocks.la
2526
test-suite.log
2627
tests/.dirstamp

Makefile.am

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ dillsocksinclude_HEADERS = dillsocks.h
3131

3232
lib_LTLIBRARIES = libdillsocks.la
3333

34-
libdillsocks_la_SOURCES =
34+
libdillsocks_la_SOURCES = \
35+
ip.c \
36+
utils.h \
37+
dns/dns.h \
38+
dns/dns.c
3539

3640
libdillsocks_la_LDFLAGS = -no-undefined -version-info \
3741
@DILLSOCKS_LIBTOOL_VERSION@

dillsocks.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,21 @@
7373
#endif
7474

7575
/******************************************************************************/
76-
/* TODO */
76+
/* IP address resolution */
7777
/******************************************************************************/
7878

79+
#define IPADDR_IPV4 1
80+
#define IPADDR_IPV6 2
81+
#define IPADDR_PREF_IPV4 3
82+
#define IPADDR_PREF_IPV6 4
83+
#define IPADDR_MAXSTRLEN 46
84+
85+
typedef struct {char data[32];} ipaddr;
86+
87+
DILL_EXPORT ipaddr iplocal(const char *name, int port, int mode);
88+
DILL_EXPORT ipaddr ipremote(const char *name, int port, int mode,
89+
int64_t deadline);
90+
DILL_EXPORT const char *ipaddrstr(ipaddr addr, char *ipstr);
7991

8092
#endif
8193

0 commit comments

Comments
 (0)