~vorlon/ubuntu/natty/avahi/multiarch

« back to all changes in this revision

Viewing changes to avahi-core/resolve-address.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2009-05-06 14:04:57 UTC
  • mfrom: (4.1.13 sid)
  • Revision ID: james.westby@ubuntu.com-20090506140457-72h3msg32nuc4j7v
Tags: 0.6.27-2ubuntu1
* Merge from Debian unstable, remaining Ubuntu changes:
* debian/control:
  - Remove linux-any as it is not yet supported by Soyuz
  - Add versioned dependency on the dbus that satisfies our upstart job
    dependency.
  - Add udebs corresponding to libavahi-common3 and libavahi-core6, so that
    we can use them for Eucalyptus integration in the installer.
  - Recommend dhcp3-client instead of isc-dhcp-client (not yet available in
    Ubuntu)
* debian/rules:
* debian/avahi-daemon.init:
* debian/avahi-dnsconfd.init:
  - Avahi init scripts (daemon or dnsconfd) do not need to
    be started before gdm, and do not need to be stopped specially on
    shutdown.
* debian/avahi-daemon.postinst:
* debian/avahi-dnsconfd.postinst:
  - Use Ubuntu versions for migration scripts
* debian/avahi-autoipd.preinst:
* debian/avahi-autoipd.install:
* debian/avahi-autoipd.postinst:
* debian/avahi-autoipd.postrm:
  - Disable DHCP 3 to 4 migration (not yet in Ubuntu)
* debian/avahi-daemon.upstart:
* debian/avahi-dnsconfd.upstart:
  - Add Upstart config
* debian/patches/03_gir_1.1.patch:
  - Compile with the latest Gobject introspection

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id$ */
2
 
 
3
1
/***
4
2
  This file is part of avahi.
5
 
 
 
3
 
6
4
  avahi is free software; you can redistribute it and/or modify it
7
5
  under the terms of the GNU Lesser General Public License as
8
6
  published by the Free Software Foundation; either version 2.1 of the
9
7
  License, or (at your option) any later version.
10
 
 
 
8
 
11
9
  avahi is distributed in the hope that it will be useful, but WITHOUT
12
10
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13
11
  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14
12
  Public License for more details.
15
 
 
 
13
 
16
14
  You should have received a copy of the GNU Lesser General Public
17
15
  License along with avahi; if not, write to the Free Software
18
16
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
37
35
struct AvahiSAddressResolver {
38
36
    AvahiServer *server;
39
37
    AvahiAddress address;
40
 
    
 
38
 
41
39
    AvahiSRecordBrowser *record_browser;
42
40
 
43
41
    AvahiSAddressResolverCallback callback;
58
56
 
59
57
static void finish(AvahiSAddressResolver *r, AvahiResolverEvent event) {
60
58
    assert(r);
61
 
    
 
59
 
62
60
    if (r->time_event) {
63
61
        avahi_time_event_free(r->time_event);
64
62
        r->time_event = NULL;
78
76
 
79
77
static void time_event_callback(AvahiTimeEvent *e, void *userdata) {
80
78
    AvahiSAddressResolver *r = userdata;
81
 
    
 
79
 
82
80
    assert(e);
83
81
    assert(r);
84
82
 
105
103
    AvahiRecord *record,
106
104
    AvahiLookupResultFlags flags,
107
105
    void* userdata) {
108
 
    
 
106
 
109
107
    AvahiSAddressResolver *r = userdata;
110
108
 
111
109
    assert(rr);
112
110
    assert(r);
113
111
 
114
112
    switch (event) {
115
 
        case AVAHI_BROWSER_NEW: 
 
113
        case AVAHI_BROWSER_NEW:
116
114
            assert(record);
117
115
            assert(record->key->type == AVAHI_DNS_TYPE_PTR);
118
 
            
 
116
 
119
117
            if (r->interface > 0 && interface != r->interface)
120
118
                return;
121
 
            
 
119
 
122
120
            if (r->protocol != AVAHI_PROTO_UNSPEC && protocol != r->protocol)
123
121
                return;
124
 
            
 
122
 
125
123
            if (r->interface <= 0)
126
124
                r->interface = interface;
127
 
            
 
125
 
128
126
            if (r->protocol == AVAHI_PROTO_UNSPEC)
129
127
                r->protocol = protocol;
130
 
            
 
128
 
131
129
            if (!r->ptr_record) {
132
130
                r->ptr_record = avahi_record_ref(record);
133
131
                r->flags = flags;
134
 
                
 
132
 
135
133
                finish(r, AVAHI_RESOLVER_FOUND);
136
134
            }
137
135
            break;
138
 
            
 
136
 
139
137
        case AVAHI_BROWSER_REMOVE:
140
138
            assert(record);
141
139
            assert(record->key->type == AVAHI_DNS_TYPE_PTR);
142
 
            
 
140
 
143
141
            if (r->ptr_record && avahi_record_equal_no_ttl(record, r->ptr_record)) {
144
142
                avahi_record_unref(r->ptr_record);
145
143
                r->ptr_record = NULL;
146
144
                r->flags = flags;
147
 
                
 
145
 
148
146
                /** Look for a replacement */
149
147
                avahi_s_record_browser_restart(r->record_browser);
150
148
                start_timeout(r);
151
149
            }
152
150
 
153
151
            break;
154
 
            
 
152
 
155
153
        case AVAHI_BROWSER_CACHE_EXHAUSTED:
156
154
        case AVAHI_BROWSER_ALL_FOR_NOW:
157
155
            break;
184
182
    AvahiLookupFlags flags,
185
183
    AvahiSAddressResolverCallback callback,
186
184
    void* userdata) {
187
 
    
 
185
 
188
186
    AvahiSAddressResolver *r;
189
187
    AvahiKey *k;
190
188
    char n[AVAHI_DOMAIN_NAME_MAX];
197
195
    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_PROTO_VALID(protocol), AVAHI_ERR_INVALID_PROTOCOL);
198
196
    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, address->proto == AVAHI_PROTO_INET || address->proto == AVAHI_PROTO_INET6, AVAHI_ERR_INVALID_PROTOCOL);
199
197
    AVAHI_CHECK_VALIDITY_RETURN_NULL(server, AVAHI_FLAGS_VALID(flags, AVAHI_LOOKUP_USE_WIDE_AREA|AVAHI_LOOKUP_USE_MULTICAST), AVAHI_ERR_INVALID_FLAGS);
200
 
    
 
198
 
201
199
    avahi_reverse_lookup_name(address, n, sizeof(n));
202
200
 
203
201
    if (!(k = avahi_key_new(n, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_PTR))) {
210
208
        avahi_key_unref(k);
211
209
        return NULL;
212
210
    }
213
 
    
 
211
 
214
212
    r->server = server;
215
213
    r->address = *address;
216
214
    r->callback = callback;
236
234
            r->retry_with_multicast = 1;
237
235
        }
238
236
    }
239
 
    
 
237
 
240
238
    r->record_browser = avahi_s_record_browser_new(server, interface, protocol, k, flags, record_browser_callback, r);
241
239
 
242
240
    if (!r->record_browser) {
245
243
    }
246
244
 
247
245
    start_timeout(r);
248
 
    
 
246
 
249
247
    return r;
250
248
}
251
249
 
265
263
 
266
264
    if (r->key)
267
265
        avahi_key_unref(r->key);
268
 
    
 
266
 
269
267
    avahi_free(r);
270
268
}