[Asterisk-bsd] Re: One way calling... NetBSD, sipphone or NAT problem?

Tom Ivar Helbekkmo tih at eunetnorge.no
Tue Oct 12 02:22:34 CDT 2004


Jay Adelson <jay at adelson.org> writes:

> I also get this error repeatedly, only when the bindaddr is 0.0.0.0:
>
> Oct 11 16:55:22 ERROR[1262485504]: acl.c:265 ast_ouraddrfor: Error writing to routing socket: Invalid argument

A quick look at the implementation of ast_ouraddrfor() under BSD shows
up a bug in the building of the query that's sent to the routing
socket -- it claims to pass two address structures, but only actually
passes one.  Try this patch:

Index: acl.c
===================================================================
RCS file: /usr/cvsroot/asterisk/acl.c,v
retrieving revision 1.27
diff -u -r1.27 acl.c
--- acl.c	30 Jun 2004 16:56:51 -0000	1.27
+++ acl.c	12 Oct 2004 07:18:47 -0000
@@ -248,14 +248,14 @@
 	seq = ++routeseq;
 	ast_mutex_unlock(&routeseq_lock);
 	m_rtmsg.m_rtm.rtm_seq = seq;
-	m_rtmsg.m_rtm.rtm_addrs = RTA_IFA | RTA_DST;
+	m_rtmsg.m_rtm.rtm_addrs = RTA_DST;
 	m_rtmsg.m_rtm.rtm_msglen = sizeof(struct rt_msghdr) + sizeof(struct sockaddr_in);
 	sin = (struct sockaddr_in *)m_rtmsg.m_space;
 	sin->sin_family = AF_INET;
 	sin->sin_len = sizeof(struct sockaddr_in);
 	sin->sin_addr = *them;
 
-	if ((s = socket(PF_ROUTE, SOCK_RAW, 0)) < 0) {
+	if ((s = socket(PF_ROUTE, SOCK_RAW, AF_UNSPEC)) < 0) {
 		ast_log(LOG_ERROR, "Error opening routing socket\n");
 		return -1;
 	}

The change from 0 to AF_UNSPEC is actually just me being pedantic; the
point is that there is no interface address structure passed, so we
mustn't claim that there is.

-tih
-- 
Tom Ivar Helbekkmo, Senior System Administrator, EUnet Norway Hosting
www.eunet.no  T +47-22092958 M +47-93013940 F +47-22092901 FWD 484145


More information about the Asterisk-BSD mailing list