From 65176697862bec2cea7ba5dbb855bc27de3bd3a6 Mon Sep 17 00:00:00 2001 From: David Wood Date: Thu, 1 Oct 2015 06:35:00 +0100 Subject: Add interface_mtu_wanted_for_pppoe() Returns the MTU wanted if an interface or vlan is used as a PPPoE port. --- src/etc/inc/interfaces.inc | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/etc') diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index 180ce6e..3e9fd21 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -3077,6 +3077,44 @@ function interface_vlan_adapt_mtu($vlanifs, $mtu) { } } +function interface_mtu_wanted_for_pppoe($realif) { + global $config; + + $mtu = 0; + + if (is_array($config['ppps']) && is_array($config['ppps']['ppp'])) { + foreach ($config['ppps']['ppp'] as $ppp) { + if ($ppp['type'] == "pppoe") { + $ports = explode(',',$ppp['ports']); + $mtu_wanted = 1500; + foreach ($ports as $pid => $port) { + if (get_real_interface($port) == $realif) { + // use the MTU configured on the interface ... + if (is_array($config['interfaces'])) { + foreach ($config['interfaces'] as $interface) { + if ($interface['if'] != $ppp['if']) + continue; + if (!empty($interface['mtu'])) + $mtu_wanted = intval($interface['mtu']) + 8; + } + } + // ... unless there is an MTU configured on the port in question + if (!empty($ppp['mtu'])) { + $mtus = explode(',',$ppp['mtu']); + if (!empty($mtus[$pid])) + $mtu_wanted = intval($mtus[$pid]) + 8; + } + if ($mtu_wanted > $mtu) + $mtu = $mtu_wanted; + } + } + } + } + } + + return $mtu; +} + function interface_configure($interface = "wan", $reloadall = false, $linkupevent = false) { global $config, $g; global $interface_sn_arr_cache, $interface_ip_arr_cache; -- cgit v1.1