Home | History | Annotate | Download | only in src

Lines Matching defs:new

394  * to create just a single new listener dynamically when our interface
397 * iface - input of the new interface details to listen on
398 * listeners - output. Creates a new struct listener and inserts at head of the list
409 struct listener *new = safe_malloc(sizeof(struct listener));
410 new->family = iface->addr.sa.sa_family;
411 new->iface = iface;
412 new->next = *listeners;
413 new->tftpfd = -1;
414 new->tcpfd = -1;
415 new->fd = -1;
416 *listeners = new;
420 if ((new->tcpfd = socket(iface->addr.sa.sa_family, SOCK_STREAM, 0)) == -1 ||
421 (new->fd = socket(iface->addr.sa.sa_family, SOCK_DGRAM, 0)) == -1 ||
422 setsockopt(new->fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1 ||
423 setsockopt(new->tcpfd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1 ||
424 !fix_fd(new->tcpfd) ||
425 !fix_fd(new->fd))
431 if (setsockopt(new->fd, IPV6_LEVEL, IPV6_V6ONLY, &opt, sizeof(opt)) == -1 ||
432 setsockopt(new->tcpfd, IPV6_LEVEL, IPV6_V6ONLY, &opt, sizeof(opt)) == -1)
439 if ((rc = bind(new->fd, &iface->addr.sa, sa_len(&iface->addr))) != -1)
456 if (rc == -1 || bind(new->tcpfd, &iface->addr.sa, sa_len(&iface->addr)) == -1)
462 if (listen(new->tcpfd, 5) == -1)
471 if ((new->tftpfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1 ||
472 setsockopt(new->tftpfd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1 ||
473 !fix_fd(new->tftpfd) ||
474 bind(new->tftpfd, &iface->addr.sa, sa_len(&iface->addr)) == -1)
484 * This new function is needed as we're dynamically changing the interfaces
547 struct listener *new = safe_malloc(sizeof(struct listener));
548 new->family = iface->addr.sa.sa_family;
549 new->iface = iface;
550 new->next = listeners;
551 new->tftpfd = -1;
552 new->tcpfd = -1;
553 new->fd = -1;
554 listeners = new;
558 if ((new->tcpfd = socket(iface->addr.sa.sa_family, SOCK_STREAM, 0)) == -1 ||
559 (new->fd = socket(iface->addr.sa.sa_family, SOCK_DGRAM, 0)) == -1 ||
560 setsockopt(new->fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1 ||
561 setsockopt(new->tcpfd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1 ||
562 !fix_fd(new->tcpfd) ||
563 !fix_fd(new->fd))
569 if (setsockopt(new->fd, IPV6_LEVEL, IPV6_V6ONLY, &opt, sizeof(opt)) == -1 ||
570 setsockopt(new->tcpfd, IPV6_LEVEL, IPV6_V6ONLY, &opt, sizeof(opt)) == -1)
577 if ((rc = bind(new->fd, &iface->addr.sa, sa_len(&iface->addr))) != -1)
594 if (rc == -1 || bind(new->tcpfd, &iface->addr.sa, sa_len(&iface->addr)) == -1)
601 if (listen(new->tcpfd, 5) == -1)
610 if ((new->tftpfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1 ||
611 setsockopt(new->tftpfd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1 ||
612 !fix_fd(new->tftpfd) ||
613 bind(new->tftpfd, &iface->addr.sa, sa_len(&iface->addr)) == -1)
740 /* need to make a new one. */
817 struct server *new, *tmp, *ret = NULL;
820 for (new = daemon->servers; new; new = tmp)
822 tmp = new->next;
824 if (!(new->flags & (SERV_LITERAL_ADDRESS | SERV_NO_ADDR)))
826 port = prettyprint_addr(&new->addr, daemon->namebuff);
829 if (new->addr.sa.sa_family == AF_INET &&
830 new->addr.in.sin_addr.s_addr == 0)
832 free(new);
837 if (sockaddr_isequal(&new->addr, &iface->addr))
842 free(new);
847 if (!new->sfd &&
848 !(new->sfd = allocate_sfd(&new->source_addr, new->interface)) &&
854 free(new);
860 new->next = ret;
861 ret = new;
863 if (new->flags & (SERV_HAS_DOMAIN | SERV_FOR_NODOTS))
866 if (!(new->flags & SERV_HAS_DOMAIN))
868 else if (strlen(new->domain) == 0)
871 s1 = _("domain"), s2 = new->domain;
873 if (new->flags & SERV_NO_ADDR)
875 else if (!(new->flags & SERV_LITERAL_ADDRESS))
878 else if (new->interface[0] != 0)
879 my_syslog(LOG_INFO, _("using nameserver %s#%d(via %s)"), daemon->namebuff, port, new->interface);
890 * Ingests a new list of interfaces and starts to listen on them, adding only the new
891 * and stopping to listen to any interfaces not on the new list.
1014 and not risk malloc if there are the same or fewer new servers.
1015 Servers which were specced on the command line go to the new list. */
1120 and not risk malloc if there are the same or fewer new servers.
1121 Servers which were specced on the command line go to the new list. */