xref: /haiku/src/add-ons/kernel/network/ppp/pppoe/PPPoEDevice.h (revision 4466b89c65970de4c7236ac87faa2bee4589f413)
1 /*
2  * Copyright 2003-2006, Waldemar Kornewald <wkornew@gmx.net>
3  * Distributed under the terms of the MIT License.
4  */
5 
6 #ifndef PPPoE_DEVICE__H
7 #define PPPoE_DEVICE__H
8 
9 #include "PPPoE.h"
10 
11 #include <KPPPDevice.h>
12 
13 
14 enum pppoe_state {
15 	INITIAL,
16 		// the same as IsDown() == true
17 	PADI_SENT,
18 	PADR_SENT,
19 	OPENED
20 		// the same as IsUp() == true
21 };
22 
23 
24 class PPPoEDevice : public KPPPDevice {
25 	public:
26 		PPPoEDevice(KPPPInterface& interface, driver_parameter *settings);
27 
28 		ifnet *EthernetIfnet() const
29 			{ return fEthernetIfnet; }
30 
31 		const uint8 *Peer() const
32 			{ return fPeer; }
33 		uint16 SessionID() const
34 			{ return fSessionID; }
35 		uint32 HostUniq() const
36 			{ return fHostUniq; }
37 
38 		const char *ACName() const
39 			{ return fACName; }
40 		const char *ServiceName() const
41 			{ return fServiceName; }
42 
43 		virtual status_t InitCheck() const;
44 
45 		virtual bool Up();
46 		virtual bool Down();
47 
48 		virtual uint32 InputTransferRate() const;
49 		virtual uint32 OutputTransferRate() const;
50 
51 		virtual uint32 CountOutputBytes() const;
52 
53 		virtual status_t Send(struct mbuf *packet, uint16 protocolNumber = 0);
54 		virtual status_t Receive(struct mbuf *packet, uint16 protocolNumber = 0);
55 
56 		virtual void Pulse();
57 
58 	private:
59 		ifnet *fEthernetIfnet;
60 		uint8 fPeer[6];
61 		uint16 fSessionID;
62 		uint32 fHostUniq;
63 		const char *fACName, *fServiceName;
64 
65 		uint32 fAttempts;
66 		bigtime_t fNextTimeout;
67 		pppoe_state fState;
68 };
69 
70 
71 #endif
72