Mistake on this page?
Report an issue in GitHub or email us
cynetwork_utils.h
1 /*
2  * Copyright (c) 2018-2019 ARM Limited
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #pragma once
19 
20 #include <stdint.h>
21 #include <stdlib.h>
22 #include <string.h>
23 
24 #if defined(__cplusplus)
25 extern "C" {
26 #endif
27 
28 #ifndef MIN
29 extern int MIN(/*@sef@*/ int x, /*@sef@*/ int y); /* LINT : This tells lint that the parameter must be side-effect free. i.e. evaluation does not change any values (since it is being evaulated more than once */
30 #define MIN(x,y) ((x) < (y) ? (x) : (y))
31 #endif /* ifndef MIN */
32 
33 #define FX_IPTYPE_IPV4 (0)
34 #define FX_IPTYPE_IPV6 (1)
35 
36 typedef union {
37  uint32_t addr;
38  uint8_t addrs[4];
40 
41 typedef struct {
42  uint32_t addr[4];
44 
45 typedef struct {
46  uint8_t type;
47  union {
48  cy_ip_addr_v4_t addrv4;
49  cy_ip_addr_v6_t addrv6;
50  };
51 } cy_ip_addr_t;
52 
53 /**
54  * Structure for storing a MAC address (Wi-Fi Media Access Control address).
55  */
56 typedef struct {
57  uint8_t octet[6]; /**< Unique 6-byte MAC address */
59 
60 /**
61  * Converts a unsigned long int to a decimal string
62  *
63  * @param value[in] : The unsigned long to be converted
64  * @param output[out] : The buffer which will receive the decimal string
65  * @param min_length[in] : the minimum number of characters to output (zero padding will apply if required).
66  * @param max_length[in] : the maximum number of characters to output (up to 10 ). There must be space for terminating NULL.
67  *
68  * @note: A terminating NULL is added. Wnsure that there is space in the buffer for this.
69  *
70  * @return the number of characters returned (excluding terminating null)
71  *
72  */
73 uint8_t unsigned_to_decimal_string(uint32_t value, char *output, uint8_t min_length, uint8_t max_length);
74 
75 /**
76  * Convert a IPv4 address to a string
77  *
78  * @note: String is 16 bytes including terminating null
79  *
80  * @param[out] buffer : Buffer which will recieve the IPv4 string
81  * @param[in] ipv4_address : IPv4 address to convert
82  */
83 void ipv4_to_string(char buffer[16], uint32_t ipv4_address);
84 
85 /**
86  * Convert a IPv4 address to a string
87  *
88  * @note: String is 16 bytes including terminating null
89  *
90  * @param[in] buffer : Buffer which has the IPv4 string
91  * @return ipv4_address (0 on failure)
92  */
93 uint32_t string_to_ipv4(const char *buffer);
94 
95 #if defined(__cplusplus)
96 }
97 #endif
Structure for storing a MAC address (Wi-Fi Media Access Control address).
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.