1 /***************************************************************************/ /** 2 * @file 3 * @brief 4 ******************************************************************************* 5 * # License 6 * <b>Copyright 2019 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_status.h" 33 #include "sl_ip_types.h" 34 #include "sl_ieee802_types.h" 35 #include "sl_wifi_types.h" 36 37 /***************************************************************************/ /** 38 * @brief 39 * Convert a character string into a sl_ipv4_address_t 40 * @param line 41 * Argument string that is expected to be like 192.168.0.1 42 * @param ip 43 * Pointer to sl_ipv4_address_t. 44 * @return 45 * sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details. 46 ******************************************************************************/ 47 sl_status_t convert_string_to_sl_ipv4_address(char *line, sl_ipv4_address_t *ip); 48 49 /***************************************************************************/ /** 50 * @brief 51 * Convert IPv6 binary address into presentation (printable) format 52 * @param[in] input 53 * A pointer to the buffer containing the binary IPV6 address 54 * @param[in] dst 55 * A pointer to the buffer where the resulting string will be stored 56 * @param[in] size 57 * The size of the destination buffer in bytes 58 * @return 59 * A pointer to a resulting string containing human readable representation of IPV6 address. 60 ******************************************************************************/ 61 char *sl_inet_ntop6(const unsigned char *input, char *dst, uint32_t size); 62 63 /***************************************************************************/ /** 64 * @brief 65 * Convert a character string into a [sl_mac_address_t](../wiseconnect-api-reference-guide-nwk-mgmt/sl-net-types#sl-mac-address-t) 66 * @param line 67 * Argument string that is expected to be like 00:11:22:33:44:55 68 * @param mac 69 * Pointer to [sl_mac_address_t](../wiseconnect-api-reference-guide-nwk-mgmt/sl-net-types#sl-mac-address-t). 70 * @return 71 * sl_status_t. See https://docs.silabs.com/gecko-platform/latest/platform-common/status for details. 72 ******************************************************************************/ 73 sl_status_t convert_string_to_mac_address(const char *line, sl_mac_address_t *mac); 74 75 void print_sl_ip_address(const sl_ip_address_t *sl_ip_address); 76 void print_sl_ipv4_address(const sl_ipv4_address_t *ip_address); 77 void print_sl_ipv6_address(const sl_ipv6_address_t *ip_address); 78 void print_mac_address(const sl_mac_address_t *mac_address); 79 void convert_uint32_to_bytestream(uint16_t data, uint8_t *buffer); 80 void little_to_big_endian(const unsigned int *source, unsigned char *result, unsigned int length); 81 int sl_inet_pton6(const char *src, const char *src_endp, unsigned char *dst, unsigned int *ptr_result); 82 void reverse_digits(unsigned char *xx, int no_digits); 83 void print_firmware_version(const sl_wifi_firmware_version_t *firmware_version); 84 85 /***************************************************************************/ /** 86 * @brief Print 802.11 packet 87 * 88 * @param[in] packet - pointer to start of MAC header 89 * @param[in] packet_length - total packet length (MAC header + payload) 90 * @param[in] max_payload_length - maximum number of payload bytes to print 91 ******************************************************************************/ 92 void print_80211_packet(const uint8_t *packet, uint32_t packet_length, uint16_t max_payload_length); 93