Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/the_dude_to_human/database/dude_field_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,20 @@ ParserResult DudeFieldParser::ReadField(ByteField& field, FieldId id) {
return result;
}

if (field.info.type.Value() != FieldType::Byte) {
switch (field.info.type) {
case FieldType::Byte:
break;
case FieldType::Int:
printf("Warning attempted to read byte on int field: %s\n",
field.info.SerializeJson().c_str());
RestoreOffset();
return ParserResult::FieldTypeMismatch;
case FieldType::Long:
printf("Warning attempted to read byte on long field: %s\n",
field.info.SerializeJson().c_str());
RestoreOffset();
return ParserResult::FieldTypeMismatch;
default:
RestoreOffset();
return ParserResult::FieldTypeMismatch;
}
Expand All @@ -219,6 +232,10 @@ ParserResult DudeFieldParser::ReadField(IntField& field, FieldId id) {
case FieldType::Int:
case FieldType::Byte:
break;
case FieldType::Long:
printf("Warning attempted to read int on long field: %s\n",
field.info.SerializeJson().c_str());
return ParserResult::FieldTypeMismatch;
default:
RestoreOffset();
return ParserResult::FieldTypeMismatch;
Expand Down
40 changes: 20 additions & 20 deletions src/the_dude_to_human/database/dude_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,14 @@ struct ServerConfigData : DudeObj {
IntField object_id;
ByteField version;
IntField snmp_profile_id;
ByteField agent_id;
ByteField probe_interval;
ByteField probe_timeout;
ByteField probe_down_count;
IntField agent_id;
IntField probe_interval;
IntField probe_timeout;
IntField probe_down_count;
IntField syslog_port;
ByteField snmp_trap_port;
IntField snmp_trap_port;
IntField map_background_color;
ByteField map_label_refresh_interval;
IntField map_label_refresh_interval;
IntField map_up_color;
IntField map_down_partial_color;
IntField map_down_complete_color;
Expand Down Expand Up @@ -747,15 +747,15 @@ struct DeviceData : DudeObj {
BoolField notify_use;
BoolField prove_enabled;
ByteField lookup;
ByteField dns_lookup_interval;
IntField dns_lookup_interval;
ByteField mac_lookup;
IntField type_id;
IntField agent_id;
IntField snmp_profile_id;
IntField object_id;
IntField prove_interval;
ByteField prove_timeout;
ByteField prove_down_count;
IntField prove_timeout;
IntField prove_down_count;
TextField custom_field_3;
TextField custom_field_2;
TextField custom_field_1;
Expand Down Expand Up @@ -810,17 +810,17 @@ struct ServiceData : DudeObj {
BoolField notify_use;
BoolField acked;
IntField probe_port;
ByteField probe_interval;
ByteField probe_timeout;
ByteField probe_down_count;
IntField probe_interval;
IntField probe_timeout;
IntField probe_down_count;
IntField data_source_id;
ByteField status;
IntField time_since_changed;
IntField time_since_last_up;
IntField time_since_last_down;
IntField time_previous_up;
IntField time_previous_down;
ByteField proves_down;
IntField proves_down;
IntField object_id;
IntField device_id;
IntField agent_id;
Expand Down Expand Up @@ -864,8 +864,8 @@ struct NotificationData : DudeObj {
IntField log_color;
ByteField speak_rate;
ByteField speak_volume;
ByteField delay_interval;
ByteField repeat_interval;
IntField delay_interval;
IntField repeat_interval;
ByteField repeat_count;
IntField object_id;
IntField rype_id;
Expand Down Expand Up @@ -960,13 +960,13 @@ struct LinkTypeData : DudeObj {
struct DataSourceData : DudeObj {
BoolField enabled;
IntField function_device_id;
ByteField function_interval;
IntField function_interval;
ByteField data_source_type;
IntField object_id;
ByteField keep_time_raw;
ByteField keep_time_10min;
ByteField keep_time_2hour;
ByteField keep_time_1Day;
IntField keep_time_raw;
IntField keep_time_10min;
IntField keep_time_2hour;
IntField keep_time_1Day;
TextField function_code;
TextField unit;
TextField name;
Expand Down
Loading