ppp_channel.h 2.9 KB

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