use same_sockaddr()

This commit is contained in:
Olaf Rempel 2007-07-14 15:26:31 +02:00
parent 4709dd9f6d
commit 0b68a8b0f9
3 changed files with 10 additions and 4 deletions

View File

@ -269,10 +269,7 @@ int ctcs_httpd_quit(struct httpd_con *con, void *privdata)
list_for_each_entry(torrent, &torrent_list, list) {
struct client_con *search;
list_for_each_entry(search, &torrent->client_list, list) {
if (search->addr.sin_addr.s_addr != addr.sin_addr.s_addr)
continue;
if (search->addr.sin_port != addr.sin_port)
if (!same_sockaddr(&search->addr, &addr))
continue;
write(event_get_fd(search->event), "CTQUIT\n", 7);

View File

@ -90,3 +90,10 @@ char * get_sockaddr_buf(struct sockaddr_in *addr)
get_sockaddr(ret, sizeof(ret), addr);
return ret;
}
int same_sockaddr(struct sockaddr_in *a, struct sockaddr_in *b)
{
return !((a->sin_family ^ b->sin_family) |
(a->sin_addr.s_addr ^ b->sin_addr.s_addr) |
(a->sin_port ^ b->sin_port));
}

View File

@ -9,4 +9,6 @@ int parse_subnet(const char *addr, struct in_addr *net, struct in_addr *mask);
int get_sockaddr(char *buf, int size, struct sockaddr_in *addr);
char * get_sockaddr_buf(struct sockaddr_in *addr);
int same_sockaddr(struct sockaddr_in *a, struct sockaddr_in *b);
#endif /* _SOCKADDR_H_ */