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