usb_rndis: remove reattach code

The MAC address is randomly generated each time the device is connected.
So there is no way to match with a previous session and reattach the
interface transparently.

Change-Id: I8aea95d5a09621a0dcdd7ce89787663a38435001
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8576
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
This commit is contained in:
PulkoMandy 2024-11-17 11:02:59 +01:00 committed by waddlesplash
parent 87e00819ce
commit 9548274ed5
3 changed files with 0 additions and 67 deletions

View File

@ -26,18 +26,6 @@ usb_rndis_device_added(usb_device device, void **cookie)
// check if this is a replug of an existing device first
mutex_lock(&gDriverLock);
for (int32 i = 0; i < MAX_DEVICES; i++) {
if (gRNDISDevices[i] == NULL)
continue;
if (gRNDISDevices[i]->CompareAndReattach(device) != B_OK)
continue;
TRACE_ALWAYS("rndis device %" B_PRId32 " replugged\n", i);
*cookie = gRNDISDevices[i];
mutex_unlock(&gDriverLock);
return B_OK;
}
// no such device yet, create a new one
RNDISDevice *rndisDevice = new RNDISDevice(device);

View File

@ -482,59 +482,6 @@ RNDISDevice::Removed()
}
status_t
RNDISDevice::CompareAndReattach(usb_device device)
{
const usb_device_descriptor *deviceDescriptor
= gUSBModule->get_device_descriptor(device);
if (deviceDescriptor == NULL) {
TRACE_ALWAYS("failed to get device descriptor\n");
return B_ERROR;
}
if (deviceDescriptor->vendor_id != fVendorID
&& deviceDescriptor->product_id != fProductID) {
// this certainly isn't the same device
return B_BAD_VALUE;
}
// this might be the same device that was replugged - read the MAC address
// (which should be at the same index) to make sure
uint8 macBuffer[6];
if (_ReadMACAddress(device, macBuffer) != B_OK
|| memcmp(macBuffer, fMACAddress, sizeof(macBuffer)) != 0) {
// reading the MAC address failed or they are not the same
return B_BAD_VALUE;
}
// this is the same device that was replugged - clear the removed state,
// re-setup the endpoints and transfers and open the device if it was
// previously opened
fDevice = device;
fRemoved = false;
status_t result = _SetupDevice();
if (result != B_OK) {
fRemoved = true;
return result;
}
// in case notifications do not work we will have a hardcoded connection
// need to register that and notify the network stack ourselfs if this is
// the case as the open will not result in a corresponding notification
bool noNotifications = (fMediaConnectState == MEDIA_STATE_CONNECTED);
if (fOpen) {
fOpen = false;
result = Open();
if (result == B_OK && noNotifications && fLinkStateChangeSem >= B_OK)
release_sem_etc(fLinkStateChangeSem, 1, B_DO_NOT_RESCHEDULE);
}
return B_OK;
}
status_t
RNDISDevice::_SendCommand(const void* data, size_t length)
{

View File

@ -28,8 +28,6 @@ public:
void Removed();
bool IsRemoved() { return fRemoved; };
status_t CompareAndReattach(usb_device device);
private:
static void _ReadCallback(void *cookie, int32 status,
void *data, size_t actualLength);