1/*
2 * Copyright 2003-2005, Haiku Inc.
3 * Distributed under the terms of the MIT License.
4 */
5
6#ifndef __K_PPP_LCP_EXTENSION__H
7#define __K_PPP_LCP_EXTENSION__H
8
9#include <KPPPDefs.h>
10
11#ifndef _K_PPP_INTERFACE__H
12#include <KPPPInterface.h>
13#endif
14
15
16class KPPPLCPExtension {
17	protected:
18		// KPPPLCPExtension must be subclassed
19		KPPPLCPExtension(const char *name, uint8 code, KPPPInterface& interface,
20			driver_parameter *settings);
21
22	public:
23		virtual ~KPPPLCPExtension();
24
25		virtual status_t InitCheck() const;
26
27		//!	Returns the name of this LCP extension.
28		const char *Name() const
29			{ return fName; }
30
31		//!	Returns the owning interface.
32		KPPPInterface& Interface() const
33			{ return fInterface; }
34		//!	Returns the LCP extension's settings.
35		driver_parameter *Settings() const
36			{ return fSettings; }
37
38		//!	Enables or disables this extension.
39		void SetEnabled(bool enabled = true)
40			{ fEnabled = enabled; }
41		//!	Returns if the extension is enabled.
42		bool IsEnabled() const
43			{ return fEnabled; }
44
45		//!	Returns the LCP packet code this extension can handle.
46		uint8 Code() const
47			{ return fCode; }
48
49		virtual status_t Control(uint32 op, void *data, size_t length);
50		virtual status_t StackControl(uint32 op, void *data);
51			// called by netstack (forwarded by KPPPInterface)
52
53		//!	Must be overridden. Called when an LCP packet with your code is received.
54		virtual status_t Receive(net_buffer *packet, uint8 code) = 0;
55
56		virtual void Reset();
57		virtual void Pulse();
58
59	protected:
60		status_t fInitStatus;
61
62	private:
63		char *fName;
64		KPPPInterface& fInterface;
65		driver_parameter *fSettings;
66		uint8 fCode;
67
68		bool fEnabled;
69};
70
71
72#endif
73