117 |
117 |
118 qDebug() << "===== END NLA_BLOB ====="; |
118 qDebug() << "===== END NLA_BLOB ====="; |
119 } |
119 } |
120 #endif |
120 #endif |
121 |
121 |
122 static QString qGetInterfaceType(const QString &interface) |
122 static QNetworkConfiguration::BearerType qGetInterfaceType(const QString &interface) |
123 { |
123 { |
124 #ifdef Q_OS_WINCE |
124 #ifdef Q_OS_WINCE |
125 Q_UNUSED(interface) |
125 Q_UNUSED(interface) |
126 #else |
126 #else |
127 unsigned long oid; |
127 unsigned long oid; |
128 DWORD bytesWritten; |
128 DWORD bytesWritten; |
129 |
129 |
130 NDIS_MEDIUM medium; |
130 NDIS_MEDIUM medium; |
131 NDIS_PHYSICAL_MEDIUM physicalMedium; |
131 NDIS_PHYSICAL_MEDIUM physicalMedium; |
132 |
132 |
133 HANDLE handle = CreateFile((TCHAR *)QString(QLatin1String("\\\\.\\%1")).arg(interface).utf16(), |
133 HANDLE handle = CreateFile((TCHAR *)QString::fromLatin1("\\\\.\\%1").arg(interface).utf16(), 0, |
134 0, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); |
134 FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); |
135 if (handle == INVALID_HANDLE_VALUE) |
135 if (handle == INVALID_HANDLE_VALUE) |
136 return QLatin1String("Unknown"); |
136 return QNetworkConfiguration::BearerUnknown; |
137 |
137 |
138 oid = OID_GEN_MEDIA_SUPPORTED; |
138 oid = OID_GEN_MEDIA_SUPPORTED; |
139 bytesWritten = 0; |
139 bytesWritten = 0; |
140 bool result = DeviceIoControl(handle, IOCTL_NDIS_QUERY_GLOBAL_STATS, &oid, sizeof(oid), |
140 bool result = DeviceIoControl(handle, IOCTL_NDIS_QUERY_GLOBAL_STATS, &oid, sizeof(oid), |
141 &medium, sizeof(medium), &bytesWritten, 0); |
141 &medium, sizeof(medium), &bytesWritten, 0); |
142 if (!result) { |
142 if (!result) { |
143 CloseHandle(handle); |
143 CloseHandle(handle); |
144 return QLatin1String("Unknown"); |
144 return QNetworkConfiguration::BearerUnknown; |
145 } |
145 } |
146 |
146 |
147 oid = OID_GEN_PHYSICAL_MEDIUM; |
147 oid = OID_GEN_PHYSICAL_MEDIUM; |
148 bytesWritten = 0; |
148 bytesWritten = 0; |
149 result = DeviceIoControl(handle, IOCTL_NDIS_QUERY_GLOBAL_STATS, &oid, sizeof(oid), |
149 result = DeviceIoControl(handle, IOCTL_NDIS_QUERY_GLOBAL_STATS, &oid, sizeof(oid), |
150 &physicalMedium, sizeof(physicalMedium), &bytesWritten, 0); |
150 &physicalMedium, sizeof(physicalMedium), &bytesWritten, 0); |
151 if (!result) { |
151 if (!result) { |
152 CloseHandle(handle); |
152 CloseHandle(handle); |
153 |
153 |
154 if (medium == NdisMedium802_3) |
154 if (medium == NdisMedium802_3) |
155 return QLatin1String("Ethernet"); |
155 return QNetworkConfiguration::BearerEthernet; |
156 else |
156 else |
157 return QLatin1String("Unknown"); |
157 return QNetworkConfiguration::BearerUnknown; |
158 } |
158 } |
159 |
159 |
160 CloseHandle(handle); |
160 CloseHandle(handle); |
161 |
161 |
162 if (medium == NdisMedium802_3) { |
162 if (medium == NdisMedium802_3) { |
163 switch (physicalMedium) { |
163 switch (physicalMedium) { |
164 case NdisPhysicalMediumWirelessLan: |
164 case NdisPhysicalMediumWirelessLan: |
165 return QLatin1String("WLAN"); |
165 return QNetworkConfiguration::BearerWLAN; |
166 case NdisPhysicalMediumBluetooth: |
166 case NdisPhysicalMediumBluetooth: |
167 return QLatin1String("Bluetooth"); |
167 return QNetworkConfiguration::BearerBluetooth; |
168 case NdisPhysicalMediumWiMax: |
168 case NdisPhysicalMediumWiMax: |
169 return QLatin1String("WiMAX"); |
169 return QNetworkConfiguration::BearerWiMAX; |
170 default: |
170 default: |
171 #ifdef BEARER_MANAGEMENT_DEBUG |
171 #ifdef BEARER_MANAGEMENT_DEBUG |
172 qDebug() << "Physical Medium" << physicalMedium; |
172 qDebug() << "Physical Medium" << physicalMedium; |
173 #endif |
173 #endif |
174 return QLatin1String("Ethernet"); |
174 return QNetworkConfiguration::BearerEthernet; |
175 } |
175 } |
176 } |
176 } |
177 |
177 |
178 #ifdef BEARER_MANAGEMENT_DEBUG |
178 #ifdef BEARER_MANAGEMENT_DEBUG |
179 qDebug() << medium << physicalMedium; |
179 qDebug() << medium << physicalMedium; |
180 #endif |
180 #endif |
181 |
181 |
182 #endif |
182 #endif |
183 |
183 |
184 return QLatin1String("Unknown"); |
184 return QNetworkConfiguration::BearerUnknown; |
185 } |
185 } |
186 |
186 |
187 class QNlaThread : public QThread |
187 class QNlaThread : public QThread |
188 { |
188 { |
189 Q_OBJECT |
189 Q_OBJECT |
372 #ifdef BEARER_MANAGEMENT_DEBUG |
372 #ifdef BEARER_MANAGEMENT_DEBUG |
373 qDebug("%s: unhandled header type NLA_802_1X_LOCATION", __FUNCTION__); |
373 qDebug("%s: unhandled header type NLA_802_1X_LOCATION", __FUNCTION__); |
374 #endif |
374 #endif |
375 break; |
375 break; |
376 case NLA_CONNECTIVITY: |
376 case NLA_CONNECTIVITY: |
377 if (blob->data.connectivity.internet == NLA_INTERNET_YES) |
377 #ifdef BEARER_MANAGEMENT_DEBUG |
378 cpPriv->internet = true; |
378 qDebug("%s: unhandled header type NLA_CONNECTIVITY", __FUNCTION__); |
379 else |
379 #endif |
380 cpPriv->internet = false; |
|
381 break; |
380 break; |
382 case NLA_ICS: |
381 case NLA_ICS: |
383 #ifdef BEARER_MANAGEMENT_DEBUG |
382 #ifdef BEARER_MANAGEMENT_DEBUG |
384 qDebug("%s: unhandled header type NLA_ICS", __FUNCTION__); |
383 qDebug("%s: unhandled header type NLA_ICS", __FUNCTION__); |
385 #endif |
384 #endif |