ppp_channel.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 net_device_path;
  22. struct net_device_path_ctx;
  23. struct ppp_channel;
  24. struct ppp_channel_ops {
  25. /* Send a packet (or multilink fragment) on this channel.
  26. Returns 1 if it was accepted, 0 if not. */
  27. int (*start_xmit)(struct ppp_channel *, struct sk_buff *);
  28. /* Handle an ioctl call that has come in via /dev/ppp. */
  29. int (*ioctl)(struct ppp_channel *, unsigned int, unsigned long);
  30. int (*fill_forward_path)(struct net_device_path_ctx *,
  31. struct net_device_path *,
  32. const struct ppp_channel *);
  33. };
  34. struct ppp_channel {
  35. void *private; /* channel private data */
  36. const struct ppp_channel_ops *ops; /* operations for this channel */
  37. int mtu; /* max transmit packet size */
  38. int hdrlen; /* amount of headroom channel needs */
  39. void *ppp; /* opaque to channel */
  40. int speed; /* transfer rate (bytes/second) */
  41. /* the following is not used at present */
  42. int latency; /* overhead time in milliseconds */
  43. };
  44. #ifdef __KERNEL__
  45. /* Called by the channel when it can send some more data. */
  46. extern void ppp_output_wakeup(struct ppp_channel *);
  47. /* Called by the channel to process a received PPP packet.
  48. The packet should have just the 2-byte PPP protocol header. */
  49. extern void ppp_input(struct ppp_channel *, struct sk_buff *);
  50. /* Called by the channel when an input error occurs, indicating
  51. that we may have missed a packet. */
  52. extern void ppp_input_error(struct ppp_channel *, int code);
  53. /* Attach a channel to a given PPP unit in specified net. */
  54. extern int ppp_register_net_channel(struct net *, struct ppp_channel *);
  55. /* Attach a channel to a given PPP unit. */
  56. extern int ppp_register_channel(struct ppp_channel *);
  57. /* Detach a channel from its PPP unit (e.g. on hangup). */
  58. extern void ppp_unregister_channel(struct ppp_channel *);
  59. /* Get the channel number for a channel */
  60. extern int ppp_channel_index(struct ppp_channel *);
  61. /* Get the unit number associated with a channel, or -1 if none */
  62. extern int ppp_unit_number(struct ppp_channel *);
  63. /* Get the device name associated with a channel, or NULL if none */
  64. extern char *ppp_dev_name(struct ppp_channel *);
  65. /*
  66. * SMP locking notes:
  67. * The channel code must ensure that when it calls ppp_unregister_channel,
  68. * nothing is executing in any of the procedures above, for that
  69. * channel. The generic layer will ensure that nothing is executing
  70. * in the start_xmit and ioctl routines for the channel by the time
  71. * that ppp_unregister_channel returns.
  72. */
  73. #endif /* __KERNEL__ */
  74. #endif