xref: /haiku/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPOptionHandler.h (revision 67bce78b48ed6d01b5a8eef89f5694c372b7e0a1)
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_OPTION_HANDLER__H
9 #define _K_PPP_OPTION_HANDLER__H
10 
11 #include <KPPPDefs.h>
12 
13 #ifndef _K_PPP_INTERFACE__H
14 #include <KPPPInterface.h>
15 #endif
16 
17 class KPPPConfigurePacket;
18 
19 
20 class KPPPOptionHandler {
21 	protected:
22 		// KPPPOptionHandler must be subclassed
23 		KPPPOptionHandler(const char *name, uint8 type, KPPPInterface& interface,
24 			driver_parameter *settings);
25 
26 	public:
27 		virtual ~KPPPOptionHandler();
28 
29 		virtual status_t InitCheck() const;
30 
31 		const char *Name() const
32 			{ return fName; }
33 
34 		uint8 Type() const
35 			{ return fType; }
36 
37 		KPPPInterface& Interface() const
38 			{ return fInterface; }
39 		driver_parameter *Settings() const
40 			{ return fSettings; }
41 
42 		void SetEnabled(bool enabled = true)
43 			{ fEnabled = enabled; }
44 		bool IsEnabled() const
45 			{ return fEnabled; }
46 
47 		virtual status_t Control(uint32 op, void *data, size_t length);
48 		virtual status_t StackControl(uint32 op, void *data);
49 			// called by netstack (forwarded by KPPPInterface)
50 
51 		virtual void ProfileChanged();
52 
53 		// we want to send a configure request or we received a reply
54 		virtual status_t AddToRequest(KPPPConfigurePacket& request) = 0;
55 		virtual status_t ParseNak(const KPPPConfigurePacket& nak) = 0;
56 			// create next request based on these and previous values
57 		virtual status_t ParseReject(const KPPPConfigurePacket& reject) = 0;
58 			// create next request based on these and previous values
59 		virtual status_t ParseAck(const KPPPConfigurePacket& ack) = 0;
60 			// this is called for all handlers
61 
62 		// peer sent configure request
63 		virtual status_t ParseRequest(const KPPPConfigurePacket& request,
64 			int32 index, KPPPConfigurePacket& nak, KPPPConfigurePacket& reject) = 0;
65 			// index may be behind the last item which means additional values can be
66 			// appended
67 		virtual status_t SendingAck(const KPPPConfigurePacket& ack) = 0;
68 			// notification that we ack these values
69 
70 		virtual void Reset() = 0;
71 			// e.g.: remove list of rejected values
72 
73 	protected:
74 		status_t fInitStatus;
75 
76 	private:
77 		char *fName;
78 		uint8 fType;
79 		KPPPInterface& fInterface;
80 		driver_parameter *fSettings;
81 
82 		bool fEnabled;
83 };
84 
85 
86 #endif
87