xref: /haiku/src/add-ons/kernel/network/ppp/shared/libkernelppp/headers/KPPPLayer.h (revision d5cd5d63ff0ad395989db6cf4841a64d5b545d1d)
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, uint32 overhead);
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 		uint32 Overhead() const
30 			{ return fOverhead; }
31 
32 		void SetNext(PPPLayer *next)
33 			{ fNext = next; }
34 		PPPLayer *Next() const
35 			{ return fNext; }
36 
37 		virtual bool Up() = 0;
38 		virtual bool Down() = 0;
39 
40 		virtual bool IsAllowedToSend() const = 0;
41 
42 		virtual status_t Send(struct mbuf *packet, uint16 protocolNumber) = 0;
43 		virtual status_t Receive(struct mbuf *packet, uint16 protocolNumber) = 0;
44 
45 		status_t SendToNext(struct mbuf *packet, uint16 protocolNumber) const;
46 			// send the packet to the next layer
47 
48 		virtual void Pulse();
49 
50 	protected:
51 		status_t fInitStatus;
52 		uint32 fOverhead;
53 
54 	private:
55 		char *fName;
56 		ppp_level fLevel;
57 
58 		PPPLayer *fNext;
59 };
60 
61 
62 #endif
63