1040 | | If the machine is multihomed (such as when VPN is used), PJSIP will use the following logic to determine which IP address is used for the Contact and Via header. |
1041 | | |
1042 | | First of all, by default PJSIP binds sockets to INADDR_ANY (0.0.0.0), so it will be able to send and receive to/from any destinations configured in the system. |
| 1040 | If the machine is multihomed (such as when VPN is used), PJSIP will use the following logic to determine which '''initial''' IP address is used for the Contact and Via header. This was implemented in ticket #1412 for version 2.1. |
| 1041 | |
| 1042 | The initial value will take into account whether STUN is enabled or disabled in the account. If it is enabled, the STUN address will be used. If it is disabled, local IP will be used. For UDP transport, if STUN is not used or disabled for the account, an attempt will be made to use the correct IP interface to be placed in the Contact URI, by querying the OS about the interface to send to the destination. This would work well for LAN destinations; if the destination is across the Internet, then whatever interface that is used to connect to it will be used by PJSIP. Thus the selected address would depend on the OS routing. Note that this is OS behavior and not PJSIP. |
| 1043 | |
| 1044 | No change for TCP; the correct IP has already been selected in the Contact URI. |
| 1045 | |
| 1046 | If registration is enabled, the correct address of Contact and Via header are by default recalculated again by looking at the REGISTER response. Please see the documentation of {{{allow_contact_rewrite}}} and {{{allow_via_rewrite}}} in the {{{pjsua_acc_config}}}. |
| 1047 | |
| 1048 | |
| 1049 | === The pj_gethostip() algorithm === |
| 1050 | |
| 1051 | This is only for reference. |