class CGPRSPlugin

GPRS specific implementation of the PeerHood plugin interface.

Inheritance:


Public Methods

[more] CGPRSPlugin()
Default constructor, sets the internal variables to their default values.
[more]bool LoadParameter(std::string& aParameter)
Loads a parameter from the configuration file.
[more]bool Start()
Starts the plugin's inquiry routine.
[more]void Stop()
Stops the plugin's inquiry routine.
[more]bool Advert()
Starts advertazing the PeerHood service by providing a lookup service.
[more]bool Unadvert()
Removes the PeerHood tag from the lookup service.
[more]const std::string& GetName()
Returns plugin's unique id string.
[more]void* ThreadStarter(void* aArguments)
Starts plugin's main (inquiry) thread.
[more]void* AdvertStarter(void* aArguments)
Starts plugin's advertising thread.
[more]bool TestConnection(unsigned int aFd, unsigned int aBytes)
Tests TCP connection for incoming data.
[more]void InquiryThread()
Plugin's main thread that performs inquiry at certain intervals.
[more]bool AddDevice(unsigned int aId)
Checks if the found device is new (i.e. not detected before).
[more]bool MakeOlder()
Increases each device's timestamp by one and checks is some of them exceeds the limit.
[more]bool AddService(unsigned int aId, CService* aService)
Adds services to internal devicelist
[more]void AdvertThread()
Listens for incoming service list requests and routes data to service.
[more]bool DecapsulateSignal(int aSourceFd, CGPRSSignal& aSignal)
Receives and decapsulates metadata
[more]bool EncapsulateSignal(int aTargetFd, CGPRSSignal& aSignal)
Encapsulates and sends metadata
[more]bool GetLocalServicesL(CService* &aService, std::string& aServiceName)
Fetches local services from daemon
[more]bool StartClientDataThread(CGPRSConnection* aLocalConnection)
Starts ClientData -thread.
[more]void* ClientDataThreadStarter(void* aArguments)
ClientData -thread starter
[more]void ClientDataThread(CGPRSThread& aThreadInfo)
Implementation of ClientData -thread
[more]bool StartServerDataThread(unsigned int aOriginalId, const std::string &aServiceName, unsigned int aCommand)
Starts ServerData -thread.
[more]void* ServerDataThreadStarter(void* aArguments)
Starts a new ServerData -thread.
[more]void ServerDataThread(CGPRSThread& aThreadInfo)
Implementation of ServerData -thread.


Inherited from MAbstractPlugin:

Public Methods

ovirtual void UpdateState()
ovirtual void LoadListeners()


Inherited from MAbstractStateConverter:

Public Methods

ovirtual void RegisterListener(MAbstractListener* aListener)
ovirtual void SetState(bool aActive)
ovirtual void TriggerShutdown()
ovirtual void SetAdapter(const std::string& aInterface, int aId)


Documentation

This class is GPRS specific implementation of the PeerHood plugin interface. Other PeerHood capable devices are located using the GPRS Gateway

o CGPRSPlugin()
Default constructor, sets the internal variables to their default values. This method loads gateway address, monitoring and service checking interval variables from configuration file.
Returns:
none

obool 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

obool 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 GPRS devices to locate PeerHood-capable devices in the neighborhood.

Returns:
boolean telling if the plugin could be started

ovoid 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

obool Advert()
Starts advertazing the PeerHood service by providing a lookup service.Other GPRS- 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

obool 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

oconst std::string& GetName()
Returns plugin's unique id string. The id of this plugin is 'gprs-base'.

Returns:
plugin's unique id string ('gprs-base')

ovoid* 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

ovoid* 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

obool 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

ovoid InquiryThread()
Plugin's main thread that performs inquiry at certain intervals. This inquiry creates TCP-connection to gateway which tries first to acquire unique id number. After id has been received, inquiry starts to inquiry for number of devices and services. Found devices are stored to the DeviceStorage shared with all plugins and the PeerHood Daemon. This whole process is performed continuosly on user-defined interval. If the connection breaks thread tries to reconnect instantly and returns back to it's initial state.

Parameters:
none -
Returns:
none

obool AddDevice(unsigned int aId)
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:
aId - The ID of the device to be added.
Returns:
true if the checked device is new

obool 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

obool AddService(unsigned int aId, CService* aService)
Adds services to internal devicelist. Method updates devicelist by adding services for specific device.

Parameters:
aId - Device ID
aService - Service which is added
Returns:
true if some device was removed from the internal device list

ovoid AdvertThread()
Listens for incoming service list requests and routes data to service. Function serves for incoming service list requests by sending all the local registered services. Function also provides routing for data between local services and GPRS-gateway.

Returns:
none

obool DecapsulateSignal(int aSourceFd, CGPRSSignal& aSignal)
Receives and decapsulates metadata. First data length is received and after that, the whole data.

Parameters:
aSourceFd - Source socket filedescriptor
aSignal - Container for received message
Returns:
true if succesful

obool EncapsulateSignal(int aTargetFd, CGPRSSignal& aSignal)
Encapsulates and sends metadata. First data length is sent and after that, the whole data.

Parameters:
aTargetFd - target filedescpriptor
aSignal - Signal which is wanted to be sent
Returns:
true if succesful

obool GetLocalServicesL(CService* &aService, std::string& aServiceName)
Fetches local services from daemon. Function queries all found local services and searches service by given aSeviceName. User is responsible to free allocated memory for aService class.

Parameters:
aService - class for receicing found service entry
aServiceName - servicaneme to search for
Returns:
true if succesful

obool StartClientDataThread(CGPRSConnection* aLocalConnection)
Starts ClientData -thread. This ClientData -thread creates a new Data Connection to the GPRS Gateway. ClientData -thread negoatiates a new Data Connection between GPRS Gateway and target device and starts to route data between localsocket -connection from application layer and TCP connection to the GPRS Gateway.

Parameters:
aLocalConnection - LocalConnection from the application layer.
Returns:
true if succesful

ovoid* ClientDataThreadStarter(void* aArguments)
ClientData -thread starter

Parameters:
aArguments - Arguments for the thread
Returns:
true if succesful

ovoid ClientDataThread(CGPRSThread& aThreadInfo)
Implementation of ClientData -thread. Negoatiates a new Data Connection between GPRS Gateway and target device. ClientData -thread routes data between local connection and established Data Connection.

Parameters:
aThreadInfo - Reference to ThreadInfo class
Returns:
true if succesful

obool StartServerDataThread(unsigned int aOriginalId, const std::string &aServiceName, unsigned int aCommand)
Starts ServerData -thread. This ServerData -thread creates a new Data Connection to the GPRS Gateway. ClientData -thread negoatiates a new Data Connection between GPRS Gateway and target device and starts to route data between Data Connection from the GPRS Gateway to the local service using local socket connection.

Parameters:
aOriginalId - Id of the remote device which initiated connection
aServiceName - Name of the local service which is wanted to be connected by a remote device
aCommand - Command from remote device (for example PH_DIRECT_DATA)
Returns:
true if succesful

ovoid* ServerDataThreadStarter(void* aArguments)
Starts a new ServerData -thread.

Parameters:
aArguments - Arguments for thread
Returns:
true if succesful

ovoid ServerDataThread(CGPRSThread& aThreadInfo)
Implementation of ServerData -thread. This thread creates a new Data Connection to GPRS gateway and to local connection to local service. After this, thread starts to route data betweeen these connections.

Parameters:
aThreadInfo - Reference to thread information
Returns:
true if succesful


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++.