1 /***************************************************************************/ /**
2  * @file
3  * @brief Network types
4  *******************************************************************************
5  * # License
6  * <b>Copyright 2022 Silicon Laboratories Inc. www.silabs.com</b>
7  *******************************************************************************
8  *
9  * SPDX-License-Identifier: Zlib
10  *
11  * The licensor of this software is Silicon Laboratories Inc.
12  *
13  * This software is provided 'as-is', without any express or implied
14  * warranty. In no event will the authors be held liable for any damages
15  * arising from the use of this software.
16  *
17  * Permission is granted to anyone to use this software for any purpose,
18  * including commercial applications, and to alter it and redistribute it
19  * freely, subject to the following restrictions:
20  *
21  * 1. The origin of this software must not be misrepresented; you must not
22  *    claim that you wrote the original software. If you use this software
23  *    in a product, an acknowledgment in the product documentation would be
24  *    appreciated but is not required.
25  * 2. Altered source versions must be plainly marked as such, and must not be
26  *    misrepresented as being the original software.
27  * 3. This notice may not be removed or altered from any source distribution.
28  *
29  ******************************************************************************/
30 #pragma once
31 
32 #include "sl_ip_types.h"
33 #include "sl_net_constants.h"
34 #include "sl_net_ip_types.h"
35 #include "sl_constants.h"
36 #include "sl_status.h"
37 #include <stdint.h>
38 
39 /** \addtogroup SL_NET_TYPES Types
40  * @{ */
41 
42 /**
43  * @typedef sl_net_event_handler_t
44  * @brief Generic callback for network events.
45  *
46  * @details
47  * This typedef defines a callback function for handling various network events. The callback function receives the event type, status, data, and data length as parameters.
48  *
49  * @param event
50  * Network event of type @ref sl_net_event_t.
51  * | @ref sl_net_event_t                  | DataType                               |
52  * |:-------------------------------------|:---------------------------------------|
53  * | SL_NET_PING_RESPONSE_EVENT           | @ref sl_si91x_ping_response_t          |
54  * | SL_NET_DNS_RESOLVE_EVENT             | [sl_ip_address_t](../wiseconnect-api-reference-guide-nwk-mgmt/sl-ip-address-t) |
55  * | SL_NET_OTA_FW_UPDATE_EVENT           | NULL in case of success, else uint16_t chunk number in case of failure |
56  * | SL_NET_DHCP_NOTIFICATION_EVENT       | NULL                                   |
57  * | SL_NET_IP_ADDRESS_CHANGE_EVENT       | @ref sl_net_ip_configuration_t         |
58  * | SL_NET_EVENT_COUNT                   | Not Applicable, Internally used by SDK |
59  *
60  * @param status
61  * Status of type sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details.
62  *
63  * @param data
64  * Data received, corresponding to the event type.
65  *
66  * @param data_length
67  * Length of the data received.
68  *
69  * @return
70  * Status of type sl_status_t. See [Status Codes](https://docs.silabs.com/gecko-platform/latest/platform-common/status) and [Additional Status Codes](../wiseconnect-api-reference-guide-err-codes/sl-additional-status-errors) for details.
71  */
72 typedef sl_status_t (*sl_net_event_handler_t)(sl_net_event_t event,
73                                               sl_status_t status,
74                                               void *data,
75                                               uint32_t data_length);
76 
77 /**
78  * @brief Abstract profile for SL Net.
79  *
80  * @details
81  * This type represents an abstract profile in the SL Net framework.
82  *
83  * @note
84  * This type is used internally by the SL Net framework and should be cast to the appropriate profile type when used.
85  */
86 typedef void sl_net_profile_t;
87 
88 /**
89  * @brief Ping Response structure.
90  *
91  * @details
92  * This structure holds the response data for a ping operation, including the IP version, ping size, and the pinged IP address.
93  */
94 typedef struct {
95   uint16_t
96     ip_version; ///< IP version (e.g., IPv4 or IPv6). One of the values from [sl_ip_version_t](../wiseconnect-api-reference-guide-common/ip-addresses#sl-ip-version-t).
97   uint16_t ping_size; ///< Size of the ping packet
98   union {
99     uint8_t ipv4_address[4];  ///< IPv4 address
100     uint8_t ipv6_address[16]; ///< IPv6 address
101   } ping_address;             ///< Pinged IP address
102 } sl_si91x_ping_response_t;
103 /** @} */
104