Lines Matching defs:state
91 errno_t (*nstat_watcher_add)(nstat_control_state *state);
92 void (*nstat_watcher_remove)(nstat_control_state *state);
108 static int nstat_control_send_description(nstat_control_state *state, nstat_src *src, u_int64_t context);
110 static void nstat_control_cleanup_source(nstat_control_state *state, nstat_src *src,
184 static errno_t nstat_control_source_add(u_int64_t context, nstat_control_state *state, nstat_provider *provider, nstat_provider_cookie_t cookie);
397 nstat_control_state *state = (nstat_control_state*)context;
418 result = nstat_control_source_add(0, state, &nstat_route_provider, rt);
428 nstat_control_state *state)
441 result = rnh->rnh_walktree(rnh, nstat_route_walktree_add, state);
462 nstat_control_state *state;
463 for (state = nstat_controls; state; state = state->ncs_next)
465 if ((state->ncs_watching & (1 << NSTAT_PROVIDER_ROUTE)) != 0)
472 if (nstat_control_source_add(0, state, &nstat_route_provider, rt) != 0)
482 __unused nstat_control_state *state)
842 // if the pcb is in the dead state, we should stop using it
877 nstat_control_state *state)
890 if (nstat_control_source_add(0, state, &nstat_tcp_provider, inp) != 0)
904 __unused nstat_control_state *state)
917 nstat_control_state *state;
918 for (state = nstat_controls; state; state = state->ncs_next)
920 if ((state->ncs_watching & (1 << NSTAT_PROVIDER_TCP)) != 0)
928 if (nstat_control_source_add(0, state, &nstat_tcp_provider, inp) != 0)
941 nstat_control_state *state;
949 for (state = nstat_controls; state; state = state->ncs_next) {
950 lck_mtx_lock(&state->mtx);
951 for (prevsrc = NULL, src = state->ncs_srcs; src;
958 nstat_control_send_counts(state, src, 0, NULL);
961 nstat_control_send_description(state, src, 0);
964 nstat_control_send_removed(state, src);
969 state->ncs_srcs = src->next;
974 lck_mtx_unlock(&state->mtx);
1021 desc->state = intotcpcb(inp)->t_state;
1099 // if the pcb is in the dead state, we should stop using it
1124 nstat_control_state *state)
1137 if (nstat_control_source_add(0, state, &nstat_udp_provider, inp) != 0)
1151 __unused nstat_control_state *state)
1164 nstat_control_state *state;
1165 for (state = nstat_controls; state; state = state->ncs_next)
1167 if ((state->ncs_watching & (1 << NSTAT_PROVIDER_UDP)) != 0)
1175 if (nstat_control_source_add(0, state, &nstat_udp_provider, inp) != 0)
1363 nstat_control_state *state,
1367 if (state)
1368 nstat_control_send_removed(state, src);
1381 nstat_control_state *state = OSMalloc(sizeof(*state), nstat_malloc_tag);
1382 if (state == NULL) return ENOMEM;
1384 bzero(state, sizeof(*state));
1385 lck_mtx_init(&state->mtx, nstat_lck_grp, NULL);
1386 state->ncs_kctl = kctl;
1387 state->ncs_unit = sac->sc_unit;
1388 state->ncs_flags = NSTAT_FLAG_REQCOUNTS;
1389 *uinfo = state;
1392 state->ncs_next = nstat_controls;
1393 nstat_controls = state;
1413 nstat_control_state *state = (nstat_control_state*)uinfo;
1420 if (*statepp == state)
1422 *statepp = state->ncs_next;
1428 lck_mtx_lock(&state->mtx);
1431 watching = state->ncs_watching;
1432 state->ncs_watching = 0;
1438 provider->nstat_watcher_remove(state);
1443 state->ncs_flags |= NSTAT_FLAG_CLEANUP;
1446 nstat_src *srcs = state->ncs_srcs;
1447 state->ncs_srcs = NULL;
1448 lck_mtx_unlock(&state->mtx);
1462 OSFree(state, sizeof(*state), nstat_malloc_tag);
1469 nstat_control_state *state)
1476 if (state->ncs_next_srcref == NSTAT_SRC_REF_INVALID ||
1477 state->ncs_next_srcref == NSTAT_SRC_REF_ALL)
1479 state->ncs_next_srcref = 1;
1483 for (src = state->ncs_srcs; src; src = src->next)
1485 if (src->srcref == state->ncs_next_srcref)
1489 if (src == NULL) toReturn = state->ncs_next_srcref;
1490 state->ncs_next_srcref++;
1498 nstat_control_state *state,
1513 result = ctl_enqueuedata(state->ncs_kctl, state->ncs_unit, &counts,
1523 nstat_control_state *state,
1561 result = ctl_enqueuembuf(state->ncs_kctl, state->ncs_unit, msg, CTL_DATA_EOR);
1572 nstat_control_state *state,
1581 result = ctl_enqueuedata(state->ncs_kctl, state->ncs_unit, &removed,
1589 nstat_control_state *state,
1631 result = nstat_control_source_add(req->hdr.context, state, provider, cookie);
1640 nstat_control_state *state,
1658 lck_mtx_lock(&state->mtx);
1659 if ((state->ncs_watching & (1 << provider->nstat_provider_id)) != 0)
1661 state->ncs_watching |= (1 << provider->nstat_provider_id);
1662 lck_mtx_unlock(&state->mtx);
1665 result = provider->nstat_watcher_add(state);
1668 lck_mtx_lock(&state->mtx);
1669 state->ncs_watching &= ~(1 << provider->nstat_provider_id);
1670 lck_mtx_unlock(&state->mtx);
1680 ctl_enqueuedata(state->ncs_kctl, state->ncs_unit, &success, sizeof(success), CTL_DATA_EOR);
1689 nstat_control_state *state,
1717 lck_mtx_lock(&state->mtx);
1719 add->srcref = src->srcref = nstat_control_next_src_ref(state);
1720 if (state->ncs_flags & NSTAT_FLAG_CLEANUP || src->srcref == NSTAT_SRC_REF_INVALID)
1722 lck_mtx_unlock(&state->mtx);
1731 errno_t result = ctl_enqueuembuf(state->ncs_kctl, state->ncs_unit, msg, CTL_DATA_EOR);
1734 lck_mtx_unlock(&state->mtx);
1741 src->next = state->ncs_srcs;
1742 state->ncs_srcs = src;
1746 // nstat_control_send_description(state, src, 0);
1748 lck_mtx_unlock(&state->mtx);
1755 nstat_control_state *state,
1765 lck_mtx_lock(&state->mtx);
1770 for (nextp = &state->ncs_srcs; *nextp; nextp = &(*nextp)->next)
1780 lck_mtx_unlock(&state->mtx);
1782 if (src) nstat_control_cleanup_source(state, src, FALSE);
1789 nstat_control_state *state,
1808 lck_mtx_lock(&state->mtx);
1810 state->ncs_flags |= NSTAT_FLAG_REQCOUNTS;
1811 nstat_src **srcpp = &state->ncs_srcs;
1820 result = nstat_control_send_counts(state, *srcpp,
1826 state->ncs_flags &= ~NSTAT_FLAG_REQCOUNTS;
1830 // send one last descriptor message so client may see last state
1832 nstat_control_send_description(state, *srcpp,
1850 lck_mtx_unlock(&state->mtx);
1860 nstat_control_cleanup_source(state, src, FALSE);
1869 ctl_enqueuedata(state->ncs_kctl, state->ncs_unit, &success, sizeof(success), CTL_DATA_EOR);
1878 nstat_control_state *state,
1888 lck_mtx_lock(&state->mtx);
1890 for (src = state->ncs_srcs; src; src = src->next)
1899 lck_mtx_unlock(&state->mtx);
1903 errno_t result = nstat_control_send_description(state, src, req.hdr.context);
1904 lck_mtx_unlock(&state->mtx);
1917 nstat_control_state *state = (nstat_control_state*)uinfo;
1942 result = nstat_control_handle_add_request(state, m);
1946 result = nstat_control_handle_add_all(state, m);
1950 result = nstat_control_handle_remove_request(state, m);
1954 result = nstat_control_handle_query_request(state, m);
1958 result = nstat_control_handle_get_src_description(state, m);