blob: 5d87f810a3b747d028c47dc9c70264c6eccd6cc0 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _PPP_CHANNEL_H_
2#define _PPP_CHANNEL_H_
3/*
4 * Definitions for the interface between the generic PPP code
5 * and a PPP channel.
6 *
7 * A PPP channel provides a way for the generic PPP code to send
8 * and receive packets over some sort of communications medium.
9 * Packets are stored in sk_buffs and have the 2-byte PPP protocol
10 * number at the start, but not the address and control bytes.
11 *
12 * Copyright 1999 Paul Mackerras.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version
17 * 2 of the License, or (at your option) any later version.
18 *
19 * ==FILEVERSION 20000322==
20 */
21
22#include <linux/list.h>
23#include <linux/skbuff.h>
24#include <linux/poll.h>
Cyrill Gorcunov273ec512009-01-21 15:55:35 -080025#include <net/net_namespace.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
27struct ppp_channel;
28
29struct ppp_channel_ops {
30 /* Send a packet (or multilink fragment) on this channel.
31 Returns 1 if it was accepted, 0 if not. */
32 int (*start_xmit)(struct ppp_channel *, struct sk_buff *);
33 /* Handle an ioctl call that has come in via /dev/ppp. */
34 int (*ioctl)(struct ppp_channel *, unsigned int, unsigned long);
35};
36
37struct ppp_channel {
38 void *private; /* channel private data */
stephen hemmingerd7100da2010-08-04 07:34:36 +000039 const struct ppp_channel_ops *ops; /* operations for this channel */
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 int mtu; /* max transmit packet size */
41 int hdrlen; /* amount of headroom channel needs */
42 void *ppp; /* opaque to channel */
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 int speed; /* transfer rate (bytes/second) */
Gabriele Paoloni9c705262009-03-13 16:09:12 -070044 /* the following is not used at present */
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 int latency; /* overhead time in milliseconds */
46};
47
48#ifdef __KERNEL__
49/* Called by the channel when it can send some more data. */
50extern 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. */
54extern 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. */
58extern void ppp_input_error(struct ppp_channel *, int code);
59
Cyrill Gorcunov273ec512009-01-21 15:55:35 -080060/* Attach a channel to a given PPP unit in specified net. */
61extern int ppp_register_net_channel(struct net *, struct ppp_channel *);
62
Linus Torvalds1da177e2005-04-16 15:20:36 -070063/* Attach a channel to a given PPP unit. */
64extern int ppp_register_channel(struct ppp_channel *);
65
66/* Detach a channel from its PPP unit (e.g. on hangup). */
67extern void ppp_unregister_channel(struct ppp_channel *);
68
69/* Get the channel number for a channel */
70extern int ppp_channel_index(struct ppp_channel *);
71
72/* Get the unit number associated with a channel, or -1 if none */
73extern int ppp_unit_number(struct ppp_channel *);
74
James Chapman63f96072010-04-02 06:18:39 +000075/* Get the device name associated with a channel, or NULL if none */
76extern char *ppp_dev_name(struct ppp_channel *);
77
Linus Torvalds1da177e2005-04-16 15:20:36 -070078/*
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