int add_remove_p2p_interface(int add) { int ret; ret = init_nl(); if (ret != 0) return ret; if (add) { ret = execute_nl_interface_cmd(P2P_INTERFACE, NL80211_IFTYPE_STATION, NL80211_CMD_NEW_INTERFACE); if (ret != 0) { ALOGE("could not add P2P interface: %d", ret); goto cleanup; } } else { ret = execute_nl_interface_cmd(P2P_INTERFACE, NL80211_IFTYPE_STATION, NL80211_CMD_DEL_INTERFACE); if (ret != 0) { ALOGE("could not remove P2P interface: %d", ret); goto cleanup; } } ALOGD("added/removed p2p interface. add: %d", add); cleanup: deinit_nl(); return ret; }
void read_header(FILE* fd) { init_nl(fd); nl(); /* ply */ nl(); /* format binary_little_endian 1.0 */ /* element vertex %nv% */ nl(); sscanf(line, "element vertex %d\n", &nv); nl(); nl(); nl(); nl(); nl(); nl(); /* property float [xyzuvw] */ nl(); sscanf(line, "element face %d\n", &nf); nl(); /* property list int int vertex_index */ nl(); /* end_header */ }
static void *run(void *data) { (void)data; /* unused parameter. silence warning. */ init_nl(); raw_sample_buf_init(); init_realtime(); set_sample_period(SAMPLE_PERIOD_US); struct timespec deadline; clock_gettime(CLOCK_MONOTONIC, &deadline); int sample_no = 0; char *iface = strdup(g_iface); struct iface_stats *stats_frame = raw_sample_buf_produce_next(); snprintf(stats_frame->iface, MAX_IFACE_LEN, "%s", iface); stats_frame->sample_period_us = sample_period_us; for (;;) { update_stats(&(stats_frame->samples[sample_no]), iface, deadline); sample_no++; sample_no %= SAMPLES_PER_FRAME; /* set the iface, samples per period at start of each frame*/ if (sample_no == 0) { pthread_mutex_lock(&g_iface_mutex); free(iface); iface = strdup(g_iface); stats_frame = raw_sample_buf_produce_next(); snprintf(stats_frame->iface, MAX_IFACE_LEN, "%s", iface); pthread_mutex_unlock(&g_iface_mutex); stats_frame->sample_period_us = sample_period_us; stats_handler(raw_sample_buf_consume_next()); } deadline.tv_nsec += 1000 * sample_period_us; /* Normalize the time to account for the second boundary */ if (deadline.tv_nsec >= 1000000000) { deadline.tv_nsec -= 1000000000; deadline.tv_sec++; } clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &deadline, NULL); } return NULL; }