blob: 91d57304d4d312cdebc317fbe6320b21e232d892 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* $Id: isdn_concap.c,v 1.1.2.2 2004/01/12 22:37:19 keil Exp $
Joe Perches475be4d2012-02-19 19:52:38 -08002 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * Linux ISDN subsystem, protocol encapsulation
4 *
5 * This software may be used and distributed according to the terms
6 * of the GNU General Public License, incorporated herein by reference.
7 *
8 */
9
10/* Stuff to support the concap_proto by isdn4linux. isdn4linux - specific
11 * stuff goes here. Stuff that depends only on the concap protocol goes to
12 * another -- protocol specific -- source file.
13 *
14 */
15
16
17#include <linux/isdn.h>
18#include "isdn_x25iface.h"
19#include "isdn_net.h"
20#include <linux/concap.h>
21#include "isdn_concap.h"
22
23
24/* The following set of device service operations are for encapsulation
25 protocols that require for reliable datalink semantics. That means:
26
27 - before any data is to be submitted the connection must explicitly
Joe Perches475be4d2012-02-19 19:52:38 -080028 be set up.
Linus Torvalds1da177e2005-04-16 15:20:36 -070029 - after the successful set up of the connection is signalled the
Joe Perches475be4d2012-02-19 19:52:38 -080030 connection is considered to be reliably up.
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
Joe Perches475be4d2012-02-19 19:52:38 -080032 Auto-dialing ist not compatible with this requirements. Thus, auto-dialing
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 is completely bypassed.
34
35 It might be possible to implement a (non standardized) datalink protocol
36 that provides a reliable data link service while using some auto dialing
37 mechanism. Such a protocol would need an auxiliary channel (i.e. user-user-
38 signaling on the D-channel) while the B-channel is down.
Joe Perches475be4d2012-02-19 19:52:38 -080039*/
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
41
Adrian Bunk3e206b02005-06-25 14:58:35 -070042static int isdn_concap_dl_data_req(struct concap_proto *concap, struct sk_buff *skb)
Linus Torvalds1da177e2005-04-16 15:20:36 -070043{
Joe Perches475be4d2012-02-19 19:52:38 -080044 struct net_device *ndev = concap->net_dev;
Wang Chen838361f2008-12-03 15:49:46 -080045 isdn_net_dev *nd = ((isdn_net_local *) netdev_priv(ndev))->netdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 isdn_net_local *lp = isdn_net_get_locked_lp(nd);
47
Joe Perches475be4d2012-02-19 19:52:38 -080048 IX25DEBUG("isdn_concap_dl_data_req: %s \n", concap->net_dev->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 if (!lp) {
Joe Perches475be4d2012-02-19 19:52:38 -080050 IX25DEBUG("isdn_concap_dl_data_req: %s : isdn_net_send_skb returned %d\n", concap->net_dev->name, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 return 1;
52 }
53 lp->huptimer = 0;
54 isdn_net_writebuf_skb(lp, skb);
55 spin_unlock_bh(&lp->xmit_lock);
Joe Perches475be4d2012-02-19 19:52:38 -080056 IX25DEBUG("isdn_concap_dl_data_req: %s : isdn_net_send_skb returned %d\n", concap->net_dev->name, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 return 0;
58}
59
60
Adrian Bunk3e206b02005-06-25 14:58:35 -070061static int isdn_concap_dl_connect_req(struct concap_proto *concap)
Linus Torvalds1da177e2005-04-16 15:20:36 -070062{
Joe Perches475be4d2012-02-19 19:52:38 -080063 struct net_device *ndev = concap->net_dev;
Joe Perchesa17531f2010-11-15 11:12:24 +000064 isdn_net_local *lp = netdev_priv(ndev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 int ret;
Joe Perches475be4d2012-02-19 19:52:38 -080066 IX25DEBUG("isdn_concap_dl_connect_req: %s \n", ndev->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
68 /* dial ... */
Joe Perches475be4d2012-02-19 19:52:38 -080069 ret = isdn_net_dial_req(lp);
70 if (ret) IX25DEBUG("dialing failed\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 return ret;
72}
73
Adrian Bunk3e206b02005-06-25 14:58:35 -070074static int isdn_concap_dl_disconn_req(struct concap_proto *concap)
Linus Torvalds1da177e2005-04-16 15:20:36 -070075{
Joe Perches475be4d2012-02-19 19:52:38 -080076 IX25DEBUG("isdn_concap_dl_disconn_req: %s \n", concap->net_dev->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
Joe Perches475be4d2012-02-19 19:52:38 -080078 isdn_net_hangup(concap->net_dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 return 0;
80}
81
82struct concap_device_ops isdn_concap_reliable_dl_dops = {
83 &isdn_concap_dl_data_req,
84 &isdn_concap_dl_connect_req,
85 &isdn_concap_dl_disconn_req
86};
87
Linus Torvalds1da177e2005-04-16 15:20:36 -070088/* The following should better go into a dedicated source file such that
89 this sourcefile does not need to include any protocol specific header
90 files. For now:
Joe Perches475be4d2012-02-19 19:52:38 -080091*/
92struct concap_proto *isdn_concap_new(int encap)
Linus Torvalds1da177e2005-04-16 15:20:36 -070093{
Joe Perches475be4d2012-02-19 19:52:38 -080094 switch (encap) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 case ISDN_NET_ENCAP_X25IFACE:
96 return isdn_x25iface_proto_new();
97 }
98 return NULL;
99}