EnOcean Link  1.14.0.0
Middleware to Connect EnOcean easily to other Projects
eoWatcher.h
Go to the documentation of this file.
1 
8 #include "eoDevice.h"
9 #include "eoTimer.h"
10 #include "eoIWatcher.h"
11 #ifndef EOWATCHER_H_
12 #define EOWATCHER_H_
13 #include <vector>
14 #include <map>
15 #include <stdint.h>
17 typedef enum
18 {
20  WATCH_OK = 0,
41 
43 
44 
46 typedef struct
47 {
49  uint32_t maxRLCDiff;
51  uint32_t minPeriodTime;
53  uint32_t maxPeriodTime;
55  uint32_t timeLastTelegram;
57  uint32_t wrongCMACUsages;
59  uint32_t maxWrongCmac;
62 } WATCH_STRUCT;
63 
64 typedef std::map<uint32_t, WATCH_STRUCT> watcher_id_map;
79 class eoWatcher : public eoIWatcher
80 {
81 public:
82  eoWatcher();
91  eoWatcher(uint32_t denialWarnCount,uint32_t denialTickBetween);
111  EO_SEC_WATCH_RESULT AddDevice(uint32_t const DeviceID,uint32_t const maxPerdiodTime,uint32_t const minPeriodTime,uint32_t const maxRLCDiff,uint32_t const maxWrongCmac,bool resetPeriod);
126  EO_SEC_WATCH_RESULT UpdateDevice(uint32_t const DeviceID,uint32_t const maxPerdiodTime,uint32_t const minPeriodTime,uint32_t const maxRLCDiff,uint32_t const maxWrongCmac,bool resetPeriod);
134  void RemoveDevice(uint32_t const DeviceID);
144  uint32_t CheckSecurity(eoDevice const * const device,eoTelegram const &tel);
145 
153  EO_SEC_WATCH_RESULT Reset(uint32_t const DeviceID);
163  bool CheckDeadDevices(std::vector<uint32_t> &deadDevicesVector);
164 
169  void SetDenialWarnCount(uint32_t const warnCount){denialWarnCount=warnCount;}
174  uint32_t GetDenialWarnCount() const{return denialWarnCount;}
179  void SetDenialTickBetween(uint32_t const tickCount){denialTickBetween=tickCount;}
184  uint32_t GetDenialTickBetween() const{return denialTickBetween;}
185  uint8_t Serialize(eoArchive &arch);
186  virtual ~eoWatcher();
187 private:
189  uint32_t denialCounter;
191  uint32_t tickOfLastTelegram;
192 
194  uint32_t denialWarnCount;
196  uint32_t denialTickBetween;
198  watcher_id_map watchedMap;
204  EO_SEC_WATCH_RESULT DeviceCheck(eoDevice const * const device);
205 };
206 
207 #endif /* EOWATCHER_H_ */
The counter of maximal allowed telegrams with wrong cmacs has been reached.
Definition: eoWatcher.h:38
uint32_t maxRLCDiff
Warns if the RLC is to different!
Definition: eoWatcher.h:49
The minimal Interface for an eoWatcher class.
Definition: eoIWatcher.h:28
The telegram of the watched device came to early.
Definition: eoWatcher.h:34
uint32_t timeLastTelegram
tick count of the last handled Telegram
Definition: eoWatcher.h:55
uint32_t maxWrongCmac
maximal allowed wrong CMAC for the device
Definition: eoWatcher.h:59
void RemoveDevice(uint32_t const DeviceID)
Remove a device.
void SetDenialWarnCount(uint32_t const warnCount)
Definition: eoWatcher.h:169
The telegram of the watched device came to late.
Definition: eoWatcher.h:36
Device does not exist.
Definition: eoWatcher.h:22
every Communication from an EnOcean Device to another one consist out of one more Telegrams...
Definition: eoTelegram.h:43
EO_SEC_WATCH_RESULT AddDevice(uint32_t const DeviceID, uint32_t const maxPerdiodTime, uint32_t const minPeriodTime, uint32_t const maxRLCDiff, uint32_t const maxWrongCmac, bool resetPeriod)
Adds a Device to watch.
a class to describe an EnOcean Device
Definition: eoDevice.h:49
A denial of service is assumed.
Definition: eoWatcher.h:30
You tried to added a non secure device or the watched device does not have valid security information...
Definition: eoWatcher.h:26
Watch structure.
Definition: eoWatcher.h:46
Device is watched and no security issues.
Definition: eoWatcher.h:20
uint8_t Serialize(eoArchive &arch)
void SetDenialTickBetween(uint32_t const tickCount)
Definition: eoWatcher.h:179
uint32_t GetDenialTickBetween() const
Definition: eoWatcher.h:184
bool resetPeriod
Reset Period after every Received Telegram.
Definition: eoWatcher.h:61
EO_SEC_WATCH_RESULT UpdateDevice(uint32_t const DeviceID, uint32_t const maxPerdiodTime, uint32_t const minPeriodTime, uint32_t const maxRLCDiff, uint32_t const maxWrongCmac, bool resetPeriod)
Update device Information.
EO_SEC_WATCH_RESULT
Security Watch Result.
Definition: eoWatcher.h:17
The Difference RLC of the last and current has reached the allowed one.
Definition: eoWatcher.h:40
A Delay attack is assumed.
Definition: eoWatcher.h:32
uint32_t wrongCMACUsages
current wrong cmac
Definition: eoWatcher.h:57
Watcher Header File.
bool CheckDeadDevices(std::vector< uint32_t > &deadDevicesVector)
Check for dead Devices.
Device duplicated.
Definition: eoWatcher.h:24
eoDevice
The processed device&message is not watched.
Definition: eoWatcher.h:28
uint32_t minPeriodTime
min Time before a Telegram is expected
Definition: eoWatcher.h:51
EO_SEC_WATCH_RESULT Reset(uint32_t const DeviceID)
Reset security parameters.
uint32_t CheckSecurity(eoDevice const *const device, eoTelegram const &tel)
checks the Security of a Device after Receiving a telegram.
an example implementation of an Security Watcher Class which tries to predict DOS and Delay Attacks...
Definition: eoWatcher.h:79
uint32_t GetDenialWarnCount() const
Definition: eoWatcher.h:174
the base Archive
Definition: eoArchive.h:46
uint32_t maxPeriodTime
max Time where a telegram is expected
Definition: eoWatcher.h:53