mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-19 19:52:48 +00:00
Route fixes for OpenBSD (bug #415)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1655 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
9
acl.c
9
acl.c
@@ -30,6 +30,7 @@
|
|||||||
#include <netinet/ip.h>
|
#include <netinet/ip.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#ifdef __OpenBSD__
|
#ifdef __OpenBSD__
|
||||||
|
#include <fcntl.h>
|
||||||
#include <net/route.h>
|
#include <net/route.h>
|
||||||
|
|
||||||
static ast_mutex_t routeseq_lock = AST_MUTEX_INITIALIZER;
|
static ast_mutex_t routeseq_lock = AST_MUTEX_INITIALIZER;
|
||||||
@@ -172,7 +173,7 @@ int ast_ouraddrfor(struct in_addr *them, struct in_addr *us)
|
|||||||
char m_space[512];
|
char m_space[512];
|
||||||
} m_rtmsg;
|
} m_rtmsg;
|
||||||
char *cp, *p = ast_strdupa(inet_ntoa(*them));
|
char *cp, *p = ast_strdupa(inet_ntoa(*them));
|
||||||
int i, l, s, seq;
|
int i, l, s, seq, flags;
|
||||||
pid_t pid = getpid();
|
pid_t pid = getpid();
|
||||||
static int routeseq; /* Protected by "routeseq_lock" mutex */
|
static int routeseq; /* Protected by "routeseq_lock" mutex */
|
||||||
|
|
||||||
@@ -197,6 +198,8 @@ int ast_ouraddrfor(struct in_addr *them, struct in_addr *us)
|
|||||||
ast_log(LOG_ERROR, "Error opening routing socket\n");
|
ast_log(LOG_ERROR, "Error opening routing socket\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
flags = fcntl(s, F_GETFL);
|
||||||
|
fcntl(s, F_SETFL, flags | O_NONBLOCK);
|
||||||
if (write(s, (char *)&m_rtmsg, m_rtmsg.m_rtm.rtm_msglen) < 0) {
|
if (write(s, (char *)&m_rtmsg, m_rtmsg.m_rtm.rtm_msglen) < 0) {
|
||||||
ast_log(LOG_ERROR, "Error writing to routing socket: %s\n", strerror(errno));
|
ast_log(LOG_ERROR, "Error writing to routing socket: %s\n", strerror(errno));
|
||||||
close(s);
|
close(s);
|
||||||
@@ -205,11 +208,13 @@ int ast_ouraddrfor(struct in_addr *them, struct in_addr *us)
|
|||||||
do {
|
do {
|
||||||
l = read(s, (char *)&m_rtmsg, sizeof(m_rtmsg));
|
l = read(s, (char *)&m_rtmsg, sizeof(m_rtmsg));
|
||||||
} while (l > 0 && (m_rtmsg.m_rtm.rtm_seq != 1 || m_rtmsg.m_rtm.rtm_pid != pid));
|
} while (l > 0 && (m_rtmsg.m_rtm.rtm_seq != 1 || m_rtmsg.m_rtm.rtm_pid != pid));
|
||||||
close(s);
|
|
||||||
if (l < 0) {
|
if (l < 0) {
|
||||||
|
if (errno != EAGAIN)
|
||||||
ast_log(LOG_ERROR, "Error reading from routing socket\n");
|
ast_log(LOG_ERROR, "Error reading from routing socket\n");
|
||||||
|
close(s);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
close(s);
|
||||||
|
|
||||||
if (m_rtmsg.m_rtm.rtm_version != RTM_VERSION) {
|
if (m_rtmsg.m_rtm.rtm_version != RTM_VERSION) {
|
||||||
ast_log(LOG_ERROR, "Unsupported route socket protocol version\n");
|
ast_log(LOG_ERROR, "Unsupported route socket protocol version\n");
|
||||||
|
Reference in New Issue
Block a user