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