xref: /linux/include/linux/ppp_channel.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
12874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
21da177e4SLinus Torvalds #ifndef _PPP_CHANNEL_H_
31da177e4SLinus Torvalds #define _PPP_CHANNEL_H_
41da177e4SLinus Torvalds /*
51da177e4SLinus Torvalds  * Definitions for the interface between the generic PPP code
61da177e4SLinus Torvalds  * and a PPP channel.
71da177e4SLinus Torvalds  *
81da177e4SLinus Torvalds  * A PPP channel provides a way for the generic PPP code to send
91da177e4SLinus Torvalds  * and receive packets over some sort of communications medium.
101da177e4SLinus Torvalds  * Packets are stored in sk_buffs and have the 2-byte PPP protocol
111da177e4SLinus Torvalds  * number at the start, but not the address and control bytes.
121da177e4SLinus Torvalds  *
131da177e4SLinus Torvalds  * Copyright 1999 Paul Mackerras.
141da177e4SLinus Torvalds  *
151da177e4SLinus Torvalds  * ==FILEVERSION 20000322==
161da177e4SLinus Torvalds  */
171da177e4SLinus Torvalds 
181da177e4SLinus Torvalds #include <linux/list.h>
191da177e4SLinus Torvalds #include <linux/skbuff.h>
201da177e4SLinus Torvalds #include <linux/poll.h>
21273ec51dSCyrill Gorcunov #include <net/net_namespace.h>
221da177e4SLinus Torvalds 
23*5f10376bSJakub Kicinski struct net_device_path;
24*5f10376bSJakub Kicinski struct net_device_path_ctx;
251da177e4SLinus Torvalds struct ppp_channel;
261da177e4SLinus Torvalds 
271da177e4SLinus Torvalds struct ppp_channel_ops {
281da177e4SLinus Torvalds 	/* Send a packet (or multilink fragment) on this channel.
291da177e4SLinus Torvalds 	   Returns 1 if it was accepted, 0 if not. */
301da177e4SLinus Torvalds 	int	(*start_xmit)(struct ppp_channel *, struct sk_buff *);
311da177e4SLinus Torvalds 	/* Handle an ioctl call that has come in via /dev/ppp. */
321da177e4SLinus Torvalds 	int	(*ioctl)(struct ppp_channel *, unsigned int, unsigned long);
33f6efc675SFelix Fietkau 	int	(*fill_forward_path)(struct net_device_path_ctx *,
34f6efc675SFelix Fietkau 				     struct net_device_path *,
35f6efc675SFelix Fietkau 				     const struct ppp_channel *);
361da177e4SLinus Torvalds };
371da177e4SLinus Torvalds 
381da177e4SLinus Torvalds struct ppp_channel {
391da177e4SLinus Torvalds 	void		*private;	/* channel private data */
40d7100da0Sstephen hemminger 	const struct ppp_channel_ops *ops; /* operations for this channel */
411da177e4SLinus Torvalds 	int		mtu;		/* max transmit packet size */
421da177e4SLinus Torvalds 	int		hdrlen;		/* amount of headroom channel needs */
431da177e4SLinus Torvalds 	void		*ppp;		/* opaque to channel */
441da177e4SLinus Torvalds 	int		speed;		/* transfer rate (bytes/second) */
459c705260SGabriele Paoloni 	/* the following is not used at present */
461da177e4SLinus Torvalds 	int		latency;	/* overhead time in milliseconds */
471da177e4SLinus Torvalds };
481da177e4SLinus Torvalds 
491da177e4SLinus Torvalds #ifdef __KERNEL__
501da177e4SLinus Torvalds /* Called by the channel when it can send some more data. */
511da177e4SLinus Torvalds extern void ppp_output_wakeup(struct ppp_channel *);
521da177e4SLinus Torvalds 
531da177e4SLinus Torvalds /* Called by the channel to process a received PPP packet.
541da177e4SLinus Torvalds    The packet should have just the 2-byte PPP protocol header. */
551da177e4SLinus Torvalds extern void ppp_input(struct ppp_channel *, struct sk_buff *);
561da177e4SLinus Torvalds 
571da177e4SLinus Torvalds /* Called by the channel when an input error occurs, indicating
581da177e4SLinus Torvalds    that we may have missed a packet. */
591da177e4SLinus Torvalds extern void ppp_input_error(struct ppp_channel *, int code);
601da177e4SLinus Torvalds 
61273ec51dSCyrill Gorcunov /* Attach a channel to a given PPP unit in specified net. */
62273ec51dSCyrill Gorcunov extern int ppp_register_net_channel(struct net *, struct ppp_channel *);
63273ec51dSCyrill Gorcunov 
641da177e4SLinus Torvalds /* Attach a channel to a given PPP unit. */
651da177e4SLinus Torvalds extern int ppp_register_channel(struct ppp_channel *);
661da177e4SLinus Torvalds 
671da177e4SLinus Torvalds /* Detach a channel from its PPP unit (e.g. on hangup). */
681da177e4SLinus Torvalds extern void ppp_unregister_channel(struct ppp_channel *);
691da177e4SLinus Torvalds 
701da177e4SLinus Torvalds /* Get the channel number for a channel */
711da177e4SLinus Torvalds extern int ppp_channel_index(struct ppp_channel *);
721da177e4SLinus Torvalds 
731da177e4SLinus Torvalds /* Get the unit number associated with a channel, or -1 if none */
741da177e4SLinus Torvalds extern int ppp_unit_number(struct ppp_channel *);
751da177e4SLinus Torvalds 
7663f96072SJames Chapman /* Get the device name associated with a channel, or NULL if none */
7763f96072SJames Chapman extern char *ppp_dev_name(struct ppp_channel *);
7863f96072SJames Chapman 
791da177e4SLinus Torvalds /*
801da177e4SLinus Torvalds  * SMP locking notes:
811da177e4SLinus Torvalds  * The channel code must ensure that when it calls ppp_unregister_channel,
821da177e4SLinus Torvalds  * nothing is executing in any of the procedures above, for that
831da177e4SLinus Torvalds  * channel.  The generic layer will ensure that nothing is executing
841da177e4SLinus Torvalds  * in the start_xmit and ioctl routines for the channel by the time
851da177e4SLinus Torvalds  * that ppp_unregister_channel returns.
861da177e4SLinus Torvalds  */
871da177e4SLinus Torvalds 
881da177e4SLinus Torvalds #endif /* __KERNEL__ */
891da177e4SLinus Torvalds #endif
90