Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers icmpv6_prefix.h Source File

icmpv6_prefix.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 icmpv6_prefix.h
00020  * \brief This module will allocate dynamic linked list for ICMPv6 prefix.
00021  *
00022  * API:
00023  *  * ADD / UPDATE, icmpv6_prefix_add()
00024  *  * Discover prefix from the list, icmpv6_prefix_compare()
00025  *  * Free Linked list, icmpv6_prefix_list_free()
00026  *
00027  */
00028 
00029 #ifndef ICMPV6_PREFIX_DEFINITION_H_
00030 #define ICMPV6_PREFIX_DEFINITION_H_
00031 #include "ns_list.h"
00032 
00033 /* Prefix Information option bits (RFC4861) */
00034 #define PIO_L 0x80  /* On-link flag */
00035 #define PIO_A 0x40  /* Autonomous address-configuration flag */
00036 #define PIO_R 0x20  /* Router Address flag (RFC6275) */
00037 
00038 typedef struct prefix_entry_t {
00039     uint8_t prefix_len;
00040     uint8_t options;
00041     uint32_t lifetime;
00042     uint32_t preftime;
00043     uint8_t prefix[16];
00044     ns_list_link_t link;
00045 } prefix_entry_t;
00046 
00047 typedef NS_LIST_HEAD (prefix_entry_t, link) prefix_list_t;
00048 
00049 prefix_entry_t *icmpv6_prefix_add(prefix_list_t *list, const uint8_t *prefixPtr, uint8_t prefix_len, uint32_t lifeTime, uint32_t prefTime, uint8_t flags);
00050 
00051 prefix_entry_t *icmpv6_prefix_compare(prefix_list_t *list, const uint8_t *addr, uint8_t prefix_len);
00052 
00053 void icmpv6_prefix_list_free(prefix_list_t *list);
00054 
00055 #endif /* ICMPV6_PREFIX_DEFINITION_H_ */