datapath-windows/ovsext/Driver.c
/*
 * --------------------------------------------------------------------------
 * Init/Load function for the OVSEXT filter Driver.
 * --------------------------------------------------------------------------
 */
Init/Load function for the OVSEXT filter Driver.
Init / Load function for the OVSEXT filter Driver .
NTSTATUS
DriverEntry(PDRIVER_OBJECT driverObject,
            PUNICODE_STRING registryPath)
{
    NDIS_STATUS status;
    NDIS_FILTER_DRIVER_CHARACTERISTICS driverChars;
    UNREFERENCED_PARAMETER(registryPath);
    status = OvsInit();
    if (status != NDIS_STATUS_SUCCESS) {
        goto cleanup;
    }
    gOvsExtDriverObject = driverObject;
    RtlZeroMemory(&driverChars, sizeof driverChars);
    driverChars.Header.Type = NDIS_OBJECT_TYPE_FILTER_DRIVER_CHARACTERISTICS;
    driverChars.Header.Size = sizeof driverChars;
    driverChars.Header.Revision = NDIS_FILTER_CHARACTERISTICS_REVISION_2;
    driverChars.MajorNdisVersion = NDIS_FILTER_MAJOR_VERSION;
    driverChars.MinorNdisVersion = NDIS_FILTER_MINOR_VERSION;
    driverChars.MajorDriverVersion = 1;
    driverChars.MinorDriverVersion = 0;
    driverChars.Flags = 0;
    RtlInitUnicodeString(&driverChars.ServiceName, ovsExtServiceName);
    RtlInitUnicodeString(&ovsExtFriendlyNameUC, ovsExtFriendlyName);
    RtlInitUnicodeString(&ovsExtGuidUC, ovsExtGuidStr);
    driverChars.FriendlyName = ovsExtFriendlyNameUC;
    driverChars.UniqueName = ovsExtGuidUC;
    driverChars.AttachHandler = OvsExtAttach;
    driverChars.DetachHandler = OvsExtDetach;
    driverChars.RestartHandler = OvsExtRestart;
    driverChars.PauseHandler = OvsExtPause;
    driverChars.SendNetBufferListsHandler = OvsExtSendNBL;
    driverChars.SendNetBufferListsCompleteHandler = OvsExtSendNBLComplete;
    driverChars.CancelSendNetBufferListsHandler = OvsExtCancelSendNBL;
    driverChars.ReceiveNetBufferListsHandler = NULL;
    driverChars.ReturnNetBufferListsHandler = NULL;
    driverChars.OidRequestHandler = OvsExtOidRequest;
    driverChars.OidRequestCompleteHandler = OvsExtOidRequestComplete;
    driverChars.CancelOidRequestHandler = OvsExtCancelOidRequest;
    driverChars.DevicePnPEventNotifyHandler = NULL;
    driverChars.NetPnPEventHandler = OvsExtNetPnPEvent;
    driverChars.StatusHandler = NULL;
    driverObject->DriverUnload = OvsExtUnload;
    gOvsExtDriverHandle = NULL;
    status = NdisFRegisterFilterDriver(driverObject,
                                       (NDIS_HANDLE)gOvsExtDriverObject,
                                       &driverChars,
                                       &gOvsExtDriverHandle);
    if (status != NDIS_STATUS_SUCCESS) {
        goto cleanup;
    }
    status = OvsCreateDeviceObject(gOvsExtDriverHandle);
    if (status != NDIS_STATUS_SUCCESS) {
        NdisFDeregisterFilterDriver(gOvsExtDriverHandle);
        gOvsExtDriverHandle = NULL;
        goto cleanup;
    }
cleanup:
    if (status != NDIS_STATUS_SUCCESS){
        OvsCleanup();
    }
    return status;
}
NTSTATUS DriverEntry ( PDRIVER_OBJECT driverObject , PUNICODE_STRING registryPath ) { NDIS_STATUS status ; NDIS_FILTER_DRIVER_CHARACTERISTICS driverChars ; UNREFERENCED_PARAMETER ( registryPath ) ; status = OvsInit ( ) ; if ( status != NDIS_STATUS_SUCCESS ) { goto cleanup ; } gOvsExtDriverObject = driverObject ; RtlZeroMemory ( & driverChars , sizeof driverChars ) ; driverChars . Header . Type = NDIS_OBJECT_TYPE_FILTER_DRIVER_CHARACTERISTICS ; driverChars . Header . Size = sizeof driverChars ; driverChars . Header . Revision = NDIS_FILTER_CHARACTERISTICS_REVISION_2 ; driverChars . MajorNdisVersion = NDIS_FILTER_MAJOR_VERSION ; driverChars . MinorNdisVersion = NDIS_FILTER_MINOR_VERSION ; driverChars . MajorDriverVersion = 1 ; driverChars . MinorDriverVersion = 0 ; driverChars . Flags = 0 ; RtlInitUnicodeString ( & driverChars . ServiceName , ovsExtServiceName ) ; RtlInitUnicodeString ( & ovsExtFriendlyNameUC , ovsExtFriendlyName ) ; RtlInitUnicodeString ( & ovsExtGuidUC , ovsExtGuidStr ) ; driverChars . FriendlyName = ovsExtFriendlyNameUC ; driverChars . UniqueName = ovsExtGuidUC ; driverChars . AttachHandler = OvsExtAttach ; driverChars . DetachHandler = OvsExtDetach ; driverChars . RestartHandler = OvsExtRestart ; driverChars . PauseHandler = OvsExtPause ; driverChars . SendNetBufferListsHandler = OvsExtSendNBL ; driverChars . SendNetBufferListsCompleteHandler = OvsExtSendNBLComplete ; driverChars . CancelSendNetBufferListsHandler = OvsExtCancelSendNBL ; driverChars . ReceiveNetBufferListsHandler = NULL ; driverChars . ReturnNetBufferListsHandler = NULL ; driverChars . OidRequestHandler = OvsExtOidRequest ; driverChars . OidRequestCompleteHandler = OvsExtOidRequestComplete ; driverChars . CancelOidRequestHandler = OvsExtCancelOidRequest ; driverChars . DevicePnPEventNotifyHandler = NULL ; driverChars . NetPnPEventHandler = OvsExtNetPnPEvent ; driverChars . StatusHandler = NULL ; driverObject -> DriverUnload = OvsExtUnload ; gOvsExtDriverHandle = NULL ; status = NdisFRegisterFilterDriver ( driverObject , ( NDIS_HANDLE ) gOvsExtDriverObject , & driverChars , & gOvsExtDriverHandle ) ; if ( status != NDIS_STATUS_SUCCESS ) { goto cleanup ; } status = OvsCreateDeviceObject ( gOvsExtDriverHandle ) ; if ( status != NDIS_STATUS_SUCCESS ) { NdisFDeregisterFilterDriver ( gOvsExtDriverHandle ) ; gOvsExtDriverHandle = NULL ; goto cleanup ; } cleanup : if ( status != NDIS_STATUS_SUCCESS ) { OvsCleanup ( ) ; } return status ; }
Init/Load function for the OVSEXT filter Driver.
Init / Load function for the OVSEXT filter Driver .
/* Initialize driver associated data structures. */ /* Create the communication channel for userspace. */