Summary:ASTERISK-04157: [patch] iax: explicit source address selection in peer declaration
Reporter:mikma (mikma)Labels:
Date Opened:2005-05-13 05:13:07Date Closed:2008-01-15 15:40:55.000-0600
Versions:Frequency of
Environment:Attachments:( 0) sourceaddress2.patch
( 1) sourceaddress2b.patch
( 2) sourceaddress3.patch
( 3) sourceaddress4.patch
Description:With this patch it's possible to select an explicit source address to
be used when communicating with a peer. It's accomplished by declaring
the source address both in a global "bindaddr" and in the peer's
"sourceaddress". The default socket will be used instead (and a
warning displayed), if the address in the "sourceaddress" statement
isn't bound.

Usage scenario:

Several peer entries that point to the same server/provider but with
different properties, for example codecs, needs to be routed or in
other ways handled differently depending on peer entry.


This is an implementation of the second part of the "Asterisk Bounty IAX2"
Comments:By: Olle Johansson (oej) 2005-05-13 08:35:01

Is this code disclaimed?

By: mikma (mikma) 2005-05-13 14:57:13

Yes, I have faxed a disclaimer today.

By: Kevin P. Fleming (kpfleming) 2005-05-14 19:43:57

Why do you need the check_srcaddr() function at all? Even if it returned a value indicating that the address is bind-able, if we aren't already bound to that address then you ignore the result anyway... Can't you just search the netsock list, and if the requested address is present then proceed from there?

By: mikma (mikma) 2005-05-15 06:51:40

The function is needed during reload. It will discover if the requested ip-address has been deleted since Asterisk started and then use the default socket instead of a socket that is unusable.

By: Kevin P. Fleming (kpfleming) 2005-05-15 12:00:55

Wouldn't it be far better to just drop the netsock that is no longer usable then, prior to handling the srcaddr for each peer? There's no value in keeping a netsock open that is not actually functional :-)

By: mikma (mikma) 2005-05-15 13:52:07

I think it's useful not to close the socket, since it will be functional if the ip-address is added to an interface again. Otherwise you will have to restart Asterisk to use the address.

By: Kevin P. Fleming (kpfleming) 2005-05-15 13:57:52

Hm.... but then the peer won't be using the desired address until you reload again, right? I guess that's not so bad. It's not a common occurrence, anyway.

By: Kevin P. Fleming (kpfleming) 2005-05-15 14:02:27

There is another issue here... the 'bindaddr' option takes both an address and a port, which means there could be multiple netsocks open on a single address, on different ports, none of them defaultsockfd port. Should the 'sourceaddress' option also accept a port number?

By: mikma (mikma) 2005-05-15 17:22:12

I have added a "sourceport" option that works as "bindport" and specifies the port for the following "sourceaddress" option in an updated patch.

By: Kevin P. Fleming (kpfleming) 2005-05-15 18:06:39

I would rather see the sourceaddress option take an "address:port" pair, rather than using two separate options (since bindaddr already accepts "address:port" pairs and that's a preferable method over using bindport/bindaddr anyway). Otherwise I think this is ready to go in.

By: mikma (mikma) 2005-05-16 05:15:36

I have uploaded another patch that permits sourceaddress options containing both host address and port number ("address:port"). The patch should be used in addition to sourceaddress2.patch.

By: Michael Jerris (mikej) 2005-06-23 06:31:37

This has passed all the reviews except for testing.  Can we please get a single patch updated for head.

By: mikma (mikma) 2005-06-29 17:04:40

Uploaded sourceaddress4.patch that combines sourceaddress2.patch and sourceaddress2b.patch and updated for HEAD.

By: Michael Jerris (mikej) 2005-06-29 17:15:38

If you could please get some people other than you to test this and post results to this bug, we will be able to commit this.

By: kb1_kanobe2 (kb1_kanobe2) 2005-06-29 19:09:56

As I was the source of the bounty for this facility I will apply the updated patch and run testing over the next few days. Others are of course also welcome to test in their environments...

mikma - thanks for keeping it up to date.

By: Kevin P. Fleming (kpfleming) 2005-07-11 22:11:51

Committed to CVS HEAD with minor mods (code simplification). Thanks!

By: Digium Subversion (svnbot) 2008-01-15 15:40:55.000-0600

Repository: asterisk
Revision: 6096

U   trunk/acl.c
U   trunk/channels/chan_iax2.c
U   trunk/include/asterisk/acl.h

r6096 | kpfleming | 2008-01-15 15:40:55 -0600 (Tue, 15 Jan 2008) | 2 lines

allow explicit source address/port selection for peers (bug ASTERISK-4157, with minor mods)