OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [uclinux/] [uClinux-2.0.x/] [drivers/] [isdn/] [pcbit/] [callbacks.c] - Blame information for rev 1765

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/*
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,
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,
63
                                 chan->proto)) < 0)
64
        {
65
                printk("capi_conn_req failed\n");
66
                return;
67
        }
68
 
69
 
70
        refnum = last_ref_num++ & 0x7fffU;
71
 
72
        chan->callref = 0;
73
        chan->layer2link = 0;
74
        chan->snum = 0;
75
        chan->s_refnum = refnum;
76
 
77
        pcbit_l2_write(dev, MSG_CONN_REQ, refnum, skb, len);
78
}
79
 
80
/*
81
 *  rcv CONNECT
82
 *  will go into ACTIVE state
83
 *  send CONN_ACTIVE_RESP
84
 *  send Select protocol request
85
 */
86
 
87
void cb_out_2(struct pcbit_dev * dev, struct pcbit_chan* chan,
88
              struct callb_data *data)
89
{
90
        isdn_ctrl ictl;
91
        struct sk_buff *skb;
92
        int len;
93
        ushort refnum;
94
 
95
        if ((len=capi_conn_active_resp(chan, &skb)) < 0)
96
        {
97
                printk("capi_conn_active_req failed\n");
98
                return;
99
        }
100
 
101
        refnum = last_ref_num++ & 0x7fffU;
102
        chan->s_refnum = refnum;
103
 
104
        pcbit_l2_write(dev, MSG_CONN_ACTV_RESP, refnum, skb, len);
105
 
106
 
107
        ictl.command = ISDN_STAT_DCONN;
108
        ictl.driver=dev->id;
109
        ictl.arg=chan->id;
110
        dev->dev_if->statcallb(&ictl);
111
 
112
        /* ACTIVE D-channel */
113
 
114
        /* Select protocol  */
115
 
116
        if ((len=capi_select_proto_req(chan, &skb, 1 /*outgoing*/)) < 0) {
117
                printk("capi_select_proto_req failed\n");
118
                return;
119
        }
120
 
121
        refnum = last_ref_num++ & 0x7fffU;
122
        chan->s_refnum = refnum;
123
 
124
        pcbit_l2_write(dev, MSG_SELP_REQ, refnum, skb, len);
125
}
126
 
127
 
128
/*
129
 * Disconnect received (actually RELEASE COMPLETE)
130
 * This means we were not able to establish connection with remote
131
 * Inform the big boss above
132
 */
133
void cb_out_3(struct pcbit_dev * dev, struct pcbit_chan* chan,
134
              struct callb_data *data)
135
{
136
        isdn_ctrl ictl;
137
 
138
        ictl.command = ISDN_STAT_DHUP;
139
        ictl.driver=dev->id;
140
        ictl.arg=chan->id;
141
        dev->dev_if->statcallb(&ictl);
142
}
143
 
144
 
145
/*
146
 * Incoming call received
147
 * inform user
148
 */
149
 
150
void cb_in_1(struct pcbit_dev * dev, struct pcbit_chan* chan,
151
             struct callb_data *cbdata)
152
{
153
        isdn_ctrl ictl;
154
        unsigned short refnum;
155
        struct sk_buff *skb;
156
        int len;
157
 
158
 
159
        ictl.command = ISDN_STAT_ICALL;
160
        ictl.driver=dev->id;
161
        ictl.arg=chan->id;
162
 
163
        /*
164
         *  ictl.num >= strlen() + strlen() + 5
165
         */
166
 
167
        if (cbdata->data.setup.CallingPN == NULL)
168
                strcpy(ictl.parm.setup.phone, "0");
169
        else
170
                strcpy(ictl.parm.setup.phone, cbdata->data.setup.CallingPN);
171
        if (cbdata->data.setup.CalledPN == NULL)
172
                strcpy(ictl.parm.setup.eazmsn, "0");
173
        else
174
                strcpy(ictl.parm.setup.eazmsn, cbdata->data.setup.CalledPN);
175
        ictl.parm.setup.si1 = 7;
176
        ictl.parm.setup.si2 = 0;
177
        ictl.parm.setup.plan = 0;
178
        ictl.parm.setup.screen = 0;
179
 
180
#ifdef DEBUG
181
        printk(KERN_DEBUG "statstr: %s\n", ictl.num);
182
#endif
183
 
184
        dev->dev_if->statcallb(&ictl);
185
 
186
 
187
        if ((len=capi_conn_resp(chan, &skb)) < 0) {
188
                printk(KERN_DEBUG "capi_conn_resp failed\n");
189
                return;
190
        }
191
 
192
        refnum = last_ref_num++ & 0x7fffU;
193
        chan->s_refnum = refnum;
194
 
195
        pcbit_l2_write(dev, MSG_CONN_RESP, refnum, skb, len);
196
}
197
 
198
/*
199
 * user has replied
200
 * open the channel
201
 * send CONNECT message CONNECT_ACTIVE_REQ in CAPI
202
 */
203
 
204
void cb_in_2(struct pcbit_dev * dev, struct pcbit_chan* chan,
205
             struct callb_data *data)
206
{
207
        unsigned short refnum;
208
        struct sk_buff *skb;
209
        int len;
210
 
211
        if ((len = capi_conn_active_req(chan, &skb)) < 0) {
212
                printk(KERN_DEBUG "capi_conn_active_req failed\n");
213
                return;
214
        }
215
 
216
 
217
        refnum = last_ref_num++ & 0x7fffU;
218
        chan->s_refnum = refnum;
219
 
220
        printk(KERN_DEBUG "sending MSG_CONN_ACTV_REQ\n");
221
        pcbit_l2_write(dev, MSG_CONN_ACTV_REQ, refnum, skb, len);
222
}
223
 
224
/*
225
 * CONN_ACK arrived
226
 * start b-proto selection
227
 *
228
 */
229
 
230
void cb_in_3(struct pcbit_dev * dev, struct pcbit_chan* chan,
231
             struct callb_data *data)
232
{
233
        unsigned short refnum;
234
        struct sk_buff *skb;
235
        int len;
236
 
237
        if ((len = capi_select_proto_req(chan, &skb, 0 /*incoming*/)) < 0)
238
        {
239
                printk("capi_select_proto_req failed\n");
240
                return;
241
        }
242
 
243
        refnum = last_ref_num++ & 0x7fffU;
244
        chan->s_refnum = refnum;
245
 
246
        pcbit_l2_write(dev, MSG_SELP_REQ, refnum, skb, len);
247
 
248
}
249
 
250
 
251
/*
252
 * Received disconnect ind on active state
253
 * send disconnect resp
254
 * send msg to user
255
 */
256
void cb_disc_1(struct pcbit_dev * dev, struct pcbit_chan* chan,
257
               struct callb_data *data)
258
{
259
        struct sk_buff *skb;
260
        int len;
261
        ushort refnum;
262
        isdn_ctrl ictl;
263
 
264
        if ((len = capi_disc_resp(chan, &skb)) < 0) {
265
                printk("capi_disc_resp failed\n");
266
                return;
267
        }
268
 
269
        refnum = last_ref_num++ & 0x7fffU;
270
        chan->s_refnum = refnum;
271
 
272
        pcbit_l2_write(dev, MSG_DISC_RESP, refnum, skb, len);
273
 
274
        ictl.command = ISDN_STAT_BHUP;
275
        ictl.driver=dev->id;
276
        ictl.arg=chan->id;
277
        dev->dev_if->statcallb(&ictl);
278
}
279
 
280
 
281
/*
282
 *  User HANGUP on active/call proceeding state
283
 *  send disc.req
284
 */
285
void cb_disc_2(struct pcbit_dev * dev, struct pcbit_chan* chan,
286
               struct callb_data *data)
287
{
288
        struct sk_buff *skb;
289
        int len;
290
        ushort refnum;
291
 
292
        if ((len = capi_disc_req(chan->callref, &skb, CAUSE_NORMAL)) < 0)
293
        {
294
                printk("capi_disc_req failed\n");
295
                return;
296
        }
297
 
298
        refnum = last_ref_num++ & 0x7fffU;
299
        chan->s_refnum = refnum;
300
 
301
        pcbit_l2_write(dev, MSG_DISC_REQ, refnum, skb, len);
302
}
303
 
304
/*
305
 *  Disc confirm received send BHUP
306
 *  Problem: when the HL driver sends the disc req itself
307
 *           LL receives BHUP
308
 */
309
void cb_disc_3(struct pcbit_dev * dev, struct pcbit_chan* chan,
310
               struct callb_data *data)
311
{
312
        isdn_ctrl ictl;
313
 
314
        ictl.command = ISDN_STAT_BHUP;
315
        ictl.driver=dev->id;
316
        ictl.arg=chan->id;
317
        dev->dev_if->statcallb(&ictl);
318
}
319
 
320
void cb_notdone(struct pcbit_dev * dev, struct pcbit_chan* chan,
321
                struct callb_data *data)
322
{
323
}
324
 
325
/*
326
 * send activate b-chan protocol
327
 */
328
void cb_selp_1(struct pcbit_dev * dev, struct pcbit_chan* chan,
329
               struct callb_data *data)
330
{
331
        struct sk_buff *skb;
332
        int len;
333
        ushort refnum;
334
 
335
        if ((len = capi_activate_transp_req(chan, &skb)) < 0)
336
        {
337
                printk("capi_conn_activate_transp_req failed\n");
338
                return;
339
        }
340
 
341
        refnum = last_ref_num++ & 0x7fffU;
342
        chan->s_refnum = refnum;
343
 
344
        pcbit_l2_write(dev, MSG_ACT_TRANSP_REQ, refnum, skb, len);
345
}
346
 
347
/*
348
 *  Inform User that the B-channel is available
349
 */
350
void cb_open(struct pcbit_dev * dev, struct pcbit_chan* chan,
351
             struct callb_data *data)
352
{
353
        isdn_ctrl ictl;
354
 
355
        ictl.command = ISDN_STAT_BCONN;
356
        ictl.driver=dev->id;
357
        ictl.arg=chan->id;
358
        dev->dev_if->statcallb(&ictl);
359
}
360
 
361
 
362
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.