Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
features/frameworks/nanostack-libservice/mbed-client-libservice/ip6string.h@0:38ceb79fef03, 2018-11-28 (annotated)
- Committer:
- kevman
- Date:
- Wed Nov 28 15:10:15 2018 +0000
- Revision:
- 0:38ceb79fef03
RTC modified
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kevman | 0:38ceb79fef03 | 1 | /* |
kevman | 0:38ceb79fef03 | 2 | * Copyright (c) 2014-2015 ARM Limited. All rights reserved. |
kevman | 0:38ceb79fef03 | 3 | * SPDX-License-Identifier: Apache-2.0 |
kevman | 0:38ceb79fef03 | 4 | * Licensed under the Apache License, Version 2.0 (the License); you may |
kevman | 0:38ceb79fef03 | 5 | * not use this file except in compliance with the License. |
kevman | 0:38ceb79fef03 | 6 | * You may obtain a copy of the License at |
kevman | 0:38ceb79fef03 | 7 | * |
kevman | 0:38ceb79fef03 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
kevman | 0:38ceb79fef03 | 9 | * |
kevman | 0:38ceb79fef03 | 10 | * Unless required by applicable law or agreed to in writing, software |
kevman | 0:38ceb79fef03 | 11 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
kevman | 0:38ceb79fef03 | 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
kevman | 0:38ceb79fef03 | 13 | * See the License for the specific language governing permissions and |
kevman | 0:38ceb79fef03 | 14 | * limitations under the License. |
kevman | 0:38ceb79fef03 | 15 | */ |
kevman | 0:38ceb79fef03 | 16 | #ifndef IP6STRING_H |
kevman | 0:38ceb79fef03 | 17 | #define IP6STRING_H |
kevman | 0:38ceb79fef03 | 18 | #ifdef __cplusplus |
kevman | 0:38ceb79fef03 | 19 | extern "C" { |
kevman | 0:38ceb79fef03 | 20 | #endif |
kevman | 0:38ceb79fef03 | 21 | |
kevman | 0:38ceb79fef03 | 22 | #include "ns_types.h" |
kevman | 0:38ceb79fef03 | 23 | |
kevman | 0:38ceb79fef03 | 24 | #define MAX_IPV6_STRING_LEN_WITH_TRAILING_NULL 40 |
kevman | 0:38ceb79fef03 | 25 | |
kevman | 0:38ceb79fef03 | 26 | /** |
kevman | 0:38ceb79fef03 | 27 | * Print binary IPv6 address to a string. |
kevman | 0:38ceb79fef03 | 28 | * |
kevman | 0:38ceb79fef03 | 29 | * String must contain enough room for full address, 40 bytes exact. |
kevman | 0:38ceb79fef03 | 30 | * IPv4 tunneling addresses are not covered. |
kevman | 0:38ceb79fef03 | 31 | * |
kevman | 0:38ceb79fef03 | 32 | * \param ip6addr IPv6 address. |
kevman | 0:38ceb79fef03 | 33 | * \param p buffer to write string to. |
kevman | 0:38ceb79fef03 | 34 | * \return length of generated string excluding the terminating null character |
kevman | 0:38ceb79fef03 | 35 | */ |
kevman | 0:38ceb79fef03 | 36 | uint_fast8_t ip6tos(const void *ip6addr, char *p); |
kevman | 0:38ceb79fef03 | 37 | |
kevman | 0:38ceb79fef03 | 38 | /** |
kevman | 0:38ceb79fef03 | 39 | * Print binary IPv6 prefix to a string. |
kevman | 0:38ceb79fef03 | 40 | * |
kevman | 0:38ceb79fef03 | 41 | * String buffer `p` must contain enough room for a full address and prefix length, 44 bytes exact. |
kevman | 0:38ceb79fef03 | 42 | * Bits in the `prefix` buffer beyond `prefix_len` bits are not shown and only the bytes containing the |
kevman | 0:38ceb79fef03 | 43 | * prefix bits are read. I.e. for a 20 bit prefix 3 bytes are read, and for a 0 bit prefix 0 bytes are |
kevman | 0:38ceb79fef03 | 44 | * read (thus if `prefix_len` is zero, `prefix` can be NULL). |
kevman | 0:38ceb79fef03 | 45 | * `prefix_len` must be 0 to 128. |
kevman | 0:38ceb79fef03 | 46 | * |
kevman | 0:38ceb79fef03 | 47 | * \param prefix IPv6 prefix. |
kevman | 0:38ceb79fef03 | 48 | * \param prefix_len length of `prefix` in bits. |
kevman | 0:38ceb79fef03 | 49 | * \param p buffer to write string to. |
kevman | 0:38ceb79fef03 | 50 | * \return length of generated string excluding the terminating null character, or 0 for an error, such as 'prefix_len' > 128 |
kevman | 0:38ceb79fef03 | 51 | */ |
kevman | 0:38ceb79fef03 | 52 | uint_fast8_t ip6_prefix_tos(const void *prefix, uint_fast8_t prefix_len, char *p); |
kevman | 0:38ceb79fef03 | 53 | |
kevman | 0:38ceb79fef03 | 54 | /** |
kevman | 0:38ceb79fef03 | 55 | * Convert numeric IPv6 address string to a binary. |
kevman | 0:38ceb79fef03 | 56 | * |
kevman | 0:38ceb79fef03 | 57 | * IPv4 tunneling addresses are not covered. |
kevman | 0:38ceb79fef03 | 58 | * |
kevman | 0:38ceb79fef03 | 59 | * \param ip6addr IPv6 address in string format. |
kevman | 0:38ceb79fef03 | 60 | * \param len Lenght of ipv6 string, maximum of 41. |
kevman | 0:38ceb79fef03 | 61 | * \param dest buffer for address. MUST be 16 bytes. |
kevman | 0:38ceb79fef03 | 62 | */ |
kevman | 0:38ceb79fef03 | 63 | void stoip6(const char *ip6addr, size_t len, void *dest); |
kevman | 0:38ceb79fef03 | 64 | /** |
kevman | 0:38ceb79fef03 | 65 | * Find out numeric IPv6 address prefix length. |
kevman | 0:38ceb79fef03 | 66 | * |
kevman | 0:38ceb79fef03 | 67 | * \param ip6addr IPv6 address in string format |
kevman | 0:38ceb79fef03 | 68 | * \return prefix length or 0 if it not given |
kevman | 0:38ceb79fef03 | 69 | */ |
kevman | 0:38ceb79fef03 | 70 | unsigned char sipv6_prefixlength(const char *ip6addr); |
kevman | 0:38ceb79fef03 | 71 | |
kevman | 0:38ceb79fef03 | 72 | #ifdef __cplusplus |
kevman | 0:38ceb79fef03 | 73 | } |
kevman | 0:38ceb79fef03 | 74 | #endif |
kevman | 0:38ceb79fef03 | 75 | #endif |