xref: /haiku/src/add-ons/kernel/network/ppp/pppoe/PPPoEDevice.h (revision 97dfeb96704e5dbc5bec32ad7b21379d0125e031)
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 #include <net/if_types.h>
14 #include <net_stack.h>
15 
16 
17 enum pppoe_state {
18 	INITIAL,
19 		// the same as IsDown() == true
20 	PADI_SENT,
21 	PADR_SENT,
22 	OPENED
23 		// the same as IsUp() == true
24 };
25 
26 
27 class PPPoEDevice : public KPPPDevice {
28 	public:
29 		PPPoEDevice(KPPPInterface& interface, driver_parameter *settings);
30 
31 		net_device *EthernetIfnet() const
32 			{ return fEthernetIfnet; }
33 
34 		const uint8 *Peer() const
35 			{ return fPeer; }
36 		uint16 SessionID() const
37 			{ return fSessionID; }
38 		uint32 HostUniq() const
39 			{ return fHostUniq; }
40 
41 		const char *ACName() const
42 			{ return fACName; }
43 		const char *ServiceName() const
44 			{ return fServiceName; }
45 
46 		virtual status_t InitCheck() const;
47 
48 		virtual bool Up();
49 		virtual bool Down();
50 
51 		virtual uint32 InputTransferRate() const;
52 		virtual uint32 OutputTransferRate() const;
53 
54 		virtual uint32 CountOutputBytes() const;
55 
56 		virtual status_t Send(net_buffer *packet, uint16 protocolNumber = 0);
57 		virtual status_t Receive(net_buffer *packet, uint16 protocolNumber = 0);
58 
59 		virtual void Pulse();
60 
61 	private:
62 		net_device *fEthernetIfnet;
63 		uint8 fPeer[6];
64 		uint8 fEtherAddr[6];
65 		uint16 fSessionID;
66 		uint32 fHostUniq;
67 		const char *fACName, *fServiceName;
68 		const char *finterfaceName;
69 
70 		uint32 fAttempts;
71 		bigtime_t fNextTimeout;
72 		pppoe_state fState;
73 };
74 
75 
76 #endif
77