]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/multilink.c
CI: Updated the 'checkout' actions that were using Node.js 16 to Node.js 20. (#489)
[ppp.git] / pppd / multilink.c
index eb4074d905b395bf52db30e605bc01f457a3c531..b44d2bbe5dd4ecff2678dc065430b46da82dabed 100644 (file)
@@ -17,7 +17,7 @@
  * 3. Redistributions of any form whatsoever must retain the following
  *    acknowledgment:
  *    "This product includes software developed by Paul Mackerras
- *     <paulus@samba.org>".
+ *     <paulus@ozlabs.org>".
  *
  * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <string.h>
 #include <ctype.h>
 #include <stdlib.h>
 #include <netinet/in.h>
 #include <unistd.h>
 
-#include "pppd.h"
+#include "pppd-private.h"
 #include "fsm.h"
 #include "lcp.h"
 #include "tdb.h"
+#include "multilink.h"
 
 bool endpoint_specified;       /* user gave explicit endpoint discriminator */
 char *bundle_id;               /* identifier for our bundle */
@@ -50,13 +56,13 @@ bool multilink_master;              /* we own the multilink bundle */
 extern TDB_CONTEXT *pppdb;
 extern char db_key[];
 
-static void make_bundle_links __P((int append));
-static void remove_bundle_link __P((void));
-static void iterate_bundle_links __P((void (*func) __P((char *))));
+static void make_bundle_links(int append);
+static void remove_bundle_link(void);
+static void iterate_bundle_links(void (*func)(char *));
 
-static int get_default_epdisc __P((struct epdisc *));
-static int parse_num __P((char *str, const char *key, int *valp));
-static int owns_unit __P((TDB_DATA pid, int unit));
+static int get_default_epdisc(struct epdisc *);
+static int parse_num(char *str, const char *key, int *valp);
+static int owns_unit(TDB_DATA pid, int unit);
 
 #define set_ip_epdisc(ep, addr) do {   \
        ep->length = 4;                 \
@@ -73,8 +79,20 @@ static int owns_unit __P((TDB_DATA pid, int unit));
 
 #define process_exists(n)      (kill((n), 0) == 0 || errno != ESRCH)
 
+multilink_join_hook_fn *multilink_join_hook = NULL;
+
+bool mp_master()
+{
+    return multilink_master;
+}
+
+bool mp_on()
+{
+    return doing_multilink;
+}
+
 void
-mp_check_options()
+mp_check_options(void)
 {
        lcp_options *wo = &lcp_wantoptions[0];
        lcp_options *ao = &lcp_allowoptions[0];
@@ -102,7 +120,7 @@ mp_check_options()
  * if we are doing multilink.
  */
 int
-mp_join_bundle()
+mp_join_bundle(void)
 {
        lcp_options *go = &lcp_gotoptions[0];
        lcp_options *ho = &lcp_hisoptions[0];
@@ -134,12 +152,12 @@ mp_join_bundle()
                if (demand) {
                        /* already have a bundle */
                        cfg_bundle(0, 0, 0, 0);
-                       netif_set_mtu(0, mtu);
+                       ppp_set_mtu(0, mtu);
                        return 0;
                }
                make_new_bundle(0, 0, 0, 0);
                set_ifunit(1);
-               netif_set_mtu(0, mtu);
+               ppp_set_mtu(0, mtu);
                return 0;
        }
 
@@ -184,8 +202,8 @@ mp_join_bundle()
        mtu = MIN(ho->mrru, ao->mru);
        if (demand) {
                cfg_bundle(go->mrru, ho->mrru, go->neg_ssnhf, ho->neg_ssnhf);
-               netif_set_mtu(0, mtu);
-               script_setenv("BUNDLE", bundle_id + 7, 1);
+               ppp_set_mtu(0, mtu);
+               ppp_script_setenv("BUNDLE", bundle_id + 7, 1);
                return 0;
        }
 
@@ -219,7 +237,7 @@ mp_join_bundle()
                /* attach to existing unit */
                if (bundle_attach(unit)) {
                        set_ifunit(0);
-                       script_setenv("BUNDLE", bundle_id + 7, 0);
+                       ppp_script_setenv("BUNDLE", bundle_id + 7, 0);
                        make_bundle_links(1);
                        unlock_db();
                        info("Link attached to %s", ifname);
@@ -231,8 +249,8 @@ mp_join_bundle()
        /* we have to make a new bundle */
        make_new_bundle(go->mrru, ho->mrru, go->neg_ssnhf, ho->neg_ssnhf);
        set_ifunit(1);
-       netif_set_mtu(0, mtu);
-       script_setenv("BUNDLE", bundle_id + 7, 1);
+       ppp_set_mtu(0, mtu);
+       ppp_script_setenv("BUNDLE", bundle_id + 7, 1);
        make_bundle_links(0);
        unlock_db();
        info("New bundle %s created", ifname);
@@ -240,7 +258,7 @@ mp_join_bundle()
        return 0;
 }
 
-void mp_exit_bundle()
+void mp_exit_bundle(void)
 {
        lock_db();
        remove_bundle_link();
@@ -258,7 +276,7 @@ static void sendhup(char *str)
        }
 }
 
-void mp_bundle_terminated()
+void mp_bundle_terminated(void)
 {
        TDB_DATA key;
 
@@ -268,7 +286,7 @@ void mp_bundle_terminated()
        print_link_stats();
        if (!demand) {
                remove_pidfiles();
-               script_unsetenv("IFNAME");
+               ppp_script_unsetenv("IFNAME");
        }
 
        lock_db();
@@ -325,7 +343,7 @@ static void make_bundle_links(int append)
                free(p);
 }
 
-static void remove_bundle_link()
+static void remove_bundle_link(void)
 {
        TDB_DATA key, rec;
        char entry[32];
@@ -388,10 +406,7 @@ static void iterate_bundle_links(void (*func)(char *))
 }
 
 static int
-parse_num(str, key, valp)
-     char *str;
-     const char *key;
-     int *valp;
+parse_num(char *str, const char *key, int *valp)
 {
        char *p, *endp;
        int i;
@@ -412,9 +427,7 @@ parse_num(str, key, valp)
  * Check whether the pppd identified by `key' still owns ppp unit `unit'.
  */
 static int
-owns_unit(key, unit)
-     TDB_DATA key;
-     int unit;
+owns_unit(TDB_DATA key, int unit)
 {
        char ifkey[32];
        TDB_DATA kd, vd;
@@ -433,30 +446,23 @@ owns_unit(key, unit)
 }
 
 static int
-get_default_epdisc(ep)
-     struct epdisc *ep;
+get_default_epdisc(struct epdisc *ep)
 {
-       char *p;
        struct hostent *hp;
        u_int32_t addr;
 
        /* First try for an ethernet MAC address */
-       p = get_first_ethernet();
-       if (p != 0 && get_if_hwaddr(ep->value, p) >= 0) {
+       if (get_first_ether_hwaddr(ep->value) >= 0) {
                ep->class = EPD_MAC;
                ep->length = 6;
-               free(p);
                return 1;
        }
 
-       if (p)
-               free(p);
-
        /* see if our hostname corresponds to a reasonable IP address */
        hp = gethostbyname(hostname);
        if (hp != NULL) {
                addr = *(u_int32_t *)hp->h_addr;
-               if (!bad_ip_adrs(addr)) {
+               if (!ppp_bad_ip_addr(addr)) {
                        addr = ntohl(addr);
                        if (!LOCAL_IP_ADDR(addr)) {
                                ep->class = EPD_IP;
@@ -478,8 +484,7 @@ static char *endp_class_names[] = {
 };
 
 char *
-epdisc_to_str(ep)
-     struct epdisc *ep;
+epdisc_to_str(struct epdisc *ep)
 {
        static char str[MAX_ENDP_LEN*3+8];
        u_char *p = ep->value;
@@ -529,9 +534,7 @@ static int hexc_val(int c)
 }
 
 int
-str_to_epdisc(ep, str)
-     struct epdisc *ep;
-     char *str;
+str_to_epdisc(struct epdisc *ep, char *str)
 {
        int i, l;
        char *p, *endp;