glib/tests: Clean up inclusion of unistd.h
[platform/upstream/glib.git] / gio / gnetworkservice.c
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2
3 /* GIO - GLib Input, Output and Streaming Library
4  *
5  * Copyright (C) 2008 Red Hat, Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General
18  * Public License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #include "config.h"
24 #include <glib.h>
25 #include "glibintl.h"
26
27 #include "gnetworkservice.h"
28
29 #include "gcancellable.h"
30 #include "ginetaddress.h"
31 #include "ginetsocketaddress.h"
32 #include "gioerror.h"
33 #include "gnetworkaddress.h"
34 #include "gnetworkingprivate.h"
35 #include "gresolver.h"
36 #include "gtask.h"
37 #include "gsocketaddressenumerator.h"
38 #include "gsocketconnectable.h"
39 #include "gsrvtarget.h"
40
41 #include <stdlib.h>
42 #include <string.h>
43
44
45 /**
46  * SECTION:gnetworkservice
47  * @short_description: A GSocketConnectable for resolving SRV records
48  * @include: gio/gio.h
49  *
50  * Like #GNetworkAddress does with hostnames, #GNetworkService
51  * provides an easy way to resolve a SRV record, and then attempt to
52  * connect to one of the hosts that implements that service, handling
53  * service priority/weighting, multiple IP addresses, and multiple
54  * address families.
55  *
56  * See #GSrvTarget for more information about SRV records, and see
57  * #GSocketConnectable for and example of using the connectable
58  * interface.
59  */
60
61 /**
62  * GNetworkService:
63  *
64  * A #GSocketConnectable for resolving a SRV record and connecting to
65  * that service.
66  */
67
68 struct _GNetworkServicePrivate
69 {
70   gchar *service, *protocol, *domain, *scheme;
71   GList *targets;
72 };
73
74 enum {
75   PROP_0,
76   PROP_SERVICE,
77   PROP_PROTOCOL,
78   PROP_DOMAIN,
79   PROP_SCHEME
80 };
81
82 static void g_network_service_set_property (GObject      *object,
83                                             guint         prop_id,
84                                             const GValue *value,
85                                             GParamSpec   *pspec);
86 static void g_network_service_get_property (GObject      *object,
87                                             guint         prop_id,
88                                             GValue       *value,
89                                             GParamSpec   *pspec);
90
91 static void                      g_network_service_connectable_iface_init       (GSocketConnectableIface *iface);
92 static GSocketAddressEnumerator *g_network_service_connectable_enumerate        (GSocketConnectable      *connectable);
93 static GSocketAddressEnumerator *g_network_service_connectable_proxy_enumerate  (GSocketConnectable      *connectable);
94
95 G_DEFINE_TYPE_WITH_CODE (GNetworkService, g_network_service, G_TYPE_OBJECT,
96                          G_ADD_PRIVATE (GNetworkService)
97                          G_IMPLEMENT_INTERFACE (G_TYPE_SOCKET_CONNECTABLE,
98                                                 g_network_service_connectable_iface_init))
99
100 static void
101 g_network_service_finalize (GObject *object)
102 {
103   GNetworkService *srv = G_NETWORK_SERVICE (object);
104
105   g_free (srv->priv->service);
106   g_free (srv->priv->protocol);
107   g_free (srv->priv->domain);
108   g_free (srv->priv->scheme);
109
110   if (srv->priv->targets)
111     g_resolver_free_targets (srv->priv->targets);
112
113   G_OBJECT_CLASS (g_network_service_parent_class)->finalize (object);
114 }
115
116 static void
117 g_network_service_class_init (GNetworkServiceClass *klass)
118 {
119   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
120
121   gobject_class->set_property = g_network_service_set_property;
122   gobject_class->get_property = g_network_service_get_property;
123   gobject_class->finalize = g_network_service_finalize;
124
125   g_object_class_install_property (gobject_class, PROP_SERVICE,
126                                    g_param_spec_string ("service",
127                                                         P_("Service"),
128                                                         P_("Service name, eg \"ldap\""),
129                                                         NULL,
130                                                         G_PARAM_READWRITE |
131                                                         G_PARAM_CONSTRUCT_ONLY |
132                                                         G_PARAM_STATIC_STRINGS));
133   g_object_class_install_property (gobject_class, PROP_PROTOCOL,
134                                    g_param_spec_string ("protocol",
135                                                         P_("Protocol"),
136                                                         P_("Network protocol, eg \"tcp\""),
137                                                         NULL,
138                                                         G_PARAM_READWRITE |
139                                                         G_PARAM_CONSTRUCT_ONLY |
140                                                         G_PARAM_STATIC_STRINGS));
141   g_object_class_install_property (gobject_class, PROP_DOMAIN,
142                                    g_param_spec_string ("domain",
143                                                         P_("Domain"),
144                                                         P_("Network domain, eg, \"example.com\""),
145                                                         NULL,
146                                                         G_PARAM_READWRITE |
147                                                         G_PARAM_CONSTRUCT_ONLY |
148                                                         G_PARAM_STATIC_STRINGS));
149   g_object_class_install_property (gobject_class, PROP_DOMAIN,
150                                    g_param_spec_string ("scheme",
151                                                         P_("Scheme"),
152                                                         P_("Network scheme (default is to use service)"),
153                                                         NULL,
154                                                         G_PARAM_READWRITE |
155                                                         G_PARAM_STATIC_STRINGS));
156
157 }
158
159 static void
160 g_network_service_connectable_iface_init (GSocketConnectableIface *connectable_iface)
161 {
162   connectable_iface->enumerate = g_network_service_connectable_enumerate;
163   connectable_iface->proxy_enumerate = g_network_service_connectable_proxy_enumerate;
164 }
165
166 static void
167 g_network_service_init (GNetworkService *srv)
168 {
169   srv->priv = g_network_service_get_instance_private (srv);
170 }
171
172 static void
173 g_network_service_set_property (GObject      *object,
174                                 guint         prop_id,
175                                 const GValue *value,
176                                 GParamSpec   *pspec)
177 {
178   GNetworkService *srv = G_NETWORK_SERVICE (object);
179
180   switch (prop_id)
181     {
182     case PROP_SERVICE:
183       srv->priv->service = g_value_dup_string (value);
184       break;
185
186     case PROP_PROTOCOL:
187       srv->priv->protocol = g_value_dup_string (value);
188       break;
189
190     case PROP_DOMAIN:
191       srv->priv->domain = g_value_dup_string (value);
192       break;
193
194     case PROP_SCHEME:
195       g_network_service_set_scheme (srv, g_value_get_string (value));
196       break;
197
198     default:
199       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
200       break;
201     }
202 }
203
204 static void
205 g_network_service_get_property (GObject    *object,
206                                 guint       prop_id,
207                                 GValue     *value,
208                                 GParamSpec *pspec)
209 {
210   GNetworkService *srv = G_NETWORK_SERVICE (object);
211
212   switch (prop_id)
213     {
214     case PROP_SERVICE:
215       g_value_set_string (value, g_network_service_get_service (srv));
216       break;
217
218     case PROP_PROTOCOL:
219       g_value_set_string (value, g_network_service_get_protocol (srv));
220       break;
221
222     case PROP_DOMAIN:
223       g_value_set_string (value, g_network_service_get_domain (srv));
224       break;
225
226     case PROP_SCHEME:
227       g_value_set_string (value, g_network_service_get_scheme (srv));
228       break;
229
230     default:
231       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
232       break;
233     }
234 }
235
236 /**
237  * g_network_service_new:
238  * @service: the service type to look up (eg, "ldap")
239  * @protocol: the networking protocol to use for @service (eg, "tcp")
240  * @domain: the DNS domain to look up the service in
241  *
242  * Creates a new #GNetworkService representing the given @service,
243  * @protocol, and @domain. This will initially be unresolved; use the
244  * #GSocketConnectable interface to resolve it.
245  *
246  * Return value: (transfer full) (type GNetworkService): a new #GNetworkService
247  *
248  * Since: 2.22
249  */
250 GSocketConnectable *
251 g_network_service_new (const gchar *service,
252                        const gchar *protocol,
253                        const gchar *domain)
254 {
255   return g_object_new (G_TYPE_NETWORK_SERVICE,
256                        "service", service,
257                        "protocol", protocol,
258                        "domain", domain,
259                        NULL);
260 }
261
262 /**
263  * g_network_service_get_service:
264  * @srv: a #GNetworkService
265  *
266  * Gets @srv's service name (eg, "ldap").
267  *
268  * Return value: @srv's service name
269  *
270  * Since: 2.22
271  */
272 const gchar *
273 g_network_service_get_service (GNetworkService *srv)
274 {
275   g_return_val_if_fail (G_IS_NETWORK_SERVICE (srv), NULL);
276
277   return srv->priv->service;
278 }
279
280 /**
281  * g_network_service_get_protocol:
282  * @srv: a #GNetworkService
283  *
284  * Gets @srv's protocol name (eg, "tcp").
285  *
286  * Return value: @srv's protocol name
287  *
288  * Since: 2.22
289  */
290 const gchar *
291 g_network_service_get_protocol (GNetworkService *srv)
292 {
293   g_return_val_if_fail (G_IS_NETWORK_SERVICE (srv), NULL);
294
295   return srv->priv->protocol;
296 }
297
298 /**
299  * g_network_service_get_domain:
300  * @srv: a #GNetworkService
301  *
302  * Gets the domain that @srv serves. This might be either UTF-8 or
303  * ASCII-encoded, depending on what @srv was created with.
304  *
305  * Return value: @srv's domain name
306  *
307  * Since: 2.22
308  */
309 const gchar *
310 g_network_service_get_domain (GNetworkService *srv)
311 {
312   g_return_val_if_fail (G_IS_NETWORK_SERVICE (srv), NULL);
313
314   return srv->priv->domain;
315 }
316
317 /**
318  * g_network_service_get_scheme:
319  * @srv: a #GNetworkService
320  *
321  * Get's the URI scheme used to resolve proxies. By default, the service name
322  * is used as scheme.
323  *
324  * Return value: @srv's scheme name
325  *
326  * Since: 2.26
327  */
328 const gchar *
329 g_network_service_get_scheme (GNetworkService *srv)
330 {
331   g_return_val_if_fail (G_IS_NETWORK_SERVICE (srv), NULL);
332
333   if (srv->priv->scheme)
334     return srv->priv->scheme;
335   else
336     return srv->priv->service;
337 }
338
339 /**
340  * g_network_service_set_scheme:
341  * @srv: a #GNetworkService
342  * @scheme: a URI scheme
343  *
344  * Set's the URI scheme used to resolve proxies. By default, the service name
345  * is used as scheme.
346  *
347  * Since: 2.26
348  */
349 void
350 g_network_service_set_scheme (GNetworkService *srv,
351                               const gchar     *scheme)
352 {
353   g_return_if_fail (G_IS_NETWORK_SERVICE (srv));
354
355   if (srv->priv->scheme)
356     g_free (srv->priv->scheme);
357   srv->priv->scheme = g_strdup (scheme);
358
359   g_object_notify (G_OBJECT (srv), "scheme");
360 }
361
362 static GList *
363 g_network_service_fallback_targets (GNetworkService *srv)
364 {
365   GSrvTarget *target;
366   struct servent *entry;
367   guint16 port;
368
369   entry = getservbyname (srv->priv->service, "tcp");
370   port = entry ? g_ntohs (entry->s_port) : 0;
371 #ifdef HAVE_ENDSERVENT
372   endservent ();
373 #endif
374
375   if (entry == NULL)
376       return NULL;
377
378   target = g_srv_target_new (srv->priv->domain, port, 0, 0);
379   return g_list_append (NULL, target);
380 }
381
382 #define G_TYPE_NETWORK_SERVICE_ADDRESS_ENUMERATOR (_g_network_service_address_enumerator_get_type ())
383 #define G_NETWORK_SERVICE_ADDRESS_ENUMERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_NETWORK_SERVICE_ADDRESS_ENUMERATOR, GNetworkServiceAddressEnumerator))
384
385 typedef struct {
386   GSocketAddressEnumerator parent_instance;
387
388   GResolver *resolver;
389   GNetworkService *srv;
390   GSocketAddressEnumerator *addr_enum;
391   GList *t;
392   gboolean use_proxy;
393
394   GError *error;
395
396 } GNetworkServiceAddressEnumerator;
397
398 typedef struct {
399   GSocketAddressEnumeratorClass parent_class;
400
401 } GNetworkServiceAddressEnumeratorClass;
402
403 static GType _g_network_service_address_enumerator_get_type (void);
404 G_DEFINE_TYPE (GNetworkServiceAddressEnumerator, _g_network_service_address_enumerator, G_TYPE_SOCKET_ADDRESS_ENUMERATOR)
405
406 static GSocketAddress *
407 g_network_service_address_enumerator_next (GSocketAddressEnumerator  *enumerator,
408                                            GCancellable              *cancellable,
409                                            GError                   **error)
410 {
411   GNetworkServiceAddressEnumerator *srv_enum =
412     G_NETWORK_SERVICE_ADDRESS_ENUMERATOR (enumerator);
413   GSocketAddress *ret = NULL;
414
415   /* If we haven't yet resolved srv, do that */
416   if (!srv_enum->srv->priv->targets)
417     {
418       GList *targets;
419       GError *my_error = NULL;
420
421       targets = g_resolver_lookup_service (srv_enum->resolver,
422                                            srv_enum->srv->priv->service,
423                                            srv_enum->srv->priv->protocol,
424                                            srv_enum->srv->priv->domain,
425                                            cancellable, &my_error);
426       if (!targets && g_error_matches (my_error, G_RESOLVER_ERROR,
427                                        G_RESOLVER_ERROR_NOT_FOUND))
428         {
429           targets = g_network_service_fallback_targets (srv_enum->srv);
430           if (targets)
431             g_clear_error (&my_error);
432         }
433
434       if (my_error)
435         {
436           g_propagate_error (error, my_error);
437           return NULL;
438         }
439
440       srv_enum->srv->priv->targets = targets;
441       srv_enum->t = srv_enum->srv->priv->targets;
442     }
443
444   /* Delegate to GNetworkAddress */
445   do
446     {
447       if (srv_enum->addr_enum == NULL && srv_enum->t)
448         {
449           GError *error = NULL;
450           gchar *uri;
451           gchar *hostname;
452           GSocketConnectable *addr;
453           GSrvTarget *target = srv_enum->t->data;
454
455           srv_enum->t = g_list_next (srv_enum->t);
456
457           hostname = g_hostname_to_ascii (g_srv_target_get_hostname (target));
458
459           if (hostname == NULL)
460             {
461               if (srv_enum->error == NULL)
462                 srv_enum->error =
463                   g_error_new (G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
464                                "Received invalid hostname '%s' from GSrvTarget",
465                                g_srv_target_get_hostname (target));
466               continue;
467             }
468
469           uri = _g_uri_from_authority (g_network_service_get_scheme (srv_enum->srv),
470                                        hostname,
471                                        g_srv_target_get_port (target),
472                                        NULL);
473           g_free (hostname);
474
475           addr = g_network_address_parse_uri (uri,
476                                               g_srv_target_get_port (target),
477                                               &error);
478           g_free (uri);
479
480           if (addr == NULL)
481             {
482               if (srv_enum->error == NULL)
483                 srv_enum->error = error;
484               continue;
485             }
486
487           if (srv_enum->use_proxy)
488             srv_enum->addr_enum = g_socket_connectable_proxy_enumerate (addr);
489           else
490             srv_enum->addr_enum = g_socket_connectable_enumerate (addr);
491           g_object_unref (addr);
492         }
493
494       if (srv_enum->addr_enum)
495         {
496           GError *error = NULL;
497
498           ret = g_socket_address_enumerator_next (srv_enum->addr_enum,
499                                                   cancellable,
500                                                   &error);
501
502           if (error)
503             {
504               if (srv_enum->error == NULL)
505                 srv_enum->error = error;
506               else
507                 g_error_free (error);
508             }
509
510           if (!ret)
511             {
512               g_object_unref (srv_enum->addr_enum);
513               srv_enum->addr_enum = NULL;
514             }
515         }
516     }
517   while (srv_enum->addr_enum == NULL && srv_enum->t);
518
519   if (ret == NULL && srv_enum->error)
520     {
521       g_propagate_error (error, srv_enum->error);
522       srv_enum->error = NULL;
523     }
524
525   return ret;
526 }
527
528 static void next_async_resolved_targets   (GObject      *source_object,
529                                            GAsyncResult *result,
530                                            gpointer      user_data);
531 static void next_async_have_targets       (GTask        *srv_enum);
532 static void next_async_have_address       (GObject      *source_object,
533                                            GAsyncResult *result,
534                                            gpointer      user_data);
535
536 static void
537 g_network_service_address_enumerator_next_async (GSocketAddressEnumerator  *enumerator,
538                                                  GCancellable              *cancellable,
539                                                  GAsyncReadyCallback        callback,
540                                                  gpointer                   user_data)
541 {
542   GNetworkServiceAddressEnumerator *srv_enum =
543     G_NETWORK_SERVICE_ADDRESS_ENUMERATOR (enumerator);
544   GTask *task;
545
546   task = g_task_new (enumerator, cancellable, callback, user_data);
547
548   /* If we haven't yet resolved srv, do that */
549   if (!srv_enum->srv->priv->targets)
550     {
551       g_resolver_lookup_service_async (srv_enum->resolver,
552                                        srv_enum->srv->priv->service,
553                                        srv_enum->srv->priv->protocol,
554                                        srv_enum->srv->priv->domain,
555                                        cancellable,
556                                        next_async_resolved_targets,
557                                        task);
558     }
559   else
560     next_async_have_targets (task);
561 }
562
563 static void
564 next_async_resolved_targets (GObject      *source_object,
565                              GAsyncResult *result,
566                              gpointer      user_data)
567 {
568   GTask *task = user_data;
569   GNetworkServiceAddressEnumerator *srv_enum = g_task_get_source_object (task);
570   GError *error = NULL;
571   GList *targets;
572
573   targets = g_resolver_lookup_service_finish (srv_enum->resolver,
574                                               result, &error);
575
576   if (!targets && g_error_matches (error, G_RESOLVER_ERROR,
577                                    G_RESOLVER_ERROR_NOT_FOUND))
578     {
579       targets = g_network_service_fallback_targets (srv_enum->srv);
580       if (targets)
581         g_clear_error (&error);
582     }
583
584   if (error)
585     {
586       g_task_return_error (task, error);
587       g_object_unref (task);
588     }
589   else
590     {
591       srv_enum->t = srv_enum->srv->priv->targets = targets;
592       next_async_have_targets (task);
593     }
594 }
595
596 static void
597 next_async_have_targets (GTask *task)
598 {
599   GNetworkServiceAddressEnumerator *srv_enum = g_task_get_source_object (task);
600
601   /* Delegate to GNetworkAddress */
602   if (srv_enum->addr_enum == NULL && srv_enum->t)
603     {
604       GSocketConnectable *addr;
605       GSrvTarget *target = srv_enum->t->data;
606
607       srv_enum->t = g_list_next (srv_enum->t);
608       addr = g_network_address_new (g_srv_target_get_hostname (target),
609                                     (guint16) g_srv_target_get_port (target));
610
611       if (srv_enum->use_proxy)
612         srv_enum->addr_enum = g_socket_connectable_proxy_enumerate (addr);
613       else
614         srv_enum->addr_enum = g_socket_connectable_enumerate (addr);
615
616       g_object_unref (addr);
617     }
618
619   if (srv_enum->addr_enum)
620     {
621       g_socket_address_enumerator_next_async (srv_enum->addr_enum,
622                                               g_task_get_cancellable (task),
623                                               next_async_have_address,
624                                               task);
625     }
626   else
627     {
628       if (srv_enum->error)
629         {
630           g_task_return_error (task, srv_enum->error);
631           srv_enum->error = NULL;
632         }
633       else
634         g_task_return_pointer (task, NULL, NULL);
635
636       g_object_unref (task);
637     }
638 }
639
640 static void
641 next_async_have_address (GObject      *source_object,
642                          GAsyncResult *result,
643                          gpointer      user_data)
644 {
645   GTask *task = user_data;
646   GNetworkServiceAddressEnumerator *srv_enum = g_task_get_source_object (task);
647   GSocketAddress *address;
648   GError *error = NULL;
649   
650   address = g_socket_address_enumerator_next_finish (srv_enum->addr_enum,
651                                                      result,
652                                                      &error);
653
654   if (error)
655     {
656       if (srv_enum->error == NULL)
657         srv_enum->error = error;
658       else
659         g_error_free (error);
660     }
661
662   if (!address)
663     {
664       g_object_unref (srv_enum->addr_enum);
665       srv_enum->addr_enum = NULL;
666
667       next_async_have_targets (task);
668     }
669   else
670     {
671       g_task_return_pointer (task, address, g_object_unref);
672       g_object_unref (task);
673     }
674 }
675
676 static GSocketAddress *
677 g_network_service_address_enumerator_next_finish (GSocketAddressEnumerator  *enumerator,
678                                                   GAsyncResult              *result,
679                                                   GError                   **error)
680 {
681   return g_task_propagate_pointer (G_TASK (result), error);
682 }
683
684 static void
685 _g_network_service_address_enumerator_init (GNetworkServiceAddressEnumerator *enumerator)
686 {
687 }
688
689 static void
690 g_network_service_address_enumerator_finalize (GObject *object)
691 {
692   GNetworkServiceAddressEnumerator *srv_enum =
693     G_NETWORK_SERVICE_ADDRESS_ENUMERATOR (object);
694
695   if (srv_enum->srv)
696     g_object_unref (srv_enum->srv);
697
698   if (srv_enum->addr_enum)
699     g_object_unref (srv_enum->addr_enum);
700
701   if (srv_enum->resolver)
702     g_object_unref (srv_enum->resolver);
703
704   if (srv_enum->error)
705     g_error_free (srv_enum->error);
706
707   G_OBJECT_CLASS (_g_network_service_address_enumerator_parent_class)->finalize (object);
708 }
709
710 static void
711 _g_network_service_address_enumerator_class_init (GNetworkServiceAddressEnumeratorClass *srvenum_class)
712 {
713   GObjectClass *object_class = G_OBJECT_CLASS (srvenum_class);
714   GSocketAddressEnumeratorClass *enumerator_class =
715     G_SOCKET_ADDRESS_ENUMERATOR_CLASS (srvenum_class);
716
717   enumerator_class->next        = g_network_service_address_enumerator_next;
718   enumerator_class->next_async  = g_network_service_address_enumerator_next_async;
719   enumerator_class->next_finish = g_network_service_address_enumerator_next_finish;
720
721   object_class->finalize = g_network_service_address_enumerator_finalize;
722 }
723
724 static GSocketAddressEnumerator *
725 g_network_service_connectable_enumerate (GSocketConnectable *connectable)
726 {
727   GNetworkServiceAddressEnumerator *srv_enum;
728
729   srv_enum = g_object_new (G_TYPE_NETWORK_SERVICE_ADDRESS_ENUMERATOR, NULL);
730   srv_enum->srv = g_object_ref (connectable);
731   srv_enum->resolver = g_resolver_get_default ();
732   srv_enum->use_proxy = FALSE;
733
734   return G_SOCKET_ADDRESS_ENUMERATOR (srv_enum);
735 }
736
737 static GSocketAddressEnumerator *
738 g_network_service_connectable_proxy_enumerate (GSocketConnectable *connectable)
739 {
740   GSocketAddressEnumerator *addr_enum;
741   GNetworkServiceAddressEnumerator *srv_enum;
742
743   addr_enum = g_network_service_connectable_enumerate (connectable);
744   srv_enum = G_NETWORK_SERVICE_ADDRESS_ENUMERATOR (addr_enum);
745   srv_enum->use_proxy = TRUE;
746
747   return addr_enum;
748 }