WLAN specific implementation of the PeerHood plugin interface.
Inheritance:
Public Methods
-
CWLANPlugin()
- Default constructor, sets the internal variables to their default values.
-
bool TestConnection(unsigned int aFd, unsigned int aBytes)
- Tests TCP connection for incoming data.
-
bool LoadParameter(std::string& aParameter)
- Loads a parameter from the configuration file.
-
bool Start()
- Starts the plugin's inquiry routine.
-
void Stop()
- Stops the plugin's inquiry routine.
-
bool Listen()
- Starts the plugin's inquiry listen routine.
-
void UnListen()
- Stops the plugin's inquiry listen routine.
-
const std::string& GetName()
- Returns plugin's unique id string.
-
void UpdateState()
- Updates the state
-
void RegisterListener(MAbstractListener* aListener)
- Register a new listener for this plugin
-
void SetState(bool aActive)
- Change the state of the plugin
-
void TriggerShutdown()
- Set to shut down - not used
-
void LoadListeners()
- Loads all listeners for this plugin
-
void* ThreadStarter(void* aArguments)
- Starts plugin's main (inquiry) thread.
-
void* ListenStarter(void* aArguments)
- Starts plugin's inquiry listen thread.
-
void* AdvertStarter(void* aArguments)
- Starts plugin's advertising thread.
-
void InquiryThread()
- Plugin's main thread that performs WLAN inquiry at certain intervals.
-
void ListenThread()
- Plugin's inquiry thread that listens WLAN inquiries.
-
bool AddDevice(const std::string& aDeviceName)
- Checks if the found device is new (i.e. not detected before).
-
bool MakeOlder()
- Increases each device's timestamp by one and checks is some of them exceeds the limit.
-
bool Advert()
- Starts advertazing the PeerHood service by providing a lookup service.
-
bool Unadvert()
- Removes the PeerHood tag from the lookup service.
-
bool HasPeerHood(const std::string& aAddress, int* aPSM)
- Checks if the PeerHood tag can be found from remote device's lookup service
-
bool FetchInformation(CDaemonDevice* aDevice)
- Fetch the required information from other device
-
bool FetchDeviceInfo(CDaemonDevice* aDevice, CTCPConnection* connection)
- Fetch services from the remote device
-
bool FetchServices(CDaemonDevice* aDevice)
- Fecthes a list of services available on the given remote device.
-
bool FetchServices(CDaemonDevice* aDevice, CTCPConnection* connection)
- Fetch services from the remote device
-
bool FetchPrototypes(CDaemonDevice* aDevice, CTCPConnection* connection)
- Fetch prototypes from the remote device
-
void RemoveListeners()
- Clear list of listers
Public Methods
-
virtual void SetAdapter(const std::string& aInterface, int aId)
Documentation
This class is WLAN specific implementation of the PeerHood plugin
interface. Other PeerHood capable devices are located using implemented
lookup service
CWLANPlugin()
-
Default constructor, sets the internal variables to their default
values. This method loads WLAN interface, monitoring and service checking interval variables fro
configuration file.
- Returns:
- none
bool TestConnection(unsigned int aFd, unsigned int aBytes)
-
Tests TCP connection using ioctl. This method checks how manyt
bytes there are available for reading. This checking is necessary because
MSG_WAITALL flag is used for reading.
- Parameters:
- aFd - Socket filedescriptor which is checked
aBytes - How many bytes are expected to be available
- Returns:
- false if there is not enough bytes pending
bool LoadParameter(std::string& aParameter)
-
Loads a parameter from the configuration file. If the requested
parameter is found then the argument <code>aParameter</code> is replaced
with parameter's value.
- Parameters:
- aParameter - Parameter's name.
- Returns:
- true if the requested parameter was found
bool Start()
-
Starts the plugin's inquiry routine. After this method is called the
plugin starts to monitor its environment and tries to locate nearby
PeerHood-capable devices. Whenever a change in the neighborhood status is
detected the plugin will update the device & service database . This plugin
uses protocol defined by virtual peerhood for WLAN devices to locate
PeerHood-capable devices in the neighborhood.
- Returns:
- boolean telling if the plugin could be started
void Stop()
-
Stops the plugin's inquiry routine. After this call is handled the
plugin will stop monitoring the environment. This means that daemon's
device & service database will be deprecated as the time passes.
- Returns:
- none
bool Listen()
-
Starts the plugin's inquiry listen routine.
- Returns:
- boolean telling if the plugin could be started
void UnListen()
-
Stops the plugin's inquiry routine.
- Returns:
- none
const std::string& GetName()
-
Returns plugin's unique id string. The id of this plugin is 'wlan-base'.
- Returns:
- plugin's unique id string ('wlan-base')
void UpdateState()
-
Checks messages for every listener that is registered into this plugin.
void RegisterListener(MAbstractListener* aListener)
-
Adds a listener into the internal list of listener. Used by listeners only.
- Parameters:
- MAbstractlistener - * aListener Reference to the listener that is added
void SetState(bool aActive)
-
Sets new state for plugin (or no changes if there is no need)
- Parameters:
- aActive - new state (true = active, false = passive)
void TriggerShutdown()
-
Not used - does nothing
void LoadListeners()
-
Uses the ListenerFactory for listener creation. When listeners have been created (listeners
automatically register themselves to the object that asked to create them) they are commanded
to connect to their sources and to check the initial state.
void* ThreadStarter(void* aArguments)
-
Starts plugin's main (inquiry) thread. This dummy function is required
because C++ doesn't allow non-static member functions to be started as a
thread. This function just calls plugin instance's real inquiry function.
- Parameters:
- aArguments - Pointer to the currently running instance.
- Returns:
- always NULL
void* ListenStarter(void* aArguments)
-
Starts plugin's inquiry listen thread. This dummy function is required
because C++ doesn't allow non-static member functions to be started as a
thread. This function just calls plugin instance's real inquiry function.
- Parameters:
- aArguments - Pointer to the currently running instance.
- Returns:
- always NULL
void* AdvertStarter(void* aArguments)
-
Starts plugin's advertising thread. This dummy function is required
because C++ doesn't allow non-static member functions to be started as a
thread. This function just calls plugin instance's real advertising
function.
- Parameters:
- aArguments - Pointer to the currently running instance.
- Returns:
- always NULL
void InquiryThread()
-
Plugin's main thread that performs WLAN inquiry at certain intervals. All
found devices are stored to the DeviceStorage shared with all plugins and
the PeerHood Daemon. Inquiry is performed in two-phases: First inquiring device
broadcastst HELLO -message using specific UDP port. Other devices are listening
to this port and send a reply back. Inquiring device receives these replies
using ListeningThread and adds devices to database.
void ListenThread()
-
Plugin's inquiry thread that listen WLAN inquiries. This thread
listens for UDP broadcast and unicast traffic using specific ports. If
someone sends UDP broadcast thread sends unicast back. If someone sends
unicast, thread adds the device into it's databse.
- Returns:
- none
bool AddDevice(const std::string& aDeviceName)
-
Checks if the found device is new (i.e. not detected before). If this
is the case then it is added to plugin's internal device list and the common
device & service database should be updated later on.
There two kinds of counters for device: timestamp is used for to mark "old" devices
and lastchecked is for performing service checking on specific interval.
timestamp is zerod every time when device is found. If timestamp reaches specific value
device is erased. If device is seen, lastchecked value is decreased. If lastchecked
reaches zero, device services are checked.
- Parameters:
- aDeviceName - The name of the device to be added.
- Returns:
- true if the checked device is new
bool MakeOlder()
-
Increases each device's timestamp value by one and checks if some of
them exceeds the limit defined byt KEEP_ALIVE_STAMP. In that case the "old"
device is removed from
the internal device list so the common device & service database should be
updated.
4 *
- Returns:
- true if some device was removed from the internal device list
bool Advert()
-
Starts advertazing the PeerHood service by providing a lookup service.Other WLAN-
enabled PeerHood devices will look PeerHood service from this well-known lookup service
when they try to locate the surrounding PeerHood devices. If this function fails other devices are
not capable of detecting PeerHood on this device.
- Returns:
- true if the advertising was started successfully
bool Unadvert()
-
Removes the PeerHood tag from the lookup service. After this
function is invoked, other devices are not able to detect the existence of
the PeerHood service on this machine.
- Returns:
- true if the advertising was ended succesfully
bool HasPeerHood(const std::string& aAddress, int* aPSM)
-
Checks if the PeerHood tag can be found from remote device's
lookup service. If the tag if found then the remote device is assumed to be
PeerHood-capable without any further checking.
- Parameters:
- aAddress - The address of the remote device.
aPSM - On return contains the PSM of the remote address if PeerHood is
found, otherwise -1.
- Returns:
- true if the PeerHood tag was found on remote device's lookup service
bool FetchInformation(CDaemonDevice* aDevice)
-
- Returns:
- true if all information is successfully fetched
bool FetchDeviceInfo(CDaemonDevice* aDevice, CTCPConnection* connection)
-
Fetch services from remote device and add them to the list of this daemon device
- Returns:
- true if all information is successfully fetched
bool FetchServices(CDaemonDevice* aDevice)
-
Fetches a list of services available on the given remote device. This
is done by establishing a new connection to the remote device using address
information given in the parameter <code>aDevice</code> and invoking the
service list request on the remote device. Founded services are added to
the device.
- Parameters:
- aDevice - The device whose service list should be fetched.
- Returns:
- none
bool FetchServices(CDaemonDevice* aDevice, CTCPConnection* connection)
-
Fetch services from remote device and add them to the list of this daemon device
- Returns:
- true if all information is successfully fetched
bool FetchPrototypes(CDaemonDevice* aDevice, CTCPConnection* connection)
-
Fetch prototypes from remote device and add them to the list of this daemon device
- Returns:
- true if all information is successfully fetched
void RemoveListeners()
-
Removes all listeners from the listener list. Called when this object is destroyed.
Listeners are loaded only once!
- This class has no child classes.
- See Also:
- MAbstractPlugin
Alphabetic index HTML hierarchy of classes or Java
This page was generated with the help of DOC++.