Compare commits
515
Commits
cares-1_7_0
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc6b8641c2 | ||
|
|
2811e30d49 | ||
|
|
55e2af978d | ||
|
|
742f56907a | ||
|
|
0b7a497ab7 | ||
|
|
ebe7b81453 | ||
|
|
3b1ff9da74 | ||
|
|
23b9ad9ede | ||
|
|
6917640336 | ||
|
|
bf45d4c7c1 | ||
|
|
10a1b7d509 | ||
|
|
fab050fe94 | ||
|
|
3e897ff27e | ||
|
|
e7fe2744db | ||
|
|
e41a39b022 | ||
|
|
6549138e8b | ||
|
|
f61151a091 | ||
|
|
63909b59a0 | ||
|
|
5b46450af4 | ||
|
|
f4fe7371fb | ||
|
|
18eeb34989 | ||
|
|
85c865e655 | ||
|
|
f0d04b2909 | ||
|
|
8d023b7d96 | ||
|
|
4ef6817c76 | ||
|
|
80bda0e9a0 | ||
|
|
385582bd14 | ||
|
|
7e17c22b0f | ||
|
|
ed7df969cd | ||
|
|
d8a0182af5 | ||
|
|
56cd98b9e4 | ||
|
|
e514088f96 | ||
|
|
2b6a1fbee7 | ||
|
|
11e37a92ef | ||
|
|
87d641a907 | ||
|
|
2bae2d56d7 | ||
|
|
53c2186e18 | ||
|
|
0c4c1ca9bc | ||
|
|
adc95e6bd6 | ||
|
|
03ba16fe7a | ||
|
|
3f301a6fe3 | ||
|
|
d4a549c78b | ||
|
|
6f1862f884 | ||
|
|
31ca57671e | ||
|
|
c9579872c8 | ||
|
|
86beb81892 | ||
|
|
ff1f7a1c3c | ||
|
|
b644412a66 | ||
|
|
5dc450a4b3 | ||
|
|
439eb45cc0 | ||
|
|
78f9ec5515 | ||
|
|
3478963873 | ||
|
|
830e8fe2b3 | ||
|
|
d3bccff740 | ||
|
|
9edf9411c7 | ||
|
|
d448d6604f | ||
|
|
92656bcc82 | ||
|
|
3231480a85 | ||
|
|
e26a678f26 | ||
|
|
25adcc413e | ||
|
|
a05f240dea | ||
|
|
83839fde7a | ||
|
|
0c423efd78 | ||
|
|
0ef56333a0 | ||
|
|
ce3f896572 | ||
|
|
f939efe7df | ||
|
|
a2c5b1d378 | ||
|
|
834c98e9d9 | ||
|
|
693e566b66 | ||
|
|
3ce586feb7 | ||
|
|
6589ebfd6a | ||
|
|
4a09121923 | ||
|
|
f2ae5d72da | ||
|
|
0c03bee6ed | ||
|
|
ffc7c52656 | ||
|
|
e3434ef33f | ||
|
|
a48447ee27 | ||
|
|
f9b9817d1d | ||
|
|
c778f0136b | ||
|
|
79dc327a2d | ||
|
|
5da3201a05 | ||
|
|
3907b6dc68 | ||
|
|
2aa07c7d02 | ||
|
|
b651f825d6 | ||
|
|
72555b6cad | ||
|
|
4a4f875c5a | ||
|
|
af3ee9a8ba | ||
|
|
148b6e93b9 | ||
|
|
59b3f81ab4 | ||
|
|
5f59b88431 | ||
|
|
b2dbc698ea | ||
|
|
ce1ea79943 | ||
|
|
8042524c70 | ||
|
|
ace90cce05 | ||
|
|
1b6905cc7f | ||
|
|
7972adc5d7 | ||
|
|
06d0f72e54 | ||
|
|
f1bcfa1122 | ||
|
|
d493e9b17c | ||
|
|
b619d13693 | ||
|
|
4ad3111a49 | ||
|
|
87ff25049c | ||
|
|
35609ceb41 | ||
|
|
e2c4b6f36c | ||
|
|
de04975c48 | ||
|
|
74ba881295 | ||
|
|
970dea47b7 | ||
|
|
46bb820be3 | ||
|
|
52c9bc57bd | ||
|
|
6aabc42e5f | ||
|
|
fa14ba7b11 | ||
|
|
68a938e771 | ||
|
|
02e1f7f9af | ||
|
|
5e5b2f4239 | ||
|
|
a37863498f | ||
|
|
e4e40161f8 | ||
|
|
ab78ef369d | ||
|
|
51dae48ecf | ||
|
|
48c0f703f6 | ||
|
|
250e7a20cc | ||
|
|
66f40230a0 | ||
|
|
c49a87eea5 | ||
|
|
affc63cba8 | ||
|
|
f945a0cfe3 | ||
|
|
52ecef76df | ||
|
|
fe34a70d6a | ||
|
|
36ca36eedd | ||
|
|
cbb466e813 | ||
|
|
ce3a0ee056 | ||
|
|
cac35ac5d8 | ||
|
|
bba4dc573f | ||
|
|
453578354f | ||
|
|
a0b24beb95 | ||
|
|
3d3ab03c6d | ||
|
|
9456c39934 | ||
|
|
296ced3a0d | ||
|
|
bd2c61353f | ||
|
|
7db1afd38f | ||
|
|
13dc4800b2 | ||
|
|
880ec44da9 | ||
|
|
ede0f84b8e | ||
|
|
2bc07b2e74 | ||
|
|
c1fe47f6d9 | ||
|
|
943e79f4bf | ||
|
|
7aabbefab1 | ||
|
|
09e64d7124 | ||
|
|
7df69c0f79 | ||
|
|
ee22246507 | ||
|
|
0004f498dc | ||
|
|
440110b303 | ||
|
|
bc529dd0c2 | ||
|
|
d5d3871335 | ||
|
|
4aa1fc4163 | ||
|
|
c8ec633bf5 | ||
|
|
83ab208e83 | ||
|
|
f19387dd72 | ||
|
|
efdd616118 | ||
|
|
30c9031afa | ||
|
|
742e234855 | ||
|
|
68b3c67e61 | ||
|
|
d69ae9c6f8 | ||
|
|
9540d48184 | ||
|
|
f8a2354016 | ||
|
|
1c948a70b1 | ||
|
|
46fa9cad79 | ||
|
|
09be3edf3a | ||
|
|
03e2fd085c | ||
|
|
df55bfac79 | ||
|
|
3f0ec4733e | ||
|
|
76ef032fd0 | ||
|
|
58a822231c | ||
|
|
c727dcb924 | ||
|
|
fb0737f3a0 | ||
|
|
b5135bbc66 | ||
|
|
9a92b80191 | ||
|
|
2e0c3076e5 | ||
|
|
148c8e0353 | ||
|
|
2004a7a111 | ||
|
|
c95041c6a1 | ||
|
|
483d49d060 | ||
|
|
1317a1c94b | ||
|
|
fa19279bba | ||
|
|
54faf09da6 | ||
|
|
127d4cb357 | ||
|
|
8f3f059f33 | ||
|
|
57203b14df | ||
|
|
a2881fee6b | ||
|
|
60cad73007 | ||
|
|
715b499c79 | ||
|
|
f454e82dc7 | ||
|
|
320c4eb659 | ||
|
|
9ed49f3e17 | ||
|
|
b82874ad6f | ||
|
|
ecf6f65b43 | ||
|
|
f4dce2e9f0 | ||
|
|
07bbbd85c3 | ||
|
|
cf7ad9758d | ||
|
|
ee9a1c2457 | ||
|
|
8d013420a0 | ||
|
|
c28e6d98db | ||
|
|
e9bca998f9 | ||
|
|
050663271e | ||
|
|
2a3a63ae1f | ||
|
|
9c03cc118c | ||
|
|
3217c7eef2 | ||
|
|
be6e6984b5 | ||
|
|
df72bed2e3 | ||
|
|
75a8407985 | ||
|
|
b6dd41b6ef | ||
|
|
422717ba6f | ||
|
|
e03b5288ec | ||
|
|
ddc7ab6713 | ||
|
|
18b7d9a9f4 | ||
|
|
e916c68de7 | ||
|
|
0110c7f6ee | ||
|
|
44635a5ec0 | ||
|
|
186c57182e | ||
|
|
b157f4a0be | ||
|
|
15177a631e | ||
|
|
971bdfedb2 | ||
|
|
14e78ad68b | ||
|
|
b74bcad714 | ||
|
|
037656b2d8 | ||
|
|
dc6c864108 | ||
|
|
4718066ea4 | ||
|
|
a664066899 | ||
|
|
70ac469a0c | ||
|
|
5b5066d6bc | ||
|
|
a056480169 | ||
|
|
b214c21cf6 | ||
|
|
c220b29b3c | ||
|
|
84eb2dc220 | ||
|
|
9da14a847f | ||
|
|
a28e44c344 | ||
|
|
4ed0fc2d44 | ||
|
|
0c677f578e | ||
|
|
a1035276c1 | ||
|
|
bceb40095a | ||
|
|
98b52964cf | ||
|
|
93a09eabeb | ||
|
|
a5ce39391c | ||
|
|
1e4f2d28fc | ||
|
|
50f25d8a4b | ||
|
|
805c736e36 | ||
|
|
65ac7e706d | ||
|
|
2b897074cb | ||
|
|
a1314e492d | ||
|
|
83093ac450 | ||
|
|
90364defb0 | ||
|
|
e447bc5c60 | ||
|
|
8283fb15e6 | ||
|
|
4d91235900 | ||
|
|
54751f4d33 | ||
|
|
bc0c3c62cc | ||
|
|
a85ba35816 | ||
|
|
b743f875d3 | ||
|
|
3b649328be | ||
|
|
6e44d64429 | ||
|
|
cc067c21fe | ||
|
|
979bf951d3 | ||
|
|
38b69b7269 | ||
|
|
1972aad19e | ||
|
|
9bd38a4a6e | ||
|
|
7ec5e8e656 | ||
|
|
f037316e4b | ||
|
|
88d6dfb3d4 | ||
|
|
d9ff559036 | ||
|
|
82a1c1c989 | ||
|
|
38a9933a6d | ||
|
|
f7b66af200 | ||
|
|
031040f893 | ||
|
|
28354d9ad2 | ||
|
|
7ce8fe781a | ||
|
|
05346c25cb | ||
|
|
b3afe9cbde | ||
|
|
2c67ce6459 | ||
|
|
80de4a7295 | ||
|
|
5e80852e4c | ||
|
|
017132bf43 | ||
|
|
2c77c33daa | ||
|
|
81db5a00e4 | ||
|
|
cb71b6bd5a | ||
|
|
f6b4cacfae | ||
|
|
fc2c91c206 | ||
|
|
41191cdd54 | ||
|
|
7e2f70a08c | ||
|
|
4980cc99e2 | ||
|
|
8b79584e01 | ||
|
|
27a478c7a3 | ||
|
|
58e62c5879 | ||
|
|
7d3f341156 | ||
|
|
995fa144d9 | ||
|
|
0d6ef42b5f | ||
|
|
4ef145cede | ||
|
|
41f8ff5070 | ||
|
|
506d586276 | ||
|
|
1c26242c52 | ||
|
|
73dc26a9fc | ||
|
|
90a150f045 | ||
|
|
6bab0393c4 | ||
|
|
4ab65461b6 | ||
|
|
f1a1df1e6c | ||
|
|
6ae9e71df4 | ||
|
|
f394cd55c8 | ||
|
|
3d84eb3bbc | ||
|
|
66e91438c5 | ||
|
|
a831da792d | ||
|
|
bab721cb1c | ||
|
|
1f8f14d21e | ||
|
|
c8d8ca2606 | ||
|
|
1089cf6052 | ||
|
|
b816675c0f | ||
|
|
d0c3cb6840 | ||
|
|
2d9a5acff5 | ||
|
|
440b5d488a | ||
|
|
14eb79f660 | ||
|
|
34d5d76969 | ||
|
|
f11c2c2891 | ||
|
|
622313ab3b | ||
|
|
c4d3cb8c3a | ||
|
|
bb4096effe | ||
|
|
1b9c2a3ea3 | ||
|
|
5da497e0e8 | ||
|
|
a94b4e53d1 | ||
|
|
a8f62e82bf | ||
|
|
3d7af9782e | ||
|
|
bffd67f16a | ||
|
|
f2ea96b1b7 | ||
|
|
2039e81e45 | ||
|
|
5f2a3b0e48 | ||
|
|
08e721e004 | ||
|
|
88d314548e | ||
|
|
4701b0c47a | ||
|
|
159b82c056 | ||
|
|
ce03c818f4 | ||
|
|
22c527cc87 | ||
|
|
09f8a05573 | ||
|
|
a1116723d4 | ||
|
|
18b6d475dc | ||
|
|
978a929b40 | ||
|
|
8e457f2c41 | ||
|
|
654733a399 | ||
|
|
b5823d6570 | ||
|
|
22c01e96f7 | ||
|
|
adf75c56c4 | ||
|
|
e67edcd18d | ||
|
|
700b928544 | ||
|
|
3cb1afe054 | ||
|
|
45ec020795 | ||
|
|
f9b24e590c | ||
|
|
56c77364d5 | ||
|
|
22a52102d6 | ||
|
|
f413fce823 | ||
|
|
5ef8f5ead2 | ||
|
|
e1c9539962 | ||
|
|
ef5390e6bb | ||
|
|
6518b56a5e | ||
|
|
d60f07d094 | ||
|
|
a268ae6a78 | ||
|
|
8520a37f62 | ||
|
|
74f1bd8c22 | ||
|
|
5e5c0132e6 | ||
|
|
e49ce8f973 | ||
|
|
2c2e2d839e | ||
|
|
ebc9a9d958 | ||
|
|
5b6a188909 | ||
|
|
bd066ab8ef | ||
|
|
822fd0f877 | ||
|
|
3abad87d88 | ||
|
|
c7ce7c7d45 | ||
|
|
9099a9eb0c | ||
|
|
d81cae7a67 | ||
|
|
8c503ddf79 | ||
|
|
ef8e2ad601 | ||
|
|
cd753ffe14 | ||
|
|
1bd524dd4a | ||
|
|
0f226fb8e4 | ||
|
|
ffb7697ac8 | ||
|
|
6e3e66dc5c | ||
|
|
9a11973403 | ||
|
|
e14f136aa3 | ||
|
|
dec9f79d0a | ||
|
|
e5fe34eea6 | ||
|
|
5a21ba2b66 | ||
|
|
d70721eb65 | ||
|
|
bd6636c138 | ||
|
|
39d7f64361 | ||
|
|
366cd6d54d | ||
|
|
766a5aaf86 | ||
|
|
2d5ed6400b | ||
|
|
70b726c334 | ||
|
|
a44f4c33e9 | ||
|
|
1cfd800d4a | ||
|
|
7a4ec5ce61 | ||
|
|
e566cc100f | ||
|
|
674e044ccb | ||
|
|
d8c830f33e | ||
|
|
3670427a0b | ||
|
|
52f493c931 | ||
|
|
2c9bdd7856 | ||
|
|
fd6f4dbe1e | ||
|
|
0d738bab0d | ||
|
|
b9959cbf36 | ||
|
|
f5e0858d2f | ||
|
|
e03a65c3d9 | ||
|
|
2c26d7d254 | ||
|
|
623f3cb531 | ||
|
|
b2dafb6974 | ||
|
|
0b497f70e1 | ||
|
|
b354607aed | ||
|
|
0ae8dbb22d | ||
|
|
4d061e6b23 | ||
|
|
09331032a0 | ||
|
|
a04dbb4323 | ||
|
|
fb4df6febc | ||
|
|
618e34bcf6 | ||
|
|
a1c27d5480 | ||
|
|
2c63440127 | ||
|
|
41b8a1bfd0 | ||
|
|
e3f7230dc2 | ||
|
|
0ea27cdbbf | ||
|
|
e3813e6d24 | ||
|
|
e9e8b6e864 | ||
|
|
4d44b54c75 | ||
|
|
461fa89e0a | ||
|
|
85520d66e0 | ||
|
|
690f9a726c | ||
|
|
137a440a36 | ||
|
|
10ae9e4ec2 | ||
|
|
4ab5eb6631 | ||
|
|
0b504d7065 | ||
|
|
dac69d52c2 | ||
|
|
494274e653 | ||
|
|
747981be8e | ||
|
|
b8044334f0 | ||
|
|
e9386cfd9f | ||
|
|
6cc3521ec9 | ||
|
|
803e2a28b7 | ||
|
|
679c1032cb | ||
|
|
fa0dd472cd | ||
|
|
293cd31700 | ||
|
|
e43e69718f | ||
|
|
5e7a4dc5d7 | ||
|
|
e6b38cdbd2 | ||
|
|
d8ed817b99 | ||
|
|
b33f331a4f | ||
|
|
17d4e513d4 | ||
|
|
9912637d32 | ||
|
|
a00e234001 | ||
|
|
3392a50ea3 | ||
|
|
07bc7ea795 | ||
|
|
cef3a4c7aa | ||
|
|
8d33804971 | ||
|
|
f575aea364 | ||
|
|
03c1378e84 | ||
|
|
1ac83339e3 | ||
|
|
45557a138e | ||
|
|
3e33e2c2ba | ||
|
|
28ff9336d5 | ||
|
|
e3b04e5a47 | ||
|
|
45a09b7efb | ||
|
|
d6b8698941 | ||
|
|
954ec10e5a | ||
|
|
b13c6552f8 | ||
|
|
359936ceca | ||
|
|
955038ea68 | ||
|
|
5209cf03a1 | ||
|
|
9cb25ea5f7 | ||
|
|
50f99d46cc | ||
|
|
890a143722 | ||
|
|
125b1a8619 | ||
|
|
0e8dc6f18e | ||
|
|
cd59ae213f | ||
|
|
be68a8ed0d | ||
|
|
63918fca76 | ||
|
|
f28874d323 | ||
|
|
63627fa5ab | ||
|
|
cd6b2b8659 | ||
|
|
6e0ab38229 | ||
|
|
a83d892bb2 | ||
|
|
5e22223332 | ||
|
|
e965d83c78 | ||
|
|
7403f443ac | ||
|
|
36e2f2b54f | ||
|
|
5923ba2a53 | ||
|
|
8c4fc9ee71 | ||
|
|
eb9ce5145b | ||
|
|
941bb3aaba | ||
|
|
f8d181ddf6 | ||
|
|
25116bbc54 | ||
|
|
7ce764fe7c | ||
|
|
1cb7bccb6a | ||
|
|
907b09ccd0 | ||
|
|
3081404dec | ||
|
|
05b07653e5 | ||
|
|
c431501153 | ||
|
|
e51156c080 | ||
|
|
0a076df87f | ||
|
|
8fe746fcf2 | ||
|
|
249fc61b8c | ||
|
|
53bf47a140 | ||
|
|
b6ffa03a21 | ||
|
|
62f43da764 | ||
|
|
561d3d8356 | ||
|
|
86718e2f52 | ||
|
|
78414c0f3a | ||
|
|
157d68729f | ||
|
|
d2f21d37b1 | ||
|
|
8b6f71ce95 | ||
|
|
004c2e3400 | ||
|
|
92dcb407d6 | ||
|
|
58d9b0c1bd | ||
|
|
bb3f003b83 | ||
|
|
c2d3f7986b | ||
|
|
df279b133c |
-35
@@ -1,35 +0,0 @@
|
||||
*.html
|
||||
*.lo
|
||||
*.pdf
|
||||
.deps
|
||||
.libs
|
||||
MSVC*
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
acountry
|
||||
adig
|
||||
ahost
|
||||
ares_build.h
|
||||
ares_config.h
|
||||
ares_config.h.in
|
||||
ares_version.h.dist
|
||||
autom4te.cache
|
||||
compile
|
||||
config.guess
|
||||
config.h
|
||||
config.h.in
|
||||
config.log
|
||||
config.lt
|
||||
config.status
|
||||
config.sub
|
||||
configure
|
||||
depcomp
|
||||
libcares.la
|
||||
libcares.pc
|
||||
libtool
|
||||
ltmain.sh
|
||||
man3
|
||||
missing
|
||||
msvc*
|
||||
stamp-h*
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
.deps
|
||||
.libs
|
||||
*.lib
|
||||
*.pdb
|
||||
*.dll
|
||||
*.exe
|
||||
*.obj
|
||||
.*.swp
|
||||
Debug
|
||||
Release
|
||||
*.exp
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
autom4te.cache
|
||||
config.guess
|
||||
config.log
|
||||
config.status
|
||||
config.sub
|
||||
configure
|
||||
depcomp
|
||||
libtool
|
||||
ltmain.sh
|
||||
compile
|
||||
libcares.pc
|
||||
missing
|
||||
test-driver
|
||||
c-ares-*.tar.gz
|
||||
INSTALL
|
||||
install-sh
|
||||
*.o
|
||||
*.lo
|
||||
*.la
|
||||
*.gcno
|
||||
*.gcda
|
||||
*.gcov
|
||||
c-ares---coverage.info
|
||||
c-ares---coverage
|
||||
mkinstalldirs
|
||||
tags
|
||||
TAGS
|
||||
*~
|
||||
aclocal.m4.bak
|
||||
acountry
|
||||
adig
|
||||
ahost
|
||||
ares_build.h
|
||||
ares_config.h
|
||||
ares_config.h.in
|
||||
stamp-h1
|
||||
stamp-h2
|
||||
ares_*pdf
|
||||
CHANGES.dist
|
||||
c-ares-*.tar.gz.asc
|
||||
ares_parse_mx_reply.pdf
|
||||
/[0-9]*.patch
|
||||
*.kdev4
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
language: c++
|
||||
sudo: false
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- gcc-4.8
|
||||
- g++-4.8
|
||||
- lcov
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: BUILD_TYPE=normal
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: BUILD_TYPE=normal
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: BUILD_TYPE=coverage
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: BUILD_TYPE=ubsan
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: BUILD_TYPE=asan
|
||||
- os: linux
|
||||
compiler: clang
|
||||
env: BUILD_TYPE=lsan
|
||||
# - os: linux
|
||||
# compiler: clang
|
||||
# env: BUILD_TYPE=analyse
|
||||
- os: osx
|
||||
compiler: gcc
|
||||
env: BUILD_TYPE=normal
|
||||
- os: osx
|
||||
compiler: clang
|
||||
env: BUILD_TYPE=normal
|
||||
- os: osx
|
||||
compiler: clang
|
||||
language: objective-c
|
||||
env: BUILD_TYPE=ios
|
||||
install:
|
||||
- pip install --user 'requests[security]<2.9.1'
|
||||
- pip install --user cpp-coveralls
|
||||
before_script:
|
||||
- |
|
||||
if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$CXX" = "g++" ]; then
|
||||
export CXX="g++-4.8"
|
||||
export CC="gcc-4.8"
|
||||
fi
|
||||
- |
|
||||
if [ "$BUILD_TYPE" = "coverage" ]; then
|
||||
export CONFIG_OPTS="--enable-debug --disable-shared --enable-code-coverage"
|
||||
fi
|
||||
- |
|
||||
if [ "$BUILD_TYPE" = "asan" ]; then
|
||||
export CONFIG_OPTS=--enable-debug
|
||||
export CFLAGS=-fsanitize=address
|
||||
export CXXFLAGS=-fsanitize=address
|
||||
export LDFLAGS=-fsanitize=address
|
||||
fi
|
||||
- |
|
||||
if [ "$BUILD_TYPE" = "lsan" ]; then
|
||||
export CONFIG_OPTS=--enable-debug
|
||||
export CFLAGS=-fsanitize=leak
|
||||
export CXXFLAGS=-fsanitize=leak
|
||||
export LDFLAGS=-fsanitize=leak
|
||||
fi
|
||||
- |
|
||||
if [ "$BUILD_TYPE" = "ubsan" ]; then
|
||||
export CFLAGS="-fsanitize=undefined -fno-sanitize-recover"
|
||||
export LDFLAGS="-fsanitize=undefined"
|
||||
fi
|
||||
- |
|
||||
if [ "$BUILD_TYPE" = "analyse" ]; then
|
||||
export SCAN_WRAP="scan-build"
|
||||
export CONFIG_OPTS="--enable-debug"
|
||||
fi
|
||||
- |
|
||||
if [ "$BUILD_TYPE" = "ios" ]; then
|
||||
export CONFIG_OPTS=--host=arm-apple-darwin10
|
||||
export DEVPATH=`xcode-select -print-path`/Platforms/iPhoneOS.platform/Developer
|
||||
export IOSFLAGS="-isysroot $DEVPATH/SDKs/iPhoneOS.sdk -arch armv7 -miphoneos-version-min=8.0.0"
|
||||
export CFLAGS=$IOSFLAGS
|
||||
export CXXFLAGS=$IOSFLAGS
|
||||
export LDFLAGS=$IOSFLAGS
|
||||
fi
|
||||
script:
|
||||
- ./buildconf && $SCAN_WRAP ./configure --disable-symbol-hiding --enable-expose-statics --enable-maintainer-mode --enable-debug $CONFIG_OPTS && $SCAN_WRAP make
|
||||
- |
|
||||
if [ "$BUILD_TYPE" != "ios" ]; then
|
||||
./adig www.google.com
|
||||
./acountry www.google.com
|
||||
./ahost www.google.com
|
||||
cd test && make && ./arestest -v && cd ..
|
||||
fi
|
||||
- |
|
||||
if [ "$BUILD_TYPE" = "coverage" ]; then
|
||||
coveralls --gcov /usr/bin/gcov-4.8 --gcov-options '\-lp'
|
||||
fi
|
||||
@@ -1,37 +1,82 @@
|
||||
c-ares is based on ares, and these are the people that have worked on it since
|
||||
the fork was made:
|
||||
|
||||
Albert Chin
|
||||
Alex Loukissas
|
||||
Alexander Klauer
|
||||
Alexander Lazic
|
||||
Alexey Simak
|
||||
Andreas Rieke
|
||||
Andrew Andkjar
|
||||
Andrew Ayer
|
||||
Andrew C. Morrow
|
||||
Ashish Sharma
|
||||
Ben Greear
|
||||
Ben Noordhuis
|
||||
BogDan Vatra
|
||||
Brad House
|
||||
Brad Spencer
|
||||
Bram Matthys
|
||||
Chris Araman
|
||||
Dan Fandrich
|
||||
Daniel Johnson
|
||||
Daniel Stenberg
|
||||
David Drysdale
|
||||
David Stuart
|
||||
Denis Bilenko
|
||||
Dima Tisnek
|
||||
Dirk Manske
|
||||
Dominick Meglio
|
||||
Doug Goldstein
|
||||
Doug Kwan
|
||||
Duncan Wilcox
|
||||
Eino Tuominen
|
||||
Erik Kline
|
||||
Fedor Indutny
|
||||
Frederic Germain
|
||||
Geert Uytterhoeven
|
||||
George Neill
|
||||
Gisle Vanem
|
||||
Gregor Jasny
|
||||
Guenter Knauf
|
||||
Guilherme Balena Versiani
|
||||
Gunter Knauf
|
||||
Henrik Stoerner
|
||||
Jakub Hrozek
|
||||
James Bursa
|
||||
Jérémy Lal
|
||||
Keith Shaw
|
||||
Lei Shi
|
||||
Marko Kreen
|
||||
Michael Wallner
|
||||
Mike Crowe
|
||||
Nick Alcock
|
||||
Nick Mathewson
|
||||
Nicolas "Pixel" Noble
|
||||
Ning Dong
|
||||
Oleg Pudeyev
|
||||
Patrick Valsecchi
|
||||
Patrik Thunstrom
|
||||
Paul Saab
|
||||
Peter Pentchev
|
||||
Phil Blundell
|
||||
Poul Thomas Lomholt
|
||||
Ravi Pratap
|
||||
Robin Cornelius
|
||||
Saúl Ibarra Corretgé
|
||||
Sebastian at basti79.de
|
||||
Shmulik Regev
|
||||
Stefan Bühler
|
||||
Steinar H. Gunderson
|
||||
Svante Karlsson
|
||||
Tofu Linden
|
||||
Tom Hughes
|
||||
Tor Arntsen
|
||||
Viktor Szakats
|
||||
Vlad Dinulescu
|
||||
William Ahern
|
||||
Yang Tse
|
||||
hpopescu at ixiacom.com
|
||||
liren at vivisimo.com
|
||||
nordsturm
|
||||
saghul
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
Contributing to c-ares
|
||||
======================
|
||||
|
||||
To contribute patches to c-ares, please generate a GitHub pull request
|
||||
and follow these guidelines:
|
||||
|
||||
- Check that the Travis builds are green for your pull request.
|
||||
- Please update the test suite to add a test case for any new functionality.
|
||||
- Build the library with `./configure --enable-debug --enable-maintainer-mode` and
|
||||
ensure there are no new warnings.
|
||||
|
||||
To improve the chances of the c-ares maintainers responding to your request:
|
||||
|
||||
- Also send an email to the mailing list at `c-ares@cool.haxx.se` describing your change.
|
||||
- To follow any associated discussion, please subscribe to the [mailing list](http://cool.haxx.se/mailman/listinfo/c-ares).
|
||||
@@ -1,7 +0,0 @@
|
||||
|
||||
CVS-INFO
|
||||
|
||||
This file is only present in the CVS - never in release archives. It is used
|
||||
as a sentinel file in buildconf.bat in order to differentiate a CVS checkout
|
||||
from release and daily snapshot archives.
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
GIT-INFO
|
||||
|
||||
This file is only present in git - never in release archives. It is used as a
|
||||
sentinel file in buildconf.bat in order to differentiate a git checkout from
|
||||
release and daily snapshot archives.
|
||||
|
||||
On *nix-like systems, run the ./buildconf script first to generate a fresh
|
||||
configure script.
|
||||
@@ -0,0 +1,328 @@
|
||||
** This file is adapted from libcurl and not yet fully rewritten for c-ares! **
|
||||
|
||||
___ __ _ _ __ ___ ___
|
||||
/ __| ___ / _` | '__/ _ \/ __|
|
||||
| (_ |___| (_| | | | __/\__ \
|
||||
\___| \__,_|_| \___||___/
|
||||
|
||||
How To Compile
|
||||
|
||||
Installing Binary Packages
|
||||
==========================
|
||||
|
||||
Lots of people download binary distributions of c-ares. This document
|
||||
does not describe how to install c-ares using such a binary package.
|
||||
This document describes how to compile, build and install c-ares from
|
||||
source code.
|
||||
|
||||
Building from git
|
||||
=================
|
||||
|
||||
If you get your code off a git repository, see the GIT-INFO file in the
|
||||
root directory for specific instructions on how to proceed.
|
||||
|
||||
UNIX
|
||||
====
|
||||
A normal unix installation is made in three or four steps (after you've
|
||||
unpacked the source archive):
|
||||
|
||||
./configure
|
||||
make
|
||||
make ahost adig acountry (optional)
|
||||
make install
|
||||
|
||||
You probably need to be root when doing the last command.
|
||||
|
||||
If you have checked out the sources from the git repository, read the
|
||||
GIT-INFO on how to proceed.
|
||||
|
||||
Get a full listing of all available configure options by invoking it like:
|
||||
|
||||
./configure --help
|
||||
|
||||
If you want to install c-ares in a different file hierarchy than /usr/local,
|
||||
you need to specify that already when running configure:
|
||||
|
||||
./configure --prefix=/path/to/c-ares/tree
|
||||
|
||||
If you happen to have write permission in that directory, you can do 'make
|
||||
install' without being root. An example of this would be to make a local
|
||||
install in your own home directory:
|
||||
|
||||
./configure --prefix=$HOME
|
||||
make
|
||||
make install
|
||||
|
||||
MORE OPTIONS
|
||||
------------
|
||||
|
||||
To force configure to use the standard cc compiler if both cc and gcc are
|
||||
present, run configure like
|
||||
|
||||
CC=cc ./configure
|
||||
or
|
||||
env CC=cc ./configure
|
||||
|
||||
To force a static library compile, disable the shared library creation
|
||||
by running configure like:
|
||||
|
||||
./configure --disable-shared
|
||||
|
||||
If you're a c-ares developer and use gcc, you might want to enable more
|
||||
debug options with the --enable-debug option.
|
||||
|
||||
SPECIAL CASES
|
||||
-------------
|
||||
Some versions of uClibc require configuring with CPPFLAGS=-D_GNU_SOURCE=1
|
||||
to get correct large file support.
|
||||
|
||||
The Open Watcom C compiler on Linux requires configuring with the variables:
|
||||
|
||||
./configure CC=owcc AR="$WATCOM/binl/wlib" AR_FLAGS=-q \
|
||||
RANLIB=/bin/true STRIP="$WATCOM/binl/wstrip" CFLAGS=-Wextra
|
||||
|
||||
|
||||
Win32
|
||||
=====
|
||||
|
||||
Building Windows DLLs and C run-time (CRT) linkage issues
|
||||
---------------------------------------------------------
|
||||
|
||||
As a general rule, building a DLL with static CRT linkage is highly
|
||||
discouraged, and intermixing CRTs in the same app is something to
|
||||
avoid at any cost.
|
||||
|
||||
Reading and comprehension of Microsoft Knowledge Base articles
|
||||
KB94248 and KB140584 is a must for any Windows developer. Especially
|
||||
important is full understanding if you are not going to follow the
|
||||
advice given above.
|
||||
|
||||
KB94248 - How To Use the C Run-Time
|
||||
http://support.microsoft.com/kb/94248/en-us
|
||||
|
||||
KB140584 - How to link with the correct C Run-Time (CRT) library
|
||||
http://support.microsoft.com/kb/140584/en-us
|
||||
|
||||
KB190799 - Potential Errors Passing CRT Objects Across DLL Boundaries
|
||||
http://msdn.microsoft.com/en-us/library/ms235460
|
||||
|
||||
If your app is misbehaving in some strange way, or it is suffering
|
||||
from memory corruption, before asking for further help, please try
|
||||
first to rebuild every single library your app uses as well as your
|
||||
app using the debug multithreaded dynamic C runtime.
|
||||
|
||||
MingW32
|
||||
-------
|
||||
|
||||
Make sure that MinGW32's bin dir is in the search path, for example:
|
||||
|
||||
set PATH=c:\mingw32\bin;%PATH%
|
||||
|
||||
then run 'make -f Makefile.m32' in the root dir.
|
||||
|
||||
Cygwin
|
||||
------
|
||||
|
||||
Almost identical to the unix installation. Run the configure script in the
|
||||
c-ares root with 'sh configure'. Make sure you have the sh executable in
|
||||
/bin/ or you'll see the configure fail toward the end.
|
||||
|
||||
Run 'make'
|
||||
|
||||
Dev-Cpp
|
||||
-------
|
||||
|
||||
See the separate INSTALL.devcpp file for details.
|
||||
|
||||
MSVC 6 caveats
|
||||
--------------
|
||||
|
||||
If you use MSVC 6 it is required that you use the February 2003 edition PSDK:
|
||||
http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm
|
||||
|
||||
MSVC from command line
|
||||
----------------------
|
||||
|
||||
Run the 'vcvars32.bat' file to get a proper environment. The
|
||||
vcvars32.bat file is part of the Microsoft development environment and
|
||||
you may find it in 'C:\Program Files\Microsoft Visual Studio\vc98\bin'
|
||||
provided that you installed Visual C/C++ 6 in the default directory.
|
||||
|
||||
Further details in README.msvc
|
||||
|
||||
MSVC IDES
|
||||
---------
|
||||
|
||||
Details in README.msvc
|
||||
|
||||
Important static c-ares usage note
|
||||
----------------------------------
|
||||
|
||||
When building an application that uses the static c-ares library, you must
|
||||
add '-DCARES_STATICLIB' to your CFLAGS. Otherwise the linker will look for
|
||||
dynamic import symbols.
|
||||
|
||||
|
||||
IBM OS/2
|
||||
========
|
||||
Building under OS/2 is not much different from building under unix.
|
||||
You need:
|
||||
|
||||
- emx 0.9d
|
||||
- GNU make
|
||||
- GNU patch
|
||||
- ksh
|
||||
- GNU bison
|
||||
- GNU file utilities
|
||||
- GNU sed
|
||||
- autoconf 2.13
|
||||
|
||||
If during the linking you get an error about _errno being an undefined
|
||||
symbol referenced from the text segment, you need to add -D__ST_MT_ERRNO__
|
||||
in your definitions.
|
||||
|
||||
If you're getting huge binaries, probably your makefiles have the -g in
|
||||
CFLAGS.
|
||||
|
||||
|
||||
QNX
|
||||
===
|
||||
(This section was graciously brought to us by David Bentham)
|
||||
|
||||
As QNX is targeted for resource constrained environments, the QNX headers
|
||||
set conservative limits. This includes the FD_SETSIZE macro, set by default
|
||||
to 32. Socket descriptors returned within the c-ares library may exceed this,
|
||||
resulting in memory faults/SIGSEGV crashes when passed into select(..)
|
||||
calls using fd_set macros.
|
||||
|
||||
A good all-round solution to this is to override the default when building
|
||||
c-ares, by overriding CFLAGS during configure, example
|
||||
# configure CFLAGS='-DFD_SETSIZE=64 -g -O2'
|
||||
|
||||
|
||||
RISC OS
|
||||
=======
|
||||
The library can be cross-compiled using gccsdk as follows:
|
||||
|
||||
CC=riscos-gcc AR=riscos-ar RANLIB='riscos-ar -s' ./configure \
|
||||
--host=arm-riscos-aof --without-random --disable-shared
|
||||
make
|
||||
|
||||
where riscos-gcc and riscos-ar are links to the gccsdk tools.
|
||||
You can then link your program with c-ares/lib/.libs/libcares.a
|
||||
|
||||
|
||||
NetWare
|
||||
=======
|
||||
To compile libcares.a / libcares.lib you need:
|
||||
- either any gcc / nlmconv, or CodeWarrior 7 PDK 4 or later.
|
||||
- gnu make and awk running on the platform you compile on;
|
||||
native Win32 versions can be downloaded from:
|
||||
http://www.gknw.net/development/prgtools/
|
||||
- recent Novell LibC SDK available from:
|
||||
http://developer.novell.com/ndk/libc.htm
|
||||
- or recent Novell CLib SDK available from:
|
||||
http://developer.novell.com/ndk/clib.htm
|
||||
|
||||
Set a search path to your compiler, linker and tools; on Linux make
|
||||
sure that the var OSTYPE contains the string 'linux'; set the var
|
||||
NDKBASE to point to the base of your Novell NDK; and then type
|
||||
'make -f Makefile.netware' from the top source directory;
|
||||
|
||||
|
||||
Android
|
||||
=======
|
||||
Method using a configure cross-compile (tested with Android NDK r7b):
|
||||
- prepare the toolchain of the Android NDK for standalone use; this can
|
||||
be done by invoking the script:
|
||||
./tools/make-standalone-toolchain.sh
|
||||
which creates a usual cross-compile toolchain. Lets assume that you put
|
||||
this toolchain below /opt then invoke configure with something like:
|
||||
export PATH=/opt/arm-linux-androideabi-4.4.3/bin:$PATH
|
||||
./configure --host=arm-linux-androideabi [more configure options]
|
||||
make
|
||||
- if you want to compile directly from our GIT repo you might run into
|
||||
this issue with older automake stuff:
|
||||
checking host system type...
|
||||
Invalid configuration `arm-linux-androideabi':
|
||||
system `androideabi' not recognized
|
||||
configure: error: /bin/sh ./config.sub arm-linux-androideabi failed
|
||||
this issue can be fixed with using more recent versions of config.sub
|
||||
and config.guess which can be obtained here:
|
||||
http://git.savannah.gnu.org/gitweb/?p=config.git;a=tree
|
||||
you need to replace your system-own versions which usually can be
|
||||
found in your automake folder:
|
||||
find /usr -name config.sub
|
||||
|
||||
|
||||
CROSS COMPILE
|
||||
=============
|
||||
(This section was graciously brought to us by Jim Duey, with additions by
|
||||
Dan Fandrich)
|
||||
|
||||
Download and unpack the c-ares package.
|
||||
|
||||
'cd' to the new directory. (e.g. cd c-ares-1.7.6)
|
||||
|
||||
Set environment variables to point to the cross-compile toolchain and call
|
||||
configure with any options you need. Be sure and specify the '--host' and
|
||||
'--build' parameters at configuration time. The following script is an
|
||||
example of cross-compiling for the IBM 405GP PowerPC processor using the
|
||||
toolchain from MonteVista for Hardhat Linux.
|
||||
|
||||
(begin script)
|
||||
|
||||
#! /bin/sh
|
||||
|
||||
export PATH=$PATH:/opt/hardhat/devkit/ppc/405/bin
|
||||
export CPPFLAGS="-I/opt/hardhat/devkit/ppc/405/target/usr/include"
|
||||
export AR=ppc_405-ar
|
||||
export AS=ppc_405-as
|
||||
export LD=ppc_405-ld
|
||||
export RANLIB=ppc_405-ranlib
|
||||
export CC=ppc_405-gcc
|
||||
export NM=ppc_405-nm
|
||||
|
||||
./configure --target=powerpc-hardhat-linux \
|
||||
--host=powerpc-hardhat-linux \
|
||||
--build=i586-pc-linux-gnu \
|
||||
--prefix=/opt/hardhat/devkit/ppc/405/target/usr/local \
|
||||
--exec-prefix=/usr/local
|
||||
|
||||
(end script)
|
||||
|
||||
You may also need to provide a parameter like '--with-random=/dev/urandom'
|
||||
to configure as it cannot detect the presence of a random number
|
||||
generating device for a target system. The '--prefix' parameter
|
||||
specifies where c-ares will be installed. If 'configure' completes
|
||||
successfully, do 'make' and 'make install' as usual.
|
||||
|
||||
In some cases, you may be able to simplify the above commands to as
|
||||
little as:
|
||||
|
||||
./configure --host=ARCH-OS
|
||||
|
||||
|
||||
PORTS
|
||||
=====
|
||||
This is a probably incomplete list of known hardware and operating systems
|
||||
that c-ares has been compiled for. If you know a system c-ares compiles and
|
||||
runs on, that isn't listed, please let us know!
|
||||
|
||||
- Alpha Tru64 v5.0 5.1
|
||||
- ARM Android 1.5, 2.1, 2.3
|
||||
- MIPS IRIX 6.2, 6.5
|
||||
- Power AIX 3.2.5, 4.2, 4.3.1, 4.3.2, 5.1, 5.2
|
||||
- i386 Linux 1.3, 2.0, 2.2, 2.3, 2.4, 2.6
|
||||
- i386 Novell NetWare
|
||||
- i386 Windows 95, 98, ME, NT, 2000, XP, 2003
|
||||
- x86_64 Linux
|
||||
|
||||
Useful URLs
|
||||
===========
|
||||
|
||||
c-ares https://c-ares.haxx.se/
|
||||
|
||||
MingW http://www.mingw.org/
|
||||
MinGW-w64 http://mingw-w64.sourceforge.net/
|
||||
OpenWatcom http://www.openwatcom.org/
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
# c-ares license
|
||||
|
||||
Copyright (c) 2007 - 2016, Daniel Stenberg with many contributors, see AUTHORS
|
||||
file.
|
||||
|
||||
Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted, provided that
|
||||
the above copyright notice appear in all copies and that both that copyright
|
||||
notice and this permission notice appear in supporting documentation, and that
|
||||
the name of M.I.T. not be used in advertising or publicity pertaining to
|
||||
distribution of the software without specific, written prior permission.
|
||||
M.I.T. makes no representations about the suitability of this software for any
|
||||
purpose. It is provided "as is" without express or implied warranty.
|
||||
+164
@@ -0,0 +1,164 @@
|
||||
#
|
||||
# Watcom / OpenWatcom / Win32 makefile for cares.
|
||||
# Quick hack by Guenter; comments to: /dev/nul
|
||||
#
|
||||
|
||||
!ifndef %watcom
|
||||
!error WATCOM environment variable not set!
|
||||
!else
|
||||
SYS_INCL = -I$(%watcom)\h\nt -I$(%watcom)\h
|
||||
SYS_LIBS = $(%watcom)\lib386\nt;$(%watcom)\lib386
|
||||
!endif
|
||||
|
||||
!ifdef %libname
|
||||
LIBNAME = $(%libname)
|
||||
!else
|
||||
LIBNAME = cares
|
||||
!endif
|
||||
TARGETS = $(LIBNAME).dll $(LIBNAME)_imp.lib $(LIBNAME).lib
|
||||
DEMOS = adig.exe ahost.exe acountry.exe
|
||||
|
||||
CC = wcc386
|
||||
LD = wlink
|
||||
AR = wlib
|
||||
RC = wrc
|
||||
|
||||
!ifdef __LOADDLL__
|
||||
! loaddll wcc386 wccd386
|
||||
! loaddll wpp386 wppd386
|
||||
! loaddll wlib wlibd
|
||||
!endif
|
||||
|
||||
!if $(__VERSION__) < 1250
|
||||
RM = del /q /f 2>NUL
|
||||
!else
|
||||
RM = rm -f
|
||||
!endif
|
||||
MD = mkdir
|
||||
RD = rmdir /q /s 2>NUL
|
||||
CP = copy
|
||||
|
||||
CFLAGS = -3r -mf -hc -zff -zgf -zq -zm -zc -s -fr=con -w2 -fpi -oilrtfm &
|
||||
-wcd=201 -bt=nt -d+ -dWIN32 -dCARES_BUILDING_LIBRARY &
|
||||
-dNTDDI_VERSION=0x05010000 -I. $(SYS_INCL)
|
||||
|
||||
LFLAGS = option quiet, map, caseexact, eliminate
|
||||
|
||||
!ifdef %debug
|
||||
DEBUG = -dDEBUG=1 -dDEBUGBUILD
|
||||
CFLAGS += -d3 $(DEBUG)
|
||||
LFLAGS += debug all
|
||||
!else
|
||||
CFLAGS += -d0
|
||||
!endif
|
||||
|
||||
CFLAGS += -d_WIN32_WINNT=0x0501
|
||||
|
||||
#
|
||||
# Change to suite.
|
||||
#
|
||||
!ifdef %use_watt32
|
||||
CFLAGS += -dWATT32 -I$(%watt_root)\inc
|
||||
!endif
|
||||
|
||||
OBJ_BASE = WC_Win32.obj
|
||||
LINK_ARG = $(OBJ_BASE)\dyn\wlink.arg
|
||||
LIB_ARG = $(OBJ_BASE)\stat\wlib.arg
|
||||
|
||||
# In order to process Makefile.inc wmake must be called with -u switch!
|
||||
!ifneq __MAKEOPTS__ -u
|
||||
!error You MUST call wmake with the -u switch!
|
||||
!else
|
||||
!include Makefile.inc
|
||||
!endif
|
||||
|
||||
OBJS = $(CSOURCES:.c=.obj)
|
||||
OBJS = $OBJ_DIR\$(OBJS: = $OBJ_DIR\)
|
||||
|
||||
#
|
||||
# Use $(OBJS) as a template to generate $(OBJS_STAT) and $(OBJS_DYN).
|
||||
#
|
||||
OBJ_DIR = $(OBJ_BASE)\stat
|
||||
OBJS_STAT = $+ $(OBJS) $-
|
||||
|
||||
OBJ_DIR = $(OBJ_BASE)\dyn
|
||||
OBJS_DYN = $+ $(OBJS) $-
|
||||
|
||||
ARESBUILDH = ares_build.h
|
||||
RESOURCE = $(OBJ_BASE)\dyn\cares.res
|
||||
|
||||
all: $(ARESBUILDH) $(OBJ_BASE) $(TARGETS) $(DEMOS) .SYMBOLIC
|
||||
@echo Welcome to cares
|
||||
|
||||
$(OBJ_BASE):
|
||||
-$(MD) $^@
|
||||
-$(MD) $^@\stat
|
||||
-$(MD) $^@\dyn
|
||||
-$(MD) $^@\demos
|
||||
|
||||
$(ARESBUILDH): .EXISTSONLY
|
||||
$(CP) $^@.dist $^@
|
||||
|
||||
$(LIBNAME).dll: $(OBJS_DYN) $(RESOURCE) $(LINK_ARG)
|
||||
$(LD) name $^@ @$]@
|
||||
|
||||
$(LIBNAME).lib: $(OBJS_STAT) $(LIB_ARG)
|
||||
$(AR) -q -b -c $^@ @$]@
|
||||
|
||||
adig.exe: $(OBJ_BASE)\demos\adig.obj $(OBJ_BASE)\demos\ares_getopt.obj $(LIBNAME).lib
|
||||
$(LD) name $^@ system nt $(LFLAGS) file { $(OBJ_BASE)\demos\ares_getopt.obj $[@ } library $]@, ws2_32.lib
|
||||
|
||||
ahost.exe: $(OBJ_BASE)\demos\ahost.obj $(OBJ_BASE)\demos\ares_getopt.obj $(LIBNAME).lib
|
||||
$(LD) name $^@ system nt $(LFLAGS) file { $(OBJ_BASE)\demos\ares_getopt.obj $[@ } library $]@, ws2_32.lib
|
||||
|
||||
acountry.exe: $(OBJ_BASE)\demos\acountry.obj $(OBJ_BASE)\demos\ares_getopt.obj $(LIBNAME).lib
|
||||
$(LD) name $^@ system nt $(LFLAGS) file { $(OBJ_BASE)\demos\ares_getopt.obj $[@ } library $]@, ws2_32.lib
|
||||
|
||||
clean: .SYMBOLIC
|
||||
-$(RM) $(OBJS_STAT)
|
||||
-$(RM) $(OBJS_DYN)
|
||||
-$(RM) $(RESOURCE) $(LINK_ARG) $(LIB_ARG)
|
||||
|
||||
vclean realclean: clean .SYMBOLIC
|
||||
-$(RM) $(TARGETS) $(LIBNAME).map
|
||||
-$(RM) $(DEMOS) $(DEMOS:.exe=.map)
|
||||
-$(RD) $(OBJ_BASE)\stat
|
||||
-$(RD) $(OBJ_BASE)\dyn
|
||||
-$(RD) $(OBJ_BASE)\demos
|
||||
-$(RD) $(OBJ_BASE)
|
||||
|
||||
.ERASE
|
||||
$(RESOURCE): cares.rc .AUTODEPEND
|
||||
$(RC) $(DEBUG) -q -r -zm -I..\include $(SYS_INCL) $[@ -fo=$^@
|
||||
|
||||
.ERASE
|
||||
.c{$(OBJ_BASE)\dyn}.obj:
|
||||
$(CC) $(CFLAGS) -bd $[@ -fo=$^@
|
||||
|
||||
.ERASE
|
||||
.c{$(OBJ_BASE)\stat}.obj:
|
||||
$(CC) $(CFLAGS) -DCARES_STATICLIB $[@ -fo=$^@
|
||||
|
||||
.ERASE
|
||||
.c{$(OBJ_BASE)\demos}.obj:
|
||||
$(CC) $(CFLAGS) -DCARES_STATICLIB $[@ -fo=$^@
|
||||
|
||||
$(LINK_ARG): $(__MAKEFILES__)
|
||||
%create $^@
|
||||
@%append $^@ system nt dll
|
||||
@%append $^@ file { $(OBJS_DYN) }
|
||||
@%append $^@ option res=$(RESOURCE), implib=$(LIBNAME)_imp.lib
|
||||
@%append $^@ $(LFLAGS)
|
||||
@%append $^@ libpath $(SYS_LIBS)
|
||||
# @%append $^@ library clib3r.lib
|
||||
!ifdef %use_watt32
|
||||
@%append $^@ library $(%watt_root)\lib\wattcpw_imp.lib
|
||||
!else
|
||||
@%append $^@ library ws2_32.lib
|
||||
!endif
|
||||
|
||||
$(LIB_ARG): $(__MAKEFILES__)
|
||||
%create $^@
|
||||
@for %f in ($(OBJS_STAT)) do @%append $^@ +- %f
|
||||
|
||||
|
||||
+58
-16
@@ -22,16 +22,16 @@ ACLOCAL_AMFLAGS = -I m4
|
||||
# $(top_srcdir) is for c-ares's ares_setup.h and other "c-ares-private" files
|
||||
|
||||
if CURLDEBUG
|
||||
INCLUDES = -I$(top_builddir)/../include/curl \
|
||||
-I$(top_builddir)/../include \
|
||||
-I$(top_srcdir)/../include \
|
||||
-I$(top_builddir)/../lib \
|
||||
-I$(top_srcdir)/../lib \
|
||||
-I$(top_builddir) \
|
||||
-I$(top_srcdir)
|
||||
AM_CPPFLAGS = -I$(top_builddir)/../include/curl \
|
||||
-I$(top_builddir)/../include \
|
||||
-I$(top_srcdir)/../include \
|
||||
-I$(top_builddir)/../lib \
|
||||
-I$(top_srcdir)/../lib \
|
||||
-I$(top_builddir) \
|
||||
-I$(top_srcdir)
|
||||
else
|
||||
INCLUDES = -I$(top_builddir) \
|
||||
-I$(top_srcdir)
|
||||
AM_CPPFLAGS = -I$(top_builddir) \
|
||||
-I$(top_srcdir)
|
||||
endif
|
||||
|
||||
lib_LTLIBRARIES = libcares.la
|
||||
@@ -52,18 +52,22 @@ noinst_PROGRAMS =$(PROGS)
|
||||
# adig and ahost are just sample programs and thus not mentioned with the
|
||||
# regular sources and headers
|
||||
EXTRA_DIST = AUTHORS CHANGES README.cares Makefile.inc Makefile.dj \
|
||||
Makefile.m32 Makefile.netware Makefile.msvc $(man_MANS) $(MSVCFILES) \
|
||||
Makefile.m32 Makefile.netware Makefile.msvc Makefile.Watcom $(man_MANS) \
|
||||
config-win32.h RELEASE-NOTES libcares.pc.in buildconf get_ver.awk maketgz \
|
||||
TODO ares_build.h.in $(PDFPAGES) cares.rc README.msvc
|
||||
TODO ares_build.h.in $(PDFPAGES) cares.rc README.msvc $(MSVCFILES) \
|
||||
$(CSOURCES) $(HHEADERS) config-dos.h acountry.1 adig.1 ahost.1 INSTALL \
|
||||
README.md LICENSE.md
|
||||
|
||||
CLEANFILES = $(PDFPAGES) $(HTMLPAGES)
|
||||
|
||||
DISTCLEANFILES = ares_build.h
|
||||
|
||||
DIST_SUBDIRS = test
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libcares.pc
|
||||
|
||||
VER=-version-info 2:0:0
|
||||
CARES_VERSION_INFO = -version-info 4:0:2
|
||||
# This flag accepts an argument of the form current[:revision[:age]]. So,
|
||||
# passing -version-info 3:12:1 sets current to 3, revision to 12, and age to
|
||||
# 1.
|
||||
@@ -92,12 +96,47 @@ VER=-version-info 2:0:0
|
||||
# set age to 0. (c:r:a=0)
|
||||
#
|
||||
|
||||
if NO_UNDEFINED
|
||||
# The -no-undefined flag is crucial for this to build fine on some platforms
|
||||
UNDEF = -no-undefined
|
||||
AM_LDFLAGS =
|
||||
|
||||
libcares_la_LDFLAGS_EXTRA =
|
||||
|
||||
if CARES_LT_SHLIB_USE_VERSION_INFO
|
||||
libcares_la_LDFLAGS_EXTRA += $(CARES_VERSION_INFO)
|
||||
endif
|
||||
|
||||
libcares_la_LDFLAGS = $(UNDEF) $(VER)
|
||||
if CARES_LT_SHLIB_USE_NO_UNDEFINED
|
||||
libcares_la_LDFLAGS_EXTRA += -no-undefined
|
||||
endif
|
||||
|
||||
if CARES_LT_SHLIB_USE_MIMPURE_TEXT
|
||||
libcares_la_LDFLAGS_EXTRA += -mimpure-text
|
||||
endif
|
||||
|
||||
libcares_la_LDFLAGS = $(AM_LDFLAGS) $(libcares_la_LDFLAGS_EXTRA)
|
||||
|
||||
# Add -Werror if defined
|
||||
CFLAGS += @CARES_CFLAG_EXTRAS@
|
||||
|
||||
if USE_CPPFLAG_CARES_STATICLIB
|
||||
AM_CPPFLAGS += $(CPPFLAG_CARES_STATICLIB)
|
||||
endif
|
||||
|
||||
libcares_la_CFLAGS_EXTRA =
|
||||
|
||||
libcares_la_CPPFLAGS_EXTRA = -DCARES_BUILDING_LIBRARY
|
||||
|
||||
if DOING_CARES_SYMBOL_HIDING
|
||||
libcares_la_CFLAGS_EXTRA += $(CFLAG_CARES_SYMBOL_HIDING)
|
||||
libcares_la_CPPFLAGS_EXTRA += -DCARES_SYMBOL_HIDING
|
||||
endif
|
||||
|
||||
@CODE_COVERAGE_RULES@
|
||||
libcares_la_LDFLAGS += $(CODE_COVERAGE_LDFLAGS)
|
||||
libcares_la_CFLAGS_EXTRA += $(CODE_COVERAGE_CFLAGS)
|
||||
|
||||
libcares_la_CFLAGS = $(AM_CFLAGS) $(libcares_la_CFLAGS_EXTRA)
|
||||
|
||||
libcares_la_CPPFLAGS = $(AM_CPPFLAGS) $(libcares_la_CPPFLAGS_EXTRA)
|
||||
|
||||
# Makefile.inc provides the CSOURCES and HHEADERS defines
|
||||
include Makefile.inc
|
||||
@@ -113,14 +152,17 @@ libcares_la_HEADERS = ares.h ares_version.h ares_dns.h \
|
||||
ahost_SOURCES = ahost.c $(SAMPLESOURCES) $(SAMPLEHEADERS)
|
||||
ahost_LDADD = $(top_builddir)/libcares.la
|
||||
ahost_CFLAGS = $(AM_CFLAGS)
|
||||
ahost_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
adig_SOURCES = adig.c $(SAMPLESOURCES) $(SAMPLEHEADERS)
|
||||
adig_LDADD = $(top_builddir)/libcares.la
|
||||
adig_CFLAGS = $(AM_CFLAGS)
|
||||
adig_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
acountry_SOURCES = acountry.c $(SAMPLESOURCES) $(SAMPLEHEADERS)
|
||||
acountry_LDADD = $(top_builddir)/libcares.la
|
||||
acountry_CFLAGS = $(AM_CFLAGS)
|
||||
acountry_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
SOURCEDMANDIR = man3
|
||||
SOURCEDMANPAGES = ares_init.3
|
||||
|
||||
+2
-3
@@ -1,8 +1,7 @@
|
||||
#
|
||||
# c-ares Makefile for djgpp/gcc/Watt-32.
|
||||
# By Gisle Vanem <gvanem@broadpark.no> 2004.
|
||||
# By Gisle Vanem <gvanem@yahoo.no> 2004.
|
||||
#
|
||||
# $Id$
|
||||
|
||||
|
||||
TOPDIR = ..
|
||||
@@ -45,7 +44,7 @@ all: $(OBJ_DIR) ares_config.h libcares.a ahost.exe adig.exe acountry.exe
|
||||
libcares.a: $(OBJECTS)
|
||||
ar rs $@ $?
|
||||
|
||||
ares_config.h: config.dos
|
||||
ares_config.h: config-dos.h
|
||||
$(COPY) $^ $@
|
||||
|
||||
ahost.exe: ahost.c $(OBJ_DIR)/ares_getopt.o $(OBJ_HACK)
|
||||
|
||||
+71
-12
@@ -11,6 +11,7 @@ CSOURCES = ares__close_sockets.c \
|
||||
ares_fds.c \
|
||||
ares_free_hostent.c \
|
||||
ares_free_string.c \
|
||||
ares_getenv.c \
|
||||
ares_gethostbyaddr.c \
|
||||
ares_gethostbyname.c \
|
||||
ares_getnameinfo.c \
|
||||
@@ -19,12 +20,19 @@ CSOURCES = ares__close_sockets.c \
|
||||
ares_library_init.c \
|
||||
ares_llist.c \
|
||||
ares_mkquery.c \
|
||||
ares_create_query.c \
|
||||
ares_nowarn.c \
|
||||
ares_options.c \
|
||||
ares_parse_a_reply.c \
|
||||
ares_parse_aaaa_reply.c \
|
||||
ares_parse_mx_reply.c \
|
||||
ares_parse_naptr_reply.c \
|
||||
ares_parse_ns_reply.c \
|
||||
ares_parse_ptr_reply.c \
|
||||
ares_parse_soa_reply.c \
|
||||
ares_parse_srv_reply.c \
|
||||
ares_parse_txt_reply.c \
|
||||
ares_platform.c \
|
||||
ares_process.c \
|
||||
ares_query.c \
|
||||
ares_search.c \
|
||||
@@ -38,15 +46,21 @@ CSOURCES = ares__close_sockets.c \
|
||||
bitncmp.c \
|
||||
inet_net_pton.c \
|
||||
inet_ntop.c \
|
||||
windows_port.c
|
||||
windows_port.c \
|
||||
amiga_port.c
|
||||
|
||||
HHEADERS = ares.h \
|
||||
ares_build.h \
|
||||
ares_data.h \
|
||||
ares_dns.h \
|
||||
ares_getenv.h \
|
||||
ares_inet_net_pton.h \
|
||||
ares_iphlpapi.h \
|
||||
ares_ipv6.h \
|
||||
ares_library_init.h \
|
||||
ares_llist.h \
|
||||
ares_nowarn.h \
|
||||
ares_platform.h \
|
||||
ares_private.h \
|
||||
ares_rules.h \
|
||||
ares_strcasecmp.h \
|
||||
@@ -54,8 +68,6 @@ HHEADERS = ares.h \
|
||||
ares_version.h \
|
||||
ares_writev.h \
|
||||
bitncmp.h \
|
||||
inet_net_pton.h \
|
||||
inet_ntop.h \
|
||||
nameser.h \
|
||||
ares_setup.h \
|
||||
setup_once.h
|
||||
@@ -70,6 +82,8 @@ MANPAGES = ares_cancel.3 \
|
||||
ares_free_data.3 \
|
||||
ares_free_hostent.3 \
|
||||
ares_free_string.3 \
|
||||
ares_get_servers.3 \
|
||||
ares_get_servers_ports.3 \
|
||||
ares_gethostbyaddr.3 \
|
||||
ares_gethostbyname.3 \
|
||||
ares_gethostbyname_file.3 \
|
||||
@@ -80,10 +94,14 @@ MANPAGES = ares_cancel.3 \
|
||||
ares_library_cleanup.3 \
|
||||
ares_library_init.3 \
|
||||
ares_mkquery.3 \
|
||||
ares_create_query.3 \
|
||||
ares_parse_a_reply.3 \
|
||||
ares_parse_aaaa_reply.3 \
|
||||
ares_parse_mx_reply.3 \
|
||||
ares_parse_naptr_reply.3 \
|
||||
ares_parse_ns_reply.3 \
|
||||
ares_parse_ptr_reply.3 \
|
||||
ares_parse_soa_reply.3 \
|
||||
ares_parse_srv_reply.3 \
|
||||
ares_parse_txt_reply.3 \
|
||||
ares_process.3 \
|
||||
@@ -91,10 +109,21 @@ MANPAGES = ares_cancel.3 \
|
||||
ares_save_options.3 \
|
||||
ares_search.3 \
|
||||
ares_send.3 \
|
||||
ares_set_local_dev.3 \
|
||||
ares_set_local_ip4.3 \
|
||||
ares_set_local_ip6.3 \
|
||||
ares_set_servers.3 \
|
||||
ares_set_servers_csv.3 \
|
||||
ares_set_servers_ports.3 \
|
||||
ares_set_servers_ports_csv.3 \
|
||||
ares_set_socket_callback.3 \
|
||||
ares_set_socket_configure_callback.3 \
|
||||
ares_set_sortlist.3 \
|
||||
ares_strerror.3 \
|
||||
ares_timeout.3 \
|
||||
ares_version.3
|
||||
ares_version.3 \
|
||||
ares_inet_pton.3 \
|
||||
ares_inet_ntop.3
|
||||
|
||||
HTMLPAGES = ares_cancel.html \
|
||||
ares_destroy.html \
|
||||
@@ -106,6 +135,8 @@ HTMLPAGES = ares_cancel.html \
|
||||
ares_free_data.html \
|
||||
ares_free_hostent.html \
|
||||
ares_free_string.html \
|
||||
ares_get_servers.html \
|
||||
ares_get_servers_ports.html \
|
||||
ares_gethostbyaddr.html \
|
||||
ares_gethostbyname.html \
|
||||
ares_gethostbyname_file.html \
|
||||
@@ -116,10 +147,13 @@ HTMLPAGES = ares_cancel.html \
|
||||
ares_library_cleanup.html \
|
||||
ares_library_init.html \
|
||||
ares_mkquery.html \
|
||||
ares_create_query.html \
|
||||
ares_parse_a_reply.html \
|
||||
ares_parse_aaaa_reply.html \
|
||||
ares_parse_mx_reply.html \
|
||||
ares_parse_ns_reply.html \
|
||||
ares_parse_ptr_reply.html \
|
||||
ares_parse_soa_reply.html \
|
||||
ares_parse_srv_reply.html \
|
||||
ares_parse_txt_reply.html \
|
||||
ares_process.html \
|
||||
@@ -127,10 +161,21 @@ HTMLPAGES = ares_cancel.html \
|
||||
ares_save_options.html \
|
||||
ares_search.html \
|
||||
ares_send.html \
|
||||
ares_set_local_dev.html \
|
||||
ares_set_local_ip4.html \
|
||||
ares_set_local_ip6.html \
|
||||
ares_set_servers.html \
|
||||
ares_set_servers_csv.html \
|
||||
ares_set_servers_ports.html \
|
||||
ares_set_servers_ports_csv.html \
|
||||
ares_set_socket_callback.html \
|
||||
ares_set_socket_configure_callback.html \
|
||||
ares_set_sortlist.html \
|
||||
ares_strerror.html \
|
||||
ares_timeout.html \
|
||||
ares_version.html
|
||||
ares_version.html \
|
||||
ares_inet_pton.html \
|
||||
ares_inet_ntop.html
|
||||
|
||||
PDFPAGES = ares_cancel.pdf \
|
||||
ares_destroy.pdf \
|
||||
@@ -142,6 +187,8 @@ PDFPAGES = ares_cancel.pdf \
|
||||
ares_free_data.pdf \
|
||||
ares_free_hostent.pdf \
|
||||
ares_free_string.pdf \
|
||||
ares_get_servers.pdf \
|
||||
ares_get_servers_ports.pdf \
|
||||
ares_gethostbyaddr.pdf \
|
||||
ares_gethostbyname.pdf \
|
||||
ares_gethostbyname_file.pdf \
|
||||
@@ -152,10 +199,13 @@ PDFPAGES = ares_cancel.pdf \
|
||||
ares_library_cleanup.pdf \
|
||||
ares_library_init.pdf \
|
||||
ares_mkquery.pdf \
|
||||
ares_create_query.pdf \
|
||||
ares_parse_a_reply.pdf \
|
||||
ares_parse_aaaa_reply.pdf \
|
||||
ares_parse_mx_reply.pdf \
|
||||
ares_parse_ns_reply.pdf \
|
||||
ares_parse_ptr_reply.pdf \
|
||||
ares_parse_soa_reply.pdf \
|
||||
ares_parse_srv_reply.pdf \
|
||||
ares_parse_txt_reply.pdf \
|
||||
ares_process.pdf \
|
||||
@@ -163,17 +213,26 @@ PDFPAGES = ares_cancel.pdf \
|
||||
ares_save_options.pdf \
|
||||
ares_search.pdf \
|
||||
ares_send.pdf \
|
||||
ares_set_local_dev.pdf \
|
||||
ares_set_local_ip4.pdf \
|
||||
ares_set_local_ip6.pdf \
|
||||
ares_set_servers.pdf \
|
||||
ares_set_servers_csv.pdf \
|
||||
ares_set_servers_ports.pdf \
|
||||
ares_set_servers_ports_csv.pdf \
|
||||
ares_set_socket_callback.pdf \
|
||||
ares_set_socket_configure_callback.pdf \
|
||||
ares_set_sortlist.pdf \
|
||||
ares_strerror.pdf \
|
||||
ares_timeout.pdf \
|
||||
ares_version.pdf
|
||||
ares_version.pdf \
|
||||
ares_inet_pton.pdf \
|
||||
ares_inet_ntop.pdf
|
||||
|
||||
SAMPLESOURCES = ares_getopt.c \
|
||||
ares_strcasecmp.c \
|
||||
inet_net_pton.c \
|
||||
inet_ntop.c
|
||||
ares_nowarn.c \
|
||||
ares_strcasecmp.c
|
||||
|
||||
SAMPLEHEADERS = ares_getopt.h \
|
||||
ares_strcasecmp.h \
|
||||
inet_net_pton.h \
|
||||
inet_ntop.h
|
||||
ares_nowarn.h \
|
||||
ares_strcasecmp.h
|
||||
|
||||
+15
-8
@@ -1,5 +1,4 @@
|
||||
#############################################################
|
||||
# $Id$
|
||||
#
|
||||
## Makefile for building libcares.a with MingW32 (GCC-3.2)
|
||||
## Use: make -f Makefile.m32 [demos]
|
||||
@@ -11,13 +10,16 @@
|
||||
|
||||
LIB = libcares.a
|
||||
|
||||
CC = gcc
|
||||
LD = gcc
|
||||
RANLIB = ranlib
|
||||
AR = $(CROSSPREFIX)ar
|
||||
CC = $(CROSSPREFIX)gcc
|
||||
LD = $(CROSSPREFIX)gcc
|
||||
RANLIB = $(CROSSPREFIX)ranlib
|
||||
#RM = rm -f
|
||||
CP = cp -afv
|
||||
|
||||
CFLAGS = -O2 -Wall
|
||||
LDFLAGS = -s
|
||||
CFLAGS = $(CARES_CFLAG_EXTRAS) -O2 -Wall -I.
|
||||
CFLAGS += -DCARES_STATICLIB
|
||||
LDFLAGS = $(CARES_LDFLAG_EXTRAS) -s
|
||||
LIBS = -lwsock32
|
||||
|
||||
# Makefile.inc provides the CSOURCES and HHEADERS defines
|
||||
@@ -27,7 +29,7 @@ OBJLIB := $(patsubst %.c,%.o,$(strip $(CSOURCES)))
|
||||
|
||||
|
||||
$(LIB): $(OBJLIB)
|
||||
ar cru $@ $^
|
||||
$(AR) cru $@ $^
|
||||
$(RANLIB) $@
|
||||
|
||||
all: $(LIB) demos
|
||||
@@ -45,6 +47,9 @@ $(OBJLIB): ares.h ares_dns.h ares_private.h ares_build.h ares_rules.h
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -c $<
|
||||
|
||||
ares_build.h:
|
||||
$(CP) ares_build.h.dist ares_build.h
|
||||
|
||||
check:
|
||||
|
||||
install:
|
||||
@@ -66,4 +71,6 @@ clean:
|
||||
|
||||
distclean: clean
|
||||
$(RM) config.cache config.log config.status Makefile
|
||||
|
||||
ifeq "$(wildcard ares_build.h.dist)" "ares_build.h.dist"
|
||||
$(RM) ares_build.h
|
||||
endif
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
AR = m68k-amigaos-ar
|
||||
CC = m68k-amigaos-gcc
|
||||
LD = m68k-amigaos-gcc
|
||||
RANLIB = m68k-amigaos-ranlib
|
||||
RM = rm -f
|
||||
CFLAGS = -O2 -Wall -I. -Iinclude -DHAVE_CONFIG_H -DCARES_STATICLIB -DAMIGA -DAOS3
|
||||
LDFLAGS = -noixemul -s
|
||||
LIBS = -lm
|
||||
|
||||
LIB = libcares.a
|
||||
LIBH = ares.h ares_build.h ares_rules.h
|
||||
|
||||
# Makefile.inc provides the CSOURCES and HHEADERS defines
|
||||
include Makefile.inc
|
||||
|
||||
OBJLIB := $(patsubst %.c,%.o,$(strip $(CSOURCES)))
|
||||
|
||||
all: $(LIB) dig host country doc
|
||||
|
||||
dig: adig.o ares_getopt.o $(LIB)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o dig adig.o ares_getopt.o $(LIB) $(LIBS)
|
||||
|
||||
host: ahost.o ares_getopt.o $(LIB)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o host ahost.o ares_getopt.o $(LIB) $(LIBS)
|
||||
|
||||
country: acountry.o ares_getopt.o $(LIB)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o country acountry.o ares_getopt.o $(LIB) $(LIBS)
|
||||
|
||||
$(LIB): $(OBJLIB)
|
||||
$(AR) cru $@ $^
|
||||
$(RANLIB) $@
|
||||
|
||||
doc:
|
||||
./workman1 adig.1 >dig.txt
|
||||
./workman2 adig.1 >dig.help
|
||||
./workman1 ahost.1 >host.txt
|
||||
./workman2 ahost.1 >host.help
|
||||
./workman1 acountry.1 >country.txt
|
||||
./workman2 acountry.1 >country.help
|
||||
|
||||
tags:
|
||||
etags *.[ch]
|
||||
|
||||
$(OBJLIB): ares.h ares_dns.h ares_private.h ares_build.h ares_rules.h
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -c $<
|
||||
|
||||
clean:
|
||||
$(RM) adig.o ahost.o acountry.o ares_getopt.o $(OBJLIB) $(LIB) dig host country dig.txt dig.help host.txt host.help country.txt country.help
|
||||
|
||||
distclean: clean
|
||||
$(RM) config.cache config.log config.status Makefile
|
||||
ifeq "$(wildcard ares_build.h.dist)" "ares_build.h.dist"
|
||||
$(RM) ares_build.h
|
||||
endif
|
||||
|
||||
+51
-47
@@ -1,6 +1,5 @@
|
||||
# $Id$
|
||||
|
||||
# Copyright (C) 2009 by Daniel Stenberg
|
||||
# Copyright (C) 2009-2013 by Daniel Stenberg
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this
|
||||
# software and its documentation for any purpose and without
|
||||
@@ -19,12 +18,12 @@
|
||||
# Makefile for building c-ares libraries and sample programs with MSVC.
|
||||
#
|
||||
# Usage: nmake /f makefile.msvc CFG=<config> <target>
|
||||
#
|
||||
#
|
||||
# <config> must be one of: [ lib-release | lib-debug | dll-release | dll-debug }
|
||||
# <target> must be one of: [ ALL | c-ares | acountry | adig | ahost | clean }
|
||||
#
|
||||
#
|
||||
# If a <target> other than ALL or clean is given, <config> becomes mandatory.
|
||||
#
|
||||
#
|
||||
# If neither <config> nor <target> are specified this results in
|
||||
# all targets being built for all <config> c-ares library types.
|
||||
#
|
||||
@@ -72,46 +71,10 @@ RTLIBD = /MTd
|
||||
|
||||
USE_WATT32 = 0
|
||||
|
||||
# -------------------------------------------
|
||||
# Detect NMAKE version deducing MSVC version
|
||||
# -------------------------------------------
|
||||
|
||||
!IFNDEF _NMAKE_VER
|
||||
! MESSAGE Macro _NMAKE_VER not defined.
|
||||
! MESSAGE Use MSVC's NMAKE to process this makefile.
|
||||
! ERROR See previous message.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(_NMAKE_VER)" == "6.00.8168.0"
|
||||
CC_VERS_NUM = 60
|
||||
!ELSEIF "$(_NMAKE_VER)" == "6.00.9782.0"
|
||||
CC_VERS_NUM = 60
|
||||
!ELSEIF "$(_NMAKE_VER)" == "7.00.9466"
|
||||
CC_VERS_NUM = 70
|
||||
!ELSEIF "$(_NMAKE_VER)" == "7.00.9955"
|
||||
CC_VERS_NUM = 70
|
||||
!ELSEIF "$(_NMAKE_VER)" == "7.10.3077"
|
||||
CC_VERS_NUM = 71
|
||||
!ELSEIF "$(_NMAKE_VER)" == "8.00.40607.16"
|
||||
CC_VERS_NUM = 80
|
||||
!ELSEIF "$(_NMAKE_VER)" == "8.00.50727.42"
|
||||
CC_VERS_NUM = 80
|
||||
!ELSEIF "$(_NMAKE_VER)" == "8.00.50727.762"
|
||||
CC_VERS_NUM = 80
|
||||
!ELSEIF "$(_NMAKE_VER)" == "9.00.21022.08"
|
||||
CC_VERS_NUM = 90
|
||||
!ELSEIF "$(_NMAKE_VER)" == "9.00.30729.01"
|
||||
CC_VERS_NUM = 90
|
||||
!ELSEIF "$(_NMAKE_VER)" == "10.00.20506.01"
|
||||
CC_VERS_NUM = 100
|
||||
!ELSE
|
||||
! MESSAGE Unknown value for _NMAKE_VER macro: "$(_NMAKE_VER)"
|
||||
! MESSAGE Please, report this condition on the c-ares development
|
||||
! MESSAGE mailing list: http://cool.haxx.se/mailman/listinfo/c-ares/
|
||||
! ERROR See previous message.
|
||||
!ENDIF
|
||||
|
||||
CC_VERS_STR = msvc$(CC_VERS_NUM)
|
||||
# --------------------------------------------------------
|
||||
# Detect compiler version.
|
||||
# --------------------------------------------------------
|
||||
!INCLUDE .\msvc_ver.inc
|
||||
|
||||
# ----------------------------------------------------
|
||||
# Verify that current subdir is the c-ares source one
|
||||
@@ -136,6 +99,22 @@ BASE_DIR = .\$(CC_VERS_STR)
|
||||
|
||||
SRCDIR = .
|
||||
|
||||
# -----------------------------
|
||||
# Default installation subdirs
|
||||
# -----------------------------
|
||||
|
||||
!IFNDEF INSTALL_DIR
|
||||
INSTALL_DIR = .
|
||||
!ENDIF
|
||||
|
||||
!IFNDEF INSTALL_DIR_LIB
|
||||
INSTALL_DIR_LIB = $(INSTALL_DIR)\lib
|
||||
!ENDIF
|
||||
|
||||
!IFNDEF INSTALL_DIR_INC
|
||||
INSTALL_DIR_INC = $(INSTALL_DIR)\include
|
||||
!ENDIF
|
||||
|
||||
# -------------------------
|
||||
# Configuration validation
|
||||
# -------------------------
|
||||
@@ -222,13 +201,19 @@ PDBTYPE_CONSOLIDATE = /pdbtype:consolidate
|
||||
!UNDEF PDBTYPE_CONSOLIDATE
|
||||
!ENDIF
|
||||
|
||||
!IF $(CC_VERS_NUM) <= 70
|
||||
RT_ERROR_CHECKING = /GZ
|
||||
!ELSE
|
||||
RT_ERROR_CHECKING = /RTCsu
|
||||
!ENDIF
|
||||
|
||||
# ----------------------------
|
||||
# Assorted commands and flags
|
||||
# ----------------------------
|
||||
|
||||
CC_CMD_REL = cl.exe /nologo $(RTLIB) /DNDEBUG /O2
|
||||
CC_CMD_DBG = cl.exe /nologo $(RTLIBD) /D_DEBUG /Od /Zi /GZ
|
||||
CC_CFLAGS = $(CFLAGS) /I. /W3 /GX /FD
|
||||
CC_CMD_DBG = cl.exe /nologo $(RTLIBD) /D_DEBUG /Od /Zi $(RT_ERROR_CHECKING)
|
||||
CC_CFLAGS = $(CFLAGS) /I. /W3 /EHsc /FD
|
||||
|
||||
RC_CMD_REL = rc.exe /l 0x409 /d "NDEBUG"
|
||||
RC_CMD_DBG = rc.exe /l 0x409 /d "_DEBUG"
|
||||
@@ -388,6 +373,12 @@ ALL:
|
||||
clean:
|
||||
@-RMDIR /S /Q $(BASE_DIR) >NUL 2>&1
|
||||
|
||||
install:
|
||||
@$(MAKE) /nologo /f .\Makefile.msvc CFG=lib-release install
|
||||
@$(MAKE) /nologo /f .\Makefile.msvc CFG=lib-debug install
|
||||
@$(MAKE) /nologo /f .\Makefile.msvc CFG=dll-release install
|
||||
@$(MAKE) /nologo /f .\Makefile.msvc CFG=dll-debug install
|
||||
|
||||
!ENDIF
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
@@ -447,6 +438,19 @@ clean:
|
||||
@-RMDIR /S /Q $(PROG2_OUTDIR) >NUL 2>&1
|
||||
@-RMDIR /S /Q $(PROG3_OUTDIR) >NUL 2>&1
|
||||
|
||||
install:
|
||||
@if not exist $(CARES_OUTDIR)\$(CARES_TARGET) \
|
||||
$(MAKE) /f .\Makefile.msvc CFG=$(CFG) c-ares
|
||||
@if not exist "$(INSTALL_DIR)" mkdir "$(INSTALL_DIR)"
|
||||
@if not exist "$(INSTALL_DIR_LIB)" mkdir "$(INSTALL_DIR_LIB)"
|
||||
@if not exist "$(INSTALL_DIR_INC)" mkdir "$(INSTALL_DIR_INC)"
|
||||
@copy /y $(CARES_OUTDIR)\*.* "$(INSTALL_DIR_LIB)" >NUL
|
||||
@copy /y $(SRCDIR)\ares.h "$(INSTALL_DIR_INC)" >NUL
|
||||
@copy /y $(SRCDIR)\ares_build.h "$(INSTALL_DIR_INC)" >NUL
|
||||
@copy /y $(SRCDIR)\ares_rules.h "$(INSTALL_DIR_INC)" >NUL
|
||||
@copy /y $(SRCDIR)\ares_version.h "$(INSTALL_DIR_INC)" >NUL
|
||||
@echo Installed c-ares $(CFG)
|
||||
|
||||
!ENDIF
|
||||
|
||||
$(BASE_DIR):
|
||||
|
||||
+13
-10
@@ -1,5 +1,4 @@
|
||||
#################################################################
|
||||
# $Id$
|
||||
#
|
||||
## Makefile for building libcares (NetWare version - gnu make)
|
||||
## Use: make -f Makefile.netware
|
||||
@@ -21,7 +20,7 @@ endif
|
||||
TARGETS = adig.nlm ahost.nlm acountry.nlm
|
||||
LTARGET = libcares.$(LIBEXT)
|
||||
VERSION = $(LIBCARES_VERSION)
|
||||
COPYR = Copyright (C) 1996 - 2008, Daniel Stenberg, <daniel@haxx.se>
|
||||
COPYR = $(LIBCARES_COPYRIGHT_STR)
|
||||
DESCR = cURL $(subst .def,,$(notdir $@)) $(LIBCARES_VERSION_STR) - http://curl.haxx.se
|
||||
MTSAFE = YES
|
||||
STACK = 64000
|
||||
@@ -104,8 +103,12 @@ AR = ar
|
||||
ARFLAGS = -cq
|
||||
LIBEXT = a
|
||||
RANLIB = ranlib
|
||||
CFLAGS += -fno-builtin -fpcc-struct-return -fno-strict-aliasing
|
||||
CFLAGS += -Wall -Wno-format -Wno-uninitialized # -pedantic
|
||||
CFLAGS += -m32
|
||||
CFLAGS += -fno-builtin -fno-strict-aliasing
|
||||
ifeq ($(findstring gcc,$(CC)),gcc)
|
||||
CFLAGS += -fpcc-struct-return
|
||||
endif
|
||||
CFLAGS += -Wall # -pedantic
|
||||
ifeq ($(LIBARCH),LIBC)
|
||||
PRELUDE = $(SDK_LIBC)/imports/libcpre.gcc.o
|
||||
else
|
||||
@@ -143,7 +146,7 @@ ifeq ($(MTSAFE),NO)
|
||||
XDCOPT = -u
|
||||
endif
|
||||
|
||||
ifeq ($(findstring linux,$(OSTYPE)),linux)
|
||||
ifeq ($(findstring /sh,$(SHELL)),/sh)
|
||||
DL = '
|
||||
#-include $(NDKBASE)/nlmconv/ncpfs.inc
|
||||
endif
|
||||
@@ -345,12 +348,13 @@ else
|
||||
@echo $(DL)#define SEND_TYPE_ARG3 size_t$(DL) >> $@
|
||||
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
|
||||
@echo $(DL)#define SEND_TYPE_RETV ssize_t$(DL) >> $@
|
||||
@echo $(DL)#define SIZEOF_STRUCT_IN6_ADDR 16$(DL) >> $@
|
||||
endif
|
||||
@echo $(DL)#define HAVE_ARPA_INET_H 1$(DL) >> $@
|
||||
@echo $(DL)#define HAVE_ASSERT_H 1$(DL) >> $@
|
||||
@echo $(DL)#define HAVE_ERRNO_H 1$(DL) >> $@
|
||||
@echo $(DL)#define HAVE_ERR_H 1$(DL) >> $@
|
||||
@echo $(DL)#define HAVE_FCNTL_H 1$(DL) >> $@
|
||||
@echo $(DL)#define HAVE_GETENV 1$(DL) >> $@
|
||||
@echo $(DL)#define HAVE_GETHOSTBYADDR 1$(DL) >> $@
|
||||
@echo $(DL)#define HAVE_GETHOSTBYNAME 1$(DL) >> $@
|
||||
@echo $(DL)#define HAVE_GETHOSTNAME 1$(DL) >> $@
|
||||
@@ -390,7 +394,6 @@ endif
|
||||
@echo $(DL)#define HAVE_UTIME_H 1$(DL) >> $@
|
||||
@echo $(DL)#define HAVE_WRITEV 1$(DL) >> $@
|
||||
@echo $(DL)#define RETSIGTYPE void$(DL) >> $@
|
||||
@echo $(DL)#define SIZEOF_STRUCT_IN_ADDR 4$(DL) >> $@
|
||||
@echo $(DL)#define STDC_HEADERS 1$(DL) >> $@
|
||||
@echo $(DL)#define TIME_WITH_SYS_TIME 1$(DL) >> $@
|
||||
ifdef NW_WINSOCK
|
||||
@@ -415,15 +418,15 @@ ares_build.h: Makefile.netware FORCE
|
||||
@echo $(DL)** Do not edit this file - it is created by make!$(DL) >> $@
|
||||
@echo $(DL)** All your changes will be lost!!$(DL) >> $@
|
||||
@echo $(DL)*/$(DL) >> $@
|
||||
@echo $(DL)#ifndef NETWARE$(DL) >> $@
|
||||
@echo $(DL)#error This $(notdir $@) is created for NetWare platform!$(DL) >> $@
|
||||
@echo $(DL)#endif$(DL) >> $@
|
||||
@echo $(DL)#ifndef __CARES_BUILD_H$(DL) >> $@
|
||||
@echo $(DL)#define __CARES_BUILD_H$(DL) >> $@
|
||||
ifeq ($(LIBARCH),CLIB)
|
||||
@echo $(DL)#define CARES_TYPEOF_ARES_SOCKLEN_T int$(DL) >> $@
|
||||
@echo $(DL)#define CARES_SIZEOF_ARES_SOCKLEN_T 4$(DL) >> $@
|
||||
else
|
||||
@echo $(DL)#define CARES_TYPEOF_ARES_SOCKLEN_T unsigned int$(DL) >> $@
|
||||
@echo $(DL)#define CARES_SIZEOF_ARES_SOCKLEN_T 4$(DL) >> $@
|
||||
endif
|
||||
@echo $(DL)#define CARES_SIZEOF_LONG 4$(DL) >> $@
|
||||
@echo $(DL)typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t;$(DL) >> $@
|
||||
@echo $(DL)#endif /* __CARES_BUILD_H */$(DL) >> $@
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
This is c-ares, a forked version of the original ares. The original ares
|
||||
README follows below, the c-ares specific details are in README.cares
|
||||
|
||||
====================================================================
|
||||
|
||||
This is ares, an asynchronous resolver library. It is intended for
|
||||
applications which need to perform DNS queries without blocking, or
|
||||
need to perform multiple DNS queries in parallel. The primary
|
||||
examples of such applications are servers which communicate with
|
||||
multiple clients and programs with graphical user interfaces.
|
||||
|
||||
This library implementation is not especially portable to crufty old
|
||||
systems like SunOS 4. It assumes a compiler which can handle ANSI C
|
||||
syntax, a system malloc which properly handles realloc(NULL, foo) and
|
||||
free(NULL), and a reasonably up-to-date <arpa/nameser.h>.
|
||||
|
||||
I have attempted to preserve the externally visible behavior of the
|
||||
BIND resolver in nearly all respects. The API of the library is, of
|
||||
course, very different from the synchronous BIND API; instead of
|
||||
invoking a function like res_send() and getting a return value back
|
||||
indicating the number of bytes in the response, you invoke a function
|
||||
like ares_send() and give it a callback function to invoke when the
|
||||
response arrives. You then have to select() on the file descriptors
|
||||
indicated by ares_fds(), with a timeout given by ares_timeout(). You
|
||||
call ares_process() when select() returns.
|
||||
|
||||
Some features are missing from the current version of ares, relative
|
||||
to the BIND resolver:
|
||||
|
||||
* There is no IPV6 support. [not true for c-ares]
|
||||
* There is no hostname verification.
|
||||
* There is no logging of unexpected events.
|
||||
* There is no debugging-oriented logging.
|
||||
* There is no YP support.
|
||||
|
||||
libares requires an ANSI compiler to compile and use. To build the
|
||||
library, just run "./configure" and "make". To install it, run "make
|
||||
install". Run "./configure --help" to see a list of options you can
|
||||
provide to configure to change how the library builds. libares has no
|
||||
data files, so you can move the include file and library around freely
|
||||
without leaving behind any dependencies on old paths. Building the
|
||||
library will also build the "adig" program, a little toy for trying
|
||||
out the library. It doesn't get installed.
|
||||
|
||||
libares is distributed at athena-dist.mit.edu:pub/ATHENA/ares. Please
|
||||
send bug reports and comments to ghudson@mit.edu.
|
||||
@@ -0,0 +1,42 @@
|
||||
Short: Command line DNS tools
|
||||
Author: Daniel Stenberg, Greg Hudson and others
|
||||
Uploader: Carsten Larsen (carsten larsen mail com)
|
||||
Type: comm/tcp
|
||||
Version: 1.12.0
|
||||
Architecture: m68k-amigaos
|
||||
URL: http://c-ares.haxx.se/
|
||||
|
||||
|
||||
ABOUT
|
||||
|
||||
Utilities from the c-ares asynchronous resolver library.
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
c-ares is an asynchronous resolver library. It is intended for
|
||||
applications which need to perform DNS queries without blocking,
|
||||
or need to perform multiple DNS queries in parallel.
|
||||
|
||||
USAGE
|
||||
|
||||
Look up the DNS A or AAAA record associated with HOST (a hostname or an
|
||||
IP address).
|
||||
|
||||
Send queries to DNS servers about NAME and print received information,
|
||||
where NAME is a valid DNS name (e.g. www.example.com, 1.2.3.10.in-
|
||||
addr.arpa).
|
||||
|
||||
Print the country where HOST (an IPv4 address or hostname) is located.
|
||||
|
||||
The full source code is available in the 'c-ares' release archives, and
|
||||
in a git repository: http://github.com/c-ares/c-ares
|
||||
|
||||
BUGS
|
||||
|
||||
If you find bugs, correct flaws, have questions or have comments in general
|
||||
in regard to c-ares (or by all means the original ares too), get in touch
|
||||
with us on the c-ares mailing list.
|
||||
|
||||
c-ares is of course distributed under the same MIT-style license as the
|
||||
original ares.
|
||||
|
||||
+14
-56
@@ -1,63 +1,21 @@
|
||||
c-ares
|
||||
======
|
||||
|
||||
This package is based on ares 1.1.1 (written by Greg Hudson). I decided to
|
||||
fork and release a separate project since the ares author didn't want the
|
||||
improvements that were vital for our use of it.
|
||||
This package is based on ares 1.1.1 (written by Greg Hudson). Daniel Stenberg
|
||||
decided to fork and release a separate project since the original ares author
|
||||
didn't want the improvements that were vital for our use of it.
|
||||
|
||||
This package is dubbed 'c-ares' since I (Daniel Stenberg) wanted this for use
|
||||
within the curl project (hence the letter C) and it makes a nice pun. Also,
|
||||
c-ares is not API compatible with ares: a new name makes that more obvious to
|
||||
the public.
|
||||
This package is dubbed 'c-ares' since Daniel wanted this for use within the
|
||||
curl project (hence the letter C) and it makes a nice pun. c-ares is not API
|
||||
compatible with ares: a new name makes that more obvious to the public.
|
||||
|
||||
The full source code is available in the 'c-ares' release archives, and in the
|
||||
'ares' subdir of the curl CVS source repository.
|
||||
The original libares was distributed at
|
||||
ftp://athena-dist.mit.edu:pub/ATHENA/ares (which seems to not be alive
|
||||
anymore). A local copy of the original ares package is kept here:
|
||||
https://c-ares.haxx.se/download/ares-1.1.1.tar.gz
|
||||
|
||||
If you find bugs, correct flaws, have questions or have comments in general in
|
||||
regard to c-ares (or by all means the original ares too), get in touch with us
|
||||
on the c-ares mailing list: http://cool.haxx.se/mailman/listinfo/c-ares
|
||||
|
||||
c-ares is of course distributed under the same MIT-style license as the
|
||||
original ares.
|
||||
|
||||
You'll find all c-ares details and news here:
|
||||
|
||||
http://c-ares.haxx.se/
|
||||
|
||||
|
||||
NOTES FOR C-ARES HACKERS
|
||||
|
||||
The following notes apply to c-ares version 1.7.0 and later.
|
||||
|
||||
* The distributed ares_build.h file is only intended to be used on systems
|
||||
which can not run the also distributed configure script.
|
||||
|
||||
* The distributed ares_build.h file is generated as a copy of ares_build.h.dist
|
||||
when the c-ares source code distribution archive file is originally created.
|
||||
|
||||
* If you check out from CVS on a non-configure platform, you must run the
|
||||
appropriate buildconf* script to set up ares_build.h and other local files
|
||||
before being able of compiling the library.
|
||||
|
||||
* On systems capable of running the configure script, the configure process
|
||||
will overwrite the distributed ares_build.h file with one that is suitable
|
||||
and specific to the library being configured and built, this new file is
|
||||
generated from the ares_build.h.in template file.
|
||||
|
||||
* If you intend to distribute an already compiled c-ares library you _MUST_
|
||||
also distribute along with it the generated ares_build.h which has been
|
||||
used to compile it. Otherwise the library will be of no use for the users of
|
||||
the library that you have built. It is _your_ responsability to provide this
|
||||
file. No one at the c-ares project can know how you have built the library.
|
||||
|
||||
* File ares_build.h includes platform and configuration dependent info,
|
||||
and must not be modified by anyone. Configure script generates it for you.
|
||||
|
||||
* We cannot assume anything else but very basic compiler features being
|
||||
present. While c-ares requires an ANSI C compiler to build, some of the
|
||||
earlier ANSI compilers clearly can't deal with some preprocessor operators.
|
||||
|
||||
* Newlines must remain unix-style for older compilers' sake.
|
||||
|
||||
* Comments must be written in the old-style /* unnested C-fashion */
|
||||
AmigaOS versions are distributed at:
|
||||
http://aminet.net/package/comm/tcp/c-ares
|
||||
|
||||
and
|
||||
http://aminet.net/package/dev/gcc/c-ares-src
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
c-ares
|
||||
======
|
||||
|
||||
[](https://travis-ci.org/c-ares/c-ares)
|
||||
[](https://ci.appveyor.com/project/c-ares/c-ares)
|
||||
[](https://coveralls.io/github/c-ares/c-ares?branch=master)
|
||||
[](https://bestpractices.coreinfrastructure.org/projects/291)
|
||||
|
||||
This is c-ares, an asynchronous resolver library. It is intended for
|
||||
applications which need to perform DNS queries without blocking, or need to
|
||||
perform multiple DNS queries in parallel. The primary examples of such
|
||||
applications are servers which communicate with multiple clients and programs
|
||||
with graphical user interfaces.
|
||||
|
||||
The full source code is available in the 'c-ares' release archives, and in a
|
||||
git repository: http://github.com/c-ares/c-ares
|
||||
|
||||
If you find bugs, correct flaws, have questions or have comments in general in
|
||||
regard to c-ares (or by all means the original ares too), get in touch with us
|
||||
on the c-ares mailing list: http://cool.haxx.se/mailman/listinfo/c-ares
|
||||
|
||||
c-ares is of course distributed under the same MIT-style license as the
|
||||
original ares.
|
||||
|
||||
You'll find all c-ares details and news here:
|
||||
https://c-ares.haxx.se/
|
||||
|
||||
|
||||
Notes for c-ares hackers
|
||||
------------------------
|
||||
|
||||
* The distributed `ares_build.h` file is only intended to be used on systems
|
||||
which can not run the also distributed configure script.
|
||||
|
||||
* The distributed `ares_build.h` file is generated as a copy of `ares_build.h.dist`
|
||||
when the c-ares source code distribution archive file is originally created.
|
||||
|
||||
* If you check out from git on a non-configure platform, you must run the
|
||||
appropriate `buildconf*` script to set up `ares_build.h` and other local files
|
||||
before being able to compile the library.
|
||||
|
||||
* On systems capable of running the `configure` script, the `configure` process
|
||||
will overwrite the distributed `ares_build.h` file with one that is suitable
|
||||
and specific to the library being configured and built, this new file is
|
||||
generated from the `ares_build.h.in` template file.
|
||||
|
||||
* If you intend to distribute an already compiled c-ares library you **MUST**
|
||||
also distribute along with it the generated `ares_build.h` which has been
|
||||
used to compile it. Otherwise the library will be of no use for the users of
|
||||
the library that you have built. It is **your** responsibility to provide this
|
||||
file. No one at the c-ares project can know how you have built the library.
|
||||
|
||||
* File `ares_build.h` includes platform and configuration dependent info,
|
||||
and must not be modified by anyone. Configure script generates it for you.
|
||||
|
||||
* We cannot assume anything else but very basic compiler features being
|
||||
present. While c-ares requires an ANSI C compiler to build, some of the
|
||||
earlier ANSI compilers clearly can't deal with some preprocessor operators.
|
||||
|
||||
* Newlines must remain unix-style for older compilers' sake.
|
||||
|
||||
* Comments must be written in the old-style /* unnested C-fashion */
|
||||
|
||||
* Try to keep line lengths below 80 columns.
|
||||
+24
-1
@@ -1,4 +1,3 @@
|
||||
$Id$
|
||||
|
||||
|
||||
___ __ _ _ __ ___ ___
|
||||
@@ -41,6 +40,30 @@
|
||||
library version it is using.
|
||||
|
||||
|
||||
How to install using MSVC from the command line
|
||||
-----------------------------------------------
|
||||
|
||||
In order to allow easy usage of c-ares libraries it may be convenient to
|
||||
install c-ares libraries and header files to a common subdirectory tree.
|
||||
|
||||
Once that c-ares libraries have been built using procedure described above,
|
||||
use same command prompt window to define environment variable INSTALL_DIR
|
||||
to designate the top subdirectory where installation of c-ares libraries and
|
||||
header files will be done.
|
||||
|
||||
> set INSTALL_DIR=c:\c-ares
|
||||
|
||||
Afterwards, run following command to actually perform the installation:
|
||||
|
||||
> nmake -f Makefile.msvc install
|
||||
|
||||
Installation procedure will copy c-ares libraries to subdirectory 'lib' and
|
||||
c-ares header files to subdirectory 'include' below the INSTALL_DIR subdir.
|
||||
|
||||
When environment variable INSTALL_DIR is not defined, installation is done
|
||||
to c-ares source folder where Makefile.msvc file is located.
|
||||
|
||||
|
||||
How to build using Visual Studio 6 IDE
|
||||
--------------------------------------
|
||||
|
||||
|
||||
+40
-30
@@ -1,36 +1,46 @@
|
||||
This is what's new and changed in the c-ares 1.7.0 release:
|
||||
c-ares version 1.12.0
|
||||
|
||||
Changed:
|
||||
Changes:
|
||||
|
||||
o in6_addr is not used in ares.h anymore, but a private ares_in6_addr is
|
||||
instead declared and used
|
||||
o ares_gethostbyname() now supports 'AF_UNSPEC' as a family for resolving
|
||||
either AF_INET6 or AF_INET
|
||||
o a build-time configured ares_socklen_t is now used instead of socklen_t
|
||||
o new ares_library_init() and ares_library_cleanup() functions
|
||||
o new --enable-curldebug configure option
|
||||
o ARES_ECANCELLED is now sent as reason for ares_cancel()
|
||||
o added ares_parse_srv_reply()
|
||||
o added ares_parse_txt_reply()
|
||||
o added ares_free_data()
|
||||
o new --enable-symbol-hiding configure option
|
||||
o new Makefile.msvc for any MSVC compiler or MS Visual Studio version
|
||||
o addrttl and addr6ttl structs renamed to ares_addrttl and ares_addr6ttl
|
||||
o naming convention for libraries built with MSVC, see README.msvc
|
||||
|
||||
Fixed:
|
||||
|
||||
o ares_parse_*_reply() functions now return ARES_EBADRESP instead of
|
||||
ARES_EBADNAME if the name in the response failed to decode
|
||||
o only expose/export symbols starting with 'ares_'
|
||||
o fix \Device\TCP handle leaks triggered by buggy iphlpapi.dll
|
||||
o init without internet gone no longer fails
|
||||
o out of bounds memory overwrite triggered with malformed /etc/hosts file
|
||||
o function prototypes in man pages out of sync with ares.h
|
||||
o api: add ARES_OPT_NOROTATE optmask value
|
||||
|
||||
Bug fixes:
|
||||
|
||||
o CVE-2016-5180: ares_create_query single byte out of buffer write [4]
|
||||
o configure: acknowledge --disable-tests [1]
|
||||
o man pages: fix typos detected by Lintian
|
||||
o test: add missing #includes for dns-proto.cc
|
||||
o test: avoid in6addr_* constants
|
||||
o test: Build with MinGW on AppVeyor
|
||||
o Makefile.m32: add support for extra flags
|
||||
o Makefile.m32: add support for CROSSPREFIX
|
||||
o configure: check if tests can get built before enabled
|
||||
o ares_library_cleanup: reset ares_realloc too
|
||||
o ahost.c: add cast to fix C++ compile
|
||||
o test: Only pass unused args to GoogleTest
|
||||
o build: commonize MSVC version detection
|
||||
o msvc_ver.inc: support Visual Studio 2015 Update 1, 2, 3
|
||||
o test: for AF_UNSPEC, return CNAME only for AAAA, but valid A record
|
||||
o ares_getnameinfo: explicitly clear struct servent before use
|
||||
o test: Update fuzzing function prototype
|
||||
o init: fix nsort initialization
|
||||
o test: add fuzzing check script to tests
|
||||
o web: http => https
|
||||
o read_tcp_data: remove superfluous NULL check
|
||||
o LICENSE.md: add a stand-alone license file
|
||||
o SECURITY.md: suggested "security process" for the project
|
||||
o ares_init_options: only propagate init failures from options [2]
|
||||
o headers: remove checks for and defines of variable sizes
|
||||
o test: fix gMock to work with gcc >= 6.x [3]
|
||||
|
||||
Thanks go to these friendly people for their efforts and contributions:
|
||||
|
||||
Phil Blundell, Japheth Cleaver, Yang Tse, Gregor Jasny, Joshua Kwan,
|
||||
Timo Teras, Jakub Hrozek, John Engelhart, Larry Lansing
|
||||
Alexander Drachevskiy, Brad House, Chris Araman, Daniel Stenberg,
|
||||
David Drysdale, Gregor Jasny, Svante Karlsson, Viktor Szakats
|
||||
|
||||
Have fun!
|
||||
References to bug reports and discussions on issues:
|
||||
|
||||
[1] = https://github.com/c-ares/c-ares/issues/44
|
||||
[2] = https://github.com/c-ares/c-ares/issues/60
|
||||
[3] = https://github.com/google/googletest/issues/705#issuecomment-235067917
|
||||
[4] = https://c-ares.haxx.se/adv_20160929.html
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
TODO
|
||||
====
|
||||
|
||||
ares_reinit()
|
||||
|
||||
- To allow an app to force a re-read of /etc/resolv.conf etc, pretty much
|
||||
like the res_init() resolver function offers
|
||||
|
||||
ares_gethostbyname
|
||||
|
||||
- When built to support IPv6, it needs to also support PF_UNSPEC or similar,
|
||||
|
||||
+46
-56
@@ -30,7 +30,7 @@ CURL_DEF_TOKEN $1
|
||||
],[
|
||||
tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
|
||||
"$GREP" CURL_DEF_TOKEN 2>/dev/null | \
|
||||
"$SED" 's/.*CURL_DEF_TOKEN[[ ]]//' 2>/dev/null | \
|
||||
"$SED" 's/.*CURL_DEF_TOKEN[[ ]][[ ]]*//' 2>/dev/null | \
|
||||
"$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
|
||||
if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
|
||||
tmp_exp=""
|
||||
@@ -145,7 +145,7 @@ AC_DEFUN([CARES_CHECK_AIX_ALL_SOURCE], [
|
||||
|
||||
dnl CURL_CHECK_HEADER_WINDOWS
|
||||
dnl -------------------------------------------------
|
||||
dnl Check for compilable and valid windows.h header
|
||||
dnl Check for compilable and valid windows.h header
|
||||
|
||||
AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
|
||||
AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
|
||||
@@ -207,18 +207,13 @@ AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
|
||||
])
|
||||
fi
|
||||
])
|
||||
case "$ac_cv_native_windows" in
|
||||
yes)
|
||||
AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
|
||||
[Define to 1 if you are building a native Windows target.])
|
||||
;;
|
||||
esac
|
||||
AM_CONDITIONAL(DOING_NATIVE_WINDOWS, test "x$ac_cv_native_windows" = xyes)
|
||||
])
|
||||
|
||||
|
||||
dnl CURL_CHECK_HEADER_WINSOCK
|
||||
dnl -------------------------------------------------
|
||||
dnl Check for compilable and valid winsock.h header
|
||||
dnl Check for compilable and valid winsock.h header
|
||||
|
||||
AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
|
||||
AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
|
||||
@@ -255,7 +250,7 @@ AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
|
||||
|
||||
dnl CURL_CHECK_HEADER_WINSOCK2
|
||||
dnl -------------------------------------------------
|
||||
dnl Check for compilable and valid winsock2.h header
|
||||
dnl Check for compilable and valid winsock2.h header
|
||||
|
||||
AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
|
||||
AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
|
||||
@@ -433,13 +428,13 @@ AC_DEFUN([CURL_CHECK_HEADER_MEMORY], [
|
||||
|
||||
dnl CURL_CHECK_FUNC_GETNAMEINFO
|
||||
dnl -------------------------------------------------
|
||||
dnl Test if the getnameinfo function is available,
|
||||
dnl Test if the getnameinfo function is available,
|
||||
dnl and check the types of five of its arguments.
|
||||
dnl If the function succeeds HAVE_GETNAMEINFO will be
|
||||
dnl defined, defining the types of the arguments in
|
||||
dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
|
||||
dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
|
||||
dnl and also defining the type qualifier of first
|
||||
dnl and also defining the type qualifier of first
|
||||
dnl argument in GETNAMEINFO_QUAL_ARG1.
|
||||
|
||||
AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
|
||||
@@ -523,7 +518,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
|
||||
if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
|
||||
AC_COMPILE_IFELSE([
|
||||
AC_LANG_PROGRAM([[
|
||||
#undef inline
|
||||
#undef inline
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
@@ -534,7 +529,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
#include <winsock2.h>
|
||||
#include <winsock2.h>
|
||||
#ifdef HAVE_WS2TCPIP_H
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
@@ -634,7 +629,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
|
||||
|
||||
dnl TYPE_SOCKADDR_STORAGE
|
||||
dnl -------------------------------------------------
|
||||
dnl Check for struct sockaddr_storage. Most IPv6-enabled
|
||||
dnl Check for struct sockaddr_storage. Most IPv6-enabled
|
||||
dnl hosts have it, but AIX 4.3 is one known exception.
|
||||
|
||||
AC_DEFUN([TYPE_SOCKADDR_STORAGE],
|
||||
@@ -680,7 +675,7 @@ AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
|
||||
AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
|
||||
netdb.h netinet/in.h arpa/inet.h)
|
||||
#
|
||||
AC_CACHE_CHECK([for working NI_WITHSCOPEID],
|
||||
AC_CACHE_CHECK([for working NI_WITHSCOPEID],
|
||||
[ac_cv_working_ni_withscopeid], [
|
||||
AC_RUN_IFELSE([
|
||||
AC_LANG_PROGRAM([[
|
||||
@@ -772,11 +767,11 @@ AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
|
||||
|
||||
dnl CURL_CHECK_FUNC_RECV
|
||||
dnl -------------------------------------------------
|
||||
dnl Test if the socket recv() function is available,
|
||||
dnl and check its return type and the types of its
|
||||
dnl arguments. If the function succeeds HAVE_RECV
|
||||
dnl will be defined, defining the types of the arguments
|
||||
dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
|
||||
dnl Test if the socket recv() function is available,
|
||||
dnl and check its return type and the types of its
|
||||
dnl arguments. If the function succeeds HAVE_RECV
|
||||
dnl will be defined, defining the types of the arguments
|
||||
dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
|
||||
dnl and RECV_TYPE_ARG4, defining the type of the function
|
||||
dnl return value in RECV_TYPE_RETV.
|
||||
|
||||
@@ -788,7 +783,7 @@ AC_DEFUN([CURL_CHECK_FUNC_RECV], [
|
||||
AC_MSG_CHECKING([for recv])
|
||||
AC_LINK_IFELSE([
|
||||
AC_LANG_PROGRAM([[
|
||||
#undef inline
|
||||
#undef inline
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
@@ -832,7 +827,7 @@ AC_DEFUN([CURL_CHECK_FUNC_RECV], [
|
||||
if test "$curl_cv_func_recv_args" = "unknown"; then
|
||||
AC_COMPILE_IFELSE([
|
||||
AC_LANG_PROGRAM([[
|
||||
#undef inline
|
||||
#undef inline
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
@@ -905,13 +900,13 @@ AC_DEFUN([CURL_CHECK_FUNC_RECV], [
|
||||
|
||||
dnl CURL_CHECK_FUNC_SEND
|
||||
dnl -------------------------------------------------
|
||||
dnl Test if the socket send() function is available,
|
||||
dnl and check its return type and the types of its
|
||||
dnl arguments. If the function succeeds HAVE_SEND
|
||||
dnl will be defined, defining the types of the arguments
|
||||
dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
|
||||
dnl Test if the socket send() function is available,
|
||||
dnl and check its return type and the types of its
|
||||
dnl arguments. If the function succeeds HAVE_SEND
|
||||
dnl will be defined, defining the types of the arguments
|
||||
dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
|
||||
dnl and SEND_TYPE_ARG4, defining the type of the function
|
||||
dnl return value in SEND_TYPE_RETV, and also defining the
|
||||
dnl return value in SEND_TYPE_RETV, and also defining the
|
||||
dnl type qualifier of second argument in SEND_QUAL_ARG2.
|
||||
|
||||
AC_DEFUN([CURL_CHECK_FUNC_SEND], [
|
||||
@@ -922,7 +917,7 @@ AC_DEFUN([CURL_CHECK_FUNC_SEND], [
|
||||
AC_MSG_CHECKING([for send])
|
||||
AC_LINK_IFELSE([
|
||||
AC_LANG_PROGRAM([[
|
||||
#undef inline
|
||||
#undef inline
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
@@ -966,7 +961,7 @@ AC_DEFUN([CURL_CHECK_FUNC_SEND], [
|
||||
if test "$curl_cv_func_send_args" = "unknown"; then
|
||||
AC_COMPILE_IFELSE([
|
||||
AC_LANG_PROGRAM([[
|
||||
#undef inline
|
||||
#undef inline
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
@@ -1090,7 +1085,7 @@ AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
|
||||
AC_MSG_CHECKING([for recvfrom])
|
||||
AC_LINK_IFELSE([
|
||||
AC_LANG_PROGRAM([[
|
||||
#undef inline
|
||||
#undef inline
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
@@ -1131,12 +1126,12 @@ AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
|
||||
for recvfrom_arg2 in 'char *' 'void *'; do
|
||||
for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
|
||||
for recvfrom_arg4 in 'int' 'unsigned int'; do
|
||||
for recvfrom_arg5 in 'struct sockaddr *' 'void *'; do
|
||||
for recvfrom_arg5 in 'struct sockaddr *' 'void *' 'const struct sockaddr *'; do
|
||||
for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *' 'void *'; do
|
||||
if test "$curl_cv_func_recvfrom_args" = "unknown"; then
|
||||
AC_COMPILE_IFELSE([
|
||||
AC_LANG_PROGRAM([[
|
||||
#undef inline
|
||||
#undef inline
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
@@ -1199,7 +1194,7 @@ AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
|
||||
shift
|
||||
#
|
||||
recvfrom_ptrt_arg2=$[2]
|
||||
recvfrom_ptrt_arg5=$[5]
|
||||
recvfrom_qual_ptrt_arg5=$[5]
|
||||
recvfrom_ptrt_arg6=$[6]
|
||||
#
|
||||
AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG1, $[1],
|
||||
@@ -1221,12 +1216,25 @@ AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
|
||||
;;
|
||||
esac
|
||||
#
|
||||
case "$recvfrom_qual_ptrt_arg5" in
|
||||
const*)
|
||||
recvfrom_qual_arg5=const
|
||||
recvfrom_ptrt_arg5=`echo $recvfrom_qual_ptrt_arg5 | sed 's/^const //'`
|
||||
;;
|
||||
*)
|
||||
recvfrom_qual_arg5=
|
||||
recvfrom_ptrt_arg5=$recvfrom_qual_ptrt_arg5
|
||||
;;
|
||||
esac
|
||||
#
|
||||
recvfrom_type_arg2=`echo $recvfrom_ptrt_arg2 | sed 's/ \*//'`
|
||||
recvfrom_type_arg5=`echo $recvfrom_ptrt_arg5 | sed 's/ \*//'`
|
||||
recvfrom_type_arg6=`echo $recvfrom_ptrt_arg6 | sed 's/ \*//'`
|
||||
#
|
||||
AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2, $recvfrom_type_arg2,
|
||||
[Define to the type pointed by arg 2 for recvfrom.])
|
||||
AC_DEFINE_UNQUOTED(RECVFROM_QUAL_ARG5, $recvfrom_qual_arg5,
|
||||
[Define to the type qualifier pointed by arg 5 for recvfrom.])
|
||||
AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5, $recvfrom_type_arg5,
|
||||
[Define to the type pointed by arg 5 for recvfrom.])
|
||||
AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6, $recvfrom_type_arg6,
|
||||
@@ -1273,7 +1281,7 @@ AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
|
||||
AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
|
||||
AC_COMPILE_IFELSE([
|
||||
AC_LANG_PROGRAM([[
|
||||
#undef inline
|
||||
#undef inline
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
@@ -1324,7 +1332,7 @@ AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
|
||||
AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
|
||||
AC_COMPILE_IFELSE([
|
||||
AC_LANG_PROGRAM([[
|
||||
#undef inline
|
||||
#undef inline
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
@@ -1735,24 +1743,6 @@ cat >>confdefs.h <<_EOF
|
||||
_EOF
|
||||
])
|
||||
|
||||
|
||||
dnl CARES_CONFIGURE_LONG
|
||||
dnl -------------------------------------------------
|
||||
dnl Find out the size of long as reported by sizeof() and define
|
||||
dnl CARES_SIZEOF_LONG as appropriate to be used in template file
|
||||
dnl ares_build.h.in to properly configure the library.
|
||||
dnl The size of long is a build time characteristic and as such
|
||||
dnl must be recorded in ares_build.h
|
||||
|
||||
AC_DEFUN([CARES_CONFIGURE_LONG], [
|
||||
if test -z "$ac_cv_sizeof_long" ||
|
||||
test "$ac_cv_sizeof_long" -eq "0"; then
|
||||
AC_MSG_ERROR([cannot find out size of long.])
|
||||
fi
|
||||
CARES_DEFINE_UNQUOTED([CARES_SIZEOF_LONG], [$ac_cv_sizeof_long])
|
||||
])
|
||||
|
||||
|
||||
dnl CARES_CONFIGURE_ARES_SOCKLEN_T
|
||||
dnl -------------------------------------------------
|
||||
dnl Find out suitable ares_socklen_t data type definition and size, making
|
||||
@@ -1884,7 +1874,7 @@ dnl CARES_CHECK_STRUCT(headers, struct name, if found, [if not found])
|
||||
|
||||
AC_DEFUN([CARES_CHECK_STRUCT], [
|
||||
AC_MSG_CHECKING([for struct $2])
|
||||
AC_TRY_COMPILE([$1],
|
||||
AC_TRY_COMPILE([$1],
|
||||
[
|
||||
struct $2 struct_instance;
|
||||
], ac_struct="yes", ac_found="no")
|
||||
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
.TH COUNTRY "1" "April 2011" "c-ares utilities"
|
||||
.SH NAME
|
||||
country \- print the country where an IPv4 address or host is located
|
||||
.SH SYNOPSIS
|
||||
.B country
|
||||
[\fIOPTION\fR]... \fIHOST\fR...
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
.\" Add any additional description here
|
||||
.PP
|
||||
Print the country where HOST (an IPv4 address or hostname) is located,
|
||||
using the countries.nerd.dk DNS domain to identify the country.
|
||||
.PP
|
||||
This utility comes with the \fBc\-ares\fR asynchronous resolver library.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-d\fR
|
||||
Print some extra debugging output.
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Display this help and exit.
|
||||
.TP
|
||||
\fB\-v\fR
|
||||
Be more verbose. Print extra information.
|
||||
.SH "REPORTING BUGS"
|
||||
Report bugs to the c-ares mailing list:
|
||||
\fBhttp://cool.haxx.se/mailman/listinfo/c-ares\fR
|
||||
.SH "SEE ALSO"
|
||||
.PP
|
||||
adig(1), ahost(1).
|
||||
.PP
|
||||
The DNSBL countries.nerd.dk
|
||||
.br
|
||||
\fBhttp://countries.nerd.dk/\fR
|
||||
.SH COPYRIGHT
|
||||
This utility is based on code/ideas contained in sofware written by Greg Hudson (ares)
|
||||
carrying the following notice:
|
||||
.br
|
||||
Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.br
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted,
|
||||
provided that the above copyright notice appear in all copies and that
|
||||
both that copyright notice and this permission notice appear in
|
||||
supporting documentation, and that the name of M.I.T. not be used in
|
||||
advertising or publicity pertaining to distribution of the software
|
||||
without specific, written prior permission. M.I.T. makes no
|
||||
representations about the suitability of this software for any
|
||||
purpose. It is provided "as is" without express or implied warranty.
|
||||
.br
|
||||
No further copyright claims are being made by the author(s) of this utility.
|
||||
.SH AUTHOR
|
||||
Gisle Vanem
|
||||
+38
-31
@@ -1,5 +1,4 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* IP-address/hostname to country converter.
|
||||
*
|
||||
@@ -16,7 +15,7 @@
|
||||
*
|
||||
* Ref: http://countries.nerd.dk/more.html
|
||||
*
|
||||
* Written by G. Vanem <gvanem@broadpark.no> 2006, 2007
|
||||
* Written by G. Vanem <gvanem@yahoo.no> 2006, 2007
|
||||
*
|
||||
* NB! This program may not be big-endian aware.
|
||||
*
|
||||
@@ -35,14 +34,6 @@
|
||||
|
||||
#include "ares_setup.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
@@ -50,16 +41,14 @@
|
||||
#if defined(WIN32) && !defined(WATT32)
|
||||
#include <winsock.h>
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_getopt.h"
|
||||
#include "inet_net_pton.h"
|
||||
#include "inet_ntop.h"
|
||||
#include "ares_nowarn.h"
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
# include "ares_strdup.h"
|
||||
@@ -80,16 +69,27 @@
|
||||
#define INADDR_NONE 0xffffffff
|
||||
#endif
|
||||
|
||||
static const char *usage = "acountry [-vh?] {host|addr} ...\n";
|
||||
const char *vers = "\0$VER: country 1.12 (29.09.2016) c-ares " ARES_VERSION_STR;
|
||||
|
||||
static const char *usage =
|
||||
#ifdef ANSI_CONSOLE
|
||||
"\33[33mcountry version " ARES_VERSION_STR " (c) " ARES_COPYRIGHT "\33[31m\n"
|
||||
#else
|
||||
"country version " ARES_VERSION_STR " (c) " ARES_COPYRIGHT "\n"
|
||||
#endif
|
||||
"Usage: country [options] { host | addr } ...\n"
|
||||
"\t-v: Be more verbose. Print extra information\n"
|
||||
"\t-h: Display this help and exit\n";
|
||||
|
||||
static const char nerd_fmt[] = "%u.%u.%u.%u.zz.countries.nerd.dk";
|
||||
static const char *nerd_ver1 = nerd_fmt + 14;
|
||||
static const char *nerd_ver2 = nerd_fmt + 11;
|
||||
static const char *nerd_ver1 = nerd_fmt + 14; /* .countries.nerd.dk */
|
||||
static const char *nerd_ver2 = nerd_fmt + 11; /* .zz.countries.nerd.dk */
|
||||
static int verbose = 0;
|
||||
|
||||
#define TRACE(fmt) do { \
|
||||
if (verbose > 0) \
|
||||
printf fmt ; \
|
||||
} while (0)
|
||||
} WHILE_FALSE
|
||||
|
||||
static void wait_ares(ares_channel channel);
|
||||
static void callback(void *arg, int status, int timeouts, struct hostent *host);
|
||||
@@ -110,6 +110,8 @@ int main(int argc, char **argv)
|
||||
ares_channel channel;
|
||||
int ch, status;
|
||||
|
||||
prog = argv[0];
|
||||
|
||||
#if defined(WIN32) && !defined(WATT32)
|
||||
WORD wVersionRequested = MAKEWORD(USE_WINSOCK,USE_WINSOCK);
|
||||
WSADATA wsaData;
|
||||
@@ -172,11 +174,12 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
// NOTICE: Not endian neutral
|
||||
sprintf(buf, nerd_fmt,
|
||||
(unsigned int)(addr.s_addr >> 24),
|
||||
(unsigned int)((addr.s_addr >> 16) & 255),
|
||||
(unsigned int)(addr.s_addr & 255),
|
||||
(unsigned int)((addr.s_addr >> 8) & 255),
|
||||
(unsigned int)(addr.s_addr & 255));
|
||||
(unsigned int)((addr.s_addr >> 16) & 255),
|
||||
(unsigned int)(addr.s_addr >> 24));
|
||||
TRACE(("Looking up %s...", buf));
|
||||
fflush(stdout);
|
||||
ares_gethostbyname(channel, buf, AF_INET, callback, buf);
|
||||
@@ -211,7 +214,9 @@ static void wait_ares(ares_channel channel)
|
||||
if (nfds == 0)
|
||||
break;
|
||||
tvp = ares_timeout(channel, NULL, &tv);
|
||||
select(nfds, &read_fds, &write_fds, NULL, tvp);
|
||||
nfds = select(nfds, &read_fds, &write_fds, NULL, tvp);
|
||||
if (nfds < 0)
|
||||
continue;
|
||||
ares_process(channel, &read_fds, &write_fds);
|
||||
}
|
||||
}
|
||||
@@ -534,7 +539,7 @@ static int is_addr(char *str, char **end)
|
||||
int a0, a1, a2, a3, num, rc = 0, length = 0;
|
||||
|
||||
num = sscanf(str,"%3d.%3d.%3d.%3d%n",&a0,&a1,&a2,&a3,&length);
|
||||
if( (num == 4) &&
|
||||
if( (num == 4 || num == 5) &&
|
||||
BYTE_OK(a0) && BYTE_OK(a1) && BYTE_OK(a2) && BYTE_OK(a3) &&
|
||||
length >= (3+4))
|
||||
{
|
||||
@@ -559,8 +564,8 @@ static void find_country_from_cname(const char *cname, struct in_addr addr)
|
||||
unsigned long ip;
|
||||
|
||||
ip = ntohl(addr.s_addr);
|
||||
z0 = tolower(cname[0]);
|
||||
z1 = tolower(cname[1]);
|
||||
z0 = TOLOWER(cname[0]);
|
||||
z1 = TOLOWER(cname[1]);
|
||||
ccopy = strdup(cname);
|
||||
dot_4 = NULL;
|
||||
|
||||
@@ -570,32 +575,35 @@ static void find_country_from_cname(const char *cname, struct in_addr addr)
|
||||
if (ver_1)
|
||||
{
|
||||
const char *dot = strchr(cname, '.');
|
||||
if ((z0 != 'z' && z1 != 'z') || dot != cname+4)
|
||||
if (dot != cname+4)
|
||||
{
|
||||
printf("Unexpected CNAME %s (ver_1)\n", cname);
|
||||
free(ccopy);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (ver_2)
|
||||
{
|
||||
z0 = tolower(dot_4[1]);
|
||||
z1 = tolower(dot_4[2]);
|
||||
z0 = TOLOWER(dot_4[1]);
|
||||
z1 = TOLOWER(dot_4[2]);
|
||||
if (z0 != 'z' && z1 != 'z')
|
||||
{
|
||||
printf("Unexpected CNAME %s (ver_2)\n", cname);
|
||||
free(ccopy);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Unexpected CNAME %s (ver?)\n", cname);
|
||||
free(ccopy);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ver_1)
|
||||
{
|
||||
ccode_A2[0] = (char)tolower(cname[2]);
|
||||
ccode_A2[1] = (char)tolower(cname[3]);
|
||||
ccode_A2[0] = (char)TOLOWER(cname[2]);
|
||||
ccode_A2[1] = (char)TOLOWER(cname[3]);
|
||||
ccode_A2[2] = '\0';
|
||||
}
|
||||
else
|
||||
@@ -625,4 +633,3 @@ static void find_country_from_cname(const char *cname, struct in_addr addr)
|
||||
}
|
||||
free(ccopy);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
.TH DIG "1" "April 2011" "c-ares utilities"
|
||||
.SH NAME
|
||||
dig \- print information collected from Domain Name System (DNS) servers
|
||||
.SH SYNOPSIS
|
||||
.B dig
|
||||
[\fIOPTION\fR]... \fINAME\fR...
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
.\" Add any additional description here
|
||||
.PP
|
||||
Send queries to DNS servers about \fINAME\fR and print received
|
||||
information, where \fINAME\fR is a valid DNS name (e.g. www.example.com,
|
||||
1.2.3.10.in-addr.arpa).
|
||||
.PP
|
||||
This utility comes with the \fBc\-ares\fR asynchronous resolver library.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-c\fR class
|
||||
Set the query class.
|
||||
Possible values for class are
|
||||
NY, CHAOS, HS, IN (default).
|
||||
.TP
|
||||
\fB\-d\fR
|
||||
Print some extra debugging output.
|
||||
.TP
|
||||
\fB\-f\fR flag
|
||||
Add a flag.
|
||||
Possible values for flag are
|
||||
igntc, noaliases, norecurse, primary, stayopen, usevc.
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Display this help and exit.
|
||||
.TP
|
||||
\fB\-T\fR port
|
||||
Use specified TCP port to connect to DNS server.
|
||||
.TP
|
||||
\fB\-s\fR server
|
||||
Connect to specified DNS server, instead of the system's default one(s).
|
||||
.TP
|
||||
\fB\-t\fR type
|
||||
Query records of specified type.
|
||||
Possible values for type are
|
||||
A (default), AAAA, AFSDB, ANY, AXFR, CNAME, GPOS, HINFO, ISDN, KEY, LOC, MAILA,
|
||||
MAILB, MB, MD, MF, MG, MINFO, MR, MX, NAPTR, NS, NSAP, NSAP_PTR, NULL,
|
||||
PTR, PX, RP, RT, SIG, SOA, SRV, TXT, WKS, X25,
|
||||
.TP
|
||||
\fB\-U\fR port
|
||||
Use specified UDP port to connect to DNS server.
|
||||
.SH "REPORTING BUGS"
|
||||
Report bugs to the c-ares mailing list:
|
||||
\fBhttp://cool.haxx.se/mailman/listinfo/c-ares\fR
|
||||
.SH "SEE ALSO"
|
||||
.PP
|
||||
acountry(1), ahost(1).
|
||||
.SH COPYRIGHT
|
||||
This utility is based on code/ideas contained in sofware written by Greg Hudson (ares)
|
||||
carrying the following notice:
|
||||
.br
|
||||
Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.br
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted,
|
||||
provided that the above copyright notice appear in all copies and that
|
||||
both that copyright notice and this permission notice appear in
|
||||
supporting documentation, and that the name of M.I.T. not be used in
|
||||
advertising or publicity pertaining to distribution of the software
|
||||
without specific, written prior permission. M.I.T. makes no
|
||||
representations about the suitability of this software for any
|
||||
purpose. It is provided "as is" without express or implied warranty.
|
||||
.br
|
||||
No further copyright claims are being made by the author(s) of this utility.
|
||||
@@ -1,6 +1,5 @@
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose and without
|
||||
@@ -17,9 +16,6 @@
|
||||
|
||||
#include "ares_setup.h"
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
@@ -38,27 +34,14 @@
|
||||
# include <arpa/nameser_compat.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_dns.h"
|
||||
#include "inet_ntop.h"
|
||||
#include "inet_net_pton.h"
|
||||
#include "ares_getopt.h"
|
||||
#include "ares_nowarn.h"
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
# include "ares_strdup.h"
|
||||
@@ -79,14 +62,26 @@
|
||||
#undef WIN32 /* Redefined in MingW headers */
|
||||
#endif
|
||||
|
||||
/* Mac OS X portability check */
|
||||
#ifndef T_SRV
|
||||
#define T_SRV 33 /* server selection */
|
||||
# define T_SRV 33 /* Server selection */
|
||||
#endif
|
||||
|
||||
/* AIX portability check */
|
||||
#ifndef T_NAPTR
|
||||
#define T_NAPTR 35 /* naming authority pointer */
|
||||
# define T_NAPTR 35 /* Naming authority pointer */
|
||||
#endif
|
||||
#ifndef T_DS
|
||||
# define T_DS 43 /* Delegation Signer (RFC4034) */
|
||||
#endif
|
||||
#ifndef T_SSHFP
|
||||
# define T_SSHFP 44 /* SSH Key Fingerprint (RFC4255) */
|
||||
#endif
|
||||
#ifndef T_RRSIG
|
||||
# define T_RRSIG 46 /* Resource Record Signature (RFC4034) */
|
||||
#endif
|
||||
#ifndef T_NSEC
|
||||
# define T_NSEC 47 /* Next Secure (RFC4034) */
|
||||
#endif
|
||||
#ifndef T_DNSKEY
|
||||
# define T_DNSKEY 48 /* DNS Public Key (RFC4034) */
|
||||
#endif
|
||||
|
||||
struct nv {
|
||||
@@ -147,6 +142,11 @@ static const struct nv types[] = {
|
||||
{ "MAILB", T_MAILB },
|
||||
{ "MAILA", T_MAILA },
|
||||
{ "NAPTR", T_NAPTR },
|
||||
{ "DS", T_DS },
|
||||
{ "SSHFP", T_SSHFP },
|
||||
{ "RRSIG", T_RRSIG },
|
||||
{ "NSEC", T_NSEC },
|
||||
{ "DNSKEY", T_DNSKEY },
|
||||
{ "ANY", T_ANY }
|
||||
};
|
||||
static const int ntypes = sizeof(types) / sizeof(types[0]);
|
||||
@@ -164,8 +164,6 @@ static const char *rcodes[] = {
|
||||
"(unknown)", "(unknown)", "(unknown)", "(unknown)", "NOCHANGE"
|
||||
};
|
||||
|
||||
static struct in_addr inaddr;
|
||||
|
||||
static void callback(void *arg, int status, int timeouts,
|
||||
unsigned char *abuf, int alen);
|
||||
static const unsigned char *display_question(const unsigned char *aptr,
|
||||
@@ -176,6 +174,11 @@ static const unsigned char *display_rr(const unsigned char *aptr,
|
||||
static const char *type_name(int type);
|
||||
static const char *class_name(int dnsclass);
|
||||
static void usage(void);
|
||||
static void destroy_addr_list(struct ares_addr_node *head);
|
||||
static void append_addr_list(struct ares_addr_node **head,
|
||||
struct ares_addr_node *node);
|
||||
|
||||
const char *vers = "\0$VER: dig 1.12 (29.09.2016) c-ares " ARES_VERSION_STR;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
@@ -186,6 +189,7 @@ int main(int argc, char **argv)
|
||||
struct hostent *hostent;
|
||||
fd_set read_fds, write_fds;
|
||||
struct timeval *tvp, tv;
|
||||
struct ares_addr_node *srvr, *servers = NULL;
|
||||
|
||||
#ifdef USE_WINSOCK
|
||||
WORD wVersionRequested = MAKEWORD(USE_WINSOCK,USE_WINSOCK);
|
||||
@@ -193,6 +197,8 @@ int main(int argc, char **argv)
|
||||
WSAStartup(wVersionRequested, &wsaData);
|
||||
#endif
|
||||
|
||||
prog = argv[0];
|
||||
|
||||
status = ares_library_init(ARES_LIB_INIT_ALL);
|
||||
if (status != ARES_SUCCESS)
|
||||
{
|
||||
@@ -227,27 +233,56 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 's':
|
||||
/* Add a server, and specify servers in the option mask. */
|
||||
if (ares_inet_pton(AF_INET, optarg, &inaddr) <= 0)
|
||||
{
|
||||
hostent = gethostbyname(optarg);
|
||||
if (!hostent || hostent->h_addrtype != AF_INET)
|
||||
{
|
||||
fprintf(stderr, "adig: server %s not found.\n", optarg);
|
||||
return 1;
|
||||
}
|
||||
memcpy(&inaddr, hostent->h_addr, sizeof(struct in_addr));
|
||||
}
|
||||
options.servers = realloc(options.servers, (options.nservers + 1)
|
||||
* sizeof(struct in_addr));
|
||||
if (!options.servers)
|
||||
/* User-specified name servers override default ones. */
|
||||
srvr = malloc(sizeof(struct ares_addr_node));
|
||||
if (!srvr)
|
||||
{
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
destroy_addr_list(servers);
|
||||
return 1;
|
||||
}
|
||||
memcpy(&options.servers[options.nservers], &inaddr,
|
||||
sizeof(struct in_addr));
|
||||
options.nservers++;
|
||||
append_addr_list(&servers, srvr);
|
||||
if (ares_inet_pton(AF_INET, optarg, &srvr->addr.addr4) > 0)
|
||||
srvr->family = AF_INET;
|
||||
else if (ares_inet_pton(AF_INET6, optarg, &srvr->addr.addr6) > 0)
|
||||
srvr->family = AF_INET6;
|
||||
else
|
||||
{
|
||||
hostent = gethostbyname(optarg);
|
||||
if (!hostent)
|
||||
{
|
||||
fprintf(stderr, "adig: server %s not found.\n", optarg);
|
||||
destroy_addr_list(servers);
|
||||
return 1;
|
||||
}
|
||||
switch (hostent->h_addrtype)
|
||||
{
|
||||
case AF_INET:
|
||||
srvr->family = AF_INET;
|
||||
memcpy(&srvr->addr.addr4, hostent->h_addr,
|
||||
sizeof(srvr->addr.addr4));
|
||||
break;
|
||||
case AF_INET6:
|
||||
srvr->family = AF_INET6;
|
||||
memcpy(&srvr->addr.addr6, hostent->h_addr,
|
||||
sizeof(srvr->addr.addr6));
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,
|
||||
"adig: server %s unsupported address family.\n", optarg);
|
||||
destroy_addr_list(servers);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/* Notice that calling ares_init_options() without servers in the
|
||||
* options struct and with ARES_OPT_SERVERS set simultaneously in
|
||||
* the options mask, results in an initialization with no servers.
|
||||
* When alternative name servers have been specified these are set
|
||||
* later calling ares_set_servers() overriding any existing server
|
||||
* configuration. To prevent initial configuration with default
|
||||
* servers that will be discarded later, ARES_OPT_SERVERS is set.
|
||||
* If this flag is not set here the result shall be the same but
|
||||
* ares_init_options() will do needless work. */
|
||||
optmask |= ARES_OPT_SERVERS;
|
||||
break;
|
||||
|
||||
@@ -308,6 +343,18 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(servers)
|
||||
{
|
||||
status = ares_set_servers(channel, servers);
|
||||
destroy_addr_list(servers);
|
||||
if (status != ARES_SUCCESS)
|
||||
{
|
||||
fprintf(stderr, "ares_init_options: %s\n",
|
||||
ares_strerror(status));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Initiate the queries, one per command-line argument. If there is
|
||||
* only one query to do, supply NULL as the callback argument;
|
||||
* otherwise, supply the query name as an argument so we can
|
||||
@@ -331,9 +378,9 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
tvp = ares_timeout(channel, NULL, &tv);
|
||||
count = select(nfds, &read_fds, &write_fds, NULL, tvp);
|
||||
if (count < 0 && SOCKERRNO != EINVAL)
|
||||
if (count < 0 && (status = SOCKERRNO) != EINVAL)
|
||||
{
|
||||
perror("select");
|
||||
printf("select fail: %d", status);
|
||||
return 1;
|
||||
}
|
||||
ares_process(channel, &read_fds, &write_fds);
|
||||
@@ -590,7 +637,7 @@ static const unsigned char *display_rr(const unsigned char *aptr,
|
||||
*/
|
||||
if (dlen < 2)
|
||||
return NULL;
|
||||
printf("\t%d", DNS__16BIT(aptr));
|
||||
printf("\t%d", (int)DNS__16BIT(aptr));
|
||||
status = ares_expand_name(aptr + 2, abuf, alen, &name.as_char, &len);
|
||||
if (status != ARES_SUCCESS)
|
||||
return NULL;
|
||||
@@ -617,10 +664,10 @@ static const unsigned char *display_rr(const unsigned char *aptr,
|
||||
p += len;
|
||||
if (p + 20 > aptr + dlen)
|
||||
return NULL;
|
||||
printf("\t\t\t\t\t\t( %lu %lu %lu %lu %lu )",
|
||||
(unsigned long)DNS__32BIT(p), (unsigned long)DNS__32BIT(p+4),
|
||||
(unsigned long)DNS__32BIT(p+8), (unsigned long)DNS__32BIT(p+12),
|
||||
(unsigned long)DNS__32BIT(p+16));
|
||||
printf("\t\t\t\t\t\t( %u %u %u %u %u )",
|
||||
DNS__32BIT(p), DNS__32BIT(p+4),
|
||||
DNS__32BIT(p+8), DNS__32BIT(p+12),
|
||||
DNS__32BIT(p+16));
|
||||
break;
|
||||
|
||||
case T_TXT:
|
||||
@@ -664,9 +711,9 @@ static const unsigned char *display_rr(const unsigned char *aptr,
|
||||
* priority, weight, and port, followed by a domain name.
|
||||
*/
|
||||
|
||||
printf("\t%d", DNS__16BIT(aptr));
|
||||
printf(" %d", DNS__16BIT(aptr + 2));
|
||||
printf(" %d", DNS__16BIT(aptr + 4));
|
||||
printf("\t%d", (int)DNS__16BIT(aptr));
|
||||
printf(" %d", (int)DNS__16BIT(aptr + 2));
|
||||
printf(" %d", (int)DNS__16BIT(aptr + 4));
|
||||
|
||||
status = ares_expand_name(aptr + 6, abuf, alen, &name.as_char, &len);
|
||||
if (status != ARES_SUCCESS)
|
||||
@@ -677,8 +724,8 @@ static const unsigned char *display_rr(const unsigned char *aptr,
|
||||
|
||||
case T_NAPTR:
|
||||
|
||||
printf("\t%d", DNS__16BIT(aptr)); /* order */
|
||||
printf(" %d\n", DNS__16BIT(aptr + 2)); /* preference */
|
||||
printf("\t%d", (int)DNS__16BIT(aptr)); /* order */
|
||||
printf(" %d\n", (int)DNS__16BIT(aptr + 2)); /* preference */
|
||||
|
||||
p = aptr + 4;
|
||||
status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
|
||||
@@ -702,13 +749,20 @@ static const unsigned char *display_rr(const unsigned char *aptr,
|
||||
ares_free_string(name.as_char);
|
||||
p += len;
|
||||
|
||||
status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
|
||||
status = ares_expand_name(p, abuf, alen, &name.as_char, &len);
|
||||
if (status != ARES_SUCCESS)
|
||||
return NULL;
|
||||
printf("\t\t\t\t\t\t%s", name.as_char);
|
||||
ares_free_string(name.as_char);
|
||||
break;
|
||||
|
||||
case T_DS:
|
||||
case T_SSHFP:
|
||||
case T_RRSIG:
|
||||
case T_NSEC:
|
||||
case T_DNSKEY:
|
||||
printf("\t[RR type parsing unavailable]");
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("\t[Unknown RR; cannot parse]");
|
||||
@@ -745,7 +799,48 @@ static const char *class_name(int dnsclass)
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage: adig [-f flag] [-s server] [-c class] "
|
||||
"[-t type] [-p port] name ...\n");
|
||||
exit(1);
|
||||
fprintf(stderr,
|
||||
#ifdef ANSI_CONSOLE
|
||||
"\33[33mdig version " ARES_VERSION_STR " (c) " ARES_COPYRIGHT "\33[31m\n"
|
||||
#else
|
||||
"dig version " ARES_VERSION_STR " (c) " ARES_COPYRIGHT "\n"
|
||||
#endif
|
||||
"Usage: dig [options] name\n"
|
||||
"\t-s <server>: connect to specified DNS server. Default is 8.8.8.8.\n"
|
||||
"\t-f <class>: set the query class: NY, CHAOS, HS, IN (default)\n"
|
||||
"\t-f <flag>: add a flag: igntc, noaliases, norecurse, primary, stayopen, usevc\n"
|
||||
"\t-t <type>: query records of specified type, default is A. Possible values:\n"
|
||||
"\t AAAA, AFSDB, ANY, AXFR, CNAME, GPOS, HINFO, ISDN, KEY,LOC,\n"
|
||||
"\t MAILA, MAILB, MB, MD, MF, MG, MINFO, MR, MX, NAPTR, NS, NSAP\n"
|
||||
"\t NSAP_PTR, NULL, PTR, PX, RP, RT, SIG, SOA, SRV, TXT, WKS, X25\n"
|
||||
"\t-p <port>: use specified TCP port to connect to DNS server\n"
|
||||
"\t-U <port>: use specified UDP port to connect to DNS server\n"
|
||||
);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void destroy_addr_list(struct ares_addr_node *head)
|
||||
{
|
||||
while(head)
|
||||
{
|
||||
struct ares_addr_node *detached = head;
|
||||
head = head->next;
|
||||
free(detached);
|
||||
}
|
||||
}
|
||||
|
||||
static void append_addr_list(struct ares_addr_node **head,
|
||||
struct ares_addr_node *node)
|
||||
{
|
||||
struct ares_addr_node *last;
|
||||
node->next = NULL;
|
||||
if(*head)
|
||||
{
|
||||
last = *head;
|
||||
while(last->next)
|
||||
last = last->next;
|
||||
last->next = node;
|
||||
}
|
||||
else
|
||||
*head = node;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
.TH HOST "1" "April 2011" "c-ares utilities"
|
||||
.SH NAME
|
||||
host \- print the A or AAAA record associated with a hostname or IP address
|
||||
.SH SYNOPSIS
|
||||
.B host
|
||||
[\fIOPTION\fR]... \fIHOST\fR...
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
.\" Add any additional description here
|
||||
.PP
|
||||
Look up the DNS A or AAAA record associated with HOST (a hostname or an
|
||||
IP address).
|
||||
.PP
|
||||
This utility comes with the \fBc\-ares\fR asynchronous resolver library.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-d\fR
|
||||
Print some extra debugging output.
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Display this help and exit.
|
||||
.TP
|
||||
\fB\-t\fR type
|
||||
If type is "a", print the A record (default).
|
||||
If type is "aaaa", print the AAAA record.
|
||||
If type is "u", look for either AAAA or A record (in that order).
|
||||
.TP
|
||||
\fB\-s\fR \fIdomain\fP
|
||||
Specify the \fIdomain\fP to search instead of using the default values from
|
||||
.br
|
||||
/etc/resolv.conf. This option only has an effect on platforms that use
|
||||
.br
|
||||
/etc/resolv.conf
|
||||
for DNS configuration; it has no effect on other platforms (such as Win32
|
||||
or Android).
|
||||
.SH "REPORTING BUGS"
|
||||
Report bugs to the c-ares mailing list:
|
||||
\fBhttp://cool.haxx.se/mailman/listinfo/c-ares\fR
|
||||
.SH "SEE ALSO"
|
||||
.PP
|
||||
acountry(1), adig(1).
|
||||
.SH COPYRIGHT
|
||||
This utility is based on code/ideas contained in sofware written by Greg Hudson (ares)
|
||||
carrying the following notice:
|
||||
.br
|
||||
Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.br
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted,
|
||||
provided that the above copyright notice appear in all copies and that
|
||||
both that copyright notice and this permission notice appear in
|
||||
supporting documentation, and that the name of M.I.T. not be used in
|
||||
advertising or publicity pertaining to distribution of the software
|
||||
without specific, written prior permission. M.I.T. makes no
|
||||
representations about the suitability of this software for any
|
||||
purpose. It is provided "as is" without express or implied warranty.
|
||||
.br
|
||||
No further copyright claims are being made by the author(s) of this utility.
|
||||
@@ -1,6 +1,5 @@
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose and without
|
||||
@@ -18,31 +17,20 @@
|
||||
#include "ares_setup.h"
|
||||
|
||||
#if !defined(WIN32) || defined(WATT32)
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_dns.h"
|
||||
#include "inet_ntop.h"
|
||||
#include "inet_net_pton.h"
|
||||
#include "ares_getopt.h"
|
||||
#include "ares_ipv6.h"
|
||||
#include "ares_nowarn.h"
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
# include "ares_strdup.h"
|
||||
@@ -62,14 +50,20 @@
|
||||
static void callback(void *arg, int status, int timeouts, struct hostent *host);
|
||||
static void usage(void);
|
||||
|
||||
const char *vers = "\0$VER: host 1.12 (29.09.2016) c-ares " ARES_VERSION_STR;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct ares_options options;
|
||||
int optmask = 0;
|
||||
ares_channel channel;
|
||||
int status, nfds, c, addr_family = AF_INET;
|
||||
fd_set read_fds, write_fds;
|
||||
struct timeval *tvp, tv;
|
||||
struct in_addr addr4;
|
||||
struct in6_addr addr6;
|
||||
struct ares_in6_addr addr6;
|
||||
|
||||
prog = argv[0];
|
||||
|
||||
#ifdef USE_WINSOCK
|
||||
WORD wVersionRequested = MAKEWORD(USE_WINSOCK,USE_WINSOCK);
|
||||
@@ -77,6 +71,8 @@ int main(int argc, char **argv)
|
||||
WSAStartup(wVersionRequested, &wsaData);
|
||||
#endif
|
||||
|
||||
memset(&options, 0, sizeof(options));
|
||||
|
||||
status = ares_library_init(ARES_LIB_INIT_ALL);
|
||||
if (status != ARES_SUCCESS)
|
||||
{
|
||||
@@ -84,7 +80,7 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
while ((c = ares_getopt(argc,argv,"dt:h")) != -1)
|
||||
while ((c = ares_getopt(argc,argv,"dt:hs:")) != -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
@@ -93,11 +89,20 @@ int main(int argc, char **argv)
|
||||
dbug_init();
|
||||
#endif
|
||||
break;
|
||||
case 's':
|
||||
optmask |= ARES_OPT_DOMAINS;
|
||||
options.ndomains++;
|
||||
options.domains = (char **)realloc(options.domains,
|
||||
options.ndomains * sizeof(char *));
|
||||
options.domains[options.ndomains - 1] = strdup(optarg);
|
||||
break;
|
||||
case 't':
|
||||
if (!strcasecmp(optarg,"a"))
|
||||
addr_family = AF_INET;
|
||||
else if (!strcasecmp(optarg,"aaaa"))
|
||||
addr_family = AF_INET6;
|
||||
else if (!strcasecmp(optarg,"u"))
|
||||
addr_family = AF_UNSPEC;
|
||||
else
|
||||
usage();
|
||||
break;
|
||||
@@ -113,7 +118,7 @@ int main(int argc, char **argv)
|
||||
if (argc < 1)
|
||||
usage();
|
||||
|
||||
status = ares_init(&channel);
|
||||
status = ares_init_options(&channel, &options, optmask);
|
||||
if (status != ARES_SUCCESS)
|
||||
{
|
||||
fprintf(stderr, "ares_init: %s\n", ares_strerror(status));
|
||||
@@ -142,13 +147,16 @@ int main(int argc, char **argv)
|
||||
/* Wait for all queries to complete. */
|
||||
for (;;)
|
||||
{
|
||||
int res;
|
||||
FD_ZERO(&read_fds);
|
||||
FD_ZERO(&write_fds);
|
||||
nfds = ares_fds(channel, &read_fds, &write_fds);
|
||||
if (nfds == 0)
|
||||
break;
|
||||
tvp = ares_timeout(channel, NULL, &tv);
|
||||
select(nfds, &read_fds, &write_fds, NULL, tvp);
|
||||
res = select(nfds, &read_fds, &write_fds, NULL, tvp);
|
||||
if (-1 == res)
|
||||
break;
|
||||
ares_process(channel, &read_fds, &write_fds);
|
||||
}
|
||||
|
||||
@@ -197,6 +205,16 @@ static void callback(void *arg, int status, int timeouts, struct hostent *host)
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage: ahost [-t {a|aaaa}] {host|addr} ...\n");
|
||||
exit(1);
|
||||
fprintf(stderr,
|
||||
#ifdef ANSI_CONSOLE
|
||||
"\33[33mhost version " ARES_VERSION_STR " (c) " ARES_COPYRIGHT "\33[31m\n"
|
||||
#else
|
||||
"host version " ARES_VERSION_STR " (c) " ARES_COPYRIGHT "\n"
|
||||
#endif
|
||||
"Usage: host [-t type] { host | addr } ...\n"
|
||||
"\t-ta: print the A record (default)\n"
|
||||
"\t-tu: look for either AAAA or A record\n"
|
||||
"\t-taaaa: print the AAAA record\n"
|
||||
);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
#include "ares_setup.h"
|
||||
#if defined(AOS3) || defined(AROS)
|
||||
|
||||
/*
|
||||
* Written by Carsten Larsen.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <clib/exec_protos.h>
|
||||
#include <clib/timer_protos.h>
|
||||
#include <clib/utility_protos.h>
|
||||
#include <clib/alib_protos.h>
|
||||
|
||||
#define OPEN_ERROR "Cannot open %s.\n"
|
||||
#define OPEN_VER_ERROR "Cannot open %s (%d.0)\n"
|
||||
#define DOSLIB_NAME "dos.library"
|
||||
#define DOSLIB_REV 37L
|
||||
#define BSDLIB_NAME "bsdsocket.library"
|
||||
#define BSDLIB_REV 03L
|
||||
#define LIB_ERROR 5
|
||||
|
||||
#ifdef AOS3
|
||||
#define IPTR ULONG
|
||||
#endif
|
||||
|
||||
#ifdef AOS3
|
||||
int h_errno;
|
||||
#endif
|
||||
|
||||
struct Library* DOSBase = NULL;
|
||||
struct Library* SocketBase = NULL;
|
||||
|
||||
char *prog;
|
||||
|
||||
void amiga_open_error(char *name)
|
||||
{
|
||||
printf(OPEN_ERROR, name);
|
||||
}
|
||||
|
||||
void amiga_open_lib_error(char *name, int version)
|
||||
{
|
||||
printf(OPEN_VER_ERROR, name, version);
|
||||
}
|
||||
|
||||
void ares_amiga_cleanup()
|
||||
{
|
||||
if (SocketBase != NULL) {
|
||||
CloseLibrary(SocketBase);
|
||||
SocketBase = NULL;
|
||||
}
|
||||
|
||||
if (DOSBase != NULL) {
|
||||
CloseLibrary(DOSBase);
|
||||
DOSBase = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int ares_amiga_init()
|
||||
{
|
||||
if((DOSBase = OpenLibrary((STRPTR)DOSLIB_NAME, DOSLIB_REV)) == NULL) {
|
||||
amiga_open_lib_error(DOSLIB_NAME, DOSLIB_REV);
|
||||
return LIB_ERROR;
|
||||
}
|
||||
|
||||
if((SocketBase = OpenLibrary((STRPTR)BSDLIB_NAME, BSDLIB_REV)) == NULL) {
|
||||
amiga_open_lib_error(BSDLIB_NAME, BSDLIB_REV);
|
||||
return LIB_ERROR;
|
||||
} else {
|
||||
SocketBaseTags(
|
||||
SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))), (IPTR) &errno,
|
||||
SBTM_SETVAL(SBTC_HERRNOLONGPTR), (IPTR) &h_errno,
|
||||
SBTM_SETVAL(SBTC_LOGTAGPTR), (IPTR) &prog,
|
||||
TAG_DONE );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
platform:
|
||||
- x64
|
||||
- x86
|
||||
build_script:
|
||||
- if "%platform%" == "x86" call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat"
|
||||
- if "%platform%" == "x64" "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64
|
||||
- if "%platform%" == "x64" call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64
|
||||
- copy ares_build.h.dist ares_build.h
|
||||
- nmake /f Makefile.msvc
|
||||
- cd test
|
||||
- nmake /f Makefile.msvc vtest
|
||||
@@ -1,7 +1,6 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright 1998, 2009 by the Massachusetts Institute of Technology.
|
||||
* Copyright (C) 2007-2009 by Daniel Stenberg
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
* Copyright (C) 2007-2013 by Daniel Stenberg
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose and without
|
||||
@@ -38,7 +37,8 @@
|
||||
libc5-based Linux systems. Only include it on system that are known to
|
||||
require it! */
|
||||
#if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \
|
||||
defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY)
|
||||
defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY) || \
|
||||
defined(ANDROID) || defined(__ANDROID__)
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
#if (defined(NETWARE) && !defined(__NOVELL_LIBC__))
|
||||
@@ -49,6 +49,12 @@
|
||||
# include <netinet/in.h>
|
||||
# include <sys/socket.h>
|
||||
# include <tcp.h>
|
||||
#elif defined(_WIN32_WCE)
|
||||
# ifndef WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# endif
|
||||
# include <windows.h>
|
||||
# include <winsock.h>
|
||||
#elif defined(WIN32)
|
||||
# ifndef WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
@@ -69,22 +75,18 @@ extern "C" {
|
||||
** c-ares external API function linkage decorations.
|
||||
*/
|
||||
|
||||
#if !defined(CARES_STATICLIB) && \
|
||||
(defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__))
|
||||
/* __declspec function decoration for Win32 and Symbian DLL's */
|
||||
#ifdef CARES_STATICLIB
|
||||
# define CARES_EXTERN
|
||||
#elif defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__)
|
||||
# if defined(CARES_BUILDING_LIBRARY)
|
||||
# define CARES_EXTERN __declspec(dllexport)
|
||||
# else
|
||||
# define CARES_EXTERN __declspec(dllimport)
|
||||
# endif
|
||||
#elif defined(CARES_BUILDING_LIBRARY) && defined(CARES_SYMBOL_HIDING)
|
||||
# define CARES_EXTERN CARES_SYMBOL_SCOPE_EXTERN
|
||||
#else
|
||||
/* visibility function decoration for other cases */
|
||||
# if !defined(CARES_SYMBOL_HIDING) || \
|
||||
defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__)
|
||||
# define CARES_EXTERN
|
||||
# else
|
||||
# define CARES_EXTERN CARES_SYMBOL_SCOPE_EXTERN
|
||||
# endif
|
||||
# define CARES_EXTERN
|
||||
#endif
|
||||
|
||||
|
||||
@@ -137,6 +139,7 @@ extern "C" {
|
||||
#define ARES_FLAG_NOSEARCH (1 << 5)
|
||||
#define ARES_FLAG_NOALIASES (1 << 6)
|
||||
#define ARES_FLAG_NOCHECKRESP (1 << 7)
|
||||
#define ARES_FLAG_EDNS (1 << 8)
|
||||
|
||||
/* Option mask values */
|
||||
#define ARES_OPT_FLAGS (1 << 0)
|
||||
@@ -154,6 +157,8 @@ extern "C" {
|
||||
#define ARES_OPT_SOCK_RCVBUF (1 << 12)
|
||||
#define ARES_OPT_TIMEOUTMS (1 << 13)
|
||||
#define ARES_OPT_ROTATE (1 << 14)
|
||||
#define ARES_OPT_EDNSPSZ (1 << 15)
|
||||
#define ARES_OPT_NOROTATE (1 << 16)
|
||||
|
||||
/* Nameinfo flag values */
|
||||
#define ARES_NI_NOFQDN (1 << 0)
|
||||
@@ -199,7 +204,8 @@ extern "C" {
|
||||
/* c-ares library initialization flag values */
|
||||
#define ARES_LIB_INIT_NONE (0)
|
||||
#define ARES_LIB_INIT_WIN32 (1 << 0)
|
||||
#define ARES_LIB_INIT_ALL (ARES_LIB_INIT_WIN32)
|
||||
#define ARES_LIB_INIT_AMIGA (2 << 0)
|
||||
#define ARES_LIB_INIT_ALL (ARES_LIB_INIT_WIN32 | ARES_LIB_INIT_AMIGA)
|
||||
|
||||
|
||||
/*
|
||||
@@ -259,6 +265,7 @@ struct ares_options {
|
||||
void *sock_state_cb_data;
|
||||
struct apattern *sortlist;
|
||||
int nsort;
|
||||
int ednspsz;
|
||||
};
|
||||
|
||||
struct hostent;
|
||||
@@ -289,8 +296,19 @@ typedef int (*ares_sock_create_callback)(ares_socket_t socket_fd,
|
||||
int type,
|
||||
void *data);
|
||||
|
||||
typedef int (*ares_sock_config_callback)(ares_socket_t socket_fd,
|
||||
int type,
|
||||
void *data);
|
||||
|
||||
CARES_EXTERN int ares_library_init(int flags);
|
||||
|
||||
CARES_EXTERN int ares_library_init_mem(int flags,
|
||||
void *(*amalloc)(size_t size),
|
||||
void (*afree)(void *ptr),
|
||||
void *(*arealloc)(void *ptr, size_t size));
|
||||
|
||||
CARES_EXTERN int ares_library_initialized(void);
|
||||
|
||||
CARES_EXTERN void ares_library_cleanup(void);
|
||||
|
||||
CARES_EXTERN const char *ares_version(int *version);
|
||||
@@ -314,10 +332,31 @@ CARES_EXTERN void ares_destroy(ares_channel channel);
|
||||
|
||||
CARES_EXTERN void ares_cancel(ares_channel channel);
|
||||
|
||||
/* These next 3 configure local binding for the out-going socket
|
||||
* connection. Use these to specify source IP and/or network device
|
||||
* on multi-homed systems.
|
||||
*/
|
||||
CARES_EXTERN void ares_set_local_ip4(ares_channel channel, unsigned int local_ip);
|
||||
|
||||
/* local_ip6 should be 16 bytes in length */
|
||||
CARES_EXTERN void ares_set_local_ip6(ares_channel channel,
|
||||
const unsigned char* local_ip6);
|
||||
|
||||
/* local_dev_name should be null terminated. */
|
||||
CARES_EXTERN void ares_set_local_dev(ares_channel channel,
|
||||
const char* local_dev_name);
|
||||
|
||||
CARES_EXTERN void ares_set_socket_callback(ares_channel channel,
|
||||
ares_sock_create_callback callback,
|
||||
void *user_data);
|
||||
|
||||
CARES_EXTERN void ares_set_socket_configure_callback(ares_channel channel,
|
||||
ares_sock_config_callback callback,
|
||||
void *user_data);
|
||||
|
||||
CARES_EXTERN int ares_set_sortlist(ares_channel channel,
|
||||
const char *sortstr);
|
||||
|
||||
CARES_EXTERN void ares_send(ares_channel channel,
|
||||
const unsigned char *qbuf,
|
||||
int qlen,
|
||||
@@ -368,7 +407,7 @@ CARES_EXTERN int ares_fds(ares_channel channel,
|
||||
fd_set *write_fds);
|
||||
|
||||
CARES_EXTERN int ares_getsock(ares_channel channel,
|
||||
int *socks,
|
||||
ares_socket_t *socks,
|
||||
int numsocks);
|
||||
|
||||
CARES_EXTERN struct timeval *ares_timeout(ares_channel channel,
|
||||
@@ -383,6 +422,15 @@ CARES_EXTERN void ares_process_fd(ares_channel channel,
|
||||
ares_socket_t read_fd,
|
||||
ares_socket_t write_fd);
|
||||
|
||||
CARES_EXTERN int ares_create_query(const char *name,
|
||||
int dnsclass,
|
||||
int type,
|
||||
unsigned short id,
|
||||
int rd,
|
||||
unsigned char **buf,
|
||||
int *buflen,
|
||||
int max_udp_size);
|
||||
|
||||
CARES_EXTERN int ares_mkquery(const char *name,
|
||||
int dnsclass,
|
||||
int type,
|
||||
@@ -434,12 +482,49 @@ struct ares_srv_reply {
|
||||
unsigned short port;
|
||||
};
|
||||
|
||||
struct ares_mx_reply {
|
||||
struct ares_mx_reply *next;
|
||||
char *host;
|
||||
unsigned short priority;
|
||||
};
|
||||
|
||||
struct ares_txt_reply {
|
||||
struct ares_txt_reply *next;
|
||||
unsigned char *txt;
|
||||
size_t length; /* length excludes null termination */
|
||||
};
|
||||
|
||||
/* NOTE: This structure is a superset of ares_txt_reply
|
||||
*/
|
||||
struct ares_txt_ext {
|
||||
struct ares_txt_ext *next;
|
||||
unsigned char *txt;
|
||||
size_t length;
|
||||
/* 1 - if start of new record
|
||||
* 0 - if a chunk in the same record */
|
||||
unsigned char record_start;
|
||||
};
|
||||
|
||||
struct ares_naptr_reply {
|
||||
struct ares_naptr_reply *next;
|
||||
unsigned char *flags;
|
||||
unsigned char *service;
|
||||
unsigned char *regexp;
|
||||
char *replacement;
|
||||
unsigned short order;
|
||||
unsigned short preference;
|
||||
};
|
||||
|
||||
struct ares_soa_reply {
|
||||
char *nsname;
|
||||
char *hostmaster;
|
||||
unsigned int serial;
|
||||
unsigned int refresh;
|
||||
unsigned int retry;
|
||||
unsigned int expire;
|
||||
unsigned int minttl;
|
||||
};
|
||||
|
||||
/*
|
||||
** Parse the buffer, starting at *abuf and of length alen bytes, previously
|
||||
** obtained from an ares_search call. Put the results in *host, if nonnull.
|
||||
@@ -475,10 +560,26 @@ CARES_EXTERN int ares_parse_srv_reply(const unsigned char* abuf,
|
||||
int alen,
|
||||
struct ares_srv_reply** srv_out);
|
||||
|
||||
CARES_EXTERN int ares_parse_mx_reply(const unsigned char* abuf,
|
||||
int alen,
|
||||
struct ares_mx_reply** mx_out);
|
||||
|
||||
CARES_EXTERN int ares_parse_txt_reply(const unsigned char* abuf,
|
||||
int alen,
|
||||
struct ares_txt_reply** txt_out);
|
||||
|
||||
CARES_EXTERN int ares_parse_txt_reply_ext(const unsigned char* abuf,
|
||||
int alen,
|
||||
struct ares_txt_ext** txt_out);
|
||||
|
||||
CARES_EXTERN int ares_parse_naptr_reply(const unsigned char* abuf,
|
||||
int alen,
|
||||
struct ares_naptr_reply** naptr_out);
|
||||
|
||||
CARES_EXTERN int ares_parse_soa_reply(const unsigned char* abuf,
|
||||
int alen,
|
||||
struct ares_soa_reply** soa_out);
|
||||
|
||||
CARES_EXTERN void ares_free_string(void *str);
|
||||
|
||||
CARES_EXTERN void ares_free_hostent(struct hostent *host);
|
||||
@@ -487,6 +588,48 @@ CARES_EXTERN void ares_free_data(void *dataptr);
|
||||
|
||||
CARES_EXTERN const char *ares_strerror(int code);
|
||||
|
||||
struct ares_addr_node {
|
||||
struct ares_addr_node *next;
|
||||
int family;
|
||||
union {
|
||||
struct in_addr addr4;
|
||||
struct ares_in6_addr addr6;
|
||||
} addr;
|
||||
};
|
||||
|
||||
struct ares_addr_port_node {
|
||||
struct ares_addr_port_node *next;
|
||||
int family;
|
||||
union {
|
||||
struct in_addr addr4;
|
||||
struct ares_in6_addr addr6;
|
||||
} addr;
|
||||
int udp_port;
|
||||
int tcp_port;
|
||||
};
|
||||
|
||||
CARES_EXTERN int ares_set_servers(ares_channel channel,
|
||||
struct ares_addr_node *servers);
|
||||
CARES_EXTERN int ares_set_servers_ports(ares_channel channel,
|
||||
struct ares_addr_port_node *servers);
|
||||
|
||||
/* Incomming string format: host[:port][,host[:port]]... */
|
||||
CARES_EXTERN int ares_set_servers_csv(ares_channel channel,
|
||||
const char* servers);
|
||||
CARES_EXTERN int ares_set_servers_ports_csv(ares_channel channel,
|
||||
const char* servers);
|
||||
|
||||
CARES_EXTERN int ares_get_servers(ares_channel channel,
|
||||
struct ares_addr_node **servers);
|
||||
CARES_EXTERN int ares_get_servers_ports(ares_channel channel,
|
||||
struct ares_addr_port_node **servers);
|
||||
|
||||
CARES_EXTERN const char *ares_inet_ntop(int af, const void *src, char *dst,
|
||||
ares_socklen_t size);
|
||||
|
||||
CARES_EXTERN int ares_inet_pton(int af, const char *src, void *dst);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
*
|
||||
@@ -17,11 +16,6 @@
|
||||
|
||||
#include "ares_setup.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
@@ -36,14 +30,14 @@ void ares__close_sockets(ares_channel channel, struct server_state *server)
|
||||
sendreq = server->qhead;
|
||||
server->qhead = sendreq->next;
|
||||
if (sendreq->data_storage != NULL)
|
||||
free(sendreq->data_storage);
|
||||
free(sendreq);
|
||||
ares_free(sendreq->data_storage);
|
||||
ares_free(sendreq);
|
||||
}
|
||||
server->qtail = NULL;
|
||||
|
||||
/* Reset any existing input buffer. */
|
||||
if (server->tcp_buffer)
|
||||
free(server->tcp_buffer);
|
||||
ares_free(server->tcp_buffer);
|
||||
server->tcp_buffer = NULL;
|
||||
server->tcp_lenbuf_pos = 0;
|
||||
|
||||
|
||||
+24
-27
@@ -1,6 +1,5 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright 1998, 2009 by the Massachusetts Institute of Technology.
|
||||
/* Copyright 1998, 2011 by the Massachusetts Institute of Technology.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose and without
|
||||
@@ -17,9 +16,6 @@
|
||||
|
||||
#include "ares_setup.h"
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
@@ -31,7 +27,8 @@
|
||||
#endif
|
||||
|
||||
#include "ares.h"
|
||||
#include "inet_net_pton.h"
|
||||
#include "ares_inet_net_pton.h"
|
||||
#include "ares_nowarn.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
int ares__get_hostent(FILE *fp, int family, struct hostent **host)
|
||||
@@ -97,7 +94,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
|
||||
p++;
|
||||
if (!*p)
|
||||
/* Ignore line if reached end of line. */
|
||||
continue;
|
||||
continue; /* LCOV_EXCL_LINE: trailing whitespace already stripped */
|
||||
|
||||
/* Pointer to start of host name. */
|
||||
txthost = p;
|
||||
@@ -146,7 +143,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
|
||||
{
|
||||
/* Actual network address family and length. */
|
||||
addr.family = AF_INET;
|
||||
addrlen = sizeof(struct in_addr);
|
||||
addrlen = sizeof(addr.addrV4);
|
||||
}
|
||||
}
|
||||
if ((family == AF_INET6) || ((family == AF_UNSPEC) && (!addrlen)))
|
||||
@@ -155,7 +152,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
|
||||
{
|
||||
/* Actual network address family and length. */
|
||||
addr.family = AF_INET6;
|
||||
addrlen = sizeof(struct in6_addr);
|
||||
addrlen = sizeof(addr.addrV6);
|
||||
}
|
||||
}
|
||||
if (!addrlen)
|
||||
@@ -167,7 +164,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
|
||||
*/
|
||||
|
||||
/* Allocate memory for the hostent structure. */
|
||||
hostent = malloc(sizeof(struct hostent));
|
||||
hostent = ares_malloc(sizeof(struct hostent));
|
||||
if (!hostent)
|
||||
break;
|
||||
|
||||
@@ -176,25 +173,25 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
|
||||
hostent->h_addr_list = NULL;
|
||||
|
||||
/* Copy official host name. */
|
||||
hostent->h_name = strdup(txthost);
|
||||
hostent->h_name = ares_strdup(txthost);
|
||||
if (!hostent->h_name)
|
||||
break;
|
||||
|
||||
/* Copy network address. */
|
||||
hostent->h_addr_list = malloc(2 * sizeof(char *));
|
||||
hostent->h_addr_list = ares_malloc(2 * sizeof(char *));
|
||||
if (!hostent->h_addr_list)
|
||||
break;
|
||||
hostent->h_addr_list[1] = NULL;
|
||||
hostent->h_addr_list[0] = malloc(addrlen);
|
||||
hostent->h_addr_list[0] = ares_malloc(addrlen);
|
||||
if (!hostent->h_addr_list[0])
|
||||
break;
|
||||
if (addr.family == AF_INET)
|
||||
memcpy(hostent->h_addr_list[0], &addr.addrV4, sizeof(struct in_addr));
|
||||
memcpy(hostent->h_addr_list[0], &addr.addrV4, sizeof(addr.addrV4));
|
||||
else
|
||||
memcpy(hostent->h_addr_list[0], &addr.addrV6, sizeof(struct in6_addr));
|
||||
memcpy(hostent->h_addr_list[0], &addr.addrV6, sizeof(addr.addrV6));
|
||||
|
||||
/* Copy aliases. */
|
||||
hostent->h_aliases = malloc((naliases + 1) * sizeof(char *));
|
||||
hostent->h_aliases = ares_malloc((naliases + 1) * sizeof(char *));
|
||||
if (!hostent->h_aliases)
|
||||
break;
|
||||
alias = hostent->h_aliases;
|
||||
@@ -210,7 +207,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
|
||||
while (*q && ISSPACE(*q))
|
||||
q++;
|
||||
*p = '\0';
|
||||
if ((*alias = strdup(txtalias)) == NULL)
|
||||
if ((*alias = ares_strdup(txtalias)) == NULL)
|
||||
break;
|
||||
alias++;
|
||||
txtalias = *q ? q : NULL;
|
||||
@@ -220,11 +217,11 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
|
||||
break;
|
||||
|
||||
/* Copy actual network address family and length. */
|
||||
hostent->h_addrtype = addr.family;
|
||||
hostent->h_length = (int)addrlen;
|
||||
hostent->h_addrtype = aresx_sitoss(addr.family);
|
||||
hostent->h_length = aresx_uztoss(addrlen);
|
||||
|
||||
/* Free line buffer. */
|
||||
free(line);
|
||||
ares_free(line);
|
||||
|
||||
/* Return hostent successfully */
|
||||
*host = hostent;
|
||||
@@ -234,7 +231,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
|
||||
|
||||
/* If allocated, free line buffer. */
|
||||
if (line)
|
||||
free(line);
|
||||
ares_free(line);
|
||||
|
||||
if (status == ARES_SUCCESS)
|
||||
{
|
||||
@@ -242,20 +239,20 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
|
||||
if (hostent)
|
||||
{
|
||||
if (hostent->h_name)
|
||||
free((char *) hostent->h_name);
|
||||
ares_free((char *) hostent->h_name);
|
||||
if (hostent->h_aliases)
|
||||
{
|
||||
for (alias = hostent->h_aliases; *alias; alias++)
|
||||
free(*alias);
|
||||
free(hostent->h_aliases);
|
||||
ares_free(*alias);
|
||||
ares_free(hostent->h_aliases);
|
||||
}
|
||||
if (hostent->h_addr_list)
|
||||
{
|
||||
if (hostent->h_addr_list[0])
|
||||
free(hostent->h_addr_list[0]);
|
||||
free(hostent->h_addr_list);
|
||||
ares_free(hostent->h_addr_list[0]);
|
||||
ares_free(hostent->h_addr_list);
|
||||
}
|
||||
free(hostent);
|
||||
ares_free(hostent);
|
||||
}
|
||||
return ARES_ENOMEM;
|
||||
}
|
||||
|
||||
+14
-8
@@ -1,4 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
*
|
||||
@@ -16,10 +15,9 @@
|
||||
*/
|
||||
|
||||
#include "ares_setup.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_nowarn.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
/* This is an internal function. Its contract is to read a line from
|
||||
@@ -38,7 +36,7 @@ int ares__read_line(FILE *fp, char **buf, size_t *bufsize)
|
||||
|
||||
if (*buf == NULL)
|
||||
{
|
||||
*buf = malloc(128);
|
||||
*buf = ares_malloc(128);
|
||||
if (!*buf)
|
||||
return ARES_ENOMEM;
|
||||
*bufsize = 128;
|
||||
@@ -46,7 +44,9 @@ int ares__read_line(FILE *fp, char **buf, size_t *bufsize)
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (!fgets(*buf + offset, (int)(*bufsize - offset), fp))
|
||||
int bytestoread = aresx_uztosi(*bufsize - offset);
|
||||
|
||||
if (!fgets(*buf + offset, bytestoread, fp))
|
||||
return (offset != 0) ? 0 : (ferror(fp)) ? ARES_EFILE : ARES_EOF;
|
||||
len = offset + strlen(*buf + offset);
|
||||
if ((*buf)[len - 1] == '\n')
|
||||
@@ -55,11 +55,17 @@ int ares__read_line(FILE *fp, char **buf, size_t *bufsize)
|
||||
break;
|
||||
}
|
||||
offset = len;
|
||||
if(len < *bufsize - 1)
|
||||
continue;
|
||||
|
||||
/* Allocate more space. */
|
||||
newbuf = realloc(*buf, *bufsize * 2);
|
||||
newbuf = ares_realloc(*buf, *bufsize * 2);
|
||||
if (!newbuf)
|
||||
return ARES_ENOMEM;
|
||||
{
|
||||
ares_free(*buf);
|
||||
*buf = NULL;
|
||||
return ARES_ENOMEM;
|
||||
}
|
||||
*buf = newbuf;
|
||||
*bufsize *= 2;
|
||||
}
|
||||
|
||||
+1
-2
@@ -1,4 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 2008 by Daniel Stenberg et al
|
||||
*
|
||||
@@ -57,7 +56,7 @@ struct timeval ares__tvnow(void)
|
||||
*/
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
else
|
||||
(void)gettimeofday(&now, NULL);
|
||||
(void)gettimeofday(&now, NULL); /* LCOV_EXCL_LINE */
|
||||
#else
|
||||
else {
|
||||
now.tv_sec = (long)time(NULL);
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
/* ares_build.h. Generated from ares_build.h.in by configure. */
|
||||
#ifndef __CARES_BUILD_H
|
||||
#define __CARES_BUILD_H
|
||||
|
||||
|
||||
/* Copyright (C) 2009 by Daniel Stenberg et al
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted, provided
|
||||
* that the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of M.I.T. not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. M.I.T. makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*/
|
||||
|
||||
/* ================================================================ */
|
||||
/* NOTES FOR CONFIGURE CAPABLE SYSTEMS */
|
||||
/* ================================================================ */
|
||||
|
||||
/*
|
||||
* NOTE 1:
|
||||
* -------
|
||||
*
|
||||
* Nothing in this file is intended to be modified or adjusted by the
|
||||
* c-ares library user nor by the c-ares library builder.
|
||||
*
|
||||
* If you think that something actually needs to be changed, adjusted
|
||||
* or fixed in this file, then, report it on the c-ares development
|
||||
* mailing list: http://cool.haxx.se/mailman/listinfo/c-ares/
|
||||
*
|
||||
* This header file shall only export symbols which are 'cares' or 'CARES'
|
||||
* prefixed, otherwise public name space would be polluted.
|
||||
*
|
||||
* NOTE 2:
|
||||
* -------
|
||||
*
|
||||
* Right now you might be staring at file ares_build.h.in or ares_build.h,
|
||||
* this is due to the following reason:
|
||||
*
|
||||
* On systems capable of running the configure script, the configure process
|
||||
* will overwrite the distributed ares_build.h file with one that is suitable
|
||||
* and specific to the library being configured and built, which is generated
|
||||
* from the ares_build.h.in template file.
|
||||
*
|
||||
*/
|
||||
|
||||
/* ================================================================ */
|
||||
/* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */
|
||||
/* ================================================================ */
|
||||
|
||||
#ifdef CARES_TYPEOF_ARES_SOCKLEN_T
|
||||
# error "CARES_TYPEOF_ARES_SOCKLEN_T shall not be defined except in ares_build.h"
|
||||
Error Compilation_aborted_CARES_TYPEOF_ARES_SOCKLEN_T_already_defined
|
||||
#endif
|
||||
|
||||
/* ================================================================ */
|
||||
/* EXTERNAL INTERFACE SETTINGS FOR CONFIGURE CAPABLE SYSTEMS ONLY */
|
||||
/* ================================================================ */
|
||||
|
||||
/* Configure process defines this to 1 when it finds out that system */
|
||||
/* header file ws2tcpip.h must be included by the external interface. */
|
||||
/* #undef CARES_PULL_WS2TCPIP_H */
|
||||
#ifdef CARES_PULL_WS2TCPIP_H
|
||||
# ifndef WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# endif
|
||||
# include <windows.h>
|
||||
# include <winsock2.h>
|
||||
# include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
/* Configure process defines this to 1 when it finds out that system */
|
||||
/* header file sys/types.h must be included by the external interface. */
|
||||
/* #undef CARES_PULL_SYS_TYPES_H */
|
||||
#ifdef CARES_PULL_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
/* Configure process defines this to 1 when it finds out that system */
|
||||
/* header file sys/socket.h must be included by the external interface. */
|
||||
/* #undef CARES_PULL_SYS_SOCKET_H */
|
||||
#ifdef CARES_PULL_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
/* Integral data type used for ares_socklen_t. */
|
||||
#define CARES_TYPEOF_ARES_SOCKLEN_T int
|
||||
|
||||
/* Data type definition of ares_socklen_t. */
|
||||
typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t;
|
||||
|
||||
#endif /* __CARES_BUILD_H */
|
||||
+8
-7
@@ -1,9 +1,8 @@
|
||||
#ifndef __CARES_BUILD_H
|
||||
#define __CARES_BUILD_H
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 2009 by Daniel Stenberg et al
|
||||
/* Copyright (C) 2009 - 2013 by Daniel Stenberg et al
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted, provided
|
||||
@@ -65,7 +64,7 @@
|
||||
* created.
|
||||
*
|
||||
* File ares_build.h.dist is not included in the distribution archive.
|
||||
* File ares_build.h is not present in the CVS tree.
|
||||
* File ares_build.h is not present in the git tree.
|
||||
*
|
||||
* The distributed ares_build.h file is only intended to be used on systems
|
||||
* which can not run the also distributed configure script.
|
||||
@@ -75,7 +74,7 @@
|
||||
* and specific to the library being configured and built, which is generated
|
||||
* from the ares_build.h.in template file.
|
||||
*
|
||||
* If you check out from CVS on a non-configure platform, you must run the
|
||||
* If you check out from git on a non-configure platform, you must run the
|
||||
* appropriate buildconf* script to set up ares_build.h and other local files.
|
||||
*
|
||||
*/
|
||||
@@ -217,10 +216,12 @@
|
||||
/* ===================================== */
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
# if defined(__i386__) || defined(__ppc__)
|
||||
# define CARES_SIZEOF_LONG 4
|
||||
# elif defined(__x86_64__) || defined(__ppc64__)
|
||||
# if defined(__LP64__) || \
|
||||
defined(__x86_64__) || defined(__ppc64__)
|
||||
# define CARES_SIZEOF_LONG 8
|
||||
# elif defined(__ILP32__) || \
|
||||
defined(__i386__) || defined(__ppc__) || defined(__arm__)
|
||||
# define CARES_SIZEOF_LONG 4
|
||||
# endif
|
||||
# define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t
|
||||
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#ifndef __CARES_BUILD_H
|
||||
#define __CARES_BUILD_H
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 2009 by Daniel Stenberg et al
|
||||
*
|
||||
@@ -51,21 +50,11 @@
|
||||
/* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */
|
||||
/* ================================================================ */
|
||||
|
||||
#ifdef CARES_SIZEOF_LONG
|
||||
# error "CARES_SIZEOF_LONG shall not be defined except in ares_build.h"
|
||||
Error Compilation_aborted_CARES_SIZEOF_LONG_already_defined
|
||||
#endif
|
||||
|
||||
#ifdef CARES_TYPEOF_ARES_SOCKLEN_T
|
||||
# error "CARES_TYPEOF_ARES_SOCKLEN_T shall not be defined except in ares_build.h"
|
||||
Error Compilation_aborted_CARES_TYPEOF_ARES_SOCKLEN_T_already_defined
|
||||
#endif
|
||||
|
||||
#ifdef CARES_SIZEOF_ARES_SOCKLEN_T
|
||||
# error "CARES_SIZEOF_ARES_SOCKLEN_T shall not be defined except in ares_build.h"
|
||||
Error Compilation_aborted_CARES_SIZEOF_ARES_SOCKLEN_T_already_defined
|
||||
#endif
|
||||
|
||||
/* ================================================================ */
|
||||
/* EXTERNAL INTERFACE SETTINGS FOR CONFIGURE CAPABLE SYSTEMS ONLY */
|
||||
/* ================================================================ */
|
||||
@@ -96,15 +85,9 @@
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
/* The size of `long', as computed by sizeof. */
|
||||
#undef CARES_SIZEOF_LONG
|
||||
|
||||
/* Integral data type used for ares_socklen_t. */
|
||||
#undef CARES_TYPEOF_ARES_SOCKLEN_T
|
||||
|
||||
/* The size of `ares_socklen_t', as computed by sizeof. */
|
||||
#undef CARES_SIZEOF_ARES_SOCKLEN_T
|
||||
|
||||
/* Data type definition of ares_socklen_t. */
|
||||
typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t;
|
||||
|
||||
|
||||
+8
-6
@@ -1,4 +1,3 @@
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.\"
|
||||
@@ -24,12 +23,15 @@ ares_cancel \- Cancel a resolve
|
||||
.B void ares_cancel(ares_channel \fIchannel\fP)
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The \fBares_cancel\fP function cancels all lookups/requests made on the the
|
||||
name service channel identified by \fIchannel\fP. \fBares_cancel\fP invokes
|
||||
the callbacks for each pending query on the channel, passing a status of
|
||||
The \fBares_cancel(3)\fP function cancels all lookups/requests made on the the
|
||||
name service channel identified by \fIchannel\fP. \fBares_cancel(3)\fP
|
||||
invokes the callbacks for each pending query on the channel, passing a status
|
||||
of
|
||||
.BR ARES_ECANCELLED .
|
||||
These calls give the callbacks a chance to clean up any state which
|
||||
might have been stored in their arguments.
|
||||
These calls give the callbacks a chance to clean up any state which might have
|
||||
been stored in their arguments. If such a callback invocation adds a new
|
||||
request to the channel, that request will \fInot\fP be cancelled by the
|
||||
current invocation of \fBares_cancel(3)\fP.
|
||||
.SH SEE ALSO
|
||||
.BR ares_init (3)
|
||||
.BR ares_destroy (3)
|
||||
|
||||
+22
-23
@@ -1,4 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 2004 by Daniel Stenberg et al
|
||||
*
|
||||
@@ -15,7 +14,7 @@
|
||||
|
||||
#include "ares_setup.h"
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
@@ -27,33 +26,33 @@
|
||||
void ares_cancel(ares_channel channel)
|
||||
{
|
||||
struct query *query;
|
||||
struct list_node list_head_copy;
|
||||
struct list_node* list_head;
|
||||
struct list_node* list_node;
|
||||
int i;
|
||||
|
||||
list_head = &(channel->all_queries);
|
||||
for (list_node = list_head->next; list_node != list_head; )
|
||||
if (!ares__is_list_empty(&(channel->all_queries)))
|
||||
{
|
||||
query = list_node->data;
|
||||
list_node = list_node->next; /* since we're deleting the query */
|
||||
query->callback(query->arg, ARES_ECANCELLED, 0, NULL, 0);
|
||||
ares__free_query(query);
|
||||
/* Swap list heads, so that only those queries which were present on entry
|
||||
* into this function are cancelled. New queries added by callbacks of
|
||||
* queries being cancelled will not be cancelled themselves.
|
||||
*/
|
||||
list_head = &(channel->all_queries);
|
||||
list_head_copy.prev = list_head->prev;
|
||||
list_head_copy.next = list_head->next;
|
||||
list_head_copy.prev->next = &list_head_copy;
|
||||
list_head_copy.next->prev = &list_head_copy;
|
||||
list_head->prev = list_head;
|
||||
list_head->next = list_head;
|
||||
for (list_node = list_head_copy.next; list_node != &list_head_copy; )
|
||||
{
|
||||
query = list_node->data;
|
||||
list_node = list_node->next; /* since we're deleting the query */
|
||||
query->callback(query->arg, ARES_ECANCELLED, 0, NULL, 0);
|
||||
ares__free_query(query);
|
||||
}
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
/* Freeing the query should remove it from all the lists in which it sits,
|
||||
* so all query lists should be empty now.
|
||||
*/
|
||||
assert(ares__is_list_empty(&(channel->all_queries)));
|
||||
for (i = 0; i < ARES_QID_TABLE_SIZE; i++)
|
||||
{
|
||||
assert(ares__is_list_empty(&(channel->queries_by_qid[i])));
|
||||
}
|
||||
for (i = 0; i < ARES_TIMEOUT_TABLE_SIZE; i++)
|
||||
{
|
||||
assert(ares__is_list_empty(&(channel->queries_by_timeout[i])));
|
||||
}
|
||||
#endif
|
||||
if (!(channel->flags & ARES_FLAG_STAYOPEN))
|
||||
if (!(channel->flags & ARES_FLAG_STAYOPEN) && ares__is_list_empty(&(channel->all_queries)))
|
||||
{
|
||||
if (channel->servers)
|
||||
{
|
||||
|
||||
+502
@@ -0,0 +1,502 @@
|
||||
/* ares_config.h. Generated from ares_config.h.in by configure. */
|
||||
/* ares_config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define if building universal (internal helper macro) */
|
||||
/* #undef AC_APPLE_UNIVERSAL_BUILD */
|
||||
|
||||
/* define this if ares is built for a big endian system */
|
||||
#define ARES_BIG_ENDIAN 1
|
||||
|
||||
/* when building as static part of libcurl */
|
||||
/* #undef BUILDING_LIBCURL */
|
||||
|
||||
/* Defined for build that exposes internal static functions for testing. */
|
||||
/* #undef CARES_EXPOSE_STATICS */
|
||||
|
||||
/* Defined for build with symbol hiding. */
|
||||
/* #undef CARES_SYMBOL_HIDING */
|
||||
|
||||
/* Definition to make a library symbol externally visible. */
|
||||
/* #undef CARES_SYMBOL_SCOPE_EXTERN */
|
||||
|
||||
/* Use resolver library to configure cares */
|
||||
/* #undef CARES_USE_LIBRESOLV */
|
||||
|
||||
/* if a /etc/inet dir is being used */
|
||||
/* #undef ETC_INET */
|
||||
|
||||
/* Define to the type of arg 2 for gethostname. */
|
||||
#define GETHOSTNAME_TYPE_ARG2 int
|
||||
|
||||
/* Define to the type qualifier of arg 1 for getnameinfo. */
|
||||
/* #undef GETNAMEINFO_QUAL_ARG1 */
|
||||
|
||||
/* Define to the type of arg 1 for getnameinfo. */
|
||||
/* #undef GETNAMEINFO_TYPE_ARG1 */
|
||||
|
||||
/* Define to the type of arg 2 for getnameinfo. */
|
||||
/* #undef GETNAMEINFO_TYPE_ARG2 */
|
||||
|
||||
/* Define to the type of args 4 and 6 for getnameinfo. */
|
||||
/* #undef GETNAMEINFO_TYPE_ARG46 */
|
||||
|
||||
/* Define to the type of arg 7 for getnameinfo. */
|
||||
/* #undef GETNAMEINFO_TYPE_ARG7 */
|
||||
|
||||
/* Specifies the number of arguments to getservbyport_r */
|
||||
/* #undef GETSERVBYPORT_R_ARGS */
|
||||
|
||||
/* Specifies the size of the buffer to pass to getservbyport_r */
|
||||
/* #undef GETSERVBYPORT_R_BUFSIZE */
|
||||
|
||||
/* Define to 1 if you have AF_INET6. */
|
||||
/* #undef HAVE_AF_INET6 */
|
||||
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#define HAVE_ARPA_INET_H 1
|
||||
|
||||
/* Define to 1 if you have the <arpa/nameser_compat.h> header file. */
|
||||
/* #undef HAVE_ARPA_NAMESER_COMPAT_H */
|
||||
|
||||
/* Define to 1 if you have the <arpa/nameser.h> header file. */
|
||||
#define HAVE_ARPA_NAMESER_H 1
|
||||
|
||||
/* Define to 1 if you have the <assert.h> header file. */
|
||||
#define HAVE_ASSERT_H 1
|
||||
|
||||
/* Define to 1 if you have the `bitncmp' function. */
|
||||
/* #undef HAVE_BITNCMP */
|
||||
|
||||
/* Define to 1 if bool is an available type. */
|
||||
#define HAVE_BOOL_T 1
|
||||
|
||||
/* Define to 1 if you have the clock_gettime function and monotonic timer. */
|
||||
/* #undef HAVE_CLOCK_GETTIME_MONOTONIC */
|
||||
|
||||
/* Define to 1 if you have the closesocket function. */
|
||||
/* #undef HAVE_CLOSESOCKET */
|
||||
|
||||
/* Define to 1 if you have the CloseSocket camel case function. */
|
||||
/* #undef HAVE_CLOSESOCKET_CAMEL */
|
||||
|
||||
/* Define to 1 if you have the connect function. */
|
||||
#define HAVE_CONNECT 1
|
||||
|
||||
/* define if the compiler supports basic C++11 syntax */
|
||||
/* #undef HAVE_CXX11 */
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
/* #undef HAVE_DLFCN_H */
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#define HAVE_ERRNO_H 1
|
||||
|
||||
/* Define to 1 if you have the fcntl function. */
|
||||
/* #undef HAVE_FCNTL */
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define to 1 if you have a working fcntl O_NONBLOCK function. */
|
||||
/* #undef HAVE_FCNTL_O_NONBLOCK */
|
||||
|
||||
/* Define to 1 if you have the freeaddrinfo function. */
|
||||
/* #undef HAVE_FREEADDRINFO */
|
||||
|
||||
/* Define to 1 if you have a working getaddrinfo function. */
|
||||
/* #undef HAVE_GETADDRINFO */
|
||||
|
||||
/* Define to 1 if the getaddrinfo function is threadsafe. */
|
||||
/* #undef HAVE_GETADDRINFO_THREADSAFE */
|
||||
|
||||
/* Define to 1 if you have the getenv function. */
|
||||
#define HAVE_GETENV 1
|
||||
|
||||
/* Define to 1 if you have the gethostbyaddr function. */
|
||||
#define HAVE_GETHOSTBYADDR 1
|
||||
|
||||
/* Define to 1 if you have the gethostbyname function. */
|
||||
#define HAVE_GETHOSTBYNAME 1
|
||||
|
||||
/* Define to 1 if you have the gethostname function. */
|
||||
#define HAVE_GETHOSTNAME 1
|
||||
|
||||
/* Define to 1 if you have the getnameinfo function. */
|
||||
/* #undef HAVE_GETNAMEINFO */
|
||||
|
||||
/* Define to 1 if you have the getservbyport_r function. */
|
||||
/* #undef HAVE_GETSERVBYPORT_R */
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#define HAVE_GETTIMEOFDAY 1
|
||||
|
||||
/* Define to 1 if you have the `if_indextoname' function. */
|
||||
/* #undef HAVE_IF_INDEXTONAME */
|
||||
|
||||
/* Define to 1 if you have a IPv6 capable working inet_net_pton function. */
|
||||
/* #undef HAVE_INET_NET_PTON */
|
||||
|
||||
/* Define to 1 if you have a IPv6 capable working inet_ntop function. */
|
||||
/* #undef HAVE_INET_NTOP */
|
||||
|
||||
/* Define to 1 if you have a IPv6 capable working inet_pton function. */
|
||||
/* #undef HAVE_INET_PTON */
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
/* #undef HAVE_INTTYPES_H */
|
||||
|
||||
/* Define to 1 if you have the ioctl function. */
|
||||
#define HAVE_IOCTL 1
|
||||
|
||||
/* Define to 1 if you have the ioctlsocket function. */
|
||||
/* #undef HAVE_IOCTLSOCKET */
|
||||
|
||||
/* Define to 1 if you have the IoctlSocket camel case function. */
|
||||
/* #undef HAVE_IOCTLSOCKET_CAMEL */
|
||||
|
||||
/* Define to 1 if you have a working IoctlSocket camel case FIONBIO function.
|
||||
*/
|
||||
/* #undef HAVE_IOCTLSOCKET_CAMEL_FIONBIO */
|
||||
|
||||
/* Define to 1 if you have a working ioctlsocket FIONBIO function. */
|
||||
/* #undef HAVE_IOCTLSOCKET_FIONBIO */
|
||||
|
||||
/* Define to 1 if you have a working ioctl FIONBIO function. */
|
||||
#define HAVE_IOCTL_FIONBIO 1
|
||||
|
||||
/* Define to 1 if you have a working ioctl SIOCGIFADDR function. */
|
||||
#define HAVE_IOCTL_SIOCGIFADDR 1
|
||||
|
||||
/* Define to 1 if you have the `resolve' library (-lresolve). */
|
||||
/* #undef HAVE_LIBRESOLVE */
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* if your compiler supports LL */
|
||||
#define HAVE_LL 1
|
||||
|
||||
/* Define to 1 if the compiler supports the 'long long' data type. */
|
||||
#define HAVE_LONGLONG 1
|
||||
|
||||
/* Define to 1 if you have the malloc.h header file. */
|
||||
#define HAVE_MALLOC_H 1
|
||||
|
||||
/* Define to 1 if you have the memory.h header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the MSG_NOSIGNAL flag. */
|
||||
/* #undef HAVE_MSG_NOSIGNAL */
|
||||
|
||||
/* Define to 1 if you have the <netdb.h> header file. */
|
||||
#define HAVE_NETDB_H 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/tcp.h> header file. */
|
||||
#define HAVE_NETINET_TCP_H 1
|
||||
|
||||
/* Define to 1 if you have the <net/if.h> header file. */
|
||||
#define HAVE_NET_IF_H 1
|
||||
|
||||
/* Define to 1 if you have PF_INET6. */
|
||||
/* #undef HAVE_PF_INET6 */
|
||||
|
||||
/* Define to 1 if you have the recv function. */
|
||||
#define HAVE_RECV 1
|
||||
|
||||
/* Define to 1 if you have the recvfrom function. */
|
||||
#define HAVE_RECVFROM 1
|
||||
|
||||
/* Define to 1 if you have the send function. */
|
||||
#define HAVE_SEND 1
|
||||
|
||||
/* Define to 1 if you have the setsockopt function. */
|
||||
#define HAVE_SETSOCKOPT 1
|
||||
|
||||
/* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */
|
||||
/* #undef HAVE_SETSOCKOPT_SO_NONBLOCK */
|
||||
|
||||
/* Define to 1 if you have the <signal.h> header file. */
|
||||
#define HAVE_SIGNAL_H 1
|
||||
|
||||
/* Define to 1 if sig_atomic_t is an available typedef. */
|
||||
#define HAVE_SIG_ATOMIC_T 1
|
||||
|
||||
/* Define to 1 if sig_atomic_t is already defined as volatile. */
|
||||
/* #undef HAVE_SIG_ATOMIC_T_VOLATILE */
|
||||
|
||||
/* Define to 1 if your struct sockaddr_in6 has sin6_scope_id. */
|
||||
/* #undef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID */
|
||||
|
||||
/* Define to 1 if you have the socket function. */
|
||||
#define HAVE_SOCKET 1
|
||||
|
||||
/* Define to 1 if you have the <socket.h> header file. */
|
||||
/* #undef HAVE_SOCKET_H */
|
||||
|
||||
/* Define to 1 if you have the <stdbool.h> header file. */
|
||||
#define HAVE_STDBOOL_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
/* #undef HAVE_STDINT_H */
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the strcasecmp function. */
|
||||
#define HAVE_STRCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the strcmpi function. */
|
||||
/* #undef HAVE_STRCMPI */
|
||||
|
||||
/* Define to 1 if you have the strdup function. */
|
||||
#define HAVE_STRDUP 1
|
||||
|
||||
/* Define to 1 if you have the stricmp function. */
|
||||
#define HAVE_STRICMP 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the strncasecmp function. */
|
||||
#define HAVE_STRNCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the strncmpi function. */
|
||||
/* #undef HAVE_STRNCMPI */
|
||||
|
||||
/* Define to 1 if you have the strnicmp function. */
|
||||
/* #undef HAVE_STRNICMP */
|
||||
|
||||
/* Define to 1 if you have the <stropts.h> header file. */
|
||||
/* #undef HAVE_STROPTS_H */
|
||||
|
||||
/* Define to 1 if you have struct addrinfo. */
|
||||
/* #undef HAVE_STRUCT_ADDRINFO */
|
||||
|
||||
/* Define to 1 if you have struct in6_addr. */
|
||||
/* #undef HAVE_STRUCT_IN6_ADDR */
|
||||
|
||||
/* Define to 1 if you have struct sockaddr_in6. */
|
||||
/* #undef HAVE_STRUCT_SOCKADDR_IN6 */
|
||||
|
||||
/* if struct sockaddr_storage is defined */
|
||||
/* #undef HAVE_STRUCT_SOCKADDR_STORAGE */
|
||||
|
||||
/* Define to 1 if you have the timeval struct. */
|
||||
#define HAVE_STRUCT_TIMEVAL 1
|
||||
|
||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
||||
#define HAVE_SYS_IOCTL_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/select.h> header file. */
|
||||
/* #undef HAVE_SYS_SELECT_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/uio.h> header file. */
|
||||
//#define HAVE_SYS_UIO_H 1
|
||||
|
||||
/* Define to 1 if you have the <time.h> header file. */
|
||||
#define HAVE_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to 1 if you have the windows.h header file. */
|
||||
/* #undef HAVE_WINDOWS_H */
|
||||
|
||||
/* Define to 1 if you have the winsock2.h header file. */
|
||||
/* #undef HAVE_WINSOCK2_H */
|
||||
|
||||
/* Define to 1 if you have the winsock.h header file. */
|
||||
/* #undef HAVE_WINSOCK_H */
|
||||
|
||||
/* Define to 1 if you have the writev function. */
|
||||
/* #undef HAVE_WRITEV */
|
||||
|
||||
/* Define to 1 if you have the ws2tcpip.h header file. */
|
||||
/* #undef HAVE_WS2TCPIP_H */
|
||||
|
||||
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* Define to 1 if you need the malloc.h header file even with stdlib.h */
|
||||
/* #undef NEED_MALLOC_H */
|
||||
|
||||
/* Define to 1 if you need the memory.h header file even with stdlib.h */
|
||||
/* #undef NEED_MEMORY_H */
|
||||
|
||||
/* Define to 1 if _REENTRANT preprocessor symbol must be defined. */
|
||||
/* #undef NEED_REENTRANT */
|
||||
|
||||
/* Define to 1 if _THREAD_SAFE preprocessor symbol must be defined. */
|
||||
/* #undef NEED_THREAD_SAFE */
|
||||
|
||||
/* cpu-machine-OS */
|
||||
#define OS "m68k-unknown-amigaos"
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "c-ares"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "c-ares mailing list: http://cool.haxx.se/mailman/listinfo/c-ares"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "c-ares"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "c-ares 1.12.0"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "c-ares"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "1.12.0"
|
||||
|
||||
/* a suitable file/device to read random data from */
|
||||
/* #undef RANDOM_FILE */
|
||||
|
||||
/* Define to the type qualifier pointed by arg 5 for recvfrom. */
|
||||
#define RECVFROM_QUAL_ARG5
|
||||
|
||||
/* Define to the type of arg 1 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG1 int
|
||||
|
||||
/* Define to the type pointed by arg 2 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG2 void
|
||||
|
||||
/* Define to 1 if the type pointed by arg 2 for recvfrom is void. */
|
||||
#define RECVFROM_TYPE_ARG2_IS_VOID 1
|
||||
|
||||
/* Define to the type of arg 3 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG3 size_t
|
||||
|
||||
/* Define to the type of arg 4 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG4 int
|
||||
|
||||
/* Define to the type pointed by arg 5 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG5 struct sockaddr
|
||||
|
||||
/* Define to 1 if the type pointed by arg 5 for recvfrom is void. */
|
||||
/* #undef RECVFROM_TYPE_ARG5_IS_VOID */
|
||||
|
||||
/* Define to the type pointed by arg 6 for recvfrom. */
|
||||
#define RECVFROM_TYPE_ARG6 int
|
||||
|
||||
/* Define to 1 if the type pointed by arg 6 for recvfrom is void. */
|
||||
/* #undef RECVFROM_TYPE_ARG6_IS_VOID */
|
||||
|
||||
/* Define to the function return type for recvfrom. */
|
||||
#define RECVFROM_TYPE_RETV int
|
||||
|
||||
/* Define to the type of arg 1 for recv. */
|
||||
#define RECV_TYPE_ARG1 int
|
||||
|
||||
/* Define to the type of arg 2 for recv. */
|
||||
#define RECV_TYPE_ARG2 void *
|
||||
|
||||
/* Define to the type of arg 3 for recv. */
|
||||
#define RECV_TYPE_ARG3 size_t
|
||||
|
||||
/* Define to the type of arg 4 for recv. */
|
||||
#define RECV_TYPE_ARG4 int
|
||||
|
||||
/* Define to the function return type for recv. */
|
||||
#define RECV_TYPE_RETV int
|
||||
|
||||
/* Define as the return type of signal handlers (`int' or `void'). */
|
||||
#define RETSIGTYPE void
|
||||
|
||||
/* Define to the type qualifier of arg 2 for send. */
|
||||
#define SEND_QUAL_ARG2 const
|
||||
|
||||
/* Define to the type of arg 1 for send. */
|
||||
#define SEND_TYPE_ARG1 int
|
||||
|
||||
/* Define to the type of arg 2 for send. */
|
||||
#define SEND_TYPE_ARG2 void *
|
||||
|
||||
/* Define to the type of arg 3 for send. */
|
||||
#define SEND_TYPE_ARG3 size_t
|
||||
|
||||
/* Define to the type of arg 4 for send. */
|
||||
#define SEND_TYPE_ARG4 int
|
||||
|
||||
/* Define to the function return type for send. */
|
||||
#define SEND_TYPE_RETV int
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#define TIME_WITH_SYS_TIME 1
|
||||
|
||||
/* Define to disable non-blocking sockets. */
|
||||
#define USE_BLOCKING_SOCKETS 1
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "1.12.0"
|
||||
|
||||
/* Define to avoid automatic inclusion of winsock.h */
|
||||
/* #undef WIN32_LEAN_AND_MEAN */
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
#if defined AC_APPLE_UNIVERSAL_BUILD
|
||||
# if defined __BIG_ENDIAN__
|
||||
# define WORDS_BIGENDIAN 1
|
||||
# endif
|
||||
#else
|
||||
# ifndef WORDS_BIGENDIAN
|
||||
/* # undef WORDS_BIGENDIAN */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Define to 1 if OS is AIX. */
|
||||
#ifndef _ALL_SOURCE
|
||||
/* # undef _ALL_SOURCE */
|
||||
#endif
|
||||
|
||||
/* Enable large inode numbers on Mac OS X 10.5. */
|
||||
#ifndef _DARWIN_USE_64_BIT_INODE
|
||||
# define _DARWIN_USE_64_BIT_INODE 1
|
||||
#endif
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
/* #undef _FILE_OFFSET_BITS */
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
/* #undef _LARGE_FILES */
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
/* #undef const */
|
||||
|
||||
/* Type to use in place of in_addr_t when system does not provide it. */
|
||||
#define in_addr_t unsigned long
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* the signed version of size_t */
|
||||
/* #undef ssize_t */
|
||||
@@ -0,0 +1,76 @@
|
||||
.\"
|
||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.\"
|
||||
.\" Permission to use, copy, modify, and distribute this
|
||||
.\" software and its documentation for any purpose and without
|
||||
.\" fee is hereby granted, provided that the above copyright
|
||||
.\" notice appear in all copies and that both that copyright
|
||||
.\" notice and this permission notice appear in supporting
|
||||
.\" documentation, and that the name of M.I.T. not be used in
|
||||
.\" advertising or publicity pertaining to distribution of the
|
||||
.\" software without specific, written prior permission.
|
||||
.\" M.I.T. makes no representations about the suitability of
|
||||
.\" this software for any purpose. It is provided "as is"
|
||||
.\" without express or implied warranty.
|
||||
.\"
|
||||
.TH ARES_CREATE_QUERY 3 "17 Aug 2012"
|
||||
.SH NAME
|
||||
ares_create_query \- Compose a single-question DNS query buffer
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
#include <ares.h>
|
||||
|
||||
int ares_create_query(const char *\fIname\fP,
|
||||
int \fIdnsclass\fP,
|
||||
int \fItype\fP,
|
||||
unsigned short \fIid\fP,
|
||||
int \fIrd\fP,
|
||||
unsigned char **\fIbuf\fP,
|
||||
int *\fIbuflen\fP,
|
||||
int \fImax_udp_size\fP)
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The \fIares_create_query(3)\fP function composes a DNS query with a single
|
||||
question. The parameter \fIname\fP gives the query name as a NUL-terminated C
|
||||
string of period-separated labels optionally ending with a period; periods and
|
||||
backslashes within a label must be escaped with a backlash.
|
||||
|
||||
The parameters \fIdnsclass\fP and \fItype\fP give the class and type of the
|
||||
query using the values defined in \fB<arpa/nameser.h>\fP.
|
||||
|
||||
The parameter \fIid\fP gives a 16-bit identifier for the query.
|
||||
|
||||
The parameter \fIrd\fP should be nonzero if recursion is desired, zero if not.
|
||||
|
||||
The query will be placed in an allocated buffer, a pointer to which will be
|
||||
stored in the variable pointed to by \fIbuf\fP, and the length of which will
|
||||
be stored in the variable pointed to by \fIbuflen\fP.
|
||||
|
||||
It is the caller's responsibility to free this buffer using
|
||||
\fIares_free_string(3)\fP when it is no longer needed. The parameter
|
||||
\fImax_udp_size\fP should be nonzero to activate EDNS. Usage of
|
||||
\fIares_create_query(3)\fP\ with \fImax_udp_size\fP set to zero is equivalent
|
||||
to using \fIares_mkquery(3)\fP.
|
||||
.SH RETURN VALUES
|
||||
.B ares_create_query
|
||||
can return any of the following values:
|
||||
.TP 15
|
||||
.B ARES_SUCCESS
|
||||
Construction of the DNS query succeeded.
|
||||
.TP 15
|
||||
.B ARES_EBADNAME
|
||||
The query name
|
||||
.I name
|
||||
could not be encoded as a domain name, either because it contained a
|
||||
zero-length label or because it contained a label of more than 63
|
||||
characters.
|
||||
.TP 15
|
||||
.B ARES_ENOMEM
|
||||
Memory was exhausted.
|
||||
.SH AVAILABILITY
|
||||
Added in c-ares 1.10.0
|
||||
.SH SEE ALSO
|
||||
.BR ares_expand_name (3),
|
||||
.BR ares_free_string (3),
|
||||
.BR ares_mkquery (3)
|
||||
.SH AUTHOR
|
||||
@@ -0,0 +1,202 @@
|
||||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose and without
|
||||
* fee is hereby granted, provided that the above copyright
|
||||
* notice appear in all copies and that both that copyright
|
||||
* notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of M.I.T. not be used in
|
||||
* advertising or publicity pertaining to distribution of the
|
||||
* software without specific, written prior permission.
|
||||
* M.I.T. makes no representations about the suitability of
|
||||
* this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*/
|
||||
|
||||
#include "ares_setup.h"
|
||||
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_NAMESER_H
|
||||
# include <arpa/nameser.h>
|
||||
#else
|
||||
# include "nameser.h"
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
|
||||
# include <arpa/nameser_compat.h>
|
||||
#endif
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_dns.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
#ifndef T_OPT
|
||||
# define T_OPT 41 /* EDNS0 option (meta-RR) */
|
||||
#endif
|
||||
|
||||
/* Header format, from RFC 1035:
|
||||
* 1 1 1 1 1 1
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | ID |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* |QR| Opcode |AA|TC|RD|RA| Z | RCODE |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | QDCOUNT |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | ANCOUNT |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | NSCOUNT |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | ARCOUNT |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* AA, TC, RA, and RCODE are only set in responses. Brief description
|
||||
* of the remaining fields:
|
||||
* ID Identifier to match responses with queries
|
||||
* QR Query (0) or response (1)
|
||||
* Opcode For our purposes, always QUERY
|
||||
* RD Recursion desired
|
||||
* Z Reserved (zero)
|
||||
* QDCOUNT Number of queries
|
||||
* ANCOUNT Number of answers
|
||||
* NSCOUNT Number of name server records
|
||||
* ARCOUNT Number of additional records
|
||||
*
|
||||
* Question format, from RFC 1035:
|
||||
* 1 1 1 1 1 1
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | |
|
||||
* / QNAME /
|
||||
* / /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | QTYPE |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | QCLASS |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* The query name is encoded as a series of labels, each represented
|
||||
* as a one-byte length (maximum 63) followed by the text of the
|
||||
* label. The list is terminated by a label of length zero (which can
|
||||
* be thought of as the root domain).
|
||||
*/
|
||||
|
||||
int ares_create_query(const char *name, int dnsclass, int type,
|
||||
unsigned short id, int rd, unsigned char **bufp,
|
||||
int *buflenp, int max_udp_size)
|
||||
{
|
||||
size_t len;
|
||||
unsigned char *q;
|
||||
const char *p;
|
||||
size_t buflen;
|
||||
unsigned char *buf;
|
||||
|
||||
/* Set our results early, in case we bail out early with an error. */
|
||||
*buflenp = 0;
|
||||
*bufp = NULL;
|
||||
|
||||
/* Allocate a memory area for the maximum size this packet might need. +2
|
||||
* is for the length byte and zero termination if no dots or ecscaping is
|
||||
* used.
|
||||
*/
|
||||
len = strlen(name) + 2 + HFIXEDSZ + QFIXEDSZ +
|
||||
(max_udp_size ? EDNSFIXEDSZ : 0);
|
||||
buf = ares_malloc(len);
|
||||
if (!buf)
|
||||
return ARES_ENOMEM;
|
||||
|
||||
/* Set up the header. */
|
||||
q = buf;
|
||||
memset(q, 0, HFIXEDSZ);
|
||||
DNS_HEADER_SET_QID(q, id);
|
||||
DNS_HEADER_SET_OPCODE(q, QUERY);
|
||||
if (rd) {
|
||||
DNS_HEADER_SET_RD(q, 1);
|
||||
}
|
||||
else {
|
||||
DNS_HEADER_SET_RD(q, 0);
|
||||
}
|
||||
DNS_HEADER_SET_QDCOUNT(q, 1);
|
||||
|
||||
if (max_udp_size) {
|
||||
DNS_HEADER_SET_ARCOUNT(q, 1);
|
||||
}
|
||||
|
||||
/* A name of "." is a screw case for the loop below, so adjust it. */
|
||||
if (strcmp(name, ".") == 0)
|
||||
name++;
|
||||
|
||||
/* Start writing out the name after the header. */
|
||||
q += HFIXEDSZ;
|
||||
while (*name)
|
||||
{
|
||||
if (*name == '.') {
|
||||
free (buf);
|
||||
return ARES_EBADNAME;
|
||||
}
|
||||
|
||||
/* Count the number of bytes in this label. */
|
||||
len = 0;
|
||||
for (p = name; *p && *p != '.'; p++)
|
||||
{
|
||||
if (*p == '\\' && *(p + 1) != 0)
|
||||
p++;
|
||||
len++;
|
||||
}
|
||||
if (len > MAXLABEL) {
|
||||
free (buf);
|
||||
return ARES_EBADNAME;
|
||||
}
|
||||
|
||||
/* Encode the length and copy the data. */
|
||||
*q++ = (unsigned char)len;
|
||||
for (p = name; *p && *p != '.'; p++)
|
||||
{
|
||||
if (*p == '\\' && *(p + 1) != 0)
|
||||
p++;
|
||||
*q++ = *p;
|
||||
}
|
||||
|
||||
/* Go to the next label and repeat, unless we hit the end. */
|
||||
if (!*p)
|
||||
break;
|
||||
name = p + 1;
|
||||
}
|
||||
|
||||
/* Add the zero-length label at the end. */
|
||||
*q++ = 0;
|
||||
|
||||
/* Finish off the question with the type and class. */
|
||||
DNS_QUESTION_SET_TYPE(q, type);
|
||||
DNS_QUESTION_SET_CLASS(q, dnsclass);
|
||||
|
||||
q += QFIXEDSZ;
|
||||
if (max_udp_size)
|
||||
{
|
||||
memset(q, 0, EDNSFIXEDSZ);
|
||||
q++;
|
||||
DNS_RR_SET_TYPE(q, T_OPT);
|
||||
DNS_RR_SET_CLASS(q, max_udp_size);
|
||||
q += (EDNSFIXEDSZ-1);
|
||||
}
|
||||
buflen = (q - buf);
|
||||
|
||||
/* Reject names that are longer than the maximum of 255 bytes that's
|
||||
* specified in RFC 1035 ("To simplify implementations, the total length of
|
||||
* a domain name (i.e., label octets and label length octets) is restricted
|
||||
* to 255 octets or less."). */
|
||||
if (buflen > (MAXCDNAME + HFIXEDSZ + QFIXEDSZ +
|
||||
(max_udp_size ? EDNSFIXEDSZ : 0))) {
|
||||
free (buf);
|
||||
return ARES_EBADNAME;
|
||||
}
|
||||
|
||||
/* we know this fits in an int at this point */
|
||||
*buflenp = (int) buflen;
|
||||
*bufp = buf;
|
||||
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
+106
-28
@@ -1,6 +1,5 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 2009 by Daniel Stenberg
|
||||
/* Copyright (C) 2009-2013 by Daniel Stenberg
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose and without
|
||||
@@ -34,6 +33,7 @@
|
||||
** of c-ares functions returning pointers that must be free'ed using this
|
||||
** function is:
|
||||
**
|
||||
** ares_get_servers()
|
||||
** ares_parse_srv_reply()
|
||||
** ares_parse_txt_reply()
|
||||
*/
|
||||
@@ -45,34 +45,86 @@ void ares_free_data(void *dataptr)
|
||||
if (!dataptr)
|
||||
return;
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:1684)
|
||||
/* 1684: conversion from pointer to same-sized integral type */
|
||||
#endif
|
||||
|
||||
ptr = (void *)((char *)dataptr - offsetof(struct ares_data, data));
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
if (ptr->mark != ARES_DATATYPE_MARK)
|
||||
return;
|
||||
|
||||
switch (ptr->type)
|
||||
{
|
||||
case ARES_DATATYPE_MX_REPLY:
|
||||
|
||||
if (ptr->data.mx_reply.next)
|
||||
ares_free_data(ptr->data.mx_reply.next);
|
||||
if (ptr->data.mx_reply.host)
|
||||
ares_free(ptr->data.mx_reply.host);
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_SRV_REPLY:
|
||||
|
||||
if (ptr->data.srv_reply.next)
|
||||
ares_free_data(ptr->data.srv_reply.next);
|
||||
if (ptr->data.srv_reply.host)
|
||||
free(ptr->data.srv_reply.host);
|
||||
ares_free(ptr->data.srv_reply.host);
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_TXT_REPLY:
|
||||
case ARES_DATATYPE_TXT_EXT:
|
||||
|
||||
if (ptr->data.txt_reply.next)
|
||||
ares_free_data(ptr->data.txt_reply.next);
|
||||
if (ptr->data.txt_reply.txt)
|
||||
free(ptr->data.txt_reply.txt);
|
||||
ares_free(ptr->data.txt_reply.txt);
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_ADDR_NODE:
|
||||
|
||||
if (ptr->data.addr_node.next)
|
||||
ares_free_data(ptr->data.addr_node.next);
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_ADDR_PORT_NODE:
|
||||
|
||||
if (ptr->data.addr_port_node.next)
|
||||
ares_free_data(ptr->data.addr_port_node.next);
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_NAPTR_REPLY:
|
||||
|
||||
if (ptr->data.naptr_reply.next)
|
||||
ares_free_data(ptr->data.naptr_reply.next);
|
||||
if (ptr->data.naptr_reply.flags)
|
||||
ares_free(ptr->data.naptr_reply.flags);
|
||||
if (ptr->data.naptr_reply.service)
|
||||
ares_free(ptr->data.naptr_reply.service);
|
||||
if (ptr->data.naptr_reply.regexp)
|
||||
ares_free(ptr->data.naptr_reply.regexp);
|
||||
if (ptr->data.naptr_reply.replacement)
|
||||
ares_free(ptr->data.naptr_reply.replacement);
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_SOA_REPLY:
|
||||
if (ptr->data.soa_reply.nsname)
|
||||
ares_free(ptr->data.soa_reply.nsname);
|
||||
if (ptr->data.soa_reply.hostmaster)
|
||||
ares_free(ptr->data.soa_reply.hostmaster);
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
free(ptr);
|
||||
ares_free(ptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -91,12 +143,18 @@ void *ares_malloc_data(ares_datatype type)
|
||||
{
|
||||
struct ares_data *ptr;
|
||||
|
||||
ptr = malloc(sizeof(struct ares_data));
|
||||
ptr = ares_malloc(sizeof(struct ares_data));
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case ARES_DATATYPE_MX_REPLY:
|
||||
ptr->data.mx_reply.next = NULL;
|
||||
ptr->data.mx_reply.host = NULL;
|
||||
ptr->data.mx_reply.priority = 0;
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_SRV_REPLY:
|
||||
ptr->data.srv_reply.next = NULL;
|
||||
ptr->data.srv_reply.host = NULL;
|
||||
@@ -105,14 +163,54 @@ void *ares_malloc_data(ares_datatype type)
|
||||
ptr->data.srv_reply.port = 0;
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_TXT_EXT:
|
||||
ptr->data.txt_ext.record_start = 0;
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case ARES_DATATYPE_TXT_REPLY:
|
||||
ptr->data.txt_reply.next = NULL;
|
||||
ptr->data.txt_reply.txt = NULL;
|
||||
ptr->data.txt_reply.length = 0;
|
||||
ptr->data.txt_reply.length = 0;
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_ADDR_NODE:
|
||||
ptr->data.addr_node.next = NULL;
|
||||
ptr->data.addr_node.family = 0;
|
||||
memset(&ptr->data.addr_node.addrV6, 0,
|
||||
sizeof(ptr->data.addr_node.addrV6));
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_ADDR_PORT_NODE:
|
||||
ptr->data.addr_port_node.next = NULL;
|
||||
ptr->data.addr_port_node.family = 0;
|
||||
ptr->data.addr_port_node.udp_port = 0;
|
||||
ptr->data.addr_port_node.tcp_port = 0;
|
||||
memset(&ptr->data.addr_port_node.addrV6, 0,
|
||||
sizeof(ptr->data.addr_port_node.addrV6));
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_NAPTR_REPLY:
|
||||
ptr->data.naptr_reply.next = NULL;
|
||||
ptr->data.naptr_reply.flags = NULL;
|
||||
ptr->data.naptr_reply.service = NULL;
|
||||
ptr->data.naptr_reply.regexp = NULL;
|
||||
ptr->data.naptr_reply.replacement = NULL;
|
||||
ptr->data.naptr_reply.order = 0;
|
||||
ptr->data.naptr_reply.preference = 0;
|
||||
break;
|
||||
|
||||
case ARES_DATATYPE_SOA_REPLY:
|
||||
ptr->data.soa_reply.nsname = NULL;
|
||||
ptr->data.soa_reply.hostmaster = NULL;
|
||||
ptr->data.soa_reply.serial = 0;
|
||||
ptr->data.soa_reply.refresh = 0;
|
||||
ptr->data.soa_reply.retry = 0;
|
||||
ptr->data.soa_reply.expire = 0;
|
||||
ptr->data.soa_reply.minttl = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
free(ptr);
|
||||
ares_free(ptr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -121,23 +219,3 @@ void *ares_malloc_data(ares_datatype type)
|
||||
|
||||
return &ptr->data;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** ares_get_datatype() - c-ares internal helper function.
|
||||
**
|
||||
** This function returns the ares_datatype of the data stored in a
|
||||
** private ares_data struct when given the public API pointer.
|
||||
*/
|
||||
|
||||
ares_datatype ares_get_datatype(void * dataptr)
|
||||
{
|
||||
struct ares_data *ptr;
|
||||
|
||||
ptr = (void *)((char *)dataptr - offsetof(struct ares_data, data));
|
||||
|
||||
if (ptr->mark == ARES_DATATYPE_MARK)
|
||||
return ptr->type;
|
||||
|
||||
return ARES_DATATYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
+15
-5
@@ -1,6 +1,5 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 2009 by Daniel Stenberg
|
||||
/* Copyright (C) 2009-2013 by Daniel Stenberg
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose and without
|
||||
@@ -19,12 +18,18 @@ typedef enum {
|
||||
ARES_DATATYPE_UNKNOWN = 1, /* unknown data type - introduced in 1.7.0 */
|
||||
ARES_DATATYPE_SRV_REPLY, /* struct ares_srv_reply - introduced in 1.7.0 */
|
||||
ARES_DATATYPE_TXT_REPLY, /* struct ares_txt_reply - introduced in 1.7.0 */
|
||||
ARES_DATATYPE_TXT_EXT, /* struct ares_txt_ext - introduced in 1.11.0 */
|
||||
ARES_DATATYPE_ADDR_NODE, /* struct ares_addr_node - introduced in 1.7.1 */
|
||||
ARES_DATATYPE_MX_REPLY, /* struct ares_mx_reply - introduced in 1.7.2 */
|
||||
ARES_DATATYPE_NAPTR_REPLY,/* struct ares_naptr_reply - introduced in 1.7.6 */
|
||||
ARES_DATATYPE_SOA_REPLY, /* struct ares_soa_reply - introduced in 1.9.0 */
|
||||
#if 0
|
||||
ARES_DATATYPE_ADDR6TTL, /* struct ares_addrttl */
|
||||
ARES_DATATYPE_ADDRTTL, /* struct ares_addr6ttl */
|
||||
ARES_DATATYPE_HOSTENT, /* struct hostent */
|
||||
ARES_DATATYPE_OPTIONS, /* struct ares_options */
|
||||
#endif
|
||||
ARES_DATATYPE_ADDR_PORT_NODE, /* struct ares_addr_port_node - introduced in 1.11.0 */
|
||||
ARES_DATATYPE_LAST /* not used - introduced in 1.7.0 */
|
||||
} ares_datatype;
|
||||
|
||||
@@ -52,11 +57,16 @@ struct ares_data {
|
||||
ares_datatype type; /* Actual data type identifier. */
|
||||
unsigned int mark; /* Private ares_data signature. */
|
||||
union {
|
||||
struct ares_txt_reply txt_reply;
|
||||
struct ares_srv_reply srv_reply;
|
||||
struct ares_txt_reply txt_reply;
|
||||
struct ares_txt_ext txt_ext;
|
||||
struct ares_srv_reply srv_reply;
|
||||
struct ares_addr_node addr_node;
|
||||
struct ares_addr_port_node addr_port_node;
|
||||
struct ares_mx_reply mx_reply;
|
||||
struct ares_naptr_reply naptr_reply;
|
||||
struct ares_soa_reply soa_reply;
|
||||
} data;
|
||||
};
|
||||
|
||||
void *ares_malloc_data(ares_datatype type);
|
||||
|
||||
ares_datatype ares_get_datatype(void * dataptr);
|
||||
|
||||
+8
-12
@@ -1,4 +1,3 @@
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.\"
|
||||
@@ -24,17 +23,14 @@ ares_destroy \- Destroy a resolver channel
|
||||
.B void ares_destroy(ares_channel \fIchannel\fP)
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
.B ares_destroy
|
||||
function destroys the name service channel identified by
|
||||
.IR channel ,
|
||||
freeing all memory and closing all sockets used by the channel.
|
||||
.B ares_destroy
|
||||
invokes the callbacks for each pending query on the channel, passing a
|
||||
status of
|
||||
.BR ARES_EDESTRUCTION .
|
||||
These calls give the callbacks a chance to clean up any state which
|
||||
might have been stored in their arguments.
|
||||
The \fBares_destroy(3)\fP function destroys the name service channel
|
||||
identified by \fIchannel\fP, freeing all memory and closing all sockets used
|
||||
by the channel.
|
||||
|
||||
\fBares_destroy(3)\fP invokes the callbacks for each pending query on the
|
||||
channel, passing a status of \IARES_EDESTRUCTION\fP. These calls give the
|
||||
callbacks a chance to clean up any state which might have been stored in their
|
||||
arguments. A callback must not add new requests to a channel being destroyed.
|
||||
.SH SEE ALSO
|
||||
.BR ares_init (3),
|
||||
.BR ares_cancel (3)
|
||||
|
||||
+36
-21
@@ -1,6 +1,6 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
* Copyright (C) 2004-2011 by Daniel Stenberg
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose and without
|
||||
@@ -16,8 +16,9 @@
|
||||
*/
|
||||
|
||||
#include "ares_setup.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
@@ -25,13 +26,16 @@ void ares_destroy_options(struct ares_options *options)
|
||||
{
|
||||
int i;
|
||||
|
||||
free(options->servers);
|
||||
if(options->servers)
|
||||
ares_free(options->servers);
|
||||
for (i = 0; i < options->ndomains; i++)
|
||||
free(options->domains[i]);
|
||||
free(options->domains);
|
||||
ares_free(options->domains[i]);
|
||||
if(options->domains)
|
||||
ares_free(options->domains);
|
||||
if(options->sortlist)
|
||||
free(options->sortlist);
|
||||
free(options->lookups);
|
||||
ares_free(options->sortlist);
|
||||
if(options->lookups)
|
||||
ares_free(options->lookups);
|
||||
}
|
||||
|
||||
void ares_destroy(ares_channel channel)
|
||||
@@ -67,27 +71,38 @@ void ares_destroy(ares_channel channel)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (channel->servers) {
|
||||
for (i = 0; i < channel->nservers; i++)
|
||||
{
|
||||
struct server_state *server = &channel->servers[i];
|
||||
ares__close_sockets(channel, server);
|
||||
assert(ares__is_list_empty(&(server->queries_to_server)));
|
||||
}
|
||||
free(channel->servers);
|
||||
}
|
||||
ares__destroy_servers_state(channel);
|
||||
|
||||
if (channel->domains) {
|
||||
for (i = 0; i < channel->ndomains; i++)
|
||||
free(channel->domains[i]);
|
||||
free(channel->domains);
|
||||
ares_free(channel->domains[i]);
|
||||
ares_free(channel->domains);
|
||||
}
|
||||
|
||||
if(channel->sortlist)
|
||||
free(channel->sortlist);
|
||||
ares_free(channel->sortlist);
|
||||
|
||||
if (channel->lookups)
|
||||
free(channel->lookups);
|
||||
ares_free(channel->lookups);
|
||||
|
||||
free(channel);
|
||||
ares_free(channel);
|
||||
}
|
||||
|
||||
void ares__destroy_servers_state(ares_channel channel)
|
||||
{
|
||||
struct server_state *server;
|
||||
int i;
|
||||
|
||||
if (channel->servers)
|
||||
{
|
||||
for (i = 0; i < channel->nservers; i++)
|
||||
{
|
||||
server = &channel->servers[i];
|
||||
ares__close_sockets(channel, server);
|
||||
assert(ares__is_list_empty(&server->queries_to_server));
|
||||
}
|
||||
ares_free(channel->servers);
|
||||
channel->servers = NULL;
|
||||
}
|
||||
channel->nservers = -1;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.\"
|
||||
@@ -24,12 +23,9 @@ ares_destroy_options \- Destroy options initialized with ares_save_options
|
||||
.B void ares_destroy_options(struct ares_options *\fIoptions\fP)
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
.B ares_destroy_options
|
||||
function destroys the options struct identified by
|
||||
.IR options ,
|
||||
freeing all memory allocated by ares_save_options.
|
||||
|
||||
The \fBares_destroy_options(3)\fP function destroys the options struct
|
||||
identified by \Ioptions\fP, freeing all memory allocated by
|
||||
\fBares_save_options(3)\fP.
|
||||
.SH SEE ALSO
|
||||
.BR ares_save_options (3),
|
||||
.BR ares_init_options (3)
|
||||
|
||||
+42
-12
@@ -1,6 +1,7 @@
|
||||
/* $Id$ */
|
||||
#ifndef HEADER_CARES_DNS_H
|
||||
#define HEADER_CARES_DNS_H
|
||||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
/* Copyright 1998, 2011 by the Massachusetts Institute of Technology.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose and without
|
||||
@@ -15,12 +16,26 @@
|
||||
* without express or implied warranty.
|
||||
*/
|
||||
|
||||
#ifndef ARES__DNS_H
|
||||
#define ARES__DNS_H
|
||||
#include <sys/endian.h>
|
||||
|
||||
#define DNS__16BIT(p) (((p)[0] << 8) | (p)[1])
|
||||
#define DNS__32BIT(p) (((p)[0] << 24) | ((p)[1] << 16) | \
|
||||
((p)[2] << 8) | (p)[3])
|
||||
#if 0
|
||||
/*
|
||||
* Macro DNS__16BIT reads a network short (16 bit) given in network
|
||||
* byte order, and returns its value as an unsigned short.
|
||||
*/
|
||||
#define DNS__16BIT(p) ((unsigned short)((unsigned int) 0xffff & \
|
||||
(((unsigned int)((unsigned char)(p)[0]) << 8U) | \
|
||||
((unsigned int)((unsigned char)(p)[1])))))
|
||||
|
||||
/*
|
||||
* Macro DNS__32BIT reads a network long (32 bit) given in network
|
||||
* byte order, and returns its value as an unsigned int.
|
||||
*/
|
||||
#define DNS__32BIT(p) ((unsigned int) \
|
||||
(((unsigned int)((unsigned char)(p)[0]) << 24U) | \
|
||||
((unsigned int)((unsigned char)(p)[1]) << 16U) | \
|
||||
((unsigned int)((unsigned char)(p)[2]) << 8U) | \
|
||||
((unsigned int)((unsigned char)(p)[3]))))
|
||||
|
||||
#define DNS__SET16BIT(p, v) (((p)[0] = (unsigned char)(((v) >> 8) & 0xff)), \
|
||||
((p)[1] = (unsigned char)((v) & 0xff)))
|
||||
@@ -28,6 +43,7 @@
|
||||
((p)[1] = (unsigned char)(((v) >> 16) & 0xff)), \
|
||||
((p)[2] = (unsigned char)(((v) >> 8) & 0xff)), \
|
||||
((p)[3] = (unsigned char)((v) & 0xff)))
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* we cannot use this approach on systems where we can't access 16/32 bit
|
||||
@@ -38,6 +54,20 @@
|
||||
#define DNS__SET32BIT(p, v) *(unsigned long*)(p) = htonl(v)
|
||||
#endif
|
||||
|
||||
/* use use this approach on systems where we can't access 16/32 bit
|
||||
data on un-aligned addresses */
|
||||
#ifdef ARES_BIG_ENDIAN
|
||||
#define DNS__16BIT(p) be16dec(p)
|
||||
#define DNS__32BIT(p) be32dec(p)
|
||||
#define DNS__SET16BIT(p, v) be16enc(p,v)
|
||||
#define DNS__SET32BIT(p, v) be32enc
|
||||
#else
|
||||
#define DNS__16BIT(p) le16dec(p)
|
||||
#define DNS__32BIT(p) le32dec(p)
|
||||
#define DNS__SET16BIT(p, v) le16enc(p,v)
|
||||
#define DNS__SET32BIT(p, v) le32enc
|
||||
#endif
|
||||
|
||||
/* Macros for parsing a DNS header */
|
||||
#define DNS_HEADER_QID(h) DNS__16BIT(h)
|
||||
#define DNS_HEADER_QR(h) (((h)[2] >> 7) & 0x1)
|
||||
@@ -83,9 +113,9 @@
|
||||
#define DNS_RR_LEN(r) DNS__16BIT((r) + 8)
|
||||
|
||||
/* Macros for constructing the fixed part of a DNS resource record */
|
||||
#define DNS_RR_SET_TYPE(r) DNS__SET16BIT(r, v)
|
||||
#define DNS_RR_SET_CLASS(r) DNS__SET16BIT((r) + 2, v)
|
||||
#define DNS_RR_SET_TTL(r) DNS__SET32BIT((r) + 4, v)
|
||||
#define DNS_RR_SET_LEN(r) DNS__SET16BIT((r) + 8, v)
|
||||
#define DNS_RR_SET_TYPE(r, v) DNS__SET16BIT(r, v)
|
||||
#define DNS_RR_SET_CLASS(r, v) DNS__SET16BIT((r) + 2, v)
|
||||
#define DNS_RR_SET_TTL(r, v) DNS__SET32BIT((r) + 4, v)
|
||||
#define DNS_RR_SET_LEN(r, v) DNS__SET16BIT((r) + 8, v)
|
||||
|
||||
#endif /* ARES__DNS_H */
|
||||
#endif /* HEADER_CARES_DNS_H */
|
||||
|
||||
+1
-6
@@ -1,4 +1,3 @@
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright (C) 2004-2009 by Daniel Stenberg
|
||||
.\"
|
||||
@@ -29,16 +28,12 @@ for name service lookups. If it returns successfully, \fBares_dup(3)\fP will
|
||||
set the variable pointed to by \fIdest\fP to a handle used to identify the
|
||||
name service channel. The caller should invoke \fIares_destroy(3)\fP on the
|
||||
handle when the channel is no longer needed.
|
||||
|
||||
The \fBares_dup_options\fP function also initializes a name service channel,
|
||||
with additional options set exactly as the \fIsource\fP channel has them
|
||||
configured.
|
||||
.SH SEE ALSO
|
||||
.BR ares_destroy(3),
|
||||
.BR ares_init(3),
|
||||
.BR ares_library_init(3)
|
||||
.SH AVAILABILITY
|
||||
ares_dup(3) was added in c-ares 1.6.0
|
||||
\fIares_dup(3)\fP was added in c-ares 1.6.0
|
||||
.SH AUTHOR
|
||||
Daniel Stenberg
|
||||
|
||||
|
||||
+3
-2
@@ -1,4 +1,3 @@
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.\"
|
||||
@@ -44,6 +43,8 @@ The length of the encoded name is stored in the variable pointed to by
|
||||
.I enclen
|
||||
so that the caller can advance past the encoded domain name to read
|
||||
further data in the message.
|
||||
|
||||
Use \fIares_free_string(3)\fP to free the allocated hostname.
|
||||
.SH RETURN VALUES
|
||||
.B ares_expand_name
|
||||
can return any of the following values:
|
||||
@@ -57,7 +58,7 @@ The encoded domain name was malformed and could not be expanded.
|
||||
.B ARES_ENOMEM
|
||||
Memory was exhausted.
|
||||
.SH SEE ALSO
|
||||
.BR ares_mkquery (3)
|
||||
.BR ares_mkquery (3), ares_free_string (3)
|
||||
.SH AUTHOR
|
||||
Greg Hudson, MIT Information Systems
|
||||
.br
|
||||
|
||||
+33
-18
@@ -1,6 +1,5 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
/* Copyright 1998, 2011 by the Massachusetts Institute of Technology.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose and without
|
||||
@@ -17,9 +16,6 @@
|
||||
|
||||
#include "ares_setup.h"
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
@@ -32,8 +28,8 @@
|
||||
# include <arpa/nameser_compat.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "ares.h"
|
||||
#include "ares_nowarn.h"
|
||||
#include "ares_private.h" /* for the memdebug */
|
||||
|
||||
static int name_length(const unsigned char *encoded, const unsigned char *abuf,
|
||||
@@ -69,22 +65,33 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
|
||||
int len, indir = 0;
|
||||
char *q;
|
||||
const unsigned char *p;
|
||||
union {
|
||||
ssize_t sig;
|
||||
size_t uns;
|
||||
} nlen;
|
||||
|
||||
len = name_length(encoded, abuf, alen);
|
||||
if (len < 0)
|
||||
nlen.sig = name_length(encoded, abuf, alen);
|
||||
if (nlen.sig < 0)
|
||||
return ARES_EBADNAME;
|
||||
|
||||
*s = malloc(((size_t)len) + 1);
|
||||
*s = ares_malloc(nlen.uns + 1);
|
||||
if (!*s)
|
||||
return ARES_ENOMEM;
|
||||
q = *s;
|
||||
|
||||
if (len == 0) {
|
||||
if (nlen.uns == 0) {
|
||||
/* RFC2181 says this should be ".": the root of the DNS tree.
|
||||
* Since this function strips trailing dots though, it becomes ""
|
||||
*/
|
||||
q[0] = '\0';
|
||||
*enclen = 1; /* the caller should move one byte to get past this */
|
||||
|
||||
/* indirect root label (like 0xc0 0x0c) is 2 bytes long (stupid, but
|
||||
valid) */
|
||||
if ((*encoded & INDIR_MASK) == INDIR_MASK)
|
||||
*enclen = 2L;
|
||||
else
|
||||
*enclen = 1L; /* the caller should move one byte to get past this */
|
||||
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -96,7 +103,7 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
|
||||
{
|
||||
if (!indir)
|
||||
{
|
||||
*enclen = p + 2 - encoded;
|
||||
*enclen = aresx_uztosl(p + 2U - encoded);
|
||||
indir = 1;
|
||||
}
|
||||
p = abuf + ((*p & ~INDIR_MASK) << 8 | *(p + 1));
|
||||
@@ -116,13 +123,13 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
|
||||
}
|
||||
}
|
||||
if (!indir)
|
||||
*enclen = p + 1 - encoded;
|
||||
*enclen = aresx_uztosl(p + 1U - encoded);
|
||||
|
||||
/* Nuke the trailing period if we wrote one. */
|
||||
if (q > *s)
|
||||
*(q - 1) = 0;
|
||||
else
|
||||
*q = 0; /* zero terminate */
|
||||
*q = 0; /* zero terminate; LCOV_EXCL_LINE: empty names exit above */
|
||||
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
@@ -133,15 +140,16 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
|
||||
static int name_length(const unsigned char *encoded, const unsigned char *abuf,
|
||||
int alen)
|
||||
{
|
||||
int n = 0, offset, indir = 0;
|
||||
int n = 0, offset, indir = 0, top;
|
||||
|
||||
/* Allow the caller to pass us abuf + alen and have us check for it. */
|
||||
if (encoded == abuf + alen)
|
||||
if (encoded >= abuf + alen)
|
||||
return -1;
|
||||
|
||||
while (*encoded)
|
||||
{
|
||||
if ((*encoded & INDIR_MASK) == INDIR_MASK)
|
||||
top = (*encoded & INDIR_MASK);
|
||||
if (top == INDIR_MASK)
|
||||
{
|
||||
/* Check the offset and go there. */
|
||||
if (encoded + 1 >= abuf + alen)
|
||||
@@ -157,7 +165,7 @@ static int name_length(const unsigned char *encoded, const unsigned char *abuf,
|
||||
if (++indir > alen)
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
else if (top == 0x00)
|
||||
{
|
||||
offset = *encoded;
|
||||
if (encoded + offset + 1 >= abuf + alen)
|
||||
@@ -170,6 +178,13 @@ static int name_length(const unsigned char *encoded, const unsigned char *abuf,
|
||||
}
|
||||
n++;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* RFC 1035 4.1.4 says other options (01, 10) for top 2
|
||||
* bits are reserved.
|
||||
*/
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* If there were any labels at all, then the number of dots is one
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.\"
|
||||
|
||||
+11
-13
@@ -1,4 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
*
|
||||
@@ -17,9 +16,6 @@
|
||||
|
||||
#include "ares_setup.h"
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
@@ -29,8 +25,6 @@
|
||||
# include "nameser.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "ares.h"
|
||||
#include "ares_private.h" /* for the memdebug */
|
||||
|
||||
@@ -46,26 +40,30 @@ int ares_expand_string(const unsigned char *encoded,
|
||||
long *enclen)
|
||||
{
|
||||
unsigned char *q;
|
||||
long len;
|
||||
union {
|
||||
ssize_t sig;
|
||||
size_t uns;
|
||||
} elen;
|
||||
|
||||
if (encoded == abuf+alen)
|
||||
return ARES_EBADSTR;
|
||||
|
||||
len = *encoded;
|
||||
if (encoded+len+1 > abuf+alen)
|
||||
elen.uns = *encoded;
|
||||
if (encoded+elen.sig+1 > abuf+alen)
|
||||
return ARES_EBADSTR;
|
||||
|
||||
encoded++;
|
||||
|
||||
*s = malloc(len+1);
|
||||
*s = ares_malloc(elen.uns+1);
|
||||
if (*s == NULL)
|
||||
return ARES_ENOMEM;
|
||||
q = *s;
|
||||
strncpy((char *)q, (char *)encoded, len);
|
||||
q[len] = '\0';
|
||||
strncpy((char *)q, (char *)encoded, elen.uns);
|
||||
q[elen.uns] = '\0';
|
||||
|
||||
*s = q;
|
||||
|
||||
*enclen = len+1;
|
||||
*enclen = (long)(elen.sig+1);
|
||||
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.\"
|
||||
|
||||
+1
-5
@@ -1,4 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
*
|
||||
@@ -17,11 +16,8 @@
|
||||
|
||||
#include "ares_setup.h"
|
||||
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_nowarn.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
int ares_fds(ares_channel channel, fd_set *read_fds, fd_set *write_fds)
|
||||
|
||||
+23
-5
@@ -1,7 +1,6 @@
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.\" Copyright (C) 2004-2009 by Daniel Stenberg
|
||||
.\" Copyright (C) 2004-2010 by Daniel Stenberg
|
||||
.\"
|
||||
.\" Permission to use, copy, modify, and distribute this
|
||||
.\" software and its documentation for any purpose and without
|
||||
@@ -15,7 +14,7 @@
|
||||
.\" this software for any purpose. It is provided "as is"
|
||||
.\" without express or implied warranty.
|
||||
.\"
|
||||
.TH ARES_FREE_DATA 3 "23 Nov 2009"
|
||||
.TH ARES_FREE_DATA 3 "5 March 2010"
|
||||
.SH NAME
|
||||
ares_free_data \- Free data allocated by several c-ares functions
|
||||
.SH SYNOPSIS
|
||||
@@ -34,27 +33,46 @@ function frees one or more data structures allocated and returned
|
||||
by several c-ares functions. Specifically the data returned by the
|
||||
following list of functions must be deallocated using this function.
|
||||
.TP 5
|
||||
.B ares_get_servers(3)
|
||||
When used to free the data returned by ares_get_servers(3) this
|
||||
will free the whole linked list of ares_addr_node structures returned
|
||||
by ares_get_servers(3).
|
||||
.TP
|
||||
.B ares_parse_srv_reply(3)
|
||||
When used to free the data returned by ares_parse_srv_reply(3) this
|
||||
will free the whole linked list of ares_srv_reply structures returned
|
||||
by ares_parse_srv_reply(3), along with any additional storage
|
||||
associated with those structures.
|
||||
.TP
|
||||
.B ares_parse_mx_reply(3)
|
||||
When used to free the data returned by ares_parse_mx_reply(3) this
|
||||
will free the whole linked list of ares_mx_reply structures returned
|
||||
by ares_parse_mx_reply(3), along with any additional storage
|
||||
associated with those structures.
|
||||
.TP
|
||||
.B ares_parse_txt_reply(3)
|
||||
When used to free the data returned by ares_parse_txt_reply(3) this
|
||||
will free the whole linked list of ares_txt_reply structures returned
|
||||
by ares_parse_txt_reply(3), along with any additional storage
|
||||
associated with those structures.
|
||||
.TP
|
||||
.B ares_parse_soa_reply(3)
|
||||
When used to free the data returned by ares_parse_soa_reply(3) this
|
||||
will free the ares_soa_reply structure, along with any additional storage
|
||||
associated with those structure.
|
||||
.SH RETURN VALUE
|
||||
The ares_free_data() function does not return a value.
|
||||
.SH AVAILABILITY
|
||||
This function was first introduced in c-ares version 1.7.0.
|
||||
.SH SEE ALSO
|
||||
.BR ares_get_servers(3),
|
||||
.BR ares_parse_srv_reply(3),
|
||||
.BR ares_parse_txt_reply(3)
|
||||
.BR ares_parse_mx_reply(3),
|
||||
.BR ares_parse_txt_reply(3),
|
||||
.BR ares_parse_soa_reply(3)
|
||||
.SH AUTHOR
|
||||
Yang Tse
|
||||
.PP
|
||||
Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.br
|
||||
Copyright (C) 2004-2009 by Daniel Stenberg.
|
||||
Copyright (C) 2004-2010 by Daniel Stenberg.
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.\"
|
||||
|
||||
+9
-8
@@ -1,4 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
*
|
||||
@@ -16,7 +15,6 @@
|
||||
*/
|
||||
|
||||
#include "ares_setup.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HAVE_NETDB_H
|
||||
#include <netdb.h>
|
||||
@@ -29,12 +27,15 @@ void ares_free_hostent(struct hostent *host)
|
||||
{
|
||||
char **p;
|
||||
|
||||
free((char *)(host->h_name));
|
||||
if (!host)
|
||||
return;
|
||||
|
||||
ares_free((char *)(host->h_name));
|
||||
for (p = host->h_aliases; *p; p++)
|
||||
free(*p);
|
||||
free(host->h_aliases);
|
||||
free(host->h_addr_list[0]); /* no matter if there is one or many entries,
|
||||
ares_free(*p);
|
||||
ares_free(host->h_aliases);
|
||||
ares_free(host->h_addr_list[0]); /* no matter if there is one or many entries,
|
||||
there is only one malloc for all of them */
|
||||
free(host->h_addr_list);
|
||||
free(host);
|
||||
ares_free(host->h_addr_list);
|
||||
ares_free(host);
|
||||
}
|
||||
|
||||
+2
-4
@@ -1,4 +1,3 @@
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright 2000 by the Massachusetts Institute of Technology.
|
||||
.\"
|
||||
@@ -24,9 +23,8 @@ ares_free_string \- Free strings allocated by ares functions
|
||||
.B void ares_free_string(void *\fIstr\fP)
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
.I ares_free_string
|
||||
function frees a string allocated by an ares function.
|
||||
The \fIares_free_string(3)\fP function frees a string allocated by an ares
|
||||
function.
|
||||
.SH SEE ALSO
|
||||
.BR ares_mkquery (3)
|
||||
.BR ares_expand_string (3)
|
||||
|
||||
+2
-3
@@ -1,4 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright 2000 by the Massachusetts Institute of Technology.
|
||||
*
|
||||
@@ -16,11 +15,11 @@
|
||||
*/
|
||||
|
||||
#include "ares_setup.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
void ares_free_string(void *str)
|
||||
{
|
||||
free(str);
|
||||
ares_free(str);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
.\"
|
||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.\" Copyright (C) 2008-2010 by Daniel Stenberg
|
||||
.\"
|
||||
.\" Permission to use, copy, modify, and distribute this
|
||||
.\" software and its documentation for any purpose and without
|
||||
.\" fee is hereby granted, provided that the above copyright
|
||||
.\" notice appear in all copies and that both that copyright
|
||||
.\" notice and this permission notice appear in supporting
|
||||
.\" documentation, and that the name of M.I.T. not be used in
|
||||
.\" advertising or publicity pertaining to distribution of the
|
||||
.\" software without specific, written prior permission.
|
||||
.\" M.I.T. makes no representations about the suitability of
|
||||
.\" this software for any purpose. It is provided "as is"
|
||||
.\" without express or implied warranty.
|
||||
.\"
|
||||
.TH ARES_GET_SERVERS 3 "5 March 2010"
|
||||
.SH NAME
|
||||
ares_get_servers, ares_get_servers_ports \- Retrieve name servers from an initialized ares_channel
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.B #include <ares.h>
|
||||
.PP
|
||||
.B int ares_get_servers(ares_channel \fIchannel\fP, struct ares_addr_node **\fIservers\fP)
|
||||
.B int ares_get_servers_ports(ares_channel \fIchannel\fP, struct ares_addr_port_node **\fIservers\fP)
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The \fBares_get_servers(3)\fP function retrieves name servers configuration
|
||||
from the
|
||||
channel data identified by
|
||||
.IR channel ,
|
||||
as a linked list of ares_addr_node structs storing a pointer to the first
|
||||
node at the address specified by
|
||||
.IR servers .
|
||||
|
||||
The \fBares_get_servers_ports(3)\fP function also retrieves any per-server
|
||||
port information that may have been previously configured, returning a linked
|
||||
list of ares_addr_port structures.
|
||||
|
||||
Function caller may traverse the returned name server linked list, or may use
|
||||
it directly as suitable input for the \fBares_set_servers(3)\fP /
|
||||
\fBares_set_servers_ports(3)\fP functions, but
|
||||
shall not shrink or extend the list on its own.
|
||||
|
||||
Each node of the name server linked list is stored in memory dynamically
|
||||
allocated and managed by c-ares. It is the caller's responsibility to free
|
||||
the resulting linked list, using \fBares_free_data(3)\fP , once the caller
|
||||
does not need it any longer.
|
||||
|
||||
This function is capable of handling IPv4 and IPv6 name server
|
||||
addresses simultaneously, rendering \fBares_save_options(3)\fP with
|
||||
optmask \fBARES_OPT_SERVERS\fP functionally obsolete except for
|
||||
IPv4-only name server usage.
|
||||
|
||||
.SH RETURN VALUES
|
||||
This function may return any of the following values:
|
||||
.TP 15
|
||||
.B ARES_SUCCESS
|
||||
The name servers configuration was successfully retrieved
|
||||
.TP 15
|
||||
.B ARES_ENOMEM
|
||||
The memory was exhausted
|
||||
.TP 15
|
||||
.B ARES_ENODATA
|
||||
The channel data identified by
|
||||
.IR channel
|
||||
was invalid.
|
||||
.SH SEE ALSO
|
||||
.BR ares_set_servers (3),
|
||||
.BR ares_init_options (3),
|
||||
.BR ares_save_options(3)
|
||||
.SH AVAILABILITY
|
||||
\fBares_get_servers(3)\fP was added in c-ares 1.7.1;
|
||||
\fBares_get_servers_ports(3)\fP was added in c-ares 1.11.0.
|
||||
.SH AUTHOR
|
||||
Implementation of this function and associated library internals are based
|
||||
on code, comments and feedback provided in November and December of 2008 by
|
||||
Daniel Stenberg, Gregor Jasny, Phil Blundell and Yang Tse, December 2009
|
||||
by Cedric Bail, February 2010 by Jakub Hrozek. On March 2010 Yang Tse
|
||||
shuffled all the bits and this function popped out.
|
||||
.br
|
||||
Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.br
|
||||
Copyright (C) 2008-2010 by Daniel Stenberg
|
||||
@@ -0,0 +1 @@
|
||||
.so man3/ares_get_servers.3
|
||||
+13
-10
@@ -1,9 +1,6 @@
|
||||
#ifndef __ARES_INET_NTOP_H
|
||||
#define __ARES_INET_NTOP_H
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 2005 by Dominick Meglio
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose and without
|
||||
@@ -18,10 +15,16 @@
|
||||
* without express or implied warranty.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_INET_NTOP
|
||||
#define ares_inet_ntop(w,x,y,z) inet_ntop(w,x,y,z)
|
||||
#else
|
||||
const char *ares_inet_ntop(int af, const void *src, char *dst, size_t size);
|
||||
#endif
|
||||
#include "ares_setup.h"
|
||||
#include "ares_getenv.h"
|
||||
|
||||
#endif /* __ARES_INET_NTOP_H */
|
||||
#ifndef HAVE_GETENV
|
||||
|
||||
char *ares_getenv(const char *name)
|
||||
{
|
||||
#ifdef _WIN32_WCE
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef HEADER_CARES_GETENV_H
|
||||
#define HEADER_CARES_GETENV_H
|
||||
|
||||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose and without
|
||||
* fee is hereby granted, provided that the above copyright
|
||||
* notice appear in all copies and that both that copyright
|
||||
* notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of M.I.T. not be used in
|
||||
* advertising or publicity pertaining to distribution of the
|
||||
* software without specific, written prior permission.
|
||||
* M.I.T. makes no representations about the suitability of
|
||||
* this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*/
|
||||
|
||||
#include "ares_setup.h"
|
||||
|
||||
#ifndef HAVE_GETENV
|
||||
extern char *ares_getenv(const char *name);
|
||||
#endif
|
||||
|
||||
#endif /* HEADER_CARES_GETENV_H */
|
||||
@@ -1,4 +1,3 @@
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.\"
|
||||
@@ -71,6 +70,9 @@ was not found.
|
||||
.B ARES_ENOMEM
|
||||
Memory was exhausted.
|
||||
.TP 19
|
||||
.B ARES_ECANCELLED
|
||||
The query was cancelled.
|
||||
.TP 19
|
||||
.B ARES_EDESTRUCTION
|
||||
The name service channel
|
||||
.I channel
|
||||
|
||||
+32
-29
@@ -1,4 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
*
|
||||
@@ -16,9 +15,6 @@
|
||||
*/
|
||||
#include "ares_setup.h"
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
@@ -37,12 +33,9 @@
|
||||
# include <arpa/nameser_compat.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ares.h"
|
||||
#include "inet_net_pton.h"
|
||||
#include "ares_inet_net_pton.h"
|
||||
#include "ares_platform.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
#ifdef WATT32
|
||||
@@ -79,14 +72,14 @@ void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen,
|
||||
return;
|
||||
}
|
||||
|
||||
if ((family == AF_INET && addrlen != sizeof(struct in_addr)) ||
|
||||
(family == AF_INET6 && addrlen != sizeof(struct in6_addr)))
|
||||
if ((family == AF_INET && addrlen != sizeof(aquery->addr.addrV4)) ||
|
||||
(family == AF_INET6 && addrlen != sizeof(aquery->addr.addrV6)))
|
||||
{
|
||||
callback(arg, ARES_ENOTIMP, 0, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
aquery = malloc(sizeof(struct addr_query));
|
||||
aquery = ares_malloc(sizeof(struct addr_query));
|
||||
if (!aquery)
|
||||
{
|
||||
callback(arg, ARES_ENOMEM, 0, NULL);
|
||||
@@ -94,9 +87,9 @@ void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen,
|
||||
}
|
||||
aquery->channel = channel;
|
||||
if (family == AF_INET)
|
||||
memcpy(&aquery->addr.addrV4, addr, sizeof(struct in_addr));
|
||||
memcpy(&aquery->addr.addrV4, addr, sizeof(aquery->addr.addrV4));
|
||||
else
|
||||
memcpy(&aquery->addr.addrV6, addr, sizeof(struct in6_addr));
|
||||
memcpy(&aquery->addr.addrV6, addr, sizeof(aquery->addr.addrV6));
|
||||
aquery->addr.family = family;
|
||||
aquery->callback = callback;
|
||||
aquery->arg = arg;
|
||||
@@ -152,13 +145,13 @@ static void addr_callback(void *arg, int status, int timeouts,
|
||||
{
|
||||
if (aquery->addr.family == AF_INET)
|
||||
{
|
||||
addrlen = sizeof(struct in_addr);
|
||||
addrlen = sizeof(aquery->addr.addrV4);
|
||||
status = ares_parse_ptr_reply(abuf, alen, &aquery->addr.addrV4,
|
||||
(int)addrlen, AF_INET, &host);
|
||||
}
|
||||
else
|
||||
{
|
||||
addrlen = sizeof(struct in6_addr);
|
||||
addrlen = sizeof(aquery->addr.addrV6);
|
||||
status = ares_parse_ptr_reply(abuf, alen, &aquery->addr.addrV6,
|
||||
(int)addrlen, AF_INET6, &host);
|
||||
}
|
||||
@@ -176,7 +169,7 @@ static void end_aquery(struct addr_query *aquery, int status,
|
||||
aquery->callback(aquery->arg, status, aquery->timeouts, host);
|
||||
if (host)
|
||||
ares_free_hostent(host);
|
||||
free(aquery);
|
||||
ares_free(aquery);
|
||||
}
|
||||
|
||||
static int file_lookup(struct ares_addr *addr, struct hostent **host)
|
||||
@@ -187,12 +180,18 @@ static int file_lookup(struct ares_addr *addr, struct hostent **host)
|
||||
|
||||
#ifdef WIN32
|
||||
char PATH_HOSTS[MAX_PATH];
|
||||
if (IS_NT()) {
|
||||
win_platform platform;
|
||||
|
||||
PATH_HOSTS[0] = '\0';
|
||||
|
||||
platform = ares__getplatform();
|
||||
|
||||
if (platform == WIN_NT) {
|
||||
char tmp[MAX_PATH];
|
||||
HKEY hkeyHosts;
|
||||
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, &hkeyHosts)
|
||||
== ERROR_SUCCESS)
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ,
|
||||
&hkeyHosts) == ERROR_SUCCESS)
|
||||
{
|
||||
DWORD dwLength = MAX_PATH;
|
||||
RegQueryValueEx(hkeyHosts, DATABASEPATH, NULL, NULL, (LPBYTE)tmp,
|
||||
@@ -201,8 +200,10 @@ static int file_lookup(struct ares_addr *addr, struct hostent **host)
|
||||
RegCloseKey(hkeyHosts);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (platform == WIN_9X)
|
||||
GetWindowsDirectory(PATH_HOSTS, MAX_PATH);
|
||||
else
|
||||
return ARES_ENOTFOUND;
|
||||
|
||||
strcat(PATH_HOSTS, WIN_PATH_HOSTS);
|
||||
|
||||
@@ -241,12 +242,14 @@ static int file_lookup(struct ares_addr *addr, struct hostent **host)
|
||||
}
|
||||
if (addr->family == AF_INET)
|
||||
{
|
||||
if (memcmp((*host)->h_addr, &addr->addrV4, sizeof(struct in_addr)) == 0)
|
||||
if (memcmp((*host)->h_addr, &addr->addrV4,
|
||||
sizeof(addr->addrV4)) == 0)
|
||||
break;
|
||||
}
|
||||
else if (addr->family == AF_INET6)
|
||||
{
|
||||
if (memcmp((*host)->h_addr, &addr->addrV6, sizeof(struct in6_addr)) == 0)
|
||||
if (memcmp((*host)->h_addr, &addr->addrV6,
|
||||
sizeof(addr->addrV6)) == 0)
|
||||
break;
|
||||
}
|
||||
ares_free_hostent(*host);
|
||||
@@ -264,15 +267,15 @@ static void ptr_rr_name(char *name, const struct ares_addr *addr)
|
||||
if (addr->family == AF_INET)
|
||||
{
|
||||
unsigned long laddr = ntohl(addr->addrV4.s_addr);
|
||||
int a1 = (int)((laddr >> 24) & 0xff);
|
||||
int a2 = (int)((laddr >> 16) & 0xff);
|
||||
int a3 = (int)((laddr >> 8) & 0xff);
|
||||
int a4 = (int)(laddr & 0xff);
|
||||
sprintf(name, "%d.%d.%d.%d.in-addr.arpa", a4, a3, a2, a1);
|
||||
unsigned long a1 = (laddr >> 24UL) & 0xFFUL;
|
||||
unsigned long a2 = (laddr >> 16UL) & 0xFFUL;
|
||||
unsigned long a3 = (laddr >> 8UL) & 0xFFUL;
|
||||
unsigned long a4 = laddr & 0xFFUL;
|
||||
sprintf(name, "%lu.%lu.%lu.%lu.in-addr.arpa", a4, a3, a2, a1);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char *bytes = (unsigned char *)&addr->addrV6.s6_addr;
|
||||
unsigned char *bytes = (unsigned char *)&addr->addrV6;
|
||||
/* There are too many arguments to do this in one line using
|
||||
* minimally C89-compliant compilers */
|
||||
sprintf(name,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.\"
|
||||
@@ -75,6 +74,9 @@ was not found.
|
||||
.B ARES_ENOMEM
|
||||
Memory was exhausted.
|
||||
.TP 19
|
||||
.B ARES_ECANCELLED
|
||||
The query was cancelled.
|
||||
.TP 19
|
||||
.B ARES_EDESTRUCTION
|
||||
The name service channel
|
||||
.I channel
|
||||
|
||||
+57
-50
@@ -1,6 +1,5 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
/* Copyright 1998, 2011, 2013 by the Massachusetts Institute of Technology.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose and without
|
||||
@@ -17,9 +16,6 @@
|
||||
|
||||
#include "ares_setup.h"
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
@@ -38,17 +34,15 @@
|
||||
# include <arpa/nameser_compat.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "ares.h"
|
||||
#include "inet_net_pton.h"
|
||||
#include "ares_inet_net_pton.h"
|
||||
#include "bitncmp.h"
|
||||
#include "ares_platform.h"
|
||||
#include "ares_nowarn.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
#ifdef WATT32
|
||||
@@ -81,7 +75,7 @@ static void sort6_addresses(struct hostent *host,
|
||||
const struct apattern *sortlist, int nsort);
|
||||
static int get_address_index(const struct in_addr *addr,
|
||||
const struct apattern *sortlist, int nsort);
|
||||
static int get6_address_index(const struct in6_addr *addr,
|
||||
static int get6_address_index(const struct ares_in6_addr *addr,
|
||||
const struct apattern *sortlist, int nsort);
|
||||
|
||||
void ares_gethostbyname(ares_channel channel, const char *name, int family,
|
||||
@@ -105,18 +99,18 @@ void ares_gethostbyname(ares_channel channel, const char *name, int family,
|
||||
return;
|
||||
|
||||
/* Allocate and fill in the host query structure. */
|
||||
hquery = malloc(sizeof(struct host_query));
|
||||
hquery = ares_malloc(sizeof(struct host_query));
|
||||
if (!hquery)
|
||||
{
|
||||
callback(arg, ARES_ENOMEM, 0, NULL);
|
||||
return;
|
||||
}
|
||||
hquery->channel = channel;
|
||||
hquery->name = strdup(name);
|
||||
hquery->name = ares_strdup(name);
|
||||
hquery->want_family = family;
|
||||
hquery->sent_family = -1; /* nothing is sent yet */
|
||||
if (!hquery->name) {
|
||||
free(hquery);
|
||||
ares_free(hquery);
|
||||
callback(arg, ARES_ENOMEM, 0, NULL);
|
||||
return;
|
||||
}
|
||||
@@ -151,8 +145,8 @@ static void next_lookup(struct host_query *hquery, int status_code)
|
||||
}
|
||||
else {
|
||||
hquery->sent_family = AF_INET;
|
||||
ares_search(hquery->channel, hquery->name, C_IN, T_A, host_callback,
|
||||
hquery);
|
||||
ares_search(hquery->channel, hquery->name, C_IN, T_A,
|
||||
host_callback, hquery);
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -194,10 +188,14 @@ static void host_callback(void *arg, int status, int timeouts,
|
||||
else if (hquery->sent_family == AF_INET6)
|
||||
{
|
||||
status = ares_parse_aaaa_reply(abuf, alen, &host, NULL, NULL);
|
||||
if (status == ARES_ENODATA || status == ARES_EBADRESP) {
|
||||
/* The query returned something but either there were no AAAA records (e.g. just CNAME)
|
||||
or the response was malformed. Try looking up A instead.
|
||||
We should possibly limit this attempt-next logic to AF_UNSPEC lookups only. */
|
||||
if ((status == ARES_ENODATA || status == ARES_EBADRESP ||
|
||||
(status == ARES_SUCCESS && host && host->h_addr_list[0] == NULL)) &&
|
||||
hquery->want_family == AF_UNSPEC) {
|
||||
/* The query returned something but either there were no AAAA
|
||||
records (e.g. just CNAME) or the response was malformed. Try
|
||||
looking up A instead. */
|
||||
if (host)
|
||||
ares_free_hostent(host);
|
||||
hquery->sent_family = AF_INET;
|
||||
ares_search(hquery->channel, hquery->name, C_IN, T_A,
|
||||
host_callback, hquery);
|
||||
@@ -208,10 +206,11 @@ static void host_callback(void *arg, int status, int timeouts,
|
||||
}
|
||||
end_hquery(hquery, status, host);
|
||||
}
|
||||
else if ((status == ARES_ENODATA || status == ARES_EBADRESP || status == ARES_ETIMEOUT) && hquery->sent_family == AF_INET6)
|
||||
else if ((status == ARES_ENODATA || status == ARES_EBADRESP ||
|
||||
status == ARES_ETIMEOUT) && (hquery->sent_family == AF_INET6 &&
|
||||
hquery->want_family == AF_UNSPEC))
|
||||
{
|
||||
/* The AAAA query yielded no useful result. Now look up an A instead.
|
||||
We should possibly limit this attempt-next logic to AF_UNSPEC lookups only. */
|
||||
/* The AAAA query yielded no useful result. Now look up an A instead. */
|
||||
hquery->sent_family = AF_INET;
|
||||
ares_search(hquery->channel, hquery->name, C_IN, T_A, host_callback,
|
||||
hquery);
|
||||
@@ -228,22 +227,22 @@ static void end_hquery(struct host_query *hquery, int status,
|
||||
hquery->callback(hquery->arg, status, hquery->timeouts, host);
|
||||
if (host)
|
||||
ares_free_hostent(host);
|
||||
free(hquery->name);
|
||||
free(hquery);
|
||||
ares_free(hquery->name);
|
||||
ares_free(hquery);
|
||||
}
|
||||
|
||||
/* If the name looks like an IP address, fake up a host entry, end the
|
||||
* query immediately, and return true. Otherwise return false.
|
||||
*/
|
||||
static int fake_hostent(const char *name, int family, ares_host_callback callback,
|
||||
void *arg)
|
||||
static int fake_hostent(const char *name, int family,
|
||||
ares_host_callback callback, void *arg)
|
||||
{
|
||||
struct hostent hostent;
|
||||
char *aliases[1] = { NULL };
|
||||
char *addrs[2];
|
||||
int result = 0;
|
||||
struct in_addr in;
|
||||
struct in6_addr in6;
|
||||
struct ares_in6_addr in6;
|
||||
|
||||
if (family == AF_INET || family == AF_INET6)
|
||||
{
|
||||
@@ -284,11 +283,11 @@ static int fake_hostent(const char *name, int family, ares_host_callback callbac
|
||||
}
|
||||
else if (family == AF_INET6)
|
||||
{
|
||||
hostent.h_length = (int)sizeof(struct in6_addr);
|
||||
hostent.h_length = (int)sizeof(struct ares_in6_addr);
|
||||
addrs[0] = (char *)&in6;
|
||||
}
|
||||
/* Duplicate the name, to avoid a constness violation. */
|
||||
hostent.h_name = strdup(name);
|
||||
hostent.h_name = ares_strdup(name);
|
||||
if (!hostent.h_name)
|
||||
{
|
||||
callback(arg, ARES_ENOMEM, 0, NULL);
|
||||
@@ -298,11 +297,11 @@ static int fake_hostent(const char *name, int family, ares_host_callback callbac
|
||||
/* Fill in the rest of the host structure and terminate the query. */
|
||||
addrs[1] = NULL;
|
||||
hostent.h_aliases = aliases;
|
||||
hostent.h_addrtype = family;
|
||||
hostent.h_addrtype = aresx_sitoss(family);
|
||||
hostent.h_addr_list = addrs;
|
||||
callback(arg, ARES_SUCCESS, 0, &hostent);
|
||||
|
||||
free((char *)(hostent.h_name));
|
||||
ares_free((char *)(hostent.h_name));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -342,12 +341,18 @@ static int file_lookup(const char *name, int family, struct hostent **host)
|
||||
|
||||
#ifdef WIN32
|
||||
char PATH_HOSTS[MAX_PATH];
|
||||
if (IS_NT()) {
|
||||
win_platform platform;
|
||||
|
||||
PATH_HOSTS[0] = '\0';
|
||||
|
||||
platform = ares__getplatform();
|
||||
|
||||
if (platform == WIN_NT) {
|
||||
char tmp[MAX_PATH];
|
||||
HKEY hkeyHosts;
|
||||
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, &hkeyHosts)
|
||||
== ERROR_SUCCESS)
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ,
|
||||
&hkeyHosts) == ERROR_SUCCESS)
|
||||
{
|
||||
DWORD dwLength = MAX_PATH;
|
||||
RegQueryValueEx(hkeyHosts, DATABASEPATH, NULL, NULL, (LPBYTE)tmp,
|
||||
@@ -356,8 +361,10 @@ static int file_lookup(const char *name, int family, struct hostent **host)
|
||||
RegCloseKey(hkeyHosts);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (platform == WIN_9X)
|
||||
GetWindowsDirectory(PATH_HOSTS, MAX_PATH);
|
||||
else
|
||||
return ARES_ENOTFOUND;
|
||||
|
||||
strcat(PATH_HOSTS, WIN_PATH_HOSTS);
|
||||
|
||||
@@ -408,8 +415,8 @@ static int file_lookup(const char *name, int family, struct hostent **host)
|
||||
return status;
|
||||
}
|
||||
|
||||
static void sort_addresses(struct hostent *host, const struct apattern *sortlist,
|
||||
int nsort)
|
||||
static void sort_addresses(struct hostent *host,
|
||||
const struct apattern *sortlist, int nsort)
|
||||
{
|
||||
struct in_addr a1, a2;
|
||||
int i1, i2, ind1, ind2;
|
||||
@@ -456,18 +463,18 @@ static int get_address_index(const struct in_addr *addr,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ares_bitncmp(&addr->s_addr, &sortlist[i].addrV4.s_addr,
|
||||
sortlist[i].mask.bits))
|
||||
if (!ares__bitncmp(&addr->s_addr, &sortlist[i].addrV4.s_addr,
|
||||
sortlist[i].mask.bits))
|
||||
break;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
static void sort6_addresses(struct hostent *host, const struct apattern *sortlist,
|
||||
int nsort)
|
||||
static void sort6_addresses(struct hostent *host,
|
||||
const struct apattern *sortlist, int nsort)
|
||||
{
|
||||
struct in6_addr a1, a2;
|
||||
struct ares_in6_addr a1, a2;
|
||||
int i1, i2, ind1, ind2;
|
||||
|
||||
/* This is a simple insertion sort, not optimized at all. i1 walks
|
||||
@@ -477,24 +484,24 @@ static void sort6_addresses(struct hostent *host, const struct apattern *sortlis
|
||||
*/
|
||||
for (i1 = 0; host->h_addr_list[i1]; i1++)
|
||||
{
|
||||
memcpy(&a1, host->h_addr_list[i1], sizeof(struct in6_addr));
|
||||
memcpy(&a1, host->h_addr_list[i1], sizeof(struct ares_in6_addr));
|
||||
ind1 = get6_address_index(&a1, sortlist, nsort);
|
||||
for (i2 = i1 - 1; i2 >= 0; i2--)
|
||||
{
|
||||
memcpy(&a2, host->h_addr_list[i2], sizeof(struct in6_addr));
|
||||
memcpy(&a2, host->h_addr_list[i2], sizeof(struct ares_in6_addr));
|
||||
ind2 = get6_address_index(&a2, sortlist, nsort);
|
||||
if (ind2 <= ind1)
|
||||
break;
|
||||
memcpy(host->h_addr_list[i2 + 1], &a2, sizeof(struct in6_addr));
|
||||
memcpy(host->h_addr_list[i2 + 1], &a2, sizeof(struct ares_in6_addr));
|
||||
}
|
||||
memcpy(host->h_addr_list[i2 + 1], &a1, sizeof(struct in6_addr));
|
||||
memcpy(host->h_addr_list[i2 + 1], &a1, sizeof(struct ares_in6_addr));
|
||||
}
|
||||
}
|
||||
|
||||
/* Find the first entry in sortlist which matches addr. Return nsort
|
||||
* if none of them match.
|
||||
*/
|
||||
static int get6_address_index(const struct in6_addr *addr,
|
||||
static int get6_address_index(const struct ares_in6_addr *addr,
|
||||
const struct apattern *sortlist,
|
||||
int nsort)
|
||||
{
|
||||
@@ -504,8 +511,8 @@ static int get6_address_index(const struct in6_addr *addr,
|
||||
{
|
||||
if (sortlist[i].family != AF_INET6)
|
||||
continue;
|
||||
if (!ares_bitncmp(&addr->s6_addr, &sortlist[i].addrV6.s6_addr, sortlist[i].mask.bits))
|
||||
break;
|
||||
if (!ares__bitncmp(addr, &sortlist[i].addrV6, sortlist[i].mask.bits))
|
||||
break;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.\"
|
||||
|
||||
+3
-2
@@ -1,4 +1,3 @@
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright 2005 by Dominick Meglio.
|
||||
.\"
|
||||
@@ -110,6 +109,9 @@ was not found.
|
||||
.B ARES_ENOMEM
|
||||
Memory was exhausted.
|
||||
.TP 19
|
||||
.B ARES_ECANCELLED
|
||||
The query was cancelled.
|
||||
.TP 19
|
||||
.B ARES_EDESTRUCTION
|
||||
The name service channel
|
||||
.I channel
|
||||
@@ -143,7 +145,6 @@ will be
|
||||
.BR NULL .
|
||||
.SH SEE ALSO
|
||||
.BR ares_process (3),
|
||||
.BR ares_getaddrinfo (3)
|
||||
.SH AUTHOR
|
||||
Dominick Meglio
|
||||
.br
|
||||
|
||||
+67
-54
@@ -1,4 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright 2005 by Dominick Meglio
|
||||
*
|
||||
@@ -23,9 +22,6 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
@@ -48,17 +44,9 @@
|
||||
#include <net/if.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_ipv6.h"
|
||||
#include "inet_ntop.h"
|
||||
#include "ares_nowarn.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
struct nameinfo_query {
|
||||
@@ -74,19 +62,22 @@ struct nameinfo_query {
|
||||
};
|
||||
|
||||
#ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
|
||||
#define IPBUFSIZ 40+IF_NAMESIZE
|
||||
#define IPBUFSIZ \
|
||||
(sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255") + IF_NAMESIZE)
|
||||
#else
|
||||
#define IPBUFSIZ 40
|
||||
#define IPBUFSIZ \
|
||||
(sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"))
|
||||
#endif
|
||||
|
||||
static void nameinfo_callback(void *arg, int status, int timeouts, struct hostent *host);
|
||||
static void nameinfo_callback(void *arg, int status, int timeouts,
|
||||
struct hostent *host);
|
||||
static char *lookup_service(unsigned short port, int flags,
|
||||
char *buf, size_t buflen);
|
||||
#ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
|
||||
static void append_scopeid(struct sockaddr_in6 *addr6, unsigned int scopeid,
|
||||
char *buf, size_t buflen);
|
||||
#endif
|
||||
static char *ares_striendstr(const char *s1, const char *s2);
|
||||
STATIC_TESTABLE char *ares_striendstr(const char *s1, const char *s2);
|
||||
|
||||
void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa,
|
||||
ares_socklen_t salen,
|
||||
@@ -97,13 +88,15 @@ void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa,
|
||||
struct nameinfo_query *niquery;
|
||||
unsigned int port = 0;
|
||||
|
||||
/* Verify the buffer size */
|
||||
if (salen == sizeof(struct sockaddr_in))
|
||||
/* Validate socket address family and length */
|
||||
if ((sa->sa_family == AF_INET) &&
|
||||
(salen == sizeof(struct sockaddr_in)))
|
||||
{
|
||||
addr = (struct sockaddr_in *)sa;
|
||||
port = addr->sin_port;
|
||||
}
|
||||
else if (salen == sizeof(struct sockaddr_in6))
|
||||
else if ((sa->sa_family == AF_INET6) &&
|
||||
(salen == sizeof(struct sockaddr_in6)))
|
||||
{
|
||||
addr6 = (struct sockaddr_in6 *)sa;
|
||||
port = addr6->sin6_port;
|
||||
@@ -170,7 +163,7 @@ void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa,
|
||||
/* This is where a DNS lookup becomes necessary */
|
||||
else
|
||||
{
|
||||
niquery = malloc(sizeof(struct nameinfo_query));
|
||||
niquery = ares_malloc(sizeof(struct nameinfo_query));
|
||||
if (!niquery)
|
||||
{
|
||||
callback(arg, ARES_ENOMEM, 0, NULL, NULL);
|
||||
@@ -183,22 +176,25 @@ void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa,
|
||||
if (sa->sa_family == AF_INET)
|
||||
{
|
||||
niquery->family = AF_INET;
|
||||
memcpy(&niquery->addr.addr4, addr, sizeof(addr));
|
||||
ares_gethostbyaddr(channel, &addr->sin_addr, sizeof(struct in_addr), AF_INET,
|
||||
memcpy(&niquery->addr.addr4, addr, sizeof(niquery->addr.addr4));
|
||||
ares_gethostbyaddr(channel, &addr->sin_addr,
|
||||
sizeof(struct in_addr), AF_INET,
|
||||
nameinfo_callback, niquery);
|
||||
}
|
||||
else
|
||||
{
|
||||
niquery->family = AF_INET6;
|
||||
memcpy(&niquery->addr.addr6, addr6, sizeof(addr6));
|
||||
ares_gethostbyaddr(channel, &addr6->sin6_addr, sizeof(struct in6_addr), AF_INET6,
|
||||
memcpy(&niquery->addr.addr6, addr6, sizeof(niquery->addr.addr6));
|
||||
ares_gethostbyaddr(channel, &addr6->sin6_addr,
|
||||
sizeof(struct ares_in6_addr), AF_INET6,
|
||||
nameinfo_callback, niquery);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void nameinfo_callback(void *arg, int status, int timeouts, struct hostent *host)
|
||||
static void nameinfo_callback(void *arg, int status, int timeouts,
|
||||
struct hostent *host)
|
||||
{
|
||||
struct nameinfo_query *niquery = (struct nameinfo_query *) arg;
|
||||
char srvbuf[33];
|
||||
@@ -217,8 +213,8 @@ static void nameinfo_callback(void *arg, int status, int timeouts, struct hosten
|
||||
service = lookup_service(niquery->addr.addr6.sin6_port,
|
||||
niquery->flags, srvbuf, sizeof(srvbuf));
|
||||
}
|
||||
/* NOFQDN means we have to strip off the domain name portion.
|
||||
We do this by determining our own domain name, then searching the string
|
||||
/* NOFQDN means we have to strip off the domain name portion. We do
|
||||
this by determining our own domain name, then searching the string
|
||||
for this domain name and removing it.
|
||||
*/
|
||||
#ifdef HAVE_GETHOSTNAME
|
||||
@@ -227,7 +223,7 @@ static void nameinfo_callback(void *arg, int status, int timeouts, struct hosten
|
||||
char buf[255];
|
||||
char *domain;
|
||||
gethostname(buf, 255);
|
||||
if ((domain = strchr(buf, '.')))
|
||||
if ((domain = strchr(buf, '.')) != NULL)
|
||||
{
|
||||
char *end = ares_striendstr(host->h_name, domain);
|
||||
if (end)
|
||||
@@ -235,8 +231,10 @@ static void nameinfo_callback(void *arg, int status, int timeouts, struct hosten
|
||||
}
|
||||
}
|
||||
#endif
|
||||
niquery->callback(niquery->arg, ARES_SUCCESS, niquery->timeouts, (char *)(host->h_name),
|
||||
niquery->callback(niquery->arg, ARES_SUCCESS, niquery->timeouts,
|
||||
(char *)(host->h_name),
|
||||
service);
|
||||
ares_free(niquery);
|
||||
return;
|
||||
}
|
||||
/* We couldn't find the host, but it's OK, we can use the IP */
|
||||
@@ -244,12 +242,15 @@ static void nameinfo_callback(void *arg, int status, int timeouts, struct hosten
|
||||
{
|
||||
char ipbuf[IPBUFSIZ];
|
||||
if (niquery->family == AF_INET)
|
||||
ares_inet_ntop(AF_INET, &niquery->addr.addr4.sin_addr, ipbuf, IPBUFSIZ);
|
||||
ares_inet_ntop(AF_INET, &niquery->addr.addr4.sin_addr, ipbuf,
|
||||
IPBUFSIZ);
|
||||
else
|
||||
{
|
||||
ares_inet_ntop(AF_INET6, &niquery->addr.addr6.sin6_addr, ipbuf, IPBUFSIZ);
|
||||
ares_inet_ntop(AF_INET6, &niquery->addr.addr6.sin6_addr, ipbuf,
|
||||
IPBUFSIZ);
|
||||
#ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
|
||||
append_scopeid(&niquery->addr.addr6, niquery->flags, ipbuf, sizeof(ipbuf));
|
||||
append_scopeid(&niquery->addr.addr6, niquery->flags, ipbuf,
|
||||
sizeof(ipbuf));
|
||||
#endif
|
||||
}
|
||||
/* They want a service too */
|
||||
@@ -262,11 +263,13 @@ static void nameinfo_callback(void *arg, int status, int timeouts, struct hosten
|
||||
service = lookup_service(niquery->addr.addr6.sin6_port,
|
||||
niquery->flags, srvbuf, sizeof(srvbuf));
|
||||
}
|
||||
niquery->callback(niquery->arg, ARES_SUCCESS, niquery->timeouts, ipbuf, service);
|
||||
niquery->callback(niquery->arg, ARES_SUCCESS, niquery->timeouts, ipbuf,
|
||||
service);
|
||||
ares_free(niquery);
|
||||
return;
|
||||
}
|
||||
niquery->callback(niquery->arg, status, niquery->timeouts, NULL, NULL);
|
||||
free(niquery);
|
||||
ares_free(niquery);
|
||||
}
|
||||
|
||||
static char *lookup_service(unsigned short port, int flags,
|
||||
@@ -278,6 +281,8 @@ static char *lookup_service(unsigned short port, int flags,
|
||||
struct servent se;
|
||||
#endif
|
||||
char tmpbuf[4096];
|
||||
char *name;
|
||||
size_t name_len;
|
||||
|
||||
if (port)
|
||||
{
|
||||
@@ -294,13 +299,16 @@ static char *lookup_service(unsigned short port, int flags,
|
||||
else
|
||||
proto = "tcp";
|
||||
#ifdef HAVE_GETSERVBYPORT_R
|
||||
memset(&se, 0, sizeof(se));
|
||||
sep = &se;
|
||||
memset(tmpbuf, 0, sizeof(tmpbuf));
|
||||
#if GETSERVBYPORT_R_ARGS == 6
|
||||
if (getservbyport_r(port, proto, &se, (void *)tmpbuf, sizeof(tmpbuf), &sep) != 0)
|
||||
sep = NULL;
|
||||
if (getservbyport_r(port, proto, &se, (void *)tmpbuf,
|
||||
sizeof(tmpbuf), &sep) != 0)
|
||||
sep = NULL; /* LCOV_EXCL_LINE: buffer large so this never fails */
|
||||
#elif GETSERVBYPORT_R_ARGS == 5
|
||||
sep = getservbyport_r(port, proto, &se, (void *)tmpbuf, sizeof(tmpbuf));
|
||||
sep = getservbyport_r(port, proto, &se, (void *)tmpbuf,
|
||||
sizeof(tmpbuf));
|
||||
#elif GETSERVBYPORT_R_ARGS == 4
|
||||
if (getservbyport_r(port, proto, &se, (void *)tmpbuf) != 0)
|
||||
sep = NULL;
|
||||
@@ -318,17 +326,23 @@ static char *lookup_service(unsigned short port, int flags,
|
||||
#endif
|
||||
}
|
||||
if (sep && sep->s_name)
|
||||
/* get service name */
|
||||
strcpy(tmpbuf, sep->s_name);
|
||||
{
|
||||
/* get service name */
|
||||
name = sep->s_name;
|
||||
}
|
||||
else
|
||||
/* get port as a string */
|
||||
sprintf(tmpbuf, "%u", (unsigned int)ntohs(port));
|
||||
if (strlen(tmpbuf) < buflen)
|
||||
{
|
||||
/* get port as a string */
|
||||
sprintf(tmpbuf, "%u", (unsigned int)ntohs(port));
|
||||
name = tmpbuf;
|
||||
}
|
||||
name_len = strlen(name);
|
||||
if (name_len < buflen)
|
||||
/* return it if buffer big enough */
|
||||
strcpy(buf, tmpbuf);
|
||||
memcpy(buf, name, name_len + 1);
|
||||
else
|
||||
/* avoid reusing previous one */
|
||||
buf[0] = '\0';
|
||||
buf[0] = '\0'; /* LCOV_EXCL_LINE: no real service names are too big */
|
||||
return buf;
|
||||
}
|
||||
buf[0] = '\0';
|
||||
@@ -342,11 +356,12 @@ static void append_scopeid(struct sockaddr_in6 *addr6, unsigned int flags,
|
||||
#ifdef HAVE_IF_INDEXTONAME
|
||||
int is_ll, is_mcll;
|
||||
#endif
|
||||
char fmt_u[] = "%u";
|
||||
char fmt_lu[] = "%lu";
|
||||
static const char fmt_u[] = "%u";
|
||||
static const char fmt_lu[] = "%lu";
|
||||
char tmpbuf[IF_NAMESIZE + 2];
|
||||
size_t bufl;
|
||||
char *fmt = (sizeof(addr6->sin6_scope_id) > sizeof(unsigned int))?fmt_lu:fmt_u;
|
||||
const char *fmt = (sizeof(addr6->sin6_scope_id) > sizeof(unsigned int))?
|
||||
fmt_lu:fmt_u;
|
||||
|
||||
tmpbuf[0] = '%';
|
||||
|
||||
@@ -377,7 +392,7 @@ static void append_scopeid(struct sockaddr_in6 *addr6, unsigned int flags,
|
||||
#endif
|
||||
|
||||
/* Determines if s1 ends with the string in s2 (case-insensitive) */
|
||||
static char *ares_striendstr(const char *s1, const char *s2)
|
||||
STATIC_TESTABLE char *ares_striendstr(const char *s1, const char *s2)
|
||||
{
|
||||
const char *c1, *c2, *c1_begin;
|
||||
int lo1, lo2;
|
||||
@@ -393,8 +408,8 @@ static char *ares_striendstr(const char *s1, const char *s2)
|
||||
c2 = s2;
|
||||
while (c2 < s2+s2_len)
|
||||
{
|
||||
lo1 = tolower(*c1);
|
||||
lo2 = tolower(*c2);
|
||||
lo1 = TOLOWER(*c1);
|
||||
lo2 = TOLOWER(*c2);
|
||||
if (lo1 != lo2)
|
||||
return NULL;
|
||||
else
|
||||
@@ -403,7 +418,5 @@ static char *ares_striendstr(const char *s1, const char *s2)
|
||||
c2++;
|
||||
}
|
||||
}
|
||||
if (c2 == c1 && c2 == NULL)
|
||||
return (char *)c1_begin;
|
||||
return NULL;
|
||||
return (char *)c1_begin;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* on 2007-04-11. Lifted from version 5.2 of the 'Open Mash' project with
|
||||
* the modified BSD license, BSD license without the advertising clause.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
+5
-6
@@ -1,4 +1,3 @@
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright 1998 by Daniel Stenberg
|
||||
.\"
|
||||
@@ -14,25 +13,25 @@
|
||||
.\" this software for any purpose. It is provided "as is"
|
||||
.\" without express or implied warranty.
|
||||
.\"
|
||||
.TH ARES_GETSOCK 3 "22 December 2005"
|
||||
.TH ARES_GETSOCK 3 "11 March 2010"
|
||||
.SH NAME
|
||||
ares_getsock \- get file descriptors to wait on
|
||||
ares_getsock \- get socket descriptors to wait on
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.B #include <ares.h>
|
||||
.PP
|
||||
.B int ares_getsock(ares_channel \fIchannel\fP, int *\fIsocks\fP,
|
||||
.B int ares_getsock(ares_channel \fIchannel\fP, ares_socket_t *\fIsocks\fP,
|
||||
.B int \fInumsocks\fP);
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
.B ares_getsock
|
||||
function retrieves the set of file descriptors which the calling
|
||||
function retrieves the set of socket descriptors which the calling
|
||||
application should wait on for reading and/or writing for the
|
||||
processing of name service queries pending on the name service channel
|
||||
identified by
|
||||
.IR channel .
|
||||
File descriptors will be set in the integer array pointed to by
|
||||
Socket descriptors will be set in the socket descriptor array pointed to by
|
||||
\fIsocks\fP.
|
||||
\fInumsocks\fP is the size of the given array in number of ints.
|
||||
|
||||
|
||||
+5
-14
@@ -1,6 +1,5 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 2005 - 2007, Daniel Stenberg
|
||||
/* Copyright (C) 2005 - 2010, Daniel Stenberg
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted, provided
|
||||
@@ -15,15 +14,11 @@
|
||||
|
||||
#include "ares_setup.h"
|
||||
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
int ares_getsock(ares_channel channel,
|
||||
int *s,
|
||||
ares_socket_t *socks,
|
||||
int numsocks) /* size of the 'socks' array */
|
||||
{
|
||||
struct server_state *server;
|
||||
@@ -32,14 +27,10 @@ int ares_getsock(ares_channel channel,
|
||||
int bitmap = 0;
|
||||
unsigned int setbits = 0xffffffff;
|
||||
|
||||
ares_socket_t *socks = (ares_socket_t *)s;
|
||||
|
||||
/* Are there any active queries? */
|
||||
int active_queries = !ares__is_list_empty(&(channel->all_queries));
|
||||
|
||||
for (i = 0;
|
||||
(i < channel->nservers) && (sockindex < ARES_GETSOCK_MAXNUM);
|
||||
i++)
|
||||
for (i = 0; i < channel->nservers; i++)
|
||||
{
|
||||
server = &channel->servers[i];
|
||||
/* We only need to register interest in UDP sockets if we have
|
||||
@@ -47,7 +38,7 @@ int ares_getsock(ares_channel channel,
|
||||
*/
|
||||
if (active_queries && server->udp_socket != ARES_SOCKET_BAD)
|
||||
{
|
||||
if(sockindex >= numsocks)
|
||||
if(sockindex >= numsocks || sockindex >= ARES_GETSOCK_MAXNUM)
|
||||
break;
|
||||
socks[sockindex] = server->udp_socket;
|
||||
bitmap |= ARES_GETSOCK_READABLE(setbits, sockindex);
|
||||
@@ -59,7 +50,7 @@ int ares_getsock(ares_channel channel,
|
||||
*/
|
||||
if (server->tcp_socket != ARES_SOCKET_BAD)
|
||||
{
|
||||
if(sockindex >= numsocks)
|
||||
if(sockindex >= numsocks || sockindex >= ARES_GETSOCK_MAXNUM)
|
||||
break;
|
||||
socks[sockindex] = server->tcp_socket;
|
||||
bitmap |= ARES_GETSOCK_READABLE(setbits, sockindex);
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
#ifndef __ARES_INET_NET_PTON_H
|
||||
#define __ARES_INET_NET_PTON_H
|
||||
#ifndef HEADER_CARES_INET_NET_PTON_H
|
||||
#define HEADER_CARES_INET_NET_PTON_H
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 2005 by Daniel Stenberg
|
||||
/* Copyright (C) 2005-2013 by Daniel Stenberg et al
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose and without
|
||||
@@ -18,15 +16,10 @@
|
||||
* without express or implied warranty.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_INET_PTON
|
||||
#define ares_inet_pton(x,y,z) inet_pton(x,y,z)
|
||||
#else
|
||||
int ares_inet_pton(int af, const char *src, void *dst);
|
||||
#endif
|
||||
#if defined(HAVE_INET_NET_PTON) && defined(HAVE_INET_NET_PTON_IPV6)
|
||||
#ifdef HAVE_INET_NET_PTON
|
||||
#define ares_inet_net_pton(w,x,y,z) inet_net_pton(w,x,y,z)
|
||||
#else
|
||||
int ares_inet_net_pton(int af, const char *src, void *dst, size_t size);
|
||||
#endif
|
||||
|
||||
#endif /* __ARES_INET_NET_PTON_H */
|
||||
#endif /* HEADER_CARES_INET_NET_PTON_H */
|
||||
@@ -0,0 +1,47 @@
|
||||
.\"
|
||||
.\" Copyright (C) 2013 by Daniel Stenberg
|
||||
.\"
|
||||
.\" Permission to use, copy, modify, and distribute this
|
||||
.\" software and its documentation for any purpose and without
|
||||
.\" fee is hereby granted, provided that the above copyright
|
||||
.\" notice appear in all copies and that both that copyright
|
||||
.\" notice and this permission notice appear in supporting
|
||||
.\" documentation, and that the name of M.I.T. not be used in
|
||||
.\" advertising or publicity pertaining to distribution of the
|
||||
.\" software without specific, written prior permission.
|
||||
.\" M.I.T. makes no representations about the suitability of
|
||||
.\" this software for any purpose. It is provided "as is"
|
||||
.\" without express or implied warranty.
|
||||
.\"
|
||||
.TH ARES_INET_NTOP 3 "17 Feb 2013"
|
||||
.SH NAME
|
||||
ares_inet_ntop \- convert a network format address to presentation format
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.B #include <ares.h>
|
||||
.PP
|
||||
.B const char *
|
||||
.B ares_inet_ntop(int af, const void *src, char *dst, ares_socklen_t size);
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
This is a portable version with the identical functionality of the commonly
|
||||
available \fIinet_ntop\fP.
|
||||
|
||||
The ares_inet_ntop() function converts a numeric address into a text string
|
||||
suitable for presentation. The \fBaf\fP argument shall specify the family of
|
||||
the address. This can be AF_INET or AF_INET6. The \fBsrc\fP argument points
|
||||
to a buffer holding an IPv4 address if the af argument is AF_INET, or an IPv6
|
||||
address if the af argument is AF_INET6; the address must be in network byte
|
||||
order. The \fBdst\fP argument points to a buffer where the function stores the
|
||||
resulting text string; it shall not be NULL. The \fBsize\fP argument specifies
|
||||
the size of this buffer, which shall be large enough to hold the text string
|
||||
(INET_ADDRSTRLEN (16) characters for IPv4, INET6_ADDRSTRLEN (46) characters
|
||||
for IPv6).
|
||||
.SH SEE ALSO
|
||||
.BR ares_init(3),
|
||||
.BR ares_inet_pton(3)
|
||||
.SH AVAILABILITY
|
||||
made properly publicly available in c-ares for real in version 1.10.0
|
||||
.SH AUTHOR
|
||||
Daniel Stenberg
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
.\"
|
||||
.\" Copyright (C) 2013 by Daniel Stenberg
|
||||
.\"
|
||||
.\" Permission to use, copy, modify, and distribute this
|
||||
.\" software and its documentation for any purpose and without
|
||||
.\" fee is hereby granted, provided that the above copyright
|
||||
.\" notice appear in all copies and that both that copyright
|
||||
.\" notice and this permission notice appear in supporting
|
||||
.\" documentation, and that the name of M.I.T. not be used in
|
||||
.\" advertising or publicity pertaining to distribution of the
|
||||
.\" software without specific, written prior permission.
|
||||
.\" M.I.T. makes no representations about the suitability of
|
||||
.\" this software for any purpose. It is provided "as is"
|
||||
.\" without express or implied warranty.
|
||||
.\"
|
||||
.TH ARES_INET_PTON 3 "17 Feb 2013"
|
||||
.SH NAME
|
||||
ares_inet_pton \- convert an IPv4 or IPv6 address from text to binary form
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.B #include <ares.h>
|
||||
.PP
|
||||
.B const char *ares_inet_pton(int af, const char *src, void *dst);
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
This is a portable version with the identical functionality of the commonly
|
||||
available \fIinet_pton\fP.
|
||||
|
||||
The ares_inet_pton() function converts the address in its standard text
|
||||
presentation form into its numeric binary form. The \fBaf\fP argument shall
|
||||
specify the family of the address. The AF_INET and AF_INET6 address families
|
||||
shall be supported. The \fBsrc\fP argument points to the string being passed
|
||||
in. The \fBdst\fP argument points to a buffer into which the function stores
|
||||
the numeric address; this shall be large enough to hold the numeric address
|
||||
(32 bits for AF_INET, 128 bits for AF_INET6).
|
||||
.SH SEE ALSO
|
||||
.BR ares_init(3),
|
||||
.BR ares_inet_ntop(3)
|
||||
.SH AVAILABILITY
|
||||
made properly publicly available in c-ares for real in version 1.10.0
|
||||
.SH AUTHOR
|
||||
Daniel Stenberg
|
||||
|
||||
+39
-157
@@ -1,7 +1,6 @@
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.\" Copyright (C) 2004-2009 by Daniel Stenberg
|
||||
.\" Copyright (C) 2004-2010 by Daniel Stenberg
|
||||
.\"
|
||||
.\" Permission to use, copy, modify, and distribute this
|
||||
.\" software and its documentation for any purpose and without
|
||||
@@ -15,166 +14,26 @@
|
||||
.\" this software for any purpose. It is provided "as is"
|
||||
.\" without express or implied warranty.
|
||||
.\"
|
||||
.TH ARES_INIT 3 "26 May 2009"
|
||||
.TH ARES_INIT 3 "5 March 2010"
|
||||
.SH NAME
|
||||
ares_init, ares_init_options \- Initialize a resolver channel
|
||||
ares_init \- Initialize a resolver channel
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.B #include <ares.h>
|
||||
.PP
|
||||
.B int ares_init(ares_channel *\fIchannelptr\fP)
|
||||
.B int ares_init_options(ares_channel *\fIchannelptr\fP,
|
||||
.B struct ares_options *\fIoptions\fP, int \fIoptmask\fP)
|
||||
.PP
|
||||
.B cc file.c -lcares
|
||||
#include <ares.h>
|
||||
|
||||
int ares_init(ares_channel *\fIchannelptr\fP)
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The \fBares_init\fP function initializes a communications channel for name
|
||||
service lookups. If it returns successfully, \fBares_init\fP will set the
|
||||
The \fBares_init(3)\fP function initializes a communications channel for name
|
||||
service lookups. If it returns successfully, \fBares_init(3)\fP will set the
|
||||
variable pointed to by \fIchannelptr\fP to a handle used to identify the name
|
||||
service channel. The caller should invoke
|
||||
.BR ares_destroy (3)
|
||||
on the handle when the channel is no longer needed.
|
||||
.PP
|
||||
The \fBares_init_options\fP function also initializes a name service channel,
|
||||
with additional options useful for applications requiring more control over
|
||||
name service configuration. The \fIoptmask\fP parameter specifies which fields
|
||||
in the structure pointed to by \fIoptions\fP are set, as follows:
|
||||
.TP 18
|
||||
.B ARES_OPT_FLAGS
|
||||
.B int \fIflags\fP;
|
||||
.br
|
||||
Flags controlling the behavior of the resolver. See below for a
|
||||
description of possible flag values.
|
||||
.TP 18
|
||||
.B ARES_OPT_TIMEOUT
|
||||
.B int \fItimeout\fP;
|
||||
.br
|
||||
The number of seconds each name server is given to respond to a query on the
|
||||
first try. (After the first try, the timeout algorithm becomes more
|
||||
complicated, but scales linearly with the value of \fItimeout\fP.) The
|
||||
default is five seconds. This option is being deprecated by
|
||||
\fIARES_OPT_TIMEOUTMS\fP starting in c-ares 1.5.2.
|
||||
.TP 18
|
||||
.B ARES_OPT_TIMEOUTMS
|
||||
.B int \fItimeout\fP;
|
||||
.br
|
||||
The number of milliseconds each name server is given to respond to a query on
|
||||
the first try. (After the first try, the timeout algorithm becomes more
|
||||
complicated, but scales linearly with the value of \fItimeout\fP.) The
|
||||
default is five seconds. Note that this option is specified with the same
|
||||
struct field as the former \fIARES_OPT_TIMEOUT\fP, it is but the option bits
|
||||
that tell c-ares how to interpret the number. This option was added in c-ares
|
||||
1.5.2.
|
||||
.TP 18
|
||||
.B ARES_OPT_TRIES
|
||||
.B int \fItries\fP;
|
||||
.br
|
||||
The number of tries the resolver will try contacting each name server
|
||||
before giving up. The default is four tries.
|
||||
.TP 18
|
||||
.B ARES_OPT_NDOTS
|
||||
.B int \fIndots\fP;
|
||||
.br
|
||||
The number of dots which must be present in a domain name for it to be
|
||||
queried for "as is" prior to querying for it with the default domain
|
||||
extensions appended. The default value is 1 unless set otherwise by
|
||||
resolv.conf or the RES_OPTIONS environment variable.
|
||||
.TP 18
|
||||
.B ARES_OPT_PORT
|
||||
.B unsigned short \fIport\fP;
|
||||
.br
|
||||
The port to use for queries (both TCP and UDP), in network byte order.
|
||||
The default value is 53 (in network byte order), the standard name
|
||||
service port.
|
||||
.TP 18
|
||||
.B ARES_OPT_SERVERS
|
||||
.B struct in_addr *\fIservers\fP;
|
||||
.br
|
||||
.B int \fInservers\fP;
|
||||
.br
|
||||
The list of servers to contact, instead of the servers specified in
|
||||
resolv.conf or the local named.
|
||||
.TP 18
|
||||
.B ARES_OPT_DOMAINS
|
||||
.B char **\fIdomains\fP;
|
||||
.br
|
||||
.B int \fIndomains\fP;
|
||||
.br
|
||||
The domains to search, instead of the domains specified in resolv.conf
|
||||
or the domain derived from the kernel hostname variable.
|
||||
.TP 18
|
||||
.B ARES_OPT_LOOKUPS
|
||||
.B char *\fIlookups\fP;
|
||||
.br
|
||||
The lookups to perform for host queries.
|
||||
.I lookups
|
||||
should be set to a string of the characters "b" or "f", where "b"
|
||||
indicates a DNS lookup and "f" indicates a lookup in the hosts file.
|
||||
.TP 18
|
||||
.B ARES_OPT_SOCK_STATE_CB
|
||||
.B void (*\fIsock_state_cb\fP)(void *data, int s, int read, int write);
|
||||
.br
|
||||
.B void *\fIsock_state_cb_data\fP;
|
||||
.br
|
||||
A callback function to be invoked when a socket changes state.
|
||||
.I s
|
||||
will be passed the socket whose state has changed;
|
||||
.I read
|
||||
will be set to true if the socket should listen for read events, and
|
||||
.I write
|
||||
will be set to true if the socket should listen for write events.
|
||||
The value of
|
||||
.I sock_state_cb_data
|
||||
will be passed as the
|
||||
.I data
|
||||
argument.
|
||||
.PP
|
||||
The
|
||||
.I flags
|
||||
field should be the bitwise or of some subset of the following values:
|
||||
.TP 23
|
||||
.B ARES_FLAG_USEVC
|
||||
Always use TCP queries (the "virtual circuit") instead of UDP
|
||||
queries. Normally, TCP is only used if a UDP query yields a truncated
|
||||
result.
|
||||
.TP 23
|
||||
.B ARES_FLAG_PRIMARY
|
||||
Only query the first server in the list of servers to query.
|
||||
.TP 23
|
||||
.B ARES_FLAG_IGNTC
|
||||
If a truncated response to a UDP query is received, do not fall back
|
||||
to TCP; simply continue on with the truncated response.
|
||||
.TP 23
|
||||
.B ARES_FLAG_NORECURSE
|
||||
Do not set the "recursion desired" bit on outgoing queries, so that the name
|
||||
server being contacted will not try to fetch the answer from other servers if
|
||||
it doesn't know the answer locally. Be aware that ares will not do the
|
||||
recursion for you. Recursion must be handled by the application calling ares
|
||||
if \fIARES_FLAG_NORECURSE\fP is set.
|
||||
.TP 23
|
||||
.B ARES_FLAG_STAYOPEN
|
||||
Do not close communications sockets when the number of active queries
|
||||
drops to zero.
|
||||
.TP 23
|
||||
.B ARES_FLAG_NOSEARCH
|
||||
Do not use the default search domains; only query hostnames as-is or
|
||||
as aliases.
|
||||
.TP 23
|
||||
.B ARES_FLAG_NOALIASES
|
||||
Do not honor the HOSTALIASES environment variable, which normally
|
||||
specifies a file of hostname translations.
|
||||
.TP 23
|
||||
.B ARES_FLAG_NOCHECKRESP
|
||||
Do not discard responses with the SERVFAIL, NOTIMP, or REFUSED
|
||||
response code or responses whose questions don't match the questions
|
||||
in the request. Primarily useful for writing clients which might be
|
||||
used to test or debug name servers.
|
||||
service channel. The caller should invoke \fIares_destroy(3)\fP on the handle
|
||||
when the channel is no longer needed.
|
||||
|
||||
The \fIares_init_options(3)\fP function is provide to offer more init
|
||||
alternatives.
|
||||
.SH RETURN VALUES
|
||||
.I ares_init
|
||||
or
|
||||
.I ares_init_options
|
||||
can return any of the following values:
|
||||
\fIares_init(3)\fP can return any of the following values:
|
||||
.TP 14
|
||||
.B ARES_SUCCESS
|
||||
Initialization succeeded.
|
||||
@@ -187,13 +46,36 @@ The process's available memory was exhausted.
|
||||
.TP 14
|
||||
.B ARES_ENOTINITIALIZED
|
||||
c-ares library initialization not yet performed.
|
||||
.SH NOTES
|
||||
When initializing from
|
||||
.B /etc/resolv.conf,
|
||||
.BR ares_init (3)
|
||||
reads the
|
||||
.I domain
|
||||
and
|
||||
.I search
|
||||
directives to allow lookups of short names relative to the domains
|
||||
specified. The
|
||||
.I domain
|
||||
and
|
||||
.I search
|
||||
directives override one another. If more that one instance of either
|
||||
.I domain
|
||||
or
|
||||
.I search
|
||||
directives is specified, the last occurrence wins. For more information,
|
||||
please see the
|
||||
.BR resolv.conf (5)
|
||||
manual page.
|
||||
.SH SEE ALSO
|
||||
.BR ares_init_options(3),
|
||||
.BR ares_destroy(3),
|
||||
.BR ares_dup(3),
|
||||
.BR ares_library_init(3)
|
||||
.BR ares_library_init(3),
|
||||
.BR ares_set_servers(3)
|
||||
.SH AUTHOR
|
||||
Greg Hudson, MIT Information Systems
|
||||
.br
|
||||
Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.br
|
||||
Copyright (C) 2004-2009 by Daniel Stenberg.
|
||||
Copyright (C) 2004-2010 by Daniel Stenberg.
|
||||
|
||||
+1021
-455
File diff suppressed because it is too large
Load Diff
+262
-2
@@ -1,2 +1,262 @@
|
||||
.so man3/ares_init.3
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.\" Copyright (C) 2004-2010 by Daniel Stenberg
|
||||
.\"
|
||||
.\" Permission to use, copy, modify, and distribute this
|
||||
.\" software and its documentation for any purpose and without
|
||||
.\" fee is hereby granted, provided that the above copyright
|
||||
.\" notice appear in all copies and that both that copyright
|
||||
.\" notice and this permission notice appear in supporting
|
||||
.\" documentation, and that the name of M.I.T. not be used in
|
||||
.\" advertising or publicity pertaining to distribution of the
|
||||
.\" software without specific, written prior permission.
|
||||
.\" M.I.T. makes no representations about the suitability of
|
||||
.\" this software for any purpose. It is provided "as is"
|
||||
.\" without express or implied warranty.
|
||||
.\"
|
||||
.TH ARES_INIT 3 "5 March 2010"
|
||||
.SH NAME
|
||||
ares_init_options \- Initialize a resolver channel
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
#include <ares.h>
|
||||
|
||||
int ares_init_options(ares_channel *\fIchannelptr\fP,
|
||||
struct ares_options *\fIoptions\fP,
|
||||
int \fIoptmask\fP)
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The \fBares_init_options(3)\fP function initializes a communications channel
|
||||
for name service lookups. If it returns successfully,
|
||||
\fBares_init_options(3)\fP will set the variable pointed to by
|
||||
\fIchannelptr\fP to a handle used to identify the name service channel. The
|
||||
caller should invoke \fIares_destroy(3)\fP on the handle when the channel is
|
||||
no longer needed.
|
||||
|
||||
The \fIoptmask\fP parameter generally specifies which fields in the structure pointed to
|
||||
by \fIoptions\fP are set, as follows:
|
||||
.TP 18
|
||||
.B ARES_OPT_FLAGS
|
||||
.B int \fIflags\fP;
|
||||
.br
|
||||
Flags controlling the behavior of the resolver. See below for a
|
||||
description of possible flag values.
|
||||
.TP 18
|
||||
.B ARES_OPT_TIMEOUT
|
||||
.B int \fItimeout\fP;
|
||||
.br
|
||||
The number of seconds each name server is given to respond to a query on the
|
||||
first try. (After the first try, the timeout algorithm becomes more
|
||||
complicated, but scales linearly with the value of \fItimeout\fP.) The
|
||||
default is five seconds. This option is being deprecated by
|
||||
\fIARES_OPT_TIMEOUTMS\fP starting in c-ares 1.5.2.
|
||||
.TP 18
|
||||
.B ARES_OPT_TIMEOUTMS
|
||||
.B int \fItimeout\fP;
|
||||
.br
|
||||
The number of milliseconds each name server is given to respond to a query on
|
||||
the first try. (After the first try, the timeout algorithm becomes more
|
||||
complicated, but scales linearly with the value of \fItimeout\fP.) The
|
||||
default is five seconds. Note that this option is specified with the same
|
||||
struct field as the former \fIARES_OPT_TIMEOUT\fP, it is but the option bits
|
||||
that tell c-ares how to interpret the number. This option was added in c-ares
|
||||
1.5.2.
|
||||
.TP 18
|
||||
.B ARES_OPT_TRIES
|
||||
.B int \fItries\fP;
|
||||
.br
|
||||
The number of tries the resolver will try contacting each name server
|
||||
before giving up. The default is four tries.
|
||||
.TP 18
|
||||
.B ARES_OPT_NDOTS
|
||||
.B int \fIndots\fP;
|
||||
.br
|
||||
The number of dots which must be present in a domain name for it to be
|
||||
queried for "as is" prior to querying for it with the default domain
|
||||
extensions appended. The default value is 1 unless set otherwise by
|
||||
resolv.conf or the RES_OPTIONS environment variable.
|
||||
.TP 18
|
||||
.B ARES_OPT_UDP_PORT
|
||||
.B unsigned short \fIudp_port\fP;
|
||||
.br
|
||||
The port to use for queries over UDP, in network byte order.
|
||||
The default value is 53 (in network byte order), the standard name
|
||||
service port.
|
||||
.TP 18
|
||||
.B ARES_OPT_TCP_PORT
|
||||
.B unsigned short \fItcp_port\fP;
|
||||
.br
|
||||
The port to use for queries over TCP, in network byte order.
|
||||
The default value is 53 (in network byte order), the standard name
|
||||
service port.
|
||||
.TP 18
|
||||
.B ARES_OPT_SERVERS
|
||||
.B struct in_addr *\fIservers\fP;
|
||||
.br
|
||||
.B int \fInservers\fP;
|
||||
.br
|
||||
The list of IPv4 servers to contact, instead of the servers specified in
|
||||
resolv.conf or the local named. In order to allow specification of either
|
||||
IPv4 or IPv6 name servers, the
|
||||
.BR ares_set_servers(3)
|
||||
function must be used instead.
|
||||
.TP 18
|
||||
.B ARES_OPT_DOMAINS
|
||||
.B char **\fIdomains\fP;
|
||||
.br
|
||||
.B int \fIndomains\fP;
|
||||
.br
|
||||
The domains to search, instead of the domains specified in resolv.conf
|
||||
or the domain derived from the kernel hostname variable.
|
||||
.TP 18
|
||||
.B ARES_OPT_LOOKUPS
|
||||
.B char *\fIlookups\fP;
|
||||
.br
|
||||
The lookups to perform for host queries.
|
||||
.I lookups
|
||||
should be set to a string of the characters "b" or "f", where "b"
|
||||
indicates a DNS lookup and "f" indicates a lookup in the hosts file.
|
||||
.TP 18
|
||||
.B ARES_OPT_SOCK_STATE_CB
|
||||
.B void (*\fIsock_state_cb\fP)(void *data, int s, int read, int write);
|
||||
.br
|
||||
.B void *\fIsock_state_cb_data\fP;
|
||||
.br
|
||||
A callback function to be invoked when a socket changes state.
|
||||
.I s
|
||||
will be passed the socket whose state has changed;
|
||||
.I read
|
||||
will be set to true if the socket should listen for read events, and
|
||||
.I write
|
||||
will be set to true if the socket should listen for write events.
|
||||
The value of
|
||||
.I sock_state_cb_data
|
||||
will be passed as the
|
||||
.I data
|
||||
argument.
|
||||
.TP 18
|
||||
.B ARES_OPT_SORTLIST
|
||||
.B struct apattern *\fIsortlist\fP;
|
||||
.br
|
||||
.B int \fInsort\fP;
|
||||
.br
|
||||
A list of IP address ranges that specifies the order of preference that
|
||||
results from \fIares_gethostbyname\fP should be returned in. Note that
|
||||
this can only be used with a sortlist retrieved via
|
||||
\fBares_save_options(3)\fP (because
|
||||
.B struct apattern
|
||||
is opaque); to set a fresh sort list, use \fBares_set_sortlist(3)\fP.
|
||||
.TP 18
|
||||
.B ARES_OPT_SOCK_SNDBUF
|
||||
.B int \fIsocket_send_buffer_size\fP;
|
||||
.br
|
||||
The send buffer size to set for the socket.
|
||||
.TP 18
|
||||
.B ARES_OPT_SOCK_RCVBUF
|
||||
.B int \fIsocket_receive_buffer_size\fP;
|
||||
.br
|
||||
The receive buffer size to set for the socket.
|
||||
.TP 18
|
||||
.B ARES_OPT_EDNSPSZ
|
||||
.B int \fIednspsz\fP;
|
||||
.br
|
||||
The message size to be advertized in EDNS; only takes effect if the
|
||||
.B ARES_FLAG_EDNS
|
||||
flag is set.
|
||||
.br
|
||||
.PP
|
||||
The \fIoptmask\fP parameter also includes options without a corresponding
|
||||
field in the
|
||||
.B ares_options
|
||||
structure, as follows:
|
||||
.TP 23
|
||||
.B ARES_OPT_ROTATE
|
||||
Perform round-robin selection of the nameservers configured for the channel
|
||||
for each resolution.
|
||||
.TP 23
|
||||
.B ARES_OPT_NOROTATE
|
||||
Do not perform round-robin nameserver selection; always use the list of
|
||||
nameservers in the same order.
|
||||
.PP
|
||||
The
|
||||
.I flags
|
||||
field should be the bitwise or of some subset of the following values:
|
||||
.TP 23
|
||||
.B ARES_FLAG_USEVC
|
||||
Always use TCP queries (the "virtual circuit") instead of UDP
|
||||
queries. Normally, TCP is only used if a UDP query yields a truncated
|
||||
result.
|
||||
.TP 23
|
||||
.B ARES_FLAG_PRIMARY
|
||||
Only query the first server in the list of servers to query.
|
||||
.TP 23
|
||||
.B ARES_FLAG_IGNTC
|
||||
If a truncated response to a UDP query is received, do not fall back
|
||||
to TCP; simply continue on with the truncated response.
|
||||
.TP 23
|
||||
.B ARES_FLAG_NORECURSE
|
||||
Do not set the "recursion desired" bit on outgoing queries, so that the name
|
||||
server being contacted will not try to fetch the answer from other servers if
|
||||
it doesn't know the answer locally. Be aware that ares will not do the
|
||||
recursion for you. Recursion must be handled by the application calling ares
|
||||
if \fIARES_FLAG_NORECURSE\fP is set.
|
||||
.TP 23
|
||||
.B ARES_FLAG_STAYOPEN
|
||||
Do not close communications sockets when the number of active queries
|
||||
drops to zero.
|
||||
.TP 23
|
||||
.B ARES_FLAG_NOSEARCH
|
||||
Do not use the default search domains; only query hostnames as-is or
|
||||
as aliases.
|
||||
.TP 23
|
||||
.B ARES_FLAG_NOALIASES
|
||||
Do not honor the HOSTALIASES environment variable, which normally
|
||||
specifies a file of hostname translations.
|
||||
.TP 23
|
||||
.B ARES_FLAG_NOCHECKRESP
|
||||
Do not discard responses with the SERVFAIL, NOTIMP, or REFUSED
|
||||
response code or responses whose questions don't match the questions
|
||||
in the request. Primarily useful for writing clients which might be
|
||||
used to test or debug name servers.
|
||||
.TP 23
|
||||
.B ARES_FLAG_EDNS
|
||||
Include an EDNS pseudo-resource record (RFC 2671) in generated requests.
|
||||
.SH RETURN VALUES
|
||||
\fBares_init_options(3)\fP can return any of the following values:
|
||||
.TP 14
|
||||
.B ARES_SUCCESS
|
||||
Initialization succeeded.
|
||||
.TP 14
|
||||
.B ARES_EFILE
|
||||
A configuration file could not be read.
|
||||
.TP 14
|
||||
.B ARES_ENOMEM
|
||||
The process's available memory was exhausted.
|
||||
.TP 14
|
||||
.B ARES_ENOTINITIALIZED
|
||||
c-ares library initialization not yet performed.
|
||||
.SH NOTES
|
||||
When initializing from
|
||||
.B /etc/resolv.conf,
|
||||
\fBares_init_options(3)\fP reads the \fIdomain\fP and \fIsearch\fP directives
|
||||
to allow lookups of short names relative to the domains specified. The
|
||||
\fIdomain\fP and \fIsearch\fP directives override one another. If more that
|
||||
one instance of either \fIdomain\fP or \fIsearch\fP directives is specified,
|
||||
the last occurrence wins. For more information, please see the
|
||||
.BR resolv.conf (5)
|
||||
manual page.
|
||||
.SH SEE ALSO
|
||||
.BR ares_init(3),
|
||||
.BR ares_destroy(3),
|
||||
.BR ares_dup(3),
|
||||
.BR ares_library_init(3),
|
||||
.BR ares_save_options(3),
|
||||
.BR ares_set_servers(3),
|
||||
.BR ares_set_sortlist(3)
|
||||
.SH AUTHOR
|
||||
Greg Hudson, MIT Information Systems
|
||||
.br
|
||||
Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.br
|
||||
Copyright (C) 2004-2010 by Daniel Stenberg.
|
||||
|
||||
|
||||
+221
@@ -0,0 +1,221 @@
|
||||
#ifndef HEADER_CARES_IPHLPAPI_H
|
||||
#define HEADER_CARES_IPHLPAPI_H
|
||||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
* Copyright (C) 2004 - 2011 by Daniel Stenberg et al
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose and without
|
||||
* fee is hereby granted, provided that the above copyright
|
||||
* notice appear in all copies and that both that copyright
|
||||
* notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of M.I.T. not be used in
|
||||
* advertising or publicity pertaining to distribution of the
|
||||
* software without specific, written prior permission.
|
||||
* M.I.T. makes no representations about the suitability of
|
||||
* this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*/
|
||||
|
||||
#if defined(USE_WINSOCK)
|
||||
|
||||
#ifndef INET_ADDRSTRLEN
|
||||
#define INET_ADDRSTRLEN 22
|
||||
#endif
|
||||
|
||||
#ifndef INET6_ADDRSTRLEN
|
||||
#define INET6_ADDRSTRLEN 65
|
||||
#endif
|
||||
|
||||
/* ---------------------------------- */
|
||||
#if !defined(_WS2DEF_) && \
|
||||
!defined(__CSADDR_DEFINED__) && \
|
||||
!defined(__CSADDR_T_DEFINED)
|
||||
/* ---------------------------------- */
|
||||
|
||||
typedef struct _SOCKET_ADDRESS {
|
||||
LPSOCKADDR lpSockaddr;
|
||||
INT iSockaddrLength;
|
||||
} SOCKET_ADDRESS, *PSOCKET_ADDRESS;
|
||||
|
||||
typedef struct _CSADDR_INFO {
|
||||
SOCKET_ADDRESS LocalAddr;
|
||||
SOCKET_ADDRESS RemoteAddr;
|
||||
INT iSocketType;
|
||||
INT iProtocol;
|
||||
} CSADDR_INFO, *PCSADDR_INFO;
|
||||
|
||||
/* --------------------------------- */
|
||||
#endif /* ! _WS2DEF_ && \ */
|
||||
/* ! __CSADDR_DEFINED__ && \ */
|
||||
/* ! __CSADDR_T_DEFINED */
|
||||
/* --------------------------------- */
|
||||
|
||||
/* ------------------------------- */
|
||||
#if !defined(IP_ADAPTER_DDNS_ENABLED)
|
||||
/* ------------------------------- */
|
||||
|
||||
#define IP_ADAPTER_ADDRESS_DNS_ELIGIBLE 0x0001
|
||||
#define IP_ADAPTER_ADDRESS_TRANSIENT 0x0002
|
||||
|
||||
#define IP_ADAPTER_DDNS_ENABLED 0x0001
|
||||
#define IP_ADAPTER_REGISTER_ADAPTER_SUFFIX 0x0002
|
||||
#define IP_ADAPTER_DHCP_ENABLED 0x0004
|
||||
#define IP_ADAPTER_RECEIVE_ONLY 0x0008
|
||||
#define IP_ADAPTER_NO_MULTICAST 0x0010
|
||||
#define IP_ADAPTER_IPV6_OTHER_STATEFUL_CONFIG 0x0020
|
||||
|
||||
#define GAA_FLAG_SKIP_UNICAST 0x0001
|
||||
#define GAA_FLAG_SKIP_ANYCAST 0x0002
|
||||
#define GAA_FLAG_SKIP_MULTICAST 0x0004
|
||||
#define GAA_FLAG_SKIP_DNS_SERVER 0x0008
|
||||
#define GAA_FLAG_INCLUDE_PREFIX 0x0010
|
||||
#define GAA_FLAG_SKIP_FRIENDLY_NAME 0x0020
|
||||
|
||||
typedef enum {
|
||||
IpPrefixOriginOther = 0,
|
||||
IpPrefixOriginManual,
|
||||
IpPrefixOriginWellKnown,
|
||||
IpPrefixOriginDhcp,
|
||||
IpPrefixOriginRouterAdvertisement
|
||||
} IP_PREFIX_ORIGIN;
|
||||
|
||||
typedef enum {
|
||||
IpSuffixOriginOther = 0,
|
||||
IpSuffixOriginManual,
|
||||
IpSuffixOriginWellKnown,
|
||||
IpSuffixOriginDhcp,
|
||||
IpSuffixOriginLinkLayerAddress,
|
||||
IpSuffixOriginRandom
|
||||
} IP_SUFFIX_ORIGIN;
|
||||
|
||||
typedef enum {
|
||||
IpDadStateInvalid = 0,
|
||||
IpDadStateTentative,
|
||||
IpDadStateDuplicate,
|
||||
IpDadStateDeprecated,
|
||||
IpDadStatePreferred
|
||||
} IP_DAD_STATE;
|
||||
|
||||
typedef enum {
|
||||
IfOperStatusUp = 1,
|
||||
IfOperStatusDown,
|
||||
IfOperStatusTesting,
|
||||
IfOperStatusUnknown,
|
||||
IfOperStatusDormant,
|
||||
IfOperStatusNotPresent,
|
||||
IfOperStatusLowerLayerDown
|
||||
} IF_OPER_STATUS;
|
||||
|
||||
typedef enum {
|
||||
ScopeLevelInterface = 0x0001,
|
||||
ScopeLevelLink = 0x0002,
|
||||
ScopeLevelSubnet = 0x0003,
|
||||
ScopeLevelAdmin = 0x0004,
|
||||
ScopeLevelSite = 0x0005,
|
||||
ScopeLevelOrganization = 0x0008,
|
||||
ScopeLevelGlobal = 0x000E
|
||||
} SCOPE_LEVEL;
|
||||
|
||||
typedef struct _IP_ADAPTER_UNICAST_ADDRESS {
|
||||
union {
|
||||
ULONGLONG Alignment;
|
||||
struct {
|
||||
ULONG Length;
|
||||
DWORD Flags;
|
||||
} s;
|
||||
} u;
|
||||
struct _IP_ADAPTER_UNICAST_ADDRESS *Next;
|
||||
SOCKET_ADDRESS Address;
|
||||
IP_PREFIX_ORIGIN PrefixOrigin;
|
||||
IP_SUFFIX_ORIGIN SuffixOrigin;
|
||||
IP_DAD_STATE DadState;
|
||||
ULONG ValidLifetime;
|
||||
ULONG PreferredLifetime;
|
||||
ULONG LeaseLifetime;
|
||||
} IP_ADAPTER_UNICAST_ADDRESS, *PIP_ADAPTER_UNICAST_ADDRESS;
|
||||
|
||||
typedef struct _IP_ADAPTER_ANYCAST_ADDRESS {
|
||||
union {
|
||||
ULONGLONG Alignment;
|
||||
struct {
|
||||
ULONG Length;
|
||||
DWORD Flags;
|
||||
} s;
|
||||
} u;
|
||||
struct _IP_ADAPTER_ANYCAST_ADDRESS *Next;
|
||||
SOCKET_ADDRESS Address;
|
||||
} IP_ADAPTER_ANYCAST_ADDRESS, *PIP_ADAPTER_ANYCAST_ADDRESS;
|
||||
|
||||
typedef struct _IP_ADAPTER_MULTICAST_ADDRESS {
|
||||
union {
|
||||
ULONGLONG Alignment;
|
||||
struct {
|
||||
ULONG Length;
|
||||
DWORD Flags;
|
||||
} s;
|
||||
} u;
|
||||
struct _IP_ADAPTER_MULTICAST_ADDRESS *Next;
|
||||
SOCKET_ADDRESS Address;
|
||||
} IP_ADAPTER_MULTICAST_ADDRESS, *PIP_ADAPTER_MULTICAST_ADDRESS;
|
||||
|
||||
typedef struct _IP_ADAPTER_DNS_SERVER_ADDRESS {
|
||||
union {
|
||||
ULONGLONG Alignment;
|
||||
struct {
|
||||
ULONG Length;
|
||||
DWORD Reserved;
|
||||
} s;
|
||||
} u;
|
||||
struct _IP_ADAPTER_DNS_SERVER_ADDRESS *Next;
|
||||
SOCKET_ADDRESS Address;
|
||||
} IP_ADAPTER_DNS_SERVER_ADDRESS, *PIP_ADAPTER_DNS_SERVER_ADDRESS;
|
||||
|
||||
typedef struct _IP_ADAPTER_PREFIX {
|
||||
union {
|
||||
ULONGLONG Alignment;
|
||||
struct {
|
||||
ULONG Length;
|
||||
DWORD Flags;
|
||||
} s;
|
||||
} u;
|
||||
struct _IP_ADAPTER_PREFIX *Next;
|
||||
SOCKET_ADDRESS Address;
|
||||
ULONG PrefixLength;
|
||||
} IP_ADAPTER_PREFIX, *PIP_ADAPTER_PREFIX;
|
||||
|
||||
typedef struct _IP_ADAPTER_ADDRESSES {
|
||||
union {
|
||||
ULONGLONG Alignment;
|
||||
struct {
|
||||
ULONG Length;
|
||||
DWORD IfIndex;
|
||||
} s;
|
||||
} u;
|
||||
struct _IP_ADAPTER_ADDRESSES *Next;
|
||||
PCHAR AdapterName;
|
||||
PIP_ADAPTER_UNICAST_ADDRESS FirstUnicastAddress;
|
||||
PIP_ADAPTER_ANYCAST_ADDRESS FirstAnycastAddress;
|
||||
PIP_ADAPTER_MULTICAST_ADDRESS FirstMulticastAddress;
|
||||
PIP_ADAPTER_DNS_SERVER_ADDRESS FirstDnsServerAddress;
|
||||
PWCHAR DnsSuffix;
|
||||
PWCHAR Description;
|
||||
PWCHAR FriendlyName;
|
||||
BYTE PhysicalAddress[MAX_ADAPTER_ADDRESS_LENGTH];
|
||||
DWORD PhysicalAddressLength;
|
||||
DWORD Flags;
|
||||
DWORD Mtu;
|
||||
DWORD IfType;
|
||||
IF_OPER_STATUS OperStatus;
|
||||
DWORD Ipv6IfIndex;
|
||||
DWORD ZoneIndices[16];
|
||||
PIP_ADAPTER_PREFIX FirstPrefix;
|
||||
} IP_ADAPTER_ADDRESSES, *PIP_ADAPTER_ADDRESSES;
|
||||
|
||||
/* -------------------------------- */
|
||||
#endif /* ! IP_ADAPTER_DDNS_ENABLED */
|
||||
/* -------------------------------- */
|
||||
|
||||
#endif /* USE_WINSOCK */
|
||||
|
||||
#endif /* HEADER_CARES_IPHLPAPI_H */
|
||||
+12
-18
@@ -1,4 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 2005 by Dominick Meglio
|
||||
*
|
||||
@@ -22,23 +21,14 @@
|
||||
#define PF_INET6 AF_INET6
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_STRUCT_IN6_ADDR) && !defined(s6_addr)
|
||||
struct in6_addr {
|
||||
union {
|
||||
unsigned char _S6_u8[16];
|
||||
} _S6_un;
|
||||
};
|
||||
#define s6_addr _S6_un._S6_u8
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRUCT_SOCKADDR_IN6
|
||||
struct sockaddr_in6
|
||||
{
|
||||
unsigned short sin6_family;
|
||||
unsigned short sin6_port;
|
||||
unsigned long sin6_flowinfo;
|
||||
struct in6_addr sin6_addr;
|
||||
unsigned int sin6_scope_id;
|
||||
unsigned short sin6_family;
|
||||
unsigned short sin6_port;
|
||||
unsigned long sin6_flowinfo;
|
||||
struct ares_in6_addr sin6_addr;
|
||||
unsigned int sin6_scope_id;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -57,16 +47,16 @@ struct addrinfo
|
||||
#endif
|
||||
|
||||
#ifndef NS_IN6ADDRSZ
|
||||
#if SIZEOF_STRUCT_IN6_ADDR == 0
|
||||
#ifndef HAVE_STRUCT_IN6_ADDR
|
||||
/* We cannot have it set to zero, so we pick a fixed value here */
|
||||
#define NS_IN6ADDRSZ 16
|
||||
#else
|
||||
#define NS_IN6ADDRSZ SIZEOF_STRUCT_IN6_ADDR
|
||||
#define NS_IN6ADDRSZ sizeof(struct in6_addr)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef NS_INADDRSZ
|
||||
#define NS_INADDRSZ SIZEOF_STRUCT_IN_ADDR
|
||||
#define NS_INADDRSZ sizeof(struct in_addr)
|
||||
#endif
|
||||
|
||||
#ifndef NS_INT16SZ
|
||||
@@ -81,4 +71,8 @@ struct addrinfo
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Defined in inet_net_pton.c for no particular reason. */
|
||||
extern const struct ares_in6_addr ares_in6addr_any; /* :: */
|
||||
|
||||
|
||||
#endif /* ARES_IPV6_H */
|
||||
|
||||
+17
-5
@@ -1,4 +1,3 @@
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.\" Copyright (C) 2004-2009 by Daniel Stenberg
|
||||
@@ -31,12 +30,20 @@ ares_library_cleanup \- c-ares library deinitialization
|
||||
The
|
||||
.B ares_library_cleanup
|
||||
function uninitializes the c-ares library, freeing all resources
|
||||
previously aquired by \fIares_library_init(3)\fP when the library
|
||||
was initialized.
|
||||
previously acquired by \fIares_library_init(3)\fP when the library
|
||||
was initialized, provided there was only one single previous call to
|
||||
\fIares_library_init(3)\fP. If there was more than one previous call to
|
||||
\fIares_library_init(3)\fP, this function uninitializes the c-ares
|
||||
library only if it is the call matching the call to
|
||||
\fIares_library_init(3)\fP which initialized the library
|
||||
(usually the very first call to \fIares_library_init(3)\fP).
|
||||
Other calls to \fIares_library_cleanup(3)\fP have no effect other than
|
||||
decrementing an internal counter.
|
||||
.PP
|
||||
This function must be called when the program using c-ares will
|
||||
no longer need any c-ares function. Once the program has called
|
||||
\fIares_library_cleanup(3)\fP it shall not make any further call to any
|
||||
\fIares_library_cleanup(3)\fP sufficiently often such that the
|
||||
library is uninitialised, it shall not make any further call to any
|
||||
c-ares function.
|
||||
.PP
|
||||
This function does not cancel any pending c-ares lookups or requests
|
||||
@@ -55,7 +62,12 @@ the DllMain function. Doing so will produce deadlocks and other problems.
|
||||
.SH AVAILABILITY
|
||||
This function was first introduced in c-ares version 1.7.0 along with the
|
||||
definition of preprocessor symbol \fICARES_HAVE_ARES_LIBRARY_CLEANUP\fP as an
|
||||
indication of the availability of this function.
|
||||
indication of the availability of this function. Reference counting in
|
||||
\fIares_library_init()\fP and \fIares_library_cleanup()\fP, which requires
|
||||
calls to the former function to match calls to the latter, is present since
|
||||
c-ares version 1.10.0.
|
||||
Earlier versions would deinitialize the library on the first call
|
||||
to \fIares_library_cleanup()\fP.
|
||||
.PP
|
||||
Since the introduction of this function, it is absolutely mandatory to call it
|
||||
for any Win32/64 program using c-ares.
|
||||
|
||||
+26
-12
@@ -1,4 +1,3 @@
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.\" Copyright (C) 2004-2009 by Daniel Stenberg
|
||||
@@ -20,11 +19,14 @@
|
||||
ares_library_init \- c-ares library initialization
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.B #include <ares.h>
|
||||
.PP
|
||||
.B int ares_library_init(int \fIflags\fP)
|
||||
.PP
|
||||
.B cc file.c -lcares
|
||||
#include <ares.h>
|
||||
|
||||
int ares_library_init(int \fIflags\fP)
|
||||
|
||||
int ares_library_init_mem(int \fIflags\fP,
|
||||
void *(*\fIamalloc\fP)(size_t),
|
||||
void (*\fIafree\fP)(void *ptr),
|
||||
void (*\fIarealloc\fP)(void *ptr, size_t size))
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
@@ -34,13 +36,15 @@ function performs initializations internally required by the c-ares
|
||||
library that must take place before any other function provided by
|
||||
c-ares can be used in a program.
|
||||
.PP
|
||||
This function must be called one time within the life of a program,
|
||||
This function must be called at least once within the life of a program,
|
||||
before the program actually executes any other c-ares library function.
|
||||
Initializations done by this function remain effective until a
|
||||
call to \fIares_library_cleanup(3)\fP is performed.
|
||||
Initializations done by this function remain effective until a number of
|
||||
calls to \fIares_library_cleanup(3)\fP equal to the number of calls to
|
||||
this function are performed.
|
||||
.PP
|
||||
Successive calls to this function do nothing, only the first call done
|
||||
when c-ares is in an uninitialized state is actually effective.
|
||||
Successive calls to this function do nothing further, only the first
|
||||
call done when c-ares is in an uninitialized state is actually
|
||||
effective.
|
||||
.PP
|
||||
The
|
||||
.I flags
|
||||
@@ -50,6 +54,12 @@ ORing the values together. In normal operation you should specify
|
||||
\fIARES_LIB_INIT_ALL\fP. Don't use any other value unless you are
|
||||
familiar with it and trying to control some internal c-ares feature.
|
||||
.PP
|
||||
The
|
||||
.B ares_library_init_mem
|
||||
function allows the caller to provide memory management functions that the
|
||||
c-ares library will be use instead of \fImalloc(3)\fP, \fIfree(3)\fP and
|
||||
\fIrealloc(3)\fP.
|
||||
.PP
|
||||
.B This function is not thread safe.
|
||||
You have to call it once the program has started, but this call must be done
|
||||
before the program starts any other thread. This is required to avoid
|
||||
@@ -78,7 +88,11 @@ non-zero error number will be returned to indicate the error. Except for
|
||||
.SH AVAILABILITY
|
||||
This function was first introduced in c-ares version 1.7.0 along with the
|
||||
definition of preprocessor symbol \fICARES_HAVE_ARES_LIBRARY_INIT\fP as an
|
||||
indication of the availability of this function.
|
||||
indication of the availability of this function. Its recursive behavior,
|
||||
which requires a matching number of calls to \fIares_library_cleanup()\fP
|
||||
in order to deinitialize the library, is present since c-ares version
|
||||
1.10.0. Earlier versions would deinitialize the library on the first call
|
||||
to \fIares_library_cleanup()\fP.
|
||||
.PP
|
||||
Since the introduction of this function it is absolutely mandatory to
|
||||
call it for any Win32/64 program using c-ares.
|
||||
|
||||
+56
-8
@@ -1,4 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
* Copyright (C) 2004-2009 by Daniel Stenberg
|
||||
@@ -27,6 +26,7 @@
|
||||
#ifdef USE_WINSOCK
|
||||
fpGetNetworkParams_t ares_fpGetNetworkParams = ZERO_NULL;
|
||||
fpSystemFunction036_t ares_fpSystemFunction036 = ZERO_NULL;
|
||||
fpGetAdaptersAddresses_t ares_fpGetAdaptersAddresses = ZERO_NULL;
|
||||
#endif
|
||||
|
||||
/* library-private global vars with source visibility restricted to this file */
|
||||
@@ -34,6 +34,11 @@ fpSystemFunction036_t ares_fpSystemFunction036 = ZERO_NULL;
|
||||
static unsigned int ares_initialized;
|
||||
static int ares_init_flags;
|
||||
|
||||
/* library-private global vars with visibility across the whole library */
|
||||
void *(*ares_malloc)(size_t size) = malloc;
|
||||
void *(*ares_realloc)(void *ptr, size_t size) = realloc;
|
||||
void (*ares_free)(void *ptr) = free;
|
||||
|
||||
#ifdef USE_WINSOCK
|
||||
static HMODULE hnd_iphlpapi;
|
||||
static HMODULE hnd_advapi32;
|
||||
@@ -45,7 +50,7 @@ static int ares_win32_init(void)
|
||||
#ifdef USE_WINSOCK
|
||||
|
||||
hnd_iphlpapi = 0;
|
||||
hnd_iphlpapi = LoadLibrary("iphlpapi.dll");
|
||||
hnd_iphlpapi = LoadLibraryW(L"iphlpapi.dll");
|
||||
if (!hnd_iphlpapi)
|
||||
return ARES_ELOADIPHLPAPI;
|
||||
|
||||
@@ -57,6 +62,15 @@ static int ares_win32_init(void)
|
||||
return ARES_EADDRGETNETWORKPARAMS;
|
||||
}
|
||||
|
||||
ares_fpGetAdaptersAddresses = (fpGetAdaptersAddresses_t)
|
||||
GetProcAddress(hnd_iphlpapi, "GetAdaptersAddresses");
|
||||
if (!ares_fpGetAdaptersAddresses)
|
||||
{
|
||||
/* This can happen on clients before WinXP, I don't
|
||||
think it should be an error, unless we don't want to
|
||||
support Windows 2000 anymore */
|
||||
}
|
||||
|
||||
/*
|
||||
* When advapi32.dll is unavailable or advapi32.dll has no SystemFunction036,
|
||||
* also known as RtlGenRandom, which is the case for Windows versions prior
|
||||
@@ -64,7 +78,7 @@ static int ares_win32_init(void)
|
||||
*/
|
||||
|
||||
hnd_advapi32 = 0;
|
||||
hnd_advapi32 = LoadLibrary("advapi32.dll");
|
||||
hnd_advapi32 = LoadLibraryW(L"advapi32.dll");
|
||||
if (hnd_advapi32)
|
||||
{
|
||||
ares_fpSystemFunction036 = (fpSystemFunction036_t)
|
||||
@@ -92,14 +106,24 @@ int ares_library_init(int flags)
|
||||
int res;
|
||||
|
||||
if (ares_initialized)
|
||||
return ARES_SUCCESS;
|
||||
{
|
||||
ares_initialized++;
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
ares_initialized++;
|
||||
|
||||
|
||||
if (flags & ARES_LIB_INIT_AMIGA)
|
||||
{
|
||||
res = ares_amiga_init();
|
||||
if (res != ARES_SUCCESS)
|
||||
return res;
|
||||
}
|
||||
|
||||
if (flags & ARES_LIB_INIT_WIN32)
|
||||
{
|
||||
res = ares_win32_init();
|
||||
if (res != ARES_SUCCESS)
|
||||
return res;
|
||||
return res; /* LCOV_EXCL_LINE: can't test Win32 init failure */
|
||||
}
|
||||
|
||||
ares_init_flags = flags;
|
||||
@@ -107,17 +131,39 @@ int ares_library_init(int flags)
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
|
||||
int ares_library_init_mem(int flags,
|
||||
void *(*amalloc)(size_t size),
|
||||
void (*afree)(void *ptr),
|
||||
void *(*arealloc)(void *ptr, size_t size))
|
||||
{
|
||||
if (amalloc)
|
||||
ares_malloc = amalloc;
|
||||
if (arealloc)
|
||||
ares_realloc = arealloc;
|
||||
if (afree)
|
||||
ares_free = afree;
|
||||
return ares_library_init(flags);
|
||||
}
|
||||
|
||||
|
||||
void ares_library_cleanup(void)
|
||||
{
|
||||
if (!ares_initialized)
|
||||
return;
|
||||
ares_initialized--;
|
||||
if (ares_initialized)
|
||||
return;
|
||||
|
||||
if (ares_init_flags & ARES_LIB_INIT_WIN32)
|
||||
ares_win32_cleanup();
|
||||
|
||||
if (ares_init_flags & ARES_LIB_INIT_AMIGA)
|
||||
ares_amiga_cleanup();
|
||||
|
||||
ares_init_flags = ARES_LIB_INIT_NONE;
|
||||
ares_malloc = malloc;
|
||||
ares_realloc = realloc;
|
||||
ares_free = free;
|
||||
}
|
||||
|
||||
|
||||
@@ -126,8 +172,10 @@ int ares_library_initialized(void)
|
||||
#ifdef USE_WINSOCK
|
||||
if (!ares_initialized)
|
||||
return ARES_ENOTINITIALIZED;
|
||||
#endif
|
||||
#ifdef AOS3
|
||||
if (!ares_initialized)
|
||||
return ARES_ENOTINITIALIZED;
|
||||
#endif
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+4
-2
@@ -1,10 +1,9 @@
|
||||
#ifndef HEADER_CARES_LIBRARY_INIT_H
|
||||
#define HEADER_CARES_LIBRARY_INIT_H
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
* Copyright (C) 2004-2009 by Daniel Stenberg
|
||||
* Copyright (C) 2004-2011 by Daniel Stenberg
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose and without
|
||||
@@ -24,15 +23,18 @@
|
||||
#ifdef USE_WINSOCK
|
||||
|
||||
#include <iphlpapi.h>
|
||||
#include <ares_iphlpapi.h>
|
||||
|
||||
typedef DWORD (WINAPI *fpGetNetworkParams_t) (FIXED_INFO*, DWORD*);
|
||||
typedef BOOLEAN (APIENTRY *fpSystemFunction036_t) (void*, ULONG);
|
||||
typedef ULONG (WINAPI *fpGetAdaptersAddresses_t) ( ULONG, ULONG, void*, IP_ADAPTER_ADDRESSES*, ULONG* );
|
||||
|
||||
/* Forward-declaration of variables defined in ares_library_init.c */
|
||||
/* that are global and unique instances for whole c-ares library. */
|
||||
|
||||
extern fpGetNetworkParams_t ares_fpGetNetworkParams;
|
||||
extern fpSystemFunction036_t ares_fpSystemFunction036;
|
||||
extern fpGetAdaptersAddresses_t ares_fpGetAdaptersAddresses;
|
||||
|
||||
#endif /* USE_WINSOCK */
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
*
|
||||
@@ -62,26 +61,3 @@ void ares__remove_from_list(struct list_node* node) {
|
||||
}
|
||||
}
|
||||
|
||||
/* Swap the contents of two lists */
|
||||
void ares__swap_lists(struct list_node* head_a,
|
||||
struct list_node* head_b) {
|
||||
int is_a_empty = ares__is_list_empty(head_a);
|
||||
int is_b_empty = ares__is_list_empty(head_b);
|
||||
struct list_node old_a = *head_a;
|
||||
struct list_node old_b = *head_b;
|
||||
|
||||
if (is_a_empty) {
|
||||
ares__init_list_head(head_b);
|
||||
} else {
|
||||
*head_b = old_a;
|
||||
old_a.next->prev = head_b;
|
||||
old_a.prev->next = head_b;
|
||||
}
|
||||
if (is_b_empty) {
|
||||
ares__init_list_head(head_a);
|
||||
} else {
|
||||
*head_a = old_b;
|
||||
old_b.next->prev = head_a;
|
||||
old_b.prev->next = head_a;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#ifndef __ARES_LLIST_H
|
||||
#define __ARES_LLIST_H
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
*
|
||||
@@ -37,7 +36,4 @@ void ares__insert_in_list(struct list_node* new_node,
|
||||
|
||||
void ares__remove_from_list(struct list_node* node);
|
||||
|
||||
void ares__swap_lists(struct list_node* head_a,
|
||||
struct list_node* head_b);
|
||||
|
||||
#endif /* __ARES_LLIST_H */
|
||||
|
||||
+7
-1
@@ -1,4 +1,3 @@
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright 1998, 2000 by the Massachusetts Institute of Technology.
|
||||
.\"
|
||||
@@ -26,6 +25,8 @@ ares_mkquery \- Compose a single-question DNS query buffer
|
||||
.B int *\fIbuflen\fP)
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
Deprecated function. See \fIares_create_query(3)\fP instead!
|
||||
|
||||
The
|
||||
.B ares_mkquery
|
||||
function composes a DNS query with a single question.
|
||||
@@ -51,6 +52,11 @@ and the length of which will be stored in the variable pointed to by
|
||||
.IR buflen .
|
||||
It is the caller's responsibility to free this buffer using
|
||||
\fIares_free_string(3)\fP when it is no longer needed.
|
||||
|
||||
Usage of \fIares_mkquery(3)\fP is deprecated, whereas the function is
|
||||
equivalent to \fIares_create_query(3)\fP with \fBmax_udp_size\fP set to
|
||||
0.
|
||||
|
||||
.SH RETURN VALUES
|
||||
.B ares_mkquery
|
||||
can return any of the following values:
|
||||
|
||||
+1
-173
@@ -1,4 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
*
|
||||
@@ -16,181 +15,10 @@
|
||||
*/
|
||||
|
||||
#include "ares_setup.h"
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_NAMESER_H
|
||||
# include <arpa/nameser.h>
|
||||
#else
|
||||
# include "nameser.h"
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
|
||||
# include <arpa/nameser_compat.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "ares.h"
|
||||
#include "ares_dns.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
/* Header format, from RFC 1035:
|
||||
* 1 1 1 1 1 1
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | ID |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* |QR| Opcode |AA|TC|RD|RA| Z | RCODE |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | QDCOUNT |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | ANCOUNT |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | NSCOUNT |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | ARCOUNT |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* AA, TC, RA, and RCODE are only set in responses. Brief description
|
||||
* of the remaining fields:
|
||||
* ID Identifier to match responses with queries
|
||||
* QR Query (0) or response (1)
|
||||
* Opcode For our purposes, always QUERY
|
||||
* RD Recursion desired
|
||||
* Z Reserved (zero)
|
||||
* QDCOUNT Number of queries
|
||||
* ANCOUNT Number of answers
|
||||
* NSCOUNT Number of name server records
|
||||
* ARCOUNT Number of additional records
|
||||
*
|
||||
* Question format, from RFC 1035:
|
||||
* 1 1 1 1 1 1
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | |
|
||||
* / QNAME /
|
||||
* / /
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | QTYPE |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
* | QCLASS |
|
||||
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|
||||
*
|
||||
* The query name is encoded as a series of labels, each represented
|
||||
* as a one-byte length (maximum 63) followed by the text of the
|
||||
* label. The list is terminated by a label of length zero (which can
|
||||
* be thought of as the root domain).
|
||||
*/
|
||||
|
||||
int ares_mkquery(const char *name, int dnsclass, int type, unsigned short id,
|
||||
int rd, unsigned char **buf, int *buflen)
|
||||
{
|
||||
int len;
|
||||
unsigned char *q;
|
||||
const char *p;
|
||||
|
||||
/* Set our results early, in case we bail out early with an error. */
|
||||
*buflen = 0;
|
||||
*buf = NULL;
|
||||
|
||||
/* Compute the length of the encoded name so we can check buflen.
|
||||
* Start counting at 1 for the zero-length label at the end. */
|
||||
len = 1;
|
||||
for (p = name; *p; p++)
|
||||
{
|
||||
if (*p == '\\' && *(p + 1) != 0)
|
||||
p++;
|
||||
len++;
|
||||
}
|
||||
/* If there are n periods in the name, there are n + 1 labels, and
|
||||
* thus n + 1 length fields, unless the name is empty or ends with a
|
||||
* period. So add 1 unless name is empty or ends with a period.
|
||||
*/
|
||||
if (*name && *(p - 1) != '.')
|
||||
len++;
|
||||
|
||||
/* Immediately reject names that are longer than the maximum of 255
|
||||
* bytes that's specified in RFC 1035 ("To simplify implementations,
|
||||
* the total length of a domain name (i.e., label octets and label
|
||||
* length octets) is restricted to 255 octets or less."). We aren't
|
||||
* doing this just to be a stickler about RFCs. For names that are
|
||||
* too long, 'dnscache' closes its TCP connection to us immediately
|
||||
* (when using TCP) and ignores the request when using UDP, and
|
||||
* BIND's named returns ServFail (TCP or UDP). Sending a request
|
||||
* that we know will cause 'dnscache' to close the TCP connection is
|
||||
* painful, since that makes any other outstanding requests on that
|
||||
* connection fail. And sending a UDP request that we know
|
||||
* 'dnscache' will ignore is bad because resources will be tied up
|
||||
* until we time-out the request.
|
||||
*/
|
||||
if (len > MAXCDNAME)
|
||||
return ARES_EBADNAME;
|
||||
|
||||
*buflen = len + HFIXEDSZ + QFIXEDSZ;
|
||||
*buf = malloc(*buflen);
|
||||
if (!*buf)
|
||||
return ARES_ENOMEM;
|
||||
|
||||
/* Set up the header. */
|
||||
q = *buf;
|
||||
memset(q, 0, HFIXEDSZ);
|
||||
DNS_HEADER_SET_QID(q, id);
|
||||
DNS_HEADER_SET_OPCODE(q, QUERY);
|
||||
if (rd) {
|
||||
DNS_HEADER_SET_RD(q, 1);
|
||||
}
|
||||
else {
|
||||
DNS_HEADER_SET_RD(q, 0);
|
||||
}
|
||||
DNS_HEADER_SET_QDCOUNT(q, 1);
|
||||
|
||||
/* A name of "." is a screw case for the loop below, so adjust it. */
|
||||
if (strcmp(name, ".") == 0)
|
||||
name++;
|
||||
|
||||
/* Start writing out the name after the header. */
|
||||
q += HFIXEDSZ;
|
||||
while (*name)
|
||||
{
|
||||
if (*name == '.')
|
||||
return ARES_EBADNAME;
|
||||
|
||||
/* Count the number of bytes in this label. */
|
||||
len = 0;
|
||||
for (p = name; *p && *p != '.'; p++)
|
||||
{
|
||||
if (*p == '\\' && *(p + 1) != 0)
|
||||
p++;
|
||||
len++;
|
||||
}
|
||||
if (len > MAXLABEL)
|
||||
return ARES_EBADNAME;
|
||||
|
||||
/* Encode the length and copy the data. */
|
||||
*q++ = (unsigned char)len;
|
||||
for (p = name; *p && *p != '.'; p++)
|
||||
{
|
||||
if (*p == '\\' && *(p + 1) != 0)
|
||||
p++;
|
||||
*q++ = *p;
|
||||
}
|
||||
|
||||
/* Go to the next label and repeat, unless we hit the end. */
|
||||
if (!*p)
|
||||
break;
|
||||
name = p + 1;
|
||||
}
|
||||
|
||||
/* Add the zero-length label at the end. */
|
||||
*q++ = 0;
|
||||
|
||||
/* Finish off the question with the type and class. */
|
||||
DNS_QUESTION_SET_TYPE(q, type);
|
||||
DNS_QUESTION_SET_CLASS(q, dnsclass);
|
||||
|
||||
return ARES_SUCCESS;
|
||||
return ares_create_query(name, dnsclass, type, id, rd, buf, buflen, 0);
|
||||
}
|
||||
|
||||
+260
@@ -0,0 +1,260 @@
|
||||
|
||||
/* Copyright (C) 2010-2013 by Daniel Stenberg
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose and without
|
||||
* fee is hereby granted, provided that the above copyright
|
||||
* notice appear in all copies and that both that copyright
|
||||
* notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of M.I.T. not be used in
|
||||
* advertising or publicity pertaining to distribution of the
|
||||
* software without specific, written prior permission.
|
||||
* M.I.T. makes no representations about the suitability of
|
||||
* this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*/
|
||||
|
||||
|
||||
#include "ares_setup.h"
|
||||
|
||||
#ifdef HAVE_ASSERT_H
|
||||
# include <assert.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#if defined(__INTEL_COMPILER) && defined(__unix__)
|
||||
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#endif /* __INTEL_COMPILER && __unix__ */
|
||||
|
||||
#define BUILDING_ARES_NOWARN_C 1
|
||||
|
||||
#include "ares_nowarn.h"
|
||||
|
||||
#ifndef HAVE_LIMITS_H
|
||||
/* systems without <limits.h> we guess have 16 bit shorts, 32bit ints and
|
||||
32bit longs */
|
||||
# define CARES_MASK_SSHORT 0x7FFF
|
||||
# define CARES_MASK_USHORT 0xFFFF
|
||||
# define CARES_MASK_SINT 0x7FFFFFFF
|
||||
# define CARES_MASK_UINT 0xFFFFFFFF
|
||||
# define CARES_MASK_SLONG 0x7FFFFFFFL
|
||||
# define CARES_MASK_ULONG 0xFFFFFFFFUL
|
||||
#else
|
||||
# define CARES_MASK_SSHORT SHRT_MAX
|
||||
# define CARES_MASK_USHORT USHRT_MAX
|
||||
# define CARES_MASK_SINT INT_MAX
|
||||
# define CARES_MASK_UINT UINT_MAX
|
||||
# define CARES_MASK_SLONG LONG_MAX
|
||||
# define CARES_MASK_ULONG ULONG_MAX
|
||||
#endif
|
||||
|
||||
/*
|
||||
** unsigned size_t to signed long
|
||||
*/
|
||||
|
||||
long aresx_uztosl(size_t uznum)
|
||||
{
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:810) /* conversion may lose significant bits */
|
||||
#endif
|
||||
|
||||
return (long)(uznum & (size_t) CARES_MASK_SLONG);
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
** unsigned size_t to signed int
|
||||
*/
|
||||
|
||||
int aresx_uztosi(size_t uznum)
|
||||
{
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:810) /* conversion may lose significant bits */
|
||||
#endif
|
||||
|
||||
return (int)(uznum & (size_t) CARES_MASK_SINT);
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
** unsigned size_t to signed short
|
||||
*/
|
||||
|
||||
short aresx_uztoss(size_t uznum)
|
||||
{
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:810) /* conversion may lose significant bits */
|
||||
#endif
|
||||
|
||||
return (short)(uznum & (size_t) CARES_MASK_SSHORT);
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
** signed int to signed short
|
||||
*/
|
||||
|
||||
short aresx_sitoss(int sinum)
|
||||
{
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:810) /* conversion may lose significant bits */
|
||||
#endif
|
||||
|
||||
DEBUGASSERT(sinum >= 0);
|
||||
return (short)(sinum & (int) CARES_MASK_SSHORT);
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
** signed long to signed int
|
||||
*/
|
||||
|
||||
int aresx_sltosi(long slnum)
|
||||
{
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:810) /* conversion may lose significant bits */
|
||||
#endif
|
||||
|
||||
DEBUGASSERT(slnum >= 0);
|
||||
return (int)(slnum & (long) CARES_MASK_SINT);
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
** signed ssize_t to signed int
|
||||
*/
|
||||
|
||||
int aresx_sztosi(ssize_t sznum)
|
||||
{
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:810) /* conversion may lose significant bits */
|
||||
#endif
|
||||
|
||||
DEBUGASSERT(sznum >= 0);
|
||||
return (int)(sznum & (ssize_t) CARES_MASK_SINT);
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
** signed ssize_t to unsigned int
|
||||
*/
|
||||
|
||||
unsigned int aresx_sztoui(ssize_t sznum)
|
||||
{
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:810) /* conversion may lose significant bits */
|
||||
#endif
|
||||
|
||||
DEBUGASSERT(sznum >= 0);
|
||||
return (unsigned int)(sznum & (ssize_t) CARES_MASK_UINT);
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
** signed int to unsigned short
|
||||
*/
|
||||
|
||||
unsigned short aresx_sitous(int sinum)
|
||||
{
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:810) /* conversion may lose significant bits */
|
||||
#endif
|
||||
|
||||
DEBUGASSERT(sinum >= 0);
|
||||
return (unsigned short)(sinum & (int) CARES_MASK_USHORT);
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(__INTEL_COMPILER) && defined(__unix__)
|
||||
|
||||
int aresx_FD_ISSET(int fd, fd_set *fdset)
|
||||
{
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:1469) /* clobber ignored */
|
||||
return FD_ISSET(fd, fdset);
|
||||
#pragma warning(pop)
|
||||
}
|
||||
|
||||
void aresx_FD_SET(int fd, fd_set *fdset)
|
||||
{
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:1469) /* clobber ignored */
|
||||
FD_SET(fd, fdset);
|
||||
#pragma warning(pop)
|
||||
}
|
||||
|
||||
void aresx_FD_ZERO(fd_set *fdset)
|
||||
{
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:593) /* variable was set but never used */
|
||||
FD_ZERO(fdset);
|
||||
#pragma warning(pop)
|
||||
}
|
||||
|
||||
unsigned short aresx_htons(unsigned short usnum)
|
||||
{
|
||||
#if (__INTEL_COMPILER == 910) && defined(__i386__)
|
||||
return (unsigned short)(((usnum << 8) & 0xFF00) | ((usnum >> 8) & 0x00FF));
|
||||
#else
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:810) /* conversion may lose significant bits */
|
||||
return htons(usnum);
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned short aresx_ntohs(unsigned short usnum)
|
||||
{
|
||||
#if (__INTEL_COMPILER == 910) && defined(__i386__)
|
||||
return (unsigned short)(((usnum << 8) & 0xFF00) | ((usnum >> 8) & 0x00FF));
|
||||
#else
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:810) /* conversion may lose significant bits */
|
||||
return ntohs(usnum);
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* __INTEL_COMPILER && __unix__ */
|
||||
@@ -0,0 +1,61 @@
|
||||
#ifndef HEADER_CARES_NOWARN_H
|
||||
#define HEADER_CARES_NOWARN_H
|
||||
|
||||
|
||||
/* Copyright (C) 2010-2012 by Daniel Stenberg
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose and without
|
||||
* fee is hereby granted, provided that the above copyright
|
||||
* notice appear in all copies and that both that copyright
|
||||
* notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of M.I.T. not be used in
|
||||
* advertising or publicity pertaining to distribution of the
|
||||
* software without specific, written prior permission.
|
||||
* M.I.T. makes no representations about the suitability of
|
||||
* this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*/
|
||||
|
||||
long aresx_uztosl(size_t uznum);
|
||||
int aresx_uztosi(size_t uznum);
|
||||
short aresx_uztoss(size_t uznum);
|
||||
|
||||
short aresx_sitoss(int sinum);
|
||||
|
||||
int aresx_sltosi(long slnum);
|
||||
|
||||
int aresx_sztosi(ssize_t sznum);
|
||||
|
||||
unsigned int aresx_sztoui(ssize_t sznum);
|
||||
|
||||
unsigned short aresx_sitous(int sinum);
|
||||
|
||||
#if defined(__INTEL_COMPILER) && defined(__unix__)
|
||||
|
||||
int aresx_FD_ISSET(int fd, fd_set *fdset);
|
||||
|
||||
void aresx_FD_SET(int fd, fd_set *fdset);
|
||||
|
||||
void aresx_FD_ZERO(fd_set *fdset);
|
||||
|
||||
unsigned short aresx_htons(unsigned short usnum);
|
||||
|
||||
unsigned short aresx_ntohs(unsigned short usnum);
|
||||
|
||||
#ifndef BUILDING_ARES_NOWARN_C
|
||||
# undef FD_ISSET
|
||||
# define FD_ISSET(a,b) aresx_FD_ISSET((a),(b))
|
||||
# undef FD_SET
|
||||
# define FD_SET(a,b) aresx_FD_SET((a),(b))
|
||||
# undef FD_ZERO
|
||||
# define FD_ZERO(a) aresx_FD_ZERO((a))
|
||||
# undef htons
|
||||
# define htons(a) aresx_htons((a))
|
||||
# undef ntohs
|
||||
# define ntohs(a) aresx_ntohs((a))
|
||||
#endif
|
||||
|
||||
#endif /* __INTEL_COMPILER && __unix__ */
|
||||
|
||||
#endif /* HEADER_CARES_NOWARN_H */
|
||||
+402
@@ -0,0 +1,402 @@
|
||||
|
||||
/* Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
* Copyright (C) 2008-2013 by Daniel Stenberg
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose and without
|
||||
* fee is hereby granted, provided that the above copyright
|
||||
* notice appear in all copies and that both that copyright
|
||||
* notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of M.I.T. not be used in
|
||||
* advertising or publicity pertaining to distribution of the
|
||||
* software without specific, written prior permission.
|
||||
* M.I.T. makes no representations about the suitability of
|
||||
* this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*/
|
||||
|
||||
|
||||
#include "ares_setup.h"
|
||||
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#include "ares.h"
|
||||
#include "ares_data.h"
|
||||
#include "ares_inet_net_pton.h"
|
||||
#include "ares_private.h"
|
||||
|
||||
|
||||
int ares_get_servers(ares_channel channel,
|
||||
struct ares_addr_node **servers)
|
||||
{
|
||||
struct ares_addr_node *srvr_head = NULL;
|
||||
struct ares_addr_node *srvr_last = NULL;
|
||||
struct ares_addr_node *srvr_curr;
|
||||
int status = ARES_SUCCESS;
|
||||
int i;
|
||||
|
||||
if (!channel)
|
||||
return ARES_ENODATA;
|
||||
|
||||
for (i = 0; i < channel->nservers; i++)
|
||||
{
|
||||
/* Allocate storage for this server node appending it to the list */
|
||||
srvr_curr = ares_malloc_data(ARES_DATATYPE_ADDR_NODE);
|
||||
if (!srvr_curr)
|
||||
{
|
||||
status = ARES_ENOMEM;
|
||||
break;
|
||||
}
|
||||
if (srvr_last)
|
||||
{
|
||||
srvr_last->next = srvr_curr;
|
||||
}
|
||||
else
|
||||
{
|
||||
srvr_head = srvr_curr;
|
||||
}
|
||||
srvr_last = srvr_curr;
|
||||
|
||||
/* Fill this server node data */
|
||||
srvr_curr->family = channel->servers[i].addr.family;
|
||||
if (srvr_curr->family == AF_INET)
|
||||
memcpy(&srvr_curr->addrV4, &channel->servers[i].addr.addrV4,
|
||||
sizeof(srvr_curr->addrV4));
|
||||
else
|
||||
memcpy(&srvr_curr->addrV6, &channel->servers[i].addr.addrV6,
|
||||
sizeof(srvr_curr->addrV6));
|
||||
}
|
||||
|
||||
if (status != ARES_SUCCESS)
|
||||
{
|
||||
if (srvr_head)
|
||||
{
|
||||
ares_free_data(srvr_head);
|
||||
srvr_head = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
*servers = srvr_head;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int ares_get_servers_ports(ares_channel channel,
|
||||
struct ares_addr_port_node **servers)
|
||||
{
|
||||
struct ares_addr_port_node *srvr_head = NULL;
|
||||
struct ares_addr_port_node *srvr_last = NULL;
|
||||
struct ares_addr_port_node *srvr_curr;
|
||||
int status = ARES_SUCCESS;
|
||||
int i;
|
||||
|
||||
if (!channel)
|
||||
return ARES_ENODATA;
|
||||
|
||||
for (i = 0; i < channel->nservers; i++)
|
||||
{
|
||||
/* Allocate storage for this server node appending it to the list */
|
||||
srvr_curr = ares_malloc_data(ARES_DATATYPE_ADDR_PORT_NODE);
|
||||
if (!srvr_curr)
|
||||
{
|
||||
status = ARES_ENOMEM;
|
||||
break;
|
||||
}
|
||||
if (srvr_last)
|
||||
{
|
||||
srvr_last->next = srvr_curr;
|
||||
}
|
||||
else
|
||||
{
|
||||
srvr_head = srvr_curr;
|
||||
}
|
||||
srvr_last = srvr_curr;
|
||||
|
||||
/* Fill this server node data */
|
||||
srvr_curr->family = channel->servers[i].addr.family;
|
||||
srvr_curr->udp_port = ntohs((unsigned short)channel->servers[i].addr.udp_port);
|
||||
srvr_curr->tcp_port = ntohs((unsigned short)channel->servers[i].addr.tcp_port);
|
||||
if (srvr_curr->family == AF_INET)
|
||||
memcpy(&srvr_curr->addrV4, &channel->servers[i].addr.addrV4,
|
||||
sizeof(srvr_curr->addrV4));
|
||||
else
|
||||
memcpy(&srvr_curr->addrV6, &channel->servers[i].addr.addrV6,
|
||||
sizeof(srvr_curr->addrV6));
|
||||
}
|
||||
|
||||
if (status != ARES_SUCCESS)
|
||||
{
|
||||
if (srvr_head)
|
||||
{
|
||||
ares_free_data(srvr_head);
|
||||
srvr_head = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
*servers = srvr_head;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int ares_set_servers(ares_channel channel,
|
||||
struct ares_addr_node *servers)
|
||||
{
|
||||
struct ares_addr_node *srvr;
|
||||
int num_srvrs = 0;
|
||||
int i;
|
||||
|
||||
if (ares_library_initialized() != ARES_SUCCESS)
|
||||
return ARES_ENOTINITIALIZED; /* LCOV_EXCL_LINE: n/a on non-WinSock */
|
||||
|
||||
if (!channel)
|
||||
return ARES_ENODATA;
|
||||
|
||||
ares__destroy_servers_state(channel);
|
||||
|
||||
for (srvr = servers; srvr; srvr = srvr->next)
|
||||
{
|
||||
num_srvrs++;
|
||||
}
|
||||
|
||||
if (num_srvrs > 0)
|
||||
{
|
||||
/* Allocate storage for servers state */
|
||||
channel->servers = ares_malloc(num_srvrs * sizeof(struct server_state));
|
||||
if (!channel->servers)
|
||||
{
|
||||
return ARES_ENOMEM;
|
||||
}
|
||||
channel->nservers = num_srvrs;
|
||||
/* Fill servers state address data */
|
||||
for (i = 0, srvr = servers; srvr; i++, srvr = srvr->next)
|
||||
{
|
||||
channel->servers[i].addr.family = srvr->family;
|
||||
channel->servers[i].addr.udp_port = 0;
|
||||
channel->servers[i].addr.tcp_port = 0;
|
||||
if (srvr->family == AF_INET)
|
||||
memcpy(&channel->servers[i].addr.addrV4, &srvr->addrV4,
|
||||
sizeof(srvr->addrV4));
|
||||
else
|
||||
memcpy(&channel->servers[i].addr.addrV6, &srvr->addrV6,
|
||||
sizeof(srvr->addrV6));
|
||||
}
|
||||
/* Initialize servers state remaining data */
|
||||
ares__init_servers_state(channel);
|
||||
}
|
||||
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
|
||||
int ares_set_servers_ports(ares_channel channel,
|
||||
struct ares_addr_port_node *servers)
|
||||
{
|
||||
struct ares_addr_port_node *srvr;
|
||||
int num_srvrs = 0;
|
||||
int i;
|
||||
|
||||
if (ares_library_initialized() != ARES_SUCCESS)
|
||||
return ARES_ENOTINITIALIZED; /* LCOV_EXCL_LINE: n/a on non-WinSock */
|
||||
|
||||
if (!channel)
|
||||
return ARES_ENODATA;
|
||||
|
||||
ares__destroy_servers_state(channel);
|
||||
|
||||
for (srvr = servers; srvr; srvr = srvr->next)
|
||||
{
|
||||
num_srvrs++;
|
||||
}
|
||||
|
||||
if (num_srvrs > 0)
|
||||
{
|
||||
/* Allocate storage for servers state */
|
||||
channel->servers = ares_malloc(num_srvrs * sizeof(struct server_state));
|
||||
if (!channel->servers)
|
||||
{
|
||||
return ARES_ENOMEM;
|
||||
}
|
||||
channel->nservers = num_srvrs;
|
||||
/* Fill servers state address data */
|
||||
for (i = 0, srvr = servers; srvr; i++, srvr = srvr->next)
|
||||
{
|
||||
channel->servers[i].addr.family = srvr->family;
|
||||
channel->servers[i].addr.udp_port = htons((unsigned short)srvr->udp_port);
|
||||
channel->servers[i].addr.tcp_port = htons((unsigned short)srvr->tcp_port);
|
||||
if (srvr->family == AF_INET)
|
||||
memcpy(&channel->servers[i].addr.addrV4, &srvr->addrV4,
|
||||
sizeof(srvr->addrV4));
|
||||
else
|
||||
memcpy(&channel->servers[i].addr.addrV6, &srvr->addrV6,
|
||||
sizeof(srvr->addrV6));
|
||||
}
|
||||
/* Initialize servers state remaining data */
|
||||
ares__init_servers_state(channel);
|
||||
}
|
||||
|
||||
return ARES_SUCCESS;
|
||||
}
|
||||
|
||||
/* Incomming string format: host[:port][,host[:port]]... */
|
||||
/* IPv6 addresses with ports require square brackets [fe80::1%lo0]:53 */
|
||||
static int set_servers_csv(ares_channel channel,
|
||||
const char* _csv, int use_port)
|
||||
{
|
||||
size_t i;
|
||||
char* csv = NULL;
|
||||
char* ptr;
|
||||
char* start_host;
|
||||
int cc = 0;
|
||||
int rv = ARES_SUCCESS;
|
||||
struct ares_addr_port_node *servers = NULL;
|
||||
struct ares_addr_port_node *last = NULL;
|
||||
|
||||
if (ares_library_initialized() != ARES_SUCCESS)
|
||||
return ARES_ENOTINITIALIZED; /* LCOV_EXCL_LINE: n/a on non-WinSock */
|
||||
|
||||
if (!channel)
|
||||
return ARES_ENODATA;
|
||||
|
||||
ares__destroy_servers_state(channel);
|
||||
|
||||
i = strlen(_csv);
|
||||
if (i == 0)
|
||||
return ARES_SUCCESS; /* blank all servers */
|
||||
|
||||
csv = ares_malloc(i + 2);
|
||||
if (!csv)
|
||||
return ARES_ENOMEM;
|
||||
|
||||
strcpy(csv, _csv);
|
||||
if (csv[i-1] != ',') { /* make parsing easier by ensuring ending ',' */
|
||||
csv[i] = ',';
|
||||
csv[i+1] = 0;
|
||||
}
|
||||
|
||||
start_host = csv;
|
||||
for (ptr = csv; *ptr; ptr++) {
|
||||
if (*ptr == ':') {
|
||||
/* count colons to determine if we have an IPv6 number or IPv4 with
|
||||
port */
|
||||
cc++;
|
||||
}
|
||||
else if (*ptr == '[') {
|
||||
/* move start_host if an open square bracket is found wrapping an IPv6
|
||||
address */
|
||||
start_host = ptr + 1;
|
||||
}
|
||||
else if (*ptr == ',') {
|
||||
char* pp = ptr - 1;
|
||||
char* p = ptr;
|
||||
int port = 0;
|
||||
struct in_addr in4;
|
||||
struct ares_in6_addr in6;
|
||||
struct ares_addr_port_node *s = NULL;
|
||||
|
||||
*ptr = 0; /* null terminate host:port string */
|
||||
/* Got an entry..see if the port was specified. */
|
||||
if (cc > 0) {
|
||||
while (pp > start_host) {
|
||||
/* a single close square bracket followed by a colon, ']:' indicates
|
||||
an IPv6 address with port */
|
||||
if ((*pp == ']') && (*p == ':'))
|
||||
break; /* found port */
|
||||
/* a single colon, ':' indicates an IPv4 address with port */
|
||||
if ((*pp == ':') && (cc == 1))
|
||||
break; /* found port */
|
||||
if (!(ISDIGIT(*pp) || (*pp == ':'))) {
|
||||
/* Found end of digits before we found :, so wasn't a port */
|
||||
/* must allow ':' for IPv6 case of ']:' indicates we found a port */
|
||||
pp = p = ptr;
|
||||
break;
|
||||
}
|
||||
pp--;
|
||||
p--;
|
||||
}
|
||||
if ((pp != start_host) && ((pp + 1) < ptr)) {
|
||||
/* Found it. Parse over the port number */
|
||||
/* when an IPv6 address is wrapped with square brackets the port
|
||||
starts at pp + 2 */
|
||||
if (*pp == ']')
|
||||
p++; /* move p before ':' */
|
||||
/* p will point to the start of the port */
|
||||
port = (int)strtol(p, NULL, 10);
|
||||
*pp = 0; /* null terminate host */
|
||||
}
|
||||
}
|
||||
/* resolve host, try ipv4 first, rslt is in network byte order */
|
||||
rv = ares_inet_pton(AF_INET, start_host, &in4);
|
||||
if (!rv) {
|
||||
/* Ok, try IPv6 then */
|
||||
rv = ares_inet_pton(AF_INET6, start_host, &in6);
|
||||
if (!rv) {
|
||||
rv = ARES_EBADSTR;
|
||||
goto out;
|
||||
}
|
||||
/* was ipv6, add new server */
|
||||
s = ares_malloc(sizeof(*s));
|
||||
if (!s) {
|
||||
rv = ARES_ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
s->family = AF_INET6;
|
||||
memcpy(&s->addr, &in6, sizeof(struct ares_in6_addr));
|
||||
}
|
||||
else {
|
||||
/* was ipv4, add new server */
|
||||
s = ares_malloc(sizeof(*s));
|
||||
if (!s) {
|
||||
rv = ARES_ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
s->family = AF_INET;
|
||||
memcpy(&s->addr, &in4, sizeof(struct in_addr));
|
||||
}
|
||||
if (s) {
|
||||
s->udp_port = use_port ? port: 0;
|
||||
s->tcp_port = s->udp_port;
|
||||
s->next = NULL;
|
||||
if (last) {
|
||||
last->next = s;
|
||||
/* need to move last to maintain the linked list */
|
||||
last = last->next;
|
||||
}
|
||||
else {
|
||||
servers = s;
|
||||
last = s;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set up for next one */
|
||||
start_host = ptr + 1;
|
||||
cc = 0;
|
||||
}
|
||||
}
|
||||
|
||||
rv = ares_set_servers_ports(channel, servers);
|
||||
|
||||
out:
|
||||
if (csv)
|
||||
ares_free(csv);
|
||||
while (servers) {
|
||||
struct ares_addr_port_node *s = servers;
|
||||
servers = servers->next;
|
||||
ares_free(s);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
int ares_set_servers_csv(ares_channel channel,
|
||||
const char* _csv)
|
||||
{
|
||||
return set_servers_csv(channel, _csv, FALSE);
|
||||
}
|
||||
|
||||
int ares_set_servers_ports_csv(ares_channel channel,
|
||||
const char* _csv)
|
||||
{
|
||||
return set_servers_csv(channel, _csv, TRUE);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright 1998 by the Massachusetts Institute of Technology.
|
||||
.\"
|
||||
@@ -23,7 +22,7 @@ ares_parse_a_reply \- Parse a reply to a DNS query of type A
|
||||
.PP
|
||||
.B int ares_parse_a_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP,
|
||||
.B struct hostent **\fIhost\fP,
|
||||
.B struct ares_addrttl *\fIaddrttls\fB, int *\fInaddrttls\fB);
|
||||
.B struct ares_addrttl *\fIaddrttls\fP, int *\fInaddrttls\fP);
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user