under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
You should have received a copy of the GNU Lesser General Public
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
You should have received a copy of the GNU Lesser General Public
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA.
***/
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA.
***/
-struct AvahiResponseJob {
- AvahiResponseScheduler *scheduler;
- AvahiTimeEvent *time_event;
+struct CattaResponseJob {
+ CattaResponseScheduler *scheduler;
+ CattaTimeEvent *time_event;
-struct AvahiResponseScheduler {
- AvahiInterface *interface;
- AvahiTimeEventQueue *time_event_queue;
+struct CattaResponseScheduler {
+ CattaInterface *interface;
+ CattaTimeEventQueue *time_event_queue;
- AVAHI_LLIST_HEAD(AvahiResponseJob, jobs);
- AVAHI_LLIST_HEAD(AvahiResponseJob, history);
- AVAHI_LLIST_HEAD(AvahiResponseJob, suppressed);
+ CATTA_LLIST_HEAD(CattaResponseJob, jobs);
+ CATTA_LLIST_HEAD(CattaResponseJob, history);
+ CATTA_LLIST_HEAD(CattaResponseJob, suppressed);
-static AvahiResponseJob* job_new(AvahiResponseScheduler *s, AvahiRecord *record, AvahiResponseJobState state) {
- AvahiResponseJob *rj;
+static CattaResponseJob* job_new(CattaResponseScheduler *s, CattaRecord *record, CattaResponseJobState state) {
+ CattaResponseJob *rj;
- if (!(rj = avahi_new(AvahiResponseJob, 1))) {
- avahi_log_error(__FILE__": Out of memory");
+ if (!(rj = catta_new(CattaResponseJob, 1))) {
+ catta_log_error(__FILE__": Out of memory");
- if ((rj->state = state) == AVAHI_SCHEDULED)
- AVAHI_LLIST_PREPEND(AvahiResponseJob, jobs, s->jobs, rj);
- else if (rj->state == AVAHI_DONE)
- AVAHI_LLIST_PREPEND(AvahiResponseJob, jobs, s->history, rj);
- else /* rj->state == AVAHI_SUPPRESSED */
- AVAHI_LLIST_PREPEND(AvahiResponseJob, jobs, s->suppressed, rj);
+ if ((rj->state = state) == CATTA_SCHEDULED)
+ CATTA_LLIST_PREPEND(CattaResponseJob, jobs, s->jobs, rj);
+ else if (rj->state == CATTA_DONE)
+ CATTA_LLIST_PREPEND(CattaResponseJob, jobs, s->history, rj);
+ else /* rj->state == CATTA_SUPPRESSED */
+ CATTA_LLIST_PREPEND(CattaResponseJob, jobs, s->suppressed, rj);
- if (rj->state == AVAHI_SCHEDULED)
- AVAHI_LLIST_REMOVE(AvahiResponseJob, jobs, s->jobs, rj);
- else if (rj->state == AVAHI_DONE)
- AVAHI_LLIST_REMOVE(AvahiResponseJob, jobs, s->history, rj);
- else /* rj->state == AVAHI_SUPPRESSED */
- AVAHI_LLIST_REMOVE(AvahiResponseJob, jobs, s->suppressed, rj);
+ if (rj->state == CATTA_SCHEDULED)
+ CATTA_LLIST_REMOVE(CattaResponseJob, jobs, s->jobs, rj);
+ else if (rj->state == CATTA_DONE)
+ CATTA_LLIST_REMOVE(CattaResponseJob, jobs, s->history, rj);
+ else /* rj->state == CATTA_SUPPRESSED */
+ CATTA_LLIST_REMOVE(CattaResponseJob, jobs, s->suppressed, rj);
-static void job_set_elapse_time(AvahiResponseScheduler *s, AvahiResponseJob *rj, unsigned msec, unsigned jitter) {
+static void job_set_elapse_time(CattaResponseScheduler *s, CattaResponseJob *rj, unsigned msec, unsigned jitter) {
- rj->time_event = avahi_time_event_new(s->time_event_queue, &tv, elapse_callback, rj);
+ rj->time_event = catta_time_event_new(s->time_event_queue, &tv, elapse_callback, rj);
- AVAHI_LLIST_REMOVE(AvahiResponseJob, jobs, s->jobs, rj);
- AVAHI_LLIST_PREPEND(AvahiResponseJob, jobs, s->history, rj);
+ CATTA_LLIST_REMOVE(CattaResponseJob, jobs, s->jobs, rj);
+ CATTA_LLIST_PREPEND(CattaResponseJob, jobs, s->history, rj);
- job_set_elapse_time(s, rj, AVAHI_RESPONSE_HISTORY_MSEC, 0);
+ job_set_elapse_time(s, rj, CATTA_RESPONSE_HISTORY_MSEC, 0);
-AvahiResponseScheduler *avahi_response_scheduler_new(AvahiInterface *i) {
- AvahiResponseScheduler *s;
+CattaResponseScheduler *catta_response_scheduler_new(CattaInterface *i) {
+ CattaResponseScheduler *s;
- if (!(s = avahi_new(AvahiResponseScheduler, 1))) {
- avahi_log_error(__FILE__": Out of memory");
+ if (!(s = catta_new(CattaResponseScheduler, 1))) {
+ catta_log_error(__FILE__": Out of memory");
- AVAHI_LLIST_HEAD_INIT(AvahiResponseJob, s->jobs);
- AVAHI_LLIST_HEAD_INIT(AvahiResponseJob, s->history);
- AVAHI_LLIST_HEAD_INIT(AvahiResponseJob, s->suppressed);
+ CATTA_LLIST_HEAD_INIT(CattaResponseJob, s->jobs);
+ CATTA_LLIST_HEAD_INIT(CattaResponseJob, s->history);
+ CATTA_LLIST_HEAD_INIT(CattaResponseJob, s->suppressed);
-static void enumerate_aux_records_callback(AVAHI_GCC_UNUSED AvahiServer *s, AvahiRecord *r, int flush_cache, void* userdata) {
- AvahiResponseJob *rj = userdata;
+static void enumerate_aux_records_callback(CATTA_GCC_UNUSED CattaServer *s, CattaRecord *r, int flush_cache, void* userdata) {
+ CattaResponseJob *rj = userdata;
- avahi_response_scheduler_post(rj->scheduler, r, flush_cache, rj->querier_valid ? &rj->querier : NULL, 0);
+ catta_response_scheduler_post(rj->scheduler, r, flush_cache, rj->querier_valid ? &rj->querier : NULL, 0);
-static int packet_add_response_job(AvahiResponseScheduler *s, AvahiDnsPacket *p, AvahiResponseJob *rj) {
+static int packet_add_response_job(CattaResponseScheduler *s, CattaDnsPacket *p, CattaResponseJob *rj) {
- if (!avahi_dns_packet_append_record(p, rj->record, rj->flush_cache, 0))
+ if (!catta_dns_packet_append_record(p, rj->record, rj->flush_cache, 0))
return 0;
/* Ok, this record will definitely be sent, so schedule the
* auxilliary packets, too */
return 0;
/* Ok, this record will definitely be sent, so schedule the
* auxilliary packets, too */
- avahi_server_enumerate_aux_records(s->interface->monitor->server, s->interface, rj->record, enumerate_aux_records_callback, rj);
+ catta_server_enumerate_aux_records(s->interface->monitor->server, s->interface, rj->record, enumerate_aux_records_callback, rj);
- avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_ANCOUNT, n);
- avahi_interface_send_packet(s->interface, p);
- avahi_dns_packet_free(p);
+ catta_dns_packet_set_field(p, CATTA_DNS_FIELD_ANCOUNT, n);
+ catta_interface_send_packet(s->interface, p);
+ catta_dns_packet_free(p);
-static void elapse_callback(AVAHI_GCC_UNUSED AvahiTimeEvent *e, void* data) {
- AvahiResponseJob *rj = data;
+static void elapse_callback(CATTA_GCC_UNUSED CattaTimeEvent *e, void* data) {
+ CattaResponseJob *rj = data;
job_free(rj->scheduler, rj); /* Lets drop this entry */
else
send_response_packet(rj->scheduler, rj);
}
job_free(rj->scheduler, rj); /* Lets drop this entry */
else
send_response_packet(rj->scheduler, rj);
}
-static AvahiResponseJob* find_suppressed_job(AvahiResponseScheduler *s, AvahiRecord *record, const AvahiAddress *querier) {
- AvahiResponseJob *rj;
+static CattaResponseJob* find_suppressed_job(CattaResponseScheduler *s, CattaRecord *record, const CattaAddress *querier) {
+ CattaResponseJob *rj;
- if (avahi_record_equal_no_ttl(rj->record, record) &&
- avahi_address_cmp(&rj->querier, querier) == 0) {
+ if (catta_record_equal_no_ttl(rj->record, record) &&
+ catta_address_cmp(&rj->querier, querier) == 0) {
-int avahi_response_scheduler_post(AvahiResponseScheduler *s, AvahiRecord *record, int flush_cache, const AvahiAddress *querier, int immediately) {
- AvahiResponseJob *rj;
+int catta_response_scheduler_post(CattaResponseScheduler *s, CattaRecord *record, int flush_cache, const CattaAddress *querier, int immediately) {
+ CattaResponseJob *rj;
-/* t = avahi_record_to_string(record); */
-/* avahi_log_debug("post %i %s", immediately, t); */
-/* avahi_free(t); */
+/* t = catta_record_to_string(record); */
+/* catta_log_debug("post %i %s", immediately, t); */
+/* catta_free(t); */
/* Check whether this response is suppressed */
if (querier &&
(rj = find_suppressed_job(s, record, querier)) &&
/* Check whether this response is suppressed */
if (querier &&
(rj = find_suppressed_job(s, record, querier)) &&
return 0;
}
/* Check if we already sent this response recently */
if ((rj = find_history_job(s, record))) {
return 0;
}
/* Check if we already sent this response recently */
if ((rj = find_history_job(s, record))) {
- avahi_elapse_time(&tv, immediately ? 0 : AVAHI_RESPONSE_DEFER_MSEC, immediately ? 0 : AVAHI_RESPONSE_JITTER_MSEC);
+ catta_elapse_time(&tv, immediately ? 0 : CATTA_RESPONSE_DEFER_MSEC, immediately ? 0 : CATTA_RESPONSE_JITTER_MSEC);
- rj->time_event = avahi_time_event_new(s->time_event_queue, &rj->delivery, elapse_callback, rj);
+ rj->time_event = catta_time_event_new(s->time_event_queue, &rj->delivery, elapse_callback, rj);
-void avahi_response_scheduler_incoming(AvahiResponseScheduler *s, AvahiRecord *record, int flush_cache) {
- AvahiResponseJob *rj;
+void catta_response_scheduler_incoming(CattaResponseScheduler *s, CattaRecord *record, int flush_cache) {
+ CattaResponseJob *rj;
if ((rj = find_scheduled_job(s, record))) {
if ((!rj->flush_cache || flush_cache) && /* flush cache bit was set correctly */
if ((rj = find_scheduled_job(s, record))) {
if ((!rj->flush_cache || flush_cache) && /* flush cache bit was set correctly */
record->ttl >= rj->record->ttl/2) { /* sensible TTL */
/* A matching entry was found, so let's mark it done */
record->ttl >= rj->record->ttl/2) { /* sensible TTL */
/* A matching entry was found, so let's mark it done */
if ((rj = find_history_job(s, record))) {
/* Found a history job, let's update it */
if ((rj = find_history_job(s, record))) {
/* Found a history job, let's update it */
return; /* OOM */
rj->flush_cache = flush_cache;
rj->querier_valid = 0;
gettimeofday(&rj->delivery, NULL);
return; /* OOM */
rj->flush_cache = flush_cache;
rj->querier_valid = 0;
gettimeofday(&rj->delivery, NULL);
- job_set_elapse_time(s, rj, AVAHI_RESPONSE_HISTORY_MSEC, 0);
+ job_set_elapse_time(s, rj, CATTA_RESPONSE_HISTORY_MSEC, 0);
-void avahi_response_scheduler_suppress(AvahiResponseScheduler *s, AvahiRecord *record, const AvahiAddress *querier) {
- AvahiResponseJob *rj;
+void catta_response_scheduler_suppress(CattaResponseScheduler *s, CattaRecord *record, const CattaAddress *querier) {
+ CattaResponseJob *rj;
- if (rj->querier_valid && avahi_address_cmp(querier, &rj->querier) == 0 && /* same originator */
- avahi_record_is_goodbye(record) == avahi_record_is_goodbye(rj->record) && /* both goodbye packets, or both not */
+ if (rj->querier_valid && catta_address_cmp(querier, &rj->querier) == 0 && /* same originator */
+ catta_record_is_goodbye(record) == catta_record_is_goodbye(rj->record) && /* both goodbye packets, or both not */
record->ttl >= rj->record->ttl/2) { /* sensible TTL */
/* A matching entry was found, so let's drop it */
record->ttl >= rj->record->ttl/2) { /* sensible TTL */
/* A matching entry was found, so let's drop it */
if ((rj = find_suppressed_job(s, record, querier))) {
/* Let's update the old entry */
if ((rj = find_suppressed_job(s, record, querier))) {
/* Let's update the old entry */
- job_set_elapse_time(s, rj, AVAHI_RESPONSE_SUPPRESS_MSEC, 0);
+ job_set_elapse_time(s, rj, CATTA_RESPONSE_SUPPRESS_MSEC, 0);