]> git.meshlink.io Git - catta/blob - avahi-core/psched.h
rename libavahi-core to avahi-core
[catta] / avahi-core / psched.h
1 #ifndef foopschedhfoo
2 #define foopschedhfoo
3
4 /* $Id$ */
5
6 /***
7   This file is part of avahi.
8  
9   avahi is free software; you can redistribute it and/or modify it
10   under the terms of the GNU Lesser General Public License as
11   published by the Free Software Foundation; either version 2.1 of the
12   License, or (at your option) any later version.
13  
14   avahi is distributed in the hope that it will be useful, but WITHOUT
15   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16   or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
17   Public License for more details.
18  
19   You should have received a copy of the GNU Lesser General Public
20   License along with avahi; if not, write to the Free Software
21   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22   USA.
23 ***/
24
25 typedef struct _AvahiQueryJob AvahiQueryJob;
26 typedef struct _AvahiResponseJob AvahiResponseJob;
27 typedef struct _AvahiPacketScheduler AvahiPacketScheduler;
28 typedef struct _AvahiKnownAnswer AvahiKnownAnswer;
29 typedef struct _AvahiProbeJob AvahiProbeJob;
30
31 #include "timeeventq.h"
32 #include "rr.h"
33 #include "llist.h"
34 #include "iface.h"
35
36 struct _AvahiQueryJob {
37     AvahiPacketScheduler *scheduler;
38     AvahiTimeEvent *time_event;
39     AvahiKey *key;
40     gboolean done;
41     GTimeVal delivery;
42     AVAHI_LLIST_FIELDS(AvahiQueryJob, jobs);
43 };
44
45 struct _AvahiResponseJob {
46     AvahiPacketScheduler *scheduler;
47     AvahiTimeEvent *time_event;
48     AvahiRecord *record;
49     AvahiAddress address;
50     gboolean address_valid;
51     gboolean done;
52     GTimeVal delivery;
53     gboolean flush_cache;
54     AVAHI_LLIST_FIELDS(AvahiResponseJob, jobs);
55 };
56
57 struct _AvahiKnownAnswer {
58     AvahiPacketScheduler *scheduler;
59     AvahiRecord *record;
60
61     AVAHI_LLIST_FIELDS(AvahiKnownAnswer, known_answer);
62 };
63
64 struct _AvahiProbeJob {
65     AvahiPacketScheduler *scheduler;
66     AvahiTimeEvent *time_event;
67     AvahiRecord *record;
68
69     gboolean chosen; /* Use for packet assembling */
70     GTimeVal delivery;
71     
72     AVAHI_LLIST_FIELDS(AvahiProbeJob, jobs);
73 };
74
75 struct _AvahiPacketScheduler {
76     AvahiServer *server;
77     
78     AvahiInterface *interface;
79
80     AVAHI_LLIST_HEAD(AvahiQueryJob, query_jobs);
81     AVAHI_LLIST_HEAD(AvahiResponseJob, response_jobs);
82     AVAHI_LLIST_HEAD(AvahiKnownAnswer, known_answers);
83     AVAHI_LLIST_HEAD(AvahiProbeJob, probe_jobs);
84 };
85
86 AvahiPacketScheduler *avahi_packet_scheduler_new(AvahiServer *server, AvahiInterface *i);
87 void avahi_packet_scheduler_free(AvahiPacketScheduler *s);
88
89 void avahi_packet_scheduler_post_query(AvahiPacketScheduler *s, AvahiKey *key, gboolean immediately);
90 void avahi_packet_scheduler_post_response(AvahiPacketScheduler *s, const AvahiAddress *a, AvahiRecord *record, gboolean flush_cache, gboolean immediately);
91 void avahi_packet_scheduler_post_probe(AvahiPacketScheduler *s, AvahiRecord *record, gboolean immediately);
92
93 void avahi_packet_scheduler_incoming_query(AvahiPacketScheduler *s, AvahiKey *key);
94 void avahi_packet_scheduler_incoming_response(AvahiPacketScheduler *s, AvahiRecord *record);
95 void avahi_packet_scheduler_incoming_known_answer(AvahiPacketScheduler *s, AvahiRecord *record, const AvahiAddress *a);
96
97 void avahi_packet_scheduler_flush_responses(AvahiPacketScheduler *s);
98
99 #endif