The attached patch extended the idea of an advertised address so that it is possible to bind such an address to each listen= statement. Syntax-wise, it works like this:
listen=[proto:]host[:port][ AS host[:port]]
This new AS host[:port] syntax binds the advertised address specifically to the corresponding socket_info structure. If such an address is specified, it will be used before the address specified as advertised_address, or set in the set_advertised_address function. If it is not specified, then those methods work as before.
The core has been modified so that address tuples using the advertised address work interchangably with the real address where you'd expect them to. grep_sock_info and find_si have been updated to allow this. Therefore, it is not nexessary to explicitly name your advertised address on an alias= line. The following are now equivalent:
Note we don't specify protocol on the advertised address. The way I see things, it makes no sense to advertise a different protocol, so it inherits the protocol of the socket.
Via construction is affected in the same way that the old global advertised_address does, except the Via is written properly for the socket used to send the message.
Lump substitution is also affected. The following lump substitutions are aware of this new facility:
As a result of this, I was able to stop using record_route_preset, and just use standard record_route. This winds up working much better, because double-rr works properly, and add_rr_param now works as expected for me, where it was a problem using record_route_preset.
Additionally, registrar and usrloc have been modified:
registrar - update the add_sock_hdr function to put the advertised address in the message instead of the real address. This allows registration information to be replicated between multi-homed proxies, and the correct interface on the peer can be used.
usrloc - update db_insert_ucontact to store the advertised address in the database instead of the real address. Same reasoning as the mods to registrar.
This code was originaly written for 1.1.x, and I've been using it quite happily for about a year now. I ported it to 1.2 with the hope of getting it submitted for 1.3, but time got the better of me. I've now ported this to HEAD, and have tested that the functionality still works as compared to in my production 1.1.1 setup. So at this point, I'd like to get this patch in here and hopefully someone can think about it for 1.4.
Any constructive comments on the functionality of the implementation would also be welcome.
Here is a (hopefully complete) breakdown of the modified files. No files were added:
cfg.lex - new listen syntax
cfg.y - new listen syntax
ip_addr.h - socket_info and socket_id expanded to hold the advertised address data.
main.c - update for new add_listen_iface prototype
msg_translator.c - lump and via support.
socket_info.[ch] - add_listen_interface updated to accept the advertised information, and socket2str expanded to accept a flag to request the real address or the advertised address
socket_info.c - grep_sock_info and find_si updated to work with the advertised addresses.
modules/lcr/lcr_mod.c - updated to call socket2str the new way.
modules/registrar/reg_mod.c - update to place the advertised address in the socket info header.
modules/usrloc/ucontact.c - updated to save the advertised address in the database.
modules/usrloc/ul_mi.c - updated to return the advertised address of the socket.