184b580c4SWaldemar Kornewald /* 2*abdb7d1aSWaldemar Kornewald * Copyright 2003-2005, Haiku Inc. 384b580c4SWaldemar Kornewald * Distributed under the terms of the MIT License. 484b580c4SWaldemar Kornewald */ 5de2f76e1SWaldemar Kornewald 6de2f76e1SWaldemar Kornewald #ifndef _K_PPP_OPTION_HANDLER__H 7de2f76e1SWaldemar Kornewald #define _K_PPP_OPTION_HANDLER__H 8de2f76e1SWaldemar Kornewald 9de2f76e1SWaldemar Kornewald #include <KPPPDefs.h> 10de2f76e1SWaldemar Kornewald 11de2f76e1SWaldemar Kornewald #ifndef _K_PPP_INTERFACE__H 12de2f76e1SWaldemar Kornewald #include <KPPPInterface.h> 13de2f76e1SWaldemar Kornewald #endif 14de2f76e1SWaldemar Kornewald 15f9ad2df8SWaldemar Kornewald class KPPPConfigurePacket; 16de2f76e1SWaldemar Kornewald 17de2f76e1SWaldemar Kornewald 18f9ad2df8SWaldemar Kornewald class KPPPOptionHandler { 1992a8026eSWaldemar Kornewald protected: 20f9ad2df8SWaldemar Kornewald // KPPPOptionHandler must be subclassed 21f9ad2df8SWaldemar Kornewald KPPPOptionHandler(const char *name, uint8 type, KPPPInterface& interface, 22de2f76e1SWaldemar Kornewald driver_parameter *settings); 2392a8026eSWaldemar Kornewald 2492a8026eSWaldemar Kornewald public: 25f9ad2df8SWaldemar Kornewald virtual ~KPPPOptionHandler(); 26de2f76e1SWaldemar Kornewald 27de2f76e1SWaldemar Kornewald virtual status_t InitCheck() const; 28de2f76e1SWaldemar Kornewald 293f3689bbSWaldemar Kornewald //! Returns the name of this handler. Name()30de2f76e1SWaldemar Kornewald const char *Name() const 31de2f76e1SWaldemar Kornewald { return fName; } 32de2f76e1SWaldemar Kornewald 333f3689bbSWaldemar Kornewald //! Returns the LCP item type this object can handle. Type()34de2f76e1SWaldemar Kornewald uint8 Type() const 35de2f76e1SWaldemar Kornewald { return fType; } 36de2f76e1SWaldemar Kornewald 373f3689bbSWaldemar Kornewald //! Returns the owning interface. Interface()38f9ad2df8SWaldemar Kornewald KPPPInterface& Interface() const 39de2f76e1SWaldemar Kornewald { return fInterface; } 403f3689bbSWaldemar Kornewald //! Returns the handler's settings. Settings()41de2f76e1SWaldemar Kornewald driver_parameter *Settings() const 42de2f76e1SWaldemar Kornewald { return fSettings; } 43de2f76e1SWaldemar Kornewald 443f3689bbSWaldemar Kornewald //! Enables or disables this handler. 45de2f76e1SWaldemar Kornewald void SetEnabled(bool enabled = true) 46de2f76e1SWaldemar Kornewald { fEnabled = enabled; } 473f3689bbSWaldemar Kornewald //! Returns if the handler is enabled. IsEnabled()48de2f76e1SWaldemar Kornewald bool IsEnabled() const 49de2f76e1SWaldemar Kornewald { return fEnabled; } 50de2f76e1SWaldemar Kornewald 51de2f76e1SWaldemar Kornewald virtual status_t Control(uint32 op, void *data, size_t length); 52de2f76e1SWaldemar Kornewald virtual status_t StackControl(uint32 op, void *data); 53f9ad2df8SWaldemar Kornewald // called by netstack (forwarded by KPPPInterface) 54de2f76e1SWaldemar Kornewald 55de2f76e1SWaldemar Kornewald // we want to send a configure request or we received a reply 563f3689bbSWaldemar Kornewald virtual status_t AddToRequest(KPPPConfigurePacket& request); 573f3689bbSWaldemar Kornewald virtual status_t ParseNak(const KPPPConfigurePacket& nak); 58de2f76e1SWaldemar Kornewald // create next request based on these and previous values 593f3689bbSWaldemar Kornewald virtual status_t ParseReject(const KPPPConfigurePacket& reject); 60de2f76e1SWaldemar Kornewald // create next request based on these and previous values 613f3689bbSWaldemar Kornewald virtual status_t ParseAck(const KPPPConfigurePacket& ack); 62de2f76e1SWaldemar Kornewald // this is called for all handlers 63de2f76e1SWaldemar Kornewald 64f9ad2df8SWaldemar Kornewald virtual status_t ParseRequest(const KPPPConfigurePacket& request, 653f3689bbSWaldemar Kornewald int32 index, KPPPConfigurePacket& nak, KPPPConfigurePacket& reject); 663f3689bbSWaldemar Kornewald virtual status_t SendingAck(const KPPPConfigurePacket& ack); 67de2f76e1SWaldemar Kornewald 683f3689bbSWaldemar Kornewald virtual void Reset(); 69de2f76e1SWaldemar Kornewald 70de2f76e1SWaldemar Kornewald protected: 71de2f76e1SWaldemar Kornewald status_t fInitStatus; 72de2f76e1SWaldemar Kornewald 73de2f76e1SWaldemar Kornewald private: 74de2f76e1SWaldemar Kornewald char *fName; 75de2f76e1SWaldemar Kornewald uint8 fType; 76f9ad2df8SWaldemar Kornewald KPPPInterface& fInterface; 77de2f76e1SWaldemar Kornewald driver_parameter *fSettings; 78de2f76e1SWaldemar Kornewald 79de2f76e1SWaldemar Kornewald bool fEnabled; 80de2f76e1SWaldemar Kornewald }; 81de2f76e1SWaldemar Kornewald 82de2f76e1SWaldemar Kornewald 83de2f76e1SWaldemar Kornewald #endif 84