source and destination not yet working

This commit is contained in:
Florian Hoss 2022-04-24 14:59:42 +02:00
parent ffee834ccb
commit 97ffecb172

View file

@ -68,9 +68,9 @@ namespace fw
uint8_t security_number = EEPROM.read(this->eeprom_settings_head); uint8_t security_number = EEPROM.read(this->eeprom_settings_head);
uint8_t amount_of_rules = EEPROM.read(this->eeprom_amout_of_rules_head); uint8_t amount_of_rules = EEPROM.read(this->eeprom_amout_of_rules_head);
if (amount_of_rules < 50 || security_number != this->security_number) if (amount_of_rules > 50 || security_number != this->security_number)
return amount_of_rules; return 0;
return 0; return amount_of_rules;
} }
return 0; return 0;
#endif #endif
@ -109,10 +109,23 @@ namespace fw
#elif defined(ESP8266) #elif defined(ESP8266)
uint16_t eespom_position = eeprom_rule_position(key); uint16_t eespom_position = eeprom_rule_position(key);
strncpy(rule_ptr->source, "test", sizeof(rule_ptr->source)); String source;
for (uint8_t i = 0; i < sizeof(rule_ptr->source); i++)
{
source += EEPROM.read(eespom_position + i);
}
strncpy(rule_ptr->source, source.c_str(), sizeof(rule_ptr->source));
eespom_position += sizeof(rule_ptr->source); eespom_position += sizeof(rule_ptr->source);
strncpy(rule_ptr->destination, "test de", sizeof(rule_ptr->destination));
String destination;
for (uint8_t i = 0; i < sizeof(rule_ptr->destination); i++)
{
destination += EEPROM.read(eespom_position + i);
}
strncpy(rule_ptr->destination, destination.c_str(), sizeof(rule_ptr->destination));
eespom_position += sizeof(rule_ptr->destination); eespom_position += sizeof(rule_ptr->destination);
rule_ptr->protocol = static_cast<firewall_protocol_t>(EEPROM.read(eespom_position)); rule_ptr->protocol = static_cast<firewall_protocol_t>(EEPROM.read(eespom_position));
eespom_position += sizeof(rule_ptr->protocol); eespom_position += sizeof(rule_ptr->protocol);
rule_ptr->target = static_cast<firewall_target_t>(EEPROM.read(eespom_position)); rule_ptr->target = static_cast<firewall_target_t>(EEPROM.read(eespom_position));
@ -146,9 +159,22 @@ namespace fw
this->memory.end(); this->memory.end();
#elif defined(ESP8266) #elif defined(ESP8266)
uint16_t eespom_position = eeprom_rule_position(rule_ptr->key); uint16_t eespom_position = eeprom_rule_position(rule_ptr->key);
EEPROM.write(this->eeprom_rules_head, rule_ptr->protocol);
for (uint8_t i = 0; i < strlen(rule_ptr->source); i++)
{
EEPROM.write(eespom_position + i, rule_ptr->source[i]);
}
eespom_position += sizeof(rule_ptr->source);
for (uint8_t i = 0; i < strlen(rule_ptr->destination); i++)
{
EEPROM.write(eespom_position + i, rule_ptr->destination[i]);
}
eespom_position += sizeof(rule_ptr->destination);
EEPROM.write(eespom_position, rule_ptr->protocol);
eespom_position += sizeof(rule_ptr->protocol); eespom_position += sizeof(rule_ptr->protocol);
EEPROM.write(this->eeprom_rules_head, rule_ptr->target); EEPROM.write(eespom_position, rule_ptr->target);
EEPROM.commit(); EEPROM.commit();
#endif #endif
} }