xref: /haiku/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLCPExtension.h (revision 9eb55bc1d104b8fda80898f8b25c94d8000c8255)
1 //-----------------------------------------------------------------------
2 //  This software is part of the OpenBeOS distribution and is covered
3 //  by the OpenBeOS license.
4 //
5 //  Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de
6 //-----------------------------------------------------------------------
7 
8 #ifndef __K_PPP_LCP_EXTENSION__H
9 #define __K_PPP_LCP_EXTENSION__H
10 
11 #include <KPPPDefs.h>
12 
13 #ifndef _K_PPP_INTERFACE__H
14 #include <KPPPInterface.h>
15 #endif
16 
17 
18 class KPPPLCPExtension {
19 	protected:
20 		// KPPPLCPExtension must be subclassed
21 		KPPPLCPExtension(const char *name, uint8 code, KPPPInterface& interface,
22 			driver_parameter *settings);
23 
24 	public:
25 		virtual ~KPPPLCPExtension();
26 
27 		virtual status_t InitCheck() const;
28 
29 		const char *Name() const
30 			{ return fName; }
31 
32 		KPPPInterface& Interface() const
33 			{ return fInterface; }
34 		driver_parameter *Settings() const
35 			{ return fSettings; }
36 
37 		void SetEnabled(bool enabled = true)
38 			{ fEnabled = enabled; }
39 		bool IsEnabled() const
40 			{ return fEnabled; }
41 
42 		uint8 Code() const
43 			{ return fCode; }
44 
45 		virtual status_t Control(uint32 op, void *data, size_t length);
46 		virtual status_t StackControl(uint32 op, void *data);
47 			// called by netstack (forwarded by KPPPInterface)
48 
49 		virtual status_t Receive(struct mbuf *packet, uint8 code) = 0;
50 
51 		virtual void Reset();
52 		virtual void Pulse();
53 
54 	protected:
55 		status_t fInitStatus;
56 
57 	private:
58 		char *fName;
59 		KPPPInterface& fInterface;
60 		driver_parameter *fSettings;
61 		uint8 fCode;
62 
63 		bool fEnabled;
64 };
65 
66 
67 #endif
68