Skip to content

Commit

Permalink
unique repeaters
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertvanheusden committed Nov 12, 2023
1 parent a136afd commit 2c06642
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 22 additions & 1 deletion ax25.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,20 @@ ax25_address & ax25_address::operator=(const ax25_address & in)
return *this;
}

bool ax25_address::operator==(const ax25_address & other) const
{
if (other.get_valid() != valid)
return false;

if (other.get_address() != address)
return false;

if (other.get_ssid() != ssid)
return false;

return true;
}

void ax25_address::set_address(const std::string & address, const int ssid)
{
this->address = address;
Expand Down Expand Up @@ -248,7 +262,14 @@ std::vector<ax25_address> ax25_packet::get_repeaters() const

void ax25_packet::add_repeater(const any_addr & addr)
{
repeaters.push_back(ax25_address(addr));
ax25_address temp(addr);

for(auto & repeater : repeaters) {
if (repeater == temp)
return;
}

repeaters.push_back(temp);
}

buffer_in ax25_packet::get_data() const
Expand Down
2 changes: 2 additions & 0 deletions ax25.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class ax25_address
ax25_address(const ax25_address & a);
ax25_address(const std::string & a, const int ssid, const bool end_mark, const bool repeated);
ax25_address(const std::string & a, const bool end_mark, const bool repeated);

ax25_address & operator=(const ax25_address &);
bool operator==(const ax25_address & other) const;

bool get_valid() const { return valid; }
std::string get_invalid_reason() const { return invalid_reason; }
Expand Down

0 comments on commit 2c06642

Please sign in to comment.