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