📄 ndis_dispatch.c
字号:
NTFY_BEGIN_CRITICAL; /* Check for NDIS_EVENT_QUEUED and redo loop */ if (ndis_flags & NDIS_EVENT_QUEUED) goto Retry_Client;Done: NTFY_END_CRITICAL; return(NOTIFY_OK);Error: NTFY_END_CRITICAL; return(notify_errno);}staticNotify_errornotify_fd(nclient, fd, type) Notify_client nclient; int fd; NTFY_TYPE type;{ Notify_func func; /* Check arguments and get function to call */ if (ndet_check_fd(fd) || ndis_send_func(nclient, type, (NTFY_DATA)fd, NTFY_USE_DATA, &func, NTFY_DATA_PTR_NULL, NDIS_RELEASE_NULL) != NOTIFY_OK) return(notify_errno); (void) func(nclient, fd); /* Pop condition off interposition stack */ nint_pop_callout(); return(NOTIFY_OK);}extern Notify_errornotify_input(nclient, fd) Notify_client nclient; int fd;{ return(notify_fd(nclient, fd, NTFY_INPUT));}extern Notify_errornotify_output(nclient, fd) Notify_client nclient; int fd;{ return(notify_fd(nclient, fd, NTFY_OUTPUT));}extern Notify_errornotify_exception(nclient, fd) Notify_client nclient; int fd;{ return(notify_fd(nclient, fd, NTFY_EXCEPTION));}extern Notify_errornotify_itimer(nclient, which) Notify_client nclient; int which;{ NTFY_TYPE type; Notify_func func; /* Check arguments and get function to call */ if (ndet_check_which(which, &type) || ndis_send_func(nclient, type, NTFY_DATA_NULL, NTFY_IGNORE_DATA, &func, NTFY_DATA_PTR_NULL, NDIS_RELEASE_NULL) != NOTIFY_OK) return(notify_errno); (void) func(nclient, which); /* Pop condition off interposition stack */ nint_pop_callout(); return(NOTIFY_OK);}extern Notify_errornotify_event(nclient, event, arg) Notify_client nclient; Notify_event event; Notify_arg arg;{ Notify_func func; Notify_release release_func; /* Get function to call */ if (ndis_send_func(nclient, NTFY_SAFE_EVENT, (NTFY_DATA)event, NTFY_USE_DATA, &func, NTFY_DATA_PTR_NULL, &release_func) != NOTIFY_OK) return(notify_errno); (void) ndet_set_event_processing(nclient, 1); (void) func(nclient, event, arg, NOTIFY_SAFE); (void) ndet_set_event_processing(nclient, 0); /* Pop condition off interposition stack */ nint_pop_callout(); /* Release arg and event */ if (release_func != NOTIFY_RELEASE_NULL) (void) release_func(nclient, arg, event); return(NOTIFY_OK);}extern Notify_errornotify_signal(nclient, sig) Notify_client nclient; int sig;{ Notify_func func; /* Check arguments and get function to call */ if (ndet_check_sig(sig) || ndis_send_func(nclient, NTFY_SYNC_SIGNAL, (NTFY_DATA)sig, NTFY_USE_DATA, &func, NTFY_DATA_PTR_NULL, NDIS_RELEASE_NULL) != NOTIFY_OK) return(notify_errno); (void) func(nclient, sig, NOTIFY_SYNC); /* Pop condition off interposition stack */ nint_pop_callout(); return(NOTIFY_OK);}extern Notify_errornotify_destroy(nclient, status) Notify_client nclient; Destroy_status status;{ Notify_func func; /* Check arguments and get function to call */ if (ndet_check_status(status) || ndis_send_func(nclient, NTFY_DESTROY, NTFY_DATA_NULL, NTFY_IGNORE_DATA, &func, NTFY_DATA_PTR_NULL, NDIS_RELEASE_NULL) != NOTIFY_OK) return(notify_errno); ndet_flags &= ~NDET_VETOED; /* Note: Unprotected */ (void) func(nclient, status); /* Pop condition off interposition stack */ nint_pop_callout(); if (status == DESTROY_CHECKING) { if (ndet_flags & NDET_VETOED) return(NOTIFY_DESTROY_VETOED); } else { NTFY_BEGIN_CRITICAL; /* remove client (if client hasn't done so himself) */ if (ntfy_find_nclient(ndet_clients, nclient, &ndet_client_latest) != NTFY_CLIENT_NULL) { NTFY_END_CRITICAL; return(notify_remove(nclient)); } NTFY_END_CRITICAL; } return(NOTIFY_OK);}extern Notify_errornotify_wait3(nclient) Notify_client nclient;{ Notify_func func; NTFY_WAIT3_DATA *wd; NTFY_CLIENT *client; /* Loop until no more wait conditions to notify */ for (;;) { /* * See if WAIT3 condition is pending. This WAIT3 * notify proc differs from the others in this module * because a client might have multiple wait3 events * pending but the prioritizer only can tell if there * is any waiting at all. Thus we must search out ALL * the WAIT3 conditions. * Protect as critical section because list searches * check to make sure that in critical. */ NTFY_BEGIN_CRITICAL; if ((client = ntfy_find_nclient(ndis_clients, nclient, &ndis_client_latest)) == NTFY_CLIENT_NULL || ntfy_find_condition(client->conditions, NTFY_WAIT3, &(client->condition_latest), NTFY_DATA_NULL, NTFY_IGNORE_DATA) == NTFY_CONDITION_NULL) { NTFY_END_CRITICAL; break; } NTFY_END_CRITICAL; /* Get function to call */ if (ndis_send_func(nclient, NTFY_WAIT3, NTFY_DATA_NULL, NTFY_IGNORE_DATA, &func, (NTFY_DATA *)&wd, NDIS_RELEASE_NULL) != NOTIFY_OK) return(notify_errno); (void) func(nclient, wd->pid, &wd->status, &wd->rusage); /* Free wait record */ NTFY_BEGIN_CRITICAL; /* Pop condition off interposition stack */ nint_unprotected_pop_callout(); ntfy_free_malloc((NTFY_DATA)wd); NTFY_END_CRITICAL; } return(NOTIFY_OK);}static Notify_errorndis_send_func(nclient, type, data, use_data, func_ptr, data_ptr, release_func_ptr) Notify_client nclient; NTFY_TYPE type; NTFY_DATA data; int use_data; Notify_func *func_ptr; NTFY_DATA *data_ptr; Notify_release *release_func_ptr;{ register NTFY_CLIENT *client; register NTFY_CONDITION *condition; NTFY_BEGIN_CRITICAL; /* Find client */ if ((client = ntfy_find_nclient(ndis_clients, nclient, &ndis_client_latest)) == NTFY_CLIENT_NULL) { ntfy_set_warning(NOTIFY_UNKNOWN_CLIENT); goto Error; } /* Find condition */ if ((condition = ntfy_find_condition(client->conditions, type, &(client->condition_latest), data, use_data)) == NTFY_CONDITION_NULL) { ntfy_set_warning(NOTIFY_NO_CONDITION); goto Error; } /* Remember function */ *func_ptr = nint_push_callout(client, condition); /* Snatch condition data and null it */ if (data_ptr) { *data_ptr = (NTFY_DATA)condition->data.an_u_int; condition->data.an_u_int = 0; } /* Remember release function so can use later and null it */ if (release_func_ptr) { *release_func_ptr = condition->release; condition->release = NOTIFY_RELEASE_NULL; } /* Remove condition */ ntfy_unset_condition(&ndis_clients, client, condition, &ndis_client_latest, NTFY_NDIS); NTFY_END_CRITICAL; return(NOTIFY_OK);Error: NTFY_END_CRITICAL; return(notify_errno);}pkg_private voidndis_flush_condition(nclient, type, data, use_data) Notify_client nclient; NTFY_TYPE type; NTFY_DATA data; int use_data;{ register NTFY_CLIENT *client; register NTFY_CONDITION *condition; NTFY_BEGIN_CRITICAL; for (;;) { /* Find client */ if ((client = ntfy_find_nclient(ndis_clients, nclient, &ndis_client_latest)) == NTFY_CLIENT_NULL) break; /* Find condition */ if ((condition = ntfy_find_condition(client->conditions, type, &(client->condition_latest), data, use_data)) == NTFY_CONDITION_NULL) break; /* Remove condition */ ntfy_unset_condition(&ndis_clients, client, condition, &ndis_client_latest, NTFY_NDIS); } NTFY_END_CRITICAL;}pkg_private voidndis_flush_wait3(nclient, pid) Notify_client nclient; int pid;{ register NTFY_CLIENT *client; register NTFY_CONDITION *condition; register NTFY_CONDITION *next; NTFY_BEGIN_CRITICAL; /* Find client */ if ((client = ntfy_find_nclient(ndis_clients, nclient, &ndis_client_latest)) == NTFY_CLIENT_NULL) goto Done; /* Find condition */ for (condition = client->conditions; condition; condition = next) { next = condition->next; if (condition->type == NTFY_WAIT3 && condition->data.wait3->pid == pid) { /* Remove condition */ ntfy_unset_condition(&ndis_clients, client, condition, &ndis_client_latest, NTFY_NDIS); break; } }Done: NTFY_END_CRITICAL;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -