concap.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* $Id: concap.h,v 1.3.2.2 2004/01/12 23:08:35 keil Exp $
  2. *
  3. * Copyright 1997 by Henner Eisen <eis@baty.hanse.de>
  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. #ifndef _LINUX_CONCAP_H
  9. #define _LINUX_CONCAP_H
  10. #include <linux/skbuff.h>
  11. #include <linux/netdevice.h>
  12. /* Stuff to support encapsulation protocols genericly. The encapsulation
  13. protocol is processed at the uppermost layer of the network interface.
  14. Based on a ideas developed in a 'synchronous device' thread in the
  15. linux-x25 mailing list contributed by Alan Cox, Thomasz Motylewski
  16. and Jonathan Naylor.
  17. For more documetation on this refer to Documentation/isdn/README.concap
  18. */
  19. struct concap_proto_ops;
  20. struct concap_device_ops;
  21. /* this manages all data needed by the encapsulation protocol
  22. */
  23. struct concap_proto{
  24. struct net_device *net_dev; /* net device using our service */
  25. struct concap_device_ops *dops; /* callbacks provided by device */
  26. struct concap_proto_ops *pops; /* callbacks provided by us */
  27. spinlock_t lock;
  28. int flags;
  29. void *proto_data; /* protocol specific private data, to
  30. be accessed via *pops methods only*/
  31. /*
  32. :
  33. whatever
  34. :
  35. */
  36. };
  37. /* Operations to be supported by the net device. Called by the encapsulation
  38. * protocol entity. No receive method is offered because the encapsulation
  39. * protocol directly calls netif_rx().
  40. */
  41. struct concap_device_ops{
  42. /* to request data is submitted by device*/
  43. int (*data_req)(struct concap_proto *, struct sk_buff *);
  44. /* Control methods must be set to NULL by devices which do not
  45. support connection control.*/
  46. /* to request a connection is set up */
  47. int (*connect_req)(struct concap_proto *);
  48. /* to request a connection is released */
  49. int (*disconn_req)(struct concap_proto *);
  50. };
  51. /* Operations to be supported by the encapsulation protocol. Called by
  52. * device driver.
  53. */
  54. struct concap_proto_ops{
  55. /* create a new encapsulation protocol instance of same type */
  56. struct concap_proto * (*proto_new) (void);
  57. /* delete encapsulation protocol instance and free all its resources.
  58. cprot may no loger be referenced after calling this */
  59. void (*proto_del)(struct concap_proto *cprot);
  60. /* initialize the protocol's data. To be called at interface startup
  61. or when the device driver resets the interface. All services of the
  62. encapsulation protocol may be used after this*/
  63. int (*restart)(struct concap_proto *cprot,
  64. struct net_device *ndev,
  65. struct concap_device_ops *dops);
  66. /* inactivate an encapsulation protocol instance. The encapsulation
  67. protocol may not call any *dops methods after this. */
  68. int (*close)(struct concap_proto *cprot);
  69. /* process a frame handed down to us by upper layer */
  70. int (*encap_and_xmit)(struct concap_proto *cprot, struct sk_buff *skb);
  71. /* to be called for each data entity received from lower layer*/
  72. int (*data_ind)(struct concap_proto *cprot, struct sk_buff *skb);
  73. /* to be called when a connection was set up/down.
  74. Protocols that don't process these primitives might fill in
  75. dummy methods here */
  76. int (*connect_ind)(struct concap_proto *cprot);
  77. int (*disconn_ind)(struct concap_proto *cprot);
  78. /*
  79. Some network device support functions, like net_header(), rebuild_header(),
  80. and others, that depend solely on the encapsulation protocol, might
  81. be provided here, too. The net device would just fill them in its
  82. corresponding fields when it is opened.
  83. */
  84. };
  85. /* dummy restart/close/connect/reset/disconn methods
  86. */
  87. extern int concap_nop(struct concap_proto *cprot);
  88. /* dummy submit method
  89. */
  90. extern int concap_drop_skb(struct concap_proto *cprot, struct sk_buff *skb);
  91. #endif