Skip to content

Commit

Permalink
Bump version to 0.6.3
Browse files Browse the repository at this point in the history
    + Minor internal cleanup (function simplification).
    + Typo in error message.
  • Loading branch information
xaqq committed Nov 17, 2015
1 parent 86766b9 commit 9b0024e
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 32 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ endif()

add_definitions(-DLEOSAC_VERSION_MAJOR=0)
add_definitions(-DLEOSAC_VERSION_MINOR=6)
add_definitions(-DLEOSAC_VERSION_PATCH=2)
add_definitions(-DLEOSAC_VERSION_PATCH=3)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LEOSAC_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LEOSAC_BINARY_DIR})
Expand Down
11 changes: 10 additions & 1 deletion doc/Firmware.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,13 @@ As an example here is `logrotate` config for `rsyslog`:
invoke-rc.d rsyslog rotate > /dev/null
endscript
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


When using Jessie which provide `journald` as a logging backend, editing
`/etc/systemd/journald.conf` and setting `MaxSystemUse` should prevent log to grow
too fat.


Disable `ifplugd`. If Leosac is configured to manage the network, `ifplugd` can
cause trouble by reconfiguring the network on its own.
7 changes: 7 additions & 0 deletions pkg/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
leosac (0.6.3-1) UNRELEASED; urgency=medium

* RPleth can now support card number with up to 64bits in the Wiegand frame.
* The TCP-Notifier module is now much more flexible.

-- <[email protected]> Tue, 17 Nov 2015 14:50:00 +0100

leosac (0.6.2-1) UNRELEASED; urgency=medium

* Add support for TCP notifications
Expand Down
2 changes: 1 addition & 1 deletion src/core/auth/WiegandCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ uint64_t WiegandCard::to_int() const
case 26:
return to_wiegand_26();
default:
INFO("Not using format to convert WiegandCard to integer because not format "
INFO("Not using format to convert WiegandCard to integer because no format "
"match.");
return to_raw_int();
}
Expand Down
14 changes: 7 additions & 7 deletions src/modules/rpleth/RplethModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,7 @@ void RplethModule::rpleth_publish_card()
RplethPacket packet(RplethPacket::Sender::Server);

msg << client.first;
if (!card_convert_from_text(card_pair, &packet.data))
continue;
packet.data = card_convert_from_text(card_pair);
packet.status = RplethProtocol::Success;
packet.type = RplethProtocol::HID;
packet.command = RplethProtocol::Badge;
Expand Down Expand Up @@ -384,18 +383,19 @@ static uint64_t htonll(uint64_t value)
}
}

bool RplethModule::card_convert_from_text(std::pair<std::string, int> card_info,
std::vector<uint8_t> *dest)
std::vector<uint8_t>
RplethModule::card_convert_from_text(const std::pair<std::string, int> &card_info)
{
Auth::WiegandCard wc(card_info.first, card_info.second);
std::vector<uint8_t> ret;

auto num = wc.to_raw_int();
// This will go over the network. So we have to convert to network byte order.
num = htonll(num);

dest->resize(sizeof(num));
std::memcpy(&(*dest)[0], &num, sizeof(num));
return true;
ret.resize(sizeof(num));
std::memcpy(&ret[0], &num, sizeof(num));
return ret;
}

RplethPacket RplethModule::get_dhcp_state()
Expand Down
20 changes: 9 additions & 11 deletions src/modules/rpleth/RplethModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,15 @@ namespace Leosac
RplethModule &operator=(const RplethModule &) = delete;

/**
* Convert a card number from text to binary and store the result
* into dest.
* The result is a vector of 8bytes containing the Card Serial Number
* in MSB order.
*
* @param card_info pair (string, int) with hex representation and number of bit.
* @param dest destination vector for binary version (cannot be null)
* @returns true if conversion went well. false otherwise
*/
static bool card_convert_from_text(std::pair<std::string, int> card_info,
std::vector<uint8_t> *dest);
* Convert a card number from textual hexadecimal representation to a
* 8 bytes byte-vector in Network Byte Order.
*
* The format (Wiegand 26, 32, ...) is ingored. The whole frame will be
* used to compute the card serial number returned in the vector.
*
* @param card_info pair (string, int) with hex representation and number of bit.
*/
static std::vector<uint8_t> card_convert_from_text(const std::pair<std::string, int> &card_info);

private:
void process_config();
Expand Down
17 changes: 6 additions & 11 deletions test/Rpleth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,25 +117,20 @@ namespace Leosac
std::vector<uint8_t> out;
std::vector<uint8_t> card_binary = {0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff};

ASSERT_TRUE(RplethModule::card_convert_from_text(std::make_pair("ff:ff:ff:ff", 32), &out));
out = RplethModule::card_convert_from_text(std::make_pair("ff:ff:ff:ff", 32));
ASSERT_EQ(card_binary, out);

card_binary = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
ASSERT_TRUE(RplethModule::card_convert_from_text(std::make_pair("00:00:00:00", 32), &out));
out = RplethModule::card_convert_from_text(std::make_pair("00:00:00:00", 32));
ASSERT_EQ(card_binary, out);

card_binary = {0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x05, 0x85};
ASSERT_TRUE(RplethModule::card_convert_from_text(std::make_pair("80:81:61:40", 26), &out));
out = RplethModule::card_convert_from_text(std::make_pair("80:81:61:40", 26));
ASSERT_EQ(card_binary, out);

card_binary = {0x00, 0x00, 0x00, 0x00, 0x80, 0x81, 0x61, 0x40};
ASSERT_TRUE(RplethModule::card_convert_from_text(std::make_pair("80:81:61:40", 32), &out));
out = RplethModule::card_convert_from_text(std::make_pair("80:81:61:40", 32));
ASSERT_EQ(card_binary, out);
/*
ASSERT_FALSE(RplethModule::card_convert_from_text(std::make_pair("0x:adfw:23", 32), &out));
ASSERT_FALSE(RplethModule::card_convert_from_text(std::make_pair("fff:aa:bb:d", 32), &out));
ASSERT_FALSE(RplethModule::card_convert_from_text(std::make_pair("d:bb:aa:fff", 32), &out));
*/
}

/**
Expand Down Expand Up @@ -164,10 +159,10 @@ namespace Leosac
check_rpleth_card_msg(client, {0x00, 0x00, 0x00, 0x00, 0x11, 0x22, 0x33, 0x44});

bus_push_.send(zmqpp::message() << "S_WIEGAND1" << Leosac::Auth::SourceType::SIMPLE_WIEGAND << "80:81:61:40" << 26);
check_rpleth_card_msg(client, {0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x05, 0x85});
check_rpleth_card_msg(client, {0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x05, 0x85});

bus_push_.send(zmqpp::message() << "S_IGNORED_READER" << Leosac::Auth::SourceType::SIMPLE_WIEGAND << "11:22:33:44" << 32);
std::this_thread::sleep_for(std::chrono::milliseconds(15));
std::this_thread::sleep_for(std::chrono::milliseconds(500));
// nothing to read anymore
ASSERT_FALSE(client.receive(msg, true));
}
Expand Down

0 comments on commit 9b0024e

Please sign in to comment.