📄 olsrd_conf.c
字号:
struct hna4_entry *h4d, *h4 = cnf->hna4_entries; struct hna6_entry *h6d, *h6 = cnf->hna6_entries; struct olsr_if *ind, *in = cnf->interfaces; struct plugin_entry *ped, *pe = cnf->plugins; struct olsr_lq_mult *mult, *next_mult; while(h4) { h4d = h4; h4 = h4->next; free(h4d); } while(h6) { h6d = h6; h6 = h6->next; free(h6d); } while(in) { for (mult = in->cnf->lq_mult; mult != NULL; mult = next_mult) { next_mult = mult->next; free(mult); } free(in->cnf); ind = in; in = in->next; free(ind->name); free(ind->config); free(ind); } while(pe) { ped = pe; pe = pe->next; free(ped->name); free(ped); } return;}struct olsrd_config *olsrd_get_default_cnf(void){ cnf = malloc(sizeof(struct olsrd_config)); if (cnf == NULL) { fprintf(stderr, "Out of memory %s\n", __func__); return NULL; } set_default_cnf(cnf); return cnf;}voidset_default_cnf(struct olsrd_config *cnf){ memset(cnf, 0, sizeof(struct olsrd_config)); cnf->debug_level = DEF_DEBUGLVL; cnf->no_fork = OLSR_FALSE; cnf->host_emul = OLSR_FALSE; cnf->ip_version = AF_INET; cnf->allow_no_interfaces = DEF_ALLOW_NO_INTS; cnf->tos = DEF_TOS; cnf->rttable = 254; cnf->willingness_auto = DEF_WILL_AUTO; cnf->ipc_connections = DEF_IPC_CONNECTIONS; cnf->open_ipc = cnf->ipc_connections ? OLSR_TRUE : OLSR_FALSE; cnf->use_hysteresis = DEF_USE_HYST; cnf->hysteresis_param.scaling = HYST_SCALING; cnf->hysteresis_param.thr_high = HYST_THRESHOLD_HIGH; cnf->hysteresis_param.thr_low = HYST_THRESHOLD_LOW; cnf->pollrate = DEF_POLLRATE; cnf->nic_chgs_pollrate = DEF_NICCHGPOLLRT; cnf->tc_redundancy = TC_REDUNDANCY; cnf->mpr_coverage = MPR_COVERAGE; cnf->lq_level = DEF_LQ_LEVEL; cnf->lq_fish = DEF_LQ_FISH; cnf->lq_dlimit = DEF_LQ_DIJK_LIMIT; cnf->lq_dinter = DEF_LQ_DIJK_INTER; cnf->lq_wsize = DEF_LQ_WSIZE; cnf->clear_screen = DEF_CLEAR_SCREEN; cnf->del_gws = OLSR_FALSE; cnf->will_int = 10 * HELLO_INTERVAL; cnf->max_jitter = 0.0; cnf->exit_value = EXIT_SUCCESS; cnf->max_tc_vtime = 0.0; cnf->ioctl_s = 0;#if LINUX_POLICY_ROUTING cnf->rtnl_s = 0;#else cnf->rts = 0;#endif}struct if_config_options *get_default_if_config(void){ struct if_config_options *io = malloc(sizeof(struct if_config_options)); struct in6_addr in6; if(io == NULL) { fprintf(stderr, "Out of memory %s\n", __func__); return NULL; } memset(io, 0, sizeof(struct if_config_options)); io->ipv6_addrtype = 1; /* XXX - FixMe */ inet_pton(AF_INET6, OLSR_IPV6_MCAST_SITE_LOCAL, &in6); memcpy(&io->ipv6_multi_site.v6, &in6, sizeof(struct in6_addr)); inet_pton(AF_INET6, OLSR_IPV6_MCAST_GLOBAL, &in6); memcpy(&io->ipv6_multi_glbl.v6, &in6, sizeof(struct in6_addr)); io->lq_mult = NULL; io->weight.fixed = OLSR_FALSE; io->weight.value = 0; io->ipv6_addrtype = 0; /* global */ io->hello_params.emission_interval = HELLO_INTERVAL; io->hello_params.validity_time = -1.0; io->tc_params.emission_interval = TC_INTERVAL; io->tc_params.validity_time = TOP_HOLD_TIME; io->mid_params.emission_interval = MID_INTERVAL; io->mid_params.validity_time = MID_HOLD_TIME; io->hna_params.emission_interval = HNA_INTERVAL; io->hna_params.validity_time = HNA_HOLD_TIME; io->autodetect_chg = OLSR_TRUE; return io;}voidolsrd_print_cnf(struct olsrd_config *cnf){ struct hna4_entry *h4 = cnf->hna4_entries; struct hna6_entry *h6 = cnf->hna6_entries; struct olsr_if *in = cnf->interfaces; struct plugin_entry *pe = cnf->plugins; struct ipc_host *ih = cnf->ipc_hosts; struct ipc_net *ie = cnf->ipc_nets; struct olsr_lq_mult *mult; char ipv6_buf[100]; /* buffer for IPv6 inet_htop */ struct in_addr in4; printf(" *** olsrd configuration ***\n"); printf("Debug Level : %d\n", cnf->debug_level); if(cnf->ip_version == AF_INET6) printf("IpVersion : 6\n"); else printf("IpVersion : 4\n"); if(cnf->allow_no_interfaces) printf("No interfaces : ALLOWED\n"); else printf("No interfaces : NOT ALLOWED\n"); printf("TOS : 0x%02x\n", cnf->tos); printf("RtTable : 0x%02x\n", cnf->rttable); if(cnf->willingness_auto) printf("Willingness : AUTO\n"); else printf("Willingness : %d\n", cnf->willingness); printf("IPC connections : %d\n", cnf->ipc_connections); while(ih) { in4.s_addr = ih->host.v4; printf("\tHost %s\n", inet_ntoa(in4)); ih = ih->next; } while(ie) { in4.s_addr = ie->net.v4; printf("\tNet %s/", inet_ntoa(in4)); in4.s_addr = ie->mask.v4; printf("%s\n", inet_ntoa(in4)); ie = ie->next; } printf("Pollrate : %0.2f\n", cnf->pollrate); printf("NIC ChangPollrate: %0.2f\n", cnf->nic_chgs_pollrate); printf("TC redundancy : %d\n", cnf->tc_redundancy); printf("MPR coverage : %d\n", cnf->mpr_coverage); printf("LQ level : %d\n", cnf->lq_level); printf("LQ fish eye : %d\n", cnf->lq_fish); printf("LQ Dijkstra limit: %d, %0.2f\n", cnf->lq_dlimit, cnf->lq_dinter); printf("LQ window size : %d\n", cnf->lq_wsize); printf("Clear screen : %s\n", cnf->clear_screen ? "yes" : "no"); /* Interfaces */ if(in) { printf("Interfaces:\n"); while(in) { printf(" dev: \"%s\"\n", in->name); if(in->cnf->ipv4_broadcast.v4) { in4.s_addr = in->cnf->ipv4_broadcast.v4; printf("\tIPv4 broadcast : %s\n", inet_ntoa(in4)); } else { printf("\tIPv4 broadcast : AUTO\n"); } printf("\tIPv6 addrtype : %s\n", in->cnf->ipv6_addrtype ? "site-local" : "global"); //union olsr_ip_addr ipv6_multi_site; //union olsr_ip_addr ipv6_multi_glbl; printf("\tIPv6 multicast site/glbl : %s", (char *)inet_ntop(AF_INET6, &in->cnf->ipv6_multi_site.v6, ipv6_buf, sizeof(ipv6_buf))); printf("/%s\n", (char *)inet_ntop(AF_INET6, &in->cnf->ipv6_multi_glbl.v6, ipv6_buf, sizeof(ipv6_buf))); printf("\tHELLO emission/validity : %0.2f/%0.2f\n", in->cnf->hello_params.emission_interval, in->cnf->hello_params.validity_time); printf("\tTC emission/validity : %0.2f/%0.2f\n", in->cnf->tc_params.emission_interval, in->cnf->tc_params.validity_time); printf("\tMID emission/validity : %0.2f/%0.2f\n", in->cnf->mid_params.emission_interval, in->cnf->mid_params.validity_time); printf("\tHNA emission/validity : %0.2f/%0.2f\n", in->cnf->hna_params.emission_interval, in->cnf->hna_params.validity_time); for (mult = in->cnf->lq_mult; mult != NULL; mult = mult->next) { inet_ntop(cnf->ip_version, &mult->addr, ipv6_buf, sizeof (ipv6_buf)); printf("\tLinkQualityMult : %s %0.2f\n", ipv6_buf, mult->val); } printf("\tAutodetetc changes : %s\n", in->cnf->autodetect_chg ? "yes" : "no"); in = in->next; } } /* Plugins */ if(pe) { printf("Plugins:\n"); while(pe) { printf("\tName: \"%s\"\n", pe->name); pe = pe->next; } } /* Hysteresis */ if(cnf->use_hysteresis) { printf("Using hysteresis:\n"); printf("\tScaling : %0.2f\n", cnf->hysteresis_param.scaling); printf("\tThr high/low : %0.2f/%0.2f\n", cnf->hysteresis_param.thr_high, cnf->hysteresis_param.thr_low); } else printf("Not using hysteresis\n"); /* HNA IPv4 */ if(h4) { printf("HNA4 entries:\n"); while(h4) { in4.s_addr = h4->net.v4; printf("\t%s/", inet_ntoa(in4)); in4.s_addr = h4->netmask.v4; printf("%s\n", inet_ntoa(in4)); h4 = h4->next; } } /* HNA IPv6 */ if(h6) { printf("HNA6 entries:\n"); while(h6) { printf("\t%s/%d\n", (char *)inet_ntop(AF_INET6, &h6->net.v6, ipv6_buf, sizeof(ipv6_buf)), h6->prefix_len); h6 = h6->next; } }}void *olsrd_cnf_malloc(unsigned int len){ return malloc(len);}void olsrd_cnf_free(void *addr){ free(addr);}#if defined WIN32_STDIO_HACKstruct ioinfo{ unsigned int handle; unsigned char attr; char buff; int flag; CRITICAL_SECTION lock;};void win32_stdio_hack(unsigned int handle){ HMODULE lib; struct ioinfo **info; lib = LoadLibrary("msvcrt.dll"); info = (struct ioinfo **)GetProcAddress(lib, "__pioinfo"); // (*info)[1].handle = handle; // (*info)[1].attr = 0x89; // FOPEN | FTEXT | FPIPE; (*info)[2].handle = handle; (*info)[2].attr = 0x89; // stdout->_file = 1; stderr->_file = 2; // setbuf(stdout, NULL); setbuf(stderr, NULL);}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -