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