xref: /linux/include/linux/ppp_channel.h (revision be239684b18e1cdcafcf8c7face4a2f562c745ad)
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 	/* the following is not used at present */
46 	int		latency;	/* overhead time in milliseconds */
47 };
48 
49 #ifdef __KERNEL__
50 /* Called by the channel when it can send some more data. */
51 extern void ppp_output_wakeup(struct ppp_channel *);
52 
53 /* Called by the channel to process a received PPP packet.
54    The packet should have just the 2-byte PPP protocol header. */
55 extern void ppp_input(struct ppp_channel *, struct sk_buff *);
56 
57 /* Called by the channel when an input error occurs, indicating
58    that we may have missed a packet. */
59 extern void ppp_input_error(struct ppp_channel *, int code);
60 
61 /* Attach a channel to a given PPP unit in specified net. */
62 extern int ppp_register_net_channel(struct net *, struct ppp_channel *);
63 
64 /* Attach a channel to a given PPP unit. */
65 extern int ppp_register_channel(struct ppp_channel *);
66 
67 /* Detach a channel from its PPP unit (e.g. on hangup). */
68 extern void ppp_unregister_channel(struct ppp_channel *);
69 
70 /* Get the channel number for a channel */
71 extern int ppp_channel_index(struct ppp_channel *);
72 
73 /* Get the unit number associated with a channel, or -1 if none */
74 extern int ppp_unit_number(struct ppp_channel *);
75 
76 /* Get the device name associated with a channel, or NULL if none */
77 extern char *ppp_dev_name(struct ppp_channel *);
78 
79 /*
80  * SMP locking notes:
81  * The channel code must ensure that when it calls ppp_unregister_channel,
82  * nothing is executing in any of the procedures above, for that
83  * channel.  The generic layer will ensure that nothing is executing
84  * in the start_xmit and ioctl routines for the channel by the time
85  * that ppp_unregister_channel returns.
86  */
87 
88 #endif /* __KERNEL__ */
89 #endif
90