void DLL_EXPORT print(word_t * self, int check){ if(check) { for(int i = 0 ; i < word_count(self) ; i++) printf("%s " , word_get(self , i)); } }
static void topology_find_radios( struct topology_parse *p ) { char *s; int error; while ((s = topology_line_get(p)) != NULL) { if (*s == '{') { topology_skip_section(p); continue; } if (word_eq(s, "bridge")) { s = word_next(s); error = word_get( s, p->bridge_name, sizeof(p->bridge_name)); if (error) { wpa_printf(MSG_ERROR, "File %s line %d Bad bridge name", p->filepath, p->line); p->errors++; strcpy(p->bridge_name, "?"); } else { topology_parse_bridge(p); } continue; } if (word_eq(s, "radio")) { s = word_next(s); error = word_get( s, p->radio_name, sizeof(p->radio_name)); if (error) { wpa_printf(MSG_ERROR, "File %s line %d Bad radio name", p->filepath, p->line); p->errors++; strcpy(p->radio_name, "?"); } else { topology_parse_radio(p); } continue; } /* skip unknown */ } return; }
static void topology_parse_bridge( struct topology_parse *p ) { char *s; struct topology_bridge *bridge; int error; /* Remember the bridge */ bridge = topology_add_bridge(p); if (bridge == NULL) return; /* Find leading brace */ if (topology_find_section(p)) return; /* Now process lines within */ while ((s = topology_line_get(p)) != NULL) { if (*s == '{') { topology_skip_section(p); continue; } if (*s == '}') break; if (word_eq(s, "interface")) { s = word_next(s); error = word_get( s, p->ifname, sizeof(p->ifname)); if (error) { wpa_printf(MSG_ERROR, "File %s line %d Bad interface name", p->filepath, p->line); p->errors++; strcpy(p->ifname, "?"); } else { topology_add_iface(p); } continue; } /* skip unknown */ } return; }
static void topology_parse_ap( struct topology_parse *p ) { char *s; /* Add to "interfaces" (really, this is radios) */ p->interfaces->count++; p->interfaces->iface = realloc(p->interfaces->iface, p->interfaces->count*sizeof(p->interfaces->iface[0])); if (p->interfaces->iface == NULL) { wpa_printf(MSG_ERROR, "FATAL: realloc error"); exit(1); p->errors++; return; } p->interfaces->iface[p->interfaces->count-1] = p->hapd_iface = wpa_zalloc(sizeof(*p->hapd_iface)); if (p->hapd_iface == NULL) { wpa_printf(MSG_ERROR, "Malloc error"); p->errors++; return; } p->hapd_iface->conf = hostapd_radio_config_create(); if (p->hapd_iface->conf == NULL) { p->errors++; return; } /* Find leading brace */ if (topology_find_section(p)) return; /* Now process lines within */ while ((s = topology_line_get(p)) != NULL) { if (*s == 0) continue; if (*s == '{') { topology_skip_section(p); continue; } if (*s == '}') break; if (word_eq(s, "config")) { s = word_next(s); if (word_get( s, p->ap_config_filepath, sizeof(p->ap_config_filepath))) { p->errors++; wpa_printf(MSG_ERROR, "File %s line %d" " config requires path", p->filepath, p->line); } else { if (hostapd_radio_config_apply_file(p->hapd_iface->conf, p->ap_config_filepath)) { p->errors++; wpa_printf(MSG_ERROR, "From file %s line %d", p->filepath, p->line); } } continue; } if (word_eq(s, "override")) { s = word_next(s); topology_parse_ap_config_override(p, s); continue; } if (word_eq(s, "bss")) { s = word_next(s); if (word_get(s, p->ifname, sizeof(p->ifname))) { p->errors++; wpa_printf(MSG_ERROR, "File %s line %d" " bss requires interface name", p->filepath, p->line); } topology_parse_bss(p); continue; } /* skip unknown */ } return; }
static void topology_parse_bss( struct topology_parse *p ) { /* p->ifname contains bss name */ char *s; int error; struct topology_iface *iface; iface = topology_find_iface(p, p->ifname); if (iface == NULL) { wpa_printf(MSG_ERROR, "File %s line %d Undeclared iface %s", p->filepath, p->line, p->ifname); p->errors++; return; } if (iface->used) { wpa_printf(MSG_ERROR, "File %s line %d Already used iface %s", p->filepath, p->line, p->ifname); p->errors++; return; } iface->used++; /* Add to radio configuration */ error = hostapd_config_bss(p->hapd_iface->conf, iface->name); if (error) { p->errors++; return; } /* Find leading brace */ if (topology_find_section(p)) return; /* Now process lines within */ while ((s = topology_line_get(p)) != NULL) { if (*s == '{') { topology_skip_section(p); continue; } if (*s == '}') break; if (word_eq(s, "config")) { s = word_next(s); if (word_get( s, p->bss_config_filepath, sizeof(p->bss_config_filepath))) { wpa_printf(MSG_ERROR, "File %s line %d" " config requires path", p->filepath, p->line); p->errors++; } else { p->errors += hostapd_bss_config_apply_file( p->hapd_iface->conf, p->hapd_iface->conf->last_bss, p->bss_config_filepath); } continue; } if (word_eq(s, "override")) { s = word_next(s); p->errors += topology_parse_bss_config_override(p, s); continue; } /* skip unknown */ } /* Now override interface name and bridge */ if (hostapd_bss_config_apply_line( p->hapd_iface->conf->last_bss, "interface", iface->name, p->line, 1/*internal*/)) { p->errors++; } if (hostapd_bss_config_apply_line( p->hapd_iface->conf->last_bss, "bridge", iface->bridge->name, p->line, 1/*internal*/)) { p->errors++; } return; }