1 /* 2 * Copyright 2003-2004, Haiku Inc. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 #ifndef _K_PPP_LAYER__H 7 #define _K_PPP_LAYER__H 8 9 #include <KPPPDefs.h> 10 11 12 class KPPPLayer { 13 protected: 14 //! KPPPLayer must be subclassed 15 KPPPLayer(const char *name, ppp_level level, uint32 overhead); 16 17 public: 18 virtual ~KPPPLayer(); 19 20 virtual status_t InitCheck() const; 21 22 //! Layer name. 23 const char *Name() const 24 { return fName; } 25 /*! \brief Level of this layer (level is defined in enum: \c ppp_level). 26 27 This should be \c PPP_PROTOCOL_LEVEL if this layer is not an encapsulator. 28 */ 29 ppp_level Level() const 30 { return fLevel; } 31 //! Length of header that will be prepended to outgoing packets. 32 uint32 Overhead() const 33 { return fOverhead; } 34 35 //! Sets the next layer. This will be the target of \c SendToNext(). 36 void SetNext(KPPPLayer *next) 37 { fNext = next; } 38 //! Next layer in chain. 39 KPPPLayer *Next() const 40 { return fNext; } 41 42 virtual void ProfileChanged(); 43 44 //! Brings this layer up. 45 virtual bool Up() = 0; 46 //! Brings this layer down. 47 virtual bool Down() = 0; 48 49 //! Returns whether this layer is allowed to send packets. 50 virtual bool IsAllowedToSend() const = 0; 51 52 //! Send a packet with the given protocol number. 53 virtual status_t Send(struct mbuf *packet, uint16 protocolNumber) = 0; 54 //! Receive a packet with the given protocol number. 55 virtual status_t Receive(struct mbuf *packet, uint16 protocolNumber) = 0; 56 57 status_t SendToNext(struct mbuf *packet, uint16 protocolNumber) const; 58 // send the packet to the next layer 59 60 virtual void Pulse(); 61 62 protected: 63 void SetName(const char *name); 64 65 protected: 66 status_t fInitStatus; 67 uint32 fOverhead; 68 69 private: 70 char *fName; 71 ppp_level fLevel; 72 73 KPPPLayer *fNext; 74 }; 75 76 77 #endif 78