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