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 //! Layer name. 25 const char *Name() const 26 { return fName; } 27 /*! \brief Level of this layer (level is defined in enum: \c ppp_level). 28 29 This should be \c PPP_PROTOCOL_LEVEL if this layer is not an encapsulator. 30 */ 31 ppp_level Level() const 32 { return fLevel; } 33 //! Length of header that will be prepended to outgoing packets. 34 uint32 Overhead() const 35 { return fOverhead; } 36 37 //! Sets the next layer. This will be the target of \c SendToNext(). 38 void SetNext(KPPPLayer *next) 39 { fNext = next; } 40 //! Next layer in chain. 41 KPPPLayer *Next() const 42 { return fNext; } 43 44 virtual void ProfileChanged(); 45 46 //! Brings this layer up. 47 virtual bool Up() = 0; 48 //! Brings this layer down. 49 virtual bool Down() = 0; 50 51 //! Returns whether this layer is allowed to send packets. 52 virtual bool IsAllowedToSend() const = 0; 53 54 //! Send a packet with the given protocol number. 55 virtual status_t Send(struct mbuf *packet, uint16 protocolNumber) = 0; 56 //! Receive a packet with the given protocol number. 57 virtual status_t Receive(struct mbuf *packet, uint16 protocolNumber) = 0; 58 59 status_t SendToNext(struct mbuf *packet, uint16 protocolNumber) const; 60 // send the packet to the next layer 61 62 virtual void Pulse(); 63 64 protected: 65 void SetName(const char *name); 66 67 protected: 68 status_t fInitStatus; 69 uint32 fOverhead; 70 71 private: 72 char *fName; 73 ppp_level fLevel; 74 75 KPPPLayer *fNext; 76 }; 77 78 79 #endif 80