minor checks on PCPSendUnsolicitedAnnounce()

This commit is contained in:
Thomas Bernard 2020-06-04 00:56:16 +02:00
parent 45191081f1
commit f151cc1dd4
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
1 changed files with 5 additions and 2 deletions

View File

@ -1,7 +1,7 @@
/* $Id: pcpserver.c,v 1.51 2019/05/21 08:39:44 nanard Exp $ */ /* $Id: pcpserver.c,v 1.51 2019/05/21 08:39:44 nanard Exp $ */
/* vim: tabstop=4 shiftwidth=4 noexpandtab /* vim: tabstop=4 shiftwidth=4 noexpandtab
* MiniUPnP project * MiniUPnP project
* Website : http://miniupnp.free.fr/ * Website : http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
* Author : Peter Tatrai * Author : Peter Tatrai
Copyright (c) 2013 by Cisco Systems, Inc. Copyright (c) 2013 by Cisco Systems, Inc.
@ -1682,9 +1682,12 @@ void PCPSendUnsolicitedAnnounce(int * sockets, int n_sockets)
addr.sin_addr.s_addr = inet_addr("224.0.0.1"); addr.sin_addr.s_addr = inet_addr("224.0.0.1");
addr.sin_port = htons(5350); addr.sin_port = htons(5350);
for(i = 0; i < n_sockets; i++) { for(i = 0; i < n_sockets; i++) {
if (sockets[i] < 0) {
continue;
}
len = sendto_or_schedule(sockets[i], buff, PCP_MIN_LEN, 0, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)); len = sendto_or_schedule(sockets[i], buff, PCP_MIN_LEN, 0, (struct sockaddr *)&addr, sizeof(struct sockaddr_in));
if( len < 0 ) { if( len < 0 ) {
syslog(LOG_ERR, "PCPSendUnsolicitedAnnounce() sendto(): %m"); syslog(LOG_ERR, "PCPSendUnsolicitedAnnounce(sockets[%d]) sendto(): %m", i);
} }
} }
#ifdef ENABLE_IPV6 #ifdef ENABLE_IPV6