Skip to content

Commit

Permalink
Convert device username to dynamic field to squeeze out a little more…
Browse files Browse the repository at this point in the history
… RAM
  • Loading branch information
dragorn committed Aug 5, 2018
1 parent eb5a43f commit 00bffe1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion devicetracker_component.cc
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ void kis_tracked_device_base::register_fields() {
RegisterField("kismet.device.base.macaddr", "mac address", &macaddr);
RegisterField("kismet.device.base.phyname", "phy name", &phyname);
RegisterField("kismet.device.base.name", "printable device name", &devicename);
RegisterField("kismet.device.base.username", "user name", &username);
username_id =
RegisterDynamicField("kismet.device.base.username", "user name", &username);
RegisterField("kismet.device.base.commonname",
"common name alias of custom or device names", &commonname);
RegisterField("kismet.device.base.type", "printable device type", &type_string);
Expand Down
8 changes: 5 additions & 3 deletions devicetracker_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,13 @@ class kis_tracked_device_base : public tracker_component {
[this](std::string i) -> bool {

// Override the common name if there's no username
if (get_username() == "")
set_commonname(i);
if (has_username())
if (get_username() == "")
set_commonname(i);
return true;
});

__ProxyL(username, std::string, std::string, std::string, username,
__ProxyDynamicL(username, std::string, std::string, std::string, username, username_id,
[this](std::string i) -> bool {

// Always override the common name
Expand Down Expand Up @@ -463,6 +464,7 @@ class kis_tracked_device_base : public tracker_component {

// User name for arbitrary naming
std::shared_ptr<TrackerElementString> username;
int username_id;

// Common name connected via preserialize
std::shared_ptr<TrackerElementString> commonname;
Expand Down

0 comments on commit 00bffe1

Please sign in to comment.