ppp: change MTU on TUN device when MRU option received
PATCH 1/1 ppp: change MTU on TUN device when MRU option received
--- gatchat/ppp_net.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
gatchat/ppp_net.c +16 -0
@@ -50,10 +50,26 @@ struct ppp_net {void ppp_net_set_mtu (struct ppp_net *net,guint16 mtu) { +struct ifreq ifr; +int sock; +if (net ==NULL )return ; net->mtu = mtu; + + sock =socket (AF_INET ,SOCK_DGRAM ,0 ); +if (sock <0 ) +return ; + +memset (&ifr,0 ,sizeof (ifr)); + +strncpy (ifr.ifr_name, net->if_name,sizeof (ifr.ifr_name)); + ifr.ifr_mtu = mtu; +if (ioctl (sock,SIOCSIFMTU , (caddr_t) &ifr) <0 ) +g_printerr ("Unable to change MTU\n" ); + +close (sock); }void ppp_net_process_packet (struct ppp_net *net,guint8 *packet)
Signature · 1 line
1.6.6.1
Hi Kristen,
Quoted 14 lines
--- gatchat/ppp_net.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)gatchat/ppp_net.c +2
-0@@ -50,10 +50,26 @@ struct ppp_net {void ppp_net_set_mtu (struct ppp_net *net,guint16 mtu) { +struct ifreq ifr; +int sock;
gatchat/ppp_net.c struct ppp_net { · line 64
Quoted 10 lines
gatchat/ppp_net.c +6
-0+if (net ==NULL )return ; net->mtu = mtu; + + sock =socket (AF_INET ,SOCK_DGRAM ,0 ); +if (sock <0 ) +return ; +
I think it would be a good idea to make this function return a gboolean indicating success or failure instead of silently returning.
gatchat/ppp_net.c struct ppp_net { · line 70
Quoted 6 lines
gatchat/ppp_net.c +6
-0+memset (&ifr,0 ,sizeof (ifr)); + +strncpy (ifr.ifr_name, net->if_name,sizeof (ifr.ifr_name)); + ifr.ifr_mtu = mtu; +if (ioctl (sock,SIOCSIFMTU , (caddr_t) &ifr) <0 ) +g_printerr ("Unable to change MTU\n" );
Generally the preferred style is to not have a space after memset but do have space before the if.
gatchat/ppp_net.c struct ppp_net { · line 75
Quoted 6 lines
gatchat/ppp_net.c +2
-0+ +close (sock); }void ppp_net_process_packet (struct ppp_net *net,guint8 *packet)
Otherwise patch looks good.
Regards,
-Denis