Changeset View
Changeset View
Standalone View
Standalone View
Modules/nics/nic.cpp
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | |||||
51 | #ifdef USE_SOLARIS | 51 | #ifdef USE_SOLARIS | ||
52 | #undef map | 52 | #undef map | ||
53 | #endif | 53 | #endif | ||
54 | 54 | | |||
55 | #include <sys/ioctl.h> | 55 | #include <sys/ioctl.h> | ||
56 | #include <KPluginFactory> | 56 | #include <KPluginFactory> | ||
57 | #include <KPluginLoader> | 57 | #include <KPluginLoader> | ||
58 | 58 | | |||
59 | #ifndef HAVE_STRUCT_SOCKADDR_SA_LEN | | |||
60 | #undef HAVE_GETNAMEINFO | | |||
61 | #undef HAVE_GETIFADDRS | | |||
62 | #endif | | |||
63 | 59 | | |||
64 | #if defined(HAVE_GETNAMEINFO) && defined(HAVE_GETIFADDRS) | 60 | #if defined(HAVE_GETNAMEINFO) && defined(HAVE_GETIFADDRS) | ||
65 | #include <ifaddrs.h> | 61 | #include <ifaddrs.h> | ||
66 | #include <netdb.h> | 62 | #include <netdb.h> | ||
67 | 63 | | |||
68 | QString flags_tos (unsigned int flags); | 64 | QString flags_tos (unsigned int flags); | ||
69 | #endif | 65 | #endif | ||
70 | 66 | | |||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | 133 | if (num.length() < 2) | |||
138 | num.prepend(QStringLiteral("0")); | 134 | num.prepend(QStringLiteral("0")); | ||
139 | if (i>0) | 135 | if (i>0) | ||
140 | ret.append(QStringLiteral(":")); | 136 | ret.append(QStringLiteral(":")); | ||
141 | ret.append(num); | 137 | ret.append(num); | ||
142 | } | 138 | } | ||
143 | return ret; | 139 | return ret; | ||
144 | } | 140 | } | ||
145 | 141 | | |||
142 | // Convenience wrapper around sa_len being available or not. | ||||
143 | static int getNameInfo(struct sockaddr *addr, struct ifaddrs *ifa, char *hostOut) | ||||
144 | { | ||||
145 | #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN | ||||
146 | getnameinfo(addr, ifa->ifa_addr->sa_len, buf, 127, 0, 0, NI_NUMERICHOST); | ||||
jjazeix: buf is not defined in this conditional and causes a build fail on freebsd: https://build.kde. | |||||
sitter: thanks. should be fixed
| |||||
147 | #else | ||||
148 | getnameinfo(addr, | ||||
149 | (ifa->ifa_addr->sa_family == AF_INET) ? sizeof(struct sockaddr_in) : | ||||
150 | sizeof(struct sockaddr_in6), | ||||
151 | hostOut, NI_MAXHOST, | ||||
152 | nullptr, 0, | ||||
153 | NI_NUMERICHOST); | ||||
154 | #endif | ||||
155 | } | ||||
156 | | ||||
146 | QList<MyNIC*> findNICs() { | 157 | QList<MyNIC*> findNICs() { | ||
147 | QString upMessage(i18nc("State of network card is connected", "Up") ); | 158 | QString upMessage(i18nc("State of network card is connected", "Up") ); | ||
148 | QString downMessage(i18nc("State of network card is disconnected", "Down") ); | 159 | QString downMessage(i18nc("State of network card is disconnected", "Down") ); | ||
149 | 160 | | |||
150 | QList<MyNIC*> nl; | 161 | QList<MyNIC*> nl; | ||
151 | 162 | | |||
152 | #if !defined(HAVE_GETIFADDRS) || !defined(HAVE_GETNAMEINFO) | 163 | #if !defined(HAVE_GETIFADDRS) || !defined(HAVE_GETNAMEINFO) | ||
153 | 164 | | |||
▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Line(s) | 258 | for (ifa = ifap; ifa; ifa = ifa->ifa_next) { | |||
249 | case AF_INET6: | 260 | case AF_INET6: | ||
250 | case AF_INET: { | 261 | case AF_INET: { | ||
251 | tmp = new MyNIC; | 262 | tmp = new MyNIC; | ||
252 | tmp->name = ifa->ifa_name; | 263 | tmp->name = ifa->ifa_name; | ||
253 | 264 | | |||
254 | char buf[128]; | 265 | char buf[128]; | ||
255 | 266 | | |||
256 | bzero(buf, 128); | 267 | bzero(buf, 128); | ||
257 | getnameinfo(ifa->ifa_addr, ifa->ifa_addr->sa_len, buf, 127, 0, 0, NI_NUMERICHOST); | 268 | getNameInfo(ifa->ifa_addr, ifa, buf); | ||
258 | tmp->addr = buf; | 269 | tmp->addr = buf; | ||
259 | 270 | | |||
260 | if (ifa->ifa_netmask != nullptr) { | 271 | if (ifa->ifa_netmask != nullptr) { | ||
261 | bzero(buf, 128); | 272 | bzero(buf, 128); | ||
262 | getnameinfo(ifa->ifa_netmask, ifa->ifa_netmask->sa_len, buf, 127, 0, 0, NI_NUMERICHOST); | 273 | getNameInfo(ifa->ifa_netmask, ifa, buf); | ||
263 | tmp->netmask = buf; | 274 | tmp->netmask = buf; | ||
264 | } | 275 | } | ||
265 | 276 | | |||
266 | tmp->state= (ifa->ifa_flags & IFF_UP) ? upMessage : downMessage; | 277 | tmp->state= (ifa->ifa_flags & IFF_UP) ? upMessage : downMessage; | ||
267 | tmp->type = flags_tos(ifa->ifa_flags); | 278 | tmp->type = flags_tos(ifa->ifa_flags); | ||
268 | 279 | | |||
269 | nl.append(tmp); | 280 | nl.append(tmp); | ||
270 | break; | 281 | break; | ||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |
buf is not defined in this conditional and causes a build fail on freebsd: https://build.kde.org/view/Failing/job/Plasma/job/kinfocenter/job/kf5-qt5%20FreeBSDQt5.13/lastFailedBuild/