From 6f21f489377a0830cb790a35a1eb21f9e63268de Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Tue, 5 Jun 2012 23:10:38 +0200 Subject: [PATCH] added MTU support (using MRU from the peer) --- src/netif/ppp/ppp.c | 42 +++++++++++++++++----------------------- src/netif/ppp/ppp.h | 6 ------ src/netif/ppp/ppp_impl.h | 2 +- 3 files changed, 19 insertions(+), 31 deletions(-) diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index ea8fabaa..937a46a7 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -1088,7 +1088,7 @@ static err_t ppp_netif_init_cb(struct netif *netif) { netif->name[0] = 'p'; netif->name[1] = 'p'; netif->output = ppp_netif_output; - netif->mtu = ppp_mtu((int)(size_t)netif->state); + netif->mtu = netif_get_mtu((int)(size_t)netif->state); netif->flags = NETIF_FLAG_POINTTOPOINT | NETIF_FLAG_LINK_UP; #if LWIP_NETIF_HOSTNAME /* @todo: Initialize interface hostname */ @@ -1381,24 +1381,6 @@ static err_t ppp_netif_output_over_ethernet(int pd, struct pbuf *p) { #endif /* PPPOE_SUPPORT */ -/* - * Return the Maximum Transmission Unit for the given PPP connection. - */ -u_short ppp_mtu(int pd) { - ppp_control *pc = &ppp_control_list[pd]; - u_short st; - - /* Validate parameters. */ - if (pd < 0 || pd >= NUM_PPP || !pc->open_flag) { - st = 0; - } else { - st = pc->mtu; - } - - return st; -} - - /* Get and set parameters for the given connection. * Return 0 on success, an error code on failure. */ int @@ -1976,7 +1958,7 @@ int ppp_send_config(int unit, int mtu, u_int32_t accm, int pcomp, int accomp) { int i; #endif /* PPPOS_SUPPORT */ - pc->mtu = mtu; + /* pc->mtu = mtu; -- set correctly with netif_set_mtu */ pc->pcomp = pcomp; pc->accomp = accomp; @@ -2190,14 +2172,26 @@ int sifnpmode(int u, int proto, enum NPmode mode) { * netif_set_mtu - set the MTU on the PPP network interface. */ void netif_set_mtu(int unit, int mtu) { - /* FIXME: set lwIP MTU */ + ppp_control *pc = &ppp_control_list[unit]; + + /* Validate parameters. */ + if (unit < 0 || unit >= NUM_PPP || !pc->open_flag) + return; + + pc->mtu = mtu; } + /* * netif_get_mtu - get PPP interface MTU */ -int netif_get_mtu(int mtu) { - /* FIXME: get lwIP MTU */ - return 1492; +int netif_get_mtu(int unit) { + ppp_control *pc = &ppp_control_list[unit]; + + /* Validate parameters. */ + if (unit < 0 || unit >= NUM_PPP || !pc->open_flag) + return 0; + + return pc->mtu; } /******************************************************************** diff --git a/src/netif/ppp/ppp.h b/src/netif/ppp/ppp.h index 57d29485..06c425a9 100644 --- a/src/netif/ppp/ppp.h +++ b/src/netif/ppp/ppp.h @@ -176,12 +176,6 @@ void ppp_sighup(int pd); */ int ppp_ioctl(int pd, int cmd, void *arg); -/* - * Return the Maximum Transmission Unit for the given PPP connection. - */ -/* FIXME: demystify MTU support */ -u_short ppp_mtu(int pd); - #if PPPOS_SUPPORT && !PPP_INPROC_OWNTHREAD /* * PPP over Serial: this is the input function to be called for received data. diff --git a/src/netif/ppp/ppp_impl.h b/src/netif/ppp/ppp_impl.h index a05ce7c2..cfb4cd72 100644 --- a/src/netif/ppp/ppp_impl.h +++ b/src/netif/ppp/ppp_impl.h @@ -493,7 +493,7 @@ int sifdown (int u); int sifnpmode(int u, int proto, enum NPmode mode); void netif_set_mtu(int unit, int mtu); -int netif_get_mtu(int mtu); +int netif_get_mtu(int unit); int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway, bool replace); int cifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway);