32 lines
No EOL
1.8 KiB
TeX
32 lines
No EOL
1.8 KiB
TeX
\section{Storage}
|
|
|
|
To store the firewall rules there will be a class to handle storing and retrieving of the currently active rules. For each board there is a library available that will handle most of the work.
|
|
|
|
\subsection{esp8266}
|
|
|
|
A library called EEPROM can be used to access the memory that will be kept when the board is powered off. With this library we can easily write and read from this area.
|
|
|
|
``The supported micro-controllers on the various Arduino [...] boards have different amounts of EEPROM: [...] The Arduino [...] boards have an emulated EEPROM space of 1024 bytes.''
|
|
|
|
\cite[][]{eeprom-doc}
|
|
|
|
\subsection{esp32}
|
|
|
|
To save and retrieve data on the esp32, the Preferences.h\footnote{\href{https://github.com/espressif/arduino-esp32/blob/master/libraries/Preferences/src/Preferences.h}{preferences.h on github}} library will be used. It is a replacement for the deprecated EEPROM library that is used with the esp8266.
|
|
|
|
\subsection{Storage class}
|
|
|
|
To use the individual library with the firewall rules the firewall can be extended with the storage class. Following protected methods will be available to store and retrieve firewall rules:
|
|
|
|
\lstset{style=c++}
|
|
\begin{lstlisting}
|
|
uint8_t retrieve_amount_of_rules();
|
|
void store_amount_of_rules(const uint8_t new_amount);
|
|
firewall_rule_t *retrieve_firewall_rule(const uint8_t key);
|
|
void store_all_firewall_rules(firewall_rule_t *rule_head);
|
|
void store_firewall_rule(firewall_rule_t *rule_ptr);
|
|
\end{lstlisting}
|
|
|
|
\subsection{Space Allocation}
|
|
|
|
Each rule will get exactly the space it needs (\verb|firewall_rule_t|). Therefore a maximum of rules of \textbf{15} is specified in the constructor of the class. At the lowest storage space, there will be an 8 bit class variable for the current amount of rules, to keep track how many rules need to be restored at power up. |