|
6 | 6 |
|
7 | 7 | /*
|
8 | 8 | * Copyright (c) 2017 Intel Corporation
|
| 9 | + * Copyright 2025 NXP |
9 | 10 | *
|
10 | 11 | * SPDX-License-Identifier: Apache-2.0
|
11 | 12 | */
|
@@ -395,6 +396,19 @@ typedef void (*dns_resolve_cb_t)(enum dns_resolve_status status,
|
395 | 396 | struct dns_addrinfo *info,
|
396 | 397 | void *user_data);
|
397 | 398 |
|
| 399 | +/** |
| 400 | + * @typedef dns_resolve_pkt_fw_cb_t |
| 401 | + * @brief DNS resolve callback which passes the received packet from DNS server to application |
| 402 | + * |
| 403 | + * @details The DNS resolve packet forwarding callback is called after a successful |
| 404 | + * DNS resolving. |
| 405 | + * |
| 406 | + * @param dns_data Pointer to data buffer containing the DNS message. |
| 407 | + * @param buf_len Length of the data. |
| 408 | + * @param user_data User data passed in dns_resolve function call. |
| 409 | + */ |
| 410 | +typedef void (*dns_resolve_pkt_fw_cb_t)(struct net_buf *dns_data, size_t buf_len, void *user_data); |
| 411 | + |
398 | 412 | /** @cond INTERNAL_HIDDEN */
|
399 | 413 |
|
400 | 414 | enum dns_resolve_context_state {
|
@@ -506,6 +520,11 @@ struct dns_resolve_context {
|
506 | 520 |
|
507 | 521 | /** Is this context in use */
|
508 | 522 | enum dns_resolve_context_state state;
|
| 523 | + |
| 524 | +#if defined(CONFIG_DNS_RESOLVER_PACKET_FORWARDING) || defined(__DOXYGEN__) |
| 525 | + /** DNS packet forwarding callback. */ |
| 526 | + dns_resolve_pkt_fw_cb_t pkt_fw_cb; |
| 527 | +#endif /* CONFIG_DNS_RESOLVER_PACKET_FORWARDING */ |
509 | 528 | };
|
510 | 529 |
|
511 | 530 | /** @cond INTERNAL_HIDDEN */
|
@@ -774,6 +793,25 @@ static inline int dns_resolve_service(struct dns_resolve_context *ctx,
|
774 | 793 | */
|
775 | 794 | struct dns_resolve_context *dns_resolve_get_default(void);
|
776 | 795 |
|
| 796 | +#if defined(CONFIG_DNS_RESOLVER_PACKET_FORWARDING) || defined(__DOXYGEN__) |
| 797 | +/** |
| 798 | + * @brief Installs the packet forwarding callback to the DNS resolving context. |
| 799 | + * |
| 800 | + * @details When this callback is installed, a received message from DNS server |
| 801 | + * will be passed to callback. |
| 802 | + * |
| 803 | + * @param ctx Pointer to DNS resolver context. |
| 804 | + * If the application wants to use the default DNS context, pointer to default dns |
| 805 | + * context can be obtained by calling dns_resolve_get_default() function. |
| 806 | + * @param cb Callback to call when received DNS message is required by application. |
| 807 | + */ |
| 808 | +static inline void dns_resolve_enable_packet_forwarding(struct dns_resolve_context *ctx, |
| 809 | + dns_resolve_pkt_fw_cb_t cb) |
| 810 | +{ |
| 811 | + ctx->pkt_fw_cb = cb; |
| 812 | +} |
| 813 | +#endif /* CONFIG_DNS_RESOLVER_PACKET_FORWARDING */ |
| 814 | + |
777 | 815 | /**
|
778 | 816 | * @brief Get IP address info from DNS.
|
779 | 817 | *
|
|
0 commit comments