concap.h 3.7 KB

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