PPPInterfaceListener.h revision 3f3689bb
16cfb4dcaSWaldemar Kornewald//-----------------------------------------------------------------------
220d09e03SWaldemar Kornewald//  This software is part of the OpenBeOS distribution and is covered
320d09e03SWaldemar Kornewald//  by the OpenBeOS license.
420d09e03SWaldemar Kornewald//
56cfb4dcaSWaldemar Kornewald//  Copyright (c) 2003-2004 Waldemar Kornewald, Waldemar.Kornewald@web.de
66cfb4dcaSWaldemar Kornewald//-----------------------------------------------------------------------
720d09e03SWaldemar Kornewald
820d09e03SWaldemar Kornewald#ifndef _PPP_INTERFACE_LISTENER__H
920d09e03SWaldemar Kornewald#define _PPP_INTERFACE_LISTENER__H
1020d09e03SWaldemar Kornewald
1120d09e03SWaldemar Kornewald#include <PPPManager.h>
1220d09e03SWaldemar Kornewald#include <Locker.h>
1320d09e03SWaldemar Kornewald
1420d09e03SWaldemar Kornewaldclass BHandler;
1520d09e03SWaldemar Kornewald
1620d09e03SWaldemar Kornewald
1720d09e03SWaldemar Kornewald#define PPP_REPORT_MESSAGE	'P3RM'
183f3689bbSWaldemar Kornewald	//!< The what field of PPPInterfaceListener report messages.
1920d09e03SWaldemar Kornewald
2020d09e03SWaldemar Kornewald
2120d09e03SWaldemar Kornewaldclass PPPInterfaceListener {
226cfb4dcaSWaldemar Kornewald		friend class PPPInterfaceListenerThread;
236cfb4dcaSWaldemar Kornewald
2420d09e03SWaldemar Kornewald	public:
2520d09e03SWaldemar Kornewald		PPPInterfaceListener(BHandler *target);
2620d09e03SWaldemar Kornewald		PPPInterfaceListener(const PPPInterfaceListener& copy);
2720d09e03SWaldemar Kornewald		~PPPInterfaceListener();
2820d09e03SWaldemar Kornewald
2920d09e03SWaldemar Kornewald		status_t InitCheck() const;
3020d09e03SWaldemar Kornewald
313f3689bbSWaldemar Kornewald		//!	Returns the target BHandler for the report messages.
3220d09e03SWaldemar Kornewald		BHandler *Target() const
3320d09e03SWaldemar Kornewald			{ return fTarget; }
3420d09e03SWaldemar Kornewald		void SetTarget(BHandler *target);
3520d09e03SWaldemar Kornewald
363f3689bbSWaldemar Kornewald		//!	Returns whether watching an interface.
376cfb4dcaSWaldemar Kornewald		bool DoesWatch() const
386cfb4dcaSWaldemar Kornewald			{ return fDoesWatch; }
393f3689bbSWaldemar Kornewald		//!	Returns which interface is being watched or \c PPP_UNDEFINED_INTERFACE_ID.
406cfb4dcaSWaldemar Kornewald		ppp_interface_id WatchingInterface() const
416cfb4dcaSWaldemar Kornewald			{ return fWatchingInterface; }
426cfb4dcaSWaldemar Kornewald
433f3689bbSWaldemar Kornewald		//!	Returns the internal PPPManager object used for accessing the PPP stack.
446cfb4dcaSWaldemar Kornewald		const PPPManager& Manager() const
456cfb4dcaSWaldemar Kornewald			{ return fManager; }
466cfb4dcaSWaldemar Kornewald
475a483e4dSWaldemar Kornewald		bool WatchInterface(ppp_interface_id ID);
486cfb4dcaSWaldemar Kornewald		void WatchAllInterfaces();
496cfb4dcaSWaldemar Kornewald		void StopWatchingInterfaces();
5020d09e03SWaldemar Kornewald
513f3689bbSWaldemar Kornewald		//!	Just sets the target to the given listener's target.
5220d09e03SWaldemar Kornewald		PPPInterfaceListener& operator= (const PPPInterfaceListener& copy)
5320d09e03SWaldemar Kornewald			{ SetTarget(copy.Target()); return *this; }
5420d09e03SWaldemar Kornewald
5520d09e03SWaldemar Kornewald	private:
5620d09e03SWaldemar Kornewald		void Construct();
5720d09e03SWaldemar Kornewald
5820d09e03SWaldemar Kornewald	private:
5920d09e03SWaldemar Kornewald		BHandler *fTarget;
6020d09e03SWaldemar Kornewald		thread_id fReportThread;
6120d09e03SWaldemar Kornewald
626cfb4dcaSWaldemar Kornewald		bool fDoesWatch;
636cfb4dcaSWaldemar Kornewald		ppp_interface_id fWatchingInterface;
646cfb4dcaSWaldemar Kornewald
6520d09e03SWaldemar Kornewald		PPPManager fManager;
6620d09e03SWaldemar Kornewald		BLocker fLock;
6720d09e03SWaldemar Kornewald};
6820d09e03SWaldemar Kornewald
6920d09e03SWaldemar Kornewald
7020d09e03SWaldemar Kornewald#endif
71