You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@quickstep.apache.org by zuyu <gi...@git.apache.org> on 2016/11/17 20:25:59 UTC
[GitHub] incubator-quickstep pull request #138: Ethernet data exchanger.
GitHub user zuyu opened a pull request:
https://github.com/apache/incubator-quickstep/pull/138
Ethernet data exchanger.
Do not merge until #132 is in.
This PR allows the `DataExchanger` to use the actual ip address, instead of the local `0.0.0.0`.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/apache/incubator-quickstep ethernet-data-exchanger
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-quickstep/pull/138.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #138
----
commit 857445c1d791090bbcf99364d5c2649daf6d6205
Author: Zuyu Zhang <zu...@apache.org>
Date: 2016-11-13T23:13:09Z
Added an util method to get the ip address.
commit 297f1a877737c0a983df0598497918145b60c7e3
Author: Zuyu Zhang <zu...@apache.org>
Date: 2016-11-13T23:55:31Z
Used the network util in DataExchanger.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-quickstep pull request #138: Ethernet data exchanger.
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/incubator-quickstep/pull/138
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-quickstep pull request #138: Ethernet data exchanger.
Posted by cramja <gi...@git.apache.org>.
Github user cramja commented on a diff in the pull request:
https://github.com/apache/incubator-quickstep/pull/138#discussion_r88716447
--- Diff: utility/NetworkUtil.cpp ---
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ **/
+
+#include "utility/NetworkUtil.hpp"
+
+#include "utility/UtilityConfig.h" // For QUICKSTEP_HAVE_WINDOWS.
+
+#ifndef QUICKSTEP_HAVE_WINDOWS
+#include <arpa/inet.h>
+#include <net/if.h> // Need to include before <ifaddrs.h> for NetBSD.
+#include <netinet/in.h>
+#include <sys/socket.h>
+#include <ifaddrs.h>
+#include <netdb.h>
+
+#include <cstring>
+#endif // QUICKSTEP_HAVE_WINDOWS
+
+#include <string>
+
+#include "gflags/gflags.h"
+#include "glog/logging.h"
+
+namespace quickstep {
+
+DEFINE_bool(use_ethernet_ip, false,
+ "Use the Ethernet ip address, instead of the loopback.");
+
+std::string GetIpv4Address() {
+#ifndef QUICKSTEP_HAVE_WINDOWS
+ struct ifaddrs *ifaddrs;
+ CHECK_EQ(0, getifaddrs(&ifaddrs));
+
+ char ip_address[NI_MAXHOST] = { '\0' };
+
+ for (struct ifaddrs *ifa = ifaddrs; ifa; ifa = ifa->ifa_next) {
+ if (ifa->ifa_addr == nullptr ||
+ ifa->ifa_addr->sa_family != AF_INET ||
+ (ifa->ifa_flags & IFF_UP) == 0) {
+ continue;
+ }
+
+ if (FLAGS_use_ethernet_ip && !std::strncmp(ifa->ifa_name, "lo", 2)) {
+ // NOTE: On Linux it starts with 'eth', while on Mac OS X, 'en'.
+ continue;
+ }
+
+ struct sockaddr_in *s4 = (struct sockaddr_in *)(ifa->ifa_addr);
+ CHECK(inet_ntop(AF_INET, reinterpret_cast<void *>(&(s4->sin_addr)), ip_address, sizeof(ip_address)) != nullptr);
+ break;
+ }
+
+ freeifaddrs(ifaddrs);
+
+ return ip_address;
+#else // QUICKSTEP_HAVE_WINDOWS
+ CHECK(!FLAGS_use_ethernet_ip);
--- End diff --
So, no ethernet for windows?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---