Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No peer checking #25

Merged
merged 1 commit into from
Apr 29, 2020
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: 13 additions & 6 deletions cannelloni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include "make_unique.h"
#include <memory>

#define CANNELLONI_VERSION "1.0.0"
#define CANNELLONI_VERSION "1.0.1"

using namespace cannelloni;

Expand All @@ -66,6 +66,7 @@ void printUsage() {
std::cout << "\t -t timeout \t\t buffer timeout for can messages (us), default: 100000" << std::endl;
std::cout << "\t -T table.csv \t\t path to csv with individual timeouts" << std::endl;
std::cout << "\t -s \t\t enable frame sorting" << std::endl;
std::cout << "\t -p \t\t no peer checking" << std::endl;
std::cout << "\t -d [cubt]\t\t enable debug, can be any of these: " << std::endl;
std::cout << "\t\t\t c : enable debugging of can frames" << std::endl;
#ifdef SCTP_SUPPORT
Expand All @@ -84,6 +85,7 @@ int main(int argc, char** argv) {
int opt;
bool remoteIPSupplied = false;
bool sortUDP = false;
bool checkPeer = true;
bool useSCTP = false;
#ifdef SCTP_SUPPORT
SCTPThreadRole sctpRole = CLIENT;
Expand All @@ -101,9 +103,9 @@ int main(int argc, char** argv) {
struct debugOptions_t debugOptions = { /* can */ 0, /* udp */ 0, /* buffer */ 0, /* timer */ 0 };

#ifdef SCTP_SUPPORT
const std::string argument_options = "S:l:L:r:R:I:t:T:d:hs";
const std::string argument_options = "S:l:L:r:R:I:t:T:d:hsp";
#else
const std::string argument_options = "Sl:L:r:R:I:t:T:d:hs";
const std::string argument_options = "Sl:L:r:R:I:t:T:d:hsp";
#endif

while ((opt = getopt(argc, argv, argument_options.c_str())) != -1) {
Expand Down Expand Up @@ -140,13 +142,15 @@ int main(int argc, char** argv) {
localPort = strtoul(optarg, NULL, 10);
break;
case 'L':
strncpy(localIP, optarg, INET_ADDRSTRLEN);
strncpy(localIP, optarg, INET_ADDRSTRLEN-1);
localIP[INET_ADDRSTRLEN-1] = '\0';
mguentner marked this conversation as resolved.
Show resolved Hide resolved
break;
case 'r':
remotePort = strtoul(optarg, NULL, 10);
break;
case 'R':
strncpy(remoteIP, optarg, INET_ADDRSTRLEN);
strncpy(remoteIP, optarg, INET_ADDRSTRLEN-1);
remoteIP[INET_ADDRSTRLEN-1] = '\0';
remoteIPSupplied = true;
break;
case 'I':
Expand Down Expand Up @@ -174,6 +178,9 @@ int main(int argc, char** argv) {
case 's':
sortUDP = true;
break;
case 'p':
checkPeer = false;
break;
default:
printUsage();
return -1;
Expand Down Expand Up @@ -279,7 +286,7 @@ int main(int argc, char** argv) {
netThread = std::make_unique<SCTPThread>(debugOptions, remoteAddr, localAddr, sortUDP, remoteIPSupplied, sctpRole);
#endif
} else {
netThread = std::make_unique<UDPThread>(debugOptions, remoteAddr, localAddr, sortUDP, true);
netThread = std::make_unique<UDPThread>(debugOptions, remoteAddr, localAddr, sortUDP, checkPeer);
}
auto canThread = std::make_unique<CANThread>(debugOptions, canInterface);
auto netFrameBuffer = std::make_unique<FrameBuffer>(1000,16000);
Expand Down
2 changes: 1 addition & 1 deletion udpthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ bool UDPThread::parsePacket(uint8_t *buffer, uint16_t len, struct sockaddr_in &c
} else {
if ((memcmp(&(clientAddr.sin_addr), &(m_remoteAddr.sin_addr), sizeof(struct in_addr)) != 0) && m_checkPeer) {
lwarn << "Received a packet from " << clientAddrStr
<< ", which is not set as a remote." << std::endl;
<< ", which is not set as a remote. Restart with -p argument to override." << std::endl;
} else {

if (m_debugOptions.udp) {
Expand Down