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

Do not use ifaddrs on Android as it is not natively supported #518

Merged
merged 1 commit into from
Dec 10, 2014
Merged
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
7 changes: 6 additions & 1 deletion clients/roscpp/src/libros/transport/transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@

#include "ros/transport/transport.h"
#include "ros/console.h"
#include <ifaddrs.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <netdb.h>

#if !defined(__ANDROID__)
#include <ifaddrs.h>
#endif

#ifndef NI_MAXHOST
#define NI_MAXHOST 1025
#endif
Expand Down Expand Up @@ -68,6 +71,7 @@ Transport::Transport()
gethostname(our_hostname, sizeof(our_hostname)-1);
allowed_hosts_.push_back(std::string(our_hostname));
allowed_hosts_.push_back("localhost");
#if !defined(__ANDROID__)
// for ipv4 loopback, we'll explicitly search for 127.* in isHostAllowed()
// now we need to iterate all local interfaces and add their addresses
// from the getifaddrs manpage: (maybe something similar for windows ?)
Expand Down Expand Up @@ -96,6 +100,7 @@ Transport::Transport()
}
allowed_hosts_.push_back(std::string(addr));
}
#endif
}

bool Transport::isHostAllowed(const std::string &host) const
Expand Down