root/drivers/isdn/pcbit/callbacks.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. cb_out_1
  2. cb_out_2
  3. cb_out_3
  4. cb_in_1
  5. cb_in_2
  6. cb_in_3
  7. cb_disc_1
  8. cb_disc_2
  9. cb_disc_3
  10. cb_notdone
  11. cb_selp_1
  12. cb_open

   1 /*
   2  * Copyright (C) 1996 Universidade de Lisboa
   3  * 
   4  * Written by Pedro Roque Marques (roque@di.fc.ul.pt)
   5  *
   6  * This software may be used and distributed according to the terms of 
   7  * the GNU Public License, incorporated herein by reference.
   8  */
   9 
  10 /*        
  11  *        callbacks for the FSM
  12  */
  13 
  14 #define __NO_VERSION__
  15 
  16 #include <linux/module.h>
  17 
  18 #include <linux/sched.h>
  19 #include <linux/string.h>
  20 #include <linux/kernel.h>
  21 
  22 #include <linux/types.h>
  23 #include <linux/malloc.h>
  24 #include <linux/mm.h>
  25 #include <linux/tqueue.h>
  26 #include <linux/skbuff.h>
  27 
  28 #include <asm/io.h>
  29 
  30 #include <linux/isdnif.h>
  31 
  32 #include "pcbit.h"
  33 #include "layer2.h"
  34 #include "edss1.h"
  35 #include "callbacks.h"
  36 #include "capi.h"
  37 
  38 ushort last_ref_num = 1;
  39 
  40 /*
  41  *  send_conn_req
  42  *
  43  */
  44 
  45 void cb_out_1(struct pcbit_dev * dev, struct pcbit_chan* chan, 
     /* [previous][next][first][last][top][bottom][index][help] */
  46               struct callb_data *cbdata) 
  47 {
  48         struct sk_buff *skb;
  49         int len;
  50         ushort refnum;
  51 
  52 
  53 #ifdef DEBUG
  54         printk(KERN_DEBUG "Called Party Number: %s\n", 
  55                cbdata->data.setup.CalledPN);
  56 #endif
  57         /*
  58          * hdr - kmalloc in capi_conn_req
  59          *     - kfree   when msg has been sent
  60          */
  61 
  62         if ((len = capi_conn_req(cbdata->data.setup.CalledPN, &skb)) < 0)
  63         {
  64                 printk("capi_conn_req failed\n");
  65                 return;
  66         }
  67 
  68 
  69         refnum = last_ref_num++ & 0x7fffU;
  70 
  71         chan->callref = 0;
  72         chan->layer2link = 0;
  73         chan->snum = 0;
  74         chan->s_refnum = refnum;
  75 
  76         pcbit_l2_write(dev, MSG_CONN_REQ, refnum, skb, len);
  77 }
  78 
  79 /*
  80  *  rcv CONNECT
  81  *  will go into ACTIVE state
  82  *  send CONN_ACTIVE_RESP
  83  *  send Select protocol request 
  84  */
  85 
  86 void cb_out_2(struct pcbit_dev * dev, struct pcbit_chan* chan, 
     /* [previous][next][first][last][top][bottom][index][help] */
  87               struct callb_data *data) 
  88 {
  89         isdn_ctrl ictl;
  90         struct sk_buff *skb;
  91         int len;
  92         ushort refnum;
  93 
  94         if ((len=capi_conn_active_resp(chan, &skb)) < 0)
  95         {
  96                 printk("capi_conn_active_req failed\n");
  97                 return;
  98         }
  99 
 100         refnum = last_ref_num++ & 0x7fffU;
 101         chan->s_refnum = refnum;
 102 
 103         pcbit_l2_write(dev, MSG_CONN_ACTV_RESP, refnum, skb, len);
 104 
 105 
 106         ictl.command = ISDN_STAT_DCONN;
 107         ictl.driver=dev->id;
 108         ictl.arg=chan->id;
 109         dev->dev_if->statcallb(&ictl);
 110 
 111         /* ACTIVE D-channel */
 112 
 113         /* Select protocol  */
 114 
 115         if ((len=capi_select_proto_req(chan, &skb, 1 /*outgoing*/)) < 0) { 
 116                 printk("capi_select_proto_req failed\n");
 117                 return;
 118         }
 119 
 120         refnum = last_ref_num++ & 0x7fffU;
 121         chan->s_refnum = refnum;
 122 
 123         pcbit_l2_write(dev, MSG_SELP_REQ, refnum, skb, len);
 124 }
 125 
 126 
 127 /*
 128  * Disconnect received (actually RELEASE COMPLETE) 
 129  * This means we were not able to establish connection with remote
 130  * Inform the big boss above
 131  */
 132 void cb_out_3(struct pcbit_dev * dev, struct pcbit_chan* chan,
     /* [previous][next][first][last][top][bottom][index][help] */
 133               struct callb_data *data) 
 134 {
 135         isdn_ctrl ictl;
 136 
 137         ictl.command = ISDN_STAT_DHUP;
 138         ictl.driver=dev->id;
 139         ictl.arg=chan->id;
 140         dev->dev_if->statcallb(&ictl);
 141 }
 142 
 143 
 144 /*
 145  * Incoming call received
 146  * inform user
 147  */
 148 
 149 void cb_in_1(struct pcbit_dev * dev, struct pcbit_chan* chan,
     /* [previous][next][first][last][top][bottom][index][help] */
 150              struct callb_data *cbdata) 
 151 {
 152         isdn_ctrl ictl;
 153         unsigned short refnum;
 154         struct sk_buff *skb;
 155         int len;
 156 
 157 
 158         ictl.command = ISDN_STAT_ICALL;
 159         ictl.driver=dev->id;
 160         ictl.arg=chan->id;
 161         
 162         /*
 163          *  ictl.num >= strlen() + strlen() + 5
 164          */
 165 
 166         if (cbdata->data.setup.CalledPN) 
 167                 sprintf(ictl.num, "%s,%d,%d,%s", 
 168                         cbdata->data.setup.CallingPN, 
 169                         7, 0, 
 170                         cbdata->data.setup.CalledPN);
 171         
 172         else
 173                 sprintf(ictl.num, "%s,%d,%d,%s", 
 174                         cbdata->data.setup.CallingPN,
 175                         7, 0, 
 176                         "0");
 177 
 178 
 179 #ifdef DEBUG
 180         printk(KERN_DEBUG "statstr: %s\n", ictl.num);
 181 #endif
 182 
 183         dev->dev_if->statcallb(&ictl);
 184 
 185         
 186         if ((len=capi_conn_resp(chan, &skb)) < 0) {
 187                 printk(KERN_DEBUG "capi_conn_resp failed\n");
 188                 return;
 189         }
 190 
 191         refnum = last_ref_num++ & 0x7fffU;
 192         chan->s_refnum = refnum;
 193 
 194         pcbit_l2_write(dev, MSG_CONN_RESP, refnum, skb, len);
 195 }
 196 
 197 /*
 198  * user has replied
 199  * open the channel
 200  * send CONNECT message CONNECT_ACTIVE_REQ in CAPI
 201  */
 202 
 203 void cb_in_2(struct pcbit_dev * dev, struct pcbit_chan* chan,
     /* [previous][next][first][last][top][bottom][index][help] */
 204              struct callb_data *data)
 205 {
 206         unsigned short refnum;
 207         struct sk_buff *skb;
 208         int len;
 209         
 210         if ((len = capi_conn_active_req(chan, &skb)) < 0) {        
 211                 printk(KERN_DEBUG "capi_conn_active_req failed\n");
 212                 return;
 213         }
 214 
 215 
 216         refnum = last_ref_num++ & 0x7fffU;
 217         chan->s_refnum = refnum;
 218 
 219         printk(KERN_DEBUG "sending MSG_CONN_ACTV_REQ\n");
 220         pcbit_l2_write(dev, MSG_CONN_ACTV_REQ, refnum, skb, len);
 221 }
 222 
 223 /*
 224  * CONN_ACK arrived
 225  * start b-proto selection
 226  *
 227  */
 228 
 229 void cb_in_3(struct pcbit_dev * dev, struct pcbit_chan* chan, 
     /* [previous][next][first][last][top][bottom][index][help] */
 230              struct callb_data *data)
 231 {
 232         unsigned short refnum;
 233         struct sk_buff *skb;
 234         int len;
 235         
 236         if ((len = capi_select_proto_req(chan, &skb, 0 /*incoming*/)) < 0)
 237         {
 238                 printk("capi_select_proto_req failed\n");
 239                 return;
 240         }
 241 
 242         refnum = last_ref_num++ & 0x7fffU;
 243         chan->s_refnum = refnum;
 244 
 245         pcbit_l2_write(dev, MSG_SELP_REQ, refnum, skb, len);
 246 
 247 }
 248 
 249 
 250 /*
 251  * Received disconnect ind on active state
 252  * send disconnect resp
 253  * send msg to user
 254  */
 255 void cb_disc_1(struct pcbit_dev * dev, struct pcbit_chan* chan, 
     /* [previous][next][first][last][top][bottom][index][help] */
 256                struct callb_data *data)
 257 {
 258         struct sk_buff *skb;
 259         int len;
 260         ushort refnum;
 261         isdn_ctrl ictl;
 262   
 263         if ((len = capi_disc_resp(chan, &skb)) < 0) {
 264                 printk("capi_disc_resp failed\n");
 265                 return;
 266         }
 267 
 268         refnum = last_ref_num++ & 0x7fffU;
 269         chan->s_refnum = refnum;
 270 
 271         pcbit_l2_write(dev, MSG_DISC_RESP, refnum, skb, len);    
 272 
 273         ictl.command = ISDN_STAT_BHUP;
 274         ictl.driver=dev->id;
 275         ictl.arg=chan->id;
 276         dev->dev_if->statcallb(&ictl);
 277 }
 278 
 279         
 280 /*
 281  *  User HANGUP on active/call proceeding state
 282  *  send disc.req
 283  */
 284 void cb_disc_2(struct pcbit_dev * dev, struct pcbit_chan* chan, 
     /* [previous][next][first][last][top][bottom][index][help] */
 285                struct callb_data *data)
 286 {
 287         struct sk_buff *skb;
 288         int len;
 289         ushort refnum;
 290 
 291         if ((len = capi_disc_req(chan->callref, &skb, CAUSE_NORMAL)) < 0)
 292         {
 293                 printk("capi_disc_req failed\n");
 294                 return;
 295         }
 296 
 297         refnum = last_ref_num++ & 0x7fffU;
 298         chan->s_refnum = refnum;
 299 
 300         pcbit_l2_write(dev, MSG_DISC_REQ, refnum, skb, len);  
 301 }
 302 
 303 /*
 304  *  Disc confirm received send BHUP
 305  *  Problem: when the HL driver sends the disc req itself
 306  *           LL receives BHUP
 307  */
 308 void cb_disc_3(struct pcbit_dev * dev, struct pcbit_chan* chan, 
     /* [previous][next][first][last][top][bottom][index][help] */
 309                struct callb_data *data)
 310 {
 311         isdn_ctrl ictl;
 312 
 313         ictl.command = ISDN_STAT_BHUP;
 314         ictl.driver=dev->id;
 315         ictl.arg=chan->id;
 316         dev->dev_if->statcallb(&ictl);
 317 }
 318 
 319 void cb_notdone(struct pcbit_dev * dev, struct pcbit_chan* chan, 
     /* [previous][next][first][last][top][bottom][index][help] */
 320                 struct callb_data *data)
 321 {
 322 }
 323 
 324 /*
 325  * send activate b-chan protocol
 326  */
 327 void cb_selp_1(struct pcbit_dev * dev, struct pcbit_chan* chan, 
     /* [previous][next][first][last][top][bottom][index][help] */
 328                struct callb_data *data) 
 329 {
 330         struct sk_buff *skb;
 331         int len;
 332         ushort refnum;
 333 
 334         if ((len = capi_activate_transp_req(chan, &skb)) < 0)
 335         {
 336                 printk("capi_conn_activate_transp_req failed\n");
 337                 return;
 338         }
 339 
 340         refnum = last_ref_num++ & 0x7fffU;
 341         chan->s_refnum = refnum;
 342 
 343         pcbit_l2_write(dev, MSG_ACT_TRANSP_REQ, refnum, skb, len);
 344 }
 345 
 346 /*
 347  *  Inform User that the B-channel is available
 348  */
 349 void cb_open(struct pcbit_dev * dev, struct pcbit_chan* chan, 
     /* [previous][next][first][last][top][bottom][index][help] */
 350              struct callb_data *data) 
 351 {
 352         isdn_ctrl ictl;
 353 
 354         ictl.command = ISDN_STAT_BCONN;
 355         ictl.driver=dev->id;
 356         ictl.arg=chan->id;
 357         dev->dev_if->statcallb(&ictl);
 358 }
 359 
 360 
 361 

/* [previous][next][first][last][top][bottom][index][help] */