static void stats_print_diff(struct stats_file *file) { struct stats_record *begin, *end; begin = get_begin(file); begin = get_next(file, begin); end = get_end(file); printf("\n(begin + 1)\n"); printf("\t[%04d] ", get_index(file, begin)); stats_print_record(begin); printf("end\n"); printf("\t[%04d] ", get_index(file, end)); stats_print_record(end); if (file->home_first && get_home(file)) { printf("\nhome\n"); stats_print_rec_diff(file->home_first, get_home(file)); } if (file->roaming_first && get_roaming(file)) { printf("\roaming\n"); stats_print_rec_diff(file->roaming_first, get_roaming(file)); } }
static void stats_hdr_info(struct stats_file *file) { struct stats_file_header *hdr; struct stats_record *begin, *end, *home, *roaming; unsigned int home_idx, roaming_idx; hdr = get_hdr(file); begin = get_begin(file); end = get_end(file); home = get_home(file); if (!home) home_idx = UINT_MAX; else home_idx = get_index(file, home); roaming = get_roaming(file); if (!roaming) roaming_idx = UINT_MAX; else roaming_idx = get_index(file, roaming); printf("Data Structure Sizes\n"); printf(" sizeof header %zd/0x%02zx\n", sizeof(struct stats_file_header), sizeof(struct stats_file_header)); printf(" sizeof entry %zd/0%02zx\n\n", sizeof(struct stats_record), sizeof(struct stats_record)); printf("File\n"); printf(" addr %p\n", file->addr); printf(" len %zd\n", file->len); printf(" max nr entries %d\n", file->max_nr); printf(" nr entries %d\n\n", file->nr); printf("Header\n"); printf(" magic 0x%08x\n", hdr->magic); printf(" begin [%d] 0x%08x\n", get_index(file, begin), hdr->begin); printf(" end [%d] 0x%08x\n", get_index(file, end), hdr->end); printf(" home [%d] 0x%08x\n", home_idx, hdr->home); printf(" roaming [%d] 0x%08x\n\n", roaming_idx, hdr->roaming); printf("Pointers\n"); printf(" hdr %p\n", hdr); printf(" begin %p\n", begin); printf(" end %p\n", end); printf(" home %p\n", home); printf(" romaing %p\n", roaming); printf(" first %p\n", file->first); printf(" last %p\n\n", file->last); }
/** * Write out /etc/udhcpd.conf conf so the config is available when it gets started */ int usb_network_set_up_dhcpd(struct mode_list_elem *data) { struct ipforward_data *ipforward = NULL; int ret = 1; /* Set up nat info only if it is required */ if(data->nat) { #ifdef OFONO /* check if we are roaming or not */ if(get_roaming()) { /* get permission to use roaming */ if(is_roaming_not_allowed()) goto end; } #endif /* OFONO */ ipforward = malloc(sizeof(struct ipforward_data)); memset(ipforward, 0, sizeof(struct ipforward_data)); #ifdef CONNMAN if(connman_get_connection_data(ipforward)) { log_debug("data connection not available!\n"); /* TODO: send a message to the UI */ goto end; } #else if(resolv_conf_dns(ipforward)) goto end; #endif /*CONNMAN */ } /* ipforward can be NULL here, which is expected and handled in this function */ ret = write_udhcpd_conf(ipforward, data); if(data->nat) ret = set_usb_ip_forward(data, ipforward); end: /* the function checks if ipforward is NULL or not */ free_ipforward_data(ipforward); return(ret); }
static void update_roaming(struct stats_file *file) { file->roaming = get_roaming(file); }