use same_sockaddr()
This commit is contained in:
parent
4709dd9f6d
commit
0b68a8b0f9
@ -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);
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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_ */
|
||||
|
Loading…
Reference in New Issue
Block a user