]>
Commit | Line | Data |
---|---|---|
5eef597e MP |
1 | #pragma once |
2 | ||
3 | /*** | |
4 | This file is part of systemd. | |
5 | ||
6 | Copyright 2014 Lennart Poettering | |
7 | ||
8 | systemd is free software; you can redistribute it and/or modify it | |
9 | under the terms of the GNU Lesser General Public License as published by | |
10 | the Free Software Foundation; either version 2.1 of the License, or | |
11 | (at your option) any later version. | |
12 | ||
13 | systemd is distributed in the hope that it will be useful, but | |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | Lesser General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU Lesser General Public License | |
19 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
20 | ***/ | |
21 | ||
22 | #include "socket-util.h" | |
23 | ||
24 | typedef struct DnsStream DnsStream; | |
25 | ||
26 | #include "resolved-dns-packet.h" | |
27 | #include "resolved-dns-transaction.h" | |
5eef597e MP |
28 | |
29 | struct DnsStream { | |
30 | Manager *manager; | |
31 | ||
32 | DnsProtocol protocol; | |
33 | ||
34 | int fd; | |
35 | union sockaddr_union peer; | |
36 | socklen_t peer_salen; | |
37 | union sockaddr_union local; | |
38 | socklen_t local_salen; | |
39 | int ifindex; | |
40 | uint32_t ttl; | |
41 | bool identified; | |
42 | ||
43 | sd_event_source *io_event_source; | |
44 | sd_event_source *timeout_event_source; | |
45 | ||
46 | be16_t write_size, read_size; | |
47 | DnsPacket *write_packet, *read_packet; | |
48 | size_t n_written, n_read; | |
49 | ||
50 | int (*on_packet)(DnsStream *s); | |
51 | int (*complete)(DnsStream *s, int error); | |
52 | ||
53 | DnsTransaction *transaction; | |
54 | ||
55 | LIST_FIELDS(DnsStream, streams); | |
56 | }; | |
57 | ||
58 | int dns_stream_new(Manager *m, DnsStream **s, DnsProtocol protocol, int fd); | |
59 | DnsStream *dns_stream_free(DnsStream *s); | |
60 | ||
61 | int dns_stream_write_packet(DnsStream *s, DnsPacket *p); |