]> git.hungrycats.org Git - linux/commitdiff
ISDN: Extend state machine
authorKai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
Sun, 6 Oct 2002 19:19:32 +0000 (14:19 -0500)
committerKai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
Sun, 6 Oct 2002 19:19:32 +0000 (14:19 -0500)
Do dial-out via the state machine as well, and add a state
to wait for the D-channel hangup as well before unbinding
the isdn_net_dev.

Plus assorted compile/warning fixes.

drivers/isdn/i4l/isdn_fsm.c
drivers/isdn/i4l/isdn_fsm.h
drivers/isdn/i4l/isdn_net_lib.c

index 53fe9cae25f216712d95711a92cf5855032908f7..5e3999d9c9d606e2f52e08936ba82b5ee6b8b78c 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/errno.h>
+#include <linux/string.h>
 #include "isdn_fsm.h"
 
 int
index 75c73038ba31f70d6d7c370542bf528659e0af33..1dd163826fcebb2b462be24d1ce628cf9259558a 100644 (file)
  *
  */
 
-#ifndef __FSM_H__
-#define __FSM_H__
+#ifndef __ISDN_FSM_H__
+#define __ISDN_FSM_H__
 
+#include <linux/kernel.h>
 #include <linux/timer.h>
 
 struct fsm_inst;
index 7761e2a00497f34ef61415faf40c3e0e11819064..579f58ef30069146b37aa380a1ae53775adf4d86 100644 (file)
@@ -44,6 +44,7 @@ enum {
        ST_IN_WAIT_DCONN,
        ST_IN_WAIT_BCONN,
        ST_ACTIVE,
+       ST_WAIT_DHUP,
        ST_WAIT_BEFORE_CB,
        ST_OUT_DIAL_WAIT,
 };
@@ -55,6 +56,7 @@ static char *isdn_net_st_str[] = {
        "ST_IN_WAIT_DCONN",
        "ST_IN_WAIT_BCONN",
        "ST_ACTIVE",
+       "ST_WAIT_DHUP",
        "ST_WAIT_BEFORE_CB",
        "ST_OUT_DIAL_WAIT",
 };
@@ -72,6 +74,7 @@ enum {
        EV_STAT_BHUP,
        EV_STAT_CINF,
        EV_STAT_BSENT,
+       EV_CMD_DIAL,
 };
 
 static char *isdn_net_ev_str[] = {
@@ -87,6 +90,7 @@ static char *isdn_net_ev_str[] = {
        "EV_STAT_BHUP",
        "EV_STAT_CINF",
        "EV_STAT_BSENT",
+       "EV_CMD_DIAL",
 };
 
 /* ====================================================================== */
@@ -1083,9 +1087,6 @@ isdn_net_tasklet(unsigned long data)
 /* call control state machine                                             */
 /* ====================================================================== */
 
-static void dialout_first(struct fsm_inst *fi, int pr, void *arg);
-static void dialout_next(struct fsm_inst *fi, int pr, void *arg);
-
 // FIXME
 int isdn_net_online(isdn_net_dev *idev)
 {
@@ -1182,8 +1183,7 @@ isdn_net_dial(isdn_net_dev *idev)
                goto err;
 
        /* Initiate dialing */
-       dialout_first(&idev->fi, 0, NULL); // FIXME
-
+       fsm_event(&idev->fi, EV_CMD_DIAL, NULL);
        return 0;
 
  err:
@@ -1203,7 +1203,7 @@ isdn_net_accept(isdn_net_dev *idev, int slot, char *nr)
        
        idev->outgoing = 0;
        idev->charge_state = ST_CHARGE_NULL;
-       /* Got incoming Call, setup L2 and L3 protocols,
+       /* Got incoming call, setup L2 and L3 protocols,
         * then wait for D-Channel-connect
         */
        cmd.arg = mlp->l2_proto << 8;
@@ -1278,6 +1278,8 @@ get_outgoing_phone(isdn_net_dev *idev)
        return NULL;
 }
 
+static void dialout_next(struct fsm_inst *fi, int pr, void *arg);
+
 /* Initiate dialout. */
 
 static void
@@ -1432,6 +1434,31 @@ bconn(struct fsm_inst *fi, int pr, void *arg)
                isdn_net_dev_wake_queue(idev);
 }
 
+static void
+bhup(struct fsm_inst *fi, int pr, void *arg)
+{
+       isdn_net_dev *idev = fi->userdata;
+       isdn_net_local *mlp = idev->mlp;
+
+       del_timer(&idev->dial_timer);
+       if (mlp->ops->disconnected)
+               mlp->ops->disconnected(idev);
+
+       printk(KERN_INFO "%s: disconnected\n", idev->name);
+       fsm_change_state(fi, ST_WAIT_DHUP);
+       isdn_net_rm_from_bundle(idev);
+}
+
+static void
+dhup(struct fsm_inst *fi, int pr, void *arg)
+{
+       isdn_net_dev *idev = fi->userdata;
+
+       printk(KERN_INFO "%s: Chargesum is %d\n", idev->name, idev->charge);
+       isdn_slot_all_eaz(idev->isdn_slot);
+       isdn_net_unbind_channel(idev);
+}
+
 /* Check if it's time for idle hang-up */
 
 static void
@@ -1483,25 +1510,6 @@ got_cinf(struct fsm_inst *fi, int pr, void *arg)
        dbg_net_dial("%s: got CINF\n", idev->name);
 }
 
-static void
-disconnected(struct fsm_inst *fi, int pr, void *arg)
-{
-       isdn_net_dev *idev = fi->userdata;
-       isdn_net_local *mlp = idev->mlp;
-
-       del_timer(&idev->dial_timer);
-       if (mlp->ops->disconnected)
-               mlp->ops->disconnected(idev);
-       
-       isdn_net_rm_from_bundle(idev);
-
-       printk(KERN_INFO "%s: disconnected\n", idev->name);
-       printk(KERN_INFO "%s: Chargesum is %d\n", idev->name,
-              idev->charge);
-       isdn_slot_all_eaz(idev->isdn_slot);
-       isdn_net_unbind_channel(idev);
-}
-
 /* Perform hangup for a net-interface. */
 
 int
@@ -1577,6 +1585,8 @@ got_bsent(struct fsm_inst *fi, int pr, void *arg)
 }
 
 static struct fsm_node isdn_net_fn_tbl[] = {
+       { ST_NULL,           EV_CMD_DIAL,        dialout_first },
+
        { ST_OUT_WAIT_DCONN, EV_TIMER_DIAL,      dial_timeout  },
        { ST_OUT_WAIT_DCONN, EV_STAT_DCONN,      out_dconn     },
        { ST_OUT_WAIT_DCONN, EV_STAT_DHUP,       connect_fail  },
@@ -1595,10 +1605,12 @@ static struct fsm_node isdn_net_fn_tbl[] = {
        { ST_IN_WAIT_BCONN,  EV_STAT_DHUP,       connect_fail  },
 
        { ST_ACTIVE,         EV_TIMER_HUP,       check_hup     },
-       { ST_ACTIVE,         EV_STAT_BHUP,       disconnected  },
+       { ST_ACTIVE,         EV_STAT_BHUP,       bhup          },
        { ST_ACTIVE,         EV_STAT_CINF,       got_cinf      },
        { ST_ACTIVE,         EV_STAT_BSENT,      got_bsent     },
 
+       { ST_WAIT_DHUP,      EV_STAT_DHUP,       dhup          },
+
        { ST_WAIT_BEFORE_CB, EV_TIMER_CB_IN,     dialout_first },
 
        { ST_OUT_DIAL_WAIT,  EV_TIMER_DIAL_WAIT, dialout_next  },