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.
lowpan_context.h
00001 /* 00002 * Copyright (c) 2015-2017, Arm Limited and affiliates. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 /* 00019 * \file lowpan_context.h 00020 * \brief This header define API how contexts are saved and listed at interface side. 00021 * 00022 * API: 00023 * * Add/Update context, lowpan_context_update() 00024 * * Delete full list Context, lowpan_context_list_free() 00025 * * Timeout update, protocol_6lowpan_context_timer() 00026 * 00027 */ 00028 00029 #ifndef LOWPAN_CONTEXT_DEFINE_H_ 00030 #define LOWPAN_CONTEXT_DEFINE_H_ 00031 #include "ns_list.h" 00032 00033 /* Flags for decode or encode to context's information to 8-bit data from message or to message (cid_flags)*/ 00034 #define LOWPAN_CONTEXT_C 0x10 // Compression 00035 #define LOWPAN_CONTEXT_CID_MASK 0x0F // Context ID MASK 00036 #define LOWPAN_MAX_CONTEXT_COUNT 16 00037 00038 typedef struct lowpan_context { 00039 uint32_t lifetime; // Remaining lifetime (100ms ticks) 00040 unsigned length: 8; // Context length 00041 unsigned cid: 4; // Context Identifier 00042 bool compression: 1; // C (Compression) flag 00043 bool expiring: 1; // True if main lifetime expired, pending deletion 00044 bool stable: 1; // Thread stable network data (always true if not Thread) 00045 uint8_t prefix[16]; // Context prefix 00046 ns_list_link_t link; 00047 } lowpan_context_t; 00048 00049 typedef NS_LIST_HEAD (lowpan_context_t, link) lowpan_context_list_t; 00050 00051 /** 00052 * \brief Update lowpan current context or add new one 00053 * 00054 * \param list pointer to linked list for context 00055 * \param cid_flags Define context id (LOWPAN_CONTEXT_CID_MASK) and Context compression mode (LOWPAN_CONTEXT_C) 00056 * \param lifetime in minutes for context 0 delete contexts 00057 * \param prefix pointer to context prefix 00058 * \param len prefin length in bits 00059 * 00060 * \return 0 Update OK 00061 * \return -2 Update fail Out of memory reason 00062 */ 00063 int_fast8_t lowpan_context_update(lowpan_context_list_t *list, uint8_t cid_flags, uint16_t lifetime, const uint8_t *prefix, uint_fast8_t len, bool stable); 00064 00065 /** 00066 * \brief Cleand free full linked list about context 00067 * 00068 * \param list pointer to linked list for context 00069 * 00070 */ 00071 void lowpan_context_list_free(lowpan_context_list_t *list); 00072 00073 /** 00074 * \brief Update lowpan context timeout ticks 00075 * 00076 * \param list pointer to linked list for context 00077 * \param ticks is in 1/10s 00078 * 00079 */ 00080 void lowpan_context_timer(lowpan_context_list_t *list, uint_fast16_t ticks); 00081 /** 00082 * \brief Get Context entry from the list by context ID 00083 * 00084 * \param list pointer to linked list for context 00085 * \param id Define 4-bit context id LOWPAN_CONTEXT_CID_MASK 00086 * 00087 * \return >0 Pointer to Entry 00088 * \return NULL Not supported Context ID 00089 * 00090 */ 00091 lowpan_context_t *lowpan_contex_get_by_id(const lowpan_context_list_t *list, uint8_t id); 00092 00093 /** 00094 * \brief Get Longest match Context entry from the list for given IPv6 address 00095 * 00096 * \param list pointer to linked list for context 00097 * \param ipv6Address pointer to 00098 * 00099 * \return >0 Pointer to Entry 00100 * \return NULL Not supported Context for this address 00101 * 00102 */ 00103 lowpan_context_t *lowpan_context_get_by_address(const lowpan_context_list_t *list, const uint8_t *ipv6Address); 00104 00105 #endif /* LOWPAN_CONTEXT_DEFINE_H_ */
Generated on Tue Jul 12 2022 12:21:59 by
