Marco Zecchini
/
Example_RTOS
Rtos API example
Embed:
(wiki syntax)
Show/hide line numbers
ip6string.h
00001 /* 00002 * Copyright (c) 2014-2015 ARM Limited. All rights reserved. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * Licensed under the Apache License, Version 2.0 (the License); you may 00005 * not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 00012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #ifndef IP6STRING_H 00017 #define IP6STRING_H 00018 #ifdef __cplusplus 00019 extern "C" { 00020 #endif 00021 00022 #include "ns_types.h" 00023 00024 #define MAX_IPV6_STRING_LEN_WITH_TRAILING_NULL 40 00025 00026 /** 00027 * Print binary IPv6 address to a string. 00028 * 00029 * String must contain enough room for full address, 40 bytes exact. 00030 * IPv4 tunneling addresses are not covered. 00031 * 00032 * \param ip6addr IPv6 address. 00033 * \param p buffer to write string to. 00034 * \return length of generated string excluding the terminating null character 00035 */ 00036 uint_fast8_t ip6tos(const void *ip6addr, char *p); 00037 00038 /** 00039 * Print binary IPv6 prefix to a string. 00040 * 00041 * String buffer `p` must contain enough room for a full address and prefix length, 44 bytes exact. 00042 * Bits in the `prefix` buffer beyond `prefix_len` bits are not shown and only the bytes containing the 00043 * prefix bits are read. I.e. for a 20 bit prefix 3 bytes are read, and for a 0 bit prefix 0 bytes are 00044 * read (thus if `prefix_len` is zero, `prefix` can be NULL). 00045 * `prefix_len` must be 0 to 128. 00046 * 00047 * \param prefix IPv6 prefix. 00048 * \param prefix_len length of `prefix` in bits. 00049 * \param p buffer to write string to. 00050 * \return length of generated string excluding the terminating null character, or 0 for an error, such as 'prefix_len' > 128 00051 */ 00052 uint_fast8_t ip6_prefix_tos(const void *prefix, uint_fast8_t prefix_len, char *p); 00053 00054 /** 00055 * Convert numeric IPv6 address string to a binary. 00056 * 00057 * IPv4 tunneling addresses are not covered. 00058 * 00059 * \param ip6addr IPv6 address in string format. 00060 * \param len Lenght of ipv6 string, maximum of 41. 00061 * \param dest buffer for address. MUST be 16 bytes. 00062 */ 00063 void stoip6(const char *ip6addr, size_t len, void *dest); 00064 /** 00065 * Find out numeric IPv6 address prefix length. 00066 * 00067 * \param ip6addr IPv6 address in string format 00068 * \return prefix length or 0 if it not given 00069 */ 00070 unsigned char sipv6_prefixlength(const char *ip6addr); 00071 00072 #ifdef __cplusplus 00073 } 00074 #endif 00075 #endif
Generated on Sun Jul 17 2022 08:25:23 by 1.7.2