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