Ben Schwartz | ded1b70 | 2017-10-25 14:41:02 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef _DNS_IDNSTLSSOCKET_H |
| 18 | #define _DNS_IDNSTLSSOCKET_H |
| 19 | |
Ben Schwartz | ded1b70 | 2017-10-25 14:41:02 -0400 | [diff] [blame] | 20 | #include <cstddef> |
Mike Yu | 5ae6154 | 2018-10-19 22:11:43 +0800 | [diff] [blame] | 21 | #include <cstdint> |
Ben Schwartz | ded1b70 | 2017-10-25 14:41:02 -0400 | [diff] [blame] | 22 | |
| 23 | #include <netdutils/Slice.h> |
| 24 | |
Ben Schwartz | ded1b70 | 2017-10-25 14:41:02 -0400 | [diff] [blame] | 25 | namespace android { |
| 26 | namespace net { |
| 27 | |
| 28 | class IDnsTlsSocketObserver; |
| 29 | class DnsTlsSessionCache; |
| 30 | |
| 31 | // A class for managing a TLS socket that sends and receives messages in |
| 32 | // [length][value] format, with a 2-byte length (i.e. DNS-over-TCP format). |
Ben Schwartz | 3386076 | 2017-10-25 14:41:02 -0400 | [diff] [blame] | 33 | // This interface is not aware of query-response pairing or anything else about DNS. |
Ben Schwartz | ded1b70 | 2017-10-25 14:41:02 -0400 | [diff] [blame] | 34 | class IDnsTlsSocket { |
Bernie Innocenti | ad4e26e | 2019-01-30 11:16:36 +0900 | [diff] [blame] | 35 | public: |
| 36 | virtual ~IDnsTlsSocket(){}; |
Ben Schwartz | ded1b70 | 2017-10-25 14:41:02 -0400 | [diff] [blame] | 37 | // Send a query on the provided SSL socket. |query| contains |
Ben Schwartz | 3386076 | 2017-10-25 14:41:02 -0400 | [diff] [blame] | 38 | // the body of a query, not including the ID bytes. This function will typically return before |
| 39 | // the query is actually sent. If this function fails, the observer will be |
| 40 | // notified that the socket is closed. |
| 41 | // Note that a true return value indicates successful sending, not receipt of a response. |
| 42 | virtual bool query(uint16_t id, const netdutils::Slice query) = 0; |
Ben Schwartz | ded1b70 | 2017-10-25 14:41:02 -0400 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | } // end of namespace net |
| 46 | } // end of namespace android |
| 47 | |
| 48 | #endif // _DNS_IDNSTLSSOCKET_H |