isdn_concap.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* $Id: isdn_concap.c,v 1.1.2.2 2004/01/12 22:37:19 keil Exp $
  2. *
  3. * 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. /* Stuff to support the concap_proto by isdn4linux. isdn4linux - specific
  10. * stuff goes here. Stuff that depends only on the concap protocol goes to
  11. * another -- protocol specific -- source file.
  12. *
  13. */
  14. #include <linux/isdn.h>
  15. #include "isdn_x25iface.h"
  16. #include "isdn_net.h"
  17. #include <linux/concap.h>
  18. #include "isdn_concap.h"
  19. /* The following set of device service operations are for encapsulation
  20. protocols that require for reliable datalink semantics. That means:
  21. - before any data is to be submitted the connection must explicitly
  22. be set up.
  23. - after the successful set up of the connection is signalled the
  24. connection is considered to be reliably up.
  25. Auto-dialing ist not compatible with this requirements. Thus, auto-dialing
  26. is completely bypassed.
  27. It might be possible to implement a (non standardized) datalink protocol
  28. that provides a reliable data link service while using some auto dialing
  29. mechanism. Such a protocol would need an auxiliary channel (i.e. user-user-
  30. signaling on the D-channel) while the B-channel is down.
  31. */
  32. static int isdn_concap_dl_data_req(struct concap_proto *concap, struct sk_buff *skb)
  33. {
  34. struct net_device *ndev = concap -> net_dev;
  35. isdn_net_dev *nd = ((isdn_net_local *) netdev_priv(ndev))->netdev;
  36. isdn_net_local *lp = isdn_net_get_locked_lp(nd);
  37. IX25DEBUG( "isdn_concap_dl_data_req: %s \n", concap->net_dev->name);
  38. if (!lp) {
  39. IX25DEBUG( "isdn_concap_dl_data_req: %s : isdn_net_send_skb returned %d\n", concap -> net_dev -> name, 1);
  40. return 1;
  41. }
  42. lp->huptimer = 0;
  43. isdn_net_writebuf_skb(lp, skb);
  44. spin_unlock_bh(&lp->xmit_lock);
  45. IX25DEBUG( "isdn_concap_dl_data_req: %s : isdn_net_send_skb returned %d\n", concap -> net_dev -> name, 0);
  46. return 0;
  47. }
  48. static int isdn_concap_dl_connect_req(struct concap_proto *concap)
  49. {
  50. struct net_device *ndev = concap -> net_dev;
  51. isdn_net_local *lp = netdev_priv(ndev);
  52. int ret;
  53. IX25DEBUG( "isdn_concap_dl_connect_req: %s \n", ndev -> name);
  54. /* dial ... */
  55. ret = isdn_net_dial_req( lp );
  56. if ( ret ) IX25DEBUG("dialing failed\n");
  57. return ret;
  58. }
  59. static int isdn_concap_dl_disconn_req(struct concap_proto *concap)
  60. {
  61. IX25DEBUG( "isdn_concap_dl_disconn_req: %s \n", concap -> net_dev -> name);
  62. isdn_net_hangup( concap -> net_dev );
  63. return 0;
  64. }
  65. struct concap_device_ops isdn_concap_reliable_dl_dops = {
  66. &isdn_concap_dl_data_req,
  67. &isdn_concap_dl_connect_req,
  68. &isdn_concap_dl_disconn_req
  69. };
  70. /* The following should better go into a dedicated source file such that
  71. this sourcefile does not need to include any protocol specific header
  72. files. For now:
  73. */
  74. struct concap_proto * isdn_concap_new( int encap )
  75. {
  76. switch ( encap ) {
  77. case ISDN_NET_ENCAP_X25IFACE:
  78. return isdn_x25iface_proto_new();
  79. }
  80. return NULL;
  81. }