author | Frank Zschockelt <lm@freakysoft.de> |
Mon, 13 May 2019 22:09:10 +0200 | |
changeset 739 | 4a32df98ff8c |
parent 712 | ba47719252ad |
child 744 | 4ebe32453682 |
permissions | -rw-r--r-- |
516
4dd3aa6b83e5
Change the tab width to 4 steps in the emacs headers
Mikael Hallendal <micke@imendio.com>
parents:
515
diff
changeset
|
1 |
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
457 | 2 |
/* |
3 |
* Copyright (C) 2008 Imendio AB |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU Lesser General Public License as |
|
7 |
* published by the Free Software Foundation; either version 2 of the |
|
8 |
* License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 |
* Lesser General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU Lesser General Public |
|
690
7ccf2113ec5f
Update the postal address of the FSF
Frank Zschockelt <lm@freakysoft.de>
parents:
670
diff
changeset
|
16 |
* License along with this program; if not, see <https://www.gnu.org/licenses> |
457 | 17 |
*/ |
18 |
||
19 |
#include <config.h> |
|
20 |
||
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
21 |
#include <string.h> |
616
b853d91bc249
Remove internal asyncns
Frank Zschockelt <lm@freakysoft.de>
parents:
614
diff
changeset
|
22 |
#ifdef HAVE_ASYNCNS |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
23 |
#include <asyncns.h> |
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
24 |
#define freeaddrinfo(x) asyncns_freeaddrinfo(x) |
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
25 |
|
473
2006c0c0a63d
More work on the asyncns srv lookup.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
26 |
/* Needed on Mac OS X */ |
2006c0c0a63d
More work on the asyncns srv lookup.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
27 |
#if HAVE_ARPA_NAMESER_COMPAT_H |
2006c0c0a63d
More work on the asyncns srv lookup.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
28 |
#include <arpa/nameser_compat.h> |
2006c0c0a63d
More work on the asyncns srv lookup.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
29 |
#endif |
2006c0c0a63d
More work on the asyncns srv lookup.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
30 |
|
2006c0c0a63d
More work on the asyncns srv lookup.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
31 |
#include <arpa/nameser.h> |
2006c0c0a63d
More work on the asyncns srv lookup.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
32 |
#include <resolv.h> |
2006c0c0a63d
More work on the asyncns srv lookup.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
33 |
|
611
1535ce921a7a
Replace g_print with g_log in asyncns-resolver:
Frank Zschockelt <lm@freakysoft.de>
parents:
607
diff
changeset
|
34 |
#include "lm-debug.h" |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
35 |
#include "lm-error.h" |
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
36 |
#include "lm-internals.h" |
457 | 37 |
#include "lm-marshal.h" |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
38 |
#include "lm-misc.h" |
457 | 39 |
#include "lm-asyncns-resolver.h" |
40 |
||
739
4a32df98ff8c
g_type_class_add_private is deprecated since glib 2.58
Frank Zschockelt <lm@freakysoft.de>
parents:
712
diff
changeset
|
41 |
#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), LM_TYPE_ASYNCNS_RESOLVER, LmAsyncnsResolverPrivate)) |
457 | 42 |
|
739
4a32df98ff8c
g_type_class_add_private is deprecated since glib 2.58
Frank Zschockelt <lm@freakysoft.de>
parents:
712
diff
changeset
|
43 |
typedef struct LmAsyncnsResolverPrivate LmAsyncnsResolverPrivate; |
4a32df98ff8c
g_type_class_add_private is deprecated since glib 2.58
Frank Zschockelt <lm@freakysoft.de>
parents:
712
diff
changeset
|
44 |
struct LmAsyncnsResolverPrivate { |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
45 |
GSource *watch_resolv; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
46 |
asyncns_query_t *resolv_query; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
47 |
asyncns_t *asyncns_ctx; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
48 |
GIOChannel *resolv_channel; |
457 | 49 |
}; |
50 |
||
712
ba47719252ad
lm-asyncns-resolver: Fix resolver uninitialization
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
51 |
static void asyncns_resolver_dispose (GObject *object); |
457 | 52 |
static void asyncns_resolver_lookup (LmResolver *resolver); |
712
ba47719252ad
lm-asyncns-resolver: Fix resolver uninitialization
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
53 |
static void asyncns_resolver_cleanup (LmResolver *resolver); |
457 | 54 |
static void asyncns_resolver_cancel (LmResolver *resolver); |
55 |
||
739
4a32df98ff8c
g_type_class_add_private is deprecated since glib 2.58
Frank Zschockelt <lm@freakysoft.de>
parents:
712
diff
changeset
|
56 |
G_DEFINE_TYPE_WITH_PRIVATE (LmAsyncnsResolver, lm_asyncns_resolver, LM_TYPE_RESOLVER) |
457 | 57 |
|
58 |
static void |
|
59 |
lm_asyncns_resolver_class_init (LmAsyncnsResolverClass *class) |
|
60 |
{ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
61 |
GObjectClass *object_class = G_OBJECT_CLASS (class); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
62 |
LmResolverClass *resolver_class = LM_RESOLVER_CLASS (class); |
457 | 63 |
|
712
ba47719252ad
lm-asyncns-resolver: Fix resolver uninitialization
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
64 |
object_class->dispose = asyncns_resolver_dispose; |
457 | 65 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
66 |
resolver_class->lookup = asyncns_resolver_lookup; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
67 |
resolver_class->cancel = asyncns_resolver_cancel; |
457 | 68 |
} |
69 |
||
70 |
static void |
|
71 |
lm_asyncns_resolver_init (LmAsyncnsResolver *asyncns_resolver) |
|
72 |
{ |
|
73 |
} |
|
74 |
||
75 |
static void |
|
712
ba47719252ad
lm-asyncns-resolver: Fix resolver uninitialization
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
76 |
asyncns_resolver_dispose (GObject *object) |
457 | 77 |
{ |
712
ba47719252ad
lm-asyncns-resolver: Fix resolver uninitialization
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
78 |
g_return_if_fail (LM_IS_ASYNCNS_RESOLVER (object)); |
457 | 79 |
|
712
ba47719252ad
lm-asyncns-resolver: Fix resolver uninitialization
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
80 |
asyncns_resolver_cleanup (LM_RESOLVER(object)); |
ba47719252ad
lm-asyncns-resolver: Fix resolver uninitialization
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
81 |
|
ba47719252ad
lm-asyncns-resolver: Fix resolver uninitialization
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
82 |
(G_OBJECT_CLASS (lm_asyncns_resolver_parent_class)->dispose) (object); |
457 | 83 |
} |
84 |
||
85 |
static void |
|
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
86 |
asyncns_resolver_cleanup (LmResolver *resolver) |
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
87 |
{ |
739
4a32df98ff8c
g_type_class_add_private is deprecated since glib 2.58
Frank Zschockelt <lm@freakysoft.de>
parents:
712
diff
changeset
|
88 |
LmAsyncnsResolverPrivate *priv = GET_PRIV (resolver); |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
89 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
90 |
if (priv->resolv_channel != NULL) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
91 |
g_io_channel_unref (priv->resolv_channel); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
92 |
priv->resolv_channel = NULL; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
93 |
} |
607 | 94 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
95 |
if (priv->watch_resolv) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
96 |
g_source_destroy (priv->watch_resolv); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
97 |
priv->watch_resolv = NULL; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
98 |
} |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
99 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
100 |
if (priv->asyncns_ctx) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
101 |
asyncns_free (priv->asyncns_ctx); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
102 |
priv->asyncns_ctx = NULL; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
103 |
} |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
104 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
105 |
priv->resolv_query = NULL; |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
106 |
} |
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
107 |
|
477
09fe238533b9
Put a ref on the resolver while calling the callback.
Mikael Hallendal <micke@imendio.com>
parents:
475
diff
changeset
|
108 |
static void |
474
b4eff3e1235c
Fixed so that service lookup seems to work with new asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
473
diff
changeset
|
109 |
asyncns_resolver_done (LmResolver *resolver) |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
110 |
{ |
739
4a32df98ff8c
g_type_class_add_private is deprecated since glib 2.58
Frank Zschockelt <lm@freakysoft.de>
parents:
712
diff
changeset
|
111 |
LmAsyncnsResolverPrivate *priv = GET_PRIV (resolver); |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
112 |
struct addrinfo *ans; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
113 |
int err; |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
114 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
115 |
err = asyncns_getaddrinfo_done (priv->asyncns_ctx, priv->resolv_query, &ans); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
116 |
priv->resolv_query = NULL; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
117 |
/* Signal that we are done */ |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
118 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
119 |
g_object_ref (resolver); |
477
09fe238533b9
Put a ref on the resolver while calling the callback.
Mikael Hallendal <micke@imendio.com>
parents:
475
diff
changeset
|
120 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
121 |
if (err) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
122 |
_lm_resolver_set_result (resolver, |
607 | 123 |
LM_RESOLVER_RESULT_FAILED, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
124 |
NULL); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
125 |
} else { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
126 |
_lm_resolver_set_result (resolver, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
127 |
LM_RESOLVER_RESULT_OK, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
128 |
ans); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
129 |
} |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
130 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
131 |
asyncns_resolver_cleanup (resolver); |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
132 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
133 |
g_object_unref (resolver); |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
134 |
} |
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
135 |
|
474
b4eff3e1235c
Fixed so that service lookup seems to work with new asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
473
diff
changeset
|
136 |
typedef gboolean (* LmAsyncnsResolverCallback) (LmResolver *resolver); |
b4eff3e1235c
Fixed so that service lookup seems to work with new asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
473
diff
changeset
|
137 |
|
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
138 |
static gboolean |
474
b4eff3e1235c
Fixed so that service lookup seems to work with new asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
473
diff
changeset
|
139 |
asyncns_resolver_io_cb (GSource *source, |
b4eff3e1235c
Fixed so that service lookup seems to work with new asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
473
diff
changeset
|
140 |
GIOCondition condition, |
b4eff3e1235c
Fixed so that service lookup seems to work with new asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
473
diff
changeset
|
141 |
LmResolver *resolver) |
b4eff3e1235c
Fixed so that service lookup seems to work with new asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
473
diff
changeset
|
142 |
{ |
739
4a32df98ff8c
g_type_class_add_private is deprecated since glib 2.58
Frank Zschockelt <lm@freakysoft.de>
parents:
712
diff
changeset
|
143 |
LmAsyncnsResolverPrivate *priv = GET_PRIV (resolver); |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
144 |
LmAsyncnsResolverCallback func; |
474
b4eff3e1235c
Fixed so that service lookup seems to work with new asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
473
diff
changeset
|
145 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
146 |
asyncns_wait (priv->asyncns_ctx, FALSE); |
474
b4eff3e1235c
Fixed so that service lookup seems to work with new asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
473
diff
changeset
|
147 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
148 |
if (!asyncns_isdone (priv->asyncns_ctx, priv->resolv_query)) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
149 |
return TRUE; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
150 |
} |
474
b4eff3e1235c
Fixed so that service lookup seems to work with new asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
473
diff
changeset
|
151 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
152 |
func = (LmAsyncnsResolverCallback) asyncns_getuserdata (priv->asyncns_ctx, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
153 |
priv->resolv_query); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
154 |
return func (resolver); |
474
b4eff3e1235c
Fixed so that service lookup seems to work with new asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
473
diff
changeset
|
155 |
} |
b4eff3e1235c
Fixed so that service lookup seems to work with new asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
473
diff
changeset
|
156 |
|
b4eff3e1235c
Fixed so that service lookup seems to work with new asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
473
diff
changeset
|
157 |
static gboolean |
b4eff3e1235c
Fixed so that service lookup seems to work with new asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
473
diff
changeset
|
158 |
asyncns_resolver_prep (LmResolver *resolver, GError **error) |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
159 |
{ |
739
4a32df98ff8c
g_type_class_add_private is deprecated since glib 2.58
Frank Zschockelt <lm@freakysoft.de>
parents:
712
diff
changeset
|
160 |
LmAsyncnsResolverPrivate *priv = GET_PRIV (resolver); |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
161 |
GMainContext *context; |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
162 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
163 |
if (priv->asyncns_ctx) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
164 |
return TRUE; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
165 |
} |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
166 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
167 |
priv->asyncns_ctx = asyncns_new (1); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
168 |
if (priv->asyncns_ctx == NULL) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
169 |
g_set_error (error, |
607 | 170 |
LM_ERROR, |
171 |
LM_ERROR_CONNECTION_FAILED, |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
172 |
"can't initialise libasyncns"); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
173 |
return FALSE; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
174 |
} |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
175 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
176 |
priv->resolv_channel = |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
177 |
g_io_channel_unix_new (asyncns_fd (priv->asyncns_ctx)); |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
178 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
179 |
g_object_get (resolver, "context", &context, NULL); |
607 | 180 |
|
181 |
priv->watch_resolv = |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
182 |
lm_misc_add_io_watch (context, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
183 |
priv->resolv_channel, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
184 |
G_IO_IN, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
185 |
(GIOFunc) asyncns_resolver_io_cb, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
186 |
resolver); |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
187 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
188 |
return TRUE; |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
189 |
} |
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
190 |
|
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
191 |
static void |
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
192 |
asyncns_resolver_lookup_host (LmResolver *resolver) |
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
193 |
{ |
739
4a32df98ff8c
g_type_class_add_private is deprecated since glib 2.58
Frank Zschockelt <lm@freakysoft.de>
parents:
712
diff
changeset
|
194 |
LmAsyncnsResolverPrivate *priv = GET_PRIV (resolver); |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
195 |
gchar *host; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
196 |
struct addrinfo req; |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
197 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
198 |
g_object_get (resolver, "host", &host, NULL); |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
199 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
200 |
memset (&req, 0, sizeof(req)); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
201 |
req.ai_family = AF_UNSPEC; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
202 |
req.ai_socktype = SOCK_STREAM; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
203 |
req.ai_protocol = IPPROTO_TCP; |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
204 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
205 |
if (!asyncns_resolver_prep (resolver, NULL)) { |
614
773201ca404c
Replaced every g_warning() with g_log()
Mikael Berthe <mikael@lilotux.net>
parents:
611
diff
changeset
|
206 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, "Signal error\n"); |
670 | 207 |
g_free (host); |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
208 |
return; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
209 |
} |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
210 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
211 |
priv->resolv_query = |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
212 |
asyncns_getaddrinfo (priv->asyncns_ctx, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
213 |
host, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
214 |
NULL, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
215 |
&req); |
474
b4eff3e1235c
Fixed so that service lookup seems to work with new asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
473
diff
changeset
|
216 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
217 |
asyncns_setuserdata (priv->asyncns_ctx, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
218 |
priv->resolv_query, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
219 |
(gpointer) asyncns_resolver_done); |
670 | 220 |
|
221 |
g_free (host); |
|
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
222 |
} |
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
223 |
|
477
09fe238533b9
Put a ref on the resolver while calling the callback.
Mikael Hallendal <micke@imendio.com>
parents:
475
diff
changeset
|
224 |
static void |
474
b4eff3e1235c
Fixed so that service lookup seems to work with new asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
473
diff
changeset
|
225 |
asyncns_resolver_srv_done (LmResolver *resolver) |
473
2006c0c0a63d
More work on the asyncns srv lookup.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
226 |
{ |
739
4a32df98ff8c
g_type_class_add_private is deprecated since glib 2.58
Frank Zschockelt <lm@freakysoft.de>
parents:
712
diff
changeset
|
227 |
LmAsyncnsResolverPrivate *priv = GET_PRIV (resolver); |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
228 |
unsigned char *srv_ans; |
547
692c7753f64e
Improved the resolvers a bit.
Mikael Hallendal <micke@imendio.com>
parents:
518
diff
changeset
|
229 |
int srv_len; |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
230 |
gboolean result = FALSE; |
473
2006c0c0a63d
More work on the asyncns srv lookup.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
231 |
|
611
1535ce921a7a
Replace g_print with g_log in asyncns-resolver:
Frank Zschockelt <lm@freakysoft.de>
parents:
607
diff
changeset
|
232 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, "srv_done callback\n"); |
473
2006c0c0a63d
More work on the asyncns srv lookup.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
233 |
|
607 | 234 |
srv_len = asyncns_res_done (priv->asyncns_ctx, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
235 |
priv->resolv_query, &srv_ans); |
473
2006c0c0a63d
More work on the asyncns srv lookup.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
236 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
237 |
priv->resolv_query = NULL; |
473
2006c0c0a63d
More work on the asyncns srv lookup.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
238 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
239 |
if (srv_len <= 0) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
240 |
/* FIXME: Report error */ |
614
773201ca404c
Replaced every g_warning() with g_log()
Mikael Berthe <mikael@lilotux.net>
parents:
611
diff
changeset
|
241 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, |
773201ca404c
Replaced every g_warning() with g_log()
Mikael Berthe <mikael@lilotux.net>
parents:
611
diff
changeset
|
242 |
"Failed to read srv request results"); |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
243 |
} else { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
244 |
gchar *new_server; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
245 |
guint new_port; |
473
2006c0c0a63d
More work on the asyncns srv lookup.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
246 |
|
611
1535ce921a7a
Replace g_print with g_log in asyncns-resolver:
Frank Zschockelt <lm@freakysoft.de>
parents:
607
diff
changeset
|
247 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, |
1535ce921a7a
Replace g_print with g_log in asyncns-resolver:
Frank Zschockelt <lm@freakysoft.de>
parents:
607
diff
changeset
|
248 |
"trying to parse srv response\n"); |
474
b4eff3e1235c
Fixed so that service lookup seems to work with new asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
473
diff
changeset
|
249 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
250 |
result = _lm_resolver_parse_srv_response (srv_ans, srv_len, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
251 |
&new_server, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
252 |
&new_port); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
253 |
if (result == TRUE) { |
611
1535ce921a7a
Replace g_print with g_log in asyncns-resolver:
Frank Zschockelt <lm@freakysoft.de>
parents:
607
diff
changeset
|
254 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, |
1535ce921a7a
Replace g_print with g_log in asyncns-resolver:
Frank Zschockelt <lm@freakysoft.de>
parents:
607
diff
changeset
|
255 |
"worked, new host/post is %s/%d\n", |
1535ce921a7a
Replace g_print with g_log in asyncns-resolver:
Frank Zschockelt <lm@freakysoft.de>
parents:
607
diff
changeset
|
256 |
new_server, new_port); |
474
b4eff3e1235c
Fixed so that service lookup seems to work with new asyncns resolver.
Mikael Hallendal <micke@imendio.com>
parents:
473
diff
changeset
|
257 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
258 |
g_object_set (resolver, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
259 |
"host", new_server, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
260 |
"port", new_port, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
261 |
NULL); |
620
2e344ed4140b
Fix segfault in asyncns resolver
Mikael Berthe <mikael@lilotux.net>
parents:
616
diff
changeset
|
262 |
g_free (new_server); |
473
2006c0c0a63d
More work on the asyncns srv lookup.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
263 |
} |
2006c0c0a63d
More work on the asyncns srv lookup.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
264 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
265 |
/* TODO: Check whether srv_ans needs freeing */ |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
266 |
} |
473
2006c0c0a63d
More work on the asyncns srv lookup.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
267 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
268 |
asyncns_resolver_cleanup (resolver); |
607 | 269 |
|
606
14aa64152209
asyncns resolver: fail when the server doesn't have a SRV field.
Frank Zschockelt <lm@freakysoft.de>
parents:
561
diff
changeset
|
270 |
g_object_ref (resolver); |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
271 |
if (result == TRUE) { |
547
692c7753f64e
Improved the resolvers a bit.
Mikael Hallendal <micke@imendio.com>
parents:
518
diff
changeset
|
272 |
_lm_resolver_set_result (LM_RESOLVER (resolver), LM_RESOLVER_RESULT_OK, NULL); |
606
14aa64152209
asyncns resolver: fail when the server doesn't have a SRV field.
Frank Zschockelt <lm@freakysoft.de>
parents:
561
diff
changeset
|
273 |
} else { |
14aa64152209
asyncns resolver: fail when the server doesn't have a SRV field.
Frank Zschockelt <lm@freakysoft.de>
parents:
561
diff
changeset
|
274 |
_lm_resolver_set_result (LM_RESOLVER (resolver), LM_RESOLVER_RESULT_FAILED, NULL); |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
275 |
} |
606
14aa64152209
asyncns resolver: fail when the server doesn't have a SRV field.
Frank Zschockelt <lm@freakysoft.de>
parents:
561
diff
changeset
|
276 |
g_object_unref (resolver); |
473
2006c0c0a63d
More work on the asyncns srv lookup.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
277 |
} |
2006c0c0a63d
More work on the asyncns srv lookup.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
278 |
|
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
279 |
static void |
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
280 |
asyncns_resolver_lookup_service (LmResolver *resolver) |
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
281 |
{ |
739
4a32df98ff8c
g_type_class_add_private is deprecated since glib 2.58
Frank Zschockelt <lm@freakysoft.de>
parents:
712
diff
changeset
|
282 |
LmAsyncnsResolverPrivate *priv = GET_PRIV (resolver); |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
283 |
gchar *domain; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
284 |
gchar *service; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
285 |
gchar *protocol; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
286 |
gchar *srv; |
473
2006c0c0a63d
More work on the asyncns srv lookup.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
287 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
288 |
g_object_get (resolver, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
289 |
"domain", &domain, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
290 |
"service", &service, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
291 |
"protocol", &protocol, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
292 |
NULL); |
607 | 293 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
294 |
srv = _lm_resolver_create_srv_string (domain, service, protocol); |
607 | 295 |
|
611
1535ce921a7a
Replace g_print with g_log in asyncns-resolver:
Frank Zschockelt <lm@freakysoft.de>
parents:
607
diff
changeset
|
296 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, |
1535ce921a7a
Replace g_print with g_log in asyncns-resolver:
Frank Zschockelt <lm@freakysoft.de>
parents:
607
diff
changeset
|
297 |
"ASYNCNS: Looking up service: %s %s %s [%s]\n", |
1535ce921a7a
Replace g_print with g_log in asyncns-resolver:
Frank Zschockelt <lm@freakysoft.de>
parents:
607
diff
changeset
|
298 |
domain, service, protocol, srv); |
473
2006c0c0a63d
More work on the asyncns srv lookup.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
299 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
300 |
if (!asyncns_resolver_prep (resolver, /* Use GError? */ NULL)) { |
614
773201ca404c
Replaced every g_warning() with g_log()
Mikael Berthe <mikael@lilotux.net>
parents:
611
diff
changeset
|
301 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, |
773201ca404c
Replaced every g_warning() with g_log()
Mikael Berthe <mikael@lilotux.net>
parents:
611
diff
changeset
|
302 |
"Failed to initiate the asyncns library"); |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
303 |
/* FIXME: Signal error */ |
670 | 304 |
g_free (srv); |
305 |
g_free (domain); |
|
306 |
g_free (service); |
|
307 |
g_free (protocol); |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
308 |
return; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
309 |
} |
473
2006c0c0a63d
More work on the asyncns srv lookup.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
310 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
311 |
priv->resolv_query = |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
312 |
asyncns_res_query (priv->asyncns_ctx, srv, C_IN, T_SRV); |
607 | 313 |
|
314 |
asyncns_setuserdata (priv->asyncns_ctx, |
|
315 |
priv->resolv_query, |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
316 |
(gpointer) asyncns_resolver_srv_done); |
473
2006c0c0a63d
More work on the asyncns srv lookup.
Mikael Hallendal <micke@imendio.com>
parents:
472
diff
changeset
|
317 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
318 |
g_free (srv); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
319 |
g_free (domain); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
320 |
g_free (service); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
321 |
g_free (protocol); |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
322 |
} |
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
323 |
|
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
324 |
static void |
457 | 325 |
asyncns_resolver_lookup (LmResolver *resolver) |
326 |
{ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
327 |
gint type; |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
328 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
329 |
/* Start the DNS querying */ |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
330 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
331 |
/* Decide if we are going to lookup a srv or host */ |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
332 |
g_object_get (resolver, "type", &type, NULL); |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
333 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
334 |
switch (type) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
335 |
case LM_RESOLVER_HOST: |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
336 |
asyncns_resolver_lookup_host (resolver); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
337 |
break; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
338 |
case LM_RESOLVER_SRV: |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
339 |
asyncns_resolver_lookup_service (resolver); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
340 |
break; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
341 |
}; |
471
a7cf42557aef
Copied in code from LmOldSocket to LmAsyncnsResolver
Mikael Hallendal <micke@imendio.com>
parents:
457
diff
changeset
|
342 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
343 |
/* End of DNS querying */ |
607 | 344 |
} |
457 | 345 |
|
346 |
static void |
|
347 |
asyncns_resolver_cancel (LmResolver *resolver) |
|
348 |
{ |
|
739
4a32df98ff8c
g_type_class_add_private is deprecated since glib 2.58
Frank Zschockelt <lm@freakysoft.de>
parents:
712
diff
changeset
|
349 |
LmAsyncnsResolverPrivate *priv; |
475
001da49d7fd1
Added cancel operation for asyncns resolver
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
350 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
351 |
g_return_if_fail (LM_IS_ASYNCNS_RESOLVER (resolver)); |
475
001da49d7fd1
Added cancel operation for asyncns resolver
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
352 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
353 |
priv = GET_PRIV (resolver); |
475
001da49d7fd1
Added cancel operation for asyncns resolver
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
354 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
355 |
if (priv->asyncns_ctx) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
356 |
if (priv->resolv_query) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
357 |
asyncns_cancel (priv->asyncns_ctx, priv->resolv_query); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
358 |
priv->resolv_query = NULL; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
359 |
} |
475
001da49d7fd1
Added cancel operation for asyncns resolver
Mikael Hallendal <micke@imendio.com>
parents:
474
diff
changeset
|
360 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
361 |
_lm_resolver_set_result (resolver, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
362 |
LM_RESOLVER_RESULT_CANCELLED, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
363 |
NULL); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
364 |
} |
457 | 365 |
} |
366 |
||
616
b853d91bc249
Remove internal asyncns
Frank Zschockelt <lm@freakysoft.de>
parents:
614
diff
changeset
|
367 |
#endif //HAVE_ASYNCNS |