xref: /haiku/src/add-ons/kernel/network/ppp/pppoe/PPPoEDevice.h (revision 84b580c425e26370792255dbb5e1879250434372)
1*84b580c4SWaldemar Kornewald /*
2*84b580c4SWaldemar Kornewald  * Copyright 2003-2004, Waldemar Kornewald <Waldemar.Kornewald@web.de>
3*84b580c4SWaldemar Kornewald  * Distributed under the terms of the MIT License.
4*84b580c4SWaldemar Kornewald  */
55a4503c3SWaldemar Kornewald 
65a4503c3SWaldemar Kornewald #ifndef PPPoE_DEVICE__H
75a4503c3SWaldemar Kornewald #define PPPoE_DEVICE__H
85a4503c3SWaldemar Kornewald 
95a4503c3SWaldemar Kornewald #include "PPPoE.h"
105a4503c3SWaldemar Kornewald 
115a4503c3SWaldemar Kornewald #include <KPPPDevice.h>
125a4503c3SWaldemar Kornewald 
135a4503c3SWaldemar Kornewald 
145a4503c3SWaldemar Kornewald enum pppoe_state {
155a4503c3SWaldemar Kornewald 	INITIAL,
168dad9b1eSWaldemar Kornewald 		// the same as IsDown() == true
175a4503c3SWaldemar Kornewald 	PADI_SENT,
185a4503c3SWaldemar Kornewald 	PADR_SENT,
195a4503c3SWaldemar Kornewald 	OPENED
208dad9b1eSWaldemar Kornewald 		// the same as IsUp() == true
215a4503c3SWaldemar Kornewald };
225a4503c3SWaldemar Kornewald 
235a4503c3SWaldemar Kornewald 
241cea3d85SWaldemar Kornewald class PPPoEDevice : public KPPPDevice {
255a4503c3SWaldemar Kornewald 	public:
261cea3d85SWaldemar Kornewald 		PPPoEDevice(KPPPInterface& interface, driver_parameter *settings);
275a4503c3SWaldemar Kornewald 		virtual ~PPPoEDevice();
285a4503c3SWaldemar Kornewald 
295a4503c3SWaldemar Kornewald 		ifnet *EthernetIfnet() const
305a4503c3SWaldemar Kornewald 			{ return fEthernetIfnet; }
315a4503c3SWaldemar Kornewald 
325a4503c3SWaldemar Kornewald 		const uint8 *Peer() const
335a4503c3SWaldemar Kornewald 			{ return fPeer; }
345a4503c3SWaldemar Kornewald 		uint16 SessionID() const
355a4503c3SWaldemar Kornewald 			{ return fSessionID; }
365a4503c3SWaldemar Kornewald 		uint32 HostUniq() const
375a4503c3SWaldemar Kornewald 			{ return fHostUniq; }
385a4503c3SWaldemar Kornewald 
395a4503c3SWaldemar Kornewald 		const char *ACName() const
405a4503c3SWaldemar Kornewald 			{ return fACName; }
415a4503c3SWaldemar Kornewald 		const char *ServiceName() const
425a4503c3SWaldemar Kornewald 			{ return fServiceName; }
435a4503c3SWaldemar Kornewald 
445a4503c3SWaldemar Kornewald 		virtual status_t InitCheck() const;
455a4503c3SWaldemar Kornewald 
465a4503c3SWaldemar Kornewald 		virtual bool Up();
475a4503c3SWaldemar Kornewald 		virtual bool Down();
485a4503c3SWaldemar Kornewald 
495a4503c3SWaldemar Kornewald 		virtual uint32 InputTransferRate() const;
505a4503c3SWaldemar Kornewald 		virtual uint32 OutputTransferRate() const;
515a4503c3SWaldemar Kornewald 
525a4503c3SWaldemar Kornewald 		virtual uint32 CountOutputBytes() const;
535a4503c3SWaldemar Kornewald 
545a4503c3SWaldemar Kornewald 		virtual status_t Send(struct mbuf *packet, uint16 protocolNumber = 0);
555a4503c3SWaldemar Kornewald 		virtual status_t Receive(struct mbuf *packet, uint16 protocolNumber = 0);
565a4503c3SWaldemar Kornewald 
575a4503c3SWaldemar Kornewald 		virtual void Pulse();
585a4503c3SWaldemar Kornewald 
595a4503c3SWaldemar Kornewald 	private:
605a4503c3SWaldemar Kornewald 		ifnet *fEthernetIfnet;
615a4503c3SWaldemar Kornewald 		uint8 fPeer[6];
625a4503c3SWaldemar Kornewald 		uint16 fSessionID;
635a4503c3SWaldemar Kornewald 		uint32 fHostUniq;
645a483e4dSWaldemar Kornewald 		const char *fACName, *fServiceName;
655a4503c3SWaldemar Kornewald 
664e0ad752SWaldemar Kornewald 		uint32 fAttempts;
675a4503c3SWaldemar Kornewald 		bigtime_t fNextTimeout;
685a4503c3SWaldemar Kornewald 		pppoe_state fState;
695a4503c3SWaldemar Kornewald 
705a4503c3SWaldemar Kornewald 		BLocker fLock;
715a4503c3SWaldemar Kornewald };
725a4503c3SWaldemar Kornewald 
735a4503c3SWaldemar Kornewald 
745a4503c3SWaldemar Kornewald #endif
75