GPRS specific implementation of the PeerHood plugin interface.
Inheritance:
Public Methods
-
CGPRSPlugin()
- Default constructor, sets the internal variables to their default values.
-
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 Advert()
- Starts advertazing the PeerHood service by providing a lookup service.
-
bool Unadvert()
- Removes the PeerHood tag from the lookup service.
-
const std::string& GetName()
- Returns plugin's unique id string.
-
void* ThreadStarter(void* aArguments)
- Starts plugin's main (inquiry) thread.
-
void* AdvertStarter(void* aArguments)
- Starts plugin's advertising thread.
-
bool TestConnection(unsigned int aFd, unsigned int aBytes)
- Tests TCP connection for incoming data.
-
void InquiryThread()
- Plugin's main thread that performs inquiry at certain intervals.
-
bool AddDevice(unsigned int aId)
- 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 AddService(unsigned int aId, CService* aService)
- Adds services to internal devicelist
-
void AdvertThread()
- Listens for incoming service list requests and routes data to service.
-
bool DecapsulateSignal(int aSourceFd, CGPRSSignal& aSignal)
- Receives and decapsulates metadata
-
bool EncapsulateSignal(int aTargetFd, CGPRSSignal& aSignal)
- Encapsulates and sends metadata
-
bool GetLocalServicesL(CService* &aService, std::string& aServiceName)
- Fetches local services from daemon
-
bool StartClientDataThread(CGPRSConnection* aLocalConnection)
- Starts ClientData -thread.
-
void* ClientDataThreadStarter(void* aArguments)
- ClientData -thread starter
-
void ClientDataThread(CGPRSThread& aThreadInfo)
- Implementation of ClientData -thread
-
bool StartServerDataThread(unsigned int aOriginalId, const std::string &aServiceName, unsigned int aCommand)
- Starts ServerData -thread.
-
void* ServerDataThreadStarter(void* aArguments)
- Starts a new ServerData -thread.
-
void ServerDataThread(CGPRSThread& aThreadInfo)
- Implementation of ServerData -thread.
Public Methods
-
virtual void UpdateState()
-
virtual void LoadListeners()
Public Methods
-
virtual void RegisterListener(MAbstractListener* aListener)
-
virtual void SetState(bool aActive)
-
virtual void TriggerShutdown()
-
virtual 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
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
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 GPRS 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 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
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
const 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')
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* 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
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
void 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
bool 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
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 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
void 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
bool 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
bool 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
bool 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
bool 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
void* ClientDataThreadStarter(void* aArguments)
-
ClientData -thread starter
- Parameters:
- aArguments - Arguments for the thread
- Returns:
- true if succesful
void 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
bool 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
void* ServerDataThreadStarter(void* aArguments)
-
Starts a new ServerData -thread.
- Parameters:
- aArguments - Arguments for thread
- Returns:
- true if succesful
void 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++.