xref: /haiku/src/add-ons/kernel/network/ppp/shared/libppp/headers/PPPInterface.h (revision 1d9d47fc72028bb71b5f232a877231e59cfe2438)
1 /*
2  * Copyright 2003-2005, Haiku Inc.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 #ifndef _PPP_INTERFACE__H
7 #define _PPP_INTERFACE__H
8 
9 #include <KPPPManager.h>
10 #include <String.h>
11 
12 class BEntry;
13 
14 
15 class PPPInterface {
16 	public:
17 		PPPInterface(ppp_interface_id ID = PPP_UNDEFINED_INTERFACE_ID);
18 		PPPInterface(const PPPInterface& copy);
19 		~PPPInterface();
20 
21 		status_t InitCheck() const;
22 
23 		//!	Returns the name of the interface description file.
24 		const char *Name() const
25 			{ return fName.String(); }
26 
27 		status_t SetTo(ppp_interface_id ID);
28 		//!	Returns the unique id of this interface.
29 		ppp_interface_id ID() const
30 			{ return fID; }
31 
32 		status_t Control(uint32 op, void *data, size_t length) const;
33 
34 		bool SetUsername(const char *username) const;
35 		bool SetPassword(const char *password) const;
36 		bool SetAskBeforeConnecting(bool askBeforeConnecting) const;
37 
38 		status_t GetSettingsEntry(BEntry *entry) const;
39 		bool GetInterfaceInfo(ppp_interface_info_t *info) const;
40 		bool GetStatistics(ppp_statistics *statistics) const;
41 		bool HasSettings(const driver_settings *settings) const;
42 
43 		bool Up() const;
44 		bool Down() const;
45 
46 		bool EnableReports(ppp_report_type type, thread_id thread,
47 			int32 flags = PPP_NO_FLAGS) const;
48 		bool DisableReports(ppp_report_type type, thread_id thread) const;
49 
50 		//!	Same as \c SetTo(copy.ID());
51 		PPPInterface& operator= (const PPPInterface& copy)
52 			{ SetTo(copy.ID()); return *this; }
53 		//!	Same as \c SetTo(ID);
54 		PPPInterface& operator= (ppp_interface_id ID)
55 			{ SetTo(ID); return *this; }
56 
57 	private:
58 		ppp_interface_id fID;
59 		int fFD;
60 		BString fName;
61 };
62 
63 
64 #endif
65