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.
ipv6_pmtu.c
00001 /** 00002 * @file ipv6_pmtu.c 00003 * @brief Path MTU Discovery for IPv6 00004 * 00005 * @section License 00006 * 00007 * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved. 00008 * 00009 * This file is part of CycloneTCP Open. 00010 * 00011 * This program is free software; you can redistribute it and/or 00012 * modify it under the terms of the GNU General Public License 00013 * as published by the Free Software Foundation; either version 2 00014 * of the License, or (at your option) any later version. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU General Public License 00022 * along with this program; if not, write to the Free Software Foundation, 00023 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00024 * 00025 * @author Oryx Embedded SARL (www.oryx-embedded.com) 00026 * @version 1.7.6 00027 **/ 00028 00029 //Switch to the appropriate trace level 00030 #define TRACE_LEVEL IPV6_TRACE_LEVEL 00031 00032 //Dependencies 00033 #include "core/net.h" 00034 #include "core/ip.h" 00035 #include "ipv6/ipv6.h" 00036 #include "ipv6/ipv6_pmtu.h" 00037 #include "ipv6/ndp.h" 00038 #include "ipv6/ndp_cache.h" 00039 #include "debug.h" 00040 00041 //Check TCP/IP stack configuration 00042 #if (IPV6_SUPPORT == ENABLED && IPV6_PMTU_SUPPORT == ENABLED) 00043 00044 00045 /** 00046 * @brief Retrieve the PMTU for the specified path 00047 * @param[in] interface Underlying network interface 00048 * @param[in] destAddr Destination IPv6 address 00049 * @return PMTU value 00050 **/ 00051 00052 size_t ipv6GetPathMtu(NetInterface *interface, const Ipv6Addr *destAddr) 00053 { 00054 size_t pathMtu; 00055 00056 #if (NDP_SUPPORT == ENABLED) 00057 NdpDestCacheEntry *entry; 00058 00059 //Search the Destination Cache for the specified IPv6 address 00060 entry = ndpFindDestCacheEntry(interface, destAddr); 00061 00062 //Check whether a matching entry has been found in the Destination Cache 00063 if(entry != NULL) 00064 { 00065 //Use the existing PMTU estimate 00066 pathMtu = entry->pathMtu; 00067 } 00068 else 00069 { 00070 //If no entry exists in the Destination Cache, the PMTU value for 00071 //the path is assumed to be the MTU of the first-hop link 00072 pathMtu = interface->ipv6Context.linkMtu; 00073 } 00074 #else 00075 //The PMTU value for the path is assumed to be the MTU of the first-hop link 00076 pathMtu = interface->ipv6Context.linkMtu; 00077 #endif 00078 00079 //Return the PMTU value 00080 return pathMtu; 00081 } 00082 00083 00084 /** 00085 * @brief Update the PMTU for the specified path 00086 * @param[in] interface Underlying network interface 00087 * @param[in] destAddr Destination IPv6 address 00088 * @param[in] tentativePathMtu Tentative PMTU value 00089 **/ 00090 00091 void ipv6UpdatePathMtu(NetInterface *interface, 00092 const Ipv6Addr *destAddr, size_t tentativePathMtu) 00093 { 00094 #if (NDP_SUPPORT == ENABLED) 00095 NdpDestCacheEntry *entry; 00096 00097 //The destination address from the original packet is used to determine 00098 //which path the message applies to 00099 entry = ndpFindDestCacheEntry(interface, destAddr); 00100 00101 //Check whether a matching entry has been found in the Destination Cache 00102 if(entry != NULL) 00103 { 00104 //Compare the tentative PMTU to the existing PMTU 00105 if(tentativePathMtu < entry->pathMtu) 00106 { 00107 //If the tentative PMTU is less than the existing PMTU estimate, 00108 //the tentative PMTU replaces the existing PMTU 00109 entry->pathMtu = tentativePathMtu; 00110 } 00111 } 00112 #endif 00113 } 00114 00115 #endif 00116
Generated on Tue Jul 12 2022 17:10:14 by
1.7.2