|
@@ -1180,13 +1180,12 @@ struct uri_opener mtftp_uri_opener __uri_opener = {
|
1180
|
1180
|
*/
|
1181
|
1181
|
static int tftp_apply_settings ( void ) {
|
1182
|
1182
|
static struct in_addr tftp_server = { 0 };
|
1183
|
|
- struct in_addr last_tftp_server;
|
|
1183
|
+ struct in_addr new_tftp_server;
|
1184
|
1184
|
char uri_string[32];
|
1185
|
1185
|
struct uri *uri;
|
1186
|
1186
|
|
1187
|
1187
|
/* Retrieve TFTP server setting */
|
1188
|
|
- last_tftp_server = tftp_server;
|
1189
|
|
- fetch_ipv4_setting ( NULL, &next_server_setting, &tftp_server );
|
|
1188
|
+ fetch_ipv4_setting ( NULL, &next_server_setting, &new_tftp_server );
|
1190
|
1189
|
|
1191
|
1190
|
/* If TFTP server setting has changed, set the current working
|
1192
|
1191
|
* URI to match. Do it only when the TFTP server has changed
|
|
@@ -1195,18 +1194,19 @@ static int tftp_apply_settings ( void ) {
|
1195
|
1194
|
* an unrelated setting and triggered all the settings
|
1196
|
1195
|
* applicators.
|
1197
|
1196
|
*/
|
1198
|
|
- if ( tftp_server.s_addr != last_tftp_server.s_addr ) {
|
1199
|
|
- if ( tftp_server.s_addr ) {
|
1200
|
|
- snprintf ( uri_string, sizeof ( uri_string ),
|
1201
|
|
- "tftp://%s/", inet_ntoa ( tftp_server ) );
|
1202
|
|
- uri = parse_uri ( uri_string );
|
1203
|
|
- if ( ! uri )
|
1204
|
|
- return -ENOMEM;
|
1205
|
|
- } else {
|
1206
|
|
- uri = NULL;
|
1207
|
|
- }
|
|
1197
|
+ if ( new_tftp_server.s_addr &&
|
|
1198
|
+ ( new_tftp_server.s_addr != tftp_server.s_addr ) ) {
|
|
1199
|
+ DBGC ( &tftp_server, "TFTP server changed %s => ",
|
|
1200
|
+ inet_ntoa ( tftp_server ) );
|
|
1201
|
+ DBGC ( &tftp_server, "%s\n", inet_ntoa ( new_tftp_server ) );
|
|
1202
|
+ snprintf ( uri_string, sizeof ( uri_string ),
|
|
1203
|
+ "tftp://%s/", inet_ntoa ( new_tftp_server ) );
|
|
1204
|
+ uri = parse_uri ( uri_string );
|
|
1205
|
+ if ( ! uri )
|
|
1206
|
+ return -ENOMEM;
|
1208
|
1207
|
churi ( uri );
|
1209
|
1208
|
uri_put ( uri );
|
|
1209
|
+ tftp_server = new_tftp_server;
|
1210
|
1210
|
}
|
1211
|
1211
|
|
1212
|
1212
|
return 0;
|