ppp_channel.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef _PPP_CHANNEL_H_
  2. #define _PPP_CHANNEL_H_
  3. /*
  4. * Definitions for the interface between the generic PPP code
  5. * and a PPP channel.
  6. *
  7. * A PPP channel provides a way for the generic PPP code to send
  8. * and receive packets over some sort of communications medium.
  9. * Packets are stored in sk_buffs and have the 2-byte PPP protocol
  10. * number at the start, but not the address and control bytes.
  11. *
  12. * Copyright 1999 Paul Mackerras.
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License
  16. * as published by the Free Software Foundation; either version
  17. * 2 of the License, or (at your option) any later version.
  18. *
  19. * ==FILEVERSION 20000322==
  20. */
  21. #include <linux/list.h>
  22. #include <linux/skbuff.h>
  23. #include <linux/poll.h>
  24. #include <net/net_namespace.h>
  25. struct ppp_channel;
  26. struct ppp_channel_ops {
  27. /* Send a packet (or multilink fragment) on this channel.
  28. Returns 1 if it was accepted, 0 if not. */
  29. int (*start_xmit)(struct ppp_channel *, struct sk_buff *);
  30. /* Handle an ioctl call that has come in via /dev/ppp. */
  31. int (*ioctl)(struct ppp_channel *, unsigned int, unsigned long);
  32. };
  33. struct ppp_channel {
  34. void *private; /* channel private data */
  35. const struct ppp_channel_ops *ops; /* operations for this channel */
  36. int mtu; /* max transmit packet size */
  37. int hdrlen; /* amount of headroom channel needs */
  38. void *ppp; /* opaque to channel */
  39. int speed; /* transfer rate (bytes/second) */
  40. /* the following is not used at present */
  41. int latency; /* overhead time in milliseconds */
  42. };
  43. #ifdef __KERNEL__
  44. /* Called by the channel when it can send some more data. */
  45. extern void ppp_output_wakeup(struct ppp_channel *);
  46. /* Called by the channel to process a received PPP packet.
  47. The packet should have just the 2-byte PPP protocol header. */
  48. extern void ppp_input(struct ppp_channel *, struct sk_buff *);
  49. /* Called by the channel when an input error occurs, indicating
  50. that we may have missed a packet. */
  51. extern void ppp_input_error(struct ppp_channel *, int code);
  52. /* Attach a channel to a given PPP unit in specified net. */
  53. extern int ppp_register_net_channel(struct net *, struct ppp_channel *);
  54. /* Attach a channel to a given PPP unit. */
  55. extern int ppp_register_channel(struct ppp_channel *);
  56. /* Detach a channel from its PPP unit (e.g. on hangup). */
  57. extern void ppp_unregister_channel(struct ppp_channel *);
  58. /* Get the channel number for a channel */
  59. extern int ppp_channel_index(struct ppp_channel *);
  60. /* Get the unit number associated with a channel, or -1 if none */
  61. extern int ppp_unit_number(struct ppp_channel *);
  62. /* Get the device name associated with a channel, or NULL if none */
  63. extern char *ppp_dev_name(struct ppp_channel *);
  64. /*
  65. * SMP locking notes:
  66. * The channel code must ensure that when it calls ppp_unregister_channel,
  67. * nothing is executing in any of the procedures above, for that
  68. * channel. The generic layer will ensure that nothing is executing
  69. * in the start_xmit and ioctl routines for the channel by the time
  70. * that ppp_unregister_channel returns.
  71. */
  72. #endif /* __KERNEL__ */
  73. #endif