Mercurial > pidgin.yaz
comparison src/protocols/rendezvous/mdns_cache.c @ 8834:beb7be215db3
[gaim-migrate @ 9598]
I removed account->ip because it isn't used anywhere and I think it's dumb.
Also added handling for a and aaaa records to rendezvous. Gaim peeps
show up in iChat rendezvous lists now. There are still problems.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 28 Apr 2004 00:48:21 +0000 |
parents | 8212661dc3cc |
children | 01c3db200c8f |
comparison
equal
deleted
inserted
replaced
8833:61fdef863ffa | 8834:beb7be215db3 |
---|---|
25 | 25 |
26 #include "internal.h" | 26 #include "internal.h" |
27 #include "debug.h" | 27 #include "debug.h" |
28 | 28 |
29 #include "mdns.h" | 29 #include "mdns.h" |
30 #include "mdns_cache.h" | |
30 | 31 |
31 /* XXX - Make sure this is freed when we sign off */ | |
32 GSList *rrs = NULL; | 32 GSList *rrs = NULL; |
33 | |
34 static ResourceRecord * | |
35 mdns_cache_find(gchar *name, unsigned short type) | |
36 { | |
37 ResourceRecord *rr; | |
38 GSList *cur; | |
39 | |
40 g_return_val_if_fail(name != NULL, NULL); | |
41 g_return_val_if_fail((type != 0) || (type != RENDEZVOUS_RRTYPE_ALL), NULL); | |
42 | |
43 for (cur = rrs; cur != NULL; cur = cur->next) { | |
44 rr = cur->data; | |
45 if ((type == rr->type) && (!strcmp(name, rr->name))) | |
46 return rr; | |
47 } | |
48 | |
49 return NULL; | |
50 } | |
33 | 51 |
34 void | 52 void |
35 mdns_cache_add(const ResourceRecord *rr) | 53 mdns_cache_add(const ResourceRecord *rr) |
36 { | 54 { |
37 ResourceRecord *new; | 55 ResourceRecord *new; |
38 | 56 |
39 g_return_if_fail(rr != NULL); | 57 g_return_if_fail(rr != NULL); |
58 g_return_if_fail((rr->type != 0) && (rr->type != RENDEZVOUS_RRTYPE_ALL)); | |
40 | 59 |
60 mdns_cache_remove(rr->name, rr->type); | |
61 | |
62 printf("caching %d\n", rr->type); | |
41 new = mdns_copy_rr(rr); | 63 new = mdns_copy_rr(rr); |
42 | |
43 rrs = g_slist_prepend(rrs, new); | 64 rrs = g_slist_prepend(rrs, new); |
44 } | 65 } |
45 | 66 |
46 void | 67 void |
47 mdns_cache_remove(ResourceRecord *rr) | 68 mdns_cache_remove(gchar *name, unsigned short type) |
48 { | 69 { |
49 g_return_if_fail(rr != NULL); | 70 ResourceRecord *rr; |
50 | 71 |
51 rrs = g_slist_remove_all(rrs, rr); | 72 g_return_if_fail(name != NULL); |
73 g_return_if_fail((type != 0) && (type != RENDEZVOUS_RRTYPE_ALL)); | |
52 | 74 |
75 rr = mdns_cache_find(name, type); | |
76 if (rr == NULL) | |
77 return; | |
78 | |
79 rrs = g_slist_remove(rrs, rr); | |
53 mdns_free_rr(rr); | 80 mdns_free_rr(rr); |
54 } | 81 } |
55 | 82 |
56 void | 83 void |
57 mdns_cache_remove_all() | 84 mdns_cache_remove_all() |
64 { | 91 { |
65 GSList *slist; | 92 GSList *slist; |
66 ResourceRecord *cur; | 93 ResourceRecord *cur; |
67 | 94 |
68 g_return_if_fail(q != NULL); | 95 g_return_if_fail(q != NULL); |
96 printf("query for q->type=%d, q->name=%s\n", q->type, q->name); | |
69 | 97 |
70 for (slist = rrs; slist != NULL; slist = g_slist_next(slist)) { | 98 for (slist = rrs; slist != NULL; slist = slist->next) { |
71 cur = slist->data; | 99 cur = slist->data; |
72 if ((q->type == cur->type) && (!strcmp(q->name, cur->name))) | 100 if ((q->type == cur->type) && (!strcmp(q->name, cur->name))) { |
73 mdns_send_rr(fd, cur); | 101 printf("responding to cur->type=%d, cur->name=%s\n", cur->type, cur->name); |
102 //mdns_send_rr(fd, cur); | |
103 } | |
74 } | 104 } |
75 } | 105 } |