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_LAYER__H 9 #define _K_PPP_LAYER__H 10 11 #include <KPPPDefs.h> 12 13 14 class KPPPLayer { 15 protected: 16 // KPPPLayer must be subclassed 17 KPPPLayer(const char *name, ppp_level level, uint32 overhead); 18 19 public: 20 virtual ~KPPPLayer(); 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(KPPPLayer *next) 33 { fNext = next; } 34 KPPPLayer *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 void SetName(const char *name); 52 53 status_t fInitStatus; 54 uint32 fOverhead; 55 56 private: 57 char *fName; 58 ppp_level fLevel; 59 60 KPPPLayer *fNext; 61 }; 62 63 64 #endif 65