]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/plugins/pppol2tp/pppol2tp.c
Header file reorganization and cleaning up the public API for pppd version 2.5.0...
[ppp.git] / pppd / plugins / pppol2tp / pppol2tp.c
index c1eaa9afeb88e23df5ecdc52fd51ca21cb1e0aa9..b808df22b794b4f9ceffce38dd9839171c3ff471 100644 (file)
 #include <net/if.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/types.h>
 #include <netinet/in.h>
 #include <signal.h>
+#include <stdbool.h>
+#include <stdarg.h>
+#include <stdio.h>
+
 #include <linux/version.h>
 #include <linux/sockios.h>
 
@@ -46,7 +52,7 @@
 #include <linux/if_pppol2tp.h>
 
 #include <pppd/pppd.h>
-#include <pppd/pathnames.h>
+#include <pppd/options.h>
 #include <pppd/fsm.h>
 #include <pppd/lcp.h>
 #include <pppd/ccp.h>
@@ -86,7 +92,7 @@ void (*pppol2tp_send_accm_hook)(int tunnel_id, int session_id,
 /* Hook provided to allow other plugins to handle IP up/down */
 void (*pppol2tp_ip_updown_hook)(int tunnel_id, int session_id, int up) = NULL;
 
-static option_t pppol2tp_options[] = {
+static struct option pppol2tp_options[] = {
        { "pppol2tp", o_special, &setdevname_pppol2tp,
          "FD for PPPoL2TP socket", OPT_DEVNAM | OPT_A2STRVAL,
           &pppol2tp_fd_str },
@@ -133,7 +139,7 @@ static int setdevname_pppol2tp(char **argv)
        if (device_got_set)
                return 0;
 
-       if (!int_option(*argv, &pppol2tp_fd))
+       if (!ppp_int_option(*argv, &pppol2tp_fd))
                return 0;
 
        if(getsockname(pppol2tp_fd, (struct sockaddr *)&s, &len) < 0) {
@@ -158,7 +164,7 @@ static int setdevname_pppol2tp(char **argv)
 
        /* Setup option defaults. Compression options are disabled! */
 
-       modem = 0;
+       ppp_set_modem(false);
 
        lcp_allowoptions[0].neg_accompression = 1;
        lcp_wantoptions[0].neg_accompression = 0;
@@ -199,7 +205,7 @@ static void disconnect_pppol2tp(void)
 }
 
 static void send_config_pppol2tp(int mtu,
-                             u_int32_t asyncmap,
+                             uint32_t asyncmap,
                              int pcomp,
                              int accomp)
 {
@@ -217,14 +223,14 @@ static void send_config_pppol2tp(int mtu,
                fd = socket(AF_INET, SOCK_DGRAM, 0);
                if (fd >= 0) {
                        memset (&ifr, '\0', sizeof (ifr));
-                       strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+                       ppp_get_ifname(ifr.ifr_name, sizeof(ifr.ifr_name));
                        strlcpy(ifr.ifr_newname, pppol2tp_ifname,
                                sizeof(ifr.ifr_name));
                        ioctl(fd, SIOCSIFNAME, (caddr_t) &ifr);
-                       strlcpy(ifname, pppol2tp_ifname, 32);
+                       ppp_set_ifname(pppol2tp_ifname);
                        if (pppol2tp_debug_mask & PPPOL2TP_MSG_CONTROL) {
                                dbglog("ppp%d: interface name %s",
-                                      ifunit, ifname);
+                                       ppp_ifunit(), ppp_ifname());
                        }
                }
                close(fd);
@@ -234,7 +240,7 @@ static void send_config_pppol2tp(int mtu,
                warn("Overriding mtu %d to %d", mtu, lcp_allowoptions[0].mru);
                mtu = lcp_allowoptions[0].mru;
        }
-       netif_set_mtu(ifunit, mtu);
+       ppp_set_mtu(ppp_ifunit(), mtu);
 
        reorderto[0] = '\0';
        if (pppol2tp_reorder_timeout > 0)
@@ -279,7 +285,7 @@ static void send_config_pppol2tp(int mtu,
 }
 
 static void recv_config_pppol2tp(int mru,
-                             u_int32_t asyncmap,
+                             uint32_t asyncmap,
                              int pcomp,
                              int accomp)
 {
@@ -288,7 +294,7 @@ static void recv_config_pppol2tp(int mru,
                     lcp_allowoptions[0].mru);
                mru = lcp_allowoptions[0].mru;
        }
-       if ((ifunit >= 0) && ioctl(pppol2tp_fd, PPPIOCSMRU, (caddr_t) &mru) < 0)
+       if ((ppp_ifunit() >= 0) && ioctl(pppol2tp_fd, PPPIOCSMRU, (caddr_t) &mru) < 0)
                error("Couldn't set PPP MRU: %m");
 }
 
@@ -496,22 +502,22 @@ void plugin_init(void)
 {
 #if defined(__linux__)
        extern int new_style_driver;    /* From sys-linux.c */
-       if (!ppp_available() && !new_style_driver)
+       if (!ppp_check_kernel_support() && !new_style_driver)
                fatal("Kernel doesn't support ppp_generic - "
                    "needed for PPPoL2TP");
 #else
        fatal("No PPPoL2TP support on this OS");
 #endif
-       add_options(pppol2tp_options);
+       ppp_add_options(pppol2tp_options);
 
        /* Hook up ip up/down notifiers to send indicator to openl2tpd
         * that the link is up
         */
-       add_notifier(&ip_up_notifier, pppol2tp_ip_up, NULL);
-       add_notifier(&ip_down_notifier, pppol2tp_ip_down, NULL);
-#ifdef INET6
-       add_notifier(&ipv6_up_notifier, pppol2tp_ip_up, NULL);
-       add_notifier(&ipv6_down_notifier, pppol2tp_ip_down, NULL);
+       ppp_add_notify(NF_IP_UP, pppol2tp_ip_up, NULL);
+       ppp_add_notify(NF_IP_DOWN, pppol2tp_ip_down, NULL);
+#ifdef PPP_WITH_IPV6CP
+       ppp_add_notify(NF_IPV6_UP, pppol2tp_ip_up, NULL);
+       ppp_add_notify(NF_IPV6_DOWN, pppol2tp_ip_down, NULL);
 #endif
 }
 
@@ -521,8 +527,8 @@ struct channel pppol2tp_channel = {
     .check_options = &pppol2tp_check_options,
     .connect = &connect_pppol2tp,
     .disconnect = &disconnect_pppol2tp,
-    .establish_ppp = &generic_establish_ppp,
-    .disestablish_ppp = &generic_disestablish_ppp,
+    .establish_ppp = &ppp_generic_establish,
+    .disestablish_ppp = &ppp_generic_disestablish,
     .send_config = &send_config_pppol2tp,
     .recv_config = &recv_config_pppol2tp,
     .close = NULL,