*/
static int tftp_apply_settings ( void ) {
static struct in_addr tftp_server = { 0 };
- struct in_addr last_tftp_server;
+ struct in_addr new_tftp_server;
char uri_string[32];
struct uri *uri;
/* Retrieve TFTP server setting */
- last_tftp_server = tftp_server;
- fetch_ipv4_setting ( NULL, &next_server_setting, &tftp_server );
+ fetch_ipv4_setting ( NULL, &next_server_setting, &new_tftp_server );
/* If TFTP server setting has changed, set the current working
* URI to match. Do it only when the TFTP server has changed
* an unrelated setting and triggered all the settings
* applicators.
*/
- if ( tftp_server.s_addr != last_tftp_server.s_addr ) {
- if ( tftp_server.s_addr ) {
- snprintf ( uri_string, sizeof ( uri_string ),
- "tftp://%s/", inet_ntoa ( tftp_server ) );
- uri = parse_uri ( uri_string );
- if ( ! uri )
- return -ENOMEM;
- } else {
- uri = NULL;
- }
+ if ( new_tftp_server.s_addr &&
+ ( new_tftp_server.s_addr != tftp_server.s_addr ) ) {
+ DBGC ( &tftp_server, "TFTP server changed %s => ",
+ inet_ntoa ( tftp_server ) );
+ DBGC ( &tftp_server, "%s\n", inet_ntoa ( new_tftp_server ) );
+ snprintf ( uri_string, sizeof ( uri_string ),
+ "tftp://%s/", inet_ntoa ( new_tftp_server ) );
+ uri = parse_uri ( uri_string );
+ if ( ! uri )
+ return -ENOMEM;
churi ( uri );
uri_put ( uri );
+ tftp_server = new_tftp_server;
}
return 0;