Example #1
0
/**
 * iflist_update - fetch and update the interface list
 *
 * We store a list of interfaces, which we get from the 
 * operating system. It may change over time, this
 * updates that list. Normally this doesn't need to
 * be called.
 **/
const struct iflist *iflist_update(void)
{
    struct iflist *ifl = iflist_get();
    struct iflist *ift = iflist;

    /* we don't lock, but what are the chances..? */
    iflist = ifl;

    if (ift)
	iflist_free(ift);

    return iflist;
}
Example #2
0
VOID
OnUnload(IN PDRIVER_OBJECT DriverObject)
{
    UNICODE_STRING linkname;
    
    free_packet();

    RtlInitUnicodeString(&linkname, L"\\??\\ip_fw");
    IoDeleteSymbolicLink(&linkname);

    IoDeleteDevice(g_devcontrol);

    pfhook_free();
    module_ipfw->modevent(g_driver_object, MOD_UNLOAD, NULL);
    iflist_free();
    log_free();
}
Example #3
0
NTSTATUS
DriverEntry(
    IN PDRIVER_OBJECT theDriverObject,
    IN PUNICODE_STRING theRegistryPath)
{
    NTSTATUS status;
    UNICODE_STRING devname, linkname;
    BOOLEAN ip_fw_started = FALSE, pfhook_started = FALSE;
    int i;

    g_driver_object = theDriverObject;

    log_init();

    /* before starting ip_fw init ip_fw_nt wrappers */
    ip_fw_nt_init();
    rn_init();
    init_tables();
    iflist_init();
    init_packet();
    
    /* send load event to ip_fw */
    
    status = module_ipfw->modevent(theDriverObject, MOD_LOAD, NULL);
    if (status != STATUS_SUCCESS) {
        KdPrint(("[wipfw] DriverEntry: ip_fw MOD_LOAD: 0x%x!\n", status));
        goto done;
    }

    ip_fw_started = TRUE;

    /* setup pfhook */

    status = pfhook_init();
    if (status != STATUS_SUCCESS) {
        KdPrint(("[wipfw] DriverEntry: pfhook_init: 0x%x!\n", status));
        goto done;
    }

    pfhook_started = TRUE;

    /* create control device and symbolic link */

    RtlInitUnicodeString(&devname, L"\\Device\\ip_fw");

    status = IoCreateDeviceSecure(theDriverObject, 0, &devname, FILE_DEVICE_UNKNOWN, FILE_DEVICE_SECURE_OPEN, (BOOLEAN) FALSE, \
    	&SDDL_DEVOBJ_SYS_ALL_ADM_ALL, NULL, &g_devcontrol);
    if (status != STATUS_SUCCESS) {
        KdPrint(("[wipfw] DriverEntry: IoCreateDevice: 0x%x!\n", status));
        goto done;
    }
    
    g_devcontrol->Flags |= DO_POWER_PAGABLE;

    RtlInitUnicodeString(&linkname, L"\\??\\ip_fw");

    status = IoCreateSymbolicLink(&linkname, &devname);
    if (status != STATUS_SUCCESS) {
        KdPrint(("[wipfw] DriverEntry: IoCreateSymbolicLink: 0x%x!\n", status));
        goto done;
    }

    for (i = 0; i < IRP_MJ_MAXIMUM_FUNCTION; i++)
        theDriverObject->MajorFunction[i] = DeviceDispatch;
        
    theDriverObject->MajorFunction[IRP_MJ_PNP] = DeviceDispatch;

#ifdef KLD_MODULE
    theDriverObject->DriverUnload = OnUnload;
#endif

    status = STATUS_SUCCESS;

done:
    if (status != STATUS_SUCCESS) {
        if (g_devcontrol != NULL)
            IoDeleteDevice(g_devcontrol);
        if (pfhook_started)
            pfhook_free();
        if (ip_fw_started)
            module_ipfw->modevent(theDriverObject, MOD_UNLOAD, NULL);
        
        iflist_free();
        log_free();
    }

    return status;
}