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)
483 * malloc()d struct irec's address, update its pointer to refer to this new
509 * This new function is needed as we're dynamically changing the interfaces
572 struct listener *new = safe_malloc(sizeof(struct listener));
573 new->family = iface->addr.sa.sa_family;
574 new->iface = iface;
575 new->next = listeners;
576 new->tftpfd = -1;
577 new->tcpfd = -1;
578 new->fd = -1;
579 listeners = new;
583 if ((new->tcpfd = socket(iface->addr.sa.sa_family, SOCK_STREAM, 0)) == -1 ||
584 (new
585 setsockopt(new->fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1 ||
586 setsockopt(new->tcpfd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1 ||
587 !fix_fd(new->tcpfd) ||
588 !fix_fd(new->fd))
594 if (setsockopt(new->fd, IPV6_LEVEL, IPV6_V6ONLY, &opt, sizeof(opt)) == -1 ||
595 setsockopt(new->tcpfd, IPV6_LEVEL, IPV6_V6ONLY, &opt, sizeof(opt)) == -1)
602 if ((rc = bind(new->fd, &iface->addr.sa, sa_len(&iface->addr))) != -1)
619 if (rc == -1 || bind(new->tcpfd, &iface->addr.sa, sa_len(&iface->addr)) == -1)
626 if (listen(new->tcpfd, 5) == -1)
635 if ((new->tftpfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1 ||
636 setsockopt(new->tftpfd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1 ||
637 !fix_fd(new->tftpfd) ||
638 bind(new->tftpfd, &iface->addr.sa, sa_len(&iface->addr)) == -1)
769 /* need to make a new one. */
847 struct server *new, *tmp, *ret = NULL;
850 for (new = daemon->servers; new; new = tmp)
852 tmp = new->next;
854 if (!(new->flags & (SERV_LITERAL_ADDRESS | SERV_NO_ADDR)))
856 port = prettyprint_addr(&new->addr, daemon->namebuff);
859 if (new->addr.sa.sa_family == AF_INET &&
860 new->addr.in.sin_addr.s_addr == 0)
862 free(new);
867 if (sockaddr_isequal(&new->addr, &iface->addr))
872 free(new);
877 if (!new->sfd &&
878 !(new->sfd = allocate_sfd(&new->source_addr, new->interface, new->mark)) &&
884 free(new);
890 new->next = ret;
891 ret = new;
893 if (new->flags & (SERV_HAS_DOMAIN | SERV_FOR_NODOTS))
896 if (!(new->flags & SERV_HAS_DOMAIN))
898 else if (strlen(new->domain) == 0)
901 s1 = _("domain"), s2 = new->domain;
903 if (new->flags & SERV_NO_ADDR)
905 else if (!(new->flags & SERV_LITERAL_ADDRESS))
908 else if (new->interface[0] != 0)
909 my_syslog(LOG_INFO, _("using nameserver %s#%d(via %s)"), daemon->namebuff, port, new->interface);
920 * Ingests a new list of interfaces and starts to listen on them, adding only the new
921 * and stopping to listen to any interfaces not on the new list.
1051 and not risk malloc if there are the same or fewer new servers.
1052 Servers which were specced on the command line go to the new list. */
1162 and not risk malloc if there are the same or fewer new servers.
1163 Servers which were specced on the command line go to the new list. */