Now that we have learned how to use force_rport()
to allow the return of the message to the right IP address and UDP port, let's see how to handle REGISTER requests and allow the UAC to receive calls behind a NAT device. When a UAC sends a REGISTER request we will do the following actions:
Test if the UAC is behind NAT (this can be done using
client_nat_test()
) and if the request is not to unregister all contacts (using * in the contact header field).Force the use of the rport field to reply to the right IP address and UDP port back to the UAC.
If the UAC is behind NAT we will fix the REGISTER using
fix_nated_register()
to request the insertion of the received IP address and UDP port into the location table.Keep the NAT mappings open using the
natping
parameter of the MediaProxy module after the first registration. This parameter is used to set the interval between sending UDP packets, to keep the NAT mappings open. Ping is used to test the connectivity...