| 1 |
/** |
| 2 |
* @file |
| 3 |
* |
| 4 |
* IPv6 static route table. |
| 5 |
*/ |
| 6 |
|
| 7 |
/* |
| 8 |
* Copyright (c) 2015 Nest Labs, Inc. |
| 9 |
* All rights reserved. |
| 10 |
* |
| 11 |
* Redistribution and use in source and binary forms, with or without modification, |
| 12 |
* are permitted provided that the following conditions are met: |
| 13 |
* |
| 14 |
* 1. Redistributions of source code must retain the above copyright notice, |
| 15 |
* this list of conditions and the following disclaimer. |
| 16 |
* 2. Redistributions in binary form must reproduce the above copyright notice, |
| 17 |
* this list of conditions and the following disclaimer in the documentation |
| 18 |
* and/or other materials provided with the distribution. |
| 19 |
* 3. The name of the author may not be used to endorse or promote products |
| 20 |
* derived from this software without specific prior written permission. |
| 21 |
* |
| 22 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 23 |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 24 |
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
| 25 |
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 26 |
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
| 27 |
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 28 |
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 29 |
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 30 |
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
| 31 |
* OF SUCH DAMAGE. |
| 32 |
* |
| 33 |
* Author: Pradip De <[email protected]> |
| 34 |
* |
| 35 |
* |
| 36 |
* Please coordinate changes and requests with Pradip De |
| 37 |
* <[email protected]> |
| 38 |
*/ |
| 39 |
|
| 40 |
#ifndef __LWIP_IP6_ROUTE_TABLE_H__ |
| 41 |
#define __LWIP_IP6_ROUTE_TABLE_H__ |
| 42 |
|
| 43 |
#include "lwip/opt.h" |
| 44 |
|
| 45 |
#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ |
| 46 |
|
| 47 |
#include "lwip/ip6_addr.h" |
| 48 |
#include "lwip/err.h" |
| 49 |
|
| 50 |
#ifdef __cplusplus |
| 51 |
extern "C" { |
| 52 |
#endif |
| 53 |
|
| 54 |
struct netif; |
| 55 |
|
| 56 |
/** |
| 57 |
* LWIP_IPV6_NUM_ROUTES: Number of IPV6 routes that can be kept in the static route table. |
| 58 |
*/ |
| 59 |
#ifndef LWIP_IPV6_NUM_ROUTE_ENTRIES |
| 60 |
#define LWIP_IPV6_NUM_ROUTE_ENTRIES (8) |
| 61 |
#endif |
| 62 |
|
| 63 |
#define IP6_MAX_PREFIX_LEN (128) |
| 64 |
#define IP6_PREFIX_ALLOWED_GRANULARITY (8) |
| 65 |
/* Prefix length cannot be greater than 128 bits and needs to be at a byte boundary */ |
| 66 |
#define ip6_prefix_valid(prefix_len) (((prefix_len) <= IP6_MAX_PREFIX_LEN) && \ |
| 67 |
(((prefix_len) % IP6_PREFIX_ALLOWED_GRANULARITY) == 0)) |
| 68 |
|
| 69 |
struct ip6_prefix { |
| 70 |
ip6_addr_t addr; |
| 71 |
u8_t prefix_len; /* prefix length in bits at byte boundaries */ |
| 72 |
}; |
| 73 |
|
| 74 |
struct ip6_route_entry { |
| 75 |
struct ip6_prefix prefix; |
| 76 |
struct netif *netif; |
| 77 |
const ip6_addr_t *gateway; |
| 78 |
}; |
| 79 |
|
| 80 |
err_t ip6_add_route_entry(const struct ip6_prefix *ip6_prefix, struct netif *netif, |
| 81 |
const ip6_addr_t *gateway, s8_t *idx); |
| 82 |
void ip6_remove_route_entry(const struct ip6_prefix *ip6_prefix); |
| 83 |
s8_t ip6_find_route_entry(const ip6_addr_t *ip6_dest_addr); |
| 84 |
struct netif *ip6_static_route(const ip6_addr_t *src, const ip6_addr_t *dest); |
| 85 |
const ip6_addr_t *ip6_get_gateway(struct netif *netif, const ip6_addr_t *dest); |
| 86 |
const struct ip6_route_entry *ip6_get_route_table(void); |
| 87 |
|
| 88 |
#ifdef __cplusplus |
| 89 |
} |
| 90 |
#endif |
| 91 |
|
| 92 |
#endif /* LWIP_IPV6 */ |
| 93 |
|
| 94 |
#endif /* __LWIP_IP6_ROUTE_TABLE_H__ */ |