xref: /haiku/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLayer.h (revision 51978af14a173e7fae0563b562be5603bc652aeb)
1 //----------------------------------------------------------------------
2 //  This software is part of the OpenBeOS distribution and is covered
3 //  by the OpenBeOS license.
4 //
5 //  Copyright (c) 2003 Waldemar Kornewald, Waldemar.Kornewald@web.de
6 //---------------------------------------------------------------------
7 
8 #ifndef _K_PPP_LAYER__H
9 #define _K_PPP_LAYER__H
10 
11 #include <KPPPDefs.h>
12 
13 
14 class PPPLayer {
15 	protected:
16 		// PPPLayer must be subclassed
17 		PPPLayer(const char *name, ppp_level level);
18 
19 	public:
20 		virtual ~PPPLayer();
21 
22 		virtual status_t InitCheck() const;
23 
24 		const char *Name() const
25 			{ return fName; }
26 		ppp_level Level() const
27 			{ return fLevel; }
28 				// should be PPP_PROTOCOL_LEVEL if not encapsulator
29 
30 		void SetNext(PPPLayer *next)
31 			{ fNext = next; }
32 		PPPLayer *Next() const
33 			{ return fNext; }
34 
35 		virtual bool Up() = 0;
36 		virtual bool Down() = 0;
37 
38 		virtual bool IsAllowedToSend() const = 0;
39 
40 		virtual status_t Send(struct mbuf *packet, uint16 protocolNumber) = 0;
41 		virtual status_t Receive(struct mbuf *packet, uint16 protocolNumber) = 0;
42 
43 		status_t SendToNext(struct mbuf *packet, uint16 protocolNumber) const;
44 			// send the packet to the next layer
45 
46 		virtual void Pulse();
47 
48 	protected:
49 		status_t fInitStatus;
50 
51 	private:
52 		char *fName;
53 		ppp_level fLevel;
54 
55 		PPPLayer *fNext;
56 };
57 
58 
59 #endif
60