]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/resolve/resolved-dns-stream.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
5 This file is part of systemd.
7 Copyright 2014 Lennart Poettering
10 #include "socket-util.h"
12 typedef struct DnsStream DnsStream
;
14 #include "resolved-dns-packet.h"
15 #include "resolved-dns-transaction.h"
16 #include "resolved-manager.h"
18 /* Streams are used by three subsystems:
20 * 1. The normal transaction logic when doing a DNS or LLMNR lookup via TCP
21 * 2. The LLMNR logic when accepting a TCP-based lookup
22 * 3. The DNS stub logic when accepting a TCP-based lookup
32 union sockaddr_union peer
;
34 union sockaddr_union local
;
35 socklen_t local_salen
;
40 sd_event_source
*io_event_source
;
41 sd_event_source
*timeout_event_source
;
43 be16_t write_size
, read_size
;
44 DnsPacket
*write_packet
, *read_packet
;
45 size_t n_written
, n_read
;
47 int (*on_packet
)(DnsStream
*s
);
48 int (*complete
)(DnsStream
*s
, int error
);
50 DnsTransaction
*transaction
; /* when used by the transaction logic */
51 DnsQuery
*query
; /* when used by the DNS stub logic */
53 LIST_FIELDS(DnsStream
, streams
);
56 int dns_stream_new(Manager
*m
, DnsStream
**s
, DnsProtocol protocol
, int fd
);
57 DnsStream
*dns_stream_unref(DnsStream
*s
);
58 DnsStream
*dns_stream_ref(DnsStream
*s
);
60 int dns_stream_write_packet(DnsStream
*s
, DnsPacket
*p
);
62 static inline bool DNS_STREAM_QUEUED(DnsStream
*s
) {
65 if (s
->fd
< 0) /* already stopped? */
68 return !!s
->write_packet
;