compilation with 'T' fixed
This commit is contained in:
@@ -42,8 +42,8 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
#if defined (LOG_D) && defined (LOG_E)
|
#if defined (LOG_D) && defined (LOG_E)
|
||||||
# define SIG_DEBUG(x, args...) LOG_D(SIM, x, ##args)
|
# define SIG_DEBUG(x, args...) LOG_D(RRC, x, ##args)
|
||||||
# define SIG_ERROR(x, args...) LOG_E(SIM, x, ##args)
|
# define SIG_ERROR(x, args...) LOG_E(RRC, x, ##args)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SIG_DEBUG
|
#ifndef SIG_DEBUG
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ multicast_link_init(void)
|
|||||||
SOCK_DGRAM,
|
SOCK_DGRAM,
|
||||||
&group_list[group].port, &sin);
|
&group_list[group].port, &sin);
|
||||||
|
|
||||||
LOG_D(SIM, "multicast_link_init(): Created socket %d for group %d, port %d\n",
|
LOG_D(PHY, "multicast_link_init(): Created socket %d for group %d, port %d\n",
|
||||||
group_list[group].socket,group,group_list[group].port);
|
group_list[group].socket,group,group_list[group].port);
|
||||||
|
|
||||||
/* Used so we can re-bind to our port while a previous connection is still
|
/* Used so we can re-bind to our port while a previous connection is still
|
||||||
@@ -107,17 +107,17 @@ multicast_link_init(void)
|
|||||||
*/
|
*/
|
||||||
if (setsockopt(group_list[group].socket, SOL_SOCKET, SO_REUSEADDR,
|
if (setsockopt(group_list[group].socket, SOL_SOCKET, SO_REUSEADDR,
|
||||||
&reuse_addr, sizeof (reuse_addr)) < 0) {
|
&reuse_addr, sizeof (reuse_addr)) < 0) {
|
||||||
LOG_E(SIM, "[MULTICAST] ERROR : setsockopt:SO_REUSEADDR, exiting ...");
|
LOG_E(PHY, "[MULTICAST] ERROR : setsockopt:SO_REUSEADDR, exiting ...");
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (multicast_if != NULL) {
|
if (multicast_if != NULL) {
|
||||||
if (setsockopt(group_list[group].socket, SOL_SOCKET,SO_BINDTODEVICE,
|
if (setsockopt(group_list[group].socket, SOL_SOCKET,SO_BINDTODEVICE,
|
||||||
multicast_if, strlen(multicast_if)) < 0) {
|
multicast_if, strlen(multicast_if)) < 0) {
|
||||||
LOG_E(SIM,
|
LOG_E(PHY,
|
||||||
"[MULTICAST] ERROR : setsockopt:SO_BINDTODEVICE on interface %s, exiting ...\n",
|
"[MULTICAST] ERROR : setsockopt:SO_BINDTODEVICE on interface %s, exiting ...\n",
|
||||||
multicast_if);
|
multicast_if);
|
||||||
LOG_E(SIM,
|
LOG_E(PHY,
|
||||||
"[MULTICAST] make sure that you have a root privilage or run with sudo -E \n");
|
"[MULTICAST] make sure that you have a root privilage or run with sudo -E \n");
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@ multicast_link_init(void)
|
|||||||
|
|
||||||
if (setsockopt (group_list[group].socket, IPPROTO_IP, IP_MULTICAST_LOOP,
|
if (setsockopt (group_list[group].socket, IPPROTO_IP, IP_MULTICAST_LOOP,
|
||||||
&multicast_loop, sizeof (multicast_loop)) < 0) {
|
&multicast_loop, sizeof (multicast_loop)) < 0) {
|
||||||
LOG_E(SIM,
|
LOG_E(PHY,
|
||||||
"[MULTICAST] ERROR: %s line %d multicast_link_main_loop() IP_MULTICAST_LOOP %m",
|
"[MULTICAST] ERROR: %s line %d multicast_link_main_loop() IP_MULTICAST_LOOP %m",
|
||||||
__FILE__, __LINE__);
|
__FILE__, __LINE__);
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
@@ -143,13 +143,13 @@ multicast_link_init(void)
|
|||||||
command.imr_interface.s_addr = htonl (INADDR_ANY);
|
command.imr_interface.s_addr = htonl (INADDR_ANY);
|
||||||
|
|
||||||
if (command.imr_multiaddr.s_addr == -1) {
|
if (command.imr_multiaddr.s_addr == -1) {
|
||||||
LOG_E(SIM, "[MULTICAST] ERROR: %s line %d NO MULTICAST", __FILE__, __LINE__);
|
LOG_E(PHY, "[MULTICAST] ERROR: %s line %d NO MULTICAST", __FILE__, __LINE__);
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setsockopt (group_list[group].socket, IPPROTO_IP, IP_ADD_MEMBERSHIP,
|
if (setsockopt (group_list[group].socket, IPPROTO_IP, IP_ADD_MEMBERSHIP,
|
||||||
&command, sizeof (command)) < 0) {
|
&command, sizeof (command)) < 0) {
|
||||||
LOG_E(SIM, "[MULTICAST] ERROR: %s line %d IP_ADD_MEMBERSHIP %m", __FILE__,
|
LOG_E(PHY, "[MULTICAST] ERROR: %s line %d IP_ADD_MEMBERSHIP %m", __FILE__,
|
||||||
__LINE__);
|
__LINE__);
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@@ -202,13 +202,13 @@ multicast_link_read_data (int groupP)
|
|||||||
if ((groupP < MULTICAST_LINK_NUM_GROUPS) && (groupP >= 0)) {
|
if ((groupP < MULTICAST_LINK_NUM_GROUPS) && (groupP >= 0)) {
|
||||||
if ((num_bytes = recvfrom (group_list[groupP].socket,
|
if ((num_bytes = recvfrom (group_list[groupP].socket,
|
||||||
group_list[groupP].rx_buffer, 40000, 0, 0, 0)) < 0) {
|
group_list[groupP].rx_buffer, 40000, 0, 0, 0)) < 0) {
|
||||||
LOG_E(SIM, "[MULTICAST] recvfrom has failed (%d:%s)\n (%s:%d)\n",
|
LOG_E(PHY, "[MULTICAST] recvfrom has failed (%d:%s)\n (%s:%d)\n",
|
||||||
errno, strerror(errno), __FILE__, __LINE__);
|
errno, strerror(errno), __FILE__, __LINE__);
|
||||||
} else {
|
} else {
|
||||||
rx_handler(num_bytes,group_list[groupP].rx_buffer);
|
rx_handler(num_bytes,group_list[groupP].rx_buffer);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG_E(SIM, "[MULTICAST] ERROR: groupP out of bounds %d\n", groupP);
|
LOG_E(PHY, "[MULTICAST] ERROR: groupP out of bounds %d\n", groupP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +242,7 @@ multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP)
|
|||||||
if ((num = sendto (group_list[groupP].socket, dataP, sizeP, 0,
|
if ((num = sendto (group_list[groupP].socket, dataP, sizeP, 0,
|
||||||
(struct sockaddr *) &group_list[groupP].sock_remote_addr,
|
(struct sockaddr *) &group_list[groupP].sock_remote_addr,
|
||||||
sizeof (group_list[groupP].sock_remote_addr))) < 0) {
|
sizeof (group_list[groupP].sock_remote_addr))) < 0) {
|
||||||
LOG_E(SIM, "[MULTICAST] sendto has failed (%d:%s)\n (%s:%d)\n",
|
LOG_E(PHY, "[MULTICAST] sendto has failed (%d:%s)\n (%s:%d)\n",
|
||||||
errno, strerror(errno),
|
errno, strerror(errno),
|
||||||
__FILE__, __LINE__);
|
__FILE__, __LINE__);
|
||||||
}
|
}
|
||||||
@@ -274,22 +274,19 @@ int multicast_link_read_data_from_sock(uint8_t is_master)
|
|||||||
|
|
||||||
multicast_link_build_select_list ();
|
multicast_link_build_select_list ();
|
||||||
|
|
||||||
LOG_D(SIM, "Stuck on select with timeout %s\n",
|
LOG_D(PHY, "Stuck on select with timeout %s\n",
|
||||||
timeout_p == NULL ? "infinite" : "15000 usecs");
|
timeout_p == NULL ? "infinite" : "15000 usecs");
|
||||||
|
|
||||||
readsocks = select(highsock + 1, &socks, (fd_set *) 0, (fd_set *) 0, timeout_p);
|
readsocks = select(highsock + 1, &socks, (fd_set *) 0, (fd_set *) 0, timeout_p);
|
||||||
|
|
||||||
if (readsocks < 0) {
|
if (readsocks < 0) {
|
||||||
LOG_E(SIM, "Multicast select failed (%d:%s)\n", errno, strerror(errno));
|
LOG_E(PHY, "Multicast select failed (%d:%s)\n", errno, strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
} else if (readsocks > 0) {
|
} else if (readsocks > 0) {
|
||||||
#ifdef DEBUG_SIM
|
|
||||||
LOG_D(SIM, "Multicast Normal read\n");
|
|
||||||
#endif
|
|
||||||
multicast_link_read();
|
multicast_link_read();
|
||||||
} else {
|
} else {
|
||||||
/* Timeout */
|
/* Timeout */
|
||||||
LOG_I(SIM, "Multicast select time-out\n");
|
LOG_I(PHY, "Multicast select time-out\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,21 +308,21 @@ void multicast_link_start(void (*rx_handlerP) (unsigned int, char *),
|
|||||||
rx_handler = rx_handlerP;
|
rx_handler = rx_handlerP;
|
||||||
multicast_group = _multicast_group;
|
multicast_group = _multicast_group;
|
||||||
multicast_if = multicast_ifname;
|
multicast_if = multicast_ifname;
|
||||||
LOG_I(SIM, "[MULTICAST] LINK START on interface=%s for group=%d: handler=%p\n",
|
LOG_I(PHY, "[MULTICAST] LINK START on interface=%s for group=%d: handler=%p\n",
|
||||||
(multicast_if == NULL) ? "not specified" : multicast_if, multicast_group,
|
(multicast_if == NULL) ? "not specified" : multicast_if, multicast_group,
|
||||||
rx_handler);
|
rx_handler);
|
||||||
multicast_link_init ();
|
multicast_link_init ();
|
||||||
#if ! defined(ENABLE_NEW_MULTICAST)
|
#if ! defined(ENABLE_NEW_MULTICAST)
|
||||||
LOG_D(SIM, "[MULTICAST] multicast link start thread\n");
|
LOG_D(PHY, "[MULTICAST] multicast link start thread\n");
|
||||||
|
|
||||||
if (pthread_create (&main_loop_thread, NULL, multicast_link_main_loop,
|
if (pthread_create (&main_loop_thread, NULL, multicast_link_main_loop,
|
||||||
NULL) != 0) {
|
NULL) != 0) {
|
||||||
LOG_E(SIM, "[MULTICAST LINK] Error in pthread_create (%d:%s)\n",
|
LOG_E(PHY, "[MULTICAST LINK] Error in pthread_create (%d:%s)\n",
|
||||||
errno, strerror(errno));
|
errno, strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
} else {
|
} else {
|
||||||
pthread_detach(main_loop_thread); // disassociate from parent
|
pthread_detach(main_loop_thread); // disassociate from parent
|
||||||
LOG_I(SIM, "[MULTICAST LINK] Thread detached\n");
|
LOG_I(PHY, "[MULTICAST LINK] Thread detached\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user