Lines Matching refs:addr
49 int iface_check(int family, struct all_addr *addr, char *name, int *indexp) in iface_check() argument
88 if (daemon->if_names || (addr && daemon->if_addrs)) in iface_check()
97 if (addr && tmp->addr.sa.sa_family == family) in iface_check()
100 tmp->addr.in.sin_addr.s_addr == addr->addr.addr4.s_addr) in iface_check()
104 IN6_ARE_ADDR_EQUAL(&tmp->addr.in6.sin6_addr, in iface_check()
105 &addr->addr.addr6)) in iface_check()
119 union mysockaddr *addr, struct in_addr netmask) in iface_allowed() argument
130 if (sockaddr_isequal(&iface->addr, addr)) in iface_allowed()
176 if (addr->sa.sa_family == AF_INET && in iface_allowed()
177 !iface_check(AF_INET, (struct all_addr *)&addr->in.sin_addr, ifr.ifr_name, NULL)) in iface_allowed()
185 if (addr->sa.sa_family == AF_INET6 && in iface_allowed()
186 !iface_check(AF_INET6, (struct all_addr *)&addr->in6.sin6_addr, ifr.ifr_name, NULL)) in iface_allowed()
193 iface->addr = *addr; in iface_allowed()
210 union mysockaddr addr; in iface_allowed_v6() local
215 memset(&addr, 0, sizeof(addr)); in iface_allowed_v6()
217 addr.in6.sin6_len = sizeof(addr.in6); in iface_allowed_v6()
219 addr.in6.sin6_family = AF_INET6; in iface_allowed_v6()
220 addr.in6.sin6_addr = *local; in iface_allowed_v6()
221 addr.in6.sin6_port = htons(daemon->port); in iface_allowed_v6()
222 addr.in6.sin6_scope_id = scope; in iface_allowed_v6()
224 return iface_allowed((struct irec **)vparam, if_index, &addr, netmask); in iface_allowed_v6()
231 union mysockaddr addr; in iface_allowed_v4() local
233 memset(&addr, 0, sizeof(addr)); in iface_allowed_v4()
235 addr.in.sin_len = sizeof(addr.in); in iface_allowed_v4()
237 addr.in.sin_family = AF_INET; in iface_allowed_v4()
238 addr.in.sin_addr = broadcast; /* warning */ in iface_allowed_v4()
239 addr.in.sin_addr = local; in iface_allowed_v4()
240 addr.in.sin_port = htons(daemon->port); in iface_allowed_v4()
242 return iface_allowed((struct irec **)vparam, if_index, &addr, netmask); in iface_allowed_v4()
269 union mysockaddr addr; in create_ipv6_listener() local
274 memset(&addr, 0, sizeof(addr)); in create_ipv6_listener()
275 addr.in6.sin6_family = AF_INET6; in create_ipv6_listener()
276 addr.in6.sin6_addr = in6addr_any; in create_ipv6_listener()
277 addr.in6.sin6_port = htons(port); in create_ipv6_listener()
279 addr.in6.sin6_len = sizeof(addr.in6); in create_ipv6_listener()
302 bind(tcpfd, (struct sockaddr *)&addr, sa_len(&addr)) == -1 || in create_ipv6_listener()
304 bind(fd, (struct sockaddr *)&addr, sa_len(&addr)) == -1) in create_ipv6_listener()
321 union mysockaddr addr; in create_wildcard_listeners() local
326 memset(&addr, 0, sizeof(addr)); in create_wildcard_listeners()
327 addr.in.sin_family = AF_INET; in create_wildcard_listeners()
328 addr.in.sin_addr.s_addr = INADDR_ANY; in create_wildcard_listeners()
329 addr.in.sin_port = htons(daemon->port); in create_wildcard_listeners()
331 addr.in.sin_len = sizeof(struct sockaddr_in); in create_wildcard_listeners()
342 bind(tcpfd, (struct sockaddr *)&addr, sa_len(&addr)) == -1 || in create_wildcard_listeners()
356 bind(fd, (struct sockaddr *)&addr, sa_len(&addr)) == -1) in create_wildcard_listeners()
363 addr.in.sin_port = htons(TFTP_PORT); in create_wildcard_listeners()
374 bind(tftpfd, (struct sockaddr *)&addr, sa_len(&addr)) == -1) in create_wildcard_listeners()
401 new->family = iface->addr.sa.sa_family; in create_bound_listeners()
411 if ((new->tcpfd = socket(iface->addr.sa.sa_family, SOCK_STREAM, 0)) == -1 || in create_bound_listeners()
412 (new->fd = socket(iface->addr.sa.sa_family, SOCK_DGRAM, 0)) == -1 || in create_bound_listeners()
420 if (iface->addr.sa.sa_family == AF_INET6) in create_bound_listeners()
430 if ((rc = bind(new->fd, &iface->addr.sa, sa_len(&iface->addr))) != -1) in create_bound_listeners()
437 if (iface->addr.sa.sa_family == AF_INET6 && (errno == ENODEV || errno == EADDRNOTAVAIL) && in create_bound_listeners()
447 if (rc == -1 || bind(new->tcpfd, &iface->addr.sa, sa_len(&iface->addr)) == -1) in create_bound_listeners()
449 prettyprint_addr(&iface->addr, daemon->namebuff); in create_bound_listeners()
459 if ((daemon->options & OPT_TFTP) && iface->addr.sa.sa_family == AF_INET && iface->dhcp_ok) in create_bound_listeners()
461 short save = iface->addr.in.sin_port; in create_bound_listeners()
462 iface->addr.in.sin_port = htons(TFTP_PORT); in create_bound_listeners()
466 bind(new->tftpfd, &iface->addr.sa, sa_len(&iface->addr)) == -1) in create_bound_listeners()
468 iface->addr.in.sin_port = save; in create_bound_listeners()
486 union mysockaddr addr; in random_sock() local
490 memset(&addr, 0, sizeof(addr)); in random_sock()
491 addr.sa.sa_family = family; in random_sock()
505 addr.in.sin_addr.s_addr = INADDR_ANY; in random_sock()
506 addr.in.sin_port = port; in random_sock()
508 addr.in.sin_len = sizeof(struct sockaddr_in); in random_sock()
514 addr.in6.sin6_addr = in6addr_any; in random_sock()
515 addr.in6.sin6_port = port; in random_sock()
517 addr.in6.sin6_len = sizeof(struct sockaddr_in6); in random_sock()
522 if (bind(fd, (struct sockaddr *)&addr, sa_len(&addr)) == 0) in random_sock()
536 int local_bind(int fd, union mysockaddr *addr, char *intname, int is_tcp) in local_bind() argument
538 union mysockaddr addr_copy = *addr; in local_bind()
563 static struct serverfd *allocate_sfd(union mysockaddr *addr, char *intname) in allocate_sfd() argument
574 if (addr->sa.sa_family == AF_INET && in allocate_sfd()
575 addr->in.sin_addr.s_addr == INADDR_ANY && in allocate_sfd()
576 addr->in.sin_port == htons(0)) in allocate_sfd()
580 if (addr->sa.sa_family == AF_INET6 && in allocate_sfd()
581 memcmp(&addr->in6.sin6_addr, &in6addr_any, sizeof(in6addr_any)) == 0 && in allocate_sfd()
582 addr->in6.sin6_port == htons(0)) in allocate_sfd()
589 if (sockaddr_isequal(&sfd->source_addr, addr) && in allocate_sfd()
598 if ((sfd->fd = socket(addr->sa.sa_family, SOCK_DGRAM, 0)) == -1) in allocate_sfd()
604 if (!local_bind(sfd->fd, addr, intname, 0) || !fix_fd(sfd->fd)) in allocate_sfd()
614 sfd->source_addr = *addr; in allocate_sfd()
628 union mysockaddr addr; in pre_allocate_sfds() local
629 memset(&addr, 0, sizeof(addr)); in pre_allocate_sfds()
630 addr.in.sin_family = AF_INET; in pre_allocate_sfds()
631 addr.in.sin_addr.s_addr = INADDR_ANY; in pre_allocate_sfds()
632 addr.in.sin_port = htons(daemon->query_port); in pre_allocate_sfds()
634 addr.in.sin_len = sizeof(struct sockaddr_in); in pre_allocate_sfds()
636 allocate_sfd(&addr, ""); in pre_allocate_sfds()
638 memset(&addr, 0, sizeof(addr)); in pre_allocate_sfds()
639 addr.in6.sin6_family = AF_INET6; in pre_allocate_sfds()
640 addr.in6.sin6_addr = in6addr_any; in pre_allocate_sfds()
641 addr.in6.sin6_port = htons(daemon->query_port); in pre_allocate_sfds()
643 addr.in6.sin6_len = sizeof(struct sockaddr_in6); in pre_allocate_sfds()
645 allocate_sfd(&addr, ""); in pre_allocate_sfds()
655 prettyprint_addr(&srv->addr, daemon->namebuff); in pre_allocate_sfds()
679 port = prettyprint_addr(&new->addr, daemon->namebuff); in check_servers()
682 if (new->addr.sa.sa_family == AF_INET && in check_servers()
683 new->addr.in.sin_addr.s_addr == 0) in check_servers()
690 if (sockaddr_isequal(&new->addr, &iface->addr)) in check_servers()
778 union mysockaddr addr, source_addr; in set_servers() local
779 memset(&addr, 0, sizeof(addr)); in set_servers()
782 if ((addr.in.sin_addr.s_addr = inet_addr(saddr)) != (in_addr_t) -1) in set_servers()
785 source_addr.in.sin_len = addr.in.sin_len = sizeof(source_addr.in); in set_servers()
787 source_addr.in.sin_family = addr.in.sin_family = AF_INET; in set_servers()
788 addr.in.sin_port = htons(NAMESERVER_PORT); in set_servers()
793 else if (inet_pton(AF_INET6, saddr, &addr.in6.sin6_addr) > 0) in set_servers()
796 source_addr.in6.sin6_len = addr.in6.sin6_len = sizeof(source_addr.in6); in set_servers()
798 source_addr.in6.sin6_family = addr.in6.sin6_family = AF_INET6; in set_servers()
799 addr.in6.sin6_port = htons(NAMESERVER_PORT); in set_servers()
819 serv->addr = addr; in set_servers()
882 union mysockaddr addr, source_addr; in reload_servers() local
892 memset(&addr, 0, sizeof(addr)); in reload_servers()
895 if ((addr.in.sin_addr.s_addr = inet_addr(token)) != (in_addr_t) -1) in reload_servers()
898 source_addr.in.sin_len = addr.in.sin_len = sizeof(source_addr.in); in reload_servers()
900 source_addr.in.sin_family = addr.in.sin_family = AF_INET; in reload_servers()
901 addr.in.sin_port = htons(NAMESERVER_PORT); in reload_servers()
906 else if (inet_pton(AF_INET6, token, &addr.in6.sin6_addr) > 0) in reload_servers()
909 source_addr.in6.sin6_len = addr.in6.sin6_len = sizeof(source_addr.in6); in reload_servers()
911 source_addr.in6.sin6_family = addr.in6.sin6_family = AF_INET6; in reload_servers()
912 addr.in6.sin6_port = htons(NAMESERVER_PORT); in reload_servers()
932 serv->addr = addr; in reload_servers()