blob: 98966064ee68246b5e3d09f9416394431c933f46 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#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 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070015 * ==FILEVERSION 20000322==
16 */
17
18#include <linux/list.h>
19#include <linux/skbuff.h>
20#include <linux/poll.h>
Cyrill Gorcunov273ec512009-01-21 15:55:35 -080021#include <net/net_namespace.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
23struct ppp_channel;
24
25struct ppp_channel_ops {
26 /* Send a packet (or multilink fragment) on this channel.
27 Returns 1 if it was accepted, 0 if not. */
28 int (*start_xmit)(struct ppp_channel *, struct sk_buff *);
29 /* Handle an ioctl call that has come in via /dev/ppp. */
30 int (*ioctl)(struct ppp_channel *, unsigned int, unsigned long);
31};
32
33struct ppp_channel {
34 void *private; /* channel private data */
stephen hemmingerd7100da2010-08-04 07:34:36 +000035 const struct ppp_channel_ops *ops; /* operations for this channel */
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 int mtu; /* max transmit packet size */
37 int hdrlen; /* amount of headroom channel needs */
38 void *ppp; /* opaque to channel */
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 int speed; /* transfer rate (bytes/second) */
Gabriele Paoloni9c705262009-03-13 16:09:12 -070040 /* the following is not used at present */
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 int latency; /* overhead time in milliseconds */
42};
43
44#ifdef __KERNEL__
45/* Called by the channel when it can send some more data. */
46extern void ppp_output_wakeup(struct ppp_channel *);
47
48/* Called by the channel to process a received PPP packet.
49 The packet should have just the 2-byte PPP protocol header. */
50extern void ppp_input(struct ppp_channel *, struct sk_buff *);
51
52/* Called by the channel when an input error occurs, indicating
53 that we may have missed a packet. */
54extern void ppp_input_error(struct ppp_channel *, int code);
55
Cyrill Gorcunov273ec512009-01-21 15:55:35 -080056/* Attach a channel to a given PPP unit in specified net. */
57extern int ppp_register_net_channel(struct net *, struct ppp_channel *);
58
Linus Torvalds1da177e2005-04-16 15:20:36 -070059/* Attach a channel to a given PPP unit. */
60extern int ppp_register_channel(struct ppp_channel *);
61
62/* Detach a channel from its PPP unit (e.g. on hangup). */
63extern void ppp_unregister_channel(struct ppp_channel *);
64
65/* Get the channel number for a channel */
66extern int ppp_channel_index(struct ppp_channel *);
67
68/* Get the unit number associated with a channel, or -1 if none */
69extern int ppp_unit_number(struct ppp_channel *);
70
James Chapman63f96072010-04-02 06:18:39 +000071/* Get the device name associated with a channel, or NULL if none */
72extern char *ppp_dev_name(struct ppp_channel *);
73
Linus Torvalds1da177e2005-04-16 15:20:36 -070074/*
75 * SMP locking notes:
76 * The channel code must ensure that when it calls ppp_unregister_channel,
77 * nothing is executing in any of the procedures above, for that
78 * channel. The generic layer will ensure that nothing is executing
79 * in the start_xmit and ioctl routines for the channel by the time
80 * that ppp_unregister_channel returns.
81 */
82
83#endif /* __KERNEL__ */
84#endif