Lines Matching refs:addr
51 int iface_check(int family, struct all_addr *addr, char *name, int *indexp) in iface_check() argument
90 if (daemon->if_names || (addr && daemon->if_addrs)) in iface_check()
99 if (addr && tmp->addr.sa.sa_family == family) in iface_check()
102 tmp->addr.in.sin_addr.s_addr == addr->addr.addr4.s_addr) in iface_check()
106 IN6_ARE_ADDR_EQUAL(&tmp->addr.in6.sin6_addr, in iface_check()
107 &addr->addr.addr6) && in iface_check()
108 (!IN6_IS_ADDR_LINKLOCAL(&addr->addr.addr6) || in iface_check()
109 (tmp->addr.in6.sin6_scope_id == (uint32_t) *indexp))) in iface_check()
123 union mysockaddr *addr, struct in_addr netmask) in iface_allowed() argument
134 if (sockaddr_isequal(&iface->addr, addr)) in iface_allowed()
180 if (addr->sa.sa_family == AF_INET && in iface_allowed()
181 !iface_check(AF_INET, (struct all_addr *)&addr->in.sin_addr, ifr.ifr_name, NULL)) in iface_allowed()
189 int ifindex = (int) addr->in6.sin6_scope_id; in iface_allowed()
190 if (addr->sa.sa_family == AF_INET6 && in iface_allowed()
191 !iface_check(AF_INET6, (struct all_addr *)&addr->in6.sin6_addr, ifr.ifr_name, &ifindex)) in iface_allowed()
198 iface->addr = *addr; in iface_allowed()
215 union mysockaddr addr; in iface_allowed_v6() local
220 memset(&addr, 0, sizeof(addr)); in iface_allowed_v6()
222 addr.in6.sin6_len = sizeof(addr.in6); in iface_allowed_v6()
224 addr.in6.sin6_family = AF_INET6; in iface_allowed_v6()
225 addr.in6.sin6_addr = *local; in iface_allowed_v6()
226 addr.in6.sin6_port = htons(daemon->port); in iface_allowed_v6()
234 addr.in6.sin6_scope_id = scope; in iface_allowed_v6()
237 return iface_allowed((struct irec **)vparam, if_index, &addr, netmask); in iface_allowed_v6()
244 union mysockaddr addr; in iface_allowed_v4() local
246 memset(&addr, 0, sizeof(addr)); in iface_allowed_v4()
248 addr.in.sin_len = sizeof(addr.in); in iface_allowed_v4()
250 addr.in.sin_family = AF_INET; in iface_allowed_v4()
251 addr.in.sin_addr = broadcast; /* warning */ in iface_allowed_v4()
252 addr.in.sin_addr = local; in iface_allowed_v4()
253 addr.in.sin_port = htons(daemon->port); in iface_allowed_v4()
255 return iface_allowed((struct irec **)vparam, if_index, &addr, netmask); in iface_allowed_v4()
282 union mysockaddr addr; in create_ipv6_listener() local
287 memset(&addr, 0, sizeof(addr)); in create_ipv6_listener()
288 addr.in6.sin6_family = AF_INET6; in create_ipv6_listener()
289 addr.in6.sin6_addr = in6addr_any; in create_ipv6_listener()
290 addr.in6.sin6_port = htons(port); in create_ipv6_listener()
292 addr.in6.sin6_len = sizeof(addr.in6); in create_ipv6_listener()
315 bind(tcpfd, (struct sockaddr *)&addr, sa_len(&addr)) == -1 || in create_ipv6_listener()
317 bind(fd, (struct sockaddr *)&addr, sa_len(&addr)) == -1) in create_ipv6_listener()
335 union mysockaddr addr; in create_wildcard_listeners() local
340 memset(&addr, 0, sizeof(addr)); in create_wildcard_listeners()
341 addr.in.sin_family = AF_INET; in create_wildcard_listeners()
342 addr.in.sin_addr.s_addr = INADDR_ANY; in create_wildcard_listeners()
343 addr.in.sin_port = htons(daemon->port); in create_wildcard_listeners()
345 addr.in.sin_len = sizeof(struct sockaddr_in); in create_wildcard_listeners()
356 bind(tcpfd, (struct sockaddr *)&addr, sa_len(&addr)) == -1 || in create_wildcard_listeners()
370 bind(fd, (struct sockaddr *)&addr, sa_len(&addr)) == -1) in create_wildcard_listeners()
377 addr.in.sin_port = htons(TFTP_PORT); in create_wildcard_listeners()
388 bind(tftpfd, (struct sockaddr *)&addr, sa_len(&addr)) == -1) in create_wildcard_listeners()
425 new->family = iface->addr.sa.sa_family; in create_bound_listener()
435 if ((new->tcpfd = socket(iface->addr.sa.sa_family, SOCK_STREAM, 0)) == -1 || in create_bound_listener()
436 (new->fd = socket(iface->addr.sa.sa_family, SOCK_DGRAM, 0)) == -1 || in create_bound_listener()
444 if (iface->addr.sa.sa_family == AF_INET6) in create_bound_listener()
454 if ((rc = bind(new->fd, &iface->addr.sa, sa_len(&iface->addr))) != -1) in create_bound_listener()
463 if (iface->addr.sa.sa_family == AF_INET6 && (errno == ENODEV || errno == EADDRNOTAVAIL) && in create_bound_listener()
473 if (rc == -1 || bind(new->tcpfd, &iface->addr.sa, sa_len(&iface->addr)) == -1) in create_bound_listener()
475 prettyprint_addr(&iface->addr, daemon->namebuff); in create_bound_listener()
484 if ((daemon->options & OPT_TFTP) && iface->addr.sa.sa_family == AF_INET && iface->dhcp_ok) in create_bound_listener()
486 short save = iface->addr.in.sin_port; in create_bound_listener()
487 iface->addr.in.sin_port = htons(TFTP_PORT); in create_bound_listener()
491 bind(new->tftpfd, &iface->addr.sa, sa_len(&iface->addr)) == -1) in create_bound_listener()
493 iface->addr.in.sin_port = save; in create_bound_listener()
515 if (sockaddr_isequal(&listener_iface->addr, &new_iface->addr)) { in fixup_possible_existing_listener()
533 int port = prettyprint_addr(&listener->iface->addr, daemon->namebuff); in delete_listener()
577 if (iface && listener_iface && sockaddr_isequal(&listener_iface->addr, &iface->addr)) { in close_bound_listener()
610 new->family = iface->addr.sa.sa_family; in create_bound_listeners()
620 if ((new->tcpfd = socket(iface->addr.sa.sa_family, SOCK_STREAM, 0)) == -1 || in create_bound_listeners()
621 (new->fd = socket(iface->addr.sa.sa_family, SOCK_DGRAM, 0)) == -1 || in create_bound_listeners()
629 if (iface->addr.sa.sa_family == AF_INET6) in create_bound_listeners()
639 if ((rc = bind(new->fd, &iface->addr.sa, sa_len(&iface->addr))) != -1) in create_bound_listeners()
646 if (iface->addr.sa.sa_family == AF_INET6 && (errno == ENODEV || errno == EADDRNOTAVAIL) && in create_bound_listeners()
656 if (rc == -1 || bind(new->tcpfd, &iface->addr.sa, sa_len(&iface->addr)) == -1) in create_bound_listeners()
658 prettyprint_addr(&iface->addr, daemon->namebuff); in create_bound_listeners()
668 if ((daemon->options & OPT_TFTP) && iface->addr.sa.sa_family == AF_INET && iface->dhcp_ok) in create_bound_listeners()
670 short save = iface->addr.in.sin_port; in create_bound_listeners()
671 iface->addr.in.sin_port = htons(TFTP_PORT); in create_bound_listeners()
675 bind(new->tftpfd, &iface->addr.sa, sa_len(&iface->addr)) == -1) in create_bound_listeners()
677 iface->addr.in.sin_port = save; in create_bound_listeners()
695 union mysockaddr addr; in random_sock() local
699 memset(&addr, 0, sizeof(addr)); in random_sock()
700 addr.sa.sa_family = family; in random_sock()
714 addr.in.sin_addr.s_addr = INADDR_ANY; in random_sock()
715 addr.in.sin_port = port; in random_sock()
717 addr.in.sin_len = sizeof(struct sockaddr_in); in random_sock()
723 addr.in6.sin6_addr = in6addr_any; in random_sock()
724 addr.in6.sin6_port = port; in random_sock()
726 addr.in6.sin6_len = sizeof(struct sockaddr_in6); in random_sock()
731 if (bind(fd, (struct sockaddr *)&addr, sa_len(&addr)) == 0) in random_sock()
745 int local_bind(int fd, union mysockaddr *addr, char *intname, uint32_t mark, int is_tcp) in local_bind() argument
747 union mysockaddr addr_copy = *addr; in local_bind()
775 static struct serverfd *allocate_sfd(union mysockaddr *addr, char *intname, uint32_t mark) in allocate_sfd() argument
786 if (addr->sa.sa_family == AF_INET && in allocate_sfd()
787 addr->in.sin_addr.s_addr == INADDR_ANY && in allocate_sfd()
788 addr->in.sin_port == htons(0)) in allocate_sfd()
792 if (addr->sa.sa_family == AF_INET6 && in allocate_sfd()
793 memcmp(&addr->in6.sin6_addr, &in6addr_any, sizeof(in6addr_any)) == 0 && in allocate_sfd()
794 addr->in6.sin6_port == htons(0)) in allocate_sfd()
801 if (sockaddr_isequal(&sfd->source_addr, addr) && in allocate_sfd()
811 if ((sfd->fd = socket(addr->sa.sa_family, SOCK_DGRAM, 0)) == -1) in allocate_sfd()
817 if (!local_bind(sfd->fd, addr, intname, mark, 0) || !fix_fd(sfd->fd)) in allocate_sfd()
827 sfd->source_addr = *addr; in allocate_sfd()
842 union mysockaddr addr; in pre_allocate_sfds() local
843 memset(&addr, 0, sizeof(addr)); in pre_allocate_sfds()
844 addr.in.sin_family = AF_INET; in pre_allocate_sfds()
845 addr.in.sin_addr.s_addr = INADDR_ANY; in pre_allocate_sfds()
846 addr.in.sin_port = htons(daemon->query_port); in pre_allocate_sfds()
848 addr.in.sin_len = sizeof(struct sockaddr_in); in pre_allocate_sfds()
850 allocate_sfd(&addr, "", 0); in pre_allocate_sfds()
852 memset(&addr, 0, sizeof(addr)); in pre_allocate_sfds()
853 addr.in6.sin6_family = AF_INET6; in pre_allocate_sfds()
854 addr.in6.sin6_addr = in6addr_any; in pre_allocate_sfds()
855 addr.in6.sin6_port = htons(daemon->query_port); in pre_allocate_sfds()
857 addr.in6.sin6_len = sizeof(struct sockaddr_in6); in pre_allocate_sfds()
859 allocate_sfd(&addr, "", 0); in pre_allocate_sfds()
869 prettyprint_addr(&srv->addr, daemon->namebuff); in pre_allocate_sfds()
893 port = prettyprint_addr(&new->addr, daemon->namebuff); in check_servers()
896 if (new->addr.sa.sa_family == AF_INET && in check_servers()
897 new->addr.in.sin_addr.s_addr == 0) in check_servers()
904 if (sockaddr_isequal(&new->addr, &iface->addr)) in check_servers()
1009 if (sockaddr_isequal(&old_iface->addr, &new_iface->addr)) { in set_interfaces()
1020 prettyprint_addr(&old_iface->addr, debug_buff); in set_interfaces()
1039 if(sockaddr_isequal(&old_iface->addr, &new_iface->addr)) { in set_interfaces()
1048 prettyprint_addr(&new_iface->addr, debug_buff); in set_interfaces()
1116 union mysockaddr addr, source_addr; in set_servers() local
1117 memset(&addr, 0, sizeof(addr)); in set_servers()
1120 if (parse_addr(AF_INET, saddr, &addr) == 0) in set_servers()
1122 addr.in.sin_port = htons(NAMESERVER_PORT); in set_servers()
1128 else if (parse_addr(AF_INET6, saddr, &addr) == 0) in set_servers()
1130 addr.in6.sin6_port = htons(NAMESERVER_PORT); in set_servers()
1151 serv->addr = addr; in set_servers()
1215 union mysockaddr addr, source_addr; in reload_servers() local
1225 memset(&addr, 0, sizeof(addr)); in reload_servers()
1228 if (parse_addr(AF_INET, token, &addr) == 0) in reload_servers()
1230 addr.in.sin_port = htons(NAMESERVER_PORT); in reload_servers()
1236 else if (parse_addr(AF_INET6, token, &addr) == 0) in reload_servers()
1238 addr.in6.sin6_port = htons(NAMESERVER_PORT); in reload_servers()
1259 serv->addr = addr; in reload_servers()