662
if(if_index != AVAHI_IF_UNSPEC and mc->interfaces != NULL){
663
/* Check if the interface is one of the interfaces we are using */
666
char *interface = NULL;
667
while((interface=argz_next(mc->interfaces, mc->interfaces_size,
669
if(if_nametoindex(interface) == (unsigned int)if_index){
677
char interface[IF_NAMESIZE];
678
if(if_indextoname((unsigned int)if_index, interface) == NULL){
679
perror_plus("if_indextoname");
681
fprintf_plus(stderr, "Skipping server on non-used interface"
683
if_indextoname((unsigned int)if_index,
662
691
ret = init_gnutls_session(&session, mc);
2006
2035
/* Lower privileges */
2010
perror_plus("seteuid");
2015
/* Remove empty interface names */
2040
/* Remove invalid interface names (except "none") */
2017
2042
char *interface = NULL;
2018
2043
while((interface = argz_next(mc.interfaces, mc.interfaces_size,
2020
if(if_nametoindex(interface) == 0){
2021
if(interface[0] != '\0' and strcmp(interface, "none") != 0){
2045
if(strcmp(interface, "none") != 0
2046
and if_nametoindex(interface) == 0){
2047
if(interface[0] != '\0'){
2022
2048
fprintf_plus(stderr, "Not using nonexisting interface"
2023
2049
" \"%s\"\n", interface);
2159
/* If we only got one interface, explicitly use only that one */
2160
if(argz_count(mc.interfaces, mc.interfaces_size) == 1){
2162
fprintf_plus(stderr, "Using only interface \"%s\"\n",
2165
if_index = (AvahiIfIndex)if_nametoindex(mc.interfaces);
2168
2184
/* Bring up interfaces which are down */
2169
if(not (argz_count(mc.interfaces, mc.interfaces_size) == 1
2170
and strcmp(mc.interfaces, "none") == 0)){
2171
2186
char *interface = NULL;
2172
2187
while((interface = argz_next(mc.interfaces, mc.interfaces_size,
2189
/* If interface name is "none", stop bringing up interfaces.
2190
Also remove all instances of "none" from the list */
2191
if(strcmp(interface, "none") == 0){
2192
argz_delete(&mc.interfaces, &mc.interfaces_size,
2195
while((interface = argz_next(mc.interfaces,
2196
mc.interfaces_size, interface))){
2197
if(strcmp(interface, "none") == 0){
2198
argz_delete(&mc.interfaces, &mc.interfaces_size,
2174
2205
bool interface_was_up = interface_is_up(interface);
2175
2206
ret = bring_up_interface(interface, delay);
2176
2207
if(not interface_was_up){
2187
free(mc.interfaces);
2188
mc.interfaces = NULL;
2189
mc.interfaces_size = 0;
2190
2218
if(debug and (interfaces_to_take_down == NULL)){
2191
2219
fprintf_plus(stderr, "No interfaces were brought up\n");
2223
/* If we only got one interface, explicitly use only that one */
2224
if(argz_count(mc.interfaces, mc.interfaces_size) == 1){
2226
fprintf_plus(stderr, "Using only interface \"%s\"\n",
2229
if_index = (AvahiIfIndex)if_nametoindex(mc.interfaces);